Jump to content

Point world position


Recommended Posts

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?

Link to comment
Share on other sites

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 by ssh
Link to comment
Share on other sites

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 by graham
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...