Author Topic: texture map problem  (Read 3279 times)

jcoy

  • Guest
texture map problem
« on: November 18, 2005, 02:19:50 am »
Hello-

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

Code: [Select]

  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:

Code: [Select]

    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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: texture map problem
« Reply #1 on: November 18, 2005, 07:52:09 am »
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

  • Guest
Re: texture map problem
« Reply #2 on: November 23, 2005, 09:53:31 pm »
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).