//! @param edge1 one edge of the rectangle //! @param edge2 the opposite edge void rGradient::DrawAtomicRect(tCoord const &edge1, tCoord const &edge2) { #ifndef DEDICATED DrawPoint(edge1); DrawPoint(tCoord(edge1.x, edge2.y)); DrawPoint(edge2); DrawPoint(tCoord(edge2.x, edge1.y)); #endif }
void VerticalBarGauge::RenderGraph(float min, float max, float val, float factor, tValue::Base const &val_s) { float x= factor * ((val-min)/(max-min)*2. - 1.); float y= (x+1.)/2.; const tCoord edge1(tCoord(m_position.x-m_size.x, m_position.y-m_size.y)); const tCoord edge2(tCoord(m_position.x+m_size.x, m_position.y+m_size.y)); m_foreground.SetGradientEdges(edge1, edge2); m_background.SetGradientEdges(edge1, edge2); m_line_color.SetGradientEdges(edge1, edge2); m_foreground.SetValue(y); m_background.SetValue(y); m_line_color.SetValue(y); m_background.DrawRect( tCoord(m_position.x+m_size.x, m_position.y+m_size.y*x), tCoord(m_position.x-m_size.x, m_position.y+m_size.y)); m_foreground.DrawRect( tCoord(m_position.x+m_size.x, m_position.y-m_size.y), tCoord(m_position.x-m_size.x, m_position.y+m_size.y*x)); m_line_color.BeginDraw(); BeginLines(); m_line_color.DrawPoint(tCoord(m_position.x+m_size.x,m_position.y+m_size.y*x)); m_line_color.DrawPoint(tCoord(m_position.x-m_size.x,m_position.y+m_size.y*x)); RenderEnd(); //Value if(m_showvalue) DisplayText( m_position.x, m_position.y, .05*m_size.y, (val_s.GetString()).c_str(), sr_fontCockpit); }
std::shared_ptr<SimpleMesh> SimpleMeshCreator::plane(glm::vec3 pos, glm::vec2 extent, unsigned int meshResX, unsigned int meshResY) { auto plane = std::make_shared<SimpleMesh>(); // Set identity matrix plane->setModelMatrix(mat4(1.f)); meshResX = std::max(1u, meshResX); meshResY = std::max(1u, meshResY); glm::vec3 p0(pos - glm::vec3(extent, 0.0f) * 0.5f); glm::vec3 texCoordDelta(1.0f / glm::vec2(meshResX, meshResY), 0.0f); glm::vec3 stepDelta(extent.x * texCoordDelta.x, extent.y * texCoordDelta.y, 0.0f); unsigned int pointsPerLine = meshResX + 1; const glm::vec4 color(0.6f, 0.6f, 0.6f, 1.0f); auto normals = std::make_shared<Vec3BufferRAM>((meshResX + 1) * (meshResY + 1)); auto normalBuffer = std::make_shared<Buffer<vec3>>(normals); for (unsigned int y = 0; y <= meshResY; ++y) { for (unsigned int x = 0; x <= meshResX; ++x) { glm::vec3 tCoord(texCoordDelta * glm::vec3(x, y, 0.0f)); plane->addVertex(p0 + stepDelta * glm::vec3(x, y, 0.0f), tCoord, color); normals->set(y * pointsPerLine + x, vec3(0.0f, 0.0f, 1.0f)); } } plane->addBuffer(BufferType::NormalAttrib, normalBuffer); // compute indices plane->setIndicesInfo(DrawType::Triangles, ConnectivityType::None); for (unsigned int y = 0; y < meshResY; ++y) { auto indices = std::make_shared<IndexBufferRAM>(pointsPerLine * 2); auto indexBuf = std::make_shared<IndexBuffer>(indices); unsigned int offset = y * pointsPerLine; std::size_t count = 0; for (unsigned int x = 0; x < pointsPerLine; ++x) { indices->set(count++, offset + x); indices->set(count++, offset + x + pointsPerLine); } plane->addIndicies(Mesh::MeshInfo(DrawType::Triangles, ConnectivityType::Strip), indexBuf); } return plane; }
void NeedleGauge::RenderGraph(float min, float max, float val, float factor, tValue::Base const &val_s) { float x, y; float t = m_reverse ? (val - max) / (min - max) : (val - min) / (max - min); float a = m_angle_min * (1 - t) + m_angle_max * t; x= cos(a); y= sin(a); /* Draws an ugly background on the gauge BeginQuads(); Color(1.,1.,1.,.8); Vertex(m_position.x-m_size-.04,m_position.y-.04,0); Vertex(m_position.x-m_size-.04,m_position.y+m_size+.04,0); Vertex(m_position.x+m_size+.04,m_position.y+m_size+.04,0); Vertex(m_position.x+m_size+.04,m_position.y-.04,0); Color(.1,.1,.1,.8); Vertex(m_position.x-m_size-.02,m_position.y-.02,0); Vertex(m_position.x-m_size-.02,m_position.y+m_size+.02,0); Vertex(m_position.x+m_size+.02,m_position.y+m_size+.02,0); Vertex(m_position.x+m_size+.02,m_position.y-.02,0); RenderEnd();*/ BeginLines(); m_foreground.SetValue((factor * ((val-min)/(max-min)*2. - 1.)+1.)/2.); m_foreground.DrawAt(tCoord(0.,0.)); Vertex(-.1*x*m_size.x+m_position.x,.1*y*m_size.y+m_position.y,0); Vertex(-x*m_size.x+m_position.x,y*m_size.y+m_position.y,0); RenderEnd(); if(m_showvalue) DisplayText( -x*1.45*m_size.x+m_position.x, y*1.35*m_size.y+m_position.y, .2*m_size.x, val_s.GetString().c_str(), sr_fontCockpit); if (!sr_glOut) return; }
tCell(eCell s = CELL_EMPTY, tCoord c=tCoord()): state(s), coord(c) {}
tCoord operator+(const tCoord c) { return tCoord(x + c.x, y + c.y, z + c.z); }