ssh Posted June 25, 2010 Share Posted June 25, 2010 Hello, What is the correct way to get world position of the point of polygonal object? gdp->points()[i]->getPos() Returns local space values. To get world space we need to multiply it by world transformation matrix. There is getWorldTransform() function that works for Objects, not SOPs. What if object with my sop is inside of another subnet or two. How can one get final world position for a point? Quote Link to comment Share on other sites More sharing options...
graham Posted June 25, 2010 Share Posted June 25, 2010 (edited) To get the world space position of a point you can multiply its local position by the world transform of it's parent(container) node. Edited June 25, 2010 by graham Quote Link to comment Share on other sites More sharing options...
ssh Posted June 25, 2010 Author Share Posted June 25, 2010 (edited) To get the world space position of a point you can multiply its local position by the world transform of it's parent(container) node. Thank you. How can one get parent(container) of sop? If there are several containers (like shown below) A | ->B | ->C | ->mySop I need to multiply by parent's matrix and then multiply result by matrix of parent's parent and next, right? Edited June 25, 2010 by ssh Quote Link to comment Share on other sites More sharing options...
graham Posted June 25, 2010 Share Posted June 25, 2010 (edited) You just need to grab the parent object and extract it's world transform. This gives you the total transform of the container and you don't have to care about its parents. You should be able to do something like this: OP_Network *parent; OBJ_Node *container; UT_DMatrix4 container_xform; UT_Vector3 pos; parent = this->getParent(); container = CAST_OBJNODE(parent); container->getWorldTransform(container_xform, context); ... pos = gdp->points()[i]->getPos(); pos *= container_xform; // do whatever you want with the now world space position Edited June 25, 2010 by graham Quote Link to comment Share on other sites More sharing options...
ssh Posted June 26, 2010 Author Share Posted June 26, 2010 Thank you very much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.