Problem: Texture Coordinate with a VB [3 screenshot]

Started by
8 comments, last by BlueChip 20 years, 5 months ago
Hi I''m here again =),with another trouble.... I can''t display correctly my texture... I''ve read SDK documentation, and different topics here on gamedev ( the best for my problem is this http://www.gamedev.net/community/forums/topic.asp?topic_id=120797) ... I''ve followed these informations but this is the result I''ve a numVertInX*numVertInZ grid and set texture coordinates in this way for apply 1 texture on each quad:

for (int z = 0; z < m_iNumOfVerticesZ; z++) { 
  for (int x = 0; x < m_iNumOfVerticesX; x++) { 
     pVertex->tu = (float)x;
     pVertex->tv = (float)z;
  }
}
 
and in this way for apply 1 texture on all quads:

for (int z = 0; z < numVertInZ; z++) { 
  for (int x = 0; x < numVertInX; x++) { 
     pVertex->tu = (float)x/numVertInZ;
     pVertex->tv = (float)z/numVertInX;
  }
}
 
But you can see that they don''t work. Any ideas?
Advertisement
     pVertex->tu = (float)x/numVertInZ;     pVertex->tv = (float)z/numVertInX;


Are you sure you don''t want?

     pVertex->tu = (float)z/numVertInZ;     pVertex->tv = (float)x/numVertInX;
Just checking, your not applying any matrices as well are you?
JoeyBlow2 already pointed ou the obvious, but what are the Y values of your verticies?
sorry .. sorry ...sorry

quote:
Are you sure you don''t want?

yes, I use
pVertex->tu = (float)z/numVertInZ;pVertex->tv = (float)x/numVertInX; 


quote:
Just checking, your not applying any matrices as well are you?

and yes I apply a matrix in Render() method....
is this that you mean... true?

quote:
but what are the Y values of your verticies


I''ve copied only a piece of my code..what I thought useful ...
Maybe is better if I post all my code?

thanks for your help guys =)


quote:Original post by BlueChip
quote:
Just checking, your not applying any matrices as well are you?

and yes I apply a matrix in Render() method....
is this that you mean... true?

I''ve copied only a piece of my code..what I thought useful ...
Maybe is better if I post all my code?


yeah, better post more of your code so we can see if things like your D3DFVF_CUSTOMVERTEX are defined properly.


quote:Original post by BlueChip
quote:
Just checking, your not applying any matrices as well are you?

and yes I apply a matrix in Render() method....
is this that you mean... true?


No, I think he is referring to texture matricies, not world transformation matricies.
hello

quote:
yeah, better post more of your code so we can see if things like your D3DFVF_CUSTOMVERTEX are defined properly.


ok ... is here =)
quote:
No, I think he is referring to texture matricies, not world transformation matricies.

.. no I don't thing that I've made it.... because I don't know it ...
I've searched in SDK and I've found some informations, but I don't know if it is that de_matt say..

is this?
	m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX , D3DTSS_TCI_PASSTHRU );    


byez =)


[edited by - BlueChip on November 18, 2003 11:37:19 AM]
change
struct CUSTOMVERTEX {    float x, y, z;    float tu, tv;   // The texture coordinates.    D3DVECTOR normal;};// Custom FVF, which describes the custom vertex structure.#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_NORMAL) 


to this

struct CUSTOMVERTEX {    float x, y, z;    D3DVECTOR normal;    float tu, tv;   // The texture coordinates.};// Custom FVF, which describes the custom vertex structure.#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_NORMAL) 


WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
yep... now it works.. woow thanks ..

I believed that order in FVF was dependent by vertices structure declaration..
But if this isn't true, then how I can know the right order?

thanks again =)

[edited by - BlueChip on November 18, 2003 4:09:55 PM]
The #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_NORMAL) is basically a bitwise combine (and) based on those constant DWORDS. It does not matter what is defined first, because the result will always be the same regardless of how you define it.

In the SDK, it explains the possible structure for a FVF format. You must use it in that order defined in the SDK. To see what I''m referring to, look at: DirectX Graphics/Programming Guide/Getting Started/Vertex Formats. Of course you can remove most of what is in that FVF, but it must be constructed in the order, and the correct flags specified (the #define in question)

This topic is closed to new replies.

Advertisement