Hello,
I have several transparent objects with their names
inside (some OrientedShape3D).
I use a ModelClip with 6 planes to
slice objects but not their name ( I used the ModelClip.addScope(objects)
method ).
I want each name disappear only when it's
object has completely disappear. so I used a BoundingPolytope,
dynamically defined with the modelclip plane equations,
and the BoundingPolytope.intersect() method ( or a
collision detection behavior ) to detect if an object is entirely
clipped (in other hands, if my object's bounds don't intersect with the
BoundingPolytop).
I don't know if I used the rigth method but I've
got a strange problem: once the first detection occurs, names are
clipped by the modelclip (just like other objects).
here is a sample code (with the
BoundingPolytope.intersect method).
This method is called each time one of the 6
modelclip planes moves.
//I don't know why but here, I can't use the modelclip.getPlanes() method (it returns null).
//this part dynamically defines the BoundingPolytop
Vector4d[]
Allplanes = new Vector4d[6];
Vector4d
plane = new Vector4d();
modelclip.getPlane(1,plane); Allplanes[1]=plane; plane = new Vector4d(); modelclip.getPlane(2,plane); Allplanes[2]=plane; plane = new Vector4d(); modelclip.getPlane(3,plane); Allplanes[3]=plane; plane = new Vector4d(); modelclip.getPlane(4,plane); Allplanes[4]=plane; plane = new Vector4d(); modelclip.getPlane(5,plane); Allplanes[5]=plane; plane = new Vector4d(); modelclip.getPlane(0,plane); Allplanes[0]=plane; plane = new Vector4d(); polytope.setPlanes(planes); //this part check if there is a collision between bounds. Set keys = handler3d.objs.keySet(); Iterator ite = keys.iterator(); while (ite.hasNext()){ Object obj3d = ite.next(); Shape3D node = (Shape3D) objs.get(obj3d); //objs is a hashtable with the objects String nameLabel = node.getUserData().toString(); Shape3D name = (Shape3D) labels.get(nameLabel); //labels is a hashtable with the name of the objects if ( ! polytope.intersect(node.getBounds()) ) name.getAppearance().setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NICEST ,0.0f)); else name.getAppearance().setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NICEST ,1.0f)); } Do you understand what's happening?
Thanks for your help in advance.
Olivier.
|
- [JAVA3D] ModelClip problem Olivier Tassy
- [JAVA3D] ModelClip problem Olivier Tassy