Hey guys, I’m trying to write a level exporter in Blender, but I’m having trouble getting certain scene related info in Python.
For example, I’m trying to get the color of a light, but the scene.object.color returns 0.0, 0.0, 0.0 - I’m assuming that is because this returns the object color, not the actual color the light emits?!? (because a light is treated as a simple object, rather than a special light-object)
Why can’t I get a list of cameras and lights separate from the meshes? They all have different attributes that I can’t get just by treating them as general objects, which is a bit of a pain… any workaround ideas?
There should be a way to differentiate between meshes, lights and cameras, so you can get their individual attributes that other types don’t have…
Thats it, thank you! I need to get more familiar with the API
I see you can get all cameras using bpy.data.cameras, but the camera type object doesn’t possess a location attribute… so in the for loop you have to work around it by using scene.objects[i.name].location…
Yeah, it separates object instances from object data. It can be really handy when you have 100 identical lights in your scene though.
using that objects[‘name’].data give you direct access to the same data block as going through the data.lamps, so if you iterate through the objects, you can pull i.location and i.data.color at once.
I have an insanely big problem now however that I hope someone can maybe help me with?
When I use the built in “Export to .OBJ” function, it exports the obj correctly, Forward Dir is “-Z” and Up Dir is “Y”
However, when I just loop through the vertices of a mesh myself and write them to file, it writes the vertices according to Forward = Y, UP = Z.
The reason I know that is that I compared the file I exported via script & the file I exported using the built in obj exporter, setting the direction to fw=Y and Up=Z
Sounds like I have to multiply the vertex coordinates of a mesh with some Matrix to get the right coordinates - any ideas?