Hi there, I am using the C++ SDK for rhino, and I want to get the attributes regarding the transformation (and translation, rotation, scale, etc) of that object.
I have been looking through the docs, but so far I have only found:
bool ON_3dmObjectAttributes::Transform ( const ON_Xform & xform )
I don’t think that this will be useful for me. So, what do I do to get the object’s transformation data?
Thanks!
Hi Alex
if You are talking about block instances then the transform is inside the reference
objects.
Geometric objects do not have a transformation like other modelling programs
where the object lives in a local space and gets instantiated trough a hierarchy of transformations.
So, if it is not stored, then how does Rhino determine its position, where it is right now? Usually, in 3D programs and game engines, all objects do have a Vector3 (x,y,z) points to represent their vertices and position.
I need this, as I am making a 3DM exporter to another file format. How should I do that then? How did the Rhino team handle the task of transferring all the object information accurately into another 3d modeling software, especially the object’s position (and also the mesh, mesh indices, etc) ?
I am not talking about the blocks. What I mean is, a regular rhino object, say, a line, a box, etc.
Okay, so how exactly do I get the data where to place the rhino objects when exporting them to another file format in another 3D modeling software/ or a 3D model viewer software, as the one I’m working with requires the transform attributes to decide where to display the object?
So sorry for not being precise and clear with my question. I will explain it now, in a clear manner.
So, my aim is to get the transforms, rotation (quaternion), translations of a rhino object.
Why?
Well, you see, I am working with a 3D viewer software, that has its own object something like this, that is equivalent of a Rhino Object :
struct Object
{
string Name; // which I can get from rhino_object->Name();
string UUID; // equivalent to : rhino_object->Attributes().m_uuid;
bool isVisible; // rhino_object->IsActiveInDocument();
...
..
Vector3 transformation; (Here, vector3 is a custom data structure, that can hold 3 float values. eg (1.2,1.2,3.4))
...
}
So, I need to get the transformation value to let the custom 3D viewer software know the location of the Rhino object.
Now, so far, I’ve got the Rhino objects through the ObjectIterator and the name and UUID through its Attributes(). But, I have no clue regarding how do I get the transformation property.
Was that clear?
Please let me know if it wasn’t . Also, I would love to hear more from you on how can I do this ?
gerryark:
if You are talking about block instances then the transform is inside the reference
objects.
I am not talking about the blocks. What I mean is, a regular rhino object, say, a line, a box, etc.
gerryark:
Geometric objects do not have a transformation like other modelling programs
where the object lives in a local space and gets instantiated trough a hierarchy of transformations.
gerry
Okay, so how exactly do I get the data where to place the rhino objects when exporting them to another file format in another 3D modeling software/ or a 3D model viewer software, as the one I’m working with requires the transform attributes to decide where to display the object?
Hi Alex if You are talking about block instances then the transform is inside the reference objects. Geometric objects do not have a transformation like other modelling programs where the object lives in a local space and gets instantiated trough a hierarchy of transformations. gerry
For the 3dm importer I do just that: rhino objects at (0,0,0) as their object location. If users want they can always reposition the object origos to i.e. the geometry bounding box center.
Hi @dale,
So from what I have gathered from all the helpful answers in here, Rhino objects do not have a separate values to denote their current scale, translation and rotation, right?
(For example, this is a gameobject in Unity3D, which has a Transform component that gives data about its various values:)
So I will use the bounding box and get their origin as the object’s translate (position on the 3d world), as you have mentioned.
Also, so what would be a suitable way to get their scale and their rotation, as these information are crucial for the custom 3D viewer to correctly place objects on the scene?
Hey @jesterking
Yes, that sounds like the way to go for getting the location. Could you also share with me your approach for getting the scale and the rotational values ?
Hey wim,
I apologize , but I’m not sure that I got what you were trying to say.
And I also think I should be more descriptive, so here goes:
Here’s a box in Rhino:
Now, I moved it a few units here and there:
So, what I’m asking is that if the object was at origin in the first at 0,0,0 and now I’ve moved it, how do I know what position is it at right now? Is it stored in somewhere?
In some game engines, there is a separate component inside the object that tells me all that.
For eg, in Unity3D:
I can clearly get the scale, position, rotation value of any object.
So I’m asking, is there any equivalent thing in Rhino for a CRhinoObject, or how should I proceed to get these values?
You’ll find that the transform is still the identity transform, and that the geometry is now different. In other words the geometry gets recalculated completely, and the transform “history” is thus lost.