----------------------------------------------------------------------------
This Email may contain confidential and/or privileged information and is
intended solely for the addressee(s) named. If you have received this
information in error, or are advised that you have been posted this Email by
accident, please notify the sender by return Email, do not redistribute it,
delete the Email and keep no copies.
----------------------------------------------------------------------------

--- Begin Message ---
Hi,

It has been a while sinse I have done this and I can't find you any example code. If 
you have no luck at all let me know and I
should be abale to track some down for you. Anyway, here is some more info you might 
find useful.


Firstly, the array must be the same actual array, you can't use a new one. That is 
basically the point of using by-ref geometry.
There is only ever one copy in memory of the actual geometry info, in this case 
coordinates. By using the geom updater interface
you can change the geom info directly on the array you orignaly passed in. By using 
the geom.updater interface you are
essentially telling java 3D that it has to resend the info it already has a reference 
to to the vid card. (I hope that made some
sense.. been a long day :  ) Heres some 'closer to real' code.



class Something implements GeometryUpdater {

double[] points;
LineStripArray lsa;

private void createGeom() {

  points = new double[10];
  lsa = new LineStripArray(
          points.size(), LineStripArray.COORDINATES | LineStripArray.BY_REFERENCE,
          new int[] {points.size()});

  las.setCoordinates(0, points);
  ga.setValidVertexCount(10);
  ga.setInitialCoordIndex(0);
}

private void changeTheGeometryPlease() {
  las.updateData(this);
}

//this is the impl of teh GeometryUpdater interface
public void updateData(..) {
  points[0] = x;
  points[1] = y;
  ....

  //if you need to have a different number of points then use:

  //it will start using index 0 of your (updated) array
  ga.setInitialCoordIndex(0);
  //and will use all the coords upto the 9th one in the array
  ga.setValidVertexCount(8);

}

Therefore you can use a different number of coordinates, but the valid coords must be 
sequential and the number must not exceed
the size of the inital array. I think making a 'too big' array to start with will have 
less of a hit to performance than
throwing away an old one and recreating a new one each time.

Hope this helps.

Cheers,

Brad

greg baboolal wrote:
>
> Hi Brad,
>
> I will look into it, will this work even if the new
> array is not the same length (greater than) the
> original?
>
> Cheers,
> Greg.
>
> --- Brad Christiansen
> <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > If you keep a referance to your original coord array
> > then you can simply change the values in that array
> > directly in the
> > updateData() method. It goes something like the
> > 'kinda-code' snippet below. If you use BY_REF
> > correctly you shouldn't need to
> > set anything other than the values in your original
> > arrays.
> >
> > eg
> >
> > double[] coords;
> >
> > initGemo() {
> >   coords = new duoble[2];
> >   ..
> >   ..
> >   la = new LineArray(.. BY_REF ..);
> >   ga.setCoords(0, coords);
> >
> > }
> >
> > updateData(..) {
> >   coords[0] = 1245.123;
> >   coords[1] = 1334.234;
> > }
> >
> >
> > Cheers,
> >
> > Brad
> >
> > greg baboolal wrote:
> > >
> > > Hi,
> > >
> > > After an intermittent 12-hr period I finally
> > decided
> > > to put the monkey-typewriter-shakesphere theory to
> > > test and came up with a remedial solution, that is
> > >
> > > line.updateData( new GeometryUpdater() {
> > >   public void updateData(Geometry g) {
> > >     g = shape3D.getGeometry();
> > >     LineArray tempLine = (LineArray) g;
> > >     tempLine = lineArray( verts2 );
> > >     shape3D.setGeometry( tempLine );
> > >   }
> > > });
> > >
> > > Still amazed that I had to initiate a new
> > LineArray
> > > but it beats the overhead of a branchGroup. If
> > there
> > > is a cleaner way to have done this please
> > enlighten
> > > me.
> > >
> > > Thanks,
> > > Greg.
> > >
> > > --- greg baboolal <[EMAIL PROTECTED]> wrote:
> > > > Hi,
> > > >
> > > > Florin thanks for the observation, I have now
> > > > implemented the switch group.
> > > >
> > > > It seems to do the job, except there is one
> > little
> > > > part of th app which I can't get right now:
> > > >
> > > > I create a LineArray shape initial only having 2
> > > > verts, the ball's current position, however I
> > then
> > > > need to be able to update the LineArray with a
> > new
> > > > set
> > > > of co-ordinates, at present i'm using:
> > > >
> > > > line.setValidVertexCount(verts.length);
> > > > line.setCoordinates( 0 , verts );
> > > >
> > > > where verts is the new array set.
> > > >
> > > > but I keep getting the following error:
> > > > initial vertex index + valid vertex count >
> > vertex
> > > > count
> > > >
> > > > Can anyone help?
> > > >
> > > > Greg.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > __________________________________________________
> > > > Do you Yahoo!?
> > > > Yahoo! Mail Plus - Powerful. Affordable. Sign up
> > > > now.
> > > > http://mailplus.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".
> > >
> > > __________________________________________________
> > > Do you Yahoo!?
> > > Yahoo! Mail Plus - Powerful. Affordable. Sign up
> > now.
> > > http://mailplus.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".
> >
> >
> >
> ----------------------------------------------------------------------------
> > This Email may contain confidential and/or
> > privileged information and is
> > intended solely for the addressee(s) named. If you
> > have received this
> > information in error, or are advised that you have
> > been posted this Email by
> > accident, please notify the sender by return Email,
> > do not redistribute it,
> > delete the Email and keep no copies.
> >
> ----------------------------------------------------------------------------
> >
> >
> ===========================================================================
> > 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!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
--- End Message ---

Reply via email to