Hi Dave,

this topic has been discussed on this list several times ago.
You could have a look at some code from j3d.org (class
RasterTextLabel).

To answer your third question:
Set a transparent background on your Graphics2D object and provide
your Shape3D object with an appropriate appearance.

...
g.setBackground(new Color(255, 255, 255, 0);
g.clearRect(0, 0, 20, 20);
...
Appearance app = new Appearance();
app.setRenderingAttributes(
        new RenderingAttributes(false, false, 0,0f,
                                RenderingAttributes.GREATER));
shape.setAppearance(app);

Regarding your second question:
Get a FontMetrics object from a dummy BufferedImage before you create
your actual label. If created with the same parameters this object
should give you the right results.

Regards,
Ingo

> I've been google'ing for a while now and having a little difficulty.
> What I'm trying to do is annotate 3D geometry.  It works fine
> except that the alpha is not working properly.
>
> These are the steps that I follow,
>
> String sID = String.valueOf( ID );
>  BufferedImage bi = new
>             BufferedImage(20, 20,BufferedImage.TYPE_INT_ARGB);
> Graphics2D g = bi.createGraphics();
> FontRenderContext fontContext = g.getFontRenderContext();
> Font f2d = g.getFont();
> FontMetrics fm = g.getFontMetrics();
> int A = fm.getMaxAscent();
> int H = fm.getHeight();
> int W = fm.stringWidth( sID );
> g.drawString(sID, 0, A );
> ImageComponent2D image = new ImageComponent2D(
>                                        ImageComponent.FORMAT_RGBA,
>                                        bi );
> Raster rID = new Raster( ctr,
>                                         RASTER_COLOR,
>                                         0, 0, W, H,
>                                         image, null );
> shape.addGeometry( rID );
>
> My questions are:
>
> 1)  the BufferedImage is ARGB and the ImageComponent2D is RGBA, what
>      is the result of this?
> 2)  How do I figure out just the right size for BufferedImage from the String
> sID?
>      I currently get the FontMetrics from the Graphics2D from the BufferedImage.
> 3) This works fine for the most part, I am using a black background for my
> Java3D
>     scene, and the text of the annotation shows up with a black background,
> except
>     the black background is repainted over the 3D geometry, instead of using an
> alpha
>     which is what I prefer.  How can I do this?
> 4) There is a lot of "imaging" stuff, Image, ImageProducer's, ImageConsumers,
> BufferedImage,
>     Java2D Raster, Java3D Raster, etc... Are there any good tutorials/docs/books
> that describe
>     integrating Java 2D into 3D?
>
> Thanks for any help,
> -DaveS

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