[SOLVED]Terrain Texturing

Hey guys

I need your help

I am a begginer in Java3D and i read quite a lot Tutorials and tried some stuff to make.
Now i made a terrain out of a coordinates, which are in a DB. All works fine but i just cant get the texture over the whole terrain.

The texture is a real map.

This is my code snippet in which i set the geometry and the texture


//grid is filled with coordinates taken out of a DB
// pts are the points of geometry, taken out of a grid
       for (int i = 0; i < grid.length - 1; i++) {
          for (int j = 0; j < grid[0].length - 1; j++) {
            pts[counter] = grid[i][j]; //top left corner
            counter++;

            pts[counter] = grid[i][j + 1]; //top right corner
            counter++;

            pts[counter] = grid[i + 1][j + 1]; //bottom right corner
            counter++;

            pts[counter] = grid[i + 1][j]; //bottom left corner
            counter++;
        
         }
      }

//geometry stuff
      GeometryInfo gi = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
      gi.setCoordinates(pts);

//making strips
      Stripifier sp = new Stripifier();
      sp.stripify(gi);

//making normals
      NormalGenerator ng = new NormalGenerator();
      ng.setCreaseAngle((float) Math.toRadians(30));
      ng.generateNormals(gi);

//setting appearance
      Appearance aper = new Appearance();
      Material Mser = new Material();
      Mser.setShininess(0.01f);
      Mser.setEmissiveColor(0.0f, 0.0f, 0.0f);
      Mser.setAmbientColor(0.1f, 0.1f, 0.1f);
      aper.setMaterial(Mser);

//setting the texturecoordinates
      Vector4f planeS = new Vector4f((float)1.0/1800,0.0f, 0.0f, 0.0f);
      Vector4f planeT = new Vector4f(0.0f, 0.0f, (float)1.0/1800, 0.0f);
      
      TexCoordGeneration tcg = new TexCoordGeneration(
                  TexCoordGeneration.OBJECT_LINEAR,
                  TexCoordGeneration.TEXTURE_COORDINATE_2,
                  planeS,
                  planeT);
      
      aper.setTexCoordGeneration(tcg);
      
//loading texture
      TextureLoader texLoad = new TextureLoader("125.tif", null);
      ImageComponent2D textImage = texLoad.getImage();

//setting texture
      Texture2D texture = new Texture2D(Texture2D.BASE_LEVEL, Texture.RGB,
                                        textImage.getWidth(),
                                        textImage.getHeight());
      texture.setImage(0, textImage);

//setting texture attributes
      texture.setMinFilter(Texture.NICEST);
      texture.setMagFilter(Texture.NICEST);
      texture.setEnable(true);

      TextureAttributes texatt = new TextureAttributes(
            TextureAttributes.DECAL, new Transform3D(), new Color4f(1.0f,
                                                                    1.0f,
                                                                    1.0f,
                                                                    1.0f),
            TextureAttributes.NICEST);

//adding texture to appearance
      aper.setTextureAttributes(texatt);
      aper.setTexture(texture);

//give geometry and appearance the scene graph
      this.setGeometry(gi.getGeometryArray());
      this.setAppearance(aper);

before I used the TexCoordGeneration I had this:


//set logical texture coordinates
//STEP = 2.0
for (int v = 0; v < textsint; v++) {
         //top left corner
         texts[v] = 0.0f;
         texts[++v] = 0.0f;

         //top right corner
         texts[++v] = 0.0f;
         //texts[++v] = widUnit;
         texts[++v] = (float) STEP;
 
         //bottom right corner
         //texts[++v] = lenUnit;
         texts[++v] = (float) STEP;
         //texts[++v] = widUnit;
         texts[++v] = (float) STEP;

         //bottom left corner
         //texts[++v] = lenUnit;
         texts[++v] = (float) STEP;  
         texts[++v] = 0.0f;
 
      }

//setting texturecoordinates
      gi.setTextureCoordinateParams(1, 2);
      gi.setTextureCoordinates(0, texts);

//setting texture and attributes
try {
         TextureLoader Texget = new TextureLoader(new java.net.URL(texture),
                                                  null);
         Texture2D ourTex = (Texture2D) Texget.getTexture();
         TextureAttributes texatt = new TextureAttributes(
               TextureAttributes.BLEND, new Transform3D(), new Color4f(1.0f,
                                                                       1.0f,
                                                                       1.0f,
                                                                       1.0f),
               TextureAttributes.NICEST);
         aper.setTextureAttributes(texatt);
         aper.setTexture(ourTex);
      }
      catch (java.net.MalformedURLException e) {
         System.err.println("error loading textures");
         e.printStackTrace();
      }


Now I got two questions
#1: How can I set the texturecoordinates, so one image covers the whole terrain?
#2: In TexCoordGeneration has planeS and T (and R, Q) and i searched in the internet for the meaning of the 4 parameters, which i can set… Vector4f planeS = new Vector4f(1.0f, 0.0f, 0.0f, 0.0f); Can someone tell me exactly for what does those 4 numbers stand?
-----EDIT:-----
k I found out what the first 3 parameters exactly do… x (length), y (height), z(width), w (wtf?)

Here is a pic of my current situation:

http://codefreak.net/~daniel/apps/hawnutor/uploads/1272627608/map.jpg

The problem:

http://codefreak.net/~daniel/apps/hawnutor/uploads/1272627740/crosspoint.jpg

The texture is wrapped exactly 4 times on the terrain but it shouldnt be wrapped at all. And is think because of the wrap the texture flips, but I dont care about that now.

Can anyone please help me?

Ok I found out how and why

here is my code for it


the code was too big for the post... I attached it

the “heart” of the code are the classes, which i copied from “Pro Java 6 3D Game Development”
My biggest problem in my early code was, that the geometry wasnt created as it should, thats why i never could put one image over the whole map.
hf gl