I am using Sketchup C sdk to render sketchup models using Unreal.
Most of the models render correctly.
I faced scaling issue with one particular model.
I use the transformations as something like this, FinalTransform = ParentTransform * ChildTransform
where I get the Parent and Child Transforms using SUComponentInstanceGetTransform
Monitor in the model is not scaled properly.
The up axes of monitor definition is Y-axis.
If I change the up axis of monitor to Z-axis, then it is rendered properly in Unreal.
So, I am guessing that I need to include the Axes info of component definition to calculate the transformations correctly.
Any thoughts ??
I am attaching the model for reference.
SketchUp and most game engines use different coordinate systems (axes.)
In game engines up is Y, and Z points out of the screen towards the viewer.
In SketchUp, Z is Up, and Y points away from the viewer. (X points to the right in both.)
So, I believe you’d need to “output” final SketchUp coordinates to (X, Z, -(Y)) for Unreal.
I am taking care of the conversion between SketchUp axes system and Unreal axes system.
I multiply the ConversionMatrix at the root node itself.
For calculating the relative transformation of each entity, I do this: FinalTransform = ParentTransform * ChildTransform
where I get the Parent and Child Transforms using SUComponentInstanceGetTransform
This works for the most of the models.
But, with very few objects inside a model relative transformations are incorrect when I use the above method.
In the image below, left is from sketchup and right is from my rendred scene. Transformations of monitors are incorrect.
I mean, I changed the axes of monitor definition so that green axis is pointing up, whereas, earlier blue axis was pointing up.
And, I see this API, SUComponentDefinitionSetAxes().
So, do I need to include the Axes info of component definition to calculate the transformations correctly ?
A black rectangular 3D block whose drawing element coordinates need to be multiplied by FinalTransform, as the 3D block is nested inside an outer component instance; and
A 2d rectangle representing the image, consisting of two triangles that are only in the outer component, and whose coordinates need to be multiplied by OuterTransform only;
That will solve having the image a different size than the black rectangular cube.
(As a side note, all rectangles are constructed from triangles, and was likely originally drawn outside of Sketchup).