I have done a lot of C++ and 2D stuff in the past, but just trying to get to grips with this engine. My C++ is rusty as I haven't done any C++ projects for a while too.
I notice a lot of tutorials keep everything in the main.cpp which I understand is to keep things simple.
In 2D if i was to make a sprite I wouldn't just add it all before main. I would make a sprite class, using a header file and various methods or functions for all the things that sprite can do.
This way I can have instances of the sprite class.
I presume I would be able to do this with a 3d mesh. eg make a class and send the model to that class, rather than having countless nodes.
eg in 2D to initialize my sprite I may do
crosshair.LoadSprite(L"data//crosshair",50,50,11,550 );
which calls my LoadSprite class and initializes the sprite.
I am pretty sure I can do this to call game entities, but not entirely sure the best way to go around this.
I presume I could set up the following code in the header file of the class
Code: Select all
IMesh* invader = smgr->getMesh("invadertest.obj");
IMeshSceneNode*node = smgr->addMeshSceneNode(invader);
if (node)
{
node->setMaterialTexture(0, driver->getTexture("invader.tga"));
node->setMaterialFlag(EMF_LIGHTING, false);
}
I like to split my code up like this because it is easier for debugging, but I am new to the 3D side of it, but I wouldn't actually put IMesh* invader = smgr->getMesh("invadertest.obj"); as the obj would be passed to the function from the main.cpp if you know what I mean
Any thoughts are welcome
Asimov