Confused with rendering a radar

Started by
5 comments, last by ankhd 11 years, 2 months ago
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
:)
Advertisement

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.

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 ?

:)

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.

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.

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
:)
For a mesh as your minmap(radar) try looking up orthographic projection. That will place it in screen.

This topic is closed to new replies.

Advertisement