void Mesh::draw() const { // --- TODO: Rewrite - way to many state changes... glPushMatrix(); glTranslatef( startBase.x(), startBase.y(), startBase.z() ); GLfloat col[4] = {0.0f, 1.0f, 1.0f, 0.1f} ; glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, col ); glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_BACK, GL_FILL); Vector3f O(0,0,0); Vector3f end = endBase - startBase; glEnable (GL_LIGHTING); glDisable(GL_CULL_FACE); // TODO: do we need this? glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GLfloat c3[4] = {0.3f, 0.3f, 0.3f, 0.5f}; glMaterialfv( GL_FRONT, GL_SPECULAR, c3 ); glMateriali(GL_FRONT, GL_SHININESS, 127); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); glBegin( GL_QUADS ); glColor4fv(primaryColor); GLfloat secondaryColor[4] = {oldRgb[0], oldRgb[1], oldRgb[2], oldAlpha}; //vertex4n(O, startDir1,startDir2+startDir1,startDir2); Vector3f c1(startDir1*0.5f+startDir2*0.5f); Vector3f c2(end+endDir1*0.5f+endDir2*0.5f); vertex4(primaryColor, c1, O, startDir1, secondaryColor,c2, end+endDir1,end,false); vertex4(primaryColor,c1, O, startDir2, secondaryColor,c2, end+endDir2,end,false); vertex4(primaryColor,c1, startDir1, startDir1+startDir2,secondaryColor,c2, end+endDir1+endDir2, end+endDir1,false); vertex4(primaryColor,c1, startDir2, startDir1+startDir2,secondaryColor,c2, end+endDir1+endDir2, end+endDir2,false); //vertex4n(O+end, endDir1+end,endDir2+endDir1+end,endDir2+end); glEnd(); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); };
void TriangleWindow::generateTerrain() { float scale = .2f; GLfloat y1; GLfloat y2; GLfloat y3; GLfloat y4; if (QFile::exists(":/heightmap-2.png")) { if(!m_image.load(":/heightmap-2.png")) { std::cout << "image non chargé "; exit(0); } } else { std::cout << "image not found "; } for(int x = 0; x < m_image.width() - 1; x++) { for(int z = 0; z < m_image.height() - 1; z++) { unsigned char* line = m_image.scanLine(z); unsigned char* line2 = m_image.scanLine(z+1); y1 = (((GLfloat)line[x*4])/255)*20; y2 = (((GLfloat)line[(x*4)+4])/255)*20; y3 = (((GLfloat)line2[(x*4)])/255)*20; y4 = (((GLfloat)line2[(x*4)+4])/255)*20; _texture.push_back(x/(m_image.width()*1.0)); _texture.push_back(z/(m_image.height()*1.0)); _texture.push_back((x+1)/(m_image.width()*1.0)); _texture.push_back(z/(m_image.height()*1.0)); _texture.push_back(x/(m_image.width()*1.0)); _texture.push_back((z+1)/(m_image.height()*1.0)); _texture.push_back((x+1)/(m_image.width()*1.0)); _texture.push_back(z/(m_image.height()*1.0)); _texture.push_back(x/(m_image.width()*1.0)); _texture.push_back((z+1)/(m_image.height()*1.0)); _texture.push_back((x+1)/(m_image.width()*1.0)); _texture.push_back((z+1)/(m_image.height()*1.0)); QVector3D vertex1(x*scale, y1, z*scale); _map.push_back(vertex1); _color.push_back(displayColor(y1)); QVector3D vertex2((x+1)*scale, y2, z*scale); _map.push_back(vertex2); _color.push_back(displayColor(y2)); QVector3D vertex3(x*scale, y3, (z+1)*scale); _map.push_back(vertex3); _color.push_back(displayColor(y3)); QVector3D normal = QVector3D::normal(vertex1, vertex2, vertex3); _normal.push_back(normal); normal = QVector3D::normal(vertex2, vertex3, vertex1); _normal.push_back(normal); normal = QVector3D::normal(vertex3, vertex1, vertex2); _normal.push_back(normal); _map.push_back(vertex2); _color.push_back(displayColor(y2)); QVector3D vertex4((x+1)*scale, y4, (z+1)*scale); _map.push_back(vertex4); _color.push_back(displayColor(y4)); _map.push_back(vertex3); _color.push_back(displayColor(y3)); normal = QVector3D::normal(vertex2, vertex4, vertex3); _normal.push_back(normal); normal = QVector3D::normal(vertex4, vertex3, vertex2); _normal.push_back(normal); normal = QVector3D::normal(vertex3, vertex2, vertex4); _normal.push_back(normal); } } }
void PrimitiveMeshHelper::SolidCube(float width, float height, float depth) { SR_ASSERT(width > 0 && height > 0 && depth > 0); width = width/2; height = height/2; depth = depth/2; DrawCmdData<Vertex> cmd; cmd.draw_mode = kDrawTriangles; VertexList &vert_list = cmd.vertex_list; std::vector<unsigned short> &index_list = cmd.index_list; //normal { // Front Face int baseIndex = vert_list.size(); vec3 normal(0, 0, +1); vec2 texCoord1(0, 0); vec3 vertex1(-width, -height, depth); vec2 texCoord2(1, 0); vec3 vertex2( width, -height, depth); vec2 texCoord3(1, 1); vec3 vertex3( width, height, depth); vec2 texCoord4(0, 1); vec3 vertex4(-width, height, depth); //add vertex Vertex v1; v1.pos = vertex1; v1.texcoord = texCoord1; v1.normal = normal; Vertex v2; v2.pos = vertex2; v2.texcoord = texCoord2; v2.normal = normal; Vertex v3; v3.pos = vertex3; v3.texcoord = texCoord3; v3.normal = normal; Vertex v4; v4.pos = vertex4; v4.texcoord = texCoord4; v4.normal = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Back Face int baseIndex = vert_list.size(); vec3 normal(0, 0, -1); vec2 texCoord1(1, 0); vec3 vertex1(-width, -height, -depth); vec2 texCoord2(1, 1); vec3 vertex2(-width, height, -depth); vec2 texCoord3(0, 1); vec3 vertex3( width, height, -depth); vec2 texCoord4(0, 0); vec3 vertex4( width, -height, -depth); //add vertex Vertex v1; v1.pos = vertex1; v1.texcoord = texCoord1; v1.normal = normal; Vertex v2; v2.pos = vertex2; v2.texcoord = texCoord2; v2.normal = normal; Vertex v3; v3.pos = vertex3; v3.texcoord = texCoord3; v3.normal = normal; Vertex v4; v4.pos = vertex4; v4.texcoord = texCoord4; v4.normal = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Top Face int baseIndex = vert_list.size(); vec3 normal(0, 1, 0); vec2 texCoord1(0, 1); vec3 vertex1(-width, height, -depth); vec2 texCoord2(0, 0); vec3 vertex2(-width, height, depth); vec2 texCoord3(1, 0); vec3 vertex3( width, height, depth); vec2 texCoord4(1, 1); vec3 vertex4( width, height, -depth); //add vertex Vertex v1; v1.pos = vertex1; v1.texcoord = texCoord1; v1.normal = normal; Vertex v2; v2.pos = vertex2; v2.texcoord = texCoord2; v2.normal = normal; Vertex v3; v3.pos = vertex3; v3.texcoord = texCoord3; v3.normal = normal; Vertex v4; v4.pos = vertex4; v4.texcoord = texCoord4; v4.normal = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Bottom Face int baseIndex = vert_list.size(); vec3 normal(0, -1, 0); vec2 texCoord1(1, 1); vec3 vertex1(-width, -height, -depth); vec2 texCoord2(0, 1); vec3 vertex2( width, -height, -depth); vec2 texCoord3(0, 0); vec3 vertex3( width, -height, depth); vec2 texCoord4(1, 0); vec3 vertex4(-width, -height, depth); //add vertex Vertex v1; v1.pos = vertex1; v1.texcoord = texCoord1; v1.normal = normal; Vertex v2; v2.pos = vertex2; v2.texcoord = texCoord2; v2.normal = normal; Vertex v3; v3.pos = vertex3; v3.texcoord = texCoord3; v3.normal = normal; Vertex v4; v4.pos = vertex4; v4.texcoord = texCoord4; v4.normal = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Right face int baseIndex = vert_list.size(); vec3 normal(1, 0, 0); vec2 texCoord1(1, 0); vec3 vertex1(width, -height, -depth); vec2 texCoord2(1, 1); vec3 vertex2(width, height, -depth); vec2 texCoord3(0, 1); vec3 vertex3(width, height, depth); vec2 texCoord4(0, 0); vec3 vertex4(width, -height, depth); //add vertex Vertex v1; v1.pos = vertex1; v1.texcoord = texCoord1; v1.normal = normal; Vertex v2; v2.pos = vertex2; v2.texcoord = texCoord2; v2.normal = normal; Vertex v3; v3.pos = vertex3; v3.texcoord = texCoord3; v3.normal = normal; Vertex v4; v4.pos = vertex4; v4.texcoord = texCoord4; v4.normal = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Left Face int baseIndex = vert_list.size(); vec3 normal(0, -1, 0); vec2 texCoord1(0, 0); vec3 vertex1(-width, -height, -depth); vec2 texCoord2(1, 0); vec3 vertex2(-width, -height, depth); vec2 texCoord3(1, 1); vec3 vertex3(-width, height, depth); vec2 texCoord4(0, 1); vec3 vertex4(-width, height, -depth); //add vertex Vertex v1; v1.pos = vertex1; v1.texcoord = texCoord1; v1.normal = normal; Vertex v2; v2.pos = vertex2; v2.texcoord = texCoord2; v2.normal = normal; Vertex v3; v3.pos = vertex3; v3.texcoord = texCoord3; v3.normal = normal; Vertex v4; v4.pos = vertex4; v4.texcoord = texCoord4; v4.normal = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } this->cmd_list_->push_back(cmd); }
std::vector<DrawCmdData<Vertex_1P1N1UV>> SolidCubeFactory::CreateNormalMesh() { float width = width_/2; float height = height_/2; float depth = depth_/2; DrawCmdData<Vertex_1P1N1UV> cmd; cmd.draw_mode = kDrawTriangles; DrawCmdData<Vertex_1P1N1UV>::VertexList &vert_list = cmd.vertex_list; std::vector<unsigned short> &index_list = cmd.index_list; //normal { // Front Face int baseIndex = vert_list.size(); Vec3 normal(0, 0, +1); Vec2 texCoord1(0, 0); Vec3 vertex1(-width, -height, depth); Vec2 texCoord2(1, 0); Vec3 vertex2( width, -height, depth); Vec2 texCoord3(1, 1); Vec3 vertex3( width, height, depth); Vec2 texCoord4(0, 1); Vec3 vertex4(-width, height, depth); //add vertex Vertex_1P1N1UV v1; v1.p = vertex1; v1.uv = texCoord1; v1.n = normal; Vertex_1P1N1UV v2; v2.p = vertex2; v2.uv = texCoord2; v2.n = normal; Vertex_1P1N1UV v3; v3.p = vertex3; v3.uv = texCoord3; v3.n = normal; Vertex_1P1N1UV v4; v4.p = vertex4; v4.uv = texCoord4; v4.n = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Back Face int baseIndex = vert_list.size(); Vec3 normal(0, 0, -1); Vec2 texCoord1(1, 0); Vec3 vertex1(-width, -height, -depth); Vec2 texCoord2(1, 1); Vec3 vertex2(-width, height, -depth); Vec2 texCoord3(0, 1); Vec3 vertex3( width, height, -depth); Vec2 texCoord4(0, 0); Vec3 vertex4( width, -height, -depth); //add vertex Vertex_1P1N1UV v1; v1.p = vertex1; v1.uv = texCoord1; v1.n = normal; Vertex_1P1N1UV v2; v2.p = vertex2; v2.uv = texCoord2; v2.n = normal; Vertex_1P1N1UV v3; v3.p = vertex3; v3.uv = texCoord3; v3.n = normal; Vertex_1P1N1UV v4; v4.p = vertex4; v4.uv = texCoord4; v4.n = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Top Face int baseIndex = vert_list.size(); Vec3 normal(0, 1, 0); Vec2 texCoord1(0, 1); Vec3 vertex1(-width, height, -depth); Vec2 texCoord2(0, 0); Vec3 vertex2(-width, height, depth); Vec2 texCoord3(1, 0); Vec3 vertex3( width, height, depth); Vec2 texCoord4(1, 1); Vec3 vertex4( width, height, -depth); //add vertex Vertex_1P1N1UV v1; v1.p = vertex1; v1.uv = texCoord1; v1.n = normal; Vertex_1P1N1UV v2; v2.p = vertex2; v2.uv = texCoord2; v2.n = normal; Vertex_1P1N1UV v3; v3.p = vertex3; v3.uv = texCoord3; v3.n = normal; Vertex_1P1N1UV v4; v4.p = vertex4; v4.uv = texCoord4; v4.n = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Bottom Face int baseIndex = vert_list.size(); Vec3 normal(0, -1, 0); Vec2 texCoord1(1, 1); Vec3 vertex1(-width, -height, -depth); Vec2 texCoord2(0, 1); Vec3 vertex2( width, -height, -depth); Vec2 texCoord3(0, 0); Vec3 vertex3( width, -height, depth); Vec2 texCoord4(1, 0); Vec3 vertex4(-width, -height, depth); //add vertex Vertex_1P1N1UV v1; v1.p = vertex1; v1.uv = texCoord1; v1.n = normal; Vertex_1P1N1UV v2; v2.p = vertex2; v2.uv = texCoord2; v2.n = normal; Vertex_1P1N1UV v3; v3.p = vertex3; v3.uv = texCoord3; v3.n = normal; Vertex_1P1N1UV v4; v4.p = vertex4; v4.uv = texCoord4; v4.n = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Right face int baseIndex = vert_list.size(); Vec3 normal(1, 0, 0); Vec2 texCoord1(1, 0); Vec3 vertex1(width, -height, -depth); Vec2 texCoord2(1, 1); Vec3 vertex2(width, height, -depth); Vec2 texCoord3(0, 1); Vec3 vertex3(width, height, depth); Vec2 texCoord4(0, 0); Vec3 vertex4(width, -height, depth); //add vertex Vertex_1P1N1UV v1; v1.p = vertex1; v1.uv = texCoord1; v1.n = normal; Vertex_1P1N1UV v2; v2.p = vertex2; v2.uv = texCoord2; v2.n = normal; Vertex_1P1N1UV v3; v3.p = vertex3; v3.uv = texCoord3; v3.n = normal; Vertex_1P1N1UV v4; v4.p = vertex4; v4.uv = texCoord4; v4.n = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } { // Left Face int baseIndex = vert_list.size(); Vec3 normal(-1, 0, 0); Vec2 texCoord1(0, 0); Vec3 vertex1(-width, -height, -depth); Vec2 texCoord2(1, 0); Vec3 vertex2(-width, -height, depth); Vec2 texCoord3(1, 1); Vec3 vertex3(-width, height, depth); Vec2 texCoord4(0, 1); Vec3 vertex4(-width, height, -depth); //add vertex Vertex_1P1N1UV v1; v1.p = vertex1; v1.uv = texCoord1; v1.n = normal; Vertex_1P1N1UV v2; v2.p = vertex2; v2.uv = texCoord2; v2.n = normal; Vertex_1P1N1UV v3; v3.p = vertex3; v3.uv = texCoord3; v3.n = normal; Vertex_1P1N1UV v4; v4.p = vertex4; v4.uv = texCoord4; v4.n = normal; vert_list.push_back(v1); vert_list.push_back(v2); vert_list.push_back(v3); vert_list.push_back(v4); //add index index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 1); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 0); index_list.push_back(baseIndex + 2); index_list.push_back(baseIndex + 3); } std::vector<DrawCmdData<Vertex_1P1N1UV>> data_list; data_list.push_back(cmd); return data_list; }
void Hud::Draw (Zeni::Time::Second_Type elapsedTime) { HeroComponent & hero = HeroComponent::GetInstance(); double heroHealth = hero.GetHealth(); double heroShields = hero.GetShields(); double healthWidth = 200.0f; double healthHeight = 30.0f; Zeni::Point2f bgPosition1 (590.0f, 40.0f); Zeni::Point2f bgPosition2 (bgPosition1.x, bgPosition1.y + healthHeight); Zeni::Point2f bgPosition3 (bgPosition1.x + healthWidth, bgPosition1.y + healthHeight); Zeni::Point2f bgPosition4 (bgPosition1.x + healthWidth, bgPosition1.y); Zeni::Point2f healthPosition1 = bgPosition1; Zeni::Point2f healthPosition2 = bgPosition2; Zeni::Point2f healthPosition3 (bgPosition1.x + healthWidth * heroHealth / 1000.0f, bgPosition1.y + healthHeight); Zeni::Point2f healthPosition4 (bgPosition1.x + healthWidth * heroHealth / 1000.0f, bgPosition1.y); Zeni::Point2f shieldPosition1 = bgPosition1; Zeni::Point2f shieldPosition2 = bgPosition2; Zeni::Point2f shieldPosition3 (bgPosition1.x + healthWidth * heroShields / 100.0f, bgPosition1.y + healthHeight); Zeni::Point2f shieldPosition4 (bgPosition1.x + healthWidth * heroShields / 100.0f, bgPosition1.y); int score = hero.GetScore(); std::stringstream ss4; ss4 << score; Zeni::get_Fonts()["score"].render_text (ss4.str(), Zeni::Point2f (20.0f, 550.0f), Zeni::get_Colors()["score"]); ++frameCount; std::stringstream ss ("FPS: "); ss << fps; //Zeni::get_Fonts()["fps"].render_text (ss.str(), Zeni::Point2f(), Zeni::get_Colors()["fps"]); const std::vector<ProjectileFactory*>& heroWeapons = hero.GetWeapons(); size_t numWeapons = heroWeapons.size(); int selectedWeapon = hero.GetSelectedWeaponIndex(); double corner = 800.0f - 30.0f * numWeapons; Zeni::Color enabled = Zeni::get_Colors()["weapon_enabled"]; Zeni::Color disabled = Zeni::get_Colors()["weapon_disabled"]; for (int i = 0; i < numWeapons; ++i) { Zeni::Vertex2f_Texture vertex1 (Zeni::Point2f(corner + 30.0f * i, 0.0f), Zeni::Point2f(0.0f, 0.0f)); Zeni::Vertex2f_Texture vertex2 (Zeni::Point2f(corner + 30.0f * i, 30.0f), Zeni::Point2f(0.0f, 1.0f)); Zeni::Vertex2f_Texture vertex3 (Zeni::Point2f(corner + 30.0f * (i + 1), 30.0f), Zeni::Point2f(1.0f, 1.0f)); Zeni::Vertex2f_Texture vertex4 (Zeni::Point2f(corner + 30.0f * (i + 1), 0.0f), Zeni::Point2f(1.0f, 0.0f)); Zeni::Quadrilateral<Zeni::Vertex2f_Texture> q (vertex1, vertex2, vertex3, vertex4); Zeni::Material backing(i == selectedWeapon ? "selected_weapon" : "weapon"); q.lend_Material (&backing); Zeni::get_Video().render (q); double r = selectedWeapon == i ? weaponRotation : 0.0f; Zeni::render_image ( heroWeapons[i]->GetTexture(), Zeni::Point2f(corner + 30 * i + 5.0f, 5.0f), Zeni::Point2f(corner + 30 * (i + 1.0f) - 5.0f, 25.0), r, 1.0f, Zeni::Point2f(corner + 30 * i + 15.0f, 15.0f), false, heroWeapons[i]->IsReady() ? enabled : disabled); } int heroAmmo = heroWeapons[selectedWeapon]->GetAmmo(); std::stringstream ss3; ss3 << heroAmmo; Zeni::get_Fonts()["ammo"].render_text (ss3.str(), Zeni::Point2f(corner - 5.0f, 0.0f), Zeni::get_Colors()["ammo"], Zeni::ZENI_RIGHT); Zeni::Vertex2f_Texture v9 (bgPosition1, Zeni::Point2f (0.0f, 0.0f)); Zeni::Vertex2f_Texture v10 (bgPosition2, Zeni::Point2f (0.0f, 1.0f)); Zeni::Vertex2f_Texture v11 (bgPosition3, Zeni::Point2f (1.0f, 1.0f)); Zeni::Vertex2f_Texture v12 (bgPosition4, Zeni::Point2f (1.0f, 0.0f)); Zeni::Quadrilateral<Zeni::Vertex2f_Texture> q3 (v9, v10, v11, v12); Zeni::Material healthbar1("healthbar1"); q3.lend_Material (&healthbar1); Zeni::get_Video().render (q3); Zeni::Vertex2f_Texture v13 (healthPosition1, Zeni::Point2f (0.0f, 0.0f)); Zeni::Vertex2f_Texture v14 (healthPosition2, Zeni::Point2f (0.0f, 1.0f)); Zeni::Vertex2f_Texture v15 (healthPosition3, Zeni::Point2f (heroHealth / 1000.0f, 1.0f)); Zeni::Vertex2f_Texture v16 (healthPosition4, Zeni::Point2f (heroHealth / 1000.0f, 0.0f)); Zeni::Quadrilateral<Zeni::Vertex2f_Texture> q4 (v13, v14, v15, v16); Zeni::Material healthbar2("healthbar2"); q4.lend_Material (&healthbar2); Zeni::get_Video().render (q4); Zeni::Vertex2f_Texture v17 (shieldPosition1, Zeni::Point2f (0.0f, 0.0f)); Zeni::Vertex2f_Texture v18 (shieldPosition2, Zeni::Point2f (0.0f, 1.0f)); Zeni::Vertex2f_Texture v19 (shieldPosition3, Zeni::Point2f (heroShields / 100.0f, 1.0f)); Zeni::Vertex2f_Texture v20 (shieldPosition4, Zeni::Point2f (heroShields / 100.0f, 0.0f)); Zeni::Quadrilateral<Zeni::Vertex2f_Texture> q5 (v17, v18, v19, v20); Zeni::Material healthbar3("healthbar3"); q5.lend_Material (&healthbar3); Zeni::get_Video().render (q5); double timeRemaining = GameTimer::GetInstance().GetRemainingTime(); Zeni::Color timerTextColor = timeRemaining < 10.0f ? Zeni::get_Colors()["low_time"] : Zeni::get_Colors()["time"]; Zeni::render_image ( "Timer", Zeni::Point2f (620.0f, 540.0f), Zeni::Point2f (670.0f, 590.0f), false, timerTextColor); std::stringstream ss2; int minutes = (int)timeRemaining / 60; ss2 << minutes << ":" << std::fixed << std::setprecision(2) << timeRemaining - minutes * 60; Zeni::get_Fonts()["time"].render_text (ss2.str(), Zeni::Point2f(680.0f, 550.0f), timerTextColor); }