Jump to content

  • Log In with Google      Sign In   
  • Create Account


Getting vertex position at certain point


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
7 replies to this topic

#1 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 03 June 2012 - 04:49 PM

How do I get a mesh vertex position at a certain point?

Sponsor:

#2 Tarika   Members   -  Reputation: 481

Like
1Likes
Like

Posted 03 June 2012 - 09:09 PM

This all depends on how your mesh is stored, what language you are using, and what you wish to achieve by this. Can you elaborate on what you wish to achieve, and which language you are using so members here can more easily answer.

Aimee.

We are now on Tumblr, so please come and check out our site! 

 

http://xpod-games.com


#3 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 03 June 2012 - 11:53 PM

I am using C++ and DirectX 9.

Thanks,

#4 Tom KQT   Members   -  Reputation: 1503

Like
0Likes
Like

Posted 04 June 2012 - 02:07 AM

Please explain a little bit what do you mean by "at a certain point".

#5 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 04 June 2012 - 08:55 AM

I have a terrain, I want to get the terrain vertex top Y axis based on X, Y axis, so I can move a character for example over the terrain.

#6 BornToCode   Members   -  Reputation: 901

Like
0Likes
Like

Posted 04 June 2012 - 08:59 AM

All the vertices info are store into your VertexBuffer. You can lock the vertexbuffer with a ReadOnly Flag and extract the vert you need. So for example if your vertex info is 3d position only therefore your vertex stride would be 12 bytes per vertex so doing simple math you can extract the vertex you want. For example if you want to extract vertex 2 you can just do 2*stride to get the pointer to point to the second vertex. I hope that helps, if you have any more question feel free to let me know.

Edited by BornToCode, 04 June 2012 - 09:00 AM.


#7 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 04 June 2012 - 02:25 PM

Can you please post code sample?

Thanks,

#8 BornToCode   Members   -  Reputation: 901

Like
0Likes
Like

Posted 05 June 2012 - 10:24 AM

It is very simple. The function that locks your vertexbuffer retursn an void* which is the address of the first element of your vertex. So if you do this
float* addr = (float*)vBuffer->Lock(); addr will point to the x element of your first vertex. To point to any vertex just multiply by the vertex index you want * whatever the sizeof one vertex is in your vertex buffer. From there using simple pointer arihmetic and dereferecing you should be able to get the values.

Edited by BornToCode, 05 June 2012 - 10:25 AM.





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