Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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.

  • You cannot reply to this topic
6 replies to this topic

#1 Anddos   Members   -  Reputation: 508

Like
0Likes
Like

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,
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, 27 January 2013 - 11:41 PM.

:)

Sponsor:

#2 NewDisplayName   Members   -  Reputation: 359

Like
0Likes
Like

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.



#3 Anddos   Members   -  Reputation: 508

Like
0Likes
Like

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 ?


:)

#4 ankhd   Members   -  Reputation: 1319

Like
0Likes
Like

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.



#5 NewDisplayName   Members   -  Reputation: 359

Like
0Likes
Like

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.



#6 Anddos   Members   -  Reputation: 508

Like
0Likes
Like

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.

:)

#7 ankhd   Members   -  Reputation: 1319

Like
0Likes
Like

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.



PARTNERS