diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 842f4cd84..d66d4df99 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -60,9 +60,7 @@ #error "Building against an incompatible Irrlicht. Distros, please use the included version." #endif -using namespace irr::core; -using namespace irr::scene; -using namespace irr::video; +using namespace irr; #ifndef round # define round(x) (floor(x+0.5f)) @@ -96,7 +94,7 @@ const int MIN_SUPPORTED_WIDTH = 800; IrrDriver::IrrDriver() { m_resolution_changing = RES_CHANGE_NONE; - m_device = createDevice(EDT_NULL); + m_device = createDevice(video::EDT_NULL); m_request_screenshot = false; } // IrrDriver @@ -172,7 +170,7 @@ void IrrDriver::updateConfigIfRelevant() UserConfigParams::m_remember_window_location) { #ifdef WIN32 - const SExposedVideoData& videoData = m_device->getVideoDriver() + const video::SExposedVideoData& videoData = m_device->getVideoDriver() ->getExposedVideoData(); // this should work even if using DirectX in theory because the HWnd is // always third pointer in the struct, no matter which union is used @@ -235,7 +233,7 @@ void IrrDriver::createListOfVideoModes() // Note that this is actually reported by valgrind as a leak, but it is // a leak in irrlicht: this list is dynamically created the first time // it is used, but then not cleaned on exit. - IVideoModeList* modes = m_device->getVideoModeList(); + video::IVideoModeList* modes = m_device->getVideoModeList(); const int count = modes->getVideoModeCount(); for(int i=0; i ssize = m_device->getVideoModeList() + const core::dimension2d ssize = m_device->getVideoModeList() ->getDesktopResolution(); if (UserConfigParams::m_width > (int)ssize.Width || UserConfigParams::m_height > (int)ssize.Height) @@ -319,14 +317,14 @@ void IrrDriver::initDevice() Log::verbose("irr_driver", "Trying to create device with " "%i bits\n", bits); - params.DriverType = EDT_OPENGL; + params.DriverType = video::EDT_OPENGL; params.Stencilbuffer = false; params.Bits = bits; params.EventReceiver = this; params.Fullscreen = UserConfigParams::m_fullscreen; params.Vsync = UserConfigParams::m_vsync; params.WindowSize = - dimension2du(UserConfigParams::m_width, + core::dimension2du(UserConfigParams::m_width, UserConfigParams::m_height); switch ((int)UserConfigParams::m_antialiasing) { @@ -358,8 +356,8 @@ void IrrDriver::initDevice() UserConfigParams::m_width = 800; UserConfigParams::m_height = 600; - m_device = createDevice(EDT_OPENGL, - dimension2du(UserConfigParams::m_width, + m_device = createDevice(video::EDT_OPENGL, + core::dimension2du(UserConfigParams::m_width, UserConfigParams::m_height ), 32, //bits per pixel UserConfigParams::m_fullscreen, @@ -403,18 +401,19 @@ void IrrDriver::initDevice() m_device->setResizable(false); m_device->setWindowCaption(L"SuperTuxKart"); m_device->getVideoDriver() - ->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, true); + ->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true); m_device->getVideoDriver() - ->setTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY, true); + ->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_QUALITY, true); if (!UserConfigParams::m_fbo) { - m_device->getVideoDriver()->disableFeature(EVDF_FRAMEBUFFER_OBJECT); + m_device->getVideoDriver() + ->disableFeature(video::EVDF_FRAMEBUFFER_OBJECT); } // Force creation of mipmaps even if the mipmaps flag in a b3d file // does not set the 'enable mipmap' flag. m_scene_manager->getParameters() - ->setAttribute(B3D_LOADER_IGNORE_MIPMAP_FLAG, true); + ->setAttribute(scene::B3D_LOADER_IGNORE_MIPMAP_FLAG, true); // Set window to remembered position if ( !UserConfigParams::m_fullscreen @@ -431,20 +430,19 @@ void IrrDriver::initDevice() file_manager->reInit(); // Initialize material2D - SMaterial& material2D = m_video_driver->getMaterial2D(); - material2D.setFlag(EMF_ANTI_ALIASING, true); - for (unsigned int n=0; ngetMaterial2D(); + material2D.setFlag(video::EMF_ANTI_ALIASING, true); + for (unsigned int n=0; nenableMaterial2D(); // Initialize post-processing if supported @@ -478,7 +476,7 @@ void IrrDriver::hidePointer() //----------------------------------------------------------------------------- -position2di IrrDriver::getMouseLocation() +core::position2di IrrDriver::getMouseLocation() { return this->getDevice()->getCursorControl()->getPosition(); } @@ -491,7 +489,8 @@ position2di IrrDriver::getMouseLocation() bool IrrDriver::moveWindow(const int x, const int y) { #ifdef WIN32 - const SExposedVideoData& videoData = m_video_driver->getExposedVideoData(); + const video::SExposedVideoData& videoData = + m_video_driver->getExposedVideoData(); // this should work even if using DirectX in theory, // because the HWnd is always third pointer in the struct, // no matter which union is used @@ -545,9 +544,9 @@ void IrrDriver::applyResolutionSettings() { // show black before resolution switch so we don't see OpenGL's buffer // garbage during switch - m_video_driver->beginScene(true, true, SColor(255,100,101,140)); - m_video_driver->draw2DRectangle( SColor(255, 0, 0, 0), - rect(0, 0, + m_video_driver->beginScene(true, true, video::SColor(255,100,101,140)); + m_video_driver->draw2DRectangle( video::SColor(255, 0, 0, 0), + core::rect(0, 0, UserConfigParams::m_prev_width, UserConfigParams::m_prev_height) ); m_video_driver->endScene(); @@ -667,9 +666,9 @@ void IrrDriver::printRenderStats() /** Loads an animated mesh and returns a pointer to it. * \param filename File to load. */ -IAnimatedMesh *IrrDriver::getAnimatedMesh(const std::string &filename) +scene::IAnimatedMesh *IrrDriver::getAnimatedMesh(const std::string &filename) { - IAnimatedMesh *m = NULL; + scene::IAnimatedMesh *m = NULL; if (StringUtils::getExtension(filename) == "b3dz") { @@ -711,9 +710,9 @@ IAnimatedMesh *IrrDriver::getAnimatedMesh(const std::string &filename) /** Loads a non-animated mesh and returns a pointer to it. * \param filename File to load. */ -IMesh *IrrDriver::getMesh(const std::string &filename) +scene::IMesh *IrrDriver::getMesh(const std::string &filename) { - IAnimatedMesh* am = getAnimatedMesh(filename); + scene::IAnimatedMesh* am = getAnimatedMesh(filename); if (am == NULL) { Log::error("irr_driver", "Cannot load mesh <%s>\n", @@ -728,16 +727,16 @@ IMesh *IrrDriver::getMesh(const std::string &filename) * material_manager. * \param mesh The mesh to change the settings in. */ -void IrrDriver::setAllMaterialFlags(IMesh *mesh) const +void IrrDriver::setAllMaterialFlags(scene::IMesh *mesh) const { unsigned int n=mesh->getMeshBufferCount(); for(unsigned int i=0; igetMeshBuffer(i); - SMaterial &irr_material=mb->getMaterial(); - for(unsigned int j=0; jgetMeshBuffer(i); + video::SMaterial &irr_material=mb->getMaterial(); + for(unsigned int j=0; jsetAllMaterialFlags(t, mb); } // for jsetMaterialFlag(EMF_GOURAUD_SHADING, true); - IMesh* welded_mesh = m_scene_manager->getMeshManipulator() + mesh->setMaterialFlag(video::EMF_GOURAUD_SHADING, true); + scene::IMesh* welded_mesh = m_scene_manager->getMeshManipulator() ->createMeshWelded(mesh); - ISceneNode* out = m_scene_manager->addWaterSurfaceSceneNode(welded_mesh, + scene::ISceneNode* out = m_scene_manager->addWaterSurfaceSceneNode(welded_mesh, wave_height, wave_speed, wave_length); - out->getMaterial(0).setFlag(EMF_GOURAUD_SHADING, true); + out->getMaterial(0).setFlag(video::EMF_GOURAUD_SHADING, true); welded_mesh->drop(); // The scene node keeps a reference return out; } // addWaterNode @@ -772,7 +771,7 @@ ISceneNode* IrrDriver::addWaterNode(IMesh *mesh, /** Adds a mesh that will be optimised using an oct tree. * \param mesh Mesh to add. */ -IMeshSceneNode *IrrDriver::addOctTree(IMesh *mesh) +scene::IMeshSceneNode *IrrDriver::addOctTree(scene::IMesh *mesh) { return m_scene_manager->addOctreeSceneNode(mesh); } // addOctTree @@ -782,14 +781,14 @@ IMeshSceneNode *IrrDriver::addOctTree(IMesh *mesh) * \param radius The radius of the sphere. * \param color The color to use (default (0,0,0,0) */ -IMeshSceneNode *IrrDriver::addSphere(float radius, - const SColor &color) +scene::IMeshSceneNode *IrrDriver::addSphere(float radius, + const video::SColor &color) { - IMeshSceneNode *node = m_scene_manager->addSphereSceneNode(radius); - node->setMaterialType(EMT_SOLID); - IMesh *mesh = node->getMesh(); - mesh->setMaterialFlag(EMF_COLOR_MATERIAL, true); - SMaterial m; + scene::IMeshSceneNode *node = m_scene_manager->addSphereSceneNode(radius); + node->setMaterialType(video::EMT_SOLID); + scene::IMesh *mesh = node->getMesh(); + mesh->setMaterialFlag(video::EMF_COLOR_MATERIAL, true); + video::SMaterial m; m.AmbientColor = color; m.DiffuseColor = color; m.EmissiveColor = color; @@ -801,7 +800,7 @@ IMeshSceneNode *IrrDriver::addSphere(float radius, // ---------------------------------------------------------------------------- /** Adds a particle scene node. */ -IParticleSystemSceneNode *IrrDriver::addParticleNode(bool default_emitter) +scene::IParticleSystemSceneNode *IrrDriver::addParticleNode(bool default_emitter) { return m_scene_manager->addParticleSystemSceneNode(default_emitter); } // addParticleNode @@ -811,17 +810,17 @@ IParticleSystemSceneNode *IrrDriver::addParticleNode(bool default_emitter) * since the node is not optimised. * \param mesh The mesh to add. */ -IMeshSceneNode *IrrDriver::addMesh(IMesh *mesh, - ISceneNode *parent) +scene::IMeshSceneNode *IrrDriver::addMesh(scene::IMesh *mesh, + scene::ISceneNode *parent) { return m_scene_manager->addMeshSceneNode(mesh, parent); } // addMesh // ---------------------------------------------------------------------------- -PerCameraNode *IrrDriver::addPerCameraMesh(IMesh* mesh, - ICameraSceneNode* camera, - ISceneNode *parent) +PerCameraNode *IrrDriver::addPerCameraMesh(scene::IMesh* mesh, + scene::ICameraSceneNode* camera, + scene::ISceneNode *parent) { return new PerCameraNode((parent ? parent : m_scene_manager->getRootSceneNode()), @@ -832,11 +831,11 @@ PerCameraNode *IrrDriver::addPerCameraMesh(IMesh* mesh, // ---------------------------------------------------------------------------- /** Adds a billboard node to scene. */ -ISceneNode *IrrDriver::addBillboard(const dimension2d< f32 > size, - ITexture *texture, - ISceneNode* parent) +scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size, + video::ITexture *texture, + scene::ISceneNode* parent) { - IBillboardSceneNode* node = + scene::IBillboardSceneNode* node = m_scene_manager->addBillboardSceneNode(parent, size); assert(node->getMaterialCount() > 0); node->setMaterialTexture(0, texture); @@ -848,15 +847,15 @@ ISceneNode *IrrDriver::addBillboard(const dimension2d< f32 > size, * \param material The material to use (NULL if no material). * \param create_one_quad If true creates one quad in the mesh. */ -IMesh *IrrDriver::createQuadMesh(const SMaterial *material, +scene::IMesh *IrrDriver::createQuadMesh(const video::SMaterial *material, bool create_one_quad) { - SMeshBuffer *buffer = new SMeshBuffer(); + scene::SMeshBuffer *buffer = new scene::SMeshBuffer(); if(create_one_quad) { - S3DVertex v; - v.Pos = vector3df(0,0,0); - v.Normal = vector3df(1/sqrt(2.0f), 1/sqrt(2.0f), 0); + video::S3DVertex v; + v.Pos = core::vector3df(0,0,0); + v.Normal = core::vector3df(1/sqrt(2.0f), 1/sqrt(2.0f), 0); // Add the vertices // ---------------- @@ -877,7 +876,7 @@ IMesh *IrrDriver::createQuadMesh(const SMaterial *material, } if(material) buffer->Material = *material; - SMesh *mesh = new SMesh(); + scene::SMesh *mesh = new scene::SMesh(); mesh->addMeshBuffer(buffer); mesh->recalculateBoundingBox(); buffer->drop(); @@ -891,33 +890,33 @@ IMesh *IrrDriver::createQuadMesh(const SMaterial *material, * \param w Width of the quad. * \param h Height of the quad. */ -IMesh *IrrDriver::createTexturedQuadMesh(const SMaterial *material, +scene::IMesh *IrrDriver::createTexturedQuadMesh(const video::SMaterial *material, const double w, const double h) { - SMeshBuffer *buffer = new SMeshBuffer(); + scene::SMeshBuffer *buffer = new scene::SMeshBuffer(); const float w_2 = (float)w/2.0f; const float h_2 = (float)h/2.0f; - S3DVertex v1; - v1.Pos = vector3df(-w_2,-h_2,0); - v1.Normal = vector3df(0, 0, -1.0f); - v1.TCoords = vector2d(1,1); + video::S3DVertex v1; + v1.Pos = core::vector3df(-w_2,-h_2,0); + v1.Normal = core::vector3df(0, 0, -1.0f); + v1.TCoords = core::vector2d(1,1); - S3DVertex v2; - v2.Pos = vector3df(w_2,-h_2,0); - v2.Normal = vector3df(0, 0, -1.0f); - v2.TCoords = vector2d(0,1); + video::S3DVertex v2; + v2.Pos = core::vector3df(w_2,-h_2,0); + v2.Normal = core::vector3df(0, 0, -1.0f); + v2.TCoords = core::vector2d(0,1); - S3DVertex v3; - v3.Pos = vector3df(w_2,h_2,0); - v3.Normal = vector3df(0, 0, -1.0f); - v3.TCoords = vector2d(0,0); + video::S3DVertex v3; + v3.Pos = core::vector3df(w_2,h_2,0); + v3.Normal = core::vector3df(0, 0, -1.0f); + v3.TCoords = core::vector2d(0,0); - S3DVertex v4; - v4.Pos = vector3df(-w_2,h_2,0); - v4.Normal = vector3df(0, 0, -1.0f); - v4.TCoords = vector2d(1,0); + video::S3DVertex v4; + v4.Pos = core::vector3df(-w_2,h_2,0); + v4.Normal = core::vector3df(0, 0, -1.0f); + v4.TCoords = core::vector2d(1,0); // Add the vertices @@ -938,7 +937,7 @@ IMesh *IrrDriver::createTexturedQuadMesh(const SMaterial *material, buffer->Indices.push_back(3); if (material) buffer->Material = *material; - SMesh *mesh = new SMesh(); + scene::SMesh *mesh = new scene::SMesh(); mesh->addMeshBuffer(buffer); mesh->recalculateBoundingBox(); buffer->drop(); @@ -949,7 +948,7 @@ IMesh *IrrDriver::createTexturedQuadMesh(const SMaterial *material, /** Removes a scene node from the scene. * \param node The scene node to remove. */ -void IrrDriver::removeNode(ISceneNode *node) +void IrrDriver::removeNode(scene::ISceneNode *node) { node->remove(); } // removeNode @@ -958,7 +957,7 @@ void IrrDriver::removeNode(ISceneNode *node) /** Removes a mesh from the mesh cache, freeing the memory. * \param mesh The mesh to remove. */ -void IrrDriver::removeMeshFromCache(IMesh *mesh) +void IrrDriver::removeMeshFromCache(scene::IMesh *mesh) { m_scene_manager->getMeshCache()->removeMesh(mesh); } // removeMeshFromCache @@ -967,7 +966,7 @@ void IrrDriver::removeMeshFromCache(IMesh *mesh) /** Removes a texture from irrlicht's texture cache. * \param t The texture to remove. */ -void IrrDriver::removeTexture(ITexture *t) +void IrrDriver::removeTexture(video::ITexture *t) { m_video_driver->removeTexture(t); } // removeTexture @@ -976,12 +975,12 @@ void IrrDriver::removeTexture(ITexture *t) /** Adds an animated mesh to the scene. * \param mesh The animated mesh to add. */ -IAnimatedMeshSceneNode *IrrDriver::addAnimatedMesh(IAnimatedMesh *mesh) +scene::IAnimatedMeshSceneNode *IrrDriver::addAnimatedMesh(scene::IAnimatedMesh *mesh) { return m_scene_manager->addAnimatedMeshSceneNode(mesh, NULL, -1, - vector3df(0,0,0), - vector3df(0,0,0), - vector3df(1,1,1), + core::vector3df(0,0,0), + core::vector3df(0,0,0), + core::vector3df(1,1,1), /*addIfMeshIsZero*/true); } // addAnimatedMesh @@ -998,7 +997,7 @@ IAnimatedMeshSceneNode *IrrDriver::addAnimatedMesh(IAnimatedMesh *mesh) * between 0 and 2, where 1 is an exact half-sphere and 2 is a full * sphere. */ -ISceneNode *IrrDriver::addSkyDome(ITexture *texture, +scene::ISceneNode *IrrDriver::addSkyDome(video::ITexture *texture, int hori_res, int vert_res, float texture_percent, float sphere_percent) @@ -1019,7 +1018,7 @@ ISceneNode *IrrDriver::addSkyDome(ITexture *texture, * \param front: Texture for the front plane of the box. * \param back: Texture for the back plane of the box. */ -ISceneNode *IrrDriver::addSkyBox(const std::vector +scene::ISceneNode *IrrDriver::addSkyBox(const std::vector &texture) { return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1], @@ -1030,7 +1029,7 @@ ISceneNode *IrrDriver::addSkyBox(const std::vector // ---------------------------------------------------------------------------- /** Adds a camera to the scene. */ -ICameraSceneNode *IrrDriver::addCameraSceneNode() +scene::ICameraSceneNode *IrrDriver::addCameraSceneNode() { return m_scene_manager->addCameraSceneNode(); } // addCameraSceneNode @@ -1042,7 +1041,7 @@ ICameraSceneNode *IrrDriver::addCameraSceneNode() * a camera is added), it's a bit cleaner and easier to check for memory * leaks, since the scene root should now always be empty. */ -void IrrDriver::removeCameraSceneNode(ICameraSceneNode *camera) +void IrrDriver::removeCameraSceneNode(scene::ICameraSceneNode *camera) { if(camera==m_scene_manager->getActiveCamera()) m_scene_manager->setActiveCamera(NULL); // basically causes a drop @@ -1057,12 +1056,12 @@ void IrrDriver::removeCameraSceneNode(ICameraSceneNode *camera) * \param is_prediv If the alpha value needs to be divided into * each pixel. */ -ITexture *IrrDriver::getTexture(const std::string &filename, +video::ITexture *IrrDriver::getTexture(const std::string &filename, bool is_premul, bool is_prediv, bool complain_if_not_found) { - ITexture* out; + video::ITexture* out; if(!is_premul && !is_prediv) { if (!complain_if_not_found) m_device->getLogger()->setLogLevel(ELL_NONE); @@ -1073,22 +1072,22 @@ ITexture *IrrDriver::getTexture(const std::string &filename, { // FIXME: can't we just do this externally, and just use the // modified textures?? - IImage* img = + video::IImage* img = m_video_driver->createImageFromFile(filename.c_str()); // PNGs are non premul, but some are used for premul tasks, so convert // http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[Premultiplied%20alpha]] // FIXME check param, not name if(is_premul && StringUtils::hasSuffix(filename.c_str(), ".png") && - (img->getColorFormat() == ECF_A8R8G8B8) && + (img->getColorFormat() == irr::video::ECF_A8R8G8B8) && img->lock()) { - dimension2d dim = img->getDimension(); + core::dimension2d dim = img->getDimension(); for(unsigned int x = 0; x < dim.Width; x++) { for(unsigned int y = 0; y < dim.Height; y++) { - SColor col = img->getPixel(x, y); + video::SColor col = img->getPixel(x, y); unsigned int alpha = col.getAlpha(); unsigned int red = alpha * col.getRed() / 255; unsigned int blue = alpha * col.getBlue() / 255; @@ -1102,15 +1101,15 @@ ITexture *IrrDriver::getTexture(const std::string &filename, // Other formats can be premul, but the tasks can be non premul // So divide to get the separate RGBA (only possible if alpha!=0) else if(is_prediv && - (img->getColorFormat() == ECF_A8R8G8B8) && + (img->getColorFormat() == irr::video::ECF_A8R8G8B8) && img->lock()) { - dimension2d dim = img->getDimension(); + core::dimension2d dim = img->getDimension(); for(unsigned int x = 0; x < dim.Width; x++) { for(unsigned int y = 0; y < dim.Height; y++) { - SColor col = img->getPixel(x, y); + video::SColor col = img->getPixel(x, y); unsigned int alpha = col.getAlpha(); // Avoid divide by zero if (alpha) { @@ -1143,17 +1142,17 @@ ITexture *IrrDriver::getTexture(const std::string &filename, * \param mesh The mesh from which the textures are being determined. * \param texture_list The list to which to attach the pointer to. */ -void IrrDriver::grabAllTextures(const IMesh *mesh) +void IrrDriver::grabAllTextures(const scene::IMesh *mesh) { const unsigned int n = mesh->getMeshBufferCount(); for(unsigned int i=0; igetMeshBuffer(i); - SMaterial &m = b->getMaterial(); - for(unsigned int j=0; jgetMeshBuffer(i); + video::SMaterial &m = b->getMaterial(); + for(unsigned int j=0; jgrab(); } // for j < MATERIAL_MAX_TEXTURE @@ -1165,17 +1164,17 @@ void IrrDriver::grabAllTextures(const IMesh *mesh) * \param mesh The mesh from which the textures are being determined. * \param texture_list The list to which to attach the pointer to. */ -void IrrDriver::dropAllTextures(const IMesh *mesh) +void IrrDriver::dropAllTextures(const scene::IMesh *mesh) { const unsigned int n = mesh->getMeshBufferCount(); for(unsigned int i=0; igetMeshBuffer(i); - SMaterial &m = b->getMaterial(); - for(unsigned int j=0; jgetMeshBuffer(i); + video::SMaterial &m = b->getMaterial(); + for(unsigned int j=0; jdrop(); @@ -1187,27 +1186,27 @@ void IrrDriver::dropAllTextures(const IMesh *mesh) } // dropAllTextures // ---------------------------------------------------------------------------- -ITexture* IrrDriver::applyMask(ITexture* texture, - const std::string& mask_path) +video::ITexture* IrrDriver::applyMask(video::ITexture* texture, + const std::string& mask_path) { - IImage* img = - m_video_driver->createImage(texture, position2d(0,0), + video::IImage* img = + m_video_driver->createImage(texture, core::position2d(0,0), texture->getSize()); - IImage* mask = + video::IImage* mask = m_video_driver->createImageFromFile(mask_path.c_str()); if (img == NULL || mask == NULL) return NULL; if (img->lock() && mask->lock()) { - dimension2d dim = img->getDimension(); + core::dimension2d dim = img->getDimension(); for (unsigned int x = 0; x < dim.Width; x++) { for (unsigned int y = 0; y < dim.Height; y++) { - SColor col = img->getPixel(x, y); - SColor alpha = mask->getPixel(x, y); + video::SColor col = img->getPixel(x, y); + video::SColor alpha = mask->getPixel(x, y); col.setAlpha( alpha.getRed() ); img->setPixel(x, y, col, false); } // for y @@ -1223,7 +1222,7 @@ ITexture* IrrDriver::applyMask(ITexture* texture, std::string base = StringUtils::getBasename(texture->getName().getPath().c_str()); - ITexture *t = m_video_driver->addTexture(base.c_str(),img, NULL); + video::ITexture *t = m_video_driver->addTexture(base.c_str(),img, NULL); img->drop(); mask->drop(); return t; @@ -1233,7 +1232,7 @@ ITexture* IrrDriver::applyMask(ITexture* texture, /** Sets the ambient light. * \param light The colour of the light to set. */ -void IrrDriver::setAmbientLight(const SColor &light) +void IrrDriver::setAmbientLight(const video::SColor &light) { m_scene_manager->setAmbientLight(light); } // setAmbientLight @@ -1254,8 +1253,8 @@ void IrrDriver::displayFPS() { no_trust--; - static SColor fpsColor = SColor(255, 255, 0, 0); - font->draw( L"FPS: ...", rect< s32 >(100,0,400,50), fpsColor, + static video::SColor fpsColor = video::SColor(255, 255, 0, 0); + font->draw( L"FPS: ...", core::rect< s32 >(100,0,400,50), fpsColor, false ); return; @@ -1305,10 +1304,10 @@ void IrrDriver::displayFPS() (int)round(kilotris)); } - stringw fpsString = buffer; + core::stringw fpsString = buffer; - static SColor fpsColor = SColor(255, 255, 0, 0); - font->draw( fpsString.c_str(), rect< s32 >(100,0,400,50), fpsColor, false ); + static video::SColor fpsColor = video::SColor(255, 255, 0, 0); + font->draw( fpsString.c_str(), core::rect< s32 >(100,0,400,50), fpsColor, false ); } // updateFPS // ---------------------------------------------------------------------------- @@ -1317,9 +1316,9 @@ void IrrDriver::drawDebugMeshes() { for (unsigned int n=0; ngetMesh(); - ISkinnedMesh* smesh = static_cast(mesh); - const array< ISkinnedMesh::SJoint * >& joints = + scene::IMesh* mesh = m_debug_meshes[n]->getMesh(); + scene::ISkinnedMesh* smesh = static_cast(mesh); + const core::array< scene::ISkinnedMesh::SJoint * >& joints = smesh->getAllJoints(); for (unsigned int j=0; jsetMaterial(material); - getVideoDriver()->setTransform(ETS_WORLD, IdentityMatrix); + getVideoDriver()->setTransform(video::ETS_WORLD, core::IdentityMatrix); for (unsigned int n=0; ngetMesh(); + scene::IMesh* mesh = m_debug_meshes[n]->getMesh(); - ISkinnedMesh* smesh = static_cast(mesh); - const array< ISkinnedMesh::SJoint * >& joints = + scene::ISkinnedMesh* smesh = static_cast(mesh); + const core::array< irr::scene::ISkinnedMesh::SJoint * >& joints = smesh->getAllJoints(); for (unsigned int j=0; jgetMesh(); - ISkinnedMesh* smesh = static_cast(mesh); + scene::IMesh* mesh = m_debug_meshes[n]->getMesh(); + scene::ISkinnedMesh* smesh = static_cast(mesh); drawJoint(true, false, joints[j], smesh, j); } @@ -1368,11 +1367,11 @@ void IrrDriver::drawDebugMeshes() * \param id Index, which (%4) determines the color to use. */ void IrrDriver::drawJoint(bool drawline, bool drawname, - ISkinnedMesh::SJoint* joint, - ISkinnedMesh* mesh, int id) + irr::scene::ISkinnedMesh::SJoint* joint, + scene::ISkinnedMesh* mesh, int id) { - ISkinnedMesh::SJoint* parent = NULL; - const array< ISkinnedMesh::SJoint * >& joints + irr::scene::ISkinnedMesh::SJoint* parent = NULL; + const core::array< irr::scene::ISkinnedMesh::SJoint * >& joints = mesh->getAllJoints(); for (unsigned int j=0; jGlobalMatrix.getTranslation(); + core::vector3df jointpos = joint->GlobalMatrix.getTranslation(); - SColor color(255, 255,255,255); - if (parent == NULL) color = SColor(255,0,255,0); + video::SColor color(255, 255,255,255); + if (parent == NULL) color = video::SColor(255,0,255,0); switch (id % 4) { case 0: - color = SColor(255,255,0,255); + color = video::SColor(255,255,0,255); break; case 1: - color = SColor(255,255,0,0); + color = video::SColor(255,255,0,0); break; case 2: - color = SColor(255,0,0,255); + color = video::SColor(255,0,0,255); break; case 3: - color = SColor(255,0,255,255); + color = video::SColor(255,0,255,255); break; } if (parent) { - vector3df parentpos = parent->GlobalMatrix.getTranslation(); + core::vector3df parentpos = parent->GlobalMatrix.getTranslation(); jointpos = joint->GlobalMatrix.getTranslation(); @@ -1425,7 +1424,7 @@ void IrrDriver::drawJoint(bool drawline, bool drawname, if (drawline) { irr_driver->getVideoDriver()->draw3DLine(jointpos, - vector3df(0,0,0), + core::vector3df(0,0,0), color); } */ @@ -1436,23 +1435,23 @@ void IrrDriver::drawJoint(bool drawline, bool drawname, switch ((id + 1) % 4) { case 0: - color = SColor(255,255,0,255); + color = video::SColor(255,255,0,255); break; case 1: - color = SColor(255,255,0,0); + color = video::SColor(255,255,0,0); break; case 2: - color = SColor(255,0,0,255); + color = video::SColor(255,0,0,255); break; case 3: - color = SColor(255,0,255,255); + color = video::SColor(255,0,255,255); break; } // This code doesn't quite work. 0.25 is used so that the bone is not // way too long (not sure why I need to manually size it down) // and the rotation of the bone is often rather off - vector3df v(0.0f, 0.25f, 0.0f); + core::vector3df v(0.0f, 0.25f, 0.0f); //joint->GlobalMatrix.rotateVect(v); joint->LocalMatrix.rotateVect(v); v *= joint->LocalMatrix.getScale(); @@ -1464,32 +1463,32 @@ void IrrDriver::drawJoint(bool drawline, bool drawname, switch ((id + 1) % 4) { case 0: - color = SColor(255,255,0,255); + color = video::SColor(255,255,0,255); break; case 1: - color = SColor(255,255,0,0); + color = video::SColor(255,255,0,0); break; case 2: - color = SColor(255,0,0,255); + color = video::SColor(255,0,0,255); break; case 3: - color = SColor(255,0,255,255); + color = video::SColor(255,0,255,255); break; } if (drawname) { - irr_driver->getVideoDriver()->setTransform(ETS_WORLD, - IdentityMatrix); + irr_driver->getVideoDriver()->setTransform(video::ETS_WORLD, + core::IdentityMatrix); - vector2di textpos = + core::vector2di textpos = irr_driver->getSceneManager()->getSceneCollisionManager() ->getScreenCoordinatesFrom3DPosition(jointpos); GUIEngine::getSmallFont()->draw( stringw(joint->Name.c_str()), - rect(textpos, - dimension2d(500,50)), - color, false, false ); + core::rect(textpos, + core::dimension2d(500,50)), + color, false, false ); } } #endif @@ -1501,7 +1500,7 @@ void IrrDriver::doScreenShot() { m_request_screenshot = false; - IImage* image = m_video_driver->createScreenShot(); + video::IImage* image = m_video_driver->createScreenShot(); if(!image) { Log::error("IrrDriver", "Could not create screen shot."); @@ -1530,8 +1529,8 @@ void IrrDriver::doScreenShot() if (base) { base->addMessage( - stringw(("Screenshot saved to\n" + path).c_str()), - NULL, 2.0f, SColor(255,255,255,255), true, false); + core::stringw(("Screenshot saved to\n" + path).c_str()), + NULL, 2.0f, video::SColor(255,255,255,255), true, false); } // if base } else @@ -1540,9 +1539,9 @@ void IrrDriver::doScreenShot() if (base) { base->addMessage( - stringw(("FAILED saving screenshot to\n" + path + + core::stringw(("FAILED saving screenshot to\n" + path + "\n:(").c_str()), - NULL, 2.0f, SColor(255,255,255,255), + NULL, 2.0f, video::SColor(255,255,255,255), true, false); } // if base } // if failed writing screenshot file @@ -1591,7 +1590,7 @@ void IrrDriver::update(float dt) { //printf("Screen that needs 3D\n"); m_video_driver->beginScene(/*backBuffer clear*/false, /*zBuffer*/true, - SColor(0,0,0,255)); + video::SColor(0,0,0,255)); m_scene_manager->drawAll(); GUIEngine::render(dt); m_video_driver->endScene(); @@ -1615,7 +1614,7 @@ void IrrDriver::update(float dt) m_video_driver->beginScene(back_buffer_clear, /*zBuffer*/ true, world ? world->getClearColor() - : SColor(255,100,101,140)); + : video::SColor(255,100,101,140)); if (inRace) { @@ -1656,7 +1655,7 @@ void IrrDriver::update(float dt) m_post_processing->render(); // Set the viewport back to the full screen for race gui - m_video_driver->setViewPort(recti(0, 0, + m_video_driver->setViewPort(core::recti(0, 0, UserConfigParams::m_width, UserConfigParams::m_height)); @@ -1714,14 +1713,14 @@ void IrrDriver::requestScreenshot() * irrLicht's chatty logging until the event handler is ready to take * the task. */ -bool IrrDriver::OnEvent(const SEvent &event) +bool IrrDriver::OnEvent(const irr::SEvent &event) { //TODO: ideally we wouldn't use this object to STFU irrlicht's chatty // debugging, we'd just create the EventHandler earlier so it // can act upon it switch (event.EventType) { - case EET_LOG_TEXT_EVENT: + case irr::EET_LOG_TEXT_EVENT: { // Ignore 'normal' messages if (event.LogEvent.Level > 1) @@ -1743,8 +1742,8 @@ bool IrrDriver::OnEvent(const SEvent &event) bool IrrDriver::supportsSplatting() { return UserConfigParams::m_pixel_shaders && - m_video_driver->queryFeature(EVDF_ARB_GLSL) && - m_video_driver->queryFeature(EVDF_MULTITEXTURE ); + m_video_driver->queryFeature(video::EVDF_ARB_GLSL) && + m_video_driver->queryFeature(video::EVDF_MULTITEXTURE ); } // ---------------------------------------------------------------------------- @@ -1761,7 +1760,7 @@ bool IrrDriver::supportsSplatting() * \param persistent_texture Whether the created RTT texture should persist in * memory after the RTTProvider is deleted */ -IrrDriver::RTTProvider::RTTProvider(const dimension2du &dimension, +IrrDriver::RTTProvider::RTTProvider(const core::dimension2du &dimension, const std::string &name, bool persistent_texture) { m_persistent_texture = persistent_texture; @@ -1769,7 +1768,7 @@ IrrDriver::RTTProvider::RTTProvider(const dimension2du &dimension, m_render_target_texture = m_video_driver->addRenderTargetTexture(dimension, name.c_str(), - ECF_A8R8G8B8); + video::ECF_A8R8G8B8); if (m_render_target_texture != NULL) { m_video_driver->setRenderTarget(m_render_target_texture); @@ -1795,30 +1794,30 @@ IrrDriver::RTTProvider::~RTTProvider() * considered to be the root, and all following meshes will have their * locations relative to the location of the first mesh. */ -void IrrDriver::RTTProvider::setupRTTScene(PtrVector& mesh, +void IrrDriver::RTTProvider::setupRTTScene(PtrVector& mesh, AlignedArray& mesh_location, AlignedArray& mesh_scale, const std::vector& model_frames) { if (model_frames[0] == -1) { - ISceneNode* node = + scene::ISceneNode* node = irr_driver->getSceneManager()->addMeshSceneNode(mesh.get(0), NULL); node->setPosition( mesh_location[0].toIrrVector() ); node->setScale( mesh_scale[0].toIrrVector() ); - node->setMaterialFlag(EMF_FOG_ENABLE, false); + node->setMaterialFlag(video::EMF_FOG_ENABLE, false); m_rtt_main_node = node; } else { - IAnimatedMeshSceneNode* node = + scene::IAnimatedMeshSceneNode* node = irr_driver->getSceneManager()->addAnimatedMeshSceneNode( - (IAnimatedMesh*)mesh.get(0), NULL ); + (scene::IAnimatedMesh*)mesh.get(0), NULL ); node->setPosition( mesh_location[0].toIrrVector() ); node->setFrameLoop(model_frames[0], model_frames[0]); node->setAnimationSpeed(0); node->setScale( mesh_scale[0].toIrrVector() ); - node->setMaterialFlag(EMF_FOG_ENABLE, false); + node->setMaterialFlag(video::EMF_FOG_ENABLE, false); m_rtt_main_node = node; } @@ -1832,7 +1831,7 @@ void IrrDriver::RTTProvider::setupRTTScene(PtrVector& mesh, { if (model_frames[n] == -1) { - ISceneNode* node = + scene::ISceneNode* node = irr_driver->getSceneManager()->addMeshSceneNode(mesh.get(n), m_rtt_main_node); node->setPosition( mesh_location[n].toIrrVector() ); @@ -1841,10 +1840,10 @@ void IrrDriver::RTTProvider::setupRTTScene(PtrVector& mesh, } else { - IAnimatedMeshSceneNode* node = + scene::IAnimatedMeshSceneNode* node = irr_driver->getSceneManager() - ->addAnimatedMeshSceneNode((IAnimatedMesh*)mesh.get(n), - m_rtt_main_node ); + ->addAnimatedMeshSceneNode((scene::IAnimatedMesh*)mesh.get(n), + m_rtt_main_node ); node->setPosition( mesh_location[n].toIrrVector() ); node->setFrameLoop(model_frames[n], model_frames[n]); node->setAnimationSpeed(0); @@ -1854,39 +1853,40 @@ void IrrDriver::RTTProvider::setupRTTScene(PtrVector& mesh, } } - irr_driver->getSceneManager()->setAmbientLight(SColor(255, 120, + irr_driver->getSceneManager()->setAmbientLight(video::SColor(255, 120, 120, 120) ); - const vector3df &sun_pos = vector3df( 0, 200, 100.0f ); + const core::vector3df &sun_pos = core::vector3df( 0, 200, 100.0f ); m_light = irr_driver->getSceneManager() - ->addLightSceneNode(NULL, sun_pos, SColorf(1.0f,1.0f,1.0f), + ->addLightSceneNode(NULL, sun_pos, video::SColorf(1.0f,1.0f,1.0f), 10000.0f /* radius */); m_light->getLightData().DiffuseColor - = SColorf(0.5f, 0.5f, 0.5f, 0.5f); + = irr::video::SColorf(0.5f, 0.5f, 0.5f, 0.5f); m_light->getLightData().SpecularColor - = SColorf(1.0f, 1.0f, 1.0f, 1.0f); + = irr::video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); - m_rtt_main_node->setMaterialFlag(EMF_GOURAUD_SHADING , true); - m_rtt_main_node->setMaterialFlag(EMF_LIGHTING, true); + m_rtt_main_node->setMaterialFlag(video::EMF_GOURAUD_SHADING , true); + m_rtt_main_node->setMaterialFlag(video::EMF_LIGHTING, true); const int materials = m_rtt_main_node->getMaterialCount(); for (int n=0; ngetMaterial(n).setFlag(EMF_LIGHTING, true); + m_rtt_main_node->getMaterial(n).setFlag(video::EMF_LIGHTING, true); // set size of specular highlights m_rtt_main_node->getMaterial(n).Shininess = 100.0f; m_rtt_main_node->getMaterial(n).SpecularColor.set(255,50,50,50); m_rtt_main_node->getMaterial(n).DiffuseColor.set(255,150,150,150); - m_rtt_main_node->getMaterial(n).setFlag(EMF_GOURAUD_SHADING , true); + m_rtt_main_node->getMaterial(n).setFlag(video::EMF_GOURAUD_SHADING , + true); } m_camera = irr_driver->getSceneManager()->addCameraSceneNode(); - m_camera->setPosition( vector3df(0.0, 20.0f, 70.0f) ); - m_camera->setUpVector( vector3df(0.0, 1.0, 0.0) ); - m_camera->setTarget( vector3df(0, 10, 0.0f) ); + m_camera->setPosition( core::vector3df(0.0, 20.0f, 70.0f) ); + m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); + m_camera->setTarget( core::vector3df(0, 10, 0.0f) ); m_camera->setFOV( DEGREE_TO_RAD*50.0f ); m_camera->updateAbsolutePosition(); @@ -1916,8 +1916,8 @@ void IrrDriver::RTTProvider::tearDownRTTScene() * \return the texture that was rendered to, or NULL if RTT does not work on * this computer */ -ITexture* IrrDriver::RTTProvider::renderToTexture(float angle, - bool is_2d_render) +video::ITexture* IrrDriver::RTTProvider::renderToTexture(float angle, + bool is_2d_render) { // m_render_target_texture will be NULL if RTT doesn't work on this computer if (m_render_target_texture == NULL) return NULL; @@ -1929,7 +1929,7 @@ ITexture* IrrDriver::RTTProvider::renderToTexture(float angle, m_video_driver->setRenderTarget(m_render_target_texture); if (angle != -1 && m_rtt_main_node != NULL) - m_rtt_main_node->setRotation( vector3df(0, angle, 0) ); + m_rtt_main_node->setRotation( core::vector3df(0, angle, 0) ); if (m_rtt_main_node == NULL) {