void drawCoordWidget(float size,float thickness,float arrowSize,float arrowWidth) { glEnable(GL_LIGHTING); float white[]={1,1,1,1}; float red[]={1,0,0,1}; float green[]={0,1,0,1}; float blue[]={0,0,1,1}; glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,white); drawSphere(size*thickness*2.0,16,8); glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,red); drawCylinder(Vector3(size*(1.0-arrowSize),0,0),size*thickness,8); glPushMatrix(); glTranslatef(size*(1.0-arrowSize),0,0); drawCone(Vector3(size*arrowSize,0,0),size*arrowWidth,8); glPopMatrix(); glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,green); drawCylinder(Vector3(0,size*(1.0-arrowSize),0),size*thickness,8); glPushMatrix(); glTranslatef(0,size*(1.0-arrowSize),0); drawCone(Vector3(0,size*arrowSize,0),size*arrowWidth,8); glPopMatrix(); glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,blue); drawCylinder(Vector3(0,0,size*(1.0-arrowSize)),size*thickness,8); glPushMatrix(); glTranslatef(0,0,size*(1.0-arrowSize)); drawCone(Vector3(0,0,size*arrowSize),size*arrowWidth,8); glPopMatrix(); }
void PatBike::drawBottomBackFrame() { glPushMatrix(); glColor3f(1,1,0); glTranslatef(-1.9, 0.0, -0.30); glRotatef (90.0 , 0.0, 1.0, 0.0); gluQuadricDrawStyle(quadric, GLU_FILL); gluQuadricOrientation(quadric, GLU_INSIDE); if (alpha > 0) { glPushMatrix(); glDisable(GL_LIGHTING); glTranslatef(0, 0.9, 0); sm->draw(0.05); glEnable(GL_LIGHTING); glPopMatrix(); } glColor3f(0.7, 0.7, 0.7); float high_shininess[] = {500.0f * alpha}; glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); drawCylinder(0.1, 0.1, 2.5, 75, 75); //left exhaust //glColor3f(1,0,0); glRotatef (-90.0 , 0.0, 1.0, 0.0); glTranslatef(0.0, 0.0, 0.6); glRotatef (90.0 , 0.0, 1.0, 0.0); //glRotatef (90.0 , 0.0, 1.0, 0.0); if (alpha > 0) { glPushMatrix(); glDisable(GL_LIGHTING); glTranslatef(0, 0.9, 0); sm->draw(0.05); glEnable(GL_LIGHTING); glPopMatrix(); } glColor3f(0.7, 0.7, 0.7); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); drawCylinder(0.1, 0.1, 2.5, 75, 75);//right exhaust glRotatef (90.0 , 0.0, 1.0, 0.0); glColor3f(1,0,1); glTranslatef(-0.50, 0, 0); drawCylinder(0.075, 0.075, 0.6, 75, 75); glTranslatef(-2.0, 0, 0); drawCylinder(0.075, 0.075, 0.6, 75, 75); glPopMatrix(); }
void drawChairClassica (float tamanho, int n_vertices, int n_camadas) { float altura_assento = 0.05*tamanho ; float comprimento_assento = 0.6*tamanho ; float largura_assento = 0.6*tamanho ; float altura_pe = 0.4*tamanho ; float raio_pe = 0.03*tamanho ; float altura_encosto = 0.6*tamanho ; float largura_encosto = 0.05*tamanho ; float inclinacao_encosto = 0 ; /* Desenhar o assento da cadeira na origem */ glPushMatrix() ; drawParalelepipedo(altura_assento, largura_assento, comprimento_assento, n_camadas) ; glPopMatrix() ; /* Desenhar os quatro pés */ /* Pé 1 */ glPushMatrix() ; glTranslatef(-comprimento_assento/2+raio_pe, -altura_assento/2 - altura_pe/2, largura_assento/2-raio_pe) ; glRotatef(45, 0, 1, 0) ; drawCylinder(raio_pe, altura_pe, n_vertices, n_camadas) ; glPopMatrix() ; /* Pé 2 */ glPushMatrix() ; glTranslatef(comprimento_assento/2-raio_pe, -altura_assento/2 - altura_pe/2, largura_assento/2-raio_pe) ; glRotatef(45, 0, 1, 0) ; drawCylinder(raio_pe, altura_pe, n_vertices, n_camadas) ; glPopMatrix() ; /* Pé 3 */ glPushMatrix() ; glTranslatef(comprimento_assento/2-raio_pe, -altura_assento/2 - altura_pe/2, -largura_assento/2+raio_pe) ; glRotatef(45, 0, 1, 0) ; drawCylinder(raio_pe, altura_pe, n_vertices, n_camadas) ; glPopMatrix() ; /* Pé 4 */ glPushMatrix() ; glTranslatef(-comprimento_assento/2+raio_pe, -altura_assento/2 - altura_pe/2, -largura_assento/2+raio_pe) ; glRotatef(45, 0, 1, 0) ; drawCylinder(raio_pe, altura_pe, n_vertices, n_camadas) ; glPopMatrix() ; /* Desenhar o encosto */ glPushMatrix() ; glTranslatef(-comprimento_assento/2 + largura_encosto/2, altura_assento/2 + altura_encosto/2, 0) ; glRotatef(90, 0, 0, 1) ; glRotatef(inclinacao_encosto, 0, 0, 1) ; drawParalelepipedo(largura_encosto, comprimento_assento, altura_encosto, n_camadas) ; glPopMatrix() ; }
void Gl1_ChainedCylinder::go(const shared_ptr<Shape>& cm, const shared_ptr<State>& state,bool wire2, const GLViewInfo&) { Real r=(static_cast<ChainedCylinder*>(cm.get()))->radius; Real length=(static_cast<ChainedCylinder*>(cm.get()))->length; Quaternionr shift;// = (static_cast<ChainedCylinder*>(cm.get()))->chainedOrientation; shift.setFromTwoVectors(Vector3r::UnitZ(),state->ori.conjugate()*(static_cast<ChainedCylinder*>(cm.get()))->segment); glColor3v(cm->color); if(glutNormalize) glPushAttrib(GL_NORMALIZE); if (wire || wire2) drawCylinder(true, r,length,shift); else drawCylinder(false, r,length,shift); if(glutNormalize) glPopAttrib(); return; }
void Gl1_Cylinder::go(const shared_ptr<Shape>& cm, const shared_ptr<State>& ,bool wire2, const GLViewInfo&) { Real r=(static_cast<Cylinder*>(cm.get()))->radius; Real length=(static_cast<Cylinder*>(cm.get()))->length; //glMaterialv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, Vector3f(cm->color[0],cm->color[1],cm->color[2])); glColor3v(cm->color); if(glutNormalize) glPushAttrib(GL_NORMALIZE); // glPushMatrix(); Quaternionr shift = (static_cast<ChainedCylinder*>(cm.get()))->chainedOrientation; if (wire || wire2) drawCylinder(true, r,length,shift); else drawCylinder(false, r,length,shift); if(glutNormalize) glPopAttrib(); // glPopMatrix(); return; }
void SampleModel::drawLeftFoot() { if (animate) { glRotated(-animLowerLegAngle, 1.0, 0, 0); SETVAL(LEFTKNEE,0); } // Undo Transformations glTranslated(0, 0, 0.7); glRotated(-90, 1.0, 0.0, 0.0); glRotated(-VAL(LEFTKNEE) * 2, 1.0, 0.0, 0.0); glTranslated(0.9, UPPER_TORSO_RADIUS + LOWER_TORSO_HEIGHT + 0.7 + 0.7 + 0.7, 0); glTranslated(-0.9 - 0.2, -UPPER_TORSO_RADIUS - LOWER_TORSO_HEIGHT - 0.7 - 0.7 - 1.3, 0.4); glTranslated(0, 0, -VAL(LEFTKNEE) / 50); glRotated(30, 0.0, -1.0, 0.0); glTranslated(0, 0, -0.3); if (animate) glRotated(animLeftFootAngle, 1.0, 0, 0); if (VAL(TEXTURESKIN)) drawTextureCylinder(0.6, 0.25, 0.1); else drawCylinder(0.6, 0.25, 0.1); glPopMatrix(); }
void SampleModel::drawUpperLeftLeg() { glPushMatrix(); glTranslated(-0.9, -UPPER_TORSO_RADIUS - LOWER_TORSO_HEIGHT, 0); glRotated(VAL(LEFTKNEE), -1.0, 0.0, 0.0); glRotated(VAL(LEFTLEGX), -1.0, 0, 0); glRotated(VAL(LEFTLEGZ), 0.0, 0, 1.0); if (animate){ glRotated(animUpperLegAngle, 1.0, 0, 0); SETVAL(LEFTKNEE, 0); SETVAL(LEFTLEGX, 0); SETVAL(LEFTLEGZ, 0); } glTranslated(0, -0.7, 0); glRotated(90, 1.0, 0.0, 0.0); glTranslated(0, 0, -0.6); if (VAL(TEXTURESKIN)) { drawTextureCylinder(1.2, 0.35, 0.35); glTranslated(0, 0, 1.25); drawTextureSphere(0.3); } else { drawCylinder(1.2, 0.35, 0.35); glTranslated(0, 0, 1.25); drawSphere(0.3); } }
// Drawing a single tree void drawTree(double heightScale, double widthScale, double xLoc, double yLoc, double zLoc) { ErrCheck("Before drawTree"); glPushMatrix(); //Everything is rotated, so it is weird coordinates glTranslated(xLoc, yLoc, zLoc); //Make sure everything is the right height glScaled(widthScale, widthScale, heightScale); //Draw Cylinder; double trunkWidth= (rand()%40+80)/1000.0; //Gets a tree trunk around .1 double treeHeight = (rand()%30+100)/115.0; //gets a tree height around 1 //glTranslated(0, 0, treeHeight); //Brings the bottom of the tree to zero //Rotate the tree so they don't all look the same glRotated(rand()%360,0,0,1); double treeColor[] = {210.0/255, 105.0/255, 30.0/255}; drawCylinder(trunkWidth, treeHeight, treeColor, treeTexture, logEndTexture, true); double currentAngle = 0; glTranslated(0, 0, treeHeight*1.05); //Moves just above the cylinder double thisLeafAngle; double leafScaleX; double leafScaleY; double leafScaleZ; setupLeaf(); int escape = 0; while(currentAngle < 720) //Draws three things of leaves { glPushMatrix(); if(currentAngle > 360) { glTranslated(0, 0, .05); } thisLeafAngle = (rand()%20+40);//Gets an angle between 20 and 40 leafScaleX = (rand()%10+90)/120.0; //Changes size a little bit leafScaleY = (rand()%10+90)/120.0; //Changes size a little bit leafScaleZ = (rand()%20+95)/100.0; //Changes size a little bit glScaled(leafScaleX, leafScaleY , -leafScaleZ); glRotated(currentAngle, 0, 0, 1); glRotated(-(rand()%6+27), 0, 1, 0); //random angle for the pitch glRotated(-(rand()%5-2.5), 1, 0, 0); //Rotates the leaf a bit drawLeafArray(); glPopMatrix(); currentAngle += thisLeafAngle; escape++; if (escape > 25) { // Make sure we don't get stuck break; } } teardownLeaf(); glPopMatrix(); ErrCheck("In drawTree"); }
void PatBike::drawTrailerHitch() { glPushMatrix(); glTranslatef(-3.2, 0.45, 0); glRotatef(-5,0,0,1); glPushMatrix();//WHeels glTranslatef(-1.25, -0.58, -0.7); glPushMatrix(); drawTire(12); glPopMatrix(); glTranslatef(0,0,1.4); glPushMatrix(); drawTire(12); glPopMatrix(); glTranslatef(0,0,-1.6); glColor3f(0.31,0.1,1.0);//Rear Axl drawCylinder(0.075, 0.075, 1.8, 75, 75); glRotatef(180,0,1,0); glutSolidCone(0.075, 0.1, 25, 25); glRotatef(-180,0,1,0); glTranslatef(0,0,1.8); glutSolidCone(0.075, 0.1, 25, 25); glPopMatrix(); glScalef(0.9,0.7,0.7); //glRotatef(180, 1, 0, 0); glColor3f(0.39,0.1,0.1); applyColor(); glutSolidTeapot(1.0); //front of hitch glTranslatef(-0.9, 0.25, 0); glScalef(1.9,0.7,1); glScalef(1,1.5,1); gluSphere( quadric, 1,70,70); setMaterial(); glPopMatrix(); }
void ArmGLWidget::drawCylinderY(float radius, float length) { glPushMatrix(); glRotatef(90, 1, 0, 0); drawCylinder(radius, length); glPopMatrix(); }
void drawLoveHeart() { model_view*=Translate(0,-.5,0); mvstack.push(model_view); mvstack.push(model_view); model_view*=Translate(-.21,.5,1); model_view*=Scale(.3,.3,.1); drawCylinder(); model_view*=Translate(1.45,0,0); drawCylinder(); model_view = mvstack.pop(); model_view*=Translate(0,0,1); model_view*=RotateZ(180); drawGcube(); model_view = mvstack.pop(); }
void GFXDrawUtil::drawArrow( const GFXStateBlockDesc &desc, const Point3F &start, const Point3F &end, const ColorI &color ) { GFXTransformSaver saver; // Direction and length of the arrow. VectorF dir = end - start; F32 len = dir.len(); dir.normalize(); len *= 0.2f; // Base of the cone will be a distance back from the end of the arrow // proportional to the total distance of the arrow... 0.3f looks about right. Point3F coneBase = end - dir * len * 0.3f; // Calculate the radius of the cone given that we want the cone to have // an angle of 25 degrees (just because it looks good). F32 coneLen = ( end - coneBase ).len(); F32 coneDiameter = mTan( mDegToRad(25.0f) ) * coneLen; // Draw the cone on at the arrow's tip. drawCone( desc, coneBase, end, coneDiameter / 2.0f, color ); // Get the difference in length from // the start of the cone to the end // of the cylinder so we can put the // end of the cylinder right against where // the cone starts. Point3F coneDiff = end - coneBase; // Draw the cylinder. F32 stickRadius = len * 0.025f; drawCylinder( desc, start, end - coneDiff, stickRadius, color ); }
void drawSkeleton() { if (materialsMode) { glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_red); } int i, j, k; for(i = 0; i < NV; i++) { glPushMatrix(); glTranslatef(vertexes[i][0], vertexes[i][1], vertexes[i][2]); glutSolidSphere(0.2, 32, 16); glPopMatrix(); } float center[3]; float difference[3]; if (materialsMode) { glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_green); } float cylinder[3] = {0, 1, 0}; float zero[3] = {0, 0, 0}; for(i = 0; i < NV; i++) { for (j = 0; j < 4; j++) { int j2 = j < 3 ? j + 1 : 0; float distance = 0; for (k = 0; k < 3; k++) { difference[k] = vertexes[faces[i][j]][k] - vertexes[faces[i][j2]][k]; distance += difference[k] * difference[k]; center[k] = (vertexes[faces[i][j]][k] + vertexes[faces[i][j2]][k]) / 2; } glPushMatrix(); glTranslatef(center[0], center[1], center[2]); /* Normalizing */ difference[0] /= sqrt(distance); difference[1] /= sqrt(distance); difference[2] /= sqrt(distance); float nx, ny, nz; float normal[3]; CalculateVectorNormal(zero, cylinder, difference, &nx, &ny, &nz); normal[0] = nx; normal[1] = ny; normal[2] = nz; float angle = DEG(getAngle(cylinder, difference)); rotateBy(normal, angle); drawCylinder(0.05, sqrt(distance), 64); glPopMatrix(); } } if (materialsMode) { glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_gray); } }
static void display() { // Position Vertex vert pos; replaceVert(&pos, 0, 0, 0); // Erase the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Enable Z-buffering in OpenGL glEnable(GL_DEPTH_TEST); // Undo previous transformations glLoadIdentity(); // Switch to manipulating the model matrix glMatrixMode(GL_MODELVIEW); // Undo previous transformations glLoadIdentity(); // User Rotation glRotatef(xrot, 1, 0, 0); glRotatef(yrot, 0, 1, 0); // Main Room drawRoom(); glColor3f(1,1,1); // Draw Cylinder glPushMatrix(); replaceVert(&pos, 0, 1.75, 0); drawCylinder(0.125, 1.5, pos, cyl_verts); glPopMatrix(); // Draw Box Method (Coordinates used as verts) replaceVert(&pos, -1.25, -1.25, 0); drawBox(1, 1, 2.5, pos); replaceVert(&pos, 1.25, 0, -2); drawBox(1, 2.5, 0.125, pos); glPushMatrix(); // Draw Box Method, Translation glTranslatef(2, -2, 1.5); replaceVert(&pos, 0, 0, 0); drawBox(1, 1, 1, pos); glPopMatrix(); glColor3f(1, 1, 1); glWindowPos2i(5, 5); Print("Xrot: %.4f Yrot: %.4f", xrot, yrot); glFlush(); glutSwapBuffers(); }
void mDisplay(void){ glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); // Setting fill color glLoadIdentity(); if(DRAW_CYLINDER) drawCylinder(); else drawSphere(); glFlush(); glutSwapBuffers(); }
/********************************************************* ********************************************************** ********************************************************** PROC: display() DOES: this gets called by the event handler to draw the scene, so this is where you need to build your ROBOT -- MAKE YOUR CHANGES AND ADDITIONS HERE Add other procedures if you like. ********************************************************** ********************************************************** **********************************************************/ void display(void) { // Clear the screen with the background colour (set in myinit) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); model_view = mat4(1.0f); model_view *= Translate(0.0f, 0.0f, -15.0f); HMatrix r; Ball_Value(Arcball,r); mat4 mat_arcball_rot( r[0][0], r[0][1], r[0][2], r[0][3], r[1][0], r[1][1], r[1][2], r[1][3], r[2][0], r[2][1], r[2][2], r[2][3], r[3][0], r[3][1], r[3][2], r[3][3]); model_view *= mat_arcball_rot; mat4 view = model_view; //model_view = Angel::LookAt(eye, ref, up);//just the view matrix; glUniformMatrix4fv( uView, 1, GL_TRUE, model_view ); // Previously glScalef(Zoom, Zoom, Zoom); model_view *= Scale(Zoom); // Draw Something set_colour(0.8f, 0.8f, 0.8f); drawSphere(); // Previously glTranslatef(3,0,0); model_view *= Translate(3.0f, 0.0f, 0.0f); // Previously glScalef(3,3,3); model_view *= Scale(3.0f, 3.0f, 3.0f); drawCube(); // And extra shapes! model_view *= Scale(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f); model_view *= Translate(3.0f, 0.0f, 0.0f); set_colour(1.0f, 1.0f, 0.0f); drawCone(); model_view *= Translate(-9.0f, 0.0f, 0.0f); set_colour(1.0f, 1.0f, 1.0f); drawCylinder(); glutSwapBuffers(); if(Recording == 1) FrSaver.DumpPPM(Width, Height) ; }
// rot: rotation around the z-axis void drawStreetLight(float x, float y, float z, float rot){ glPushMatrix(); glTranslatef(x, y, z); glRotatef(rot, 0, 0, 1); //glColor3b(77, 40, 0); drawCylinder(0, 0, 0, streetLightThickness, streetLightHeight); glTranslatef(0, 0, streetLightHeight - streetLightThickness); glRotatef(90.0f - streetLightTheta, 0, 1, 0); for(int i = 0; i < 3; i++){ drawCylinder(0, 0, 0, streetLightThickness, streetLightBranchLength); glTranslatef(0, 0, streetLightBranchLength); glRotatef(streetLightTheta, 0, 1, 0); //drawCylinder(0, 0, 0, streetLightThickness, streetLightBranchLength); } glRotatef(-1 * (streetLightTheta * 2 + 90), 0, 1, 0); drawConalCylinder(0, 0, -.25 * streetLightLampHeight, streetLightLampBottomRadius, streetLightLampTopRadius, streetLightLampTopRadius); placeLight(); glPopMatrix(); }
/* * Display the scene */ void display() { // Clear the image glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Reset previous transforms glLoadIdentity(); // Set view angle glRotated(ph,1,0,0); glRotated(th,0,1,0); glEnable(GL_DEPTH_TEST); //Enable z buffering /* Draw 4 Clyinders */ drawCylinder(0, 0, 0, 1, 1, 1, 0, 'r', 'b'); drawCylinder(.5, .5, .5, 1, 3, 1, 20, 'b', 'q'); drawCylinder(-.9, 0, 0, 2, 2, 1, 90, 'w', 'g'); drawCylinder(-.6, -.6, -.8, .3, .5, .3, -45, 'g', 'r'); // Draw axes in white glColor3f(1,1,1); glBegin(GL_LINES); glVertex3d(0,0,0); glVertex3d(1,0,0); glVertex3d(0,0,0); glVertex3d(0,1,0); glVertex3d(0,0,0); glVertex3d(0,0,1); glEnd(); // Label axes glRasterPos3d(1,0,0); Print("X"); glRasterPos3d(0,1,0); Print("Y"); glRasterPos3d(0,0,1); Print("Z"); // Display parameters glWindowPos2i(5,5); Print("View Angle=%d,%d",th,ph); // Flush and swap glFlush(); glutSwapBuffers(); }
void SampleModel::drawRightLegJoint() { glPushMatrix(); glTranslated(0.5, -UPPER_TORSO_RADIUS - 0.4, 0); glRotated(48, 0.0, 0.0, 1.0); glRotated(90, 1.0, 0.0, 0.0); glTranslated(0, 0, -0.3); if (VAL(TEXTURESKIN)) drawTextureCylinder(0.7, 0.2, 0.2); else drawCylinder(0.7, 0.2, 0.2); glPopMatrix(); }
void SampleModel::drawLowerTorso() { glPushMatrix(); glTranslated(0, -UPPER_TORSO_RADIUS, 0); // move down glRotated(90, 1.0, 0.0, 0.0); glTranslated(0, 0, -0.4); if (VAL(TEXTURESKIN)) drawTextureCylinder(LOWER_TORSO_HEIGHT, 0.9, 0.8); else drawCylinder(LOWER_TORSO_HEIGHT, 0.9, 0.8); glPopMatrix(); }
void Needle::draw() { glColor3f(color0, color1, color2); int obj_ind; for (obj_ind = 0; obj_ind<i_objs.size(); obj_ind++) { drawCylinder(i_objs[obj_ind]->_start_pos, i_objs[obj_ind]->_end_pos, i_objs[obj_ind]->_radius); drawSphere(i_objs[obj_ind]->_start_pos, i_objs[obj_ind]->_radius); } drawSphere(i_objs[obj_ind-1]->_end_pos, i_objs[obj_ind-1]->_radius); glColor3f(1,0,0); drawSphere(i_objs[0]->_start_pos, i_objs[0]->_radius); }
void POVPainter::drawMultiCylinder (const Vector3d &end1, const Vector3d &end2, double radius, int order, double) { // Just render single bonds with the standard drawCylinder function if (order == 1) { drawCylinder(end1, end2, radius); return; } // Find the bond axis Vector3d axis = end2 - end1; double axisNorm = axis.norm(); if( axisNorm < 1.0e-5 ) return; Vector3d axisNormalized = axis / axisNorm; // Use the plane normal vector for the molecule to draw multicylinders along Vector3d ortho1 = axisNormalized.cross(d->planeNormalVector); double ortho1Norm = ortho1.norm(); if( ortho1Norm > 0.001 ) ortho1 /= ortho1Norm; else ortho1 = axisNormalized.unitOrthogonal(); // This number seems to work well for drawing the multiCylinder inside ortho1 *= radius*1.5; Vector3d ortho2 = axisNormalized.cross(ortho1); // Use an angle offset of zero for double bonds, 90 for triple and 22.5 for higher order double angleOffset = 0.0; if( order >= 3 ) { if( order == 3 ) angleOffset = 90.0; else angleOffset = 22.5; } // Actually draw the cylinders for( int i = 0; i < order; i++) { double alpha = angleOffset / 180.0 * M_PI + 2.0 * M_PI * i / order; Vector3d displacement = cos(alpha) * ortho1 + sin(alpha) * ortho2; Vector3d displacedEnd1 = end1 + displacement; Vector3d displacedEnd2 = end2 + displacement; // Write out a POVRay cylinder for rendering *(d->output) << "cylinder {\n" << "\t<" << displacedEnd1.x() << ", " << displacedEnd1.y() << ", " << displacedEnd1.z() << ">, " << "\t<" << displacedEnd2.x() << ", " << displacedEnd2.y() << ", " << displacedEnd2.z() << ">, " << radius << "\n\tpigment { rgbt <" << d->color.red() << ", " << d->color.green() << ", " << d->color.blue() << ", " << 1.0 - d->color.alpha() << "> }\n}\n"; } }
void SampleModel::drawUpperLeftHand() { glPushMatrix(); glTranslated(-UPPER_TORSO_RADIUS - 0.2, 0.8, 0); glRotated(VAL(LEFTARMZ), 0, 0, 1.0); glRotated(VAL(LEFTARMY), 0, 1.0, 0); glTranslated(-0.3, -0.6, 0); glRotated(20, 0.0, 0.0, -1.0); glRotated(90, 1.0, 0.0, 0.0); glTranslated(0, 0, -0.5); glRotated(VAL(LEFTARMX), 1.0, 0, 0); if (VAL(TEXTURESKIN)) drawTextureCylinder(1, 0.25, 0.25); else drawCylinder(1, 0.25, 0.25); }
void drawWiskyBottle(double alt, int nlados, int ncamadas) { glPushMatrix(); glRotatef(45, 0, 1, 0); glTranslatef(0, ((2*alt)/9), 0); drawParalelepipedo((2*alt)/3 - alt/10, alt/5-alt/40,alt/5-alt/40, nlados); glPopMatrix(); glPushMatrix(); glTranslatef(0, (2*alt)/3 - alt/6, 0); drawWiskyBottle_top(alt/8, alt/6, nlados, 4); glPopMatrix(); glPushMatrix(); glTranslatef(0, (2*alt)/3 , 0); drawCylinder(alt/26, alt/5, nlados/2, ncamadas/2); glPopMatrix(); glPushMatrix(); glTranslatef(0, (2*alt)/3 + alt/12, 0); drawCylinder(alt/23, alt/50, nlados/2, ncamadas/3); glPopMatrix(); }
void Qualitative::paintGL() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity(); // light sources glLightfv(GL_LIGHT0, GL_POSITION, qlight1_pos); Point3D b1, b2; // test tubes glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, qglass); glMaterialfv(GL_FRONT, GL_SPECULAR, qglwhite); glMaterialfv(GL_FRONT, GL_SHININESS, qglpolished); b1.setXYZ(-3.0,-1.0,-10.0); b2.setXYZ(-3.0,4.0,-10.0); drawCylinder(b1,b2,0.75); b1.setXYZ(0.0,-1.0,-10.0); b2.setXYZ(0.0,4.0,-10.0); drawCylinder(b1,b2,0.75); b1.setXYZ(3.0,-1.0,-10.0); b2.setXYZ(3.0,4.0,-10.0); drawCylinder(b1,b2,0.75); }
void base(float h) { setDiffuseColor( 0.25, 0.25, 0.25 ); setAmbientColor( 0.25, 0.25, 0.25 ); glPushMatrix(); glPushMatrix(); glTranslatef(1.0, h / 2.0, 0.75); drawCylinder(0.25, h / 2.0, h / 2.0); glPopMatrix(); glPushMatrix(); glTranslatef(1.0, h / 2.0, -1.0); drawCylinder(0.25, h / 2.0, h / 2.0); glPopMatrix(); glPushMatrix(); glTranslatef(-1.0, h / 2.0, 0.75); drawCylinder(0.25, h / 2.0, h / 2.0); glPopMatrix(); glPushMatrix(); glTranslatef(-1.0, h / 2.0, -1.0); drawCylinder(0.25, h / 2.0, h / 2.0); glPopMatrix(); glScalef(4.0f, h, 4.0f); y_box(1.0f); glPopMatrix(); }
void PatBike::drawFrontFrame() { glColor3f(0.7, 0.7, 0.7); float high_shininess[] = {500.0f * alpha}; glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glPushMatrix(); glTranslatef(0.0, 0.0, -0.3); drawCylinder(0.07, 0.07, 0.6, 75, 75);//bearing in front glPopMatrix(); glPushMatrix(); glTranslatef(0.0, 0.0, 0.30); glRotatef (20.0 , 0.0, 0.0, 1.0); glRotatef (-90.0 , 1.0, 0.0, 0.0); drawCylinder(0.09, 0.09, 1.25, 75, 75); glPopMatrix(); glPushMatrix(); glTranslatef(0.0, 0.0, -0.30); glRotatef (20.0 , 0.0, 0.0, 1.0); glRotatef (-90.0 , 1.0, 0.0, 0.0); drawCylinder(0.09, 0.09, 1.25, 75, 75); glPopMatrix(); glPushMatrix(); glColor3d(1,0,0); glTranslatef(-0.1, 0.70, 0); glRotatef(7, 0, 0, 1); glScalef(0.55,0.2,0.25); //tm->BindTextureByIndex(4, quadric); applyColor(); gluSphere( quadric, 1,70,70); setMaterial(); glDisable(GL_TEXTURE_2D); glDisable(GL_CULL_FACE); //glutSolidSphere(1,20,20); glPopMatrix(); }
//-------------------------------------------------------------- void ofxBulletCylinder::draw() { if(!_bCreated || _rigidBody == NULL) { ofLog(OF_LOG_WARNING, "ofxBulletCylinder :: draw : must call create() first and add() after"); return; } int upAxis = ((btCylinderShape*)_rigidBody->getCollisionShape())->getUpAxis(); float halfHeight = ((btCylinderShape*)_rigidBody->getCollisionShape())->getHalfExtentsWithMargin()[upAxis]; btScalar m[16]; ofGetOpenGLMatrixFromRigidBody( _rigidBody, m ); glPushMatrix(); glMultMatrixf( m ); drawCylinder( getRadius(), halfHeight, upAxis ); glPopMatrix(); }
void drawSaber(float r, float g, float b) { mvstack.push(model_view); set_colour(.3, .3, .4); model_view *= Scale(0.5, 2, 0.5); model_view *= RotateX(90); drawCylinder(); model_view = mvstack.pop(); mvstack.push(model_view); set_colour(.9, 0, 0); model_view *= Translate(0,.4,.5); model_view *= Scale(.15, .15, .15); drawCylinder(); model_view = mvstack.pop(); if (TIME >= 10) { mvstack.push(model_view); model_view *= Translate(0, 7, 0); drawBlade(r, g, b); model_view = mvstack.pop(); } }
void drawPineTree(void) { mvstack.push(model_view); mvstack.push(model_view); model_view *= Translate(0.0,19.0,0.0); model_view *= Scale(5.0,7.0,5.0); model_view *= RotateX(90); set_colour(0.0,0.8,0.3); drawCone(); model_view = mvstack.pop(); set_colour(.5,.5,.2); model_view *= Scale(1.0,13.0,1.0); model_view *= RotateX(90); drawCylinder(); model_view = mvstack.pop(); }