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:
[java]
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”);
mat1.setColor(“Color”, ColorRGBA.randomColor());
cube.setMaterial(mat1);
I’m not sure what the code you’ve posted is supposed to do but I can tell you what it does do…
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.