Code: Select all
#include "StdAfx.h"
#include "Newton/physicsman.h"
//________________________________________________________
// Default constructor
Plate::Plate()
{
printf("\nPlate created.\n");
mass = 2;
width = 3;
length = 4;
//platePos = (0, 0, 0);
mesh = smgr->getMesh("data/smallcube.3ds");
node = smgr->addAnimatedMeshSceneNode(mesh);
physicsman.createCube();
}
Here is the Irrlich class
Code: Select all
#include "StdAfx.h"
MastEventReceiver receiver;
// window width and height values
int height = 768;
int width = 1024;
void Irrlicht::Init()
{
receiver.init();
// Init the Irrlicht engine
device = createDevice(EDT_DIRECT3D9, dimension2d<s32>(width, height), 32, false, true, &receiver);
// ISoundEngine* engine = createIrrKlangDevice();
// engine->play2D("data/track.wav", true);
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
// add the camera
cam = smgr->addCameraSceneNode();
cam->setFarValue(90000.0f);
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
camera->setPosition(core::vector3df(-50,50,-150));
// disable mouse cursor
device->getCursorControl()->setVisible(false);
}
void Irrlicht::CreateSky()
{
smgr->addSkyBoxSceneNode(driver->getTexture("data/zolsky05_up.jpg"),
driver->getTexture("data/zolsky05_dn.jpg"),driver->getTexture("data/zolsky05_lf.jpg"),
driver->getTexture("data/zolsky05_rt.jpg"),driver->getTexture("data/zolsky05_fr.jpg"),
driver->getTexture("data/zolsky05_bk.jpg"));
}
void Irrlicht::MainLoop()
{
device->setEventReceiver(&receiver);
Render();
// Update newton 100 times / second
//if (device->getTimer()->getTime() > lasttick + 10) {
// lasttick = device->getTimer()->getTime();
// NewtonUpdate(nWorld, 0.01f);
//}
}
void Irrlicht::Render()
{
receiver.endEventProcess();
ReadInput();
driver->beginScene(true, true, video::SColor(0,220,220,255));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
receiver.startEventProcess();
}
void Irrlicht::ReadInput()
{
if(receiver.keyPressed(KEY_SPACE))
{
printf("Space pressed.\n");
}
}
Code: Select all
#include "StdAfx.h"
#if !defined(IRRLICHT_H)
#define IRRLICHT_H
class Irrlicht
{
public:
// Irrlicht vars
IVideoDriver* driver;
ISceneManager* smgr;
IGUIEnvironment* guienv;
IrrlichtDevice *device;
// ISoundEngine* engine;
ICameraSceneNode *cam;
void Init();
void CreateSky();
void MainLoop();
void Render();
void ReadInput();
};
#endif
Code: Select all
#include "StdAfx.h"
#include "Irrlicht.h"
#include "singletons.h"
Irrlicht Sys;
World GameWorld;
int main(int argc, char* argv[])
{
Sys.Init();
physicsman.Init();
Sys.CreateSky();
GameWorld.Create();
// Main Loop
while(Sys.device->run())
{
Sys.MainLoop();
}
// Clean up memory
//Sys.Finish();
return 0;
}
Thank you very much for your time.
tl;dr how do I use driver, device, smgr etc in any place in my program beyond the class in which they were declared? I thought just including my Irrlicht.h file should allow this?