Saurabh,
There are a couple questions you must ask. First, do you want the text
to stay the say same size regardless of distance to the vertex? If not,
2D text (which is a textured polygon) or 3D text will be fine. If you
*do* want the text to stay the same size (and easier to read), then you
need to use Raster.
Finally, connecting it to a 3D position is not a problem, but keeping
the text from being obscured by the cube requires advanced logic,
provided by you ;)
If you just want the text "on top", then you could just turn off depth
buffering for this item and draw it last. The real point is that the
functionality you are asking for is not just sitting around.
-Lee
> -----Original Message-----
> From: Saurabh Akhauri [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, March 14, 2001 3:18 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [JAVA3D] Annotation
>
>
> I really appreciate your help brian
> but my real problem is like this
>
> suppose i have a simple scenegraph containing a
> cube and 2D text attached to one of its vertices,
> now if i pick and rotate the cube, I want the 2D text
> to adjust its position accordingly without getting distorted
> and always facing the viewer.
>
> will be greatful if anyone can help me out
>
> saurabh
>
>
> ----- Original Message -----
> From: Brian Eppert <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, March 13, 2001 11:20 PM
> Subject: Re: [JAVA3D] Annotation
>
>
> > Don't know if anyone answered this already, but here's how I handled
> > it (in a subclass of TransformGroup):
> >
> > {
> > TransformGroup labelTG = new TransformGroup();
> > labelTG.setCapability(labelTG.ALLOW_TRANSFORM_WRITE);
> >
> > Transform3D topTransform = new Transform3D();
> > getTransform(topTransform);
> >
> > Text2D label = new Text2D(getTarget().getLabelString(),
> > new Color3f(1f, 1f, 1f), "Courier",
> > 14, Font.PLAIN);
> >
> > GeometryArray ga = (GeometryArray) label.getGeometry();
> > Point3f center = getCenter(ga);
> >
> > Vector3f centerTranslation = new Vector3f(-center.x, 0, 0);
> > Vector3f currentTranslation = new Vector3f();
> > Vector3f offsetTranslation = new
> > Vector3f(getTarget().getLabelOffset());
> >
> > topTransform.get(currentTranslation);
> >
> > currentTranslation.add(centerTranslation);
> > currentTranslation.add(offsetTranslation);
> >
> > topTransform.setTranslation(currentTranslation);
> > setTransform(topTransform);
> >
> > Billboard billboard = new Billboard(labelTG,
> >
> Billboard.ROTATE_ABOUT_POINT,
> > new Point3f(center.x,
> > center.y, 0));
> >
> > billboard.setSchedulingBounds(new BoundingSphere(new Point3d(),
> > 1000.0));
> > addChild(billboard);
> >
> > labelTG.addChild(label);
> > addChild(labelTG);
> > }
> >
> > The utility method getCenter:
> > float [] mins = new float[3];
> > float [] maxs = new float[3];
> > float [] curr = new float[3];
> >
> > public Point3f getCenter(GeometryArray geomArray) {
> >
> > if((geomArray == null) || geomArray.getVertexCount() == 0)
> > return null;
> >
> > geomArray.getCoordinate(0, mins);
> > geomArray.getCoordinate(0, maxs);
> >
> > for (int i = 1; i < geomArray.getVertexCount(); i++) {
> >
> > geomArray.getCoordinate(i, curr);
> >
> > if (curr[0] < mins[0]) {mins[0] = curr[0];}
> > if (curr[0] > maxs[0]) {maxs[0] = curr[0];}
> >
> > if (curr[1] < mins[1]) {mins[1] = curr[1];}
> > if (curr[1] > maxs[1]) {maxs[1] = curr[1];}
> >
> > if (curr[2] < mins[2]) {mins[2] = curr[2];}
> > if (curr[2] > maxs[2]) {maxs[2] = curr[2];}
> > }
> >
> > return new Point3f((maxs[0] + mins[0]) / 2, (maxs[1] +
> mins[1]) /
> > 2,
> > (maxs[2] + mins[2]) / 2);
> > }
> >
> > Hope it helps.
> > -Brian
> >
> > --- Saurabh Akhauri <[EMAIL PROTECTED]> wrote:
> > > I am trying to add 2D text as annotation to a 3D part.
> > > If i add same behaviour to both and try to rotate the part, the
> > > text also
> > > rotates with the part and looks distorted/vanishes.
> > >
> > > Is there some way by which the 2D text always remains at
> same plane
> > >
> > > and adjusts its position relative to the 3D part's rotation /
> > > translation / zoom
> > > on the screen.
> > >
> > > Basically i want to have behaviour of the 2D text effected by the
> > > behaviour of 3D body.
> > >
> > > saurabh
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Auctions - Buy the things you want at great prices.
> > http://auctions.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".
>
===========================================================================
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".