Texture Mapping extension


RE: Texture Mapping extension
#91
(2018-01-28, 0:29)Leonardo Zide Wrote: Basically I project the vertex into p1 and get the atan of that point for u, and then for v it's the angle of the triangle where the opposite side is the distance to plane 1 and the hypotenuse is the distance to the center. 

This approach works well except at the north/south poles and at the back where the 2 sides of the projection meet (u jumps from 0 to 1). I only have the vertex positions when I calculate the UVs, I need to change how I do things so that I have triangles instead of points and then these problems will be trivial to fix. Did you run into similar problems?

I do something similar indeed but when the angle results in 0.0 (uv 0 or 1) i look at the previous and next vertices in the mesh to decide on 0 or 1, this is not fool proof because the positional soup of LDraw doesn't guaranteed them o be close by.

But in case of the sphere it works very well. I think in practice part authors should avoid such situations by splitting the texture into two.

Having triangle info on the mapping level would indeed solve it, but like  you I'm working directly on the OpenGL float vector array. I do have the triangle information in the smoothing stage of preparations, but it's a bit messy to preserve that data into this stage. Something to consider for 2.0 I guess Smile

edit: With "longitude and latitude" I meant rotating one of the reference planes along with the angle found on the other before finding an angle on that one.
Code:
TGLVector3d curDir(false), baseDir(false), curNor(false), altRestDir(false);
  double baseAngle;
  for (int i=0; i<pntCnt; i++)
  {
    TGLVector2f &tc=uv[i];

    if (doStrict)
    {
      //Spec methode, geeft problemen by >180
      tc.u=calcTexCoord(dPnts, pntCnt, i, horAngle, horNor, restDir, curDir, NULL, baseAngle);
      tc.v=calcTexCoord(dPnts, pntCnt, i, verAngle, verNor, restDir, curDir, NULL, baseAngle);
    }
    else
    {
      if (verAngle<=M_PI)
      {
        //horizontaal dominant
        tc.u=calcTexCoord(dPnts, pntCnt, i, horAngle, horNor, restDir, altRestDir, &baseDir, baseAngle);
        curNor.loadFromCross(horNor, altRestDir);
        tc.v=calcTexCoord(dPnts, pntCnt, i, verAngle, curNor, altRestDir, curDir, NULL, baseAngle);
      }
      else
      {
        //verticaal dominant
        tc.v=calcTexCoord(dPnts, pntCnt, i, verAngle, verNor, restDir, altRestDir, &baseDir, baseAngle);
        curNor.loadFromCross(altRestDir, verNor);
        tc.u=calcTexCoord(dPnts, pntCnt, i, horAngle, curNor, altRestDir, curDir, NULL, baseAngle);
      }
    }
  }
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Re: Texture Mapping extension - by Tim Gould - 2012-04-14, 22:08
Re: Texture Mapping extension - by Tim Gould - 2012-11-15, 22:51
RE: Texture Mapping extension - by Roland Melkert - 2018-01-28, 19:13
Re: Texture Mapping extension - by Tim Gould - 2012-11-30, 21:55

Forum Jump:


Users browsing this thread: 1 Guest(s)