Hi everyone,
maybe this is a stupid question but I am stuck with a problem regarding Nodes, quads and collision check!
I am building multiple Quads and adding them to a Node. Then I am checking this node for collision!
speederNode = new Node("speeder");
for(int i = 0; i<50; i++){
speeder1 = new Quad("speeder"+i, 8, 8);
float x = (float) Math.random() * 350;
float z = (float) Math.random() * 350;
speeder1.setLocalTranslation(new Vector3f(x,1.1f,z));
speeder1.setLocalRotation(new Matrix3f(0,0,0,0,0,1.0f,0,0,1.0f));
speederNode.attachChild(speeder1);
// We need to make sure the quad is rendered after the land. QUEUE
// TRANSPARENT!
}
speederNode.setRenderQueueMode(Renderer.QUEUE_INHERIT);
speederNode.setLightCombineMode(LightState.OFF);
speederNode.setModelBound(new BoundingBox());
speederNode.updateModelBound();
TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
ts.setEnabled(true);
Texture tex = TextureManager.loadTexture(
Start.class.getClassLoader().getResource(
"data/images/speedSign.png"),
Texture.MM_LINEAR_LINEAR,
Texture.FM_LINEAR);
ts.setTexture(tex);
speederNode.setRenderState(ts);
return speederNode;
Now I check the Node with checkSpeeder(speederNode, tpf);
private void checkSpeeder(Node n, float time){
if(player.getWorldBound().intersects(n.getWorldBound())){
System.out.println("Collision detected");
player.setVelocity(player.getVelocity());
}
}
It detects collision everywhere in the area. Not only when the player intersects with the quads!
Before this version I had several Nodes and attached one quad to each Node. Then I checked each Node for collision! It worked, but the code was way to long*g*
Thanks for any help ;)