I'm trying to use a BoundingVolume for collision detection;
I've a thread where I can control an object;
After I translate the object ( geom.setLocalTranslation(new Vector3f(x,y,z)) ),
I update the BoundingVolume ( geom.updateModelBound()),
and I expect the BoundingVolume to have the same translation of the object.
The rendering works but if I print boundingVolume.getCenter(),
the result doesn't change(also if I move the geometry object).
I guess this approach is wrong
Sphere s = new Sphere("MySphere1", new Vector3f(17, 7, 7), 20, 20, 4f);
BoundingBox b = new BoundingBox();
System.out.println(wrapper.getCenter()); //com.jme.math.Vector3f [X=17.0, Y=7.0, Z=7.0]
System.out.println(wrapper.getCenter()); //com.jme.math.Vector3f [X=17.0, Y=7.0, Z=7.0] <— is it normal ???
the model bound does not change with translation - the world bound does (call updateWorldVectors or updateGeometricState first).
Thank you very much,
I'm gonna try
I tried but I obtain the same results…
Where should I have to call these methods?
I tried on the Geometry object I move…
maybe on the rootNode?
The import thing was "the world bound does".
This means: use getWorldBound() not the model bound!
It does not matter where you call the update methods in this case.
but I make collision detection using the boundingvolume around the geometry.
I use bv.intersect(Ray r),
cause I simulate a sensor represented by a Ray.
When I start the application, the detection works;
if I move the geometry, the detection is not updated cause the boundingvolume doesn't update.
I.e. bv.intersect(Ray r) returns true also if the geometry is not intersected anymore by the ray of the sensor.
you can use intersect on the bound retrieved by getWorldBound, too. In terms of your code snipet above:
if ( s.getWorldBound().intersect(r) )
Thanks …it works