Yes, this is the purpose of GeometryArray.updateData(). If you do it
right, you should be able to change your geometry on a regular basis
without slowing down the system too much.
However, calculating normals can be tricky. Unless your object is
something simple like a sphere or cube, it will be hard to calculate
normals that create a smooth appearance. Remember, you calculate the
normal at the vertex positions, not the face of the triangle, so the
same normal is shared among all triangles sharing that vertex. So you
take the normals of all triangles sharing a vertex and average them to
get the normal at the vertex. That's not trivial, and that doesn't
even account for creases in your model, which makes things much more
complicated.
Have you taken a look at the Morph node? It may be an easier way
to do what you want.
-Paul
> Date: Mon, 27 Aug 2001 13:14:36 -0700 (PDT)
> From: Dola Woolfe <[EMAIL PROTECTED]>
> Subject: Re: [JAVA3D] GeomInfo useful to me?
> To: Paul Pantera <[EMAIL PROTECTED]>
> MIME-Version: 1.0
>
> Dear Paul,
>
> Thank you for the response. I will try what you're
> suggesting when I get a chance. For now I must admit
> that it is a little too advanced for me. I'm only a
> beginner.
> What I've decided to do instead is to calculate the
> normals myslef. What a novel idea... This way I keep
> the IndexedArray intact and only change the locations
> and the normals. (The project I'm working on now is
> scientific so the normals are easily available to me
> anyway...)
>
> What I'm curious though is whether this is better then
> generating a new Array via GeometryInfo every time. It
> seems cleaner to me to simply plug new data into an
> already existing object rather than create a new one,
> detach the old one and replace it with the new one. Do
> you guys agree?
>
> Thanks a lot!
>
> Pavel
>
> --- Paul Pantera <[EMAIL PROTECTED]> wrote:
> > > Delivered-To: [EMAIL PROTECTED]
> > > Date: Sat, 25 Aug 2001 09:10:58 -0700
> > > From: Dola Woolfe <[EMAIL PROTECTED]>
> > > Subject: [JAVA3D] GeomInfo useful to me?
> > > To: [EMAIL PROTECTED]
> > >
> > > Hi,
> > >
> > > I'm using a GeometryInfo on my objects for two
> > > purposes: strippify and calculate normals. Can I
> > still
> > > make use of GeomtryInfo is the locations (but not
> > the
> > > topology) of my vertices are changing? Obviously,
> > the
> > > normals need to be recalculated while
> > strippification
> > > remains in tact.
> > >
> > > My hope is this. Without GeometryInfo I'm able to
> > > create and IndexGeomArray once, make a Shape3D out
> > of
> > > it and then only have to worry about changing the
> > > locations of the vertices. That's what I would
> > like to
> > > keep doing. Right now, I probably missing
> > something as
> > > it appears to me that when the vertices change I
> > need
> > > to kill the old shape and create a new one. Am I
> > > wrong? (Please say "yes".)
> >
> > Well, GeometryInfo isn't really designed to be used
> > this way, but I
> > think it's possible. I've never done it, but maybe
> > someone else has
> > and can point out some potential pitfalls. It would
> > be very tricky.
> >
> > First, forget about Stripifying. NormalGenerator
> > only works on indexed
> > triangles, so you'd constantly be switching back and
> > forth between
> > individual triangles and strips - not good. Your
> > original data should
> > be individual triangles and it should remain
> > individual triangles.
> >
> > What you need to do is read the data out of the
> > GeometryInfo and make
> > your own by-reference GeometryArray. (Don't call
> > GeometryInfo.getGeometryArray()). You should create
> > extra space in the
> > GeometryArray and use validVertexCount to only
> > render those being used.
> > (The vertexCount of a GeometryArray can't be changed
> > after creation,
> > and creating normals may change the vertexCount.)
> >
> > Put the data into the GeometryInfo and generate
> > normals, read it out
> > and put it into your GeometryArray. Next frame
> > change the coordinates
> > within the GeometryInfo (the internal format will
> > now be indexed
> > triangles) regenerate normals and copy into the
> > GeometryArray again.
> > Remember to update validVertexCount. Since
> > GeometryInfo.getCoordinates
> > will return a reference to the data list, you should
> > be able to send
> > this reference directly to the GeometryArray using
> > GeometryArray.setCoordRef3f(). Do all this in the
> > updateData method.
> >
> > LMK how it goes.
> >
> > -Paul
> >
> >
> > > Delivered-To: [EMAIL PROTECTED]
> > > MIME-Version: 1.0
> > > Date: Sat, 25 Aug 2001 09:10:58 -0700
> > > From: Dola Woolfe <[EMAIL PROTECTED]>
> > > Subject: [JAVA3D] GeomInfo useful to me?
> > > To: [EMAIL PROTECTED]
> > >
> > > Hi,
> > >
> > > I'm using a GeometryInfo on my objects for two
> > > purposes: strippify and calculate normals. Can I
> > still
> > > make use of GeomtryInfo is the locations (but not
> > the
> > > topology) of my vertices are changing? Obviously,
> > the
> > > normals need to be recalculated while
> > strippification
> > > remains in tact.
> > >
> > > My hope is this. Without GeometryInfo I'm able to
> > > create and IndexGeomArray once, make a Shape3D out
> > of
> > > it and then only have to worry about changing the
> > > locations of the vertices. That's what I would
> > like to
> > > keep doing. Right now, I probably missing
> > something as
> > > it appears to me that when the vertices change I
> > need
> > > to kill the old shape and create a new one. Am I
> > > wrong? (Please say "yes".)
> > >
> > > Thanks!
> > >
> > > Dola
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Make international calls for as low as $.04/minute
> > with Yahoo! Messenger
> > > http://phonecard.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".
>
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.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".