Object's transform

Hi,

Is there a way to transform an object without changing its original data? Basically, I get a final transform at each iteration and I want to apply the transform on the object and do not want its original data is changed. I just want to set the object’s transform so it can be displayed at the right place.

I do not want to have to calculate the delta change of the transform between the previous transform and the current transform. It is a bit intense for the performance.

Thanks for any hint.

Brian

Rhino data is generally in worldspace - most object types are. That means transforming an object transform the geometry data accordingly.

If you want to work with keeping the object data unchanged you should create your models such that their object center is world 0,0,0. Then create a block from of the object with world 0,0,0 as its base point.

Now you can apply transforms without the original geometry data being changed.

Thanks Nathan for a prompt response.

I am not sure I quite get what you meant by “create your models…”. do you know any sample code like what you describe I can review. I am not familiar with the concept.

What I did in the past was creating my custom object derived from CRhinoPointObject and creating a ON_UserData to store the transform. But with this way I still have to regenerate the object with the new transform which is not optimized.

I found a sample code written by Dale. Is it similar to what you have suggested?

Thanks.

Brian.

1 Like

If you are only interested in the transform before actually applying it then that is probably the way to go.

This is generally done using a display conduit. For an example, you might take a look at the SampleAnimator command, which is part of the SampleUserInterface project found in the SDK samples on GitHub.

– Dale

Hi Dale,

I found a way to apply transforms to the objects without changing their original underlying data. The transforms are applied only for displaying. I use SetDynamicTransform to set the transforms to the objects.

{
   ...
            VxSmartInterface<CollisionGeometry> geo = *itGeo;
            if(geo.valid())
            {
                CRhinoObject* object = dynamic_cast<CRhinoObject*>(RhinoPhysicsPlugIn().mVortexRhinoObjectMap[geo->getProxy()]);
                if(object)
                {
                    VxMath::Matrix44 m44 = part->getWorldTransform();
                    m44.transpose();
                    double m[4][4];
                    m44.get(m);
                    ON_Xform xform(m);          
                    object->SetDynamicTransform(xform);
                }
            }
...
}

It works great. However I encounter one issue that the displayed objects are clipped. It looks line the world transform does not take into account the transforms of the objects. I had to manually create a clipping plane close to the displayed object to be able to view everything. Please see the attached clip for the problem.

Any idea how i can overcome this in the code?

Thank you.

Brian.

Casting away the const pointer and then calling CRhinoObject::SetDynamicTransform is the incorrect approach. You should draw the transformed object using a display conduit, as I have mentioned above. Please referece the sample I also mentioned.

– Dale