Juan,

This is what I use in case of displaying an image without tiling
on a shape. The trick here is the division 1/width and 1/height.
This will show your picture exactly as it is on your shape (no
shift or tiling). Mind that in the case below, the shape is
oriented in the x-z plane. So, in the last Vector4f defintion
you see "0,0,1/height,0.5f" If it would be in the x-y plane, you
Should use "0,1/height,0,0.5f".

Success, Dirk

import com.sun.j3d.utils.image.TextureLoader;
.....
...

        float height=280.0f;//the sizes of my shape...
        float width =560.0f;
        try {
            loader=new TextureLoader("whateverImage.jpg",null);
            image=loader.getImage();
            imageWidth=image.getWidth();
            imageHeight=image.getHeight();
            Texture2D texture=new
Texture2D(Texture.BASE_LEVEL,Texture.RGBA,
                                                imageWidth,imageHeight);
            texture.setImage(0,image);
         }
        catch(Exception ef)
            {
            Whatever action .....
            }
        TexCoordGeneration tcg1=new TexCoordGeneration(
                                TexCoordGeneration.OBJECT_LINEAR,
                                TexCoordGeneration.TEXTURE_COORDINATE_2,
                                new Vector4f(1/width,0,0,0.5f),
                                new Vector4f(0,0,1/height,0.5f));
        Appearance appb=new Appearance();
        appb.setTexCoordGeneration(tcg1);
        TextureAttributes texAttr1=new TextureAttributes();
        texAttr1.setCapability(TextureAttributes.ALLOW_TRANSFORM_WRITE);
        texAttr1.setTextureMode(TextureAttributes.REPLACE);
        appb.setTextureAttributes(texAttr1);
        appb.setTexture(texture);

-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED] On Behalf Of Juan Carlos Bermudez
Sent: Saturday, June 12, 2004 10:47 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Displaying a simple image

Thanks for the reply Alessandro,

   interesting, quite interesting your post. So if I have a picture that
is
64 x 32 pixels then I should use a quadarray of 0.25 x 0.125 meters?
(pixel
size / 256 = x mts?).

   Now I have another question. I've resized my picture to be
512x64pixels,
set the quadarray to be 2 x 0.25 mts, but the picture is not being
rendered
as it should. The question: what is the right order for the texture
coordinates to be set, i.e. left bottom corner first, then right bottom,
then right upper, then left upper is the right order? And about the
texture
coordinates, the TexCoord3f values of the texture coordinate should
match
the same values as those of the point3f of the vertex coordinate (values
AND order of assignment)? Am I getting this right. I have to admit I am
quite confused. Thanks in advance.

JC.

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