Jump to content
  • Advertisement
Sign in to follow this  

Texture coordinates problem

This topic is 3629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm having trouble generating textures coordinates for the cells of my terrain Here is the code :
int v_index = 0;
int HeightIndex = 0;	
TerrainVertex * v = NULL;
int i = 0;
for(int z = (int)pNode->vBoundingCoords[0].y; z <= (int)pNode->vBoundingCoords[3].y; z += vertexSpacing)
	int j = 0;
	for(int x = (int)pNode->vBoundingCoords[0].x; x <= (int)pNode->vBoundingCoords[3].x; x += vertexSpacing)
		v_index = i * numVerticePerSide + j;
		coordU = ((float)j)/16.0f;
		coordV = ((float)i)/16.0f;
		HeightIndex = ((i * FileWidth)+(FileWidth*(pNode->vBoundingCoords[0].y/vertexSpacing))) + (j+(pNode->vBoundingCoords[0].x/vertexSpacing));
		v[v_index] = TerrainVertex((float)x,(float)0,(float)z,coordU,coordV);

I divide coordU and coordV by 16.0 but it is just a random number to test In fact the problem is that coordU has no influence, I can set it to what ever I want it doesn't change anything..... But coordV does work fine, the coordinates are not good at all! If you have any ideas....... Thanx. [Edited by - Grigou on August 13, 2008 4:28:00 PM]

Share this post

Link to post
Share on other sites
Try stepping through your code in debug mode, line by line, examining the values of x, z, i and j and see if they're what they should be.

For instance, is j incrementing correctly? Do you get reasonable values for coordU and coordV? Is j always less than numVerticePerSide?

EDIT: What is TerrainVertex::FVF? It appears that it should be D3DFVF_XYZ | D3DFVF_TEX1. Is that what you have it set to?

Share this post

Link to post
Share on other sites
Well, sorry for the code part, i'm new and I dont know how it works....

So this is my vertex declaration :
TerrainVertex::FVF = D3DFVF_XYZ|D3DFVF_TEX1;
It should be fine .....

Before is was creating my terrain cells one by one and the texture coordinates where working fine.
Now I am using a QuadTree to manage the terrain.
I am checking all the variables...

Thanx for the replies

EDIT : Okay I solved the problem after a few hours of research....
Seems like the terrain vertices were not getting the proper vertex declaration
Anyway thank you for spending some time on this thread

[Edited by - Grigou on August 14, 2008 5:10:08 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!