Question about internal blender format

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
jorrit
Posts: 0
Joined: Thu May 15, 2003 4:01 pm

Question about internal blender format

Post by jorrit »

Hi all. I'm working on blend2cs which is a C++ program to convert .blend files to Crystal Space format. To properly support hierarchical objects (i.e. parented objects in blender) I need to find the relative position and rotation of a child (relative to the parent). I'm using the DNA source to parse the .blend file and in every object I can find the following fields (among many others):

float loc[3]
float dloc[3]
float orig[3]
float rot[3]
float drot[3]
float parentinv[4][4]

I'm uncertain on how to interprete these fields and how I can use that to get the position/rotation relative of the parent. Any help here?

Greetings and thanks,

ideasman
Posts: 0
Joined: Tue Feb 25, 2003 2:37 pm

Post by ideasman »

Use python, youll find it much easier, if there is some variable you need thats not accsessable, then write a hook- its often not that hard, especialy if your just getting data,

- Cam

jorrit
Posts: 0
Joined: Thu May 15, 2003 4:01 pm

Post by jorrit »

ideasman wrote:Use python, youll find it much easier, if there is some variable you need thats not accsessable, then write a hook- its often not that hard, especialy if your just getting data,

- Cam
Sorry but that's not an option for several reasons. First it is an existing program and I'm not going to port to python (especially since I don't know python good enough to do that). Secondly I need to link with other C++/C libraries and doing that in python is a hassle (if you need to integrate with blender at least).

Greetings,

stiv
Posts: 0
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Post by stiv »

Ideasman is right. The quickest, easiest way to do a blender->anything converter is thru the blender python api. And that includes the time needed for a c++ programmer to learn python.

The whole point of the bpy api was to write importers and exporters. My recomendation is to take one of the many existing exporters and modify it to spit out Crystal Space format. Blender *can* run scripts from the command line, by the way.

Whichever way you go, there are a number of design docs over on blender3d.org. Good luck.

LetterRip
Posts: 0
Joined: Thu Mar 25, 2004 7:03 am

Post by LetterRip »

While I agree with Stivs and Cam that it would be faster for you to just learn python and adapt one of the current scripts

you might be able to figure out what you need by looking at the python binding that performs what you want to do, look in directory

blender\source\blender\python\api2_2x\bone.c

Here is a doc on learning python it will probably take you 10 minutes or so to learn well enough to accomplish what you want - be warned, once you use python you will be addicted :)

http://diveintopython.org/

LetterRip

jorrit
Posts: 0
Joined: Thu May 15, 2003 4:01 pm

Post by jorrit »

Please people. Don't try to convince me to use python. I don't like the language (I absolutely hate the fact that indentation matters) and blend2cs is already a big program and I have absolutely no intentions of porting that. But thanks for the other pointers. I will have a look there.

Still would have been nice to simply find documentation documenting what those fields mean. Somebody in the world must know that.

Greetings,

ideasman
Posts: 0
Joined: Tue Feb 25, 2003 2:37 pm

Post by ideasman »

Use python or get sombody else to use python :), thats what its there for... or just dont use Blender.

Failing that, why not add your exported in C allongside blenders existing C coded exporters, though for somthing non standard like crystal space its unlikely to get in the BF-Tree.

jorrit
Posts: 0
Joined: Thu May 15, 2003 4:01 pm

Post by jorrit »

ideasman wrote:Use python or get sombody else to use python :), thats what its there for... or just dont use Blender.

Failing that, why not add your exported in C allongside blenders existing C coded exporters, though for somthing non standard like crystal space its unlikely to get in the BF-Tree.
Bah, I asked a question about internal data structures and all I get are preaches about how I should use Python or other answers that don't help in the slightest bit. Sorry but this is not how you should help people. Just answer the question or don't answer at all.

Greetings,

theeth
Posts: 500
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Post by theeth »

You could use obmat[4][4], which is the orientation matrix of the object (global orientation matrix) and multiply by the invert of the parent's matrix (obmat too).

Martin
Life is what happens to you when you're busy making other plans.
- John Lennon

ton
Site Admin
Posts: 350
Joined: Wed Oct 16, 2002 12:13 am
Contact:

Post by ton »

We unfortunately don't have docs about how Blender internally works for animation systems... most of the clues you can find in the code. :)

If you export to CS, what could work very well is to check on how the game engine in Blender handles it, here a full conversion happens as well.
Another good read is the blenkernel/intern/object.c (where_is_object()).

Basically the object obmat[4][4] matrix is constructed this way:

ob->loc + ob->rot + ob->size => temp matrix => mult with ob->parentinv => mult with parent->obmat => delivers ob->obmat

the dloc, drot and dsize are (animation) Ipo tricks. You could skip that for exporting, too complex.

(Yes I know you deserve a straight answer :) the python API in blender just has a much better level of implementation for this, with docs, support, and so on. A question as you have not many people can answer, so you're left more in the dark to find out things yourself)

jorrit
Posts: 0
Joined: Thu May 15, 2003 4:01 pm

Post by jorrit »

Thanks for the replies! I will soon try this out and see if I can get it working.

Greetings,

jorrit
Posts: 0
Joined: Thu May 15, 2003 4:01 pm

Post by jorrit »

theeth wrote:You could use obmat[4][4], which is the orientation matrix of the object (global orientation matrix) and multiply by the invert of the parent's matrix (obmat too).

Martin
This did the trick! Thanks a lot for your suggestion.

Greetings,

Post Reply