Python script help

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

jpannonius
Posts: 2
Joined: Tue Jul 31, 2012 12:35 pm
Location: Hungary

Python script help

Postby jpannonius » Tue Jul 31, 2012 1:56 pm

Hi all,

I'm working on a C++/Direct3D game engine now, and I'd like to make an export script for bring blender models to the engine. But I wouldn't like to use common model formats, I'd like to use custom one in hexadecimal format. Although, I haven't got any experience in Python scripting, so I modify one of the built-in scripts in the blender directory. This is the RAW exporter. Originally the raw_export.py has got the tag 'wb' that makes the export of the data to binary format, but it is somehow in decimal format. Yes, and the content of the file could be modified by hex editor. I don't know that you could understand me, but the format should'nt be string. It must be in binary format if I'm understandable. And a little problem. When I modify the display format from %f %f %f to %f%f%f, there will be dots between the values instead of spaces. But I don't like them at all, but I could ignore this problem by modify the code in C++, but i would like to ignore them. And is there a way to reverse the byte order in the floats? Thanks!

ehhm. sorry for english, i'M 14 now.

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

Postby stiv » Tue Jul 31, 2012 7:17 pm

For reading and writing binary data, the Python struct module it your friend. It will also do big endian/little endian conversion.

jpannonius
Posts: 2
Joined: Tue Jul 31, 2012 12:35 pm
Location: Hungary

...

Postby jpannonius » Wed Aug 01, 2012 8:41 am

stiv wrote:For reading and writing binary data, the Python struct module it your friend. It will also do big endian/little endian conversion.


But how can I use it? Do you have any examples? Because I have 0% experience in Python.

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

Postby stiv » Wed Aug 01, 2012 5:09 pm

1. do the tutorial in the doc section at www.python.org

2. look at the docs for the struct module. it has examples.


Return to “Coding Blender”

Who is online

Users browsing this forum: No registered users and 2 guests