DX8 Texturing Problem
On my current project I''ve some how jacked up my textures. When I''m rendering my terrain it tiles the image across it. Well about a few days ago it worked correctly. Now it''s not: I can tell it''s still drawing the texture though. It seems to draw the picture correctly in a grid like fashion but the picture seems stretched out kinda like this:
*-----*-----*-----*
| | | |
*-----*-----*-----*
| | | |
*-----*-----*-----*
where the stars indicate the "seemingly" correct way to place the texutre and the lines are the picture stretched between them.
I''ve seen this happen before, but i don''t know how I fixed it. I''ve checked my texture scaling and it''s correct and the render states and textures seem correct.
I got a feeling I need to change a texture set or something.
Thanks for the help in advance,
Pactuul
"The thing I like about friends in my classes is that they can''t access my private members directly."
Maybe you have clamped your textures, try this:
m_p3DDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); m_p3DDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );
That would seem like a good suggestion, but it didn''t fix it or change anything. I looked back on the previous backup of my program and I can''t find any changes that would possbily effect it...
#define D3D8T_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1|D3DFVF_DIFFUSE)
that''s my vertex def.
I decide to go through my wrapper and clean up a lot code and stuff, but I still haven''t got an Idea to the problem. I''ve got my project switching between a "chat room" (just a pic) and the terrain and game part of it. Well the program first runs in the chat room and the texture is just fine and when I switch to the terrain (which is messed up on textures still) and switch back the chat picture is very tiny. So I''m thinking I have to be changing something during the switches, but I can''t find it.
Is their a command or way that I could be telling directx to "shrink the pictures"?
that''s my vertex def.
I decide to go through my wrapper and clean up a lot code and stuff, but I still haven''t got an Idea to the problem. I''ve got my project switching between a "chat room" (just a pic) and the terrain and game part of it. Well the program first runs in the chat room and the texture is just fine and when I switch to the terrain (which is messed up on textures still) and switch back the chat picture is very tiny. So I''m thinking I have to be changing something during the switches, but I can''t find it.
Is their a command or way that I could be telling directx to "shrink the pictures"?
Yeah, the vertex definition is the problem here. Remember that the order of values in your struct is important. You are telling D3D to look for 3 float values for coordinates, 3 floats for normals, two floats for textures, and one DWORD for color. But, it looks in a specific order, regardless of how you define your FVF. What is happening is that d3d is reading bytes from your normal coordinates for the color, bytes from both normals and texture coordinates for the normals, and from the color for the texture coordinates (or something like that =). ALl you need to do is define your struct like so:
struct CUSTVERT
{
float x;
float y;
float z;
DWORD color;
float nx;
float ny;
float nz;
float tu;
float tv;
};
forgive the formatting.
Z.
struct CUSTVERT
{
float x;
float y;
float z;
DWORD color;
float nx;
float ny;
float nz;
float tu;
float tv;
};
forgive the formatting.
Z.
not true. It does matter what order you have them
as long as your #define lists them in the order as they are in the structure.
as long as your #define lists them in the order as they are in the structure.
Incorrect. You can test this yourself. Create some random console app, do something along the lines of "cout << (1 | 4 | 8) << endl; cout << (4 | 1 | 8) << endl; cout << (8 | 4 | 1) << endl;". You will find that, regardless of order, then result will be 13. The same goes for FVF flags. No matter the order, the result will always be the same. So, since D3D cannot determine the order you typed your FVF #define, it has to search for values in a certain order.
Z.
[edit]
In fact, because every FVF code has a different value, you can do something like (D3DFVF_XYZ + D3DFVF_DIFFUSE) instead of using "|", in this case.
Edited by - Zaei on July 21, 2001 1:28:36 PM
Z.
[edit]
In fact, because every FVF code has a different value, you can do something like (D3DFVF_XYZ + D3DFVF_DIFFUSE) instead of using "|", in this case.
Edited by - Zaei on July 21, 2001 1:28:36 PM
Per the MS SDK Docs, you must list the structure in a specific order:
Position
RHW
Blending weight
Vertex Normal
Vertex Point Size
Diffuse Color
Specular Color
Texture Coords sets 1-8
Some flags are mutually exclusive (such as D3DFVF_XYZ and D3DFVF_XYZRHW) and cannot be used together. Other than that, it does not matter which order the FVF descriptors are defined:
Thus:
#define FVF (D3DFVF_DIFFUSE | D3DFVF_XYZ)
is the same as:
#define FVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)
Jim
Jim Adams
home.att.net/~rpgbook
Programming Role-Playing Games with DirectX 8
Position
RHW
Blending weight
Vertex Normal
Vertex Point Size
Diffuse Color
Specular Color
Texture Coords sets 1-8
Some flags are mutually exclusive (such as D3DFVF_XYZ and D3DFVF_XYZRHW) and cannot be used together. Other than that, it does not matter which order the FVF descriptors are defined:
Thus:
#define FVF (D3DFVF_DIFFUSE | D3DFVF_XYZ)
is the same as:
#define FVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)
Jim
Jim Adams
home.att.net/~rpgbook
Programming Role-Playing Games with DirectX 8
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement