Urgent - Is there a script to reset/zero all transformation?
-
Yes, there is something definitely wrong there.....hmm. Have you tried exploding everything first? Do you still need to use groups/componets in the fbx export?
Does fbx export come with SU, or is that part of the Lightup plugin?
Chris
-
@pixero said:
This should be an apartment.
Looks like you turned the Dali option on. Is there a checkbox for surreal?
Seriously, it looks like rotations and scalings aren't the issue. Location is the issue. When you originally placed the towels, for example, you put them where you wanted them. They moved. Resetting location to [0,0,0] would move them to the origin. I doubt that would help. I'm afraid you don't have a scriptable problem.
-
For what its worth, I seem to have come around the problem by splitting the model in several parts and exploding everything deeper than one group and then lighting and exporting them separately.
My tests shows it works now so now I'm waiting to see if the highres stuff works also...
I suspect the model was to complicated for the fbx exporter. -
Chris, you think it could be similar problem as with the Faceme components? SU scaling transformation?
-
In LightUp's Tour mode it all looks OK but after exporting and opening in different apps (Unity and 3ds Max) its a mess.
As I said, I suspect that the scene was to "heavy" for exporting in one go.@unknownuser said:
Chris, you think it could be similar problem as with the Faceme components? SU scaling transformation?
Still if there is a fix for that it might help in the future...
-
Yeah, that would be my guess. I suppose a script could be written to go through and reset all scaling transformations to a more universal translation, instead of the SU shortcut of just adjusting the last element in the transofmration array to act as a global scale modifier. I had considered writing this plugin previously but I decided not to bother since it seems so rare to come by. But perhaps it would have its uses. This might be a good model to test it on.
Chris
-
Please do write it.
-
I've alsmost got something ready for you to test. Does anyone know (I know you do!) what classes get listed in the
model.definitions
? I am planning on iterating through all definitions and then instances to straighten out their transformation. But I need to know what to weed out. I am guessing I would only include groups and components, is there anything else whose transformation might need to be reset?Chris
-
The
model.definitions
returns a list of 'component_definitions' which includes all components, groups and images... you can test for the last two with.group?
and.image?
http://code.google.com/apis/sketchup/docs/ourdoc/componentdefinition.html -
Well, I don't know if this is perfect. It should reset the scaling of all groups and components. Just enter this all as a single line of code into the ruby console.
ins = [];Sketchup.active_model.definitions.each { |e| e.instances.to_a.each { |x| ins << x } };ins.each do |e| if (e.class == Sketchup;;ComponentInstance) || (e.class == Sketchup;;Group);old_t = e.transformation.to_a;old_t[15] = 1.0;ngsm = (1)/(e.transformation.to_a[15]);e.transformation = Geom;;Transformation.new(old_t);e.transform! Geom;;Transformation.scaling(ngsm,ngsm,ngsm);end;end
Then try to re-export. I'll be interested to see if this changes anything. Thanks!
Chris
-
ok thanks TIG! I couldn't remember if it was more than just those 3 classes. In the end, I just filtered out anything that was not a group or componentinstance. I think that works out safely.
And the theory behind what my code is fixing is simple. SU uses a cheap trick to sometimes adjust the global scale of objects. It just changes the 16 element of the transformation matrix from "1.0" to a global multiplier (0.5 if the component is scale 2x larger, for example). And then it multiplies the rest of the transformation object by that 16th element. BUT, the 16th element of the transformation array is ignored by most other apps. So when exporting to renderers, they often do not take into account that a component might have a global scale modifier applied to it, hiding in that 16th element. Thus they ignore the global scale entirely, causing problems.
So this snippet will go through and determine what the global multiplier is, and apply it to the transformation matrix and reset the 16th element to 1.0. Thus the components should export correctly because all their scale data should be contained in the regular location inside the transformation matrix.
We'll see if it really helps though.
Chris
PS. This snippet WILL fix face me components that rotate all crazy in SU 7.1, as that is also a side effect of SU's own cheap global scaling trick, if anyone is having problems with that.
-
Did you get a chance to test this Jan?
-
@chris fullmer said:
Did you get a chance to test this Jan?
Sorry for not getting back.
I managed to export the scene in smaller chunks and am currently finishing it up in time for my deadline.
I will try it when things calm down later this week.
Thank you very much, I'm sure I will use this in the future. -
@unknownuser said:
The best way to tackle this issue is to explode EVERYTHING. It takes a while, especially with larger models, but it's nearly full-proof. Same thing happens when exporting to certain other formats. The Group/Comps structure of SketchUp isn't translated properly. Exploding the model puts everything in one context.
You might want to have a look a TBD's Bomb script. It explodes everything without having to do it manually. It takes the same amount of time, but you can 'set-it-and-forget-it' and wait till it's done. Might be hours though.
HTH
The thing is I don't want to explode everything, since that removes any control over how lightmapping is applied on certain objects.
Anyway you can watch the result here:
http://forums.sketchucation.com/viewtopic.php?f=81&t=28907 -
Please oh pretty please try my code snippet? Just to see if it helps, or if it even just doesn't crash. I'd love to see if that little bit of code could fix it all.
Chris
-
Oh and maybe I didn't explain it well enough. It does not change anything visually in the model. It will all look exactly the same. Nothing gets exploded. So just run it, then re-export and see if it helps sort out the issues. Thanks!
Chris
-
@chris fullmer said:
Please oh pretty please try my code snippet? Just to see if it helps, or if it even just doesn't crash. I'd love to see if that little bit of code could fix it all.
Chris
I will I will. Next week I'll have to make some modifications so I'll have to re export at least parts of the scen. I will try it then if not before.
-
Chris, I tried the script but it didnt work. Same mess as before.
Will try again later. -
Bummer, I was very hopeful. Any chance you could forward me a copy of your model to test a few things on?
-
I'll do that tomorrow.
Advertisement