Thank you very much David, it seems to work now.
I can get my obj coords with:
javax.media.j3d.BoundingSphere bSphere = new
BoundingSphere( shape3d.getBounds());
Point3d position2 = new Point3d();
bSphere.getCenter(position2);
Point3f position = new Point3f(position2);
I can then place my labels with
Font3D f3d = new Font3D(new Font("dialog", Font.PLAIN,
1),new FontExtrusion());
Text3D text3d= new Text3D(
//Font3D
f3d,
//String
nameobj,
//position
position,
//alignment
Text3D.ALIGN_CENTER,
//path
Text3D.PATH_RIGHT
);
OrientedShape3D orient = new OrientedShape3D(
text3d,
appearancetxt,
OrientedShape3D.ROTATE_ABOUT_POINT,
position
);
but I still have a problem:
The coordinate system seems to be different for my
labels and for my objects and I have to multiplicate
each value of my Point3f position by 25 in order to
have the labels inside my transparent objects.
Do you know why?
Do you think this code, used to load the objects, can
be the cause:
int flags = ObjectFile.RESIZE;
ObjectFile f = new ObjectFile(flags,(float)(60 *
Math.PI / 180.0));
or it is a problem with a transform3d I used to resize
the text ?
Thanks for your help
TT
--- David Yazel <[EMAIL PROTECTED]> a �crit : > Ok
sure :) It's hard to keep banging your head
> against a wall on the same
> problem!
>
> Ok... the method node.getLocalToVworld(t3d3) will
> ONLY work if your node is
> in a live scene. If it is part of the live scene,
> but there are no
> translations done between the root of the scene and
> the node, then it will
> return (0,0,0) as the location. If the location of
> the node is (0,0,0) BUT
> the shapes are appearing somewhere other than the
> origin then the vertices
> of the geometries within the shape are placing the
> object somewhere other
> than the origin. Use the getBounds() method to find
> out a rough idea of the
> range of vertice that are inside your shape.
>
> So that answers your question "I just want to get
> the coords of the objects
> I have loaded from a .obj file".
>
> David Yazel
> http://www.cosm-game.com
>
>
> ----- Original Message -----
> From: thorsten topol <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, December 19, 2001 6:01 AM
> Subject: Re: [JAVA3D] obj coordinates
>
>
> Hi,
> Thank you very much for your help (again) but there
> is
> something I really don't understand.
>
> I just want to get the coords of the objects I have
> loaded from a .obj file
> These objects are addchilded() to the scene, then to
> the branch group.
>
> >scene = ObjectFile.load(filename);
> ...
> >branchgroup.addChild(scene.getSceneGroup());
>
> Then I recover my objects with
>
> >Hashtable objs= new Hashtable();
> >objs= scene.getNamedObjects();
>
> and transform them with
>
> >Set keys = objs.keySet();
> >Iterator ite = keys.iterator();
> >while (ite.hasNext()){
> > Object obj3d = ite.next();
> > Shape3D node = (Shape3D) objs.get(obj3d);
> >
>
node.setCapability(javax.media.j3d.Node.ALLOW_LOCAL_TO_VWORLD_READ);
>
> > file://relooking
> > if (node != null) {
> > node.setAppearance(app0);
> > }
>
> this work fine so my objects seems to be in a live
> scene graph (they are rendered!).
>
> The problem is I can't have these coord with
> > Transform3D t3d3 = new Transform3D();
> > try{
> > node.getLocalToVworld(t3d3);
> > }
> > catch(RestrictedAccessException e){}
> >}
>
> (it returns
> "javax.media.j3d.RestrictedAccessException: Node:
> local to vworld transform is undefined for a node
> that
> is not part of a live scene graph")
>
>
> I tried to get the coords once the branchgroup has
> been added to the unverse. I have then (0.0,0.0,0.0)
> coords for all my objects (egad!)
>
> Can you help me?
>
> Thorsten.
>
>
>
>
> > > Here, you new a Shape3D, but you haven't
> > > addChilded() it to
> > > anything attached to the root yet. There's no
> > > getLocalToVworld() defined.
> > >
> > > Are you trying to setAppearance() based on the
> > > Shape3D's global
> > > position? If so, you have to wait until after
> > > you've attached
> > > the Shape3D to the live scene graph (after a
> > > setCapability(ALLOW_APPEARANCE_WRITE)).
> > >
> > > . . .
> > >
> > > Hth,
> > > Fred Klingener
> > >
> > >
>
>
>
___________________________________________________________
> Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et
> en fran�ais !
> Yahoo! Courrier : http://courrier.yahoo.fr
>
>
===========================================================================
> 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!? -- Une adresse @yahoo.fr gratuite et en fran�ais !
Yahoo! Courrier : http://courrier.yahoo.fr
===========================================================================
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".