[Closed] Problems with group export
Hi everyone,
i’ve searched this forum and i wasn’t able to find anything i could get a clue of.
So here is the problem.
I’m writing a mesh exporter for Kerkythea and it seems that in some cases the objects
get scattered throughout the scene. So pos,scale and rot are exported wrong.
After some investigation i found that the
problem only arises when the objects are grouped.
I use the following code to export the mesh.
snaps = snapshot obj
num_verts = snaps.numverts
for v = 1 to num_verts do (
vert = in coordsys local getVert snaps v
format vert.x vert.y vert.z
)
etc......
Then the objects will be transformed in KT by its matrix
Therefore i use the obj.transform…
This does not works if the object is part of a group. see pic02
If i then ungroup all the objects by hand the export is fine. see pic1
I really can’t get why this happens. So i would be more than happy to receive
some help here. I’ve been batteling with this for about a year now
i have deleloped some workarounds (resetXForm etc)
that unfortunatelly do not work in every case …
that’s why i’m back on it … sure there is a very simple solution for this but
it seems i’m blind …
Thanks alot in advance …
u3dreal
Maybe it has to do with the fact that linked objects (grouped) are defined in their parent’s space.
Probably easiest way is to ungroup/unlink before export and relink/regroup after.
Else you may need to multiply by the inverse transform matrix
Thanks Zbuffer !!!
Ok i will probably switch to multiply with the inverse matrix…
i will have to multiply verts with the invmatrix … yes
and the normals too ? Well if this solves the problem
then i will do it …
cheers
u3dreal
Ok thanks again Zbuffer !!
Now with using the inv matrix it seems to work correctly…
Thanks for the support evryone
cheers
u3dreal
Just one last question,
is there a difference between using
vert = (getVert mesh v)*invmatrix
and
vert = in coordsys local getVert mesh v
??
One thing i noticed — for some objects it still does not work … starnge thing is once i ungroup
and then regroup again it works … ?
Anyone has anidea on how to add that to the script ?
Thanks in advance
cheers
u3dreal
I’ve had some problems with groups reporting their overall dimensions incorrectly until I used setGroupOpen() to open and close the group. This seemed to refresh the reported dimensions for the group.
If this technique does the same for your problem, you might be able to avoid the more complex and potentially destructive step of ungrouping and regrouping.
Thanks John !
I will add this and it gives me a good idea on how to export groups
why not writing groups into an array while opening and closing them …
and exoprt them afterwards
cheers
u3dreal