Hello all,
I am trying to add a box as an obstacle to a scene. When I do the following:
Node obstacle = new Node("node 1");
TriMesh theBox = new Box("box 1", new Vector3f(0f,0f,0f), new Vector3f(2f,2f,4f));
theBox.setSolidColor(new ColorRGBA(1,0,0,1));
theBox.setLocalTranslation(new Vector3f(-1,-1,-2));
obstacle.attachChild(theBox);
rootNode.attachChild(obstacle);
All is well. But when I add a bounding box as follows:
Node obstacle = new Node("node 1");
TriMesh theBox = new Box("box 1", new Vector3f(0f,0f,0f), new Vector3f(2f,2f,4f));
theBox.setSolidColor(new ColorRGBA(1,0,0,1));
theBox.setModelBound(new OrientedBoundingBox());
theBox.updateModelBound();
theBox.setLocalTranslation(new Vector3f(-1,-1,-2));
obstacle.attachChild(theBox);
rootNode.attachChild(obstacle);
Nothing in the scene is drawn.
Thanks for the help.
Todd
That certainly is a problem… do you see the same thing if you try BoundingSphere or BoundingBox?
I just tried BoundingSphere() and I get the same results. It is very wierd because everything is fine until I try to add the Bounding volume.
Hmm, using your code I made a simple example:
import com.jme.app.SimpleGame;
import com.jme.bounding.OrientedBoundingBox;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.TriMesh;
import com.jme.scene.shape.Box;
public class SimpleScene extends SimpleGame {
protected void simpleInitGame() {
Node obstacle = new Node("node 1");
TriMesh theBox = new Box("box 1", new Vector3f(0f,0f,0f), new Vector3f(2f,2f,4f));
theBox.setSolidColor(new ColorRGBA(1,0,0,1));
theBox.setModelBound(new OrientedBoundingBox());
theBox.updateModelBound();
theBox.setLocalTranslation(new Vector3f(-1,-1,-2));
obstacle.attachChild(theBox);
rootNode.attachChild(obstacle);
}
public static void main(String[] args) {
new SimpleScene().start();
}
}
And it seems to work just fine. Anything else you can add?
Ok,
I have this working, I am doing something wierd with the camera that got wierder when I added the bounding volume.
I’m not really sure why this happened, but I seem to be past it.
Thanks!
Todd