CVoid CSkyDome::RenderIcon( CBool selectionMode ) { glUseProgram(0); if( selectionMode ) { glPushName( m_nameIndex ); } if( !selectionMode ) { if( m_nameIndex == g_selectedName || m_nameIndex == g_lastEngineObjectSelectedName ) { g_tempLastEngineObjectSelectedName = m_nameIndex; if( g_transformObject ) { m_position[0] = g_arrowPosition.x; m_position[1] = g_arrowPosition.y - 3.0f; m_position[2] = g_arrowPosition.z; } else { g_arrowPosition.x = m_position[0]; g_arrowPosition.y = m_position[1] + 3.0f; g_arrowPosition.z = m_position[2]; } g_glUtil.Billboarding( m_position[0], m_position[1] + 3.0f, m_position[2], g_skyImg->GetId(), 0.7f, 0.7f, 1.0, 0.0, 0.0 ); g_showArrow = CTrue; } else g_glUtil.Billboarding( m_position[0], m_position[1] + 3.0f, m_position[2], g_skyImg->GetId(), 0.7f, 0.7f ); } else g_glUtil.Billboarding( m_position[0], m_position[1] + 3.0f, m_position[2], g_skyImg->GetId(), 0.7f, 0.7f ); if( selectionMode ) glPopName(); }
void GUIJunctionWrapper::drawGL(const GUIVisualizationSettings& s) const { // check whether it is not too small if (s.scale * myMaxSize < 1.) { return; } if (!myIsInner) { glPushName(getGlID()); glPushMatrix(); const SUMOReal colorValue = static_cast<SUMOReal>(s.junctionColorer.getActive() == 1 && gSelected.isSelected(getType(), getGlID())); GLHelper::setColor(s.junctionColorer.getScheme().getColor(colorValue)); glTranslated(0, 0, getType()); GLHelper::drawFilledPoly(myJunction.getShape(), true); glPopMatrix(); } if (myIsInner) { drawName(myJunction.getPosition(), s.scale, s.internalJunctionName); } else { drawName(myJunction.getPosition(), s.scale, s.junctionName); } glPopName(); }
void GNEPOI::drawGL(const GUIVisualizationSettings& s) const { // check if boundary has to be drawn if(s.drawBoundaries) { GLHelper::drawBoundary(getCenteringBoundary()); } // first clear vertices myPOIVertices.clear(); // check if POI can be drawn if (checkDraw(s)) { // push name (needed for getGUIGlObjectsUnderCursor(...) glPushName(getGlID()); // draw inner polygon drawInnerPOI(s, drawUsingSelectColor()); // draw an orange square mode if there is an image(see #4036) if (!getShapeImgFile().empty() && OptionsCont::getOptions().getBool("gui-testing")) { // Add a draw matrix for drawing logo glPushMatrix(); glTranslated(x(), y(), getType() + 0.01); GLHelper::setColor(RGBColor::ORANGE); GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1); glPopMatrix(); } // check if dotted contour has to be drawn if (myNet->getViewNet()->getDottedAC() == this) { if (getShapeImgFile() != DEFAULT_IMG_FILE) { const double exaggeration = s.poiSize.getExaggeration(s, this); GLHelper::drawShapeDottedContour(getType(), *this, 2 * myHalfImgWidth * exaggeration, 2 * myHalfImgHeight * exaggeration); } else if (myPOIVertices.size() > 0) { glPushMatrix(); glTranslated(x(), y(), getType() + 0.01); GLHelper::drawShapeDottedContour(getType(), myPOIVertices); glPopMatrix(); } } // pop name glPopName(); } }
void GUIViewTraffic::drawRoute(const VehicleOps &vo, int routeNo, SUMOReal darken) { if (myUseToolTips) { glPushName(vo.vehicle->getGlID()); } myVisualizationSettings->vehicleColorer.setGlColor(*(vo.vehicle)); GLdouble colors[4]; glGetDoublev(GL_CURRENT_COLOR, colors); colors[0] -= darken; if (colors[0]<0) colors[0] = 0; colors[1] -= darken; if (colors[1]<0) colors[1] = 0; colors[2] -= darken; if (colors[2]<0) colors[2] = 0; colors[3] -= darken; if (colors[3]<0) colors[3] = 0; glColor3dv(colors); draw(vo.vehicle->getRoute(routeNo)); if (myUseToolTips) { glPopName(); } }
void ParticleShaderVoronoi::drawParticle(int i) { // push the shader name down glPushName(0xffffffff); glMatrixMode(GL_MODELVIEW); glPushMatrix(); gmVector3 p = position->getPosition(i); glTranslatef(p[0],p[1],p[2]); gmMatrix4 rotMat = orientation->getMatrix(i); GLdouble mat[16]; rotMat.copyTo(mat); glMultMatrixd(mat); // Set the disk center GLfloat dC[3] = {0.0, 0.0, 0.0}; // Get the radius if (radius_data) radius = (*radius_data)[i]; else radius = 1.0; // Set the per-particle Cg parameters cgGLSetParameter3fv(diskCenterWC, dC); cgGLSetParameter1f(diskRadius, GLfloat(radius * scale)); cgGLSetStateMatrixParameter(modelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY); cgGLSetStateMatrixParameter(modelView, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY); cgGLSetStateMatrixParameter(modelViewIT, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE_TRANSPOSE); drawShape(i); glPopMatrix(); glPopName(); }
void GeometryNode::walk_gl(bool picking) const { if( picking && m_parent != NULL && m_parent->is_joint()){ glPushName( (GLuint) m_id ); } GLint mm; glGetIntegerv( GL_MATRIX_MODE, &mm); glMatrixMode(GL_MODELVIEW); glPushMatrix(); // glLoadIdentity(); GLdouble t[16]; int z=0; for( int i=0; i < 4; i++ ){ for( int j=0; j < 4; j++ ){ t[z] = m_trans[j][i]; z++; } } glMultMatrixd(t); if(m_material){ m_material -> apply_gl(m_picked); } m_primitive -> walk_gl( picking ); if(picking && m_parent != NULL && m_parent->is_joint()){ glPopName(); } glPopMatrix(); for(ChildList::const_iterator i = m_children.begin(); i != m_children.end(); i++){ (*i)->walk_gl(picking); } glMatrixMode(mm); }
void GUISUMOAbstractView::drawDecals() { glPushName(0); myDecalsLock.lock(); for (std::vector<GUISUMOAbstractView::Decal>::iterator l = myDecals.begin(); l != myDecals.end(); ++l) { GUISUMOAbstractView::Decal& d = *l; if (d.skip2D) { continue; } if (!d.initialised) { try { FXImage* img = checkGDALImage(d); if (img == 0) { img = MFXImageHelper::loadImage(getApp(), d.filename); } if (MFXImageHelper::scalePower2(img, GUITexturesHelper::getMaxTextureSize())) { WRITE_WARNING("Scaling '" + d.filename + "'."); } d.glID = GUITexturesHelper::add(img); d.initialised = true; d.image = img; } catch (InvalidArgument& e) { WRITE_ERROR("Could not load '" + d.filename + "'.\n" + e.what()); d.skip2D = true; } } glPushMatrix(); glTranslated(d.centerX, d.centerY, d.layer); glRotated(d.rot, 0, 0, 1); glColor3d(1, 1, 1); const SUMOReal halfWidth = d.width / 2.; const SUMOReal halfHeight = d.height / 2.; GUITexturesHelper::drawTexturedBox(d.glID, -halfWidth, -halfHeight, halfWidth, halfHeight); glPopMatrix(); } myDecalsLock.unlock(); glPopName(); }
void GLWidget::draw3D(void) { Vector<double> &X = pObj->GetX(), &Y = pObj->GetY(), &Z = pObj->GetZ(); Matrix<int>& Faces = pObj->GetFaces(); int NumFaces = Faces.Size1(), SizeFaces = (Faces.Size2() > 4) ? 3 : Faces.Size2(); // Для обработки квадратичных элементов double x0 = (maxX + minX) * 0.5, y0 = (maxY + minY) * 0.5, z0 = (maxZ + minZ) * 0.5; GLenum Val = (SizeFaces == 3) ? GL_TRIANGLES : GL_QUADS; glInitNames(); /////////////// makeMaterial(0,1,0,1); glBegin(Val); for (int i = 0; i < NumFaces; i++) { glPushName(i); /////////////// glNormal3d(Normal[i][0],Normal[i][1],Normal[i][2]); for (int j = 0; j < SizeFaces; j++) glVertex3d(X[Faces[i][j]] - x0, Y[Faces[i][j]] - y0, Z[Faces[i][j]] - z0); glPopName(); ///////////////// } glEnd(); makeMaterial(0,0,0,1); for (int i = 0; i < NumFaces; i++) { glBegin(GL_LINE_LOOP); for (int j = 0; j < SizeFaces; j++) glVertex3d(X[Faces[i][j]] - x0, Y[Faces[i][j]] - y0, Z[Faces[i][j]] - z0); glEnd(); } }
void GUILane::drawMarkings(const GUIVisualizationSettings& s, SUMOReal scale) const { glPushMatrix(); glPushName(0); glTranslated(0, 0, GLO_EDGE); #ifdef HAVE_INTERNAL if (!MSGlobals::gUseMesoSim) #endif setColor(s); // optionally draw inverse markings if (myIndex > 0) { SUMOReal mw = (myHalfLaneWidth + SUMO_const_laneOffset + .01) * scale; int e = (int) getShape().size() - 1; for (int i = 0; i < e; ++i) { glPushMatrix(); glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1); glRotated(myShapeRotations[i], 0, 0, 1); for (SUMOReal t = 0; t < myShapeLengths[i]; t += 6) { glBegin(GL_QUADS); glVertex2d(-mw, -t); glVertex2d(-mw, -t - 3.); glVertex2d(myQuarterLaneWidth * scale, -t - 3.); glVertex2d(myQuarterLaneWidth * scale, -t); glEnd(); } glPopMatrix(); } } // draw white boundings and white markings glColor3d(1, 1, 1); GLHelper::drawBoxLines( getShape(), getShapeRotations(), getShapeLengths(), (getHalfWidth() + SUMO_const_laneOffset) * scale); glPopMatrix(); glPopName(); }
void CTriangleObj::DrawPickingObjectFace(const int objid) { int i, name = objid; Vector3i* m_pTriangle = (Vector3i*)m_pPolygon; Vector3i *ptri; Vector3d *v; //draw the triangles SETUP_PICKING_GLENV(); for (i=0; i<m_nPolygonCount; i++, name++){ ptri = &m_pTriangle[i]; glPushName(name); glBegin(GL_TRIANGLES); v = &m_pVertex[ptri->x]; glVertex3dv(&v->x); v = &m_pVertex[ptri->y]; glVertex3dv(&v->x); v = &m_pVertex[ptri->z]; glVertex3dv(&v->x); glEnd(); glPopName(); } }
void ccKdTree::drawMeOnly(CC_DRAW_CONTEXT& context) { if (!m_associatedGenericCloud || !m_root) return; if (MACRO_Draw3D(context)) { bool pushName = MACRO_DrawEntityNames(context); if (pushName) { //not fast at all! if (MACRO_DrawFastNamesOnly(context)) return; glPushName(getUniqueIDForDisplay()); } DrawMeOnlyVisitor(m_associatedGenericCloud->getBB()).visit(m_root); if (pushName) glPopName(); } }
// Méthode qui permet de dessiner le sol de la maison void Maison::drawSol(bool withName) { glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); // Matériaux GLfloat mat_Ks[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat mat_Ka[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; GLfloat mat_Kd[4] = { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat mat_Ke[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_Ks); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_Ka); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_Kd); glMaterialfv(GL_FRONT, GL_EMISSION, mat_Ke); glMaterialf(GL_FRONT, GL_SHININESS, 20.0f); if (withName) glPushName(FLOOR_NAME); _floorTexture->bind(); glBegin(GL_POLYGON); glNormal3f(0.0f, 1.0f, 0.0f); for (int i = 0; i < _points.size(); ++i) { glTexCoord2d(_points[i].getX(), _points[i].getY()); glVertex3d(_points[i].getX(), 0.05, _points[i].getY()); } glEnd(); glDisable(GL_TEXTURE_2D); if (withName) glPopName(); }
void drawShapes() { for (std::list<Shape>::iterator it = listOfShapes.begin(); it != listOfShapes.end(); it++) { glPushMatrix(); unsigned int id = it->shapeId; vec3 transV = it->trans.trans; vec3 rotV = it->rot.trans; vec3 scaleV = it->scale.trans; vec3 color = it->color; glVertexAttrib3f(1,color[0],color[1],color[2]); glTranslatef(transV[0],transV[1],transV[2]); glRotatef(rotV[0],1.0,0.0,0.0); glRotatef(rotV[1],0.0,1.0,0.0); glRotatef(rotV[2],0.0,0.0,1.0); glScalef(scaleV[0],scaleV[1],scaleV[2]); glPushName(id); setShaderVariables(shaderProg); it->drawShape(); glPopName(); if(id == selected) { if(GL20Support) glUseProgram(noLightProg); else glUseProgramObjectARB(noLightProg); setShaderVariables(noLightProg); drawSelectCube(); if(GL20Support) glUseProgram(shaderProg); else glUseProgramObjectARB(shaderProg); } glPopMatrix(); } }
void DoseCalcSelectionRenderer::VisitBeamNode(BeamNode* node){ glPushName(count++); names.push_back(node); glDisable(GL_DEPTH_TEST); glColor4f(0,1,0,1); glEnable(GL_LINE_SMOOTH); // draw beam surface glLineWidth(1.0); const float dist = 1.0; const float wh = 0.5, hh = 0.5; glBegin(GL_LINE_STRIP); glVertex3f(-wh,0,-hh); glVertex3f(-wh,0,hh); glVertex3f(wh,0,hh); glVertex3f(wh,0,-hh); glVertex3f(-wh,0,-hh); glEnd(); // draw beam outlines glBegin(GL_LINES); glVertex3f(0.0,-dist,0.0); glVertex3f(-wh,0,-hh); glVertex3f(0.0,-dist,0.0); glVertex3f(-wh,0,hh); glVertex3f(0.0,-dist,0.0); glVertex3f(wh,0,hh); glVertex3f(0.0,-dist,0.0); glVertex3f(wh,0,-hh); glEnd(); glDisable(GL_LINE_SMOOTH); glEnable(GL_DEPTH_TEST); node->VisitSubNodes(*this); CHECK_FOR_GL_ERROR(); glPopName(); }
void Mesh::render(int renderMode, int glMode){ int group_name = 0; int currentID = 0; glBindTexture(GL_TEXTURE_2D, currentID); if (glMode == GL_LINE_LOOP) { renderVerts(); if (renderMode == GL_SELECT) return; } for(Group* g : groups){ if(renderMode == GL_SELECT && glMode == GL_POLYGON){ glLoadName(group_name++); } if(!g->getVisible()){ continue; } string mtlName = g->getMtl(); if(!mtlName.empty()){ Material* mtl = getMtl(mtlName); glMaterialfv(GL_FRONT, GL_SPECULAR, mtl->getSpecular()); glMaterialfv(GL_FRONT, GL_AMBIENT, mtl->getAmbient()); glMaterialfv(GL_FRONT, GL_DIFFUSE, mtl->getDiffuse()); glMaterialf(GL_FRONT, GL_SHININESS, mtl->getShininess()); int tID = mtl->getID(); if(tID != currentID){ currentID = tID; glBindTexture(GL_TEXTURE_2D, currentID); } } int face_name = 0; glColor3f(1.0, 1.0, 1.0); for(Face* f : g->getFaces()){ if (f == face_selected.face) glColor3f(0.603922f, 0.803922f, 0.196078f); vector<int> v = f->getVerts(); vector<int> n = f->getNorms(); vector<int> t = f->getTexts(); bool hasNorm = !n.empty(); bool hasText = !t.empty(); int nv = v.size(); if (renderMode == GL_SELECT && glMode == GL_POLYGON) glPushName(face_name++); glBegin(glMode); for(int x = 0; x < nv; ++x){ if(hasNorm) { glNormal3fv(norms[n[x]].getCoords()); } if(hasText){ glTexCoord2fv(texts[t[x]].getCoords()); } glVertex3fv(verts[v[x]].getCoords()); } glEnd(); if (renderMode == GL_SELECT && glMode == GL_POLYGON) glPopName(); if (f == face_selected.face) glColor3f(1.0, 1.0, 1.0); } } }
void GUITriggeredRerouter::GUITriggeredRerouterEdge::drawGL(const GUIVisualizationSettings& s) const { const SUMOReal exaggeration = s.addSize.getExaggeration(s); if (s.scale * exaggeration >= 3) { glPushName(getGlID()); const SUMOReal prob = myParent->getProbability(); if (myAmClosedEdge) { // draw closing symbol onto all lanes const RerouteInterval* const ri = myParent->getCurrentReroute(MSNet::getInstance()->getCurrentTimeStep()); if (ri != 0 && prob > 0) { // draw only if the edge is closed at this time if (std::find(ri->closed.begin(), ri->closed.end(), myEdge) != ri->closed.end()) { const size_t noLanes = myFGPositions.size(); for (size_t j = 0; j < noLanes; ++j) { Position pos = myFGPositions[j]; SUMOReal rot = myFGRotations[j]; glPushMatrix(); glTranslated(pos.x(), pos.y(), 0); glRotated(rot, 0, 0, 1); glTranslated(0, -1.5, 0); int noPoints = 9; if (s.scale > 25) { noPoints = (int)(9.0 + s.scale / 10.0); if (noPoints > 36) { noPoints = 36; } } glTranslated(0, 0, getType()); //glScaled(exaggeration, exaggeration, 1); glColor3d(0.7, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.3, noPoints); glTranslated(0, 0, .1); glColor3d(1, 0, 0); GLHelper::drawFilledCircle((SUMOReal) 1.3, noPoints, 0, prob * 360); glTranslated(0, 0, .1); glColor3d(1, 1, 1); glRotated(-90, 0, 0, 1); glBegin(GL_TRIANGLES); glVertex2d(0 - .3, -1.); glVertex2d(0 - .3, 1.); glVertex2d(0 + .3, 1.); glVertex2d(0 + .3, -1.); glVertex2d(0 - .3, -1.); glVertex2d(0 + .3, 1.); glEnd(); glPopMatrix(); } } } } else { // draw rerouter symbol onto all lanes for (size_t i = 0; i < myFGPositions.size(); ++i) { const Position& pos = myFGPositions[i]; SUMOReal rot = myFGRotations[i]; glPushMatrix(); glTranslated(pos.x(), pos.y(), 0); glRotated(rot, 0, 0, 1); glTranslated(0, 0, getType()); glScaled(exaggeration, exaggeration, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_TRIANGLES); glColor3d(1, .8f, 0); // base glVertex2d(0 - 1.4, 0); glVertex2d(0 - 1.4, 6); glVertex2d(0 + 1.4, 6); glVertex2d(0 + 1.4, 0); glVertex2d(0 - 1.4, 0); glVertex2d(0 + 1.4, 6); glEnd(); glTranslated(0, 0, .1); glColor3d(0, 0, 0); pfSetPosition(0, 0); pfSetScale(3.f); SUMOReal w = pfdkGetStringWidth("U"); glRotated(180, 0, 1, 0); glTranslated(-w / 2., 2, 0); pfDrawString("U"); glTranslated(w / 2., -2, 0); std::string str = toString((int)(prob * 100)) + "%"; pfSetPosition(0, 0); pfSetScale(.7f); w = pfdkGetStringWidth(str.c_str()); glTranslated(-w / 2., 4, 0); pfDrawString(str.c_str()); glPopMatrix(); } } glPopName(); } }
void GNEDetectorE1::drawGL(const GUIVisualizationSettings& s) const { // get values glPushName(getGlID()); double width = (double) 2.0 * s.scale; glLineWidth(1.0); const double exaggeration = s.addSize.getExaggeration(s, this); // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(s.SUMO_color_E1); } // draw shape glPushMatrix(); glTranslated(0, 0, getType()); glTranslated(myGeometry.shape[0].x(), myGeometry.shape[0].y(), 0); glRotated(myGeometry.shapeRotations[0], 0, 0, 1); glScaled(exaggeration, exaggeration, 1); glBegin(GL_QUADS); glVertex2d(-1.0, 2); glVertex2d(-1.0, -2); glVertex2d(1.0, -2); glVertex2d(1.0, 2); glEnd(); glTranslated(0, 0, .01); glBegin(GL_LINES); glVertex2d(0, 2 - .1); glVertex2d(0, -2 + .1); glEnd(); // outline if isn't being drawn for selecting if ((width * exaggeration > 1) && !s.drawForSelecting) { // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectionColor); } else { GLHelper::setColor(RGBColor::WHITE); } glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_QUADS); glVertex2f(-1.0, 2); glVertex2f(-1.0, -2); glVertex2f(1.0, -2); glVertex2f(1.0, 2); glEnd(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } // position indicator if isn't being drawn for selecting if ((width * exaggeration > 1) && !s.drawForSelecting) { // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectionColor); } else { GLHelper::setColor(RGBColor::WHITE); } glRotated(90, 0, 0, -1); glBegin(GL_LINES); glVertex2d(0, 1.7); glVertex2d(0, -1.7); glEnd(); } // Pop shape matrix glPopMatrix(); // Check if the distance is enought to draw details and isn't being drawn for selecting if ((s.scale * exaggeration >= 10) && !s.drawForSelecting) { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myGeometry.shape.getLineCenter().x(), myGeometry.shape.getLineCenter().y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-1, 0, 0); // draw E1 logo if (drawUsingSelectColor()) { GLHelper::drawText("E1", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E1", Position(), .1, 1.5, RGBColor::BLACK); } // pop matrix glPopMatrix(); // Show Lock icon depending of the Edit mode myBlockIcon.draw(); } // Finish draw if isn't being drawn for selecting if (!s.drawForSelecting) { drawName(getPositionInView(), s.scale, s.addName); } // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape[0], 2, 4, myGeometry.shapeRotations[0]); } // pop name glPopName(); }
void GUIChargingStation::drawGL(const GUIVisualizationSettings& s) const { // Draw Charging Station glPushName(getGlID()); glPushMatrix(); RGBColor blue(114, 210, 252, 255); RGBColor green(76, 170, 50, 255); RGBColor yellow(255, 235, 0, 255); RGBColor yellowCharge(255, 180, 0, 255); // draw the area depending if the vehicle is charging glTranslated(0, 0, getType()); if (myChargingVehicle == true) { GLHelper::setColor(yellowCharge); } else { GLHelper::setColor(blue); } const SUMOReal exaggeration = s.addSize.getExaggeration(s); GLHelper::drawBoxLines(myFGShape, myFGShapeRotations, myFGShapeLengths, exaggeration); // draw details unless zoomed out to far if (s.scale * exaggeration >= 10) { // push charging power matrix glPushMatrix(); // Traslate End positionof signal glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); // Rotate 180 (Eje X -> Mirror) glRotated(180, 1, 0, 0); // Rotate again using myBlockIconRotation glRotated(myFGSignRot, 0, 0, 1); // Set poligon mode glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // set polyfront position on 0,0 pfSetPosition(0, 0); // Set polyfront scale to 1 pfSetScale(1.f); // traslate matrix glTranslated(1.2, 0, 0); // draw charging power pfDrawString((toString(myChargingPower) + " W").c_str()); // pop charging power matrix glPopMatrix(); // draw the sign glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); int noPoints = 9; if (s.scale * exaggeration > 25) { noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36); } glScaled(exaggeration, exaggeration, 1); GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); glTranslated(0, 0, .1); GLHelper::setColor(yellow); GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints); if (s.scale * exaggeration >= 4.5) { GLHelper::drawText("C", Position(), .1, 1.6, blue, myFGSignRot); } glTranslated(5, 0, 0); } glPopMatrix(); glPopName(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); }
void C_API Program::Render(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glInitNames(); if (m_ShowText) { begin2D(m_window_width, m_window_height); glColor3f(1.0f, 1.0f, 1.0f); glPrintf(10, m_window_height-20, "Object Loaded In %f Seconds", m_LoadedObj.fLoadTimeInSecs); glPrintf(10, m_window_height-40, "Vertices: %u", m_LoadedObj.nVertexCount); glPrintf(10, m_window_height-60, "Normals: %u", m_LoadedObj.nNormalCount); glPrintf(10, m_window_height-80, "UVs: %u", m_LoadedObj.nUVCount); glPrintf(10, 20, "FPS: %i", calcFPS()); end2D(); } if (m_LoadedObj.pMesh != NULL) { glPushMatrix(); glTranslatef(0.0f, 0.0f, m_Zoom); glRotatef(-(m_AngleY), 1.0f, 0.0f, 0.0f); glRotatef(-(m_AngleX), 0.0f, 1.0f, 0.0f); Mesh::RenderMode renderMode; if (m_Wireframe) { renderMode = Mesh::Wireframe; glLineWidth(1.0f); // Wireframe Line Color: glColor3f(0.6f, 0.6f, 0.77f); } else { renderMode = Mesh::Solid; glLineWidth(2.0f); } // Render Everything: if (m_LoadedObj.nDrawByGroupID == -1) { // First Pass, Normal Rendering: if ((m_LoadedObj.nNormalCount > 0) && (!m_Wireframe)) { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } m_LoadedObj.pMesh->SetRenderMode(renderMode); Mesh::GroupMap::const_iterator GroupIndex = m_LoadedObj.pMesh->Groups().begin(); Mesh::GroupMap::const_iterator LastGroup = m_LoadedObj.pMesh->Groups().end(); GLuint name = 0; while (GroupIndex != LastGroup) { glPushName(name); m_LoadedObj.pMesh->Render(GroupIndex); glPopName(); ++name; ++GroupIndex; } if ((m_LoadedObj.nNormalCount > 0) && (!m_Wireframe)) { glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); } // Second Pass, Draw Group Outline: if (m_LoadedObj.nSelectedGroup != -1) { glColor3f(0.2f, 0.8f, 0.35f); // Give It A Cool Maya Style Outline Color. m_LoadedObj.pMesh->SetRenderMode(Mesh::Wireframe); m_LoadedObj.pMesh->Render(m_LoadedObj.pMesh->Groups().find(m_vMeshGroups[m_LoadedObj.nSelectedGroup])); } } else // Render The Selected Group Only: { if ((m_LoadedObj.nNormalCount > 0) && (!m_Wireframe)) { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } m_LoadedObj.pMesh->SetRenderMode(renderMode); m_LoadedObj.pMesh->Render(m_LoadedObj.pMesh->Groups().find(m_vMeshGroups[m_LoadedObj.nDrawByGroupID])); if ((m_LoadedObj.nNormalCount > 0) && (!m_Wireframe)) { glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); } } glPopMatrix(); } glFlush(); glutSwapBuffers(); }
void VisualSceneOCCGeometry :: MouseDblClick (int px, int py) { int hits; // select surface triangle by mouse click GLuint selbuf[10000]; glSelectBuffer (10000, selbuf); glRenderMode (GL_SELECT); GLint viewport[4]; glGetIntegerv (GL_VIEWPORT, viewport); glMatrixMode (GL_PROJECTION); glPushMatrix(); GLdouble projmat[16]; glGetDoublev (GL_PROJECTION_MATRIX, projmat); glLoadIdentity(); gluPickMatrix (px, viewport[3] - py, 1, 1, viewport); glMultMatrixd (projmat); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode (GL_MODELVIEW); glPushMatrix(); glMultMatrixf (transformationmat); glInitNames(); glPushName (1); glPolygonOffset (1, 1); glEnable (GL_POLYGON_OFFSET_FILL); glDisable(GL_CLIP_PLANE0); // Philippose - 30/01/2009 // Enable clipping planes for Selection mode in OCC Geometry if (vispar.clipenable) { Vec<3> n(clipplane[0], clipplane[1], clipplane[2]); double len = Abs(n); double mu = -clipplane[3] / (len*len); Point<3> p (mu * n); n /= len; Vec<3> t1 = n.GetNormal (); Vec<3> t2 = Cross (n, t1); double xi1mid = (center - p) * t1; double xi2mid = (center - p) * t2; glLoadName (0); glBegin (GL_QUADS); glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid-rad) * t2); glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid-rad) * t2); glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid+rad) * t2); glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid+rad) * t2); glEnd (); } glCallList (trilists.Get(1)); glDisable (GL_POLYGON_OFFSET_FILL); glPopName(); glMatrixMode (GL_PROJECTION); glPopMatrix(); glMatrixMode (GL_MODELVIEW); glPopMatrix(); glFlush(); hits = glRenderMode (GL_RENDER); int minname = 0; GLuint mindepth = 0; // find clippingplane GLuint clipdepth = 0; // GLuint(-1); for (int i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; if (!curname) clipdepth = selbuf[4*i+1]; } for (int i = 0; i < hits; i++) { int curname = selbuf[4*i+3]; GLuint curdepth = selbuf[4*i+1]; if (curname && (curdepth> clipdepth) && (curdepth < mindepth || !minname)) { mindepth = curdepth; minname = curname; } } occgeometry->LowLightAll(); if (minname) { occgeometry->fvispar[minname-1].Highlight(); if (vispar.occzoomtohighlightedentity) occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE; else occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE; cout << "Selected face: " << minname << endl; } else { occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE; } glDisable(GL_CLIP_PLANE0); SelectFaceInOCCDialogTree (minname); // Philippose - 30/01/2009 // Set the currently selected face in the array // for local face mesh size definition occgeometry->SetSelectedFace(minname); // selecttimestamp = NextTimeStamp(); }
void GNEDetectorE2::drawGL(const GUIVisualizationSettings& s) const { // Start drawing adding an gl identificator glPushName(getGlID()); // Add a draw matrix glPushMatrix(); // Start with the drawing of the area traslating matrix to origin glTranslated(0, 0, getType()); // Set color of the base if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { // set color depending if is or isn't valid if (myE2valid) { GLHelper::setColor(s.SUMO_color_E2); } else { GLHelper::setColor(RGBColor::RED); } } // Obtain exaggeration of the draw const double exaggeration = s.addSize.getExaggeration(s, this); // check if we have to drawn a E2 single lane or a E2 multiLane if (myGeometry.shape.size() > 0) { // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration); } else { // iterate over multishapes for (int i = 0; i < (int)myGeometry.multiShape.size(); i++) { // don't draw shapes over connections if "show connections" is enabled if (!myViewNet->getViewOptions().showConnections() || (i % 2 == 0)) { GLHelper::drawBoxLines(myGeometry.multiShape.at(i), myGeometry.multiShapeRotations.at(i), myGeometry.multiShapeLengths.at(i), exaggeration); } } } // Pop last matrix glPopMatrix(); // Check if the distance is enougth to draw details and isn't being drawn for selecting if ((s.scale * exaggeration >= 10) && !s.drawForSelecting) { // draw logo depending if this is an Multilane E2 detector if (myTagProperty.getTag() == SUMO_TAG_E2DETECTOR) { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myGeometry.shape.getLineCenter().x(), myGeometry.shape.getLineCenter().y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-0.75, 0, 0); // draw E2 logo if (drawUsingSelectColor()) { GLHelper::drawText("E2", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK); } } else { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myBlockIcon.position.x(), myBlockIcon.position.y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-1.5, 0, 0); // draw E2 logo if (drawUsingSelectColor()) { GLHelper::drawText("E2", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK); } //move to logo position glTranslated(1.2, 0, 0); // Rotate depending of myBlockIcon.rotation glRotated(90, 0, 0, 1); if (drawUsingSelectColor()) { GLHelper::drawText("multi", Position(), .1, 0.9, s.selectedAdditionalColor); } else { GLHelper::drawText("multi", Position(), .1, 0.9, RGBColor::BLACK); } } // pop matrix glPopMatrix(); // Show Lock icon depending of the Edit mode myBlockIcon.draw(); } // Draw name if isn't being drawn for selecting if (!s.drawForSelecting) { drawName(getPositionInView(), s.scale, s.addName); } // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { if (myGeometry.shape.size() > 0) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape, exaggeration); } else { GLHelper::drawShapeDottedContour(getType(), myGeometry.multiShapeUnified, exaggeration); } } // Pop name glPopName(); }
//----------------------------------------------------------------------------- // name: render_2() // desc: ... //----------------------------------------------------------------------------- void AudicleFaceShredder::render_2( t_CKFLOAT delta ) { Shred_Stat * stat = NULL; Shred_Data * data = NULL; Color4D c; Point3D p, v, a; Point3D b; t_CKFLOAT theta; static char buffer[2048]; char * t; char * d; int i; // loop through t_CKFLOAT y = 1.15; for( i = 0; i < m_stats.size(); i++ ) { stat = m_stats[i]; data = (Shred_Data *)stat->data; data->pos2[1] = y; y -= .15; } // loop through Shred_Stat * s; t_CKFLOAT srate = Digitalio::sampling_rate() / 1000.0; for( i = 0; i < m_stats.size(); i++ ) { s = m_stats[i]; data = m_stats[i]->data; c = data->color; p = data->pos2; switch( s->state ) { case 0: t = "inactive"; break; case 1: t = "active"; break; case 2: t = "waiting"; break; case 3: t = "done"; break; default: t = "none"; break; } sprintf( buffer, "%i - %s - %s - %s - cycle(%i) - acts(%i) - c/a(%.2f) - avg(%.2fms)", s->id, t, s->name.c_str(), s->source.c_str(), s->cycles, s->activations, s->average_cycles, s->average_ctrl / srate ); // push the name glPushName( data->name ); glPushMatrix(); glColor4f( c[0], c[1], c[2], c[3] ); glTranslatef( p[0], p[1], p[2] ); glutSolidSphere( data->radius2, 15, 15 ); glTranslatef( .1, -.033, 0.0 ); glPushMatrix(); glColor4f( 0.0, 0.0, 0.0, 1.0 ); scaleFont( .052 ); drawString( buffer ); glPopMatrix(); glPopMatrix(); glPopName(); } // loop through map<Shred_Stat *, Shred_Stat *>::iterator iter; for( iter = m_done.begin(); iter != m_done.end(); iter++ ) { s = (*iter).second; data = (Shred_Data *)(*iter).second->data; c = data->color; data->pos2[1] = y; y -= .15; p = data->pos2; switch( s->state ) { case 0: t = "inactive"; break; case 1: t = "active"; break; case 2: t = "waiting"; break; case 3: t = "done"; break; default: t = "none"; break; } sprintf( buffer, "%i - %s - %s - %s - cycle(%i) - acts(%i) - c/a(%.2f) - avg(%.2fms)", s->id, t, s->name.c_str(), s->source.c_str(), s->cycles, s->activations, s->average_cycles, s->average_ctrl / srate ); // push the name glPushName( data->name ); glPushMatrix(); glColor4f( c[0], c[1], c[2], c[3] ); glTranslatef( p[0], p[1], p[2] ); glutSolidSphere( data->radius2, 15, 15 ); glTranslatef( .1, -.033, 0.0 ); glPushMatrix(); glDisable( GL_LIGHTING ); glColor4f( 0.4, 0.4, 0.4, 1.0 ); scaleFont( .052 ); drawString( buffer ); glEnable( GL_LIGHTING ); glPopMatrix(); glPopMatrix(); glPopName(); } }
void SelectionBox::draw(bool withNames){ // set min/max new from grabbed frame: for (unsigned i = 0; i < m_frames.size(); ++i){ if (frame(i)->grabsMouse()){ qglviewer::Vec f = frame(i)->position(); unsigned oi = i+3; float corr = m_arrowLength/2.0; if (i >= 3){ oi = i-3; corr *= -1; } qglviewer::Vec fo = frame(oi)->position(); unsigned ci = i%3; m_minPt[ci] = std::min(f[ci] - corr, fo[ci] + corr); m_maxPt[ci] = std::max(f[ci] - corr, fo[ci] + corr); } } // draw box: glEnable(GL_LINE_SMOOTH); glLineWidth(2.); glDisable(GL_LIGHTING); glColor3f(0.9,0.0, 0.0); glBegin(GL_LINE_LOOP); // Start drawing a line primitive glVertex3f(m_minPt.x, m_minPt.y, m_minPt.z); glVertex3f(m_maxPt.x, m_minPt.y, m_minPt.z); glVertex3f(m_maxPt.x, m_maxPt.y, m_minPt.z); glVertex3f(m_minPt.x, m_maxPt.y, m_minPt.z); glEnd(); glBegin(GL_LINE_LOOP); glVertex3f(m_minPt.x, m_minPt.y, m_maxPt.z); glVertex3f(m_maxPt.x, m_minPt.y, m_maxPt.z); glVertex3f(m_maxPt.x, m_maxPt.y, m_maxPt.z); glVertex3f(m_minPt.x, m_maxPt.y, m_maxPt.z); // glVertex3f(-1.0f, -1.0f, 0.0f); // The bottom left corner // glVertex3f(-1.0f, 1.0f, 0.0f); // The top left corner // glVertex3f(1.0f, 1.0f, 0.0f); // The top right corner // glVertex3f(1.0f, -1.0f, 0.0f); // The bottom right corner glEnd(); glBegin(GL_LINES); glVertex3f(m_minPt.x, m_minPt.y, m_minPt.z); glVertex3f(m_minPt.x, m_minPt.y, m_maxPt.z); glVertex3f(m_maxPt.x, m_minPt.y, m_minPt.z); glVertex3f(m_maxPt.x, m_minPt.y, m_maxPt.z); glVertex3f(m_maxPt.x, m_maxPt.y, m_minPt.z); glVertex3f(m_maxPt.x, m_maxPt.y, m_maxPt.z); glVertex3f(m_minPt.x, m_maxPt.y, m_minPt.z); glVertex3f(m_minPt.x, m_maxPt.y, m_maxPt.z); glEnd(); glDisable(GL_LINE_SMOOTH); glEnable(GL_LIGHTING); // correct all arrow frames: for (unsigned i = 0; i < m_frames.size(); ++i){ qglviewer::Vec pt = m_minPt; float corr = m_arrowLength/2; if (i/3 == 1){ pt = m_maxPt; corr *= -1; } pt[i%3] += corr; frame(i)->setTranslation(pt); } // draw spheres in their frames: // GLUquadricObj* quadric=gluNewQuadric(); // gluQuadricNormals(quadric, GLU_SMOOTH); // glColor4f(1.0, 0.0, 0.0, 1.0); GLboolean lighting, colorMaterial; glGetBooleanv(GL_LIGHTING, &lighting); glGetBooleanv(GL_COLOR_MATERIAL, &colorMaterial); glDisable(GL_COLOR_MATERIAL); for (unsigned i = 0; i < m_frames.size(); ++i){ glPushMatrix(); glMultMatrixd(m_frames[i]->matrix()); if (withNames) glPushName(i); float length = m_arrowLength; if (frame(i)->grabsMouse()) length *= 2; const float radius = length/20; float color[4]; if (i%3 == 0){ // x color[0] = 1.0f; color[1] = 0.7f; color[2] = 0.7f; color[3] = 1.0f; glPushMatrix(); glRotatef(90.0, 0.0, 1.0, 0.0); } else if (i%3 == 1){ // y color[0] = 0.7f; color[1] = 1.0f; color[2] = 0.7f; color[3] = 1.0f; glPushMatrix(); glRotatef(-90.0, 1.0, 0.0, 0.0); } else { // z glPushMatrix(); color[0] = 0.7f; color[1] = 0.7f; color[2] = 1.0f; color[3] = 1.0f; } glTranslatef(0.0, 0.0, -length/2.0); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); QGLViewer::drawArrow(length, radius); glPopMatrix(); if (withNames) glPopName(); glPopMatrix(); } if (colorMaterial) glEnable(GL_COLOR_MATERIAL); if (!lighting) glDisable(GL_LIGHTING); //gluDeleteQuadric(quadric); }
void GUIEdge::drawGL(const GUIVisualizationSettings& s) const { if (s.hideConnectors && myFunction == MSEdge::EDGEFUNCTION_CONNECTOR) { return; } glPushName(getGlID()); // draw the lanes for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) { #ifdef HAVE_INTERNAL if (MSGlobals::gUseMesoSim) { setColor(s); } #endif GUILane* l = dynamic_cast<GUILane*>(*i); if (l != 0) { l->drawGL(s); } } #ifdef HAVE_INTERNAL if (MSGlobals::gUseMesoSim) { if (s.scale * s.vehicleSize.getExaggeration(s) > s.vehicleSize.minSize) { drawMesoVehicles(s); } } #endif glPopName(); // (optionally) draw the name and/or the street name const bool drawEdgeName = s.edgeName.show && myFunction == EDGEFUNCTION_NORMAL; const bool drawInternalEdgeName = s.internalEdgeName.show && myFunction == EDGEFUNCTION_INTERNAL; const bool drawCwaEdgeName = s.cwaEdgeName.show && (myFunction == EDGEFUNCTION_CROSSING || myFunction == EDGEFUNCTION_WALKINGAREA); const bool drawStreetName = s.streetName.show && myStreetName != ""; if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName) { GUILane* lane1 = dynamic_cast<GUILane*>((*myLanes)[0]); GUILane* lane2 = dynamic_cast<GUILane*>((*myLanes).back()); if (lane1 != 0 && lane2 != 0) { Position p = lane1->getShape().positionAtOffset(lane1->getShape().length() / (SUMOReal) 2.); p.add(lane2->getShape().positionAtOffset(lane2->getShape().length() / (SUMOReal) 2.)); p.mul(.5); SUMOReal angle = lane1->getShape().rotationDegreeAtOffset(lane1->getShape().length() / (SUMOReal) 2.); angle += 90; if (angle > 90 && angle < 270) { angle -= 180; } if (drawEdgeName) { drawName(p, s.scale, s.edgeName, angle); } else if (drawInternalEdgeName) { drawName(p, s.scale, s.internalEdgeName, angle); } else if (drawCwaEdgeName) { drawName(p, s.scale, s.cwaEdgeName, angle); } if (drawStreetName) { GLHelper::drawText(getStreetName(), p, GLO_MAX, s.streetName.size / s.scale, s.streetName.color, angle); } } } if (s.scale * s.personSize.getExaggeration(s) > s.personSize.minSize) { myLock.lock(); for (std::set<MSPerson*>::const_iterator i = myPersons.begin(); i != myPersons.end(); ++i) { GUIPerson* person = dynamic_cast<GUIPerson*>(*i); assert(person != 0); person->drawGL(s); } myLock.unlock(); } if (s.scale * s.containerSize.getExaggeration(s) > s.containerSize.minSize) { myLock.lock(); for (std::set<MSContainer*>::const_iterator i = myContainers.begin(); i != myContainers.end(); ++i) { GUIContainer* container = dynamic_cast<GUIContainer*>(*i); assert(container != 0); container->drawGL(s); } myLock.unlock(); } }
void ccGenericMesh::drawMeOnly(CC_DRAW_CONTEXT& context) { ccGenericPointCloud* vertices = getAssociatedCloud(); if (!vertices) return; handleColorRamp(context); //3D pass if (MACRO_Draw3D(context)) { //any triangle? unsigned triNum = size(); if (triNum == 0) return; //L.O.D. bool lodEnabled = (triNum > GET_MAX_LOD_FACES_NUMBER() && context.decimateMeshOnMove && MACRO_LODActivated(context)); unsigned decimStep = (lodEnabled ? (unsigned)ceil((float)triNum*3 / (float)GET_MAX_LOD_FACES_NUMBER()) : 1); unsigned displayedTriNum = triNum / decimStep; //display parameters glDrawParams glParams; getDrawingParameters(glParams); glParams.showNorms &= bool(MACRO_LightIsEnabled(context)); //vertices visibility const ccGenericPointCloud::VisibilityTableType* verticesVisibility = vertices->getTheVisibilityArray(); bool visFiltering = (verticesVisibility && verticesVisibility->isAllocated()); //wireframe ? (not compatible with LOD) bool showWired = isShownAsWire() && !lodEnabled; //per-triangle normals? bool showTriNormals = (hasTriNormals() && triNormsShown()); //fix 'showNorms' glParams.showNorms = showTriNormals || (vertices->hasNormals() && m_normalsDisplayed); //materials & textures bool applyMaterials = (hasMaterials() && materialsShown()); bool showTextures = (hasTextures() && materialsShown() && !lodEnabled); //GL name pushing bool pushName = MACRO_DrawEntityNames(context); //special case: triangle names pushing (for picking) bool pushTriangleNames = MACRO_DrawTriangleNames(context); pushName |= pushTriangleNames; if (pushName) { //not fast at all! if (MACRO_DrawFastNamesOnly(context)) return; glPushName(getUniqueIDForDisplay()); //minimal display for picking mode! glParams.showNorms = false; glParams.showColors = false; //glParams.showSF --> we keep it only if SF 'NaN' values are hidden showTriNormals = false; applyMaterials = false; showTextures = false; } //in the case we need to display scalar field colors ccScalarField* currentDisplayedScalarField = 0; bool greyForNanScalarValues = true; unsigned colorRampSteps = 0; ccColorScale::Shared colorScale(0); if (glParams.showSF) { assert(vertices->isA(CC_TYPES::POINT_CLOUD)); ccPointCloud* cloud = static_cast<ccPointCloud*>(vertices); greyForNanScalarValues = (cloud->getCurrentDisplayedScalarField() && cloud->getCurrentDisplayedScalarField()->areNaNValuesShownInGrey()); if (greyForNanScalarValues && pushName) { //in picking mode, no need to take SF into account if we don't hide any points! glParams.showSF = false; } else { currentDisplayedScalarField = cloud->getCurrentDisplayedScalarField(); colorScale = currentDisplayedScalarField->getColorScale(); colorRampSteps = currentDisplayedScalarField->getColorRampSteps(); assert(colorScale); //get default color ramp if cloud has no scale associated?! if (!colorScale) colorScale = ccColorScalesManager::GetUniqueInstance()->getDefaultScale(ccColorScalesManager::BGYR); } } //materials or color? bool colorMaterial = false; if (glParams.showSF || glParams.showColors) { applyMaterials = false; colorMaterial = true; glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); } //in the case we need to display vertex colors ColorsTableType* rgbColorsTable = 0; if (glParams.showColors) { if (isColorOverriden()) { glColor3ubv(m_tempColor); glParams.showColors = false; } else { assert(vertices->isA(CC_TYPES::POINT_CLOUD)); rgbColorsTable = static_cast<ccPointCloud*>(vertices)->rgbColors(); } } else { glColor3fv(context.defaultMat.diffuseFront); } if (glParams.showNorms) { //DGM: Strangely, when Qt::renderPixmap is called, the OpenGL version can fall to 1.0! glEnable((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_2 ? GL_RESCALE_NORMAL : GL_NORMALIZE)); glEnable(GL_LIGHTING); context.defaultMat.applyGL(true,colorMaterial); } //in the case we need normals (i.e. lighting) NormsIndexesTableType* normalsIndexesTable = 0; ccNormalVectors* compressedNormals = 0; if (glParams.showNorms) { assert(vertices->isA(CC_TYPES::POINT_CLOUD)); normalsIndexesTable = static_cast<ccPointCloud*>(vertices)->normals(); compressedNormals = ccNormalVectors::GetUniqueInstance(); } //stipple mask if (stipplingEnabled()) EnableGLStippleMask(true); if (!pushTriangleNames && !visFiltering && !(applyMaterials || showTextures) && (!glParams.showSF || greyForNanScalarValues)) { //the GL type depends on the PointCoordinateType 'size' (float or double) GLenum GL_COORD_TYPE = sizeof(PointCoordinateType) == 4 ? GL_FLOAT : GL_DOUBLE; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3,GL_COORD_TYPE,0,GetVertexBuffer()); if (glParams.showNorms) { glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_COORD_TYPE,0,GetNormalsBuffer()); } if (glParams.showSF || glParams.showColors) { glEnableClientState(GL_COLOR_ARRAY); glColorPointer(3,GL_UNSIGNED_BYTE,0,GetColorsBuffer()); } //we can scan and process each chunk separately in an optimized way //we mimic the way ccMesh beahves by using virtual chunks! unsigned chunks = static_cast<unsigned>(ceil((double)displayedTriNum/(double)MAX_NUMBER_OF_ELEMENTS_PER_CHUNK)); unsigned chunkStart = 0; const colorType* col = 0; for (unsigned k=0; k<chunks; ++k, chunkStart += MAX_NUMBER_OF_ELEMENTS_PER_CHUNK) { //virtual chunk size const unsigned chunkSize = k+1 < chunks ? MAX_NUMBER_OF_ELEMENTS_PER_CHUNK : (displayedTriNum % MAX_NUMBER_OF_ELEMENTS_PER_CHUNK); //vertices PointCoordinateType* _vertices = GetVertexBuffer(); for (unsigned n=0; n<chunkSize; n+=decimStep) { const CCLib::TriangleSummitsIndexes* ti = getTriangleIndexes(chunkStart + n); memcpy(_vertices,vertices->getPoint(ti->i1)->u,sizeof(PointCoordinateType)*3); _vertices+=3; memcpy(_vertices,vertices->getPoint(ti->i2)->u,sizeof(PointCoordinateType)*3); _vertices+=3; memcpy(_vertices,vertices->getPoint(ti->i3)->u,sizeof(PointCoordinateType)*3); _vertices+=3; } //scalar field if (glParams.showSF) { colorType* _rgbColors = GetColorsBuffer(); assert(colorScale); for (unsigned n=0; n<chunkSize; n+=decimStep) { const CCLib::TriangleSummitsIndexes* ti = getTriangleIndexes(chunkStart + n); col = currentDisplayedScalarField->getValueColor(ti->i1); memcpy(_rgbColors,col,sizeof(colorType)*3); _rgbColors += 3; col = currentDisplayedScalarField->getValueColor(ti->i2); memcpy(_rgbColors,col,sizeof(colorType)*3); _rgbColors += 3; col = currentDisplayedScalarField->getValueColor(ti->i3); memcpy(_rgbColors,col,sizeof(colorType)*3); _rgbColors += 3; } } //colors else if (glParams.showColors) { colorType* _rgbColors = GetColorsBuffer(); for (unsigned n=0; n<chunkSize; n+=decimStep) { const CCLib::TriangleSummitsIndexes* ti = getTriangleIndexes(chunkStart + n); memcpy(_rgbColors,rgbColorsTable->getValue(ti->i1),sizeof(colorType)*3); _rgbColors += 3; memcpy(_rgbColors,rgbColorsTable->getValue(ti->i2),sizeof(colorType)*3); _rgbColors += 3; memcpy(_rgbColors,rgbColorsTable->getValue(ti->i3),sizeof(colorType)*3); _rgbColors += 3; } } //normals if (glParams.showNorms) { PointCoordinateType* _normals = GetNormalsBuffer(); if (showTriNormals) { for (unsigned n=0; n<chunkSize; n+=decimStep) { CCVector3 Na, Nb, Nc; getTriangleNormals(chunkStart + n, Na, Nb, Nc); memcpy(_normals,Na.u,sizeof(PointCoordinateType)*3); _normals+=3; memcpy(_normals,Nb.u,sizeof(PointCoordinateType)*3); _normals+=3; memcpy(_normals,Nc.u,sizeof(PointCoordinateType)*3); _normals+=3; } } else { for (unsigned n=0; n<chunkSize; n+=decimStep) { const CCLib::TriangleSummitsIndexes* ti = getTriangleIndexes(chunkStart + n); memcpy(_normals,vertices->getPointNormal(ti->i1).u,sizeof(PointCoordinateType)*3); _normals+=3; memcpy(_normals,vertices->getPointNormal(ti->i2).u,sizeof(PointCoordinateType)*3); _normals+=3; memcpy(_normals,vertices->getPointNormal(ti->i3).u,sizeof(PointCoordinateType)*3); _normals+=3; } } } if (!showWired) { glDrawArrays(lodEnabled ? GL_POINTS : GL_TRIANGLES,0,(chunkSize/decimStep)*3); } else { glDrawElements(GL_LINES,(chunkSize/decimStep)*6,GL_UNSIGNED_INT,GetWireVertexIndexes()); } } //disable arrays glDisableClientState(GL_VERTEX_ARRAY); if (glParams.showNorms) glDisableClientState(GL_NORMAL_ARRAY); if (glParams.showSF || glParams.showColors) glDisableClientState(GL_COLOR_ARRAY); } else { //current vertex color const colorType *col1=0,*col2=0,*col3=0; //current vertex normal const PointCoordinateType *N1=0,*N2=0,*N3=0; //current vertex texture coordinates float *Tx1=0,*Tx2=0,*Tx3=0; //loop on all triangles int lasMtlIndex = -1; if (showTextures) { //#define TEST_TEXTURED_BUNDLER_IMPORT #ifdef TEST_TEXTURED_BUNDLER_IMPORT glPushAttrib(GL_COLOR_BUFFER_BIT); glEnable(GL_BLEND); glBlendFunc(context.sourceBlend, context.destBlend); #endif glEnable(GL_TEXTURE_2D); } if (pushTriangleNames) glPushName(0); GLenum triangleDisplayType = lodEnabled ? GL_POINTS : showWired ? GL_LINE_LOOP : GL_TRIANGLES; glBegin(triangleDisplayType); //per-triangle normals const NormsIndexesTableType* triNormals = getTriNormsTable(); //materials const ccMaterialSet* materials = getMaterialSet(); for (unsigned n=0; n<triNum; ++n) { //current triangle vertices const CCLib::TriangleSummitsIndexes* tsi = getTriangleIndexes(n); //LOD: shall we display this triangle? if (n % decimStep) continue; if (visFiltering) { //we skip the triangle if at least one vertex is hidden if ((verticesVisibility->getValue(tsi->i1) != POINT_VISIBLE) || (verticesVisibility->getValue(tsi->i2) != POINT_VISIBLE) || (verticesVisibility->getValue(tsi->i3) != POINT_VISIBLE)) continue; } if (glParams.showSF) { assert(colorScale); col1 = currentDisplayedScalarField->getValueColor(tsi->i1); if (!col1) continue; col2 = currentDisplayedScalarField->getValueColor(tsi->i2); if (!col2) continue; col3 = currentDisplayedScalarField->getValueColor(tsi->i3); if (!col3) continue; } else if (glParams.showColors) { col1 = rgbColorsTable->getValue(tsi->i1); col2 = rgbColorsTable->getValue(tsi->i2); col3 = rgbColorsTable->getValue(tsi->i3); } if (glParams.showNorms) { if (showTriNormals) { assert(triNormals); int n1,n2,n3; getTriangleNormalIndexes(n,n1,n2,n3); N1 = (n1>=0 ? ccNormalVectors::GetNormal(triNormals->getValue(n1)).u : 0); N2 = (n1==n2 ? N1 : n1>=0 ? ccNormalVectors::GetNormal(triNormals->getValue(n2)).u : 0); N3 = (n1==n3 ? N1 : n3>=0 ? ccNormalVectors::GetNormal(triNormals->getValue(n3)).u : 0); } else { N1 = compressedNormals->getNormal(normalsIndexesTable->getValue(tsi->i1)).u; N2 = compressedNormals->getNormal(normalsIndexesTable->getValue(tsi->i2)).u; N3 = compressedNormals->getNormal(normalsIndexesTable->getValue(tsi->i3)).u; } } if (applyMaterials || showTextures) { assert(materials); int newMatlIndex = this->getTriangleMtlIndex(n); //do we need to change material? if (lasMtlIndex != newMatlIndex) { assert(newMatlIndex<(int)materials->size()); glEnd(); if (showTextures) { GLuint texID = (newMatlIndex>=0 ? (*materials)[newMatlIndex].texID : 0); if (texID>0) assert(glIsTexture(texID)); glBindTexture(GL_TEXTURE_2D, texID); } //if we don't have any current material, we apply default one (newMatlIndex>=0 ? (*materials)[newMatlIndex] : context.defaultMat).applyGL(glParams.showNorms,false); glBegin(triangleDisplayType); lasMtlIndex=newMatlIndex; } if (showTextures) { getTriangleTexCoordinates(n,Tx1,Tx2,Tx3); } } if (pushTriangleNames) { glEnd(); glLoadName(n); glBegin(triangleDisplayType); } else if (showWired) { glEnd(); glBegin(triangleDisplayType); } //vertex 1 if (N1) ccGL::Normal3v(N1); if (col1) glColor3ubv(col1); if (Tx1) glTexCoord2fv(Tx1); ccGL::Vertex3v(vertices->getPoint(tsi->i1)->u); //vertex 2 if (N2) ccGL::Normal3v(N2); if (col2) glColor3ubv(col2); if (Tx2) glTexCoord2fv(Tx2); ccGL::Vertex3v(vertices->getPoint(tsi->i2)->u); //vertex 3 if (N3) ccGL::Normal3v(N3); if (col3) glColor3ubv(col3); if (Tx3) glTexCoord2fv(Tx3); ccGL::Vertex3v(vertices->getPoint(tsi->i3)->u); } glEnd(); if (pushTriangleNames) glPopName(); if (showTextures) { #ifdef TEST_TEXTURED_BUNDLER_IMPORT glPopAttrib(); //GL_COLOR_BUFFER_BIT #endif glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); } } if (stipplingEnabled()) EnableGLStippleMask(false); if (colorMaterial) glDisable(GL_COLOR_MATERIAL); if (glParams.showNorms) { glDisable(GL_LIGHTING); glDisable((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_2 ? GL_RESCALE_NORMAL : GL_NORMALIZE)); } if (pushName) glPopName(); } }
void ccSymbolCloud::drawMeOnly(CC_DRAW_CONTEXT& context) { if (!m_points->isAllocated()) return; //nothing to do?! if (!m_showSymbols && !m_showLabels) return; if (MACRO_Draw2D(context) && MACRO_Foreground(context)) { //we get display parameters glDrawParams glParams; getDrawingParameters(glParams); //standard case: list names pushing bool pushName = MACRO_DrawEntityNames(context); bool hasLabels = !m_labels.empty(); if (pushName) { //not fast at all! if (MACRO_DrawFastNamesOnly(context)) return; glPushName(getUniqueID()); hasLabels = false; //no need to display labels in 'picking' mode } //we should already be in orthoprojective & centered omde //glOrtho(-halfW,halfW,-halfH,halfH,-maxS,maxS); //default color const unsigned char* color = context.pointsDefaultCol; if (isColorOverriden()) { color = m_tempColor; glParams.showColors = false; } if (!glParams.showColors) glColor3ubv(color); unsigned numberOfPoints = size(); //viewport parameters (will be used to project 3D positions to 2D) int VP[4]; context._win->getViewportArray(VP); const double* MM = context._win->getModelViewMatd(); //viewMat const double* MP = context._win->getProjectionMatd(); //projMat //only usefull when displaying labels! QFont font(context._win->getTextDisplayFont()); //takes rendering zoom into account! font.setPointSize(static_cast<int>(m_fontSize * context.renderZoom)); //font.setBold(true); QFontMetrics fontMetrics(font); double symbolSizeBackup = m_symbolSize; m_symbolSize *= static_cast<double>(context.renderZoom); double xpShift = 0.0; if (m_labelAlignFlags & ccGenericGLDisplay::ALIGN_HLEFT) xpShift = m_symbolSize/2.0; else if (m_labelAlignFlags & ccGenericGLDisplay::ALIGN_HRIGHT) xpShift = -m_symbolSize/2.0; double ypShift = 0.0; if (m_labelAlignFlags & ccGenericGLDisplay::ALIGN_VTOP) ypShift = m_symbolSize/2.0; else if (m_labelAlignFlags & ccGenericGLDisplay::ALIGN_VBOTTOM) ypShift = -m_symbolSize/2.0; //draw symbols + labels { for (unsigned i=0;i<numberOfPoints;i++) { //symbol center const CCVector3* P = getPoint(i); //project it in 2D screen coordinates GLdouble xp,yp,zp; gluProject(P->x,P->y,P->z,MM,MP,VP,&xp,&yp,&zp); //apply point color (if any) if (glParams.showColors) { color = getPointColor(i); glColor3ubv(color); } //draw associated symbol if (m_showSymbols && m_symbolSize > 0.0) { drawSymbolAt(xp-static_cast<double>(context.glW/2),yp-static_cast<double>(context.glH/2)); } //draw associated label? if (m_showLabels && hasLabels && m_labels.size() > i && !m_labels[i].isNull()) { //draw label context._win->displayText(m_labels[i],static_cast<int>(xp+xpShift),static_cast<int>(yp+ypShift),m_labelAlignFlags,0,color,&font); } } } //restore original symbol size m_symbolSize = symbolSizeBackup; if (pushName) glPopName(); } }
void GNEDetectorEntry::drawGL(const GUIVisualizationSettings& s) const { // Start drawing adding gl identificator glPushName(getGlID()); // Push detector matrix glPushMatrix(); glTranslated(0, 0, getType()); // Set initial values if(isAdditionalSelected()) { glColor3d(myBaseColorSelected.red(), myBaseColorSelected.green(), myBaseColorSelected.blue()); } else { glColor3d(myBaseColor.red(), myBaseColor.green(), myBaseColor.blue()); } const SUMOReal exaggeration = s.addSize.getExaggeration(s); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Push poligon matrix glPushMatrix(); glScaled(exaggeration, exaggeration, 1); glTranslated(myShape[0].x(), myShape[0].y(), 0); glRotated(myShapeRotations[0], 0, 0, 1); // Draw poligon glBegin(GL_LINES); glVertex2d(1.7, 0); glVertex2d(-1.7, 0); glEnd(); glBegin(GL_QUADS); glVertex2d(-1.7, .5); glVertex2d(-1.7, -.5); glVertex2d(1.7, -.5); glVertex2d(1.7, .5); glEnd(); // first Arrow glTranslated(1.5, 0, 0); GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05); GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (SUMOReal) 1, (SUMOReal) .25); // second Arrow glTranslated(-3, 0, 0); GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05); GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (SUMOReal) 1, (SUMOReal) .25); // Pop poligon matrix glPopMatrix(); // Pop detector matrix glPopMatrix(); // Check if the distance is enought to draw details if (s.scale * exaggeration >= 10) { // Draw icon drawDetectorIcon(GUITextureSubSys::getGif(GNETEXTURE_ENTRY), 1.5, 1); // Show Lock icon depending of the Edit mode drawLockIcon(0.4); } // Draw name drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); // pop gl identificator glPopName(); }
void ROWdrawAction_drawLinkRules(const GUINet &net, const GUILaneWrapper &lane, bool showToolTips) { unsigned int noLinks = lane.getLinkNumber(); const Position2DVector &g = lane.getShape(); const Position2D &end = g.getEnd(); const Position2D &f = g[-2]; const Position2D &s = end; SUMOReal rot = (SUMOReal) atan2((s.x()-f.x()), (f.y()-s.y()))*(SUMOReal) 180.0/(SUMOReal) PI; if (noLinks==0) { if (showToolTips) { glPushName(lane.getGlID()); } // draw a grey bar if no links are on the street glColor3d(0.5, 0.5, 0.5); glPushMatrix(); glTranslated(end.x(), end.y(), 0); glRotated(rot, 0, 0, 1); glBegin(GL_QUADS); glVertex2d(-SUMO_const_halfLaneWidth, 0.0); glVertex2d(-SUMO_const_halfLaneWidth, 0.5); glVertex2d(SUMO_const_halfLaneWidth, 0.5); glVertex2d(SUMO_const_halfLaneWidth, 0.0); glEnd(); glPopMatrix(); if (showToolTips) { glPopName(); } return; } // draw all links SUMOReal w = SUMO_const_laneWidth / (SUMOReal) noLinks; SUMOReal x1 = 0; glPushMatrix(); glTranslated(end.x(), end.y(), 0); glRotated(rot, 0, 0, 1); for (unsigned int i=0; i<noLinks; ++i) { SUMOReal x2 = x1 + w; MSLink::LinkState state = lane.getLane().getLinkCont()[i]->getState(); if (showToolTips) { switch (state) { case MSLink::LINKSTATE_TL_GREEN_MAJOR: case MSLink::LINKSTATE_TL_GREEN_MINOR: case MSLink::LINKSTATE_TL_RED: case MSLink::LINKSTATE_TL_YELLOW_MAJOR: case MSLink::LINKSTATE_TL_YELLOW_MINOR: case MSLink::LINKSTATE_TL_OFF_BLINKING: glPushName(net.getLinkTLID(lane.getLane().getLinkCont()[i])); break; case MSLink::LINKSTATE_MAJOR: case MSLink::LINKSTATE_MINOR: case MSLink::LINKSTATE_EQUAL: case MSLink::LINKSTATE_TL_OFF_NOSIGNAL: default: glPushName(lane.getGlID()); break; } } switch (state) { case MSLink::LINKSTATE_TL_GREEN_MAJOR: case MSLink::LINKSTATE_TL_GREEN_MINOR: glColor3d(0, 1, 0); break; case MSLink::LINKSTATE_TL_RED: glColor3d(1, 0, 0); break; case MSLink::LINKSTATE_TL_YELLOW_MAJOR: case MSLink::LINKSTATE_TL_YELLOW_MINOR: glColor3d(1, 1, 0); break; case MSLink::LINKSTATE_TL_OFF_BLINKING: glColor3d(1, 1, 0); break; case MSLink::LINKSTATE_TL_OFF_NOSIGNAL: glColor3d(0, 1, 1); break; case MSLink::LINKSTATE_MAJOR: glColor3d(1, 1, 1); break; case MSLink::LINKSTATE_MINOR: glColor3d(.2, .2, .2); break; case MSLink::LINKSTATE_EQUAL: glColor3d(.5, .5, .5); break; case MSLink::LINKSTATE_DEADEND: glColor3d(0, 0, 0); break; } glBegin(GL_QUADS); glVertex2d(x1-SUMO_const_halfLaneWidth, 0.0); glVertex2d(x1-SUMO_const_halfLaneWidth, 0.5); glVertex2d(x2-SUMO_const_halfLaneWidth, 0.5); glVertex2d(x2-SUMO_const_halfLaneWidth,0.0); glEnd(); if (showToolTips) { glPopName(); } x1 = x2; x2 += w; } glPopMatrix(); }
//----------------------------------------------------------------------------- // name: render() // desc: ... //----------------------------------------------------------------------------- t_CKUINT AudicleFaceShredder::render( void * d ) { static t_CKFLOAT x = 0.0; glPushMatrix(); glPushName( m_b1_id ); glTranslatef( 1.5, -1.1, .1 ); glColor3f( .25, .75, .25 ); glRotatef( x, 0.0, 0.0, 1.0 ); x += .1 ; glutWireSphere( sphere_down ? .06 : .075, 15, 15 ); glPopName(); glPopMatrix(); glRotatef( m_eye_y * 100.0, 1.0, 0.0, 0.0 ); // get shreds from ChucK VM AudicleStats::instance()->get_shreds( m_stats, m_done ); Shred_Stat * stat = NULL; Shred_Data * data = NULL; Color4D c; Point3D p, v, a; Point3D b; t_CKFLOAT theta; m_time = AudicleWindow::main()->get_current_time(); if( m_last_time < 0.0 ) m_last_time = m_time; t_CKFLOAT delta = m_time - m_last_time; m_last_time = m_time; int i; // loop through for( i = 0; i < m_stats.size(); i++ ) { stat = m_stats[i]; data = (Shred_Data *)stat->data; // initialized? if( stat->data == NULL ) { initialize_stat_data ( stat ); } if( stat->data->in_shredder_map == false ) { //this will catch data that have been inited //outside the shredder ( like in TNT! ) m_map[stat->data->name] = stat->data; stat->data->in_shredder_map = true; } } // loop through for( i = 0; i < m_stats.size(); i++ ) { stat = m_stats[i]; data = (Shred_Data *)stat->data; p = data->pos; // v = data->vel; // a = data->acc; // advance // v += a * delta; theta = stat->average_cycles / 100000.0 + v[0]; b[0] = cos(theta) * p[0] + sin(theta) * p[1]; b[1] = -sin(theta) * p[0] + cos(theta) * p[1]; b[2] = p[2]; data->pos = b; // data->vel = v; } // loop through for( i = 0; i < m_stats.size(); i++ ) { data = (Shred_Data *)m_stats[i]->data; if( data->radius < .15 ) data->radius += .05 * delta; for( int j = 0; j < m_stats.size(); j++ ) { Shred_Data * other = (Shred_Data *)m_stats[j]->data; if( data == other ) continue; t_CKFLOAT norm = ( data->pos - other->pos ).length(); if( norm < ( data->radius + other->radius + .02 ) ) { Shred_Data * smaller = other->radius < data->radius ? other : data; Shred_Data * bigger = smaller == other ? data : other; t_CKFLOAT ratio = norm / ( data->radius + other->radius + .02 ); data->radius *= ratio; other->radius *= ratio; if( smaller->radius < .07 ) smaller->radius = .07; if( bigger->radius < .07 ) bigger->radius = .07; } } } // loop through m_happy.clear(); map<Shred_Stat *, Shred_Stat *>::iterator iter; for( iter = m_done.begin(); iter != m_done.end(); iter++ ) { stat = (*iter).second; data = (Shred_Data *)stat->data; // data->color.scale( .9 ); if( !data || data->pos[2] > 20.0 ) { if( data ) data->ref_count--; m_happy.push_back( stat ); continue; } data->x += .0015; data->pos[2] += data->x * delta; // data->radius -= .1 * delta; } // loop through for( i = 0; i < m_happy.size(); i++ ) { m_done.erase( m_done.find( m_happy[i] ) ); } if( which == 1 ) render_1( delta ); else if( which == 2 ) render_2( delta ); // else if( which == 3 ) render_3(); return 0; }
void GUILaneWrapper::drawGL(const GUIVisualizationSettings &s) const throw() { // set lane color #ifdef HAVE_MESOSIM if (!MSGlobals::gUseMesoSim) #endif s.laneColorer.setGlColor(*this); // (optional) set id if (s.needsGlID) { glPushName(getGlID()); } // draw lane // check whether it is not too small if (s.scale<1.) { GLHelper::drawLine(myShape); // (optional) clear id if (s.needsGlID) { glPopName(); } } else { if (getLane().getEdge().getPurpose()!=MSEdge::EDGEFUNCTION_INTERNAL) { glTranslated(0, 0, .005); GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, SUMO_const_halfLaneWidth); glTranslated(0, 0, -.005); } else { GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, SUMO_const_quarterLaneWidth); } // (optional) clear id if (s.needsGlID) { glPopName(); } // draw ROWs (not for inner lanes) if (getLane().getEdge().getPurpose()!=MSEdge::EDGEFUNCTION_INTERNAL) {// !!! getPurpose() glTranslated(0, 0, -.02); GUINet *net = (GUINet*) MSNet::getInstance(); ROWdrawAction_drawLinkRules(*net, *this, s.needsGlID); if (s.showLinkDecals) { ROWdrawAction_drawArrows(*this, s.needsGlID); } if (s.showLane2Lane) { // this should be independent to the geometry: // draw from end of first to the begin of second ROWdrawAction_drawLane2LaneConnections(*this); } glTranslated(0, 0, .02); if (s.drawLinkJunctionIndex) { glTranslated(0, 0, -.03); ROWdrawAction_drawLinkNo(*this); glTranslated(0, 0, .03); } if (s.drawLinkTLIndex) { glTranslated(0, 0, -.03); ROWdrawAction_drawTLSLinkNo(*net, *this); glTranslated(0, 0, .03); } } } // draw vehicles if (s.scale>s.minVehicleSize) { // retrieve vehicles from lane; disallow simulation const MSLane::VehCont &vehicles = myLane.getVehiclesSecure(); for (MSLane::VehCont::const_iterator v=vehicles.begin(); v!=vehicles.end(); ++v) { static_cast<const GUIVehicle*const>(*v)->drawGL(s); } // allow lane simulation myLane.releaseVehicles(); } glPopMatrix(); }