void TransformGroup::render(const RenderingConfiguration &renderingConfiguration) const { Lock l(m_listOfChildrenMutex); // Render if unnamed or not disabled. if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { // Translate the model. glTranslated(m_translation.getX(), m_translation.getY(), m_translation.getZ()); // Rotate the model using DEG (m_rotation is in RAD!). glRotated(m_rotation.getX()*180.0 / data::Constants::PI, 1, 0, 0); glRotated(m_rotation.getY()*180.0 / data::Constants::PI, 0, 1, 0); glRotated(m_rotation.getZ()*180.0 / data::Constants::PI, 0, 0, 1); // Scale the model. glScaled(m_scaling.getX(), m_scaling.getY(), m_scaling.getZ()); // Draw all existing children. vector<Node*>::const_iterator it = m_listOfChildren.begin(); while (it != m_listOfChildren.end()) { const Node *n = (*it++); if (n != NULL) { n->render(renderingConfiguration); } } } glPopMatrix(); } }
void Grid::render(RenderingConfiguration &renderingConfiguration) { if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { glLineWidth(m_lineWidth); glColor3f(1, 1, 1); glBegin(GL_LINES); int32_t size = m_size; for (int32_t y = -size; y <= size; y++) { for (int32_t x = -size; x <= size; x++) { // X-axis. glVertex3f(0, static_cast<float>(y), 0); glVertex3f(static_cast<float>(x), static_cast<float>(y), 0); // Y-axis. glVertex3f(static_cast<float>(x), 0, 0); glVertex3f(static_cast<float>(x), static_cast<float>(y), 0); } } glEnd(); glLineWidth(1); } glPopMatrix(); } }
void HeightGridRenderer::render(const RenderingConfiguration &renderingConfiguration) const { if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { glCallList(m_callList); } glPopMatrix(); } }
void Point::render(const RenderingConfiguration &renderingConfiguration) const { if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { glPointSize(m_width); glColor3d(m_color.getX(), m_color.getY(), m_color.getZ()); glBegin(GL_POINTS); glVertex3d(m_position.getX(), m_position.getY(), m_position.getZ()); glEnd(); glPointSize(1); } glPopMatrix(); } }
void Triangle::render(RenderingConfiguration &renderingConfiguration) { if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { glBegin(GL_TRIANGLES); glNormal3d(m_normal.getX(), m_normal.getY(), m_normal.getZ()); for (uint32_t i = 0; i < 3; i++) { if (m_textureCoordinates.size() == 3) { glTexCoord2d(m_textureCoordinates[i].getX(), m_textureCoordinates[i].getY()); } glVertex3d(m_vertices[i].getX(), m_vertices[i].getY(), m_vertices[i].getZ()); } glEnd(); } glPopMatrix(); } }
void Line::render(RenderingConfiguration &renderingConfiguration) { // Render if unnamed or not disabled. if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { glLineWidth(m_width); glColor3d(m_color.getX(), m_color.getY(), m_color.getZ()); glBegin(GL_LINES); glVertex3d(m_positionA.getX(), m_positionA.getY(), m_positionA.getZ()); glVertex3d(m_positionB.getX(), m_positionB.getY(), m_positionB.getZ()); glEnd(); glLineWidth(1); } glPopMatrix(); } }
void Polygon::render(RenderingConfiguration &renderingConfiguration) { if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { glColor3d(m_color.getX(), m_color.getY(), m_color.getZ()); glBegin(GL_QUADS); for (uint32_t i = 0; i < m_listOfGroundVertices.size() - 1; i++) { const Point3 &p1 = m_listOfGroundVertices[i]; const Point3 &p2 = m_listOfGroundVertices[i+1]; Point3 P12 = p2 - p1; P12.setZ(0); const Point3 P1H = Point3(p1.getX(), p1.getY(), m_height); const Point3 P1HxP12 = P1H.cross(P12); glVertex3d(p1.getX(), p1.getY(), 0); glVertex3d(p1.getX(), p1.getY(), m_height); glVertex3d(p2.getX(), p2.getY(), m_height); glVertex3d(p2.getX(), p2.getY(), 0); glNormal3d(P1HxP12.getX(), P1HxP12.getY(), P1HxP12.getZ()); } glEnd(); // Bottom of the polygon. glBegin(GL_POLYGON); for (uint32_t i = 0; i < m_listOfGroundVertices.size(); i++) { const Point3 &p1 = m_listOfGroundVertices[i]; glVertex3d(p1.getX(), p1.getY(), 0); } glEnd(); // Top of the polygon. glBegin(GL_POLYGON); for (uint32_t i = 0; i < m_listOfGroundVertices.size(); i++) { const Point3 &p1 = m_listOfGroundVertices[i]; glVertex3d(p1.getX(), p1.getY(), m_height); } glEnd(); } glPopMatrix(); } }
void CheckerBoard::render(const RenderingConfiguration &renderingConfiguration) const { if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { bool color = false; uint32_t squares = 0; double height = 0; while (height < m_height) { Point3 p = m_positionA; double d = p.getDistanceTo(m_positionB); squares = 0; while (d > 0.1) { if (color) { glColor3d(1, 1, 1); } else { glColor3d(0.1, 0.1, 0.1); } glBegin(GL_QUADS); { glVertex3d(p.getX(), p.getY(), height); glVertex3d(p.getX(), p.getY(), height + 0.1); p += Point3(0.1, 0, 0); glVertex3d(p.getX(), p.getY(), height + 0.1); glVertex3d(p.getX(), p.getY(), height); } glEnd(); color = !color; d = p.getDistanceTo(m_positionB); squares++; } if ((squares % 2) == 0) { color = !color; } height += 0.1; } } glPopMatrix(); } }
void TriangleSet::render(RenderingConfiguration &renderingConfiguration) { if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { // Try to load an apropriate texture. int32_t textureHandle = m_material.getTextureHandle(); if (textureHandle > 0) { if (renderingConfiguration.hasDrawTextures()) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, static_cast<uint32_t>(textureHandle)); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); } } else { glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); float ambient[] = { static_cast<float>(m_material.getAmbient().getX()), static_cast<float>(m_material.getAmbient().getY()), static_cast<float>(m_material.getAmbient().getZ()) }; // float ambient[] = { 0, // 0, // 0 // }; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); float diffuse[] = { static_cast<float>(m_material.getDiffuse().getX()), static_cast<float>(m_material.getDiffuse().getY()), static_cast<float>(m_material.getDiffuse().getZ()) }; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); float specular[] = { static_cast<float>(m_material.getSpecular().getX()), static_cast<float>(m_material.getSpecular().getY()), static_cast<float>(m_material.getSpecular().getZ()) }; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, static_cast<float>(m_material.getShininess())); glColor3d(m_material.getDiffuse().getX(), m_material.getDiffuse().getY(), m_material.getDiffuse().getZ()); } // Use compiled lists. if (!m_compiled) { compile(); } glCallList(m_callList); if (textureHandle) { if (renderingConfiguration.hasDrawTextures()) { glDisable(GL_TEXTURE_2D); } } } glPopMatrix(); } }
void XYZAxes::render(const RenderingConfiguration &renderingConfiguration) const { // Render if unnamed or not disabled. if ((getNodeDescriptor().getName().size() == 0) || (renderingConfiguration.getNodeRenderingConfiguration(getNodeDescriptor()).hasParameter(NodeRenderingConfiguration::ENABLED))) { glPushMatrix(); { glLineWidth(m_lineWidth); glColor3f(1, 1, 1); glBegin(GL_LINES); // X-axis. glVertex3f(0, 0, 0); glVertex3f(m_lineLength, 0, 0); // Arrow. glVertex3f(m_lineLength, 0, 0); glVertex3f((m_lineLength - 0.1f), 0.1f, 0); glVertex3f(m_lineLength, 0, 0); glVertex3f((m_lineLength - 0.1f), -0.1f, 0); // X-label. glVertex3f(-0.3f + (m_lineLength - 0.1f), -0.3f + 0.1f, 0); glVertex3f(-0.3f + (m_lineLength + 0.1f), -0.3f + -0.1f, 0); glVertex3f(-0.3f + (m_lineLength + 0.1f), -0.3f + 0.1f, 0); glVertex3f(-0.3f + (m_lineLength - 0.1f), -0.3f + -0.1f, 0); // Y-axis glVertex3f(0, 0, 0); glVertex3f(0, m_lineLength, 0); // Arrow. glVertex3f(0, m_lineLength, 0); glVertex3f(0.1f, (m_lineLength - 0.1f), 0); glVertex3f(0, m_lineLength, 0); glVertex3f(-0.1f, (m_lineLength - 0.1f), 0); // Y-label. glVertex3f(-0.3f + -0.1f, m_lineLength, 0); glVertex3f(-0.3f + 0, (m_lineLength - 0.1f), 0); glVertex3f(-0.3f + 0.1f, m_lineLength, 0); glVertex3f(-0.3f + 0, (m_lineLength - 0.1f), 0); glVertex3f(-0.3f + 0, (m_lineLength - 0.1f), 0); glVertex3f(-0.3f + 0, (m_lineLength - 0.2f), 0); // Z-axis glVertex3f(0, 0, 0); glVertex3f(0, 0, m_lineLength); // Arrow. glVertex3f(0, 0, m_lineLength); glVertex3f(0.1f, 0, (m_lineLength - 0.1f)); glVertex3f(0, 0, m_lineLength); glVertex3f(-0.1f, 0, (m_lineLength - 0.1f)); // Z-label. glVertex3f(-0.3f + -0.1f, 0, m_lineLength); glVertex3f(-0.3f + 0.1f, 0, m_lineLength); glVertex3f(-0.3f + 0.1f, 0, m_lineLength); glVertex3f(-0.3f + -0.1f, 0, (m_lineLength - 0.1f)); glVertex3f(-0.3f + -0.1f, 0, (m_lineLength - 0.1f)); glVertex3f(-0.3f + 0.1f, 0, (m_lineLength - 0.1f)); glEnd(); glLineWidth(1); } glPopMatrix(); } }