In a class called CIrrlichtManager I have this code sniplet:
ISceneManager* smgr = device->getSceneManager();
Then, in another class called CModelManager I want to use that smgr. So I have this:
scene::IAnimatedMesh* weaponMesh = CIrrlichtManager::smgr->getMesh("models/meshFile.obj");
But, that gives me this error:
CModelManager.cpp(13) : error C2227: left of '->getMesh' must point to class/struct/union
type is ''
Obviously it thinks smgr is not a defined? How can I fix this? Thanks.
Referencing smgr from another class
Well, is CIrrlichtManager::smgr static? If it is, did you allocate memory for it
(as gloabal variable)?
(as gloabal variable
Code: Select all
ISceneManager* CIrrlichtManager::smgr =0;-
Guest
Also, currently I have this code in a function in CIrrlicht called initIrrlicht.
If I want that to be the Irrlicht base class so I can use CBlah : CIrrlicht for child classes, should I move that code into the constructor? or..?
Thanks.
Code: Select all
IrrlichtDevice* device = createDevice(EDT_OPENGL, dimension2d<s32>(800,600), 16, false, false, 0);
//Define video driver, GUI environment and scene manager
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
//Create our FPS camera
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 30, 50, -1);
Thanks.
Am I missing something? What I showed works fine for me. I have a class called CGame and in it a public member declared like this
At the beginning of game.cpp I allocate memory for the static variable like
In the constructor of my class CPlayer (which does not inherit from CGame) I have
All works fine for me.
Code: Select all
static ISceneManager *smgr;Code: Select all
ISceneManager *CGame::smgr=0;Code: Select all
mesh=CGame::smgr->getMesh("player.x");