texture map problem

Started by jcoy, November 18, 2005, 02:19:50 AM

Previous topic - Next topic

jcoy

Hello-

I've been using the following code to create planes:


 public void addAPlaneToObj3D(Object3D obj3D, SimpleVector p1, SimpleVector p2, SimpleVector p3, SimpleVector p4) {
   float lTiles = 1f;
   float wTiles = 1f;

   lTiles = (float)(DistanceBetween(p1, p2) / DistanceBetween(p2, p3)); // tile as squares based on width

   // top right triangle
   obj3D.addTriangle(p2, 0f,     wTiles, p1, lTiles, wTiles, p4, lTiles, 0f);
   // bottom left triangle
   obj3D.addTriangle(p4, lTiles, 0f,     p3, 0f,     0f,     p2, 0f,     wTiles);
 }

 public double DistanceBetween(SimpleVector p1, SimpleVector p2) {
   SimpleVector p = new SimpleVector(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z);
   return Math.sqrt(p.x * p.x + p.y * p.y + p.z * p.z);
 }


but I'm getting some texture ripping when I rotate the result (using rotateZ()).  It's hard to explain so I put up a small demo here:

         http://162.42.246.56/jpcttest/

If you load that page, left click and drag to the right it will rotate the Object3D and the "ripping" effect should show up (and become more pronounced) as the end of the board approaches the camera (the demo responds to other mouseDragged events as well).

The rotate code is just:


   int x = e.getX();
   if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
     if (x > lastX) {
       board.rotateZ(-.03f);
     } else {
       board.rotateZ(.03f);
     }
   }



Is this a bug or am I just doing something goofy?

EgonOlsen

Quote from: "jcoy"
Is this a bug or am I just doing something goofy?
A little bit of both... :wink:
It's not really a bug, it's an accuracy problem. You are overusing the texture tiling, because your plane is so large. Have a look at the tokima-thread in the projects section, which had the same problem once (there's also a screenshot in there). The texture coordinates you are using simply don't fit into 32bits correctly anymore (after being converted to fixed point internally). There's nothing i can do about this without losing mapping accuracy, so the only option is to split such an object into smaller triangles.

Anonymous

Quote from: "EgonOlsen"The texture coordinates you are using simply don't fit into 32bits correctly anymore (after being converted to fixed point internally). There's nothing i can do about this without losing mapping accuracy, so the only option is to split such an object into smaller triangles.

Thank you for the timely response, that solves the problem (or at least makes it addressable).