Jump to content
  • Advertisement
Sign in to follow this  
Medo Mex

Getting vertex position at certain point

This topic is 2380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!