/* Irrlicht Library Wrapper Created by: Nathan Adams Copyright (C) 2008 This software is licensed under the GNU/GPL. This software may not be used for commerical purposes. */ #include //#include "IrrLib.h" //#include "IrrSphere.h" //You probably aren't going to be using 3D objects in a 2D environment! #include #include #include "Irr2D.h" #include "IrrSprite.h" using namespace irr; using namespace core; using namespace scene; using namespace video; using namespace io; using namespace gui; using namespace std; Irr2D::Irr2D(){ this->numTextures = 0; this->numLines = 0; this->nImages = 0; //NA Should we set textures to new } Irr2D::~Irr2D(){ /*for(int i = 0; i < numTextures; ++i) delete this->textures[i]; delete this->textures;*/ //No more dynamic memory business yay! NA //All handled by vectors! } /*void Irr2D::SetSmgr(irr::scene::ISceneManager* smgr){ this->smgr = smgr; Sprite.SetSmgr(smgr); } void Irr2D::SetDriver(irr::video::IVideoDriver* driver){ this->driver = driver; Sprite.SetDriver(driver); }*/ IrrObj Irr2D::LoadTexturemap(stringc file){ this->texturemap = driver->getTexture(file.c_str()); } IrrObj Irr2D::LoadTexture(stringc file){ //this->textures[this->numTextures] = driver->getTexture(file.c_str()); textures.push_back(driver->getTexture(file.c_str())); this->numTextures++; IrrObj ret; ret.eventid = 0; ret.objectid = numTextures--; return ret; } void Irr2D::DrawLine(IrrPos& start, IrrPos& end, irr::video::SColor color) { this->driver->draw2DLine(start, end, color); } void Irr2D::AddLines(IrrPos& start, IrrPos& end, irr::video::SColor color) { this->start.push_back(start); this->end.push_back(end); this->color.push_back(color); this->numLines++; } void Irr2D::DrawLines() { for(int i = 0; i < numLines; ++i) this->driver->draw2DLine(this->start[i], this->end[i], this->color[i]); } IrrObj Irr2D::LoadIrrImage(irr::core::stringc file) { images.push_back(this->driver->getTexture(file.c_str())); IrrObj ret; ret.objectid = nImages; ret.eventid = 0; this->nImages++; return ret; } void Irr2D::DrawImage(IrrObj img) { irr::core::position2d destPos(img.x, img.y); this->driver->draw2DImage(images[img.objectid], destPos); } void Irr2D::Draw2DObj(irr::core::stringc file) { //NewtonObj tmp; //tmp.irr_node = smgr->addMeshSceneNode(smgr->getMesh(file.c_str())->getMesh(0)); //IMeshSceneNode* temp; objects.push_back(smgr->addMeshSceneNode(smgr->getMesh(file.c_str())->getMesh(0))); objects.push_back(smgr->addMeshSceneNode(smgr->getMesh(file.c_str())->getMesh(0))); objects[0]->setPosition(vector3df(-5,0,0)); objects[0]->getMaterial(0).EmissiveColor.set(255,0,255,5); } /*bool Irr2D::Collision(IrrObj obj1, IrrObj obj2) { int x1 = obj1.x; int y1 = obj1.y; }*/