raysect / source

The main source repository for the Raysect project.
http://www.raysect.org
BSD 3-Clause "New" or "Revised" License
89 stars 23 forks source link

Mesh exports should allow a global coordinates option #439

Open mattngc opened 3 weeks ago

mattngc commented 3 weeks ago

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.

Mateasek commented 3 weeks ago

@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.

mattngc commented 3 weeks ago

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.

vsnever commented 3 weeks ago

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.

Mateasek commented 3 weeks ago

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

mattngc commented 3 weeks ago

Got it, ok. That makes sense I think.