Previous Thread  Next Thread

chat icon Python script help

jpannonius

Posted: Tue Jul 31, 2012 12:56 pm
Joined: 31 Jul 2012
Posts: 2
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.
Reply with quote


stiv

Posted: Tue Jul 31, 2012 6:17 pm
Joined: 05 Aug 2003
Posts: 3645
For reading and writing binary data, the Python struct module it your friend. It will also do big endian/little endian conversion.
Reply with quote


jpannonius

Posted: Wed Aug 01, 2012 7:41 am
Joined: 31 Jul 2012
Posts: 2
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.
Reply with quote


stiv

Posted: Wed Aug 01, 2012 4:09 pm
Joined: 05 Aug 2003
Posts: 3645
1. do the tutorial in the doc section at www.python.org

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


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group