Sign in to follow this  
Anddos

Confused with rendering a radar

Recommended Posts

Anddos    588
I am following a book and this is how they set up the vertex for the radar
//vertex.h
struct VertexPT
{
VertexPT()
:pos(0.0f, 0.0f, 0.0f),
tex0(0.0f, 0.0f){}
VertexPT(float x, float y, float z,
float u, float v):pos(x,y,z), tex0(u,v){}
VertexPT(const D3DXVECTOR3& v, const D3DXVECTOR2& uv)
:pos(v), tex0(uv){}

D3DXVECTOR3 pos;
D3DXVECTOR2 tex0;

static IDirect3DVertexDeclaration9* Decl;
};



//main code
HR(gd3dDevice->CreateVertexBuffer(6*sizeof(VertexPT), D3DUSAGE_WRITEONLY,
0, D3DPOOL_MANAGED, &mRadarVB, 0));
// Radar quad takes up quadrant IV. Note that we specify coordinate directly in
// normalized device coordinates. I.e., world, view, projection matrices are all
// identity.
VertexPT* v = 0;
HR(mRadarVB->Lock(0, 0, (void**)&v, 0));
v[0] = VertexPT(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
v[1] = VertexPT(1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
v[2] = VertexPT(0.0f, -1.0f, 0.0f, 0.0f, 1.0f);
v[3] = VertexPT(0.0f, -1.0f, 0.0f, 0.0f, 1.0f);
v[4] = VertexPT(1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
v[5] = VertexPT(1.0f, -1.0f, 0.0f, 1.0f, 1.0f);
HR(mRadarVB->Unlock());

which part is setting the idenitity in that vertex declaration?

picture

pic01s.jpg Edited by Anddos

Share this post


Link to post
Share on other sites

which part is setting the idenitity in that vertex declaration?

 

Not clear what identity are you looking for in your vertex declaration. The main code that you have shown (between VB Lock/Unlock) is basically UV mapping of your VB.

Share this post


Link to post
Share on other sites
Anddos    588

would it be possible todo this for a 3d model such as hands or a weapon , i think i would have to clone the mesh and modify the vertex buffer or something so its uv mapped the same way ?

Share this post


Link to post
Share on other sites
ankhd    2304

there allready transformed into -1 to 1 screen space 0, 0 is the centre and 1,-1 bottom right of window.

 

then the texture that has the terrain rendered on it is then put onto your quad.

Share this post


Link to post
Share on other sites

would it be possible todo this for a 3d model such as hands or a weapon , i think i would have to clone the mesh and modify the vertex buffer or something so its uv mapped the same way ?

 

UV mapping is indeed used to render 3D models in 2D coordinate map, with U,V being mapped to X,Y. So you can use it for any kind of 3D model.

The only change your VB will need is to keep in line with the above rule.

Share this post


Link to post
Share on other sites
Anddos    588
I am not sure where to start to add uv coords to a 3d models vertex buffer, it seems complex but i get the idea of the process
I should start with a cube or something first with D3DXCreateBox and see if i can uv map that so its placed like the rader is
Any sample code and i will be very greatfull Edited by Anddos

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this