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 ArrowGeometry::render(const Camera& camera) { if (m_vertices.empty()) return; // Prepare the shader program if necessary. update(); if (!d->program.bind()) cout << d->program.error() << endl; // Set up our uniforms (model-view and projection matrices right now). if (!d->program.setUniformValue("modelView", camera.modelView().matrix())) { cout << d->program.error() << endl; } if (!d->program.setUniformValue("projection", camera.projection().matrix())) { cout << d->program.error() << endl; } // Render the arrows using the shader. for (unsigned int startIndex = 0; startIndex < m_vertices.size(); ++startIndex) { Vector3f v3 = m_vertices[startIndex].first + 0.8 * (m_vertices[startIndex].second - m_vertices[startIndex].first); drawLine(m_vertices[startIndex].first, v3, 2); drawCone(v3, m_vertices[startIndex].second, 0.05, 1.0); } d->program.release(); }
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 drawBouquet(float r, float g, float b) { mvstack.push(model_view); model_view *= RotateX(-90); set_colour(r,g,b); drawCone(); model_view *= RotateX(90); model_view *= Translate(0.0f, 2.0f, 0.0f); drawFlower(); mvstack.push(model_view); model_view *= RotateZ(25); model_view *= Translate(-1.0f, 0.25f, 0.0f); drawFlower(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= RotateZ(-25); model_view *= Translate(1.0f, 0.25f, 0.0f); drawFlower(); model_view = mvstack.pop(); model_view = mvstack.pop(); }
/********************************************************* ********************************************************** ********************************************************** 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) ; }
void ObstacleWheelBH::draw() const { DECLARE_DEBUG_DRAWING("representation:ObstacleWheelBH:wheel", "drawingOnField"); for(const Cone& cone : cones) { drawCone(cone); } CIRCLE("representation:ObstacleWheelBH:wheel", 0, 0, wheelRadius, 1, Drawings::ps_solid, ColorClasses::black, Drawings::bs_null, ColorClasses::black); }
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(); }
void drawQuaternion(){ float colorA0[]={0,0,0,0}; float colorD0[]={1,0,0,1}; float colorS0[]={1,0,0,1}; Vector normW=quaternionW*(1/quaternionW.Length()); Vector v=Vector(0,0,1); Vector normal=normW%v; float cosin=normW*v; float fi=acos(cosin)*180/M_PI; float length=fabs(quaternionS)*4.0/cos(M_PI/4); glPushMatrix(); glMaterialfv(GL_FRONT,GL_AMBIENT,colorA0); glMaterialfv(GL_FRONT,GL_DIFFUSE,colorD0); glMaterialfv(GL_FRONT, GL_SPECULAR, colorS0); glMaterialf(GL_FRONT,GL_SHININESS,50); glTranslatef(heliPos.x,heliPos.y,heliPos.z); glRotatef(-fi,normal.x,normal.y,normal.z); drawCylinder(0.1f,length*5.0f/6.0f,20,20); glTranslatef(0.0f,0.0f,length*5.0f/6.0f); drawCone(0.2f,length/6.0f,20,20); glPopMatrix(); }
void drawHead2(void) { //head mvstack.push(model_view); set_colour(.95, .9, .75); drawSphere(); model_view = mvstack.pop(); //hat mvstack.push(model_view); set_colour(.1, .1, .1); model_view *= Translate (0, 1.5, 0); model_view *= RotateX(90); drawCone(); model_view = mvstack.pop(); //stache mvstack.push(model_view); set_colour(.1,.1,.1); model_view *= Translate (0, -.25, 1); model_view *= Scale(.2, .1, .05); drawCube(); model_view = mvstack.pop(); //eyes mvstack.push(model_view); set_colour(.1,.1,.1); model_view *= Translate(-.27, .3, .7); model_view *= Scale(.2, .2, .2); drawSphere(); model_view = mvstack.pop(); mvstack.push(model_view); set_colour(.1,.1,.1); model_view *= Translate(.27, .3, .7); model_view *= Scale(.2, .2, .2); drawSphere(); model_view = mvstack.pop(); }
void TranslateCommand::drawTransArrows(bool sel) { glPushMatrix(); //glLoadIdentity(); glTranslated(0.5*(m_selMinP.x+m_selMaxP.x), 0.5*(m_selMinP.y+m_selMaxP.y), 0.5*(m_selMinP.z+m_selMaxP.z)); float black[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; if (!sel) { glEnable(GL_CULL_FACE); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black); } GLUquadricObj *obj = gluNewQuadric(); float grid_sz = m_app->GetViewPort()->GetGridSize()*0.5f; glLoadName(TRANSLATION_X); glDisable(GL_LIGHTING); glBegin(GL_LINES); if (!sel) glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(grid_sz,0.0f,0.0f); glEnd(); if (!sel) glEnable(GL_LIGHTING); drawCone(obj, 1.0f, 0.0f, 0.0f,grid_sz); glLoadName(TRANSLATION_Y); glDisable(GL_LIGHTING); glBegin(GL_LINES); if (!sel) glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(0.0f, grid_sz,0.0f); glEnd(); if (!sel) glEnable(GL_LIGHTING); drawCone(obj, 0.0f, 1.0f, 0.0f,grid_sz); glLoadName(TRANSLATION_Z); glDisable(GL_LIGHTING); glBegin(GL_LINES); if (!sel) glColor3f(0.0f, 0.0f, 1.0f); glVertex3f(0.0f,0.0f,0.0f); glVertex3f(0.0f, 0.0f, grid_sz); glEnd(); if (!sel) glEnable(GL_LIGHTING); drawCone(obj, 0.0f, 0.0f, 1.0f,grid_sz); gluDeleteQuadric(obj); if (!sel) glDisable(GL_CULL_FACE); glPopMatrix(); }
void drawFemale(float r, float g, float b) { mvstack.push(model_view); model_view *= Translate(0.0f, 1.4f, 0.0f); // Draw Head mvstack.push(model_view); if(timeline > 21.0f && timeline < 24.0f) model_view *= RotateY(-temp2); if(timeline >= 24.0f && (-45+(temp2-45)*2) < 0) model_view *= RotateY(-45+(temp2-45)*2); if(timeline > 35.0 && timeline < 37.0f) { model_view *= RotateY(45-(temp2-230)*5); prevY = 45-(temp2-230)*5; } if(timeline > 37.0f && timeline < 38.0f) model_view *= RotateY(prevY); if(timeline > 38.0f && prevY+(temp2-255) < 0) model_view *= RotateY(prevY+(temp2-255)); drawBFMHearts(); set_colour(r, g, b); drawSphere(); set_colour(0.0f, 0.0f, 0.0f); model_view *= Translate(0.5f, 0.0f, 0.75f); model_view *= Scale(0.25f, 0.25f, 0.25f); drawSphere(); model_view *= Translate(-4.0f, 0.0f, 0.0f); drawSphere(); model_view = mvstack.pop(); set_colour(r, g, b); model_view *= Translate(0.0f, -2.0f, 0.0f); model_view*=RotateX(90); model_view *= Scale(1.0f, 1.0f, 1.1f); drawCylinder(); model_view = mvstack.pop(); //Draw Arms mvstack.push(model_view); mvstack.push(model_view); model_view *= Translate(1.25f, 0.0f, 0.0f); if(timeline>40) model_view*=RotateY(-60); model_view*=RotateY(-90); model_view*=Scale(.3,.3,.7); drawCylinder(); model_view = mvstack.pop(); model_view *= Translate(-2.5+1.25f, 0.0f, 0.0f); if(timeline>40) model_view*=RotateY(60); model_view*=RotateY(90); model_view*=Scale(.3,.3,.7); drawCylinder(); model_view = mvstack.pop(); //Draw Legs if(timeline < 13.5f || (timeline > 40.0f && timeline < 53.75)) { model_view *= Translate(0.5f, -2.0f, 0.0f); mvstack.push(model_view); model_view *= Translate(-0.5f, 1.0f, 0.0f); model_view*=Scale(2,1,2); model_view*=RotateX(90); drawCone(); model_view = mvstack.pop(); mvstack.push(model_view); model_view *= RotateX(moveLegs); model_view *= RotateX(-90); model_view*=Scale(.3,.3,1.0); drawCylinder(); model_view = mvstack.pop(); model_view *= Translate(-1.0f, 0.0f, 0.0f); mvstack.push(model_view); model_view *= RotateX(-moveLegs); model_view *= RotateX(90); model_view*=Scale(.3,.3,1.0); drawCylinder(); model_view = mvstack.pop(); } if(timeline > 13.5 && timeline < 40.0 || timeline > 53.75) { mvstack.push(model_view); model_view *= Translate(0.0f, -1.0f, 0.0f); model_view*=Scale(2,1,2); model_view*=RotateX(90); drawCone(); model_view = mvstack.pop(); mvstack.push(model_view); mvstack.push(model_view); model_view *= Translate(0.5f, -2.0+.2f, 1.0f); model_view*=RotateX(30); model_view*=Scale(.3,.3,1.2); drawCylinder(); model_view = mvstack.pop(); model_view *= Translate(-1.0+.5f, 0.0-2.0+.2f, 0.0+1.0f); model_view*=RotateX(30); model_view*=Scale(.3,.3,1.2); drawCylinder(); model_view = mvstack.pop(); } if(timeline > 40) { model_view *= Translate(0.0f, 2.0f, -.3f); mvstack.push(model_view); model_view *= Translate(-.7f, 0.0f, 1.0f); model_view *= RotateX(40); model_view*=Scale(.8,.8,.8); model_view *= RotateY(120); drawBouquet(1,1,1); model_view = mvstack.pop(); } }