source icon indicating copy to clipboard operation
source copied to clipboard

Mesh exports should allow a global coordinates option

Open mattngc opened this issue 1 year ago • 5 comments

The "export_obj()" function and related mesh export functions are useful for debugging scenes and viewing them in Meshlab or similar. I recently noticed in a use case that the export defaults to local mesh coordiantes. This is a bit unhelpful when trying to debug a scene where the mesh has a translation/rotation applied to it. Would be great if there is a toggle/flag that let's you set the export as happening in global coordinates instead. This fix is fairly simple.

mattngc avatar Oct 23 '24 11:10 mattngc

@mattngc, what about passing as argument a node object defining the coordinate system you want the coordinates in? Default value could be local coordinates for backwards compatibility.

Mateasek avatar Oct 23 '24 12:10 Mateasek

Yeah, agree it should default to local coordinates for backwards compaitibility. But the mesh already has a transform applied to it (effectively its own Node), we just need a toggle to include that transform. For example

def export_obj(mesh, filename, include_transform=False)

This would give the current behaviour for backwards compatibility but allow you to include the Node transform with a toggle.

mattngc avatar Oct 23 '24 12:10 mattngc

Yeah, agree it should default to local coordinates for backwards compaitibility. But the mesh already has a transform applied to it (effectively its own Node), we just need a toggle to include that transform. For example

def export_obj(mesh, filename, include_transform=False)

This would give the current behaviour for backwards compatibility but allow you to include the Node transform with a toggle.

I think, passing the Node only should be enough:

def export_obj(mesh, filename, node=None)

If the node is not specified, then no transformation is applied. Passing a parent node will apply the local transformation to the parent node, passing a root node will apply the transformation to global coordinates.

vsnever avatar Oct 23 '24 12:10 vsnever

@vsnever , this is exactly what I meant. It would give you the freedom to select the coordinate system you want to export in.

Mateasek avatar Oct 23 '24 12:10 Mateasek

Got it, ok. That makes sense I think.

mattngc avatar Oct 23 '24 13:10 mattngc