Component Instance Transformation


#1

I’ve been able to read in component instances and definitions from a skp file using the c++ sdk. a number of the component instances have a single transformation attached, If I apply the transformation to the vertices of the component instance will that correctly position the component instance in the world or would I need to apply an additional transformation?

Thanks


#2

Each component instance or group has a single transformation (4×4 matrix). The transformation includes also the translation, so there is no additional data required.

  • make sure you interprete the axis correctly (in SketchUp: x = right, y = back, z = up)
  • components can be nested and form a hierarchy. The vertices of the most innerst component get the transformation of their parent component, then the transformation of the parent of the parent… etc. applied.
  • make sure to consider the 4th diagonal matrix element. It is a uniform scale factor, and if it’s not 1.0 it is multiplied to the x, y, z scale.

How to Transform the components in SketchUp to world space
#3

Thanks for the advice, I had adjusted the vertices to match the axis configuration used by directx x file format but forgot about the configuration of the transformation matrix. That will probably account for why a number of components aren’t being positioned correct In the directx x file conversion utility I’m writing.


#4

Can you please tell me how you fixed the transformation problem. I am not able to get the components properly because of their transformation - since component instance have different transformation from the world( as mentioned they get their transformation from their parent and so on …) .
Thank You !


#5

To make the conversion process easier I use sketchup and make sure any groups or components in the mesh have been exploded I then build a up a collection of all the groups, components and faces within the mesh. I then iterate through all the individual items that make up each group and component multiplying the transformation matrixes at each step of the iteration so that the transformations flow down to subsequence child items remembering to record the transformation matrix along with faces vertices at each stage. When I say iterate I believe I wrote it using recursion.

Once I have built up a collection of faces and transformation matrixes I simply apply the transformation matrix to the vertices when creating the direct x mesh file.

Hope this helps it’s been a while since I wrote the code.


#6

Thanks,
That’s what I have been doing !
I just wanted to know if there is any other way we could do that without exploding.
But no worries, that was helpful !


#7

To make the conversion process easier I use sketchup and make sure any groups or components in the mesh have been exploded I then build a up a collection of all the groups, components and faces within the mesh. I then iterate through all the individual items that make up each group and component multiplying the transformation matrixes at each step of the iteration so that the transformations flow down to subsequence child items remembering to record the transformation matrix along with faces vertices at each stage. When I say iterate I believe I wrote it using recursion.

Once I have built up a collection of faces and transformation matrixes I simply apply the transformation matrix to the vertices when creating the direct x mesh file.

Hope this helps it’s been a while since I wrote the code.