Game Development Community

Precipitation - Weird TexCoords

by Edward F. Maurina III · in Torque Game Engine · 07/27/2003 (9:32 pm) · 4 replies

Hello. I'm looking at the precipitation mission object and am able to get them working 'OK'. On closer inspection, I noticed that all images are rendered with goofy texture coordinates. The end effect is that the texture is squeezed into a corner. Poking around the code I found a routine that was pre-generating the texture coordinates for the billoboard quads. For the life of me I couldn't quite grasp what it was doing.

Anyways, I've modified the renderPrecip() routine as follow:
//               glTexCoord2f(coordX, coordY);
               glTexCoord2f(0.f, 0.f); //EFM
               glVertex3f(point[0].x, point[0].y, point[0].z);
               glTexCoord2f(0.f, 1.f);//EFM
//               glTexCoord2f(coordX, coordY + 0.25);
               glVertex3f(point[1].x, point[1].y, point[1].z);
               glTexCoord2f(1.f, 1.f);//EFM
//               glTexCoord2f(coordX + 0.25, coordY + 0.25);
               glVertex3f(point[2].x, point[2].y, point[2].z);
               glTexCoord2f(1.f, 0.f);//EFM
//               glTexCoord2f(coordX + 0.25, coordY);
               glVertex3f(point[3].x, point[3].y, point[3].z);

What I'd like to know is, "Does anyone have a clue what is going on with those original texture coords, and if so how can we manipulate them, or at least get them to render nicely?

Thanks!

PS - Here is the routine I was talking about:

void Precipitation::setupTexCoords()
{
   S32 x, y, numTimes = NUM_TEXTURES / 4;
   
   for(y = 0; y < numTimes ; ++y)  
      for(x = 0; x < numTimes ; ++x)  
         mTexCoord[y * numTimes + x].set(x * 0.25f, y * 0.25f);
}

PPS Here is screen shot showing the before (left) and after (right) images: www.hallofworlds.com/pages/Torque/TorqueImages/precipitation.jpg

#1
07/28/2003 (1:24 am)
Hmm... never noticed it, although I should ask if your precipitation tile only has a single image and what size it is.

The T2 precipitation image file was a 128x128 image divided into a 4x4 grid, of 32x32 tiles, with a different variation of the precipitation type in each square.
#2
07/28/2003 (3:52 am)
Have a look here It's a resource I posted to have more flexibility with the precipitation code.
#3
07/29/2003 (1:02 pm)
LabRat/Frank,

Thanks to both of you for your replies. I didn't think of that! 16 subtextures. I'll check it out and see what I get.

Also, having kind of slow access right now, but I'll check out your resource Frank.

-Ed
#4
07/29/2003 (1:15 pm)
Frank,

I feel like a hoser :\ now. I even commented on that resource before. Its right there and I just missed it. Thanks again to both of you!