Archived

This topic is now archived and is closed to further replies.

John Milton

2D real world size problem

Recommended Posts

Hi, i''m trying to draw a sprite to the screen in 2D.. when i you the XYZ flag and TEX1, it''s drawing the bitmap right into the middle of the screen, and in the wrong size(larger) so i read in a tutrial that i need to use the XYZRHW flag, but when i do it(change the struct, put "1" in rhw) it dosent draw at all.. help? and on another topic(meybe the same problem?) i''m drawting with 6 vertexes, but in the tutrial i found it''s done with 4? i tried and again, it doesn''t draw anything..

Share this post


Link to post
Share on other sites
hmmm...what do you have as your z value? turn off back face culling maybe you are defining your verticies in reverse order. Are you using a triangle list? That''s fine if you have 6 verticies, the tutorial you are using probobaly used a strip or fan.


dankydoo

Share this post


Link to post
Share on other sites
If you set rhw to 1.0f, it means that the vertex is on the back (or front, can''t remember :s) clipping plane - so it won''t show up.

How are you drawing a quad with 6 vertices? You only need 4: use them in a Z shape - top left, top right, bottom left, bottom right - to get a quad.

What do you mean its drawing the quad larger: you mean its 20 pixels wide when you vertices are 10.0f apart? Is it only off by a few pixels, or it is more extreme?

Steve
DirectX Programmer
Soon to be the new Bill Gates

Share this post


Link to post
Share on other sites
Hi again,
i tried to use "Device->SetRenderState ( D3DRS_CULLMODE, D3DCULL_NONE);"
dosent work..

the rhw = 1.0 is from all(3) tutrial that i saw..
when i try to do 4 points, it draw nothing(yet again).
i'm trying to draw a brick in from a pic of size x[0..37] y[0..12] to the screen in 800X600, and when i use the XYZ it is bigger the 37X12, in the middle, that's for sure, it takes about 1/8 screen.

i don't know what i'm doing wrong..

the only thing that i do is changing from:

struct MyVertex{
float x, y, z; // The transformed position for the vertex.
float tu, tv; // The vertex color.
};
#define D3D8T_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_TEX1)
float XSize = 0.9f ;
float YSize = 0.36f ;
SetVertex(0, -XSize, -YSize, 1.0f, 0.0f, 1.0f);
SetVertex(1, -XSize, YSize, 1.0f, 0.0f, 0.0f);
SetVertex(2, XSize, YSize, 1.0f, 1.0f, 0.0f);
SetVertex(3, XSize, YSize, 1.0f, 1.0f, 0.0f);
SetVertex(4, XSize, -YSize, 1.0f, 1.0f, 1.0f);
SetVertex(5, -XSize, -YSize, 1.0f, 0.0f, 1.0f);

To:

struct MyVertex{
float x, y, z, rhw; // The transformed position for the vertex.
DWORD color;
float tu, tv; // The vertex color.
};
#define D3D8T_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_TEX1|D3DFVF_DIFFUSE)
float XSize = 100.0f;//37.0f ;
float YSize = 50.0f;//12.0f ;
float X=10.0f;//30.0f;
float Y=10.0f;//40.0f;

SetVertex(0, X, Y, 1.0f, 0.0f, 1.0f);
SetVertex(1, X, Y+YSize, 1.0f, 0.0f, 0.0f);
SetVertex(2, X+XSize, Y+YSize, 1.0f, 1.0f, 0.0f);
SetVertex(3, X+XSize, Y+YSize, 1.0f, 1.0f, 0.0f);
SetVertex(4, X+XSize, Y, 1.0f, 1.0f, 1.0f);
SetVertex(5, X, Y, 1.0f, 0.0f, 1.0f);


and in SetVertex i add that-
Vertexs.rhw = 1.0 ;
Vertexs[i].color = 0xFFFFFFFF;


sorry about posting the code like this, i don't know how to post it in a window like you guys do


[edited by - John Milton on July 18, 2002 2:30:59 PM]

Share this post


Link to post
Share on other sites