Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

How to rotate or translate a MRenderItem in an MGeometry ?

How to rotate or translate a MRenderItem in an MGeometry ?

Anonymous
Not applicable
723 Views
3 Replies
Message 1 of 4

How to rotate or translate a MRenderItem in an MGeometry ?

Anonymous
Not applicable

Hi,

In a maya plugin (c++), I have an MPxLocatorNode using a MPxGeometryOverride.

In the updateRenderItems function, I am creating MRenderItems and in the populateGeometry function, I am adding geometry to these renderItems.

Is there a way I can rotate or translate a renderItem without touching all the vertices I assigned to it ?

Thanks !

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

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi, 

 

You can use MRenderItem::setMatrix to apply a world matrix to it. You can do translate and rotation in the world matrix.

 

Yours,

Li

0 Likes
Message 3 of 4

Anonymous
Not applicable
Oh, indeed ! Rtfm 🙂
Thanks !
0 Likes
Message 4 of 4

negow
Advocate
Advocate

I'm having trouble with this.

 

MRenderItem::setMatrix does operate in worldspace using MPxSubSceneOverride, but not MPxGeometryOverride. For example this here is a no-op, does nothing.

 

void MyNode::updateRenderItems(const MDagPath& path, MHWRender::MRenderItemList& renderItems) {
    // ...
    const auto matrix = MMatrix::identity;

    for (int i=0; i < renderItems.length(); i++) {
        MRenderItem* item = renderItems.itemAt(i);

        if (!item) continue;

        item->setMatrix(&matrix);
    }
}

 

It can be reproduced by putting this into the geometryOverrideExample1.cpp example in the devkit, tested in Maya 2020.

 

Any matrix I set is relative the DAG node transform itself, not worldspace. Is there a way to fix this, other than involving an inverse matrix?

0 Likes