Still learning C++, and I just ran my head against the wall. Say I would like to make X copies of the same scenenode - then everyone would say "you just need to make a class". Okay.. I dig that, but how?
This is some example code that I would like to resuse:
Code: Select all
mesh = smgr->getMesh("house4/house4.b3d");
node = smgr->addOctTreeSceneNode(mesh);
node->setScale(core::vector3df(1.5f, 1.5f, 1.5f));
node->setPosition(core::vector3df(0, 0, 0));
node->setMaterialFlag(video::EMF_FOG_ENABLE, false);
node->setMaterialFlag(video::EMF_LIGHTING, true);
selector = smgr->createOctTreeTriangleSelector(mesh->getMesh(0), node, 128);
node->setTriangleSelector(selector);
metaselector->addTriangleSelector(selector);
selector->drop();
scene::ISceneManager* smgr = device->getSceneManager();
scene::IAnimatedMesh* mesh = 0;
scene::ISceneNode* node = 0;
scene::IMetaTriangleSelector* metaselector = smgr->createMetaTriangleSelector();
scene::ITriangleSelector* selector;
Ok. So far so good. Now this is close to what I would like to be able to do outside the class (let call it items) containing the "House" node creationcode:
Code: Select all
house = items->addhouse(4);
house->position(x, y, z);
house->scale(i, j, k);
house->rotation(bla bla bla);
house->drop();
house = items->addhouse(8);
house->position(x, y, z);
house->scale(i, j, k);
house->rotation(bla bla bla);
house->drop();
// And when the houses works, lots of other items will be added.
lamp = items->addlamp();
lamp->position(x, y, z);
lamp->scale(i, j, k);
lamp->rotation(bla bla bla);
lamp->drop();
How do I white that code? How do I gain access to the vars used in the main program, from within the class? Could someone please help me out here?
Regards Stickbit