Get points from primitive

From Odwiki

Jump to: navigation, search


Contents

Get points from a Primitive

This is usefull if you would want to access all points from a certain Primitive in your geometry.

Get the amount of Primitives in the geometry

First you need to know how many Primitives you have in your geometry.

 uint NumOfPrimEntries = GU_Detail::primitives().entries();

Get the points from the Primitive

Now when you know how many Primitives there is in the geometry, you would need to access the specific Primitive you would want to work with. This you simply do with the function below.

'CurrentPrimitive' is the number of the Primitive you want to access.

GU_Detail::primitives()(CurrentPrimitive);

Get number of Points from a Primitive

In the above function so did you get the current Primitive that you want to work with. So now when you have that Primitive, you can use this function to get out the number of Points that is within this Primitive.

Note! This function only returns how many Points there is. You would need to run another function to work with the individual Point.

uint NumberOfPoints = GU_Detail::primitives()(uint CurrentPrimitive)::getVertexCount();

Access individual Point from the Primitive

To access the individual Point, you need to run this function:

GU_Detail::primitives()(uint CurrentPrimitive)::getVertex(uint i):

With this function, you can access all information about that certain Point. Usefull information can be such as

// The number the Point has in the complete Point list
uint PointNum = GU_Detail::primitives()(uint CurrentPrimitive)::getVertex(uint i)::getNum();
// The Position of the Point UT_Vector4 PointPosition = GU_Detail::primitives()(uint CurrentPrimitive)::getVertex(uint i)::getPos();

Putting it all together

Below I have posted a simple pseudo-code that shows how you can get the amount of Primitives from the geometry, access a specific one and get out which number and position each Point has:

GU_Detail *pGuDetail
const GEO_Primitive *pCurrentPrimNode;
for(uint CurrentPrimitive = 0; CurrentPrimitive < pGuDetail->primitives().entries() ; CurrentPrimitive++) { pCurrentPrimitiveNode = pGuDetail->primitives()(CurrentPrimitive);
for(uint i = 0; i < pCurrentPrimitiveNode->getVertexCount(); i++) { UT_Vector4 *pPointPosition = &pCurrentPrimitiveNode->getVertex(i).getPt()->getPos(); int PointNumber = pCurrentPrimitiveNode->getVertex(i).getPt()->getNum(); } }

© 2009 od[force].net | advertise