Extending B3DMeshFileLoader and ISkinnedMesh

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
xray
Posts: 231
Joined: Fri Feb 02, 2007 1:06 pm
Location: Germany, Munich
Contact:

Extending B3DMeshFileLoader and ISkinnedMesh

Post by xray »

I made a 'very' little extension to ISkinnedMesh and CB3DMeshFileLoader to be able to load the nodes from one b3d file as seperate SceneNodes. It isnt much, but could be helpful for someone else, and maybe it is possible to add it official to irrlicht svn ??

The only thing I had to know after loading a mesh, is which meshbuffers belongs to which joints, because the information of nodes inside a b3d file is stored into a joint... but theres still missing information which meshbuffers belong to which joint.

In 'ISkinnedMesh.h' I added this variable into the SJoint struct:

Code: Select all

core::array< u32 > FolderMeshBuffer;
And into 'CB3DMeshFileLoader.cpp' I added the following marked line into 'readChunkMesh' method (row 273):

Code: Select all

		else if ( strncmp( B3dStack.getLast().name, "TRIS", 4 ) == 0 )
		{
			scene::SSkinMeshBuffer *MeshBuffer = AnimatedMesh->createBuffer();

			// MARKED LINE
			InJoint->FolderMeshBuffer.push_back( AnimatedMesh->getMeshBuffers().size() );
			// ----------------------------

			if (brush_id!=-1)
			{
				loadTextures(Materials[brush_id]);
				MeshBuffer->Material=Materials[brush_id].Material;
			}

Cheers!
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

So using this "mod" you could retrieve a "scene" from a B3D file?

Will that still work with a character hierachy? How the B3D file need to be so that elements will separate as scene nodes?
xray
Posts: 231
Joined: Fri Feb 02, 2007 1:06 pm
Location: Germany, Munich
Contact:

Post by xray »

No with this mod you dont retrieve a scene from a b3d file, thats something you have to code it your self. But with this extension you know which mesh buffer depends to witch node in a b3d file. So if you have a b3d file with some nodes in it for example with one node is a street and other nodes are buildings and so on, than you can create separate scenenodes with the following code logic:

+ loading the b3d file over getMesh into an scene::ISkinnedMesh
+ get all joints from ISkinnedMesh (every joint is representing a b3d node)
+ access to the joints folderMeshBuffer and append all MeshBuffers from folderMeshBuffer to an SMesh
+ recalc bounding box from SMesh
+ create a scenenode from SMesh over sceneManager->addMeshSceneNode
Will that still work with a character hierachy?
I dont think so because there is no information in the SJoint struct of the hirarchy of the b3d nodes. but I think it shouldnt be so difficult to append this function. For this you have to modify the SJoint struct and the b3d loader.

cheers
Post Reply