Maybe is it a good idea to highlight the entire object?
The most easy way to do is to make an Class that implements SceneProcessor. Such renderer should have an setObjectForHighlight or addObjectForHighlight, I dont know if you need to highlight just one or more objects at a time. Anyway, in postFrame you need to test if the object is on viewport’s queue, if so:
in the Shaderblow plugin I think there is an outline capability directly in the lighting shader.
unofrtunately Google decided to make google code painful so you can’t consult the code online anymore because there are too much sub folders in the ocntribution repo…so you either have to checkout the SVN repo, either to use the plugin int he SDK and look at the code
Edit look for lightBlow.j3md
Hi, thanks. I suppose I could do that. The only issue is, I’m using color to distinguish between players (I’m making an RTS), so changing the entire color is not the best approach.
What I mean is that, changing the entire color of the object is not a good idea because of UX (user experience) since the color of the object serves a purpose (to distinguish players). I’m working on implementing this though for testing purposes.
Start simple and move to more complex techniques if you are not happy.
Not perfect, but easy as hell. (Might be better to scale the highlight mesh on the shader in the direction of the normal)
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.light.AmbientLight;
import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
/**
* test
* @author normenhansen
*/
public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
Spatial jaime = this.assetManager.loadModel("Models/Jaime/Jaime.j3o");
Material unshaded=new Material(this.assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
Spatial jaimeClone=jaime.clone();
unshaded.setColor("Color", ColorRGBA.Blue);
unshaded.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Front);
jaimeClone.setMaterial(unshaded);
jaimeClone.scale(1.02f);
jaimeClone.move(0, -0.01f,0);
rootNode.attachChild(jaime);
rootNode.attachChild(jaimeClone);
/** A white ambient light source. */
AmbientLight ambient = new AmbientLight();
ambient.setColor(ColorRGBA.White);
rootNode.addLight(ambient);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
I did one of these a while ago. I think it was just a case of flagging the vertices whos normals are perpendicular to the camera direction and then setting them a different/modified colour in the fragment shader.