Sign in to follow this  

Getting vertex position at certain point

This topic is 2051 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

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

This topic is 2051 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this