does anybody know why my two boxes source1 and source2 aren't green and orange? they are only black, grey and white
im really desperated!! thx
package src;
import java.net.URL;
import java.util.HashMap;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.input.ChaseCamera;
import com.jme.input.ThirdPersonHandler;
import com.jme.light.PointLight;
import com.jme.math.FastMath;
import com.jme.math.Ray;
import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;
import com.jme.scene.state.CullState;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;
import com.jme.scene.state.ZBufferState;
import com.jme.util.TextureManager;
public class CP_Controller extends SimpleGame {
private CP_Controller controller;
private Node m_character;
private ChaseCamera chaser;
private PointLight light;
private Node floorNode;
private Node boxNode;
public void init(CP_Controller controller) {
this.controller = controller;
controller.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
controller.start();
}
@Override
protected void simpleInitGame() {
ZBufferState buf = display.getRenderer().createZBufferState();
buf.setEnabled(true);
buf.setFunction(ZBufferState.CF_LEQUAL);
rootNode.setRenderState(buf);
light = new PointLight();
light.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
light.setLocation(new Vector3f(0f,10f,15f));
light.setEnabled(true);
LightState ls = display.getRenderer().createLightState();
ls.attach(light);
lightState.detachAll();
boxNode = new Node("BoxNode");
setupCharacter();
setupTerrain();
setupChaseCamera();
setupInput();
setupTestData();
rootNode.setRenderState(ls);
rootNode.attachChild(boxNode);
}
protected void simpleUpdate() {
chaser.update(tpf);
float camMinHeight = 2f;
if (!Float.isInfinite(camMinHeight) && !Float.isNaN(camMinHeight)
&& cam.getLocation().y <= camMinHeight) {
cam.getLocation().y = camMinHeight;
cam.update();
}
float characterMinHeight = 2f;
if (!Float.isInfinite(characterMinHeight) && !Float.isNaN(characterMinHeight)) {
m_character.getLocalTranslation().y = characterMinHeight;
}
}
private void setupInput() {
HashMap<String, Object> handlerProps = new HashMap<String, Object>();
handlerProps.put(ThirdPersonHandler.PROP_DOGRADUAL, "true");
handlerProps.put(ThirdPersonHandler.PROP_TURNSPEED, ""+(1.0f * FastMath.PI));
handlerProps.put(ThirdPersonHandler.PROP_LOCKBACKWARDS, "false");
handlerProps.put(ThirdPersonHandler.PROP_CAMERAALIGNEDMOVE, "true");
input = new ThirdPersonHandler(m_character, cam, handlerProps);
input.setActionSpeed(100f);
}
private void setupChaseCamera() {
Vector3f targetOffset = new Vector3f();
targetOffset.y = (((BoundingBox) m_character.getWorldBound()).yExtent+10) * 1.5f;
targetOffset.x = (((BoundingBox) m_character.getWorldBound()).xExtent+10) * 1.5f;
targetOffset.z = (((BoundingBox) m_character.getWorldBound()).zExtent+10) * 1.5f;
chaser = new ChaseCamera(cam, m_character);
chaser.setTargetOffset(targetOffset);
}
private void setupTerrain() {
rootNode.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
fpsNode.setRenderQueueMode(Renderer.QUEUE_ORTHO);
display.getRenderer().setBackgroundColor(ColorRGBA.blue);
CullState cs = display.getRenderer().createCullState();
cs.setCullMode(CullState.CS_BACK);
cs.setEnabled(true);
rootNode.setRenderState(cs);
URL monkeyLoc;
monkeyLoc = CP_Controller.class.getClassLoader().getResource("data/Grid.png");
TextureState ts = display.getRenderer().createTextureState();
Texture t = TextureManager.loadTexture(monkeyLoc, Texture.MM_LINEAR, Texture.FM_LINEAR);
ts.setTexture(t);
for (int i = 1; i < 5; i++) {
for (int j = 1; j < 5; j++) {
Box box = new Box("box", new Vector3f(i*50, 0, j*50), 50f, 0.01f, 50f);
box.setRenderState(ts);
rootNode.attachChild(box);
}
}
Box y = new Box("y" ,new Vector3f(0,0,0), 0.1f, 100f, 0.1f);
Box x = new Box("x", new Vector3f(0,0,0), 100f, 0.1f, 0.1f);
Box z = new Box("z", new Vector3f(0,0,0), 0.1f, 0.1f, 100f);
rootNode.attachChild(x);
rootNode.attachChild(y);
rootNode.attachChild(z);
}
private void setupCharacter() {
Box b = new Box("b", new Vector3f(), 0.01f,0.01f,0.01f);
b.setModelBound(new BoundingBox());
b.updateModelBound();
m_character = new Node("char Node");
rootNode.attachChild(m_character);
m_character.attachChild(b);
m_character.updateWorldBound();
}
private void setupTestData() {
Box source1 = new Box("source1", new Vector3f(10,15f,10f), 5f, 15f, 5f);
Box source2 = new Box("source2", new Vector3f(40,30f,70f), 5f, 30f, 5f);
source1.setDefaultColor(ColorRGBA.green);
source2.setDefaultColor(ColorRGBA.orange);
boxNode.attachChild(source1);
boxNode.attachChild(source2);
}
}