Is it Posible Loading separated mesh from one file ?

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.
radiant
Posts: 112
Joined: Fri Feb 22, 2008 8:04 pm
Location: Mexico

Post by radiant »

lets say... i have something like this:

Image

it has 4 materials

will i get 4 meshbuffers even if i use join in blender or use join -> convert to editable mesh in MAX ??

In this proyect.... every equip is goin to be something like this...

and a single scene is goin to have quite a few of em....

since i dont know what my scene is goin to have.... cause i wont be the one putting it together, i have to take a scene file... wich god knows what has in it... and break it into separated scene nodes and then i have to somehow find out what equipment is in every node....

so if i try to use something like this:

Code: Select all


scene::IMesh* m = Device->getSceneManager()->getMesh(my_scene_file.3ds);

iMeshSceneNode *meshes[m->getMshBufferCount()];

for(int i=0; i< m->getMeshBufferCount();i++)
{

//Load meshes into array
//Identify mesh as equip

}
what will i get? will this work? or ill get my scene separated into pieces of equipment separated by materials or will i get one mesh for every equip in the scene.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you don't use 3ds, but some other file format, you have a good chance that your parts will also be put into separate mesh buffers. But you will also get always different meshbuffers for different materials. If you need separate meshes, you must save them into separate files, or use a scene file format such as Collada or .irr.
radiant
Posts: 112
Joined: Fri Feb 22, 2008 8:04 pm
Location: Mexico

Post by radiant »

Well.. ok then its settleled....

Thanks for the info
shlainn
Posts: 12
Joined: Tue Apr 01, 2008 1:44 am

Post by shlainn »

I have another question about that: If I have a mesh with say 50 meshbuffers - how can I remove some of these? That is before creating the scene node.
And is there any way to access the mesh after creating the scene node?

Thanks a lot

shlainn
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, just check the API. An IMeshSceneNode will return an IMesh* with getMesh(), for the animated version you have to use getMesh(0).
This pointer has to be casted to the proper underlying mesh class, in order to access the buffers.
shlainn
Posts: 12
Joined: Tue Apr 01, 2008 1:44 am

Post by shlainn »

Ah, thank you,
The typecasting part was the tricky one.

So basically we get this:

Code: Select all

scene::IAnimatedMeshSceneNode* node = irrSceneMgr->addAnimatedMeshSceneNode(myMesh);

//Now access the first mesh buffer of the first animation frame

((scene::SMesh*)node->getMesh()->getMesh(0))->MeshBuffers.erase(n);
//where n is the number of meshbuffes i want to erase.

//But why doesn't this work:
((scene::SMesh*)node->getMesh()->getMesh(0))->MeshBuffers[n]->getMaterial().setTexture(0,irrDriver->getTexture("texture.bmp"));

//or
((scene::SMesh*)node->getMesh()->getMesh(0))->getMeshBuffer(n)->getMaterial().setTexture(0,irrDriver->getTexture("texture.bmp"));

By the way, is there a flag or something which i can set for a MeshBuffer to be drawn or not to be drawn?

Shlainn
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, meshbuffers cannot be made invisble, except by using a 100% transparent materials (oh, or with the very latest SVN, where you can enable backface AND frontface culling :D )
The material should be set via the material of the scene node: Material n of the scene node refers to the material of the nth mesh buffer.
Oh, I think that means that you will ruin your meshes when removing whole meshbuffers... I'll have to check this, maybe we have to add a mesh buffer deletion method in that case.
shlainn
Posts: 12
Joined: Tue Apr 01, 2008 1:44 am

Post by shlainn »

hybrid wrote: The material should be set via the material of the scene node: Material n of the scene node refers to the material of the nth mesh buffer.

Code: Select all

node->getMaterial(n).setTexture(0,irrDriver->getTexture("texture.bmp"));
does the trick

I'm primarily looking for a method to draw only a specific subset of mesh buffers from a mesh, and a possibility to change this set at runtime - any ideas?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Custom scene node, which let's you enable/disable meshbuffers, or split it into several scene nodes (more overhead in run-time, less coding effort).
Post Reply