I didn't set the initial size of the bounding sphere. The bounds are
computed automatically. Here's some sample code:


//centering the object...
        Point3d c = new Point3d();
        sceneBounds.getCenter(c);       // sceneBounds is my branchgroup
that
                                                // holds all the shape3d's
i've loaded in...

        // Find out how far the object is from the center...
        Vector3d temp2 = new Vector3d(c);
        // negate the vector to translate everything back to the origin...
        temp2.negate();
        Transform3D centerTrans = new Transform3D();
        centerTrans.set(temp2);

  objRealTrans.setTransform(centerTrans); // this is the transformgroup
directly above
                                                        // sceneBounds

Here's the code for scaling:
 Transform3D t3d = new Transform3D();
        //scale the object assembly within 1 radius sphere
        double scale = 1/(sceneBounds.getRadius());
        t3d.setScale(scale);
        objScale.setTransform(t3d);


        //change the sceneBounds to match the actual position of
        // the object
        sceneBounds.setCenter(new Point3d(0,0,0));
        sceneBounds.setRadius(1);


Maybe I did this completely wrong and it happened to work out... but the
results seem to be all right with the exception of one bug that I can't fix.

When I pick any part of the assembly, the picked shape 3d rotates around
some strange axis. Further, when I pick a part the rest of the assembly
doesn't stand still.
Once a part is picked, I'd like the rest of the assembly to stop rotating,
translating whatever.
But enough about my problems!
I hope this code helps you out, Bruno.
If you need any more help or code, I'd be happy to give it.
~John
-----Original Message-----
From: Bruno Sousa Caiado [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 28, 2000 3:44 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] How to determine correct scale factor


Hello John,
Just two questions:
What do you mean by: "I used the bounding sphere center to recenter the
assembly".??
And how did you set the initial size of the bounding sphere?
Thank you.

Bruno

----- Original Message -----
From: Snavely, John A <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 27, 2000 11:48 PM
Subject: Re: [JAVA3D] How to determine correct scale factor


> I'm not sure if this applies... but here's what I did.
> Once I loaded up all the object files that made up the assembly and packed
> them into a branchgroup, I used the bounding sphere center to recenter the
> assembly. Then I used the radius of the bounding sphere to scale
everything
> to within a sphere of radius 1. I aimed my view platform at the result and
> it worked!
> Hope this helps!
> ~John
>
> -----Original Message-----
> From: Bruno Sousa Caiado [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 26, 2000 2:18 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [JAVA3D] How to determine correct scale factor
>
>
> Hello,
>
> I had the same exact problem when i started working with J3D..
> After loosing alot of time and pacience looking for the j3d API solution
for
> this problem, which i never found, i gave up and come up with the
following
> solution:
>
> When i�m building my objects( QuadArrays, TriangleArrays, etc) i keep
track
> of the maximum value that appears in the object i�m going to draw. For
> example if i�m going to draw a triangle whose vertices are:
>     (1,1,1)
>     (1,1,1)
>     (1000,1000,1000)
>
>     i keep track of the value max=1000 and then i use it to scale the
> object...
>
>     what u have to do, like i did, is come up with a mathematical formula
to
> apply to the max value to find the correct scale value....
>
> Hope it helps.
> Good luck and good work
>
>
> ----- Original Message -----
> From: Rajamiyer Ravichandran <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, July 25, 2000 9:17 PM
> Subject: [JAVA3D] How to determine correct scale factor
>
>
> > Hi All,
> > I have difficulty in setting the correct scale factor
> > for the top level TransformGroup of my scene graph. My
> > 3D models have different sizes and shapes. Knowing the
> > current size of the model, how can determine the scale
> > factor so that, the model will just fit in the
> > canvas3d. I believe there must be some relationship
> > between the model extents and the screen size so that
> > the scale factor can be computed. I am using
> > PARALLEL_PROJECTION.
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get Yahoo! Mail - Free email you can access from anywhere!
> > http://mail.yahoo.com/
> >
> >
>
===========================================================================
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff JAVA3D-INTEREST".  For general help, send email
to
> > [EMAIL PROTECTED] and include in the body of the message "help".
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to