Exporting scene as wavefront (obj) with mesh coordinates relative to object origin

Hello all,
First, my apologies if this is a trivial question. I’m trying to find a way to do this, for hours, without success. I tried searching everywhere for a answer, but all I got was a python script that does not seems to work, and someone that hacked blender export script for doing what he wanted (but did not post the solution).
So, I’m developing a 3d world (university task) in OpenGL, and I’m using blender for modeling the buildings and export the model to obj. On that side, everything is working as expected. What I want to do now, is to make blender export the model with the mesh vertices relative to the object center, instead of the scene center (I mean, I don’t want the translations on the obj file). What I want to do, is to create all buildings inside the same blender project, so I can arrange them in position, export each object to a separate obj file, and perform the translations inside my code. But, when I try exporting a selected object, is gets exported with it’s coordinates relative to the whole scene, instead of it’s own origin.
Is there a way for doing that, or the only way is translating the object manually to the scene origin before exporting it ?
I’m kite rookie with blender, so, again, sorry if it’s some kind of silly question.
Thanks in advance

Regards

What happens if you export with the “selection only” checkbox listed? Does that export your single mesh with just object coordinates? If so then you might just need a script that loops though all the Objects in your scene, selects them individually, and exports them.

I would recommend another approach however. You should model each object in a separate .blend file. This keeps all your model data separate and tidy. Then you make a separate .blend file where you link in all the objects from the individual files.

To get your objects you just export from the individual files. When you export your scene it could just dump out the translation/rotation/scale for each object.

I tried exporting with ‘selection only’, but, the result is the same: the object is on world coordinates.
I thought about that too, and it’s is probably what I’ll do if there is no way to export the mesh coordinates (and it’s wwaaayy cleaner then translating the objects back to the world origin too, hehehe, thanks).
Even though that mostly solves my problems , I guess that this feature would be a good one to have, isn’t it ?I can be wrong, I’m a complete rookie regarding computer graphics :stuck_out_tongue:
Thanks :slight_smile:

I just tried your sugestion, but , I could not make it work.
If I link the projects, I can’t translate the objects of the linked model. I’m I missing something ?
It’s seems to me, up to now, that the only way is to export the other models, and import them in the ‘scene’ project. Is there any other way ?

Thanks

in export_obj.py, locate

me.transform(EXPORT_GLOBAL_MATRIX * ob_mat)

and change it to

me.transform(EXPORT_GLOBAL_MATRIX)

Note that location, rotation and scale will be in local object space. If you just want local location, then you’ll have to replace the me.transform by custom code for all vertices etc.

normal process would be - if you want some objects to be exported at a different locations -
you create a keyframe for this setup(= the object is in the center and not rotated and maybe if needed with a different scaling).
Then you have to export this keyframe of your object.

But if you have a lot of different objects and need to export every one to a different file out of one setup - then you may need to do some manual settings and not use the normal gui-setup for the export.
The gui-usage is a pain if you have to re-do an export every time after a few changes.

Once you link an object into a .blend file, you have to make a proxy object if you want to be able to manipulate it. Select the object, hit spacebar, and type ‘Proxy’ you should see an option to “Make Proxy”. That will let you move the object around in your scene once it is linked.

That’s the best solution for my problem. I can work all models independently… and create a project for the whole scene, where I can position everything where it must be, and, if I update the model, the scene project gets updated. Perfect :slight_smile:
Thank you :slight_smile: