JuanCarlosAragon / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

Calculating of texture coords on terrain patch wrong #356

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I think there is an mistanke in calculating texture coordinates while producing 
a terrain patch.

What steps will reproduce the problem?
1. Build a Terrain and apply a Texture with a thin Border on each side. (You 
can use the HelloTerrain.class, replace alphamap with full red picture and 
change grass-texture to attached Test.png.)

What is the expected output? What do you see instead?
As you can see, two edges of the terrain don't reach the end of the texture.

What version of the product are you using? On what operating system?
I use the revision 7505 of jme3

My fix in class com.jme3.terrain.geomipmap.LODGeomep
Line 128 - Method getUV(...)

public Vector2f getUV(int x, int y, Vector2f store, Vector2f offset,  
                      float offsetAmount, int totalSize){
  float offsetX = offset.x + (offsetAmount * 1.0f);//stepScale.x);
  float offsetY = offset.y + (offsetAmount * 1.0f);//stepScale.z);

  // fix: change totalSize to totalSize-1
  store.set( ( ((float)x)+offsetX) / (float)(totalSize-1), 
             ( ((float)y)+offsetY) / (float)(totalSize-1) );
  return store;
}

And the texture is fully applied to the terrain...

Original issue reported on code.google.com by muvis...@web.de on 16 May 2011 at 7:59

Attachments:

GoogleCodeExporter commented 8 years ago
I forget: you have to set m_Tex1Scale to 1.0f

Original comment by muvis...@web.de on 16 May 2011 at 8:02

GoogleCodeExporter commented 8 years ago
closing old, applied, invalid and wrongly posted issues, all people searching 
for help please use the forum at jmonkeyengine.org

Original comment by normen667 on 7 Jun 2011 at 11:44