Hello!

I'm tying to create a ground_surface, but it allways apper upside down
and I can't get it right.

I use a Shape3D which I add a texture on like this:

1) Apperance-class (I do here not the import statements)
public class TextureAppearance extends Appearance
{
        public TextureAppearance(String imageName, Applet applet)
        {
                TextureLoader textureLoader = new
TextureLoader(imageName, applet);
                ImageComponent2D imageComponent2D =
textureLoader.getImage();
                Texture2D texture2D = new Texture2D(Texture.BASE_LEVEL,
Texture.RGBA,
imageComponent2D.getWidth(), imageComponent2D.getHeight());
                texture2D.setImage(0, imageComponent2D);
                setTexture(texture2D);
        }
}

2) The Shape3D class  (I do here not the import statements)
 public class TextureGround extends Shape3D
 {
        float x = 2;
        float y = 4;
        float z = 2;

        float posX = 0;
        float posY = 0;
        float posZ = 0;

        int type = 0;

        public TextureGround(float x, float y, float z, String
imageName, Applet applet, int type)
        {
                this.x = x;
                this.y = y;
                this.z = z;

                QuadArray quadArray = new QuadArray(4,
GeometryArray.COORDINATES |
GeometryArray.TEXTURE_COORDINATE_2);

                Point3f point3f = new Point3f(posX,  posY, posZ);
                quadArray.setCoordinate(0, point3f);

                point3f.set(posX, posY, posZ - z);
                quadArray.setCoordinate(1, point3f);

                point3f.set(posX + x, posY,  posZ - z);
                quadArray.setCoordinate(2, point3f);

                point3f.set(posX + x,  posY,  posZ);
                quadArray.setCoordinate(3, point3f);

                Point2f point2f = new Point2f(0.0f,  1.0f);
                quadArray.setTextureCoordinate(0, point2f);

                point2f.set(0.0f, 0.0f);
                quadArray.setTextureCoordinate(1, point2f);

                point2f.set(1.0f, 0.0f);
                quadArray.setTextureCoordinate(2, point2f);

                point2f.set(1.0f, 1.0f);
                quadArray.setTextureCoordinate(3, point2f);

                setAppearance(new TextureAppearance(imageName, applet));
                setGeometry(quadArray);
        }
}

3) I create this with:
new TextureGround(25.6f, 0.0f, 25.6f, "images/dead_end_s.gif", applet,
Constants.DEAD_END_S);


....I can't understand why it always get's uppdown, I use to navigate
around this ground with a KeyNavigatorBehavior with this inside a
Applet:
                TransformGroup transformGroup1 =
simpleUniverse.getViewingPlatform().getViewPlatformTransform();
                KeyNavigatorBehavior keyNavigatorBehavior = new
KeyNavigatorBehavior(transformGroup1);
                keyNavigatorBehavior.setSchedulingBounds(new
BoundingSphere(new Point3d(0.0f, 0.0f, -8.0f),10000.0));

                branchGroup.addChild(keyNavigatorBehavior);


So if someone understand why it won't appare with the texture in the
right way, please let me know.

Best Regards

Fredrik Andersson

Ps  A good deed a day brings good karma to the world in these days.

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