Getting Active Camera from Another Class

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
android_808
Posts: 13
Joined: Mon Feb 28, 2005 4:12 pm

Getting Active Camera from Another Class

Post by android_808 »

Noob to C++

I am using the first event receiver from here http://irrlicht.sourceforge.net/phpBB2/ ... ass#28044 . I have began to write my update() function but I am unable to work out how to get the active camera. Spintz uses getObject(), but I think this must be using a custom class or IrrlichtNX or something.

I think I need to use getActiveCamera(). the device is declared in main.cpp as follows

Code: Select all

#include <Irrlicht.h>
#include "CEventReceiver.h"

 using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

 int main()
 {
        // start up the engine
        IrrlichtDevice *device = createDevice(video::EDT_OPENGL,
                core::dimension2d<s32>(640,480), false);

        video::IVideoDriver* driver = device->getVideoDriver();
        scene::ISceneManager* scenemgr = device->getSceneManager();
        gui::ICursorControl * cursorcontrol = device->getCursorControl();
        cursorcontrol->setVisible(false);
        
       
        // set initial window title shown whilst loading
        device->setWindowCaption(L"Cameleon Engine");

        // add .pk3 archive to the file system
        device->getFileSystem()->addZipFileArchive("maps/map-20kdm2.pk3");

        // load .bsp file and show it using an octtree
        scenemgr->addOctTreeSceneNode(scenemgr->getMesh("20kdm2.bsp"));

        // add a first person shooter style user controlled camera
        scenemgr->addCameraSceneNodeFPS();
 
        //create Event Receiver
        CEventReceiver eReceiver;
 
        wchar_t tmp[255];
        
        // draw everything
        while(device->run() && driver)
        {
                eReceiver.Update();
                driver->beginScene(true, true, video::SColor(255,0,0,255));
                scenemgr->drawAll();
                driver->endScene();
                // get driver name and fps to display in window title
		    	swprintf(tmp, 255, L"Cameleon Engine (%s fps:%d)", driver->getName(),	driver->getFPS());
		    	device->setWindowCaption(tmp);
        }

        // delete device
        device->drop();
        return 0;
 }
How can I get device in the event receiver.
android_808
Posts: 13
Joined: Mon Feb 28, 2005 4:12 pm

Post by android_808 »

I seem to have temporarily solved this issue by adding a variable to the EventReceiver constructor. I create the device in main.cpp, then create an instance of the event receiver class as before, sending device as a variable and finally using device->setEventReceiver(&eReceiver)
Post Reply