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 to become transparent only when it's corresponding 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 names are removed, remaining names are clipped by the modelclip (just like other objects).
when I try to change the names color instead of transparency, this modelclip problem does not occurs, but the intersection detection still occurs only one time (the first names are removed, and all remaining names change their color).
 
 
 
here is a sample code (with the BoundingPolytope.intersect method).
This method is called each time one of the 6 modelclip planes moves.
 

 
        //this part dynamically defines the BoundingPolytop
//I don't know why but here, I can't use the  modelclip.getPlanes() method (it returns null).       
        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;
      
        boundingpolytope.setPlanes(Allplanes);
        
        

        //this part check if there is a collision between bounds.
            Set keys = objs.keySet();    //objs is a hashtable with the objects
            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 ( boundingpolytope.intersect(node.getBounds()) )
                    name.getAppearance().setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NONE, 0.0f));
                else
                    name.getAppearance().setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NICEST, 0.7f));
                
            }
 
 
 
Do you understand what's happening? Do you know a best way to do this job?
Thanks for your help in advance.
 
Olivier.

Reply via email to