View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Confused with rendering a radar

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1Anddos  Members

Posted 27 January 2013 - 11:07 PM

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,
// normalized device coordinates. I.e., world, view, projection matrices are all
// identity.
VertexPT* 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);

which part is setting the idenitity in that vertex declaration?

picture

Edited by Anddos, 27 January 2013 - 11:41 PM.

### #2NewDisplayName  Members

Posted 28 January 2013 - 12:41 AM

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.

### #3Anddos  Members

Posted 28 January 2013 - 12:51 AM

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 ?

### #4ankhd  Members

Posted 28 January 2013 - 01:37 AM

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.

### #5NewDisplayName  Members

Posted 28 January 2013 - 01:52 AM

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.

### #6Anddos  Members

Posted 28 January 2013 - 02:36 AM

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, 28 January 2013 - 02:40 AM.

### #7ankhd  Members

Posted 30 January 2013 - 07:45 PM

For a mesh as your minmap(radar) try looking up orthographic projection. That will place it in screen.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.