Why do they invoke...

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
ProjectIRR
Posts: 21
Joined: Mon Oct 26, 2009 3:21 am

Why do they invoke...

Post by ProjectIRR »

In example 1 the writer invokes a IAnimatedMeshSceneNode
IAnimatedMesh* mesh = smgr->getMesh("../../media/test.obj");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
In example two the user makes a scene node, then seems to, redefine? it as some kind of other scene node?
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::IAnimatedMesh* buildingmesh = smgr->getMesh("../../media/buildingtest2.obj");
scene::ISceneNode* node = 0;
scene::ISceneNode* buildingnode = 0;

if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0), 0, -1, 1024);
if (buildingmesh)
buildingnode = smgr->addMeshSceneNode(buildingmesh->getMesh(0));
I added a mesh in the code above

I'm just wondering why he took this seemingly extra step.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

They are just checking to make sure that the mesh pointer is valid before initializing the scene node. That being said the current examples don't necessarily portray the recommended coding style as they are more designed to show Irrlicht usage in a simple manner rather than the basics of C++ coding.

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply