Halaman

Kamis, 25 Oktober 2012

[Irrlicht]Working with files:Intro

Hi there! if any of you need a quick code snippet to work with file in Irrlicht:

//Reading file sample
io::IReadFile *f = App::Instance()->GetDevice()->getFileSystem()->createAndOpenFile("didum/dadam/anykindoffile.ext");

//this is how you get actual path (physical/not relative), it will return the input given to it if no actual path was found
io::path p = App::Instance()->GetDevice()->getFileSystem()->getAbsolutePath("didum/dadam/anykindoffile.ext");

//preparing a buffer to save the file contents
char *buffer = new char[f->getSize()];
long fl = f->getSize();

//read that file to the buffer
f->read(buffer, f->getSize());

//writing file sample
io::IWriteFile *wf = App::Instance()->GetDevice()->getFileSystem()->createAndWriteFile("savedname.saved");
wf->write(buffer, f->getSize());
wf->drop();
f->drop();

delete [] buffer;
Fair warning though.. i did not included the safe checking for the file exists etc.. i guess you know where to put them right ;) Cheer!

Minggu, 21 Oktober 2012

[Irrlicht]Blender 2.6X as your game scenes editor?

Just a quick note for me to implement scene / level editor in the future,
You could generate your UVs, Images, Vertices, Faces (even triangulates them) through the python scripting library..

And by using blender's "Append / Link" along with "Custom Properties" , we should be able to load / re-use and do almost everything to compose our game world. Wouldn't it be great to have msvc express for the IDE, angelscript / lua as the scripting interface, and Blender as your modeler and game scene editor?

For the 'future me" here is a list of scripts function which will help you.. :p
  1. dont forget the 'dir' command! example: dir(bpy.data.meshes['mesh_id']
  2. bpy.data.images['IMAGE_ID'].filepath for retrieving physical location of the image file used as the texture
  3. bpy.data.libraries['LIB_ID'] for your external files..
  4. list(bpy.data.meshes["YOUR_MESH_ID'].vertices) this is an array of your vertices
  5. list(bpy.data.meshes[' YOUR_MESH_ID '].faces[1].vertices) this is the face, and the indexs of your vertices
  6. it is a bit longer to get this one.. but here it is.., to get the texture coordinates: bpy.data.meshes["YOUR_MESH_ID"].uv_textures['UVMap'].data[1].uv# with # being 1 to 4..
  7. a simple tutorial on wikibook : exporting scene!
Now there you have it.. a complete arsenal to represent a 3d world (vertices, faces, textures, texture coordinates, and transforms..) what? owh yes.. what about animation you asked? well.. for the time being, if you need an animated mesh, you should consider manually add them to your 'static' world ;)

cheers!