September 12, 2013, 7:11am
I’ve done all of the tutorials through HelloEffects (as well as all of the exercises for each) and started on my game development journey, but I ran into an issue that lead me back to the HelloPicking tutorial.
Link for reference.
What if I wanted to expand the collision volume of a box in the tutorial? I started looking in to BoundingVolumes, but I wasn’t sure if those only pertain to physics.
My attempt at rewriting the makeCube() looks like:
protected Geometry makeCube(String name, float x, float y, float z)
Box box = new Box(1, 1, 1);
Geometry cube = new Geometry(name, box);
cube.setLocalTranslation(x, y, z);
Material mat1 = new Material(this.assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
BoundingBox boundingBox = new BoundingBox(Vector3f.ZERO, 1.5f, 1.5f, 1.5f);
Am I aiming in the right direction? (Get it?
September 12, 2013, 7:43am
I’m not sure what the code you’ve posted is supposed to do but I can tell you what it
create a box 2,2,2 (1,1,1 extents)
create geometry for that box
set it to x,y,z
create an unshaded material
assign it a random color
set the material on that geometry
…so far so good create a bounding box 3,3,3 (1.5 extents)
set that to the geometry
recalculate the bounding shape thereby returning it to its original 2,2,2 bounds.
I think this last part is not really what you mean to do.
At any rate, picking is done on the actual mesh. So if the mesh is only 2,2,2 then that’s all you’ll pick no matter what the size of the bounding volume.
September 12, 2013, 8:12am
Ah, thanks! I must have misread about the updateModelBound() then. More importantly, it’s good to know about picking being done on the actual mesh.
What would be a correct way to have a geometry with a 2,2,2 visible mesh but a 3,3,3 “pickable” volume?
September 12, 2013, 2:36pm
2,2,2 visible mesh and a second geometry with a 3,3,3 mesh but with cull hint set to always. (picking is done even on culled objects).
September 12, 2013, 8:40pm
Perfect, thanks for your help!
I ultimately created a Cylinder that will act as the shape for these purposes.
// create cube shape
Box cube = new Box(0.5f, 1, 0.5f);
Geometry cubeGeometry = new Geometry("Character Cube " + id, cube);
Material material = new Material(this.assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
// create collision cylinder
Cylinder cylinder = new Cylinder(4, 12, 1.5f, 2, true);
Geometry collisionGeometry = new Geometry(“Collision Cylinder” + id, cylinder);
collisionGeometry.rotate(FastMath.HALF_PI, 0, 0);
Material wirematerial = new Material(this.assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
(I have the Cull Hint commented out until I’m finished with debugging.)