DrawMeshBuffer with *.obj files - empty mesh buffer

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jcarew
Posts: 34
Joined: Wed Jul 04, 2007 3:54 pm

DrawMeshBuffer with *.obj files - empty mesh buffer

Post by jcarew »

If I render *.ms3d mesh by:

Code: Select all

Driver->drawMeshBuffer(mesh->getMeshBuffer(0));
All it's ok but if I render *.obj per drawMeshBuffer my mesh, I don't see my mesh:( Why? With smgr->drawAll(); it's ok, but I need drawMeshBuffer support for obj.
Last edited by jcarew on Tue Oct 23, 2007 3:25 pm, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You need to set the material and the world transform before you draw anything. Look at the implementation of the render() method of any of the scene nodes. They all do this, but your code does not.
jcarew
Posts: 34
Joined: Wed Jul 04, 2007 3:54 pm

Post by jcarew »

I add set the material and the world transform before drawMeshBuffer, but mesh isn't visible and function getPrimitiveCountDrawn() show 0 triagles.

My code look like this:

Code: Select all

IAnimatedMesh* mesh = SceneManager->getMesh("human.obj");
// next I add nodes, position etc...
scene::IMeshBuffer* mb = mesh2->getMeshBuffer(0);
// Now test function:
if(!mb)
printf("Error");
// Other code from application...
Why mesh buffer isn't create? With IMesh* mesh I too have error. If I load human.ms3d it's ok... I think that is problem with SMesh and IMesh structures.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You create "mesh" and use "mesh2". Looks like two different variables to me.

edit: Btw. to test if you .obj does work you can load it in the meshviewer (example 09).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
jcarew
Posts: 34
Joined: Wed Jul 04, 2007 3:54 pm

Post by jcarew »

Of course in code I use mesh:)

Code: Select all

scene::IMeshBuffer* mb = mesh->getMeshBuffer(0); 
In MeshViewer and with function render() and drawAll() mesh is properly display, but If I try getMeshBuffer, my buffer is empty:/
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Just guessing, but maybe several buffers are created and the first one is really empty? I think something like that could maybe happen if a material is defined but never used. Not sure, but you could try getting the other meshbuffers.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
jcarew
Posts: 34
Joined: Wed Jul 04, 2007 3:54 pm

Post by jcarew »

With mesh *.X, *.B3D, *.MS3D it's ok, but with *.OBJ, *.3DS is this problem... I think, than this work only with SAnimatedMesh structure and SMeshBuffer structure...
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

You have to render mesh by this steps:
1. You create an IAnimatedMesh eg:

Code: Select all

IAnimatedMesh* mesh = SceneManager->getMesh("human.obj");
2. You have to return a mesh to other IMesh eg:

Code: Select all

IMesh* m = mesh->getMesh(0, 255, 0, 0);
3. You create an IMeshBuffer eg:

Code: Select all

IMeshBuffer* mb = m->getMeshBuffer(0);
4. Now You can display all meshes (obj, 3ds, b3d etc.) by drawMeshBuffer eg:

Code: Select all

Driver->drawMeshBuffer(mb);
You need set world transform;)
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
jcarew
Posts: 34
Joined: Wed Jul 04, 2007 3:54 pm

Post by jcarew »

Now it's ok:) Big Thanks Nadro
Post Reply