Pointing the viewer at a star is a relatively simple problem, but the exact
solution depends on how you represent the stars.
Representing a star field using spheres which are placed using transforms is
going to be incredibly slow (as I think you have discovered). But the solution
to your problem for this case is to inquire the localToVworld transform for the
sphere and then transform the center of the sphere (0,0,0) through the transform
to get the star's current VWorld position. You can then point the view along a
vector from the view position (in VWorld coords) to the star. The
Transform3D.lookAt() method may be useful in setting up the transform for the
ViewPlatform.
For other representations for the stars, the process is the same: get the
localToVworld transform and the local coordinate for the star, transform the
coordinate to VWorld coordinates and point the ViewPlatform at that VWorld
point.
I can't help but offer some alternatives to your representation for the stars,
you should be able to make your display orders of magnitude faster.
The only reason why each star would *have* to be under it's own transform would
be if you intended to animate the stars over time. If the star's positions are
fixed, finding a way to make them have the same transform is going to really
help performance. Putting multiple stars into a single Shape3D will help even
more.
If you can represent the stars a "dots" then putting all of the stars into a
PointArray is going to give the best performance. If you need to convey
different magnitudes you could use different shades of grey. Just be sure to
sort your stars so that all the ones with the same magnitude (color) are in the
same PointArray.
If you must represent the stars as spheres you can still improve performance.
Make the spheres have a low polygon count by specifying a small number of
divisions in the constructor for the Sphere. Consider transforming the points
of the sphere into a common coordinate space (contact me if you want details on
this).
Doug Gehringer
Sun Microsystems
> From: "Roberto Speranza" <[EMAIL PROTECTED]>
>
> If your stars are represented as spheres and the user can select them, you
> want the camera to point at the center of the sphere. When the user selects
> a star, attach a callback object that activates when the position changes
> (which I assume is being driven by some Behaviour object that is driving
> stellar position based on some star motion simulation routine). Find out
> what the modified position is and then use that to retarget the camera
> direction. The camera direction should be the normalized vector from the
> camera's position to the star's centre. I would provide specifics but I am
> just about to start looking over the specs in detail.
>
> Roberto Speranza
> President, Dot Internet Solutions Inc.
> mailto:[EMAIL PROTECTED]
> http://www.dotinc.net/
> ----- Original Message -----
> From: Randy Stiles <[EMAIL PROTECTED]>
> To: David A Thomson <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: April 29, 1999 12:50 PM
> Subject: Re: [java3d] Star Map in Java3D
>
>
> > David A Thomson wrote:
> > >
> > > My project is to build a fully rotatable 3D star map in Java. I
> currently
> > > have about 3000 sphere transforms in a contentBranchGroup which is
> running
> > > incredibly slowly (but that's for another mail). My problem is that I
> > > should be able to select a star and move the camera to point directly at
> > > it. However, because the stars are rotatable, the star positions (x,
> > > y, z coordinates) change all the time. How can I keep track of their
> > > coordinates?
> >
> > You may want to consider modeling the stars as points, on the inside of
> > one large transparent sphere. Then when people select a star point,
> > they are really selecting the sphere wall . This deals with slowness,
> > and deals with getting star location to use in a pointAt routine.
> >
> > Often star coordinates are given as a kind of polar coordinates in the
> > earth's sky, so you can take these and map them as points onto a sphere
> > easily. Then you take geometry for a large sphere, turn backface
> > culling off or invert the geometry, make it transparent, and make it a
> > little larger than the abstract sphere where your star points are
> > located.
> >
> >
> > --
> > // Randy Stiles mailto:[EMAIL PROTECTED] O/L922 B/255
> > // Lockheed Martin Advanced Technology Center 3251 Hanover Street
> > // office: 650.354.5256 fax: 650.354.5235 Palo Alto, CA 94304-1192
> > // http://vet.parl.com/~vet/
> > =====================================================================
> > To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> > Java 3D Home Page: http://java.sun.com/products/java-media/3D/
>
> =====================================================================
> To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> Java 3D Home Page: http://java.sun.com/products/java-media/3D/
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/