Login  Register

Texture Problems !

Posted by Davidave on Nov 25, 2014; 12:38am
URL: https://forum.jogamp.org/Texture-Problems-tp4033628.html

Hey guys ! i have got a big problem with texturing a simple box. My texture seems to be stretched out over the surface!! i use an image for my texture which 128x128 pixel. Now i have read something about Quadarrays ! But i really dont understand what a quadarray IS or what it is doing!  Huh

it would be awesome if i show you my code and someone could help me to implement a quadarray!!! Smiley

this is my code

       Appearance wallApp = new Appearance();
   
       Texture mauer = new TextureLoader("mauer.jpg", frame).getTexture();
     
       //ground links
     
      TransformGroup tgLeft = new TransformGroup();
      Transform3D t3Left= new  Transform3D();
      Vector3f min = new Vector3f(-1.72f, -0.55f, -4f);
      t3Left.setTranslation(min);
      boxapp.setTexture(grass);
     
      Box left = new Box(1.5f,0.005f,6f,Box.GENERATE_TEXTURE_COORDS,wallapp);
      tgLeft.setTransform(t3Left);
      tgLeft.addChild(left);
      RootBg.addChild(tgLeft);


and this is an example i have found


 QuadArray plane = new QuadArray(4, GeometryArray.COORDINATES
 | GeometryArray.TEXTURE_COORDINATE_2);
 Point3f p = new Point3f();
 p.set(-1.0f, 1.0f, 0.0f);
 plane.setCoordinate(0, p);
 p.set(-1.0f, -1.0f, 0.0f);
 plane.setCoordinate(1, p);
 p.set( 1.0f, -1.0f, 0.0f);
 plane.setCoordinate(2, p);
 p.set( 1.0f, 1.0f, 0.0f);
 plane.setCoordinate(3, p);
 Point2f q = new Point2f();
q.set(0.0f, 1.0f);
 plane.setTextureCoordinate(0, q);
 q.set(0.0f, 0.0f);
 plane.setTextureCoordinate(1, q);
 q.set(1.0f, 0.0f);
 plane.setTextureCoordinate(2, q);
q.set(1.0f, 1.0f);
 plane.setTextureCoordinate(3, q);


okay thats it! now i have to modify this quadarray?! what do I need ? the size of my Box(1.5f,0.005f,6f)?? the Coordinates of my box( -1.72f, -0.55f, -4f) ?? please help me =(

thanks in advance
david


ps. im only allowed to use java3d