Saving mirrored components as collada

Sketchup has a feature where you can mirror a component using “flip along”. This is very useful if you have two halves of something that will use the same textures and stuff.

But when exporting mirrored components to collada not only does it save them as separate components but all subcomponents are saved separately too.

It seems to only save them as same components if they have rotational or translational transformations, not mirror transformations.

How can I get mirror transformations of components to work when saving to collada?

select all and eplode, then export.
Chek the outliner for indented components or groups

How does that fix the problem? That just deletes my components. Now instead of being 2 instances of the same component its one big ungrouped mesh in the collada file.

1 Like

Then choose the following : select the component and the mirored one, explode and with all geometry still selected, make component

A component is just a ‘wrapper’ or ‘container’ with entities and can hold many levels of groups, components and geometry.
you decide what’s inside
Even the model can act as a container when you import it in an empty file

I think you don’t understand how Sketchup exports components into collada format.
Collada allows instancing of components so that the vertex information doesn’t need to be repeated.

If you copy a component then translate or rotate it sketchup will not repeat the vertex information, it will use the vertex information for the first one but apply a matrix transformation to it.


Here you can see the collada format showing only 2 geometries (cube and room) because the right and left are the same objects just rotated 180 degrees.


but here you can see the same situation but instead of a rotation a mirror is applied. Notice how now there are 4 geometries. Sketchup is failing to instance these components and repeating the vertex information for the cube and room 2 times.

In the outliner its identical. 2 components room and cube, regardless of the mirror. But this is not reflected(no pun intended :P) in the exported collada file.

1 Like

Have you tried scaling -1?
Maybe that will work

Thanks! That seems to work. Its back to 2 geometries in the collada file. Any idea why?

Nope! From what you are describing, namely that rotate and translate work, I would thought that the flip along fit better than the scale tool. Maybe @TIG could chime in?

It’s down to the Collada exporter.
But I think that the Collada file format only supports basic transformations, like translation and rotate.
It does not include Mirroring [or perhaps even -ve Scaling ?].
So any component-instances that have been transformed like this are exported as new separate definitions…

So perhaps you are wanting the exporter to do something that is not possible ??

1 Like

From my testing scale seems to work. It doesn’t create a new geometry but instances existing. I’m wondering if the normals won’t get messed up though.

1 Like

Maybe the Collada format specifically forbids scaling by a factor less than 0? Scaling to negative would cause faces to be flipped because it reverses the winding order and they would need to be re-flipped when drawn to the screen. SketchUp handles this natively but it’s possibly not allowed in the Collada specification.

Just thinking out load.

@alexfevery, what strikes me as very odd is (according to your experience with both methods) that SketchUp would allow the existence two identical looking instances, even showing them as such in ‘Entity Info’ but in fact they appear to be not. The mirrored one then seems to be different from the flipped one.
I can imagine the exporter is developed to not being capable of handling flipped instances. But where does SketchUp ‘hide’ its information to distinguish between a flipped instance and a scaled (-1) instance.
It’s somewhat scary if we (the SketchUp users) aren’t aware of this, thinking they are the same.
(reset scale and scale definition is available to both the flipped and the mirrored instance)

1 Like

I took a quick look at the Collada 1.4.1 specs. Transform elements include

  • lookat
  • matrix
  • rotate
  • scale
  • skew
  • translate

The spec for scale says it consists of three floating point values for the scaling of the x,y,and z axes. It says nothing about restrictions on the values (such as positive or non-zero). So I have to agree with @TIG that this behavior results from the way the exporter was written, not from Collada per-se.

It’s interesting that the matrix element is a 4x4 that could be generated directly from SketchUp’s representation, the only possible issue being row vs column dominant ordering (I didn’t check whether they are the same).

2 Likes

I have loaded up the model in 3DS max after using the -1 scale technique and the mirrored object normals are correct. In fact everything seems fine with the model. It is the same mesh with a reflection matrix transformation applied.

Is there some difference between flipped and -1 scaled components under the hood in sketchup that would cause the collada export to be incorrect? If not should we submit this as a bug?

3 Likes

Seems yes.
And if so, how would this affect using SketchUp itself? In Dynamic Components perhaps?

1 Like

People have previously noticed that there may be some internal details of Transformations that are not exposed via the Ruby API or the SDK. For example, SketchUp seems to remember that a Transformation was created explicitly as an Identity vs being an Identity based on values. Speculation is that there is some undocumented optimization involved.

Regarding flip vs -1 scale, I did the following experiment: I created a component and made two copies of it. I flipped one copy along red and scaled the other copy by -1 along red. Then I compared the matrix representations of their Transformations using the Ruby API. The part of the matrix that determines scaling was identical (basically an Identity with -1 in the first element). But the experience reported here indicates that the Collada exporter does distinguish between them, which as @Wo3Dan says, suggests there is another secret internal flag.

I suppose one could quibble about whether representing the same geometry in two ways, one more efficient than the other, is a bug or just a quirk.

2 Likes

Perhaps something here ?

Get Component Rotation (x, y, z) - #4 by Aerilius

I just did an experiment myself with Collada. I created one component, made one copy that I flipped (using SketchUp’s flip command) and one that I scaled to -1 (using scale tool).

When opening the .dae file in a text editor there was 2 “component definitions”/nodes by the same name as that of mine in SU. One was referenced by the original un-flipped instance and one by both the flipped ones, regardless of how they were flipped.

I compared these two “component definitions”/nodes and their only difference was the order of the vertices of the mesh. However when manually changing the instances to all reference the same definition the face orientation didn’t change as I had expected. They seem to contain the same data, just differently formatted.

Bottom line, I think this is a quirk of the Collada exporter. It seems however that you can just manually replace the reference and purge the definition you don’t need.

My models are complex and I cannot keep track of which components have been mirrored using -1 scale vs flip. I either need a way to tell in sketchup which method was used or a plugin that converts them from flip to -1 scale in the collada export. I can’t sort through this massive collada file by hand trying to look for duplicate components.

my OpenGL app depends on being able to identify instanced components by reading the collada file. So is there really no way to make sure before I export?

My experiment suggest there is no difference in flipping and scaling to -1. They seem to be identical and it seems the collada exporter is to blame for creating unique definitioons/nodes. However both definitions in the collada file have the same name property (the component definition name). Perhaps you could write a script to clean up the collada file by changing the references and purging the unused definitions?