void Sprite::LoadSprite(const char * filename) { const std::string fullFileName(std::string(SPRITE_PATH) + std::string(filename) + std::string(".spr")); ConfigLua conf(fullFileName.c_str()); mHeader.frameCount = conf.GetInt("gclsprite.frame_count"); mHeader.width = conf.GetInt("gclsprite.width"); mHeader.height = conf.GetInt("gclsprite.height"); mHeader.textureCount = conf.GetInt("gclsprite.texture_count"); std::stringstream fullTextureKey; const std::string textureKey("gclsprite.textures.texture"); for (size_t i=0; i<mHeader.textureCount; ++i) { fullTextureKey.str(""); fullTextureKey << textureKey; fullTextureKey << i; const std::string filename = conf.GetString(fullTextureKey.str().c_str()); std::string fullTextureFileName(TEXTURE_PATH); fullTextureFileName += filename; Texture *texture = new Texture(fullTextureFileName.c_str()); GCLAssertMsg(mHeader.width <= texture->GetResourceWidth(), std::string(filename) + ": You have a sprite that is bigger than your texture"); GCLAssertMsg(mHeader.height <= texture->GetResourceHeight(), std::string(filename) + ": You have a sprite that is bigger than your texture"); mTextureList.push_back(texture); } MeshReal halfWidth = MeshReal(mHeader.width/2.0); MeshReal halfHeight = MeshReal(mHeader.height/2.0); square[0] = VertexPT(Point3<MeshReal>(-halfWidth, halfHeight, 0.0), Point2<MeshReal>(0.0, 1.0)); // top left square[1] = VertexPT(Point3<MeshReal>(halfWidth, -halfHeight, 0.0), Point2<MeshReal>(1.0, 0.0)); // bot right square[2] = VertexPT(Point3<MeshReal>(-halfWidth, -halfHeight, 0.0),Point2<MeshReal>(0.0, 0.0)); // bot left square[3] = VertexPT(Point3<MeshReal>(halfWidth, halfHeight, 0.0), Point2<MeshReal>(1.0, 1.0)); // top right square[4] = VertexPT(Point3<MeshReal>(halfWidth, -halfHeight, 0.0), Point2<MeshReal>(1.0, 0.0)); // bot right square[5] = VertexPT(Point3<MeshReal>(-halfWidth, halfHeight, 0.0), Point2<MeshReal>(0.0, 1.0)); // top left mMaterial = new Material("DefaultSprite"); mObj = new RenderObject( *mMaterial, square, 6); }