How to update a vertex buffer with world space positions?

How to update a vertex buffer with world space positions?

paris.downes
Participant Participant
459 Views
2 Replies
Message 1 of 3

How to update a vertex buffer with world space positions?

paris.downes
Participant
Participant

Hello, I'm trying to understand something about viewport 2.0 geometry overrides. I'm a bit new to this, so bear with me. I have a node plugin derived from MPxLocatorNode which is drawn in the viewport as a plane. There's a polyPlane mesh being fed into the locator which is being used to drive the locator's shape. This plane has no subdivisions, so it's just 4 vertices. The way the shape is being driven is by using the plane node to initialize an MGeometryExtractor in the locator's associated MPxGeometryOverride class. The same extractor is used to initialize the MIndexBuffer. What I need to do is to modify the vertex positions from existing point positions which are in world space. The MGeometry and MGeometryRequirements objects that are passed into the populateGeometry() method are used to generate an MVertexBuffer, but when I examine this vertex buffer the 12 floats that should be representing the current vertices are not world space positions but just values between -0.5 and 0.5, like this...

 

-0.5, -0.5, 0, 0.5, -0.5, 0, -0.5, 0.5, 0, 0.5, 0.5, 0, 0

 

The data I want to replace it with looks like this...

 

-38.6714, 13.4587, -50, 38.6714, 13.4587, -50, 38.6714, -13.4587, -50, -38.6714, -13.4587, -50

 

but when I plug those values into the vertex buffer, the mesh plane goes haywire. Can anyone tell what this -0.5 to 0.5 range means and how I can set the vertex positions from world space data?

 

Thanks.

 

0 Likes
Accepted solutions (1)
460 Views
2 Replies
Replies (2)
Message 2 of 3

FirespriteNate
Advocate
Advocate
Accepted solution

geometry shapes don't store their point (vertex) positions in world space, they are always stored in local space (i.e. relative to their parent transform). If you have world space coordinates and you want to apply those to your vertices you will need to convert them into local space.

0 Likes
Message 3 of 3

paris.downes
Participant
Participant

Yeah I just realised straight after I posted that that the locator transform has scale values on it. That would explain it. Definitely good to know that the vertex positions are always in local space. Thanks.

0 Likes