Here you go:

Cone cone = new Cone(...);
cone.getShape(Cone.BODY).setUserData(cone);
cone.getShape(Cone.CAP).setUserData(cone);

H.

p.s. read javadoc / look at demos how things are done! you get much better
mileage that way, rather than posting a question and waiting for somebody
else to study those resources for you!

----- Original Message -----
From: "Brobbey,Isaac (neuron)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 06, 2003 8:32 AM
Subject: Re: [JAVA3D] scene graph object


> Dear all:
>
> i understand everything you saying, but how do i set the User Data ? at
the
> point of creating the cone ?
> this is what i have:
>
> SceneGraphPath []Path = branchGroup.pickAllSorted(pickRay);
> if(Path!=null)
> {
>         for (int b=0;b<Path.length;b++)
>         {
>         System.out.println("path[i]="+Path[b]);
>         Node node = Path[b].getObject();
>         Protein protein = (Protein) node.getUserData();
>         System.out.println("protein="+protein);
>        }
> }
>
> but it says the protein is null , does that mean that i did not set the
user
> data ? this  is what the compiler prints out. why is printing protein=null
> when infact it is not ?
>
> path[i]=javax.media.j3d.Locale@1c7980c : com.sun.j3d.utils.geometry.Cone,
> Protein@1568fb5 :
> javax.media.j3d.Shape3Djavax.media.j3d.TriangleFanArray@1f4bcf7
> protein=null
>
>
> any Ideas ??
>
>
> thanks,
>
> Isaac
>
> -----Original Message-----
> From: greg baboolal
> To: Brobbey,Isaac (neuron)
> Sent: 2/6/03 4:00 AM
> Subject: RE: [JAVA3D] scene graph object
>
> Hi,
>
> ID is an arbitrary Object where (i) is an argument in
> it's constructor.
>
> it is part of the demo examples for j3d:
> C:\j2sdk1.4.0_02\demo\java3d\FourByFour\ID.java
>
> By setting a reference to a corresponding Object in
> the userData, for example, one could then do something
> like this:
>
> Protein protein = (Protein) node.getUserData();
>
> Sys.out.print(  protein.name  );
>
> (assuming that for example 'name' is a var in the
> Protein Object class )
>
> Got to go, but can discuss later.
>
> Greg.
>
> --- "Brobbey,Isaac (neuron)"
> <[EMAIL PROTECTED]> wrote:
> >  Greg:
> >
> > thanks, for the insight.
> > one little thing to know is, how does ID id = new
> > ID(i); gets created ?
> > where is the i coming from ? which package is the ID
> > coming from?
> >
> > thanks once again
> >
> >
> > Isaac
> >
> > -----Original Message-----
> > From: greg baboolal
> > To: [EMAIL PROTECTED]
> > Sent: 2/5/03 10:08 PM
> > Subject: Re: [JAVA3D] scene graph object
> >
> > Dear Isaac,
> >
> > It is not very clear how or why the TriangleFanArray
> > is being displayed in the scene path.
> >
> > As a test I used the Four by Four example in the j3d
> > example and changed the spheres to Cones, when
> > printing out the scene path it shows:
> >
> > path[0]=javax.media.j3d.Locale@f297e7 :
> > com.sun.j3d.utils.geometry.Cone, ID@d2fc36 :
> > javax.media.j3d.Shape3D, ID@d2fc36
> > LocalToVworld Transform:
> > 1.0, 0.0, 0.0, 10.0
> > 0.0, 1.0, 0.0, -10.0
> > 0.0, 0.0, 1.0, 30.0
> > 0.0, 0.0, 0.0, 1.0
> >
> > FOUND:javax.media.j3d.Shape3D@19e15c
> > ID:ID@d2fc36
> >
> > which makes no reference to a 'tfa'?
> >
> > In the Positions file i set the Cones userData with
> > it's corresponding ID object which is detected and
> > is
> > retrievable as demo'd in the above snippet.
> >
> > the code to do this was:
> >
> > ID id = new ID(i);
> > posCone[i].setUserData(id);
> >
> > The retrieval would then be:
> >
> > ID posID = (ID) node.getUserData();
> >
> > This is irrespective of whether, for example, your
> > Protein extends a Shape3D. I have found it easiest
> > to
> > retrieve a reference to an object that is associated
> > with a geometrical j3d shape by setting a reference
> > to
> > that object in the shape3D's userData.
> >
> > Maybe someone can clarify this. As I too am in
> > development of j3d experience I have been following
> > your postings with interest ( there are similiar
> > traits to the stuff I have been working with ) thats
> > why it's nice to see solutions too!
> >
> > Anyway hope this helps.
> >
> > Greg.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --- "Brobbey,Isaac (neuron)"
> > <[EMAIL PROTECTED]> wrote:
> > > Dear all:
> > >
> > > consider the snippet below:
> > >
> > > int x = ((MouseEvent)event[i]).getX();
> > >                         int y =
> > > ((MouseEvent)event[i]).getY();
> > >                         System.out.println("x="+"
> > > "+x);
> > >                         PickRay pickRay =
> > > generatePickRay(x,y);
> > > SceneGraphPath []Path =
> > > branchGroup.pickAll(pickRay);
> > >                      for (int
> > b=0;b<Path.length;b++)
> > >                         {
> > >
> > > System.out.println("path[b]="+Path[b]);
> > >                          }
> > >
> > > the following print below shows the result of  the
> > > path, i want to retrieve
> > > the object Protein which i used to make the
> > > cone.something like
> > >
> > > Protein tein =(Protein)Path[0].getObject();
> > >
> > > but that throws an exception, any ideas on how
> > > really get to this object ?
> > >
> > > path[i]=javax.media.j3d.Locale@1fe571f :
> > > com.sun.j3d.utils.geometry.Cone,
> > > Protein@109ea96 :
> > >
> >
> javax.media.j3d.Shape3Djavax.media.j3d.TriangleFanArray@83b1b
> > >
> > > LocalToVworld Transform:
> > > 0.0375749076740305, -0.005965948985267853,
> > > -0.012350453208999744,
> > > 0.285124270664246 0.0, 0.03601788328904463,
> > > -0.017398620975559716,
> > > 0.12078290366391121 0.013715911991643523,
> > > 0.01634378978561484,
> > > 0.033834216736250124, 0.6479161499920172
> > > 0.0, 0.0, 0.0, 1.0
> > >
> > >
> > > this is what i really want to process
> > >
> > > path[i]=javax.media.j3d.Locale@1fe571f :
> > > com.sun.j3d.utils.geometry.Cone,
> > > Protein@109ea96 :
> > >
> >
> javax.media.j3d.Shape3Djavax.media.j3d.TriangleFanArray@83b1b
> > >
> > > and get to the protein object.
> > >
> > > any Ideas ?
> > >
> > >
> > > thanks,
> > >
> > > Isaac
> > >
> > >
> >
> ========================================================================
> > ===
> > > 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".
>
>
> __________________________________________________
> 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".

===========================================================================
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