Hi,
Thank you all for your help.
It seems to work but my ModelClip does not fit my objects extremities. it start after the highest point and stop before the last one.
If your equation is correct (and I know it is), the problem should comes from the extremum points determination, but I can not find the mistake.
 
Here is the code I use:
 
Hashtable objs= new Hashtable();
objs= scene.getNamedObjects();
Set keys = objs.keySet();
Iterator ite = keys.iterator();
          
extremumPointTop=0;
extremumPointBottom=0;
while (ite.hasNext()){
        Object obj3d = ite.next();
        Shape3D node = (Shape3D) objs.get(obj3d);
 
         //search the 2 extremum points for each object
         javax.media.j3d.BoundingBox bbox = new BoundingBox(node.getBounds());
         Point3d posUpper = new Point3d();
         bbox.getUpper(posUpper);
         Point3d posLower = new Point3d();
         bbox.getLower(posLower);
                
         //get the x y and z values for each point
         double[] tupleUpper=new double[3];
         posUpper.get(tupleUpper);
         double[] tupleLower=new double[3];
         posLower.get(tupleLower);
                
         //search the 2 extremum y values for the entire scene
         if (tupleUpper[1]>extremumPointTop)
               extremumPointTop = tupleUpper[1];
         if(tupleLower[1]<extremumPointBottom)
               extremumPointBottom = tupleLower[1];
}
System.out.println("extremum: "+extremumPointTop+"   "+extremumPointBottom);
 
 
Thanks for your help in advance.
 
 
----- Original Message -----
Sent: Wednesday, January 09, 2002 2:05 PM
Subject: Re: [JAVA3D] fit ModelClip

A plane can be defined by a normal to the plane and a point on the plane.  The x, y, z values of the normal are the a, b, c values of the plane equation with the d value equal to -dot(normal, pointOnPlane).

This can be accomplished with the following code:

// You supply these two.
Vector3f normal;
Point3f  pointOnPlane;

// The eqn of the plane.
Vector3d eqn = new Vector3d();
eqn.x = normal.x;
eqn.y = normal.y;
eqn.z = normal.z;
eqn.w = -normal.dot(new Vector3f(pointOnPlane));

Say you want to clip your model by z value (ie. you have zmin and zmax).

normal = (0, 0, 1)
point on zmax plane = (0, 0, zmax)
point on zmin plane  = (0, 0, zmin)
plane equation = (0, 0, 1, zmin + sliderValue*(zmax - zmin))

Hope this helps,
Renoir

--
Renoir Sewjee
Software Engineer
ISS International (Welkom)
Tel: +27 (0)57 912 2702
Fax: +27 (0)57 912 2652
--

> Hi, I have a Jslider(values 0 to 100%) wich performs a modelclipping
> for a = set of objects in my scene.  I want the clipping to start
> from the top point of the top object and = finish to the bottom
> point of the bottom object.  I can get the coords of both extremum
> by using BoundingBox' getUpper = and getLower methods (thank you
> Joachim), but I don't know how to set = the plane equation for the
> ModelClip.
>
> I tried with something like=20 Vector4d eqn1 =3D new Vector4d(0.0,
> extremumPointTop , 0.0, = -JsliderValue * extremumPointTop );
> modelclip.setPlane(1, eqn1);
>
> But it seems to be wrong.
>
>
> Thanks for your help in advance.

Reply via email to