main.cpp
Code: Select all
#include <irrlicht.h>
#include "shapes.h"
#include <IGUISkin.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<u32>(1440, 900), 16,
false, false, false, 0);
if (!device)
return 1;
device->setWindowCaption(L"Game v0.1");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
IGUISkin* skin = guienv->getSkin();
shapes shapeMngr;
scene::ISceneNode *n;
shapeMngr.createSquare(NULL, vector3df(0,0,0), 0,vector3df(0,0,0), vector3df(1,1,1), driver, smgr, n );
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
while(device->run())
{[code]
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}[/code]
shapes.h
Code: Select all
#pragma once
#include <irrlicht.h>
#include <IGUISkin.h>
#include <iostream>
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
class shapes
{
public:
shapes(void);
void createSquare(float size, vector3df position, int id, vector3df rotation, vector3df scale, IVideoDriver* urDriver, ISceneManager* urSceneManger, ISceneNode* n);
};
Code: Select all
#include "shapes.h"
shapes::shapes(void)
{
}
void createSquare(float size, vector3df position, int id, vector3df rotation, vector3df scale, IVideoDriver* urDriver, ISceneManager* urSceneManger, ISceneNode* n)
{
if(n)
n = urSceneManger->addCubeSceneNode();
n->setMaterialTexture(0, urDriver->getTexture("Textures/default.jpg"));
n->setPosition(position);
n->setScale(scale);
n->setRotation(rotation);
n->setID = id;
n->setMaterialFlag(video::EMF_LIGHTING, false);
}