Esempio n. 1
0
	glEnable(GL_LIGHTING);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHT0);
	glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse);
	glLightfv(GL_LIGHT0,GL_POSITION,light_position);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

	//glLightModelfv(GL_LIGHT_MODEL_AMBIENT,global_ambient);
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
	glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);
	glEnable(GL_COLOR_MATERIAL);
}

GLUquadricObj* objekt= gluNewQuadric();

void onDraw(void) {
	g_endTime = GetTickCount();
	int diffTime = g_endTime-g_startTime;
	if (diffTime<1000.0/FRAME_RATE) return;
	g_startTime = g_endTime;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glTranslatef(0,0,-5);
	glRotatef(-rotacija_y,1,0,0);
	glRotatef(-rotacija_x,0,1,0);
Esempio n. 2
0
void TransformerBone::drawCylinderBone(float length, float width)
{
	GLUquadricObj *qobj = 0;
	qobj = gluNewQuadric();
	gluCylinder(qobj, width, width, length, 5, 5);
}
Esempio n. 3
0
///////////////////////////////////////////////////////////////////
// Draw the unit axis. A small white sphere represents the origin
// and the three axes are colored Red, Green, and Blue, which 
// corresponds to positive X, Y, and Z respectively. Each axis has
// an arrow on the end, and normals are provided should the axes
// be lit. These are all built using the quadric shapes. For best
// results, put this in a display list.
void gltDrawUnitAxes(void)
	{
	GLUquadricObj *pObj;	// Temporary, used for quadrics
	
	// Measurements
	float fAxisRadius = 0.025f;
	float fAxisHeight = 1.0f;
	float fArrowRadius = 0.06f;
	float fArrowHeight = 0.1f;
	
	// Setup the quadric object
	pObj = gluNewQuadric();
	gluQuadricDrawStyle(pObj, GLU_FILL);
	gluQuadricNormals(pObj, GLU_SMOOTH);
	gluQuadricOrientation(pObj, GLU_OUTSIDE);
	gluQuadricTexture(pObj, GLU_FALSE);
	
	///////////////////////////////////////////////////////
	// Draw the blue Z axis first, with arrowed head
	glColor3f(0.0f, 0.0f, 1.0f);
	gluCylinder(pObj, fAxisRadius, fAxisRadius, fAxisHeight, 10, 1);
	glPushMatrix();
	glTranslatef(0.0f, 0.0f, 1.0f);
	gluCylinder(pObj, fArrowRadius, 0.0f, fArrowHeight, 10, 1);
    glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
    gluDisk(pObj, fAxisRadius, fArrowRadius, 10, 1);
	glPopMatrix();
	
	///////////////////////////////////////////////////////
	// Draw the Red X axis 2nd, with arrowed head
    glColor3f(1.0f, 0.0f, 0.0f);
	glPushMatrix();
	glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
	gluCylinder(pObj, fAxisRadius, fAxisRadius, fAxisHeight, 10, 1);
	glPushMatrix();
	glTranslatef(0.0f, 0.0f, 1.0f);
	gluCylinder(pObj, fArrowRadius, 0.0f, fArrowHeight, 10, 1);
	glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
	gluDisk(pObj, fAxisRadius, fArrowRadius, 10, 1);
	glPopMatrix();
	glPopMatrix();
	
	///////////////////////////////////////////////////////
	// Draw the Green Y axis 3rd, with arrowed head
	glColor3f(0.0f, 1.0f, 0.0f);
	glPushMatrix();
	glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
	gluCylinder(pObj, fAxisRadius, fAxisRadius, fAxisHeight, 10, 1);
	glPushMatrix();
	glTranslatef(0.0f, 0.0f, 1.0f);
	gluCylinder(pObj, fArrowRadius, 0.0f, fArrowHeight, 10, 1);
	glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
	gluDisk(pObj, fAxisRadius, fArrowRadius, 10, 1);
	glPopMatrix();
	glPopMatrix();
	
	////////////////////////////////////////////////////////
	// White Sphere at origin
	glColor3f(1.0f, 1.0f, 1.0f);
	gluSphere(pObj, 0.05f, 15, 15);
	
	// Delete the quadric
	gluDeleteQuadric(pObj);
	}
Esempio n. 4
0
static void initQuadObj(void)
{
    quadObj = gluNewQuadric();
    if (!quadObj)
        PM_fatalError("out of memory.");
}
Esempio n. 5
0
static void LowerLeg(
    char solid)
{
    float k, l;
    GLUquadricObj *ankle = gluNewQuadric();
    GLUquadricObj *ankle_face[2];

#ifdef LIGHT
    SetMaterial(mat_specular, mat_ambient, mat_diffuse, mat_shininess);
#endif
    glColor3f(1.0, 1.0, 0.0);
    for (k = 0.0; k < 2.0; k++) {
        for (l = 0.0; l < 2.0; l++) {
            glPushMatrix();
            glTranslatef(k, 0.0, l);
#ifdef LIGHT
            SetMaterial(mat_specular, mat_ambient, mat_diffuse, mat_shininess);
#endif
            glColor3f(1.0, 1.0, 0.0);
            Box(1.0, 0.5, 1.0, solid);
            glTranslatef(0.0, -0.45, 0.0);
#ifdef LIGHT
            SetMaterial(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2);
#endif
            glColor3f(0.5, 0.5, 0.5);
#ifdef SPHERE
            if (!solid)
                makeWireSphere(0.2, 16, 10);
            else
                makeSolidSphere(0.2, 16, 10);
#endif
            if (leg)
                glRotatef((GLfloat) heel1, 1.0, 0.0, 0.0);
            else
                glRotatef((GLfloat) heel2, 1.0, 0.0, 0.0);
            glTranslatef(0.0, -1.7, 0.0);
#ifdef LIGHT
            SetMaterial(mat_specular, mat_ambient, mat_diffuse, mat_shininess);
#endif
            glColor3f(1.0, 1.0, 0.0);
            Box(0.25, 3.0, 0.25, solid);
            glTranslatef(0.0, -1.7, 0.0);
#ifdef LIGHT
            SetMaterial(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2);
#endif
            glColor3f(0.5, 0.5, 0.5);
#ifdef SPHERE
            if (!solid)
                makeWireSphere(0.2, 16, 10);
            else
                makeSolidSphere(0.2, 16, 10);
#endif
            if (leg)
                glRotatef((GLfloat) - heel1, 1.0, 0.0, 0.0);
            else
                glRotatef((GLfloat) - heel2, 1.0, 0.0, 0.0);
            glTranslatef(0.0, -0.45, 0.0);
#ifdef LIGHT
            SetMaterial(mat_specular, mat_ambient, mat_diffuse, mat_shininess);
#endif
            glColor3f(1.0, 1.0, 0.0);
            Box(1.0, 0.5, 1.0, solid);
            if (!k && !l) {
                int j;

                glTranslatef(-0.4, -0.8, 0.5);
                if (leg)
                    glRotatef((GLfloat) ankle1, 1.0, 0.0, 0.0);
                else
                    glRotatef((GLfloat) ankle2, 1.0, 0.0, 0.0);
                glRotatef(90.0, 0.0, 1.0, 0.0);
                if (!solid)
                    gluQuadricDrawStyle(ankle, GLU_LINE);
                gluCylinder(ankle, 0.8, 0.8, 1.8, 16, 10);
                for (j = 0; j < 2; j++) {
                    ankle_face[j] = gluNewQuadric();
                    if (!solid)
                        gluQuadricDrawStyle(ankle_face[j], GLU_LINE);
                    if (j) {
                        glScalef(-1.0, 1.0, 1.0);
                        glTranslatef(0.0, 0.0, 1.8);
                        }
                    gluDisk(ankle_face[j], 0.0, 0.8, 16, 10);
                    if (j)
                        glTranslatef(0.0, 0.0, -1.8);
                    }
                glScalef(-1.0, 1.0, 1.0);
                glRotatef(-90.0, 0.0, 1.0, 0.0);
                glTranslatef(0.95, -0.8, 0.0);
                glCallList(SOLID_MECH_FOOT);
                }
            glPopMatrix();
            }
        }
}
Esempio n. 6
0
void Robot::draw() {
	if(robotLife > 0){
		//draw bounding box
		glPushMatrix();
			box->draw();
		glPopMatrix();

		//draw robot
		glPushMatrix();
			if (!isRobotBeingControlled){
				if(computerControlled){
					aiSetDestination();
				}
				goToDestination();
			}
		
			//Translate()
			glTranslatef(xPos,0.0f,zPos);
			
			//Spin()
			glTranslatef(0.5f, 0.0f, 0.5f);
			glRotatef(spinDegrees,0.0f,1.0f,0.0f);
			glTranslatef(-0.5f,0.0f,-0.5f);

			//Draw Headlight
			glPushMatrix();
				glTranslatef(0.0f,height-0.25f,0.0f);
				if(isMyLightOn){
					((HeadlightModel*)headlight)->whiteLight = true;
				}
				else{
					((HeadlightModel*)headlight)->whiteLight = false;
				}
				headlight->draw();
			glPopMatrix();

			//Draw Model
			model->draw();
		glPopMatrix();
	}
	else{
		GLUquadricObj *quadric = gluNewQuadric();
		gluQuadricTexture(quadric, true);

		if ((currentTime - lastExplosion) >= 200.0 && explosionSize <= 2.0f)
		{
			explosionSize+=.5f;
			lastExplosion = clock();
			if (explosionSize == 2.5f)
				stop = true;
		}

		if (!stop)
		{
			glPushMatrix();
				glColor3f(1.0f, 0.4f, 0.0f);
				glTranslatef(xPos, 0.0f, zPos);
				gluSphere(quadric, explosionSize+=.5f, 5, 5);
			glPopMatrix();
		}

		box->resize(box->size.x,0.1f,box->size.z);
		glPushMatrix();
			box->draw();
		glPopMatrix();
		glPushMatrix();
			//Translate()
			glTranslatef(xPos,0.0f,zPos);
			glColor3f(0.5f,0.5f,0.5f);
			rubble->draw();
		glPopMatrix();
		gluDeleteQuadric(quadric);
	}
}
   # Dessin du vecteur direction de l'effecteur final
   ############################################################################################################################ */

void DrawEEOrientation() {
/* **************************************************************************************************************************** */
	/*
	 * Draw Grey border
	 */
	SetEEOrientView(WindowWidth, WindowHeight); 
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, _EEW_W_, 0, _EEW_H_, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glDisable(GL_LIGHTING);
	glColor3f(1, 1, 1);
	glColor3f(0.5, 0.5, 0.5);
	glBegin(GL_TRIANGLE_STRIP);
		glVertex2f(0, 0);
		glVertex2f(_EEW_B_, _EEW_B_);
		glVertex2f(0, _EEW_H_);
		glVertex2f(_EEW_B_, _EEW_H_-_EEW_B_);
		glVertex2f(_EEW_W_, _EEW_H_);
		glVertex2f(_EEW_W_-_EEW_B_, _EEW_H_-_EEW_B_);
		glVertex2f(_EEW_W_, 0);
		glVertex2f(_EEW_W_-_EEW_B_, _EEW_B_);
		glVertex2f(0, 0);
		glVertex2f(_EEW_B_, _EEW_B_);
	glEnd();
	glEnable(GL_LIGHTING);
/* **************************************************************************************************************************** */
	/* Set persp. proj. */
	SetEEOrientView(WindowWidth, WindowHeight); 
/* **************************************************************************************************************************** */
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
    glTranslatef(0.0f,0.0f,-25.0f);
    glRotatef(ynew,1.0,0.0,0.0);
    glRotatef(xnew,0.0,1.0,0.0);
    glRotatef(ONew[0], 1.0, 0.0, 0.0);
    glRotatef(ONew[1], 0.0, 1.0, 0.0);
    glRotatef(ONew[2], 0.0, 0.0, 1.0);
/* **************************************************************************************************************************** */
#define _ARROW_L_	(5)
/* **************************************************************************************************************************** */
	/* 
	 * Display Arrow
	 */

	GLUquadricObj	*gluAxesObj_1;
	gluAxesObj_1	= gluNewQuadric();

	glPushMatrix();
	glColor3f(1, 1, 0);
	glScalef(_ARROW_L_, 0.5, 0.5);
	glRotatef(90, 0, 1, 0);
	gluCylinder(gluAxesObj_1, 1.0, 1.0, 1.0, 15, 15);
	glPopMatrix();
	glPushMatrix();
	glTranslatef(_ARROW_L_, 0, 0);
	glRotatef(-90, 0, 1, 0);
	gluDisk(gluAxesObj_1, 0.5, 1.5, 15, 15);
	glTranslatef(0, 0, -2);
	gluCylinder(gluAxesObj_1, 0.0, 1.5, 2.0, 15, 15);
void compoe_sala(void){
  GLUquadricObj *quadric;
  

  /* inicia a composicao da sala */
  sala = glGenLists(1);
  glNewList(sala, GL_COMPILE);

  quadric = gluNewQuadric();
  //gluQuadricTexture(quadric, GL_TRUE);
	
	
	
	
  //ar condicionado esquerdo
  //glEnable(GL_TEXTURE_GEN_S);
  //glEnable(GL_TEXTURE_GEN_T);

  //glBindTexture(GL_TEXTURE_2D, texture_id[1]);


  //glDisable(GL_TEXTURE_GEN_S);
  //glDisable(GL_TEXTURE_GEN_T);
  
  //glBindTexture(GL_TEXTURE_2D, 0);
  //glPushMatrix();
  //glColor3f(1,1,1);
  //tras/frente - cima/baixo - direita/esquerda
  //glTranslatef (2.0, 7.5, -30.5);
  //espessura, altura, largura
  //glScalef (0.8, 0.4, 0.15);
  //glBindTexture(GL_TEXTURE_2D, texture_id[1]);
  //glutSolidCube (10.0);
  //glPopMatrix();
  //glDisable(GL_TEXTURE_GEN_S);
  //glDisable(GL_TEXTURE_GEN_T);
	
  //glBindTexture(GL_TEXTURE_2D, 0);




  //janela sobre a porta
  glPushMatrix();
  glColor3f(1,1,1);
  //tras/frente - cima/baixo - direita/esquerda
  glTranslatef (4.3, 7.5, 15.5);
  //espessura, altura, largura
  glScalef (0.1, 1.0, 1.5);
  glutWireCube (4.0);
  glPopMatrix();



  //janela do lado da janela sobre a porta
  glPushMatrix();
  //tras/frente - cima/baixo - direita/esquerda
  glTranslatef (4.3, 7.5, 11.2);
  //espessura, altura, largura
  glScalef (0.1, 1.0, 0.5);
  glutWireCube (4.0);
  glPopMatrix();

  //janela lateral do lado da porta
  glPushMatrix();
  //tras/frente - cima/baixo - direita/esquerda
  glTranslatef (4.3, -0.2, 11.2);
  //espessura, altura, largura
  glScalef (0.1, 2.68, 0.5);
  glutWireCube (4.0);
  glPopMatrix();

  //janela lateral em baixo da janela lateral do lado da porta
  glPushMatrix();
  //tras/frente - cima/baixo - direita/esquerda
  glTranslatef (4.3, -7.8, 11.2);
  //espessura, altura, largura
  glScalef (0.1, 1.0, 0.5);
  glutWireCube (4.0);
  glPopMatrix();

  //tela do projetor
  //glPushMatrix();
  //tras/frente - cima/baixo - direita/esquerda
  //glTranslatef (-16, -1.5, 18.5);
  //largura, altura, espessura
  //glScalef (3, 2.8, 0.05);
  //glutWireCube (5.0);
  //glPopMatrix();

  //quadro
  glPushMatrix();
  glColor3f(0.75,0.75,0.75);
  //tras/frente - cima/baixo - direita/esquerda
  glTranslatef (-15.7, 1., 18.5);
  //largura, altura, espessura
  glScalef (4, 1.5, 0.05);
  glutSolidCube (5.0);
  glPopMatrix();


  //teto
  glPushMatrix();
  //tras/frente - cima/baixo - direita/esquerda
  glTranslatef (-14.85, 10.0, -6.0);
  //largura, altura, espessura
  glScalef (10.05, 0.1, 10);
  glutWireCube (5.0);
  glPopMatrix();


/*
  //piso 

  //glEnable(GL_TEXTURE_GEN_S);
  //glEnable(GL_TEXTURE_GEN_T);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
  glBindTexture(GL_TEXTURE_2D, textura_plano);
  glEnable(GL_TEXTURE_2D);
	glBegin(GL_QUADS);
		glTexCoord2f(0, 0); glVertex3f(-1, -1, -1);
		glTexCoord2f(1, 0); glVertex3f(1, -1, -1);
		glTexCoord2f(1, 1); glVertex3f(1, 1, -1);
		glTexCoord2f(0, 1); glVertex3f(-1, 1, -1);
        glEnd();
	glDisable(GL_TEXTURE_2D);
 
  glColor3f(0.85,0.85,0.85);
  //tras/frente - cima/baixo - direita/esquerda
 glPushMatrix();
  glTranslatef (-14.85, -10.0, -6.0);
  //largura, altura, espessura
  glScalef (10.05, 0.1, 10);
  //glBindTexture(GL_TEXTURE_2D, texture_id[texture_floor]);
  glutSolidCube (5.0);
  glPopMatrix();
  //glDisable(GL_TEXTURE_GEN_S);
  //glDisable(GL_TEXTURE_GEN_T);*/

/*//textura do chao 1 (com quadrado)
draw_wall(-55.0f, -25, -25.0f,
      -55.0f, -25,  25.0f,
      55.0f, -25,  25.0f,
      55.0f, -25, -25.0f,0);*/

	//glBindTexture(GL_TEXTURE_2D, texture_id[0]);

	// PISO	 COM TEXTURA
	glColor3f(1,1,1);
	
	draw_wall(20, -9.5, 20,
		  -35, -9.5, 20,
		  -35, -9.5, -40,
		   20	, -9.5, -40, 1); 

 	/*// piso
 	glBindTexture(GL_TEXTURE_2D, texture_id[1]);

	compoe_piso();
  
        glBindTexture(GL_TEXTURE_2D, 0);*/



//  glEnable(GL_TEXTURE_GEN_S);
  //glEnable(GL_TEXTURE_GEN_T);

  //glBindTexture(GL_TEXTURE_2D, texture_id[3]);

  //compoe_cadeiras();
  //glDisable(GL_TEXTURE_GEN_S);
  //glDisable(GL_TEXTURE_GEN_T);
  //glBindTexture(GL_TEXTURE_2D, 0);

  glColor3f(0,0,1.0);
  compoe_grade();
  
  glColor3f(1.0,1.0,1.0);

	  glEnable(GL_TEXTURE_GEN_S);
          glEnable(GL_TEXTURE_GEN_T);

	  glBindTexture(GL_TEXTURE_2D, texture_id[0]);

	  compoe_parede_exterior();
	  compoe_parede_entrada();
	  compoe_parede_quadro_ar();	
    compoe_janelas_sol();
    compoe_janelas_entrada();

   // compoe_cadeiras();

	  glDisable(GL_TEXTURE_GEN_S);
          glDisable(GL_TEXTURE_GEN_T);
          glBindTexture(GL_TEXTURE_2D, 0);

  compoe_biros_esquerdo();
  compoe_biros_direito();  

  glColor3f(0,0,0);
  compoe_computador_esq();
  compoe_computador_dir();

  glColor3f(1,1,1);
  


  glEnable(GL_TEXTURE_GEN_S);
  glEnable(GL_TEXTURE_GEN_T);
  glBindTexture(GL_TEXTURE_2D, texture_id[3]); 
  
  compoe_cadeiras();

  glDisable(GL_TEXTURE_GEN_S);
  glDisable(GL_TEXTURE_GEN_T);
  
  glBindTexture(GL_TEXTURE_2D, 0);

  glEndList();
}
Esempio n. 9
0
void INode::renderTree(Context& ctx) const {
  for (size_t i = 0; i < _states.size(); i++) {
    // start point
    vec3 startpoint = ctx.getCurrentOrigin();

    // calculate end point of joint
    vec3 endpoint = _states[i]->getEndpoint(ctx);

    // draw the link
    //glBegin(GL_LINES);
    //  glColor3d(1.0, 1.0, 1.0);
    //  glVertex3d(startpoint[0], startpoint[1], startpoint[2]);
    //  glVertex3d(endpoint[0], endpoint[1], endpoint[2]);
    //glEnd();

    // calculate orthonormal basis for cylinder on joint
    vec3 u, v, n;
    _states[i]->getBasis(ctx, u, v, n);

    // check if basis is really orthonormal
    assert(double_equals(dot(u, v), 0));
    assert(double_equals(dot(u, n), 0));
    assert(double_equals(dot(v, n), 0));

    assert(double_equals(norm(u, 2), 1));
    assert(double_equals(norm(v, 2), 1));
    assert(double_equals(norm(n, 2), 1));

    //cout << "pos:" << endl << pos << endl;

    //cout << "u:" << endl << u << endl;
    //cout << "v:" << endl << v << endl;
    //cout << "n:" << endl << n << endl;

    vec3 x = makeVec3(1, 0, 0); 
    vec3 y = makeVec3(0, 1, 0);
    vec3 z = makeVec3(0, 0, 1);

    double ux = dot(x, u);
    double uy = dot(y, u);
    double uz = dot(z, u);

    double vx = dot(x, v);
    double vy = dot(y, v);
    double vz = dot(z, v);

    double nx = dot(x, n);
    double ny = dot(y, n);
    double nz = dot(z, n);

    // change of orthonormal basis from uvn -> xyz
    GLdouble m[16];
    m[0]  = ux;
    m[1]  = uy;
    m[2]  = uz;
    m[3]  = 0;
    
    m[4]  = vx; 
    m[5]  = vy;
    m[6]  = vz;
    m[7]  = 0;

    m[8]  = nx;
    m[9]  = ny;
    m[10] = nz;
    m[11] = 0;

    m[12] = 0; m[13] = 0; m[14] = 0; m[15] = 1;

    mat44 A; 
    A << ux << vx << nx << 0 << endr 
      << uy << vy << ny << 0 << endr
      << uz << vz << nz << 0 << endr 
      << 0  << 0  << 0  << 1 << endr;

    //if (!double_equals(det(A), 1))
    //  cout << "A is: " << endl << A << endl;

    //cout << "det(A): " << det(A) << endl;
    const double dA = det(A);
    if (!double_equals(dA, 1)) {
      cerr << "ERROR: det(A) = " << dA << endl; 
      throw runtime_error("determinant not 1 for rotation matrix");
    }


    //cout << "--" << endl;
    //for (int iii = 0; iii < 16; iii++) {
    //  cout << m[iii] << endl;
    //}
    //cout << "--" << endl;

    if (isRootNode())
      glColor3d(0.0, 0.0, 0.8);
    else if (isFixed())
      glColor3d(0.0, 1.0, 1.0); 
    else
      glColor3d(0.0, 0.0, 1.0);

    glPushMatrix();
      glTranslated(startpoint[0], startpoint[1], startpoint[2]);
      if (isRootNode())
        glutSolidSphere(0.1, 20, 20);
      else
        glutSolidSphere(0.08, 20, 20);
    glPopMatrix();

    GLUquadricObj *quadric = gluNewQuadric();

    glPushMatrix();
      glColor3d(0.0, 1.0, 0.0);
      glTranslated(startpoint[0], startpoint[1], startpoint[2]);
      glMultMatrixd(m);
      gluCylinder(quadric, 0.05, 0.05, _states[i]->getLength(), 32, 32);
    glPopMatrix();

    gluDeleteQuadric(quadric);

    // recurse into child
    _states[i]->pushContext(ctx);
      _kids[i]->renderTree(ctx);
    ctx.popContext();
  }
}
void compoe_computador_dir(void){

  GLUquadricObj *quadric;
  // inicia a composicao do computador
  comp_dir = glGenLists(1);
  glNewList(comp_dir, GL_COMPILE);
  quadric = gluNewQuadric();
  //gluQuadricTexture(quadric, GL_TRUE);

  GLfloat lado, atras;
  //compoe computador do lado da porta, 4 colunas
  for(int i = 0; i<4; i++){
    atras = i * 10.0;
    //3 computadores lado a lado
    for(int j=0; j<3; j++){
      lado = j * 6.0;

      //base tela
      quadric = gluNewQuadric();
      gluQuadricDrawStyle(quadric, GLU_FILL);
      gluQuadricOrientation(quadric, GLU_INSIDE); 
      glPushMatrix();  
      //tras/frente - direita/esquerda - cima/baixo 
      glRotatef(90,1,0,0);
      glTranslatef (-19-lado, 6.0-atras, 3.9);    
      SOLID_CLOSED_CYLINDER(quadric, 1., 1., 0.15, 30, 1)
      gluDeleteQuadric(quadric);
      glPopMatrix();

      //apoio tela
      quadric = gluNewQuadric();
      gluQuadricDrawStyle(quadric, GLU_FILL);
      gluQuadricOrientation(quadric, GLU_INSIDE);
      glPushMatrix();   
      glRotatef(90,1,0,0);  
      glTranslatef (-19-lado, 6.8-atras, 2.0);
      //tras/frente - direita/esquerda - cima/baixo 
      SOLID_CLOSED_CYLINDER(quadric, 0.25, 0.25, 2., 30, 1)
      gluDeleteQuadric(quadric);
      glPopMatrix();

      //tela
      glPushMatrix();
      //tras/frente - cima/baixo - direita/esquerda 
      glTranslatef (-19-lado, -1.7, 6.5-atras);
      glScalef (3., 3., 0.2);
      glutSolidCube (1.0);
      glPopMatrix();

      glColor3f(1,1,1);
      draw_wall(-17.7-lado, -0.3, 6.35-atras,
      -20.3-lado, -0.3, 6.35-atras,
      -20.3-lado, -3, 6.35-atras,
      -17.7-lado, -3, 6.35-atras, 5);

      glColor3f(0.2,0.2, 0.2); 

      //cpu
      glPushMatrix();
      //tras/frente - cima/baixo - direita/esquerda 
      glTranslatef (-21.3-lado, -2.8, 6.0-atras);
      glScalef (1., 3., 3.);
      glutSolidCube (1.0);
      glPopMatrix();


      draw_wall(-21.8-lado, -1.3, 4.45-atras,
      -20.8-lado, -1.3, 4.45-atras,
      -20.8-lado, -4, 4.45-atras,
      -21.8-lado, -4, 4.45-atras, 6); 

      //teclado

      glColor3f(0.5,0.5, 0.5);


      glPushMatrix();
      //tras/frente - cima/baixo - direita/esquerda 
      glTranslatef (-18.7-lado, -4.0, 4.0-atras);
      glScalef (2.9, 0.2, 1.2);
      glutSolidCube (1.0);
      glPopMatrix();

      draw_wall(-17.3-lado, -3.89, 4.5-atras,
      -20.1-lado, -3.89, 4.5-atras,
      -20.1-lado, -3.89, 3.4-atras,
       -17.3-lado, -3.89, 3.4-atras, 4); 


      glColor3f(0.15,0.15,0.15);

       

      //mouse
      quadric = gluNewQuadric();
      gluQuadricDrawStyle(quadric, GLU_FILL);
      gluQuadricOrientation(quadric, GLU_INSIDE);
      glPushMatrix();
      //tras/frente - cima/baixo - direita/esquerda 
      glTranslatef (-21-lado, -4.1, 4.0-atras);
      gluSphere(quadric, 0.25, 30,15);
      gluDeleteQuadric(quadric);
      glPopMatrix();
    }
  }
} 
void compoe_cadeiras(void){
  GLUquadricObj *quadric;
  // inicia a composicao do computador
  cadeiras = glGenLists(1);
  glNewList(cadeiras, GL_COMPILE);
  quadric = gluNewQuadric();
  //gluQuadricTexture(quadric, GL_TRUE);

  GLfloat lado, atras = 0;
  //compoe cadeiras, 4 colunas
  for(int i = 0; i<4; i++){
    atras = i * 9.5;
    //6 cadeiras lado a lado - 3 da cada lado
    for(int j=0; j<6; j++){
      lado = j*6.0;
      if (j>2){
        lado = lado + 8;
      }

      glColor3f(0,0,0);

      //pe cadeira - atrás esquerda
      quadric = gluNewQuadric();
      gluQuadricDrawStyle(quadric, GLU_FILL);
      gluQuadricOrientation(quadric, GLU_INSIDE);
      gluQuadricTexture(quadric, GL_TRUE);
      glPushMatrix();
      glRotatef(90,1,0,0);
      //-tras/frente+ - +esquerda/direita- - +baixo/cima-
      glTranslatef (8-lado, -0.8-atras, 6.8);
      SOLID_CLOSED_CYLINDER(quadric, 0.1, 0.1, 3.3, 30, 5)
      gluDeleteQuadric(quadric);
      glPopMatrix();


      //pe cadeira - atrás direita
      quadric = gluNewQuadric();
      gluQuadricOrientation(quadric, GLU_INSIDE);
      gluQuadricTexture(quadric, GL_TRUE);
      glPushMatrix();
      glRotatef(90,1,0,0);
      //-tras/frente+ - +esquerda/direita- - +baixo/cima-
      glTranslatef (6-lado, -0.8-atras, 6.8);
      SOLID_CLOSED_CYLINDER(quadric, 0.1, 0.1, 3.3, 30, 5)
      gluDeleteQuadric(quadric);
      glPopMatrix();


      //pe cadeira - frente esquerda
      quadric = gluNewQuadric();
      gluQuadricDrawStyle(quadric, GLU_FILL);
      gluQuadricOrientation(quadric, GLU_INSIDE);
      gluQuadricTexture(quadric, GL_TRUE);
      glPushMatrix();
      glRotatef(90,1,0,0);
      //-tras/frente+ - +esquerda/direita- - +baixo/cima-
      glTranslatef (8-lado, 1.2-atras, 6.8);
      SOLID_CLOSED_CYLINDER(quadric, 0.1, 0.1, 3.3, 30, 5)
      gluDeleteQuadric(quadric);
      glPopMatrix();


      //pe cadeira - frente direita
      quadric = gluNewQuadric();
      gluQuadricDrawStyle(quadric, GLU_FILL);
      gluQuadricOrientation(quadric, GLU_INSIDE);
      gluQuadricTexture(quadric, GL_TRUE);
      glPushMatrix();
      glRotatef(90,1,0,0);
      //-tras/frente+ - +esquerda/direita- - +baixo/cima-
      glTranslatef (6-lado, 1.2-atras, 6.8);
      SOLID_CLOSED_CYLINDER(quadric, 0.1, 0.1, 3.3, 30, 5)
      gluDeleteQuadric(quadric);
      glPopMatrix();

      

      //assento cadeira
      glPushMatrix();  
      //+tras/frente- - +baixo/cima- - - +esquerda/direita-
      glTranslatef (7-lado, -6.8, 0.3-atras);
      glScalef(4.0,0.3,3.0);
      quadric=gluNewQuadric();

      /*gluQuadricNormals(quadric, GLU_SMOOTH);
      gluQuadricTexture(quadric, GL_TRUE);
      glEnable(GL_TEXTURE_2D);
      glBindTexture(GL_TEXTURE_2D, texture_id[3]);    // texID is the texture ID of a
*/
                                    
      glColor3f(0,0,1);
      /*glEnable(GL_TEXTURE_GEN_S);
      glEnable(GL_TEXTURE_GEN_T);

      glBindTexture(GL_TEXTURE_2D, texture_id[3]);  */
      gluSphere(quadric,0.5,15,12);




      /*glDisable(GL_TEXTURE_GEN_S);
      glDisable(GL_TEXTURE_GEN_T);
      */
      //glBindTexture(GL_TEXTURE_2D, 0);
      glPopMatrix();

      //glEnable(GL_TEXTURE_GEN_S);
      //glEnable(GL_TEXTURE_GEN_T);

      //glBindTexture(GL_TEXTURE_2D, texture_id[3]);  

      //encosto cadeira
      glPushMatrix();  
      //+tras/frente- - +baixo/cima- - - +esquerda/direita-
      glTranslatef (7-lado, -4.75, -1.5-atras);
      glRotatef(-15,1,0,1);
      glScalef(4,3,0.5);
      quadric=gluNewQuadric();
      
      gluSphere(quadric,0.5,15,12);
      glPopMatrix();

      //glDisable(GL_TEXTURE_GEN_S);
      //glDisable(GL_TEXTURE_GEN_T);
      
      glBindTexture(GL_TEXTURE_2D, 0);

      //apoio encosto cadeira - vertical
      quadric = gluNewQuadric();
      gluQuadricDrawStyle(quadric, GLU_FILL);
      gluQuadricOrientation(quadric, GLU_INSIDE);
      glPushMatrix();   
      glColor3f(0,0,0);
      glRotatef(90,1,0,0);  
      glTranslatef (7-lado, -1.8-atras, 5);
      //tras/frente - direita/esquerda - cima/baixo 
      SOLID_CLOSED_CYLINDER(quadric, 0.15, 0.15, 2.2, 30, 1)
      //gluDeleteQuadric(quadric);
      glPopMatrix();

  //apoio encosto cadeira - horizontal
      quadric = gluNewQuadric();
      gluQuadricDrawStyle(quadric, GLU_FILL);
      gluQuadricOrientation(quadric, GLU_INSIDE);
      glPushMatrix();   
      glColor3f(0,0,0);
      glTranslatef (7-lado, -7, -2-atras);
      //tras/frente - cima/baixo - direita/esquerda 
      SOLID_CLOSED_CYLINDER(quadric, 0.15, 0.15, 2.2, 30, 1)
      gluDeleteQuadric(quadric);
      glPopMatrix();
    }
  }
}
Esempio n. 12
0
void duduk(){
     GLUquadric *quadric = gluNewQuadric();
     glPushMatrix();
        glColor3f(1.0,1.0,1.0);
       //tempat duduk
            glPushMatrix();
            glColor3f(1.0,0.3,2.0);
                glTranslatef(5,0,0);
                glRotatef(angl,0,0,1);
                glRotatef(270,1,0,0);
                gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                glTranslatef(0,0,0.75);
                glutSolidOctahedron(); 
            glPopMatrix();
             glPushMatrix();
             glColor3f(0.3,1.0,0.5);
                glTranslatef(-5,0,0);
                glRotatef(angl,0,0,1);
                glRotatef(270,1,0,0);
                gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                glTranslatef(0,0,0.75);
                glutSolidOctahedron(); 
            glPopMatrix();  
             glPushMatrix();
             glColor3f(0.1,1.0,0.4);
                glTranslatef(0,5,0);
                glRotatef(angl,0,0,1);
                glRotatef(270,1,0,0);
                gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                glTranslatef(0,0,0.75);
                glutSolidOctahedron(); 
            glPopMatrix();
             glPushMatrix();
             glColor3f(1.0,0.5,1.0);
                glTranslatef(0,-5,0);
                glRotatef(angl,0,0,1);
                glRotatef(270,1,0,0);
                gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                glTranslatef(0,0,0.75);
                glutSolidOctahedron(); 
            glPopMatrix();
           glPushMatrix();
           glColor3f(1.0,0.0,0.0);
                glTranslatef(3.5,3.5,0);
                glRotatef(angl,0,0,1);
                glRotatef(270,1,0,0);
                gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                glTranslatef(0,0,0.75);
                glutSolidOctahedron(); 
            glPopMatrix();
            glPushMatrix();
            glColor3f(0.8,0.5,0.0);
                glTranslatef(-3.5,3.5,0);
                glRotatef(angl,0,0,1);
                glRotatef(270,1,0,0);
                gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                glTranslatef(0,0,0.75);
                glutSolidOctahedron(); 
            glPopMatrix();
            glPushMatrix();
            glColor3f(6.0,0.5,0.0);
                glTranslatef(3.5,-3.5,0);
                glRotatef(angl,0,0,1);
                glRotatef(270,1,0,0);
                gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                glTranslatef(0,0,0.75);
                glutSolidOctahedron(); 
            glPopMatrix();
             glPushMatrix();
             glColor3f(0.5,0.7,1.0);
                glTranslatef(-3.5,-3.5,0);
                glRotatef(angl,0,0,1);
                glRotatef(270,1,0,0);
                gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                glTranslatef(0,0,0.75);
                glutSolidOctahedron(); 
            glPopMatrix();
        glPopMatrix();
angl-=1;
}
Esempio n. 13
0
void donat() {
     if(asd<=70){asd+=0.25;
     if(asd==70)fgh=70;}
     else if(fgh>=0){fgh-=0.25;
     if(fgh==0)asd=0.0;}
    GLUquadric *quadric = gluNewQuadric();
    glPushMatrix();
        glColor3f(0,1,1);
        glRotatef(90,1,0,0);
        glRotatef(zxc,0,0,1);
        glTranslatef(0,0,4);
      glutSolidTorus(1,2,45,35);
      glTranslatef(0,-3,0);
      glRotatef(90,1,0,0);
        gluCylinder(quadric, 0.1, 0.1, 3,30, 40);
        glTranslatef(-3,0,-3);
      glRotatef(270,0,1,0);
        gluCylinder(quadric, 0.1, 0.1, 3,30, 40);
          glTranslatef(0,0,-6);
      glRotatef(180,0,1,0);
        gluCylinder(quadric, 0.1, 0.1, 3,30, 40);
    glTranslatef(6,0,-3);
    glRotatef(270,0,1,0);
        gluCylinder(quadric, 0.1, 0.1, 3,30, 40);
        glPushMatrix();
                //glTranslatef(0,-1.5,0);
                glColor3f(1.0,0.1,0.1);
                glRotatef(-90,0,1,0);
                glRotatef(-180,1,0,0);
                //gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                //glTranslatef(0,0,0.75);
                //glutSolidCone(0.8,0.8,50,2); 
                
                gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                   glTranslatef(0,0,0.75);
                  glutWireCone(0.8,0.8,50,2);
                
                glTranslatef(0,-1.5,0);
                
        glPopMatrix();
           glPushMatrix();
                glTranslatef(6,0,6);
                glRotatef(180,0,1,0);
                  glRotatef(180,1,0,0);
                   gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                   glTranslatef(0,0,0.75);
                  glutWireCone(0.8,0.8,50,2);
                  
                  glTranslatef(0,-1.5,0);
                   
            glPopMatrix();
             glPushMatrix();
                glTranslatef(-6,0,6);
             
                  glRotatef(180,1,0,0);
                  gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                   glTranslatef(0,0,0.75);
                  glutWireCone(0.8,0.8,50,2);
                  
                  glTranslatef(0,-1.5,0);
                   
            glPopMatrix();
             glPushMatrix();
                glTranslatef(0,0,12);
                glRotatef(90,0,1,0);
                glRotatef(180,1,0,0);
                  //glRotatef(270,1,0,0);
                   //gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                   //glTranslatef(0,0,0.75);
                  //glutSolidCone(0.8,0.8,50,2);
                   gluCylinder(quadric, 0.5, 0.5, 1, 20, 20);
                   glTranslatef(0,0,0.75);
                  glutWireCone(0.8,0.8,50,2);
                   
                  glTranslatef(0,-1.5,0);
                   
            glPopMatrix();
glPopMatrix();

      zxc-=5;

}
Esempio n. 14
0
void RenderScene() 
{
    int i=0;    

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
    glLoadIdentity();                                   // Reset The matrix


/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

    // Set our camera to the left a bit for a nice side view of the left hand side

        //      Position          View       Up Vector
    gluLookAt(-2.5f, 0.5, -0.1,  0, 0.5f, 0,   0, 1, 0); // This determines where the camera's position and view is

    // Rotate the camera around our world for a 360 degree view of what is going on.
    // Yes I know... we are actually rotating the whole world, not the camera :)
    glRotatef(g_rotateY, 0, 1, 0);

    // We need a radius for our sphere, so let's create it here with 0.1
    float radius = 0.1f;
    
    // Draw the polygon

    glBegin (GL_TRIANGLES);                             // This is our BEGIN to draw

        glColor3ub(255, 0, 0);                          // Make the Left vertex RED
        glVertex3f(g_vTriangle[0].x, g_vTriangle[0].y, g_vTriangle[0].z);

        glColor3ub(0, 255, 0);                          // Make the Right vertex GREEN
        glVertex3f(g_vTriangle[1].x, g_vTriangle[1].y, g_vTriangle[1].z);

        glColor3ub(0, 0, 255);                          // Make the Top vertex BLUE
        glVertex3f(g_vTriangle[2].x, g_vTriangle[2].y, g_vTriangle[2].z);
    glEnd();                                            // This is the END of drawing

    // Instead of calculating the sphere ourselves, we are going to use quadrics.
    // Check out the tutorial on quadrics if this is confusing for you.

    // Allocate a quadric object to use as a sphere
    GLUquadricObj *pObj = gluNewQuadric();              // Get a Quadric off the stack

    // To make it easier to see, we want the sphere to be in wire frame
    gluQuadricDrawStyle(pObj, GLU_LINE);                // Draw the sphere normally

    // Move the sphere to it's center position
    glTranslatef(g_vPosition.x, g_vPosition.y, g_vPosition.z);

    // Now we get to the wonderful function that does it all for us.  All we
    // need to do is pass in the array of vertices for the triangle, the center
    // of the sphere and it's radius.  This will return a true or false, depending
    // on if we collided or not.  True = The Sphere Collided
    bool bCollided = SpherePolygonCollision(g_vTriangle, g_vPosition, 3, radius);   
    
    // If we collided we want the sphere to be green, otherwise it should be purple
    if(bCollided)
        glColor3ub(0, 255, 0);                          // Make the sphere green
    else        
        glColor3ub(255, 0, 255);                        // Make the sphere purple
        
    // Draw the quadric as a sphere with the radius of .1 and a 15 by 15 detail.
    // To increase the detail of the sphere, just increase the 2 last parameters.
    gluSphere(pObj, radius, 15, 15);

    gluDeleteQuadric(pObj);                             // Free the Quadric

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *


    SDL_GL_SwapBuffers();                                   // Swap the backbuffers to the foreground
}
 void draw()
 {
   GLUquadricObj* q = gluNewQuadric();
   gluSphere(q, 0.5, 15, 15);
   gluDeleteQuadric(q);
 }
Esempio n. 16
0
// Initializer. Returns false if something went wrong, like not being able to
// load the texture.
bool Sphere::Initialize(int scale, float x, float y, float z, float r, float g, float b, char * texture)
{
    ubyte   *image_data;
    int	    image_height, image_width;
    
    // Load the image for the texture. The texture file has to be in
    // a place where it will be found.
    if ( ! ( image_data = (ubyte*)tga_load(texture, &image_width,
                                           &image_height, TGA_TRUECOLOR_24) ) )
    {
        fprintf(stderr, "Ground::Initialize: Couldn't load road.tga\n");
        return false;
    }
    
    // This creates a texture object and binds it, so the next few operations
    // apply to this texture.
    glGenTextures(1, &texture_obj);
    glBindTexture(GL_TEXTURE_2D, texture_obj);
    
    // This sets a parameter for how the texture is loaded and interpreted.
    // basically, it says that the data is packed tightly in the image array.
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    
    // This sets up the texture with high quality filtering. First it builds
    // mipmaps from the image data, then it sets the filtering parameters
    // and the wrapping parameters. We want the grass to be repeated over the
    // ground.
    gluBuild2DMipmaps(GL_TEXTURE_2D,3, image_width, image_height, GL_RGB, GL_UNSIGNED_BYTE, image_data);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
    
    float maximumAnistropy;
    //get the value
    glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnistropy);
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maximumAnistropy);
    
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
    
    // This says what to do with the texture. Modulate will multiply the
    // texture by the underlying color.
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    
    // Now do the geometry. Create the display list.
    display_list = glGenLists(1);
    glNewList(display_list, GL_COMPILE);
	// Use white, because the texture supplies the color.
	glColor3f(r/255.0f, g/255.0f, b/255.0f);
    
	// The surface normal is up for the ground.
	glNormal3f(0.0, 0.0, 1.0);
    
    glTranslatef(x, y, z);

    qobj_ptr = gluNewQuadric();
    gluQuadricNormals(qobj_ptr, GLU_SMOOTH);
    gluQuadricTexture(qobj_ptr, GL_TRUE);

    
    glColor3f(r/255.0f, g/255.0f, b/255.0f);
    glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texture_obj);
    gluSphere(qobj_ptr, scale, 100, 100);
    glDisable(GL_TEXTURE_2D);
    glEndList();
    
    // We only do all this stuff once, when the GL context is first set up.
    initialized = true;
    
    return true;
}
Esempio n. 17
0
void Unit::compileDL()
{	
    if(Unit::compiled) return;


    Unit::teamList = glGenLists(1);
    glNewList(Unit::teamList, GL_COMPILE);
	glPushMatrix();
	gluSphere(gluNewQuadric(), 1, 36, 18);
    
	//glScalef(2.0, 2.0, 2.0);

	glBegin(GL_TRIANGLES);	
	
	//glColor3f(10.0f,0.0f,0.0f);			// red
	glVertex3f( 0.0f, 10.0f, 0.0f);		// up-frontplane
	//glColor3f(0.0f,10.0f,0.0f);			// green
	glVertex3f(-10.0f,-10.0f, 10.0f);		// left-frontplane
	//glColor3f(0.0f,0.0f,1.0f);			// blue
	glVertex3f( 10.0f,-10.0f, 10.0f);		// right-frontplane

	

	//glColor3f(10.0f,0.0f,0.0f);			// red
	glVertex3f( 0.0f, 10.0f, 0.0f);		// up-backplane
	//glColor3f(0.0f,1.0f,0.0f);			// green
	glVertex3f( 10.0f,-10.0f, -10.0f);		// left-backplane
	//glColor3f(0.0f,0.0f,1.0f);			// plane
	glVertex3f(-10.0f,-10.0f, -10.0f);		// right-backplane
    
	
	glEnd();

	glPopMatrix();
    
    glEndList();

	Unit::typeList = glGenLists(1);
    glNewList(Unit::typeList, GL_COMPILE);
	glPushMatrix();
	gluSphere(gluNewQuadric(), 1, 36, 18);
    
	//glScalef(2.0, 2.0, 2.0);

	glBegin(GL_TRIANGLES);	

	//glColor3f(10.0f,0.0f,0.0f);			// red
	glVertex3f( 0.0f, 10.0f, 0.0f);		// up-rightplane
	//glColor3f(0.0f,0.0f,10.0f);			// blue
	glVertex3f( 10.0f,-10.0f, 10.0f);		// left-rightplane
	//glColor3f(0.0f,01.0f,0.0f);			// green
	glVertex3f( 10.0f,-10.0f, -10.0f);		// right-rightplane
    
	//glColor3f(10.0f,0.0f,0.0f);			// red
	glVertex3f( 0.0f, 10.0f, 0.0f);		// up-leftplane
	//glColor3f(0.0f,0.0f,10.0f);			// blue
	glVertex3f(-10.0f,-10.0f,-10.0f);		// left-leftplane
	//glColor3f(0.0f,10.0f,0.0f);			// green
	glVertex3f(-10.0f,-10.0f, 10.0f);		// right-leftplane
	glEnd();

	glPopMatrix();
    
    glEndList();


    Unit::healthBar = glGenLists(1);
    glNewList(Unit::healthBar, GL_COMPILE);
    
    setColor(0.0, 1.0, 0.0, 1.0, 0.1, 0.5, 0.7);
    setGLColor();
	glBegin(GL_QUADS);
    glVertex3f(-10.0f, 10.0f, 0.0f);
    glVertex3f(-10.0f, 15.0f, 0.0f);
    glVertex3f(10.0f, 15.0f, 0.0f);
    glVertex3f(10.0f, 10.0f, 0.0f);
    glEnd();
    glEndList();

    Unit::compiled = true;
}
Esempio n. 18
0
void C3DPlotCanvas::RenderScene()
{
	std::vector<bool>& hs = highlight_state->GetHighlight();
	
	int xt = var_info[0].time;
	int yt = var_info[1].time;
	int zt = var_info[2].time;
	
	GLUquadric* myQuad = 0;
	myQuad = gluNewQuadric();
	if (m_d) {
		//glColor3f(1.0, 1.0, 1.0);
		glColor3f(((GLfloat) selectable_fill_color.Red())/((GLfloat) 255.0),
				  ((GLfloat) selectable_fill_color.Green())/((GLfloat) 255.0),
				  ((GLfloat) selectable_fill_color.Blue())/((GLfloat) 255.0));
		for (int i=0; i<num_obs; i++) {
			if (hs[i]) continue;
			glPushMatrix();
			glTranslatef(scaled_d[0][xt][i], scaled_d[1][yt][i],
						 scaled_d[2][zt][i]);
			gluSphere(myQuad, 0.03, 5, 5); 	
			glPopMatrix();
		}
		//glColor3f(1.0, 1.0, 0.0);
		glColor3f(((GLfloat) highlight_color.Red())/((GLfloat) 255.0),
				  ((GLfloat) highlight_color.Green())/((GLfloat) 255.0),
				  ((GLfloat) highlight_color.Blue())/((GLfloat) 255.0));
		for (int i=0; i<num_obs; i++) {
			if (!hs[i]) continue;
			glPushMatrix();
			glTranslatef(scaled_d[0][xt][i], scaled_d[1][yt][i],
						 scaled_d[2][zt][i]);
			gluSphere(myQuad, 0.03, 5, 5); 	
			glPopMatrix();
		}
		
	}

	glDisable(GL_LIGHTING);
	if (m_x) {
		//glColor3f(0.75, 0.75, 0.75);
		glColor3f(((GLfloat) selectable_fill_color.Red())/((GLfloat) 255.0),
				  ((GLfloat) selectable_fill_color.Green())/((GLfloat) 255.0),
				  ((GLfloat) selectable_fill_color.Blue())/((GLfloat) 255.0));
		for(int i=0; i<num_obs; i++) {
			if (hs[i]) continue;
			glPushMatrix();
			glTranslatef(-1, scaled_d[1][yt][i], scaled_d[2][zt][i]);
			glRotatef(90, 0.0, 1.0, 0.0);	
			gluDisk(myQuad, 0, 0.02, 5, 3);
			glPopMatrix();
		}
		//glColor3f(1.0, 1.0, 0.0);
		glColor3f(((GLfloat) highlight_color.Red())/((GLfloat) 255.0),
				  ((GLfloat) highlight_color.Green())/((GLfloat) 255.0),
				  ((GLfloat) highlight_color.Blue())/((GLfloat) 255.0));
		for (int i=0; i<num_obs; i++) {
			if (!hs[i]) continue;
			glPushMatrix();
			glTranslatef(-1, scaled_d[1][yt][i], scaled_d[2][zt][i]);
			glRotatef(90, 0.0, 1.0, 0.0);
			gluDisk(myQuad, 0, 0.02, 5, 3);
			glPopMatrix();
		}
	}
	
	if (m_y) {
		//glColor3f(0.75, 0.75, 0.75);
		glColor3f(((GLfloat) selectable_fill_color.Red())/((GLfloat) 255.0),
				  ((GLfloat) selectable_fill_color.Green())/((GLfloat) 255.0),
				  ((GLfloat) selectable_fill_color.Blue())/((GLfloat) 255.0));
		for (int i=0; i<num_obs; i++) {
			if (hs[i]) continue;
			glPushMatrix();
			glTranslatef(scaled_d[0][xt][i], -1, scaled_d[2][zt][i]);
			glRotatef(90, 1.0, 0.0, 0.0); 
			gluDisk(myQuad, 0, 0.02, 5, 3);
			glPopMatrix();
		}
		//glColor3f(1.0, 1.0, 0.0);
		glColor3f(((GLfloat) highlight_color.Red())/((GLfloat) 255.0),
				  ((GLfloat) highlight_color.Green())/((GLfloat) 255.0),
				  ((GLfloat) highlight_color.Blue())/((GLfloat) 255.0));
		for (int i=0; i<num_obs; i++) {
			if (!hs[i]) continue;
			glPushMatrix();
			glTranslatef(scaled_d[0][xt][i], -1, scaled_d[2][zt][i]);
			glRotatef(90, 1.0, 0.0, 0.0); 
			gluDisk(myQuad, 0, 0.02, 5, 3);
			glPopMatrix();
		}
	}

	if (m_z) {
		//glColor3f(0.75, 0.75, 0.75);
		glColor3f(((GLfloat) selectable_fill_color.Red())/((GLfloat) 255.0),
				  ((GLfloat) selectable_fill_color.Green())/((GLfloat) 255.0),
				  ((GLfloat) selectable_fill_color.Blue())/((GLfloat) 255.0));
		for (int i=0; i<num_obs; i++) {
			if (hs[i]) continue;
			glPushMatrix();
			glTranslatef(scaled_d[0][xt][i], scaled_d[1][yt][i], -1);
			gluDisk(myQuad, 0, 0.02, 5, 3);
			glPopMatrix();
		}
		//glColor3f(1.0, 1.0, 0.0);
		glColor3f(((GLfloat) highlight_color.Red())/((GLfloat) 255.0),
				  ((GLfloat) highlight_color.Green())/((GLfloat) 255.0),
				  ((GLfloat) highlight_color.Blue())/((GLfloat) 255.0));
		for(int i=0; i<num_obs; i++) {
			if (!hs[i]) continue;
			glPushMatrix();
			glTranslatef(scaled_d[0][xt][i], scaled_d[1][yt][i], -1);
			gluDisk(myQuad, 0, 0.02, 5, 3);
			glPopMatrix();
		}
	}
	glEnable(GL_LIGHTING);

	if (b_select) {
		double minx = xp - xs;
		double maxx = xp + xs;
		double miny = yp - ys;
		double maxy = yp + ys;
		double minz = zp - zs;
		double maxz = zp + zs;
		glDisable(GL_LIGHTING);
		glLineWidth(2.0);
		glColor3f(1.0, 0.0, 0.0);
		glBegin(GL_LINES);
			glVertex3f(maxx,maxy,maxz);
			glVertex3f(maxx,miny,maxz);
			glVertex3f(maxx,miny,maxz);
			glVertex3f(minx,miny,maxz);
			glVertex3f(minx,miny,maxz);
			glVertex3f(minx,maxy,maxz);
			glVertex3f(minx,maxy,maxz);
			glVertex3f(maxx,maxy,maxz);
			glVertex3f(maxx,maxy,minz);
			glVertex3f(maxx,miny,minz);
			glVertex3f(maxx,miny,minz);
			glVertex3f(minx,miny,minz);
			glVertex3f(minx,miny,minz);
			glVertex3f(minx,maxy,minz);
			glVertex3f(minx,maxy,minz);
			glVertex3f(maxx,maxy,minz);
			glVertex3f(maxx,maxy,maxz);
			glVertex3f(maxx,maxy,minz);
			glVertex3f(maxx,miny,maxz);
			glVertex3f(maxx,miny,minz);
			glVertex3f(minx,miny,maxz);
			glVertex3f(minx,miny,minz);
			glVertex3f(minx,maxy,maxz);
			glVertex3f(minx,maxy,minz);			
		glEnd();
		glEnable(GL_LIGHTING);
	}

	glLineWidth(3.0);

	glColor3f((GLfloat) 0.95,(GLfloat) 0.0,(GLfloat) 0.95);
	glDisable(GL_LIGHTING);
	glBegin(GL_LINES);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) -1);
		glVertex3f((GLfloat) 1,(GLfloat) -1,(GLfloat) -1);

		glVertex3f((GLfloat) 1.2,(GLfloat) -0.9,(GLfloat) -1.0);
		glVertex3f((GLfloat) 1.1,(GLfloat) -0.8,(GLfloat) -1.0);
		glVertex3f((GLfloat) 1.2,(GLfloat) -0.8,(GLfloat) -1.0);
		glVertex3f((GLfloat) 1.1,(GLfloat) -0.9,(GLfloat) -1.0);
    glEnd();

	glColor3f((GLfloat) 0.0,(GLfloat) 0.95,(GLfloat) 0.0);
	glBegin(GL_LINES);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) -1);
		glVertex3f((GLfloat) -1,(GLfloat) 1,(GLfloat) -1);

		glVertex3f((GLfloat) -0.85,(GLfloat) 1.15,(GLfloat) -1.0);
		glVertex3f((GLfloat) -0.9,(GLfloat) 1.2,(GLfloat) -1.0);
		glVertex3f((GLfloat) -0.85,(GLfloat) 1.15,(GLfloat) -1.0);
		glVertex3f((GLfloat) -0.8,(GLfloat) 1.2,(GLfloat) -1.0);
		glVertex3f((GLfloat) -0.85,(GLfloat) 1.15,(GLfloat) -1.0);
		glVertex3f((GLfloat) -0.85,(GLfloat) 1.1,(GLfloat) -1.0);		
	glEnd();

	glColor3f((GLfloat) 0.0,(GLfloat) 0.95,(GLfloat) 0.95);
	glBegin(GL_LINES);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) -1);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) 1);

		glVertex3f((GLfloat) -1.0,(GLfloat) -0.8,(GLfloat) 1.2);
		glVertex3f((GLfloat) -1.0,(GLfloat) -0.8,(GLfloat) 1.1);
		glVertex3f((GLfloat) -1.0,(GLfloat) -0.8,(GLfloat) 1.1);
		glVertex3f((GLfloat) -1.0,(GLfloat) -0.9,(GLfloat) 1.2);
		glVertex3f((GLfloat) -1.0,(GLfloat) -0.9,(GLfloat) 1.2);
		glVertex3f((GLfloat) -1.0,(GLfloat) -0.9,(GLfloat) 1.1);		
	glEnd();

	glLineWidth(1.0);
	glColor3f(1.0, 1.0, 1.0);
	glBegin(GL_LINES);
		glVertex3f((GLfloat) 1,(GLfloat) 1,(GLfloat) 1);
		glVertex3f((GLfloat) 1,(GLfloat) -1,(GLfloat) 1);
		glVertex3f((GLfloat) 1,(GLfloat) -1,(GLfloat) 1);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) 1);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) 1);
		glVertex3f((GLfloat) -1,(GLfloat) 1,(GLfloat) 1);
		glVertex3f((GLfloat) -1,(GLfloat) 1,(GLfloat) 1);
		glVertex3f((GLfloat) 1,(GLfloat) 1,(GLfloat) 1);
		glVertex3f((GLfloat) 1,(GLfloat) 1,(GLfloat) -1);
		glVertex3f((GLfloat) 1,(GLfloat) -1,(GLfloat) -1);
		glVertex3f((GLfloat) 1,(GLfloat) -1,(GLfloat) -1);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) -1);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) -1);
		glVertex3f((GLfloat) -1,(GLfloat) 1,(GLfloat) -1);
		glVertex3f((GLfloat) -1,(GLfloat) 1,(GLfloat) -1);
		glVertex3f((GLfloat) 1,(GLfloat) 1,(GLfloat) -1);
		glVertex3f((GLfloat) 1,(GLfloat) 1,(GLfloat) 1);
		glVertex3f((GLfloat) 1,(GLfloat) 1,(GLfloat) -1);
		glVertex3f((GLfloat) 1,(GLfloat) -1,(GLfloat) 1);
		glVertex3f((GLfloat) 1,(GLfloat) -1,(GLfloat) -1);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) 1);
		glVertex3f((GLfloat) -1,(GLfloat) -1,(GLfloat) -1);
		glVertex3f((GLfloat) -1,(GLfloat) 1,(GLfloat) 1);
		glVertex3f((GLfloat) -1,(GLfloat) 1,(GLfloat) -1);
	glEnd();

	glEnable(GL_LIGHTING);
 
	gluDeleteQuadric(myQuad);
}
Esempio n. 19
0
   ############################################################################################################################ */


void MakeCallLists() 
{

GLUquadricObj	*gluLinkObj;
GLUquadricObj	*gluJointObj;
GLUquadricObj	*gluAxesObj;

gluLinkObj	= gluNewQuadric();
gluJointObj	= gluNewQuadric();
gluAxesObj	= gluNewQuadric();

/* **************************************************************************************************************************** */
	// Axes
	glNewList(AxesList, GL_COMPILE);
		glMatrixMode(GL_MODELVIEW);

		glPushMatrix();
		glColor3f(1, 0, 0);
		glTranslatef(-50.0, 0, 0);
		glScalef(100, 0.5, 0.5);
		glRotatef(90, 0, 1, 0);
		gluCylinder(gluAxesObj, 0.5, 0.5, 1.0, 15, 15);
		glPopMatrix();
		glPushMatrix();
		glTranslatef(50.0+3, 0, 0);
		glRotatef(-90, 0, 1, 0);
		gluCylinder(gluAxesObj, 0.0, 1.5, 3.0, 15, 15);
		glPopMatrix();

		glPushMatrix();
		glColor3f(0, 1, 0);
		glTranslatef(0.0, 50.0, 0);
		glScalef(0.5, 100.0, 0.5);
		glRotatef(90, 0, 1, 0);
		glRotatef(90, 1, 0, 0);
		gluCylinder(gluAxesObj, 0.5, 0.5, 1.0, 15, 15);
		glPopMatrix();
		glPushMatrix();
		glTranslatef(0.0, 50.0+3, 0);
		glRotatef(90, 0, 1, 0);
		glRotatef(90, 1, 0, 0);
		gluCylinder(gluAxesObj, 0.0, 1.5, 3.0, 15, 15);
		glPopMatrix();

		glPushMatrix();
		glColor3f(0, 0, 1);
		glTranslatef(0.0, 0.0, -50.0);
		glScalef(0.5, 0.5, 100.0);
		gluCylinder(gluAxesObj, 0.5, 0.5, 1.0, 15, 15);
		glPopMatrix();
		glPushMatrix();
		glTranslatef(0.0, 0.0, 50.0+3);
		glRotatef(180, 1, 0, 0);
		gluCylinder(gluAxesObj, 0.0, 1.5, 3.0, 15, 15);
		glPopMatrix();
 
	glEndList();
/* **************************************************************************************************************************** */
	// Segment
	glNewList(LinkList, GL_COMPILE);
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glRotatef(90, 0, 1, 0);
		gluCylinder(gluLinkObj, 1.0, 1.0, 1.0, 30, 30);
		glPopMatrix();
	glEndList();
/* **************************************************************************************************************************** */
	// Articulation
	glNewList(JointList, GL_COMPILE);
		glMatrixMode(GL_MODELVIEW);
		gluSphere(gluJointObj, 1.0, 30, 30);
	glEndList();
/* **************************************************************************************************************************** */
	// Effecteur final
	glNewList(EEList, GL_COMPILE);
		glPushMatrix();
		glTranslatef(1*thickness, 0, 0);

		glPushMatrix();
		glScalef(2*thickness, thickness/3, thickness/2);
		glutSolidCube(1);
		glPopMatrix();

		glTranslatef(1*thickness+thickness/8, 0, 0);

		glPushMatrix();
		glScalef(thickness/4, 2*thickness, 2*thickness);
		glutSolidCube(1);
		glPopMatrix();

		glPushMatrix();
		glTranslatef(thickness/2 + thickness/8, 0, 0);
		glTranslatef(0, thickness - thickness/8, 0);
		glScalef(thickness, thickness/4, 2*thickness);
		glutSolidCube(1);
		glPopMatrix();
		
		glPushMatrix();
		glTranslatef(thickness/2 + thickness/8, 0, 0);
		glTranslatef(0, -thickness + thickness/8, 0);
		glScalef(thickness, thickness/4, 2*thickness);
		glutSolidCube(1);
		glPopMatrix();
		
		glPopMatrix();
Esempio n. 20
0
/* Initialises texturing, lighting, display lists, and everything else 
   associated with the model. */
void 
myinit(void)
{
  GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
  GLfloat mat_shininess[] = {50.0};
  GLfloat light_position1[] = {1.0, 1.0, 1.0, 0.0};
  GLfloat light_position2[] = {-1.0, 1.0, 1.0, 0.0};

#ifdef STEREO
  /* check if GL_STEREO quad-buffered page-flipping display enabled */
  if (bStereoRequested)
	  glGetBooleanv(GL_STEREO, &bStereoEnabled);
  /* lower background contrast to reduce ghosting in LC shutter glasses */
  if (bStereoEnabled)
	  glClearColor(0.2, 0.2, 0.2, 0.0);
  else
#endif
  glClearColor(0.0, 0.0, 0.0, 0.0);

  obj = gluNewQuadric();
  make_table();
  make_image();

  /* Set up Texturing */
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glTexImage2D(GL_TEXTURE_2D, 0, 3, IMAGE_WIDTH,
    IMAGE_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE,
    image);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

  /* Set up Lighting */
  glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
  glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
  glLightfv(GL_LIGHT0, GL_POSITION, light_position1);
  glLightfv(GL_LIGHT1, GL_POSITION, light_position2);

  /* Initial render mode is with full shading and LIGHT 0
     enabled. */
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
  glDepthFunc(GL_LEQUAL);
  glEnable(GL_DEPTH_TEST);
  glDisable(GL_ALPHA_TEST);

  glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
  glEnable(GL_COLOR_MATERIAL);
  glShadeModel(GL_SMOOTH);

  /* Initialise display lists */
  glNewList(list_piston_shaded, GL_COMPILE);
    draw_piston();
  glEndList();
  glNewList(list_flywheel_shaded, GL_COMPILE);
    draw_flywheel();
  glEndList();

  gluQuadricTexture(obj, GL_TRUE);
  glNewList(list_piston_texture, GL_COMPILE);
    draw_piston();
  glEndList();
  glNewList(list_flywheel_texture, GL_COMPILE);
    draw_flywheel();
  glEndList();
  gluQuadricTexture(obj, GL_FALSE);
}
Esempio n. 21
0
void ModelViewController::draw()
{
    if (!valid())
		{
		gui->RFP_Browser->callback( &tree_callback, gui );
		gui->RFP_Browser->redraw();

		glLoadIdentity();
		glViewport (0, 0, w(),h());											// Reset The Current Viewport
		glMatrixMode (GL_PROJECTION);										// Select The Projection Matrix
		glLoadIdentity ();													// Reset The Projection Matrix
		gluPerspective (45.0f, (float)w()/(float)h(),1.0f, 1000000.0f);						// Calculate The Aspect Ratio Of The Window
		glMatrixMode (GL_MODELVIEW);										// Select The Modelview Matrix
		glLoadIdentity ();													// Reset The Modelview Matrix
		ArcBall->setBounds((GLfloat)w(), (GLfloat)h());                 //*NEW* Update mouse bounds for arcball
		glEnable(GL_LIGHTING);
		for(int i=0;i<4;i++)
		{
			lights[i].Init((GLenum)(GL_LIGHT0+i));
			lights[i].SetAmbient(0.2f, 0.2f, 0.2f, 1.0f);
			lights[i].SetDiffuse(1.0f, 1.0f, 1.0f, 1.0f);
			lights[i].SetSpecular(1.0f, 1.0f, 1.0f, 1.0f);
			lights[i].Off();
		}

		lights[0].SetLocation(-100, 100, 200, 0);
		lights[1].SetLocation(100, 100, 200, 0);
		lights[2].SetLocation(100, -100, 200, 0);
		lights[3].SetLocation(100, -100, 200, 0);

		lights[0].On();
		lights[3].On();

		// enable lighting
		glDisable ( GL_LIGHTING);

		glDepthFunc (GL_LEQUAL);										// The Type Of Depth Testing (Less Or Equal)
		glEnable (GL_DEPTH_TEST);										// Enable Depth Testing
		glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);				// Set Perspective Calculations To Most Accurate

		quadratic=gluNewQuadric();										// Create A Pointer To The Quadric Object
		gluQuadricNormals(quadratic, GLU_SMOOTH);						// Create Smooth Normals
		gluQuadricTexture(quadratic, GL_TRUE);							// Create Texture Coords
	}
//    glEnable(GL_BLEND);
//    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);				// Clear Screen And Depth Buffer
	glLoadIdentity();												// Reset The Current Modelview Matrix
	glTranslatef(0.0f,0.0f,-zoom*2);								// Move Left 1.5 Units And Into The Screen 6.0

	glMultMatrixf(Transform.M);										// NEW: Apply Dynamic Transform
	CenterView();

    glPushMatrix();													// NEW: Prepare Dynamic Transform
	glColor3f(0.75f,0.75f,1.0f);


	/*--------------- Draw Grid and Axis ---------------*/

	DrawGridAndAxis();

	/*--------------- Draw models ------------------*/

	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);

	Flu_Tree_Browser::Node *node = gui->RFP_Browser->get_selected( 1 );
	ProcessControl.Draw(node);

	/*--------------- Exit -----------------*/
	glPopMatrix();													// NEW: Unapply Dynamic Transform
	glFlush();														// Flush The GL Rendering Pipeline
//	swap_buffers();
}
Esempio n. 22
0
void Visualizer::paintGL()
{ 

    // Wait for lock on model. Need this to avoid concurrency issues when reading searcher and target data structures.
    model->lock();

    QPainter painter;
    painter.begin(this);


    // qApp->processEvents();
    //cout << "paintGL called" << endl;
    model->gui_ready = true;

    model->drawing = true;

    SearchSpace* space = model->getSearchSpace();
    int n_targets = 0;
    Target* targets = space->getTargetsCopy(n_targets);

    int n_searchers = 0;
    Searcher* searchers = space->getSearchersCopy(n_searchers);


    x_min_bound = getModel()->getSearchSpace()->getXMinBound();
    y_min_bound = getModel()->getSearchSpace()->getYMinBound();
    z_min_bound = getModel()->getSearchSpace()->getZMinBound();
    x_max_bound = getModel()->getSearchSpace()->getXMaxBound();
    y_max_bound = getModel()->getSearchSpace()->getYMaxBound();
    z_max_bound = getModel()->getSearchSpace()->getZMaxBound();

    float x_center = (x_max_bound-x_min_bound)/2;
    float y_center = (y_max_bound-y_min_bound)/2;
    float z_center = (z_max_bound-z_min_bound)/2;

    saveGLState();

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    //glTranslatef(0.0, 0.0, -10.0);
    glFrustum(-1, 1, -1, 1, 0, 0);
   // glViewport(0, 0, 2*width(), 2*height());
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    //glTranslatef(0.0f, 0.0f, -15.0f);
    glRotatef(xRot / 16.0, 1.0, 0.0, 0.0);
    glRotatef(yRot / 16.0, 0.0, 1.0, 0.0);
    glRotatef(zRot / 16.0, 0.0, 0.0, 1.0);
    glTranslatef(horz_pan, vert_pan, 0.0f);
    //glScalef (1.0, 1.0, 1.0);      /* modeling transformation */
    glScalef(scale, scale, scale);
    glColor4f(1.0, 1.0, 1.0, 0.3);

    drawRectangularPrism(x_min_bound-x_center, y_min_bound-y_center, z_min_bound-z_center, x_max_bound-x_center, y_max_bound-y_center, z_max_bound-z_center);

    QPointF pos;
    QPointF center_pos;

    //int n_searchers = space->getNumSearchers();
    //Searcher* searchers = space->getSearchers();

    //cout << "Number of searchers: " << n_searchers << endl;

    // draw boundary
    QRect frame_rect = this->contentsRect();
    int frame_height = frame_rect.height();
    int frame_width = frame_rect.width();

    center_pos = frame_rect.center();

    for ( int i = 0; i < n_searchers; i++ )
    {
        float scaled_x = searchers[i].getXPos()-x_center;
        float scaled_y = searchers[i].getYPos()-y_center;
        float scaled_z = searchers[i].getZPos()-z_center;

        glColor3f(searchers[i].red/255.0, searchers[i].blue/255.0, searchers[i].green/255.0);

        GLUquadricObj *quadric=gluNewQuadric();
        gluQuadricNormals(quadric, GLU_SMOOTH);
        glPushMatrix();
        glTranslatef( scaled_x, scaled_y, scaled_z );
        glPushMatrix();
        gluSphere(quadric, target_display_radius, 10,10);
        glPopMatrix();
        gluDeleteQuadric(quadric);

        //cout << "Raw (" << searchers[i].getXPos() << ", " << searchers[i].getYPos() << ", " << searchers[i].getZPos() <<")" << endl;
        //cout << "Scaled (" << scaled_x << ", " << scaled_y << ", " << scaled_z << ")" << endl;


        // Display path
        vector<Coordinate*> path = searchers[i].getPath();

        for(vector<Coordinate*>::iterator it = path.begin(); it != path.end(); ++it)
        {

            if (*(it+1) == NULL || *it == NULL)
            {
               // cout << "Tried to display path but it seems to have been invalidated" << endl;
                continue; // Trying to avoid occasional concurrent change errors
            }

            float scaled_path_x = (*it)->getX()-x_center;//*frame_width/2;//+center_pos.x();
            float scaled_path_y = (*it)->getY()-y_center;//*frame_height/2;//+center_pos.y();
            float scaled_path_z = (*it)->getZ()-z_center;//*frame_height/2;//+center_pos.y(); // <---- FIX FOR Z

            Coordinate start, end;
            start.setX(scaled_path_x);
            start.setY(scaled_path_y);
            start.setZ(scaled_path_z);


            if (it+1 != path.end())
            {
                scaled_path_x = (*(it+1))->getX()-x_center;//*frame_width/2;//+center_pos.x();
                scaled_path_y = (*(it+1))->getY()-y_center;//*frame_height/2;//+center_pos.y();
                scaled_path_z = (*(it+1))->getZ()-z_center;//*frame_height/2;//+center_pos.y();
            }
            else
            {
                break;
            }

            end.setX(scaled_path_x);
            end.setY(scaled_path_y);
            end.setZ(scaled_path_z);

            //painter.drawLine(path_segment);

            glBegin(GL_LINES);
            glVertex3d(start.getX(), start.getY(), start.getZ());
            glVertex3d(end.getX(), end.getY(), end.getZ());
            glEnd();

        }


    }


    // display targets


    for ( int i = 0; i < n_targets; i++ )
    {
        if ( targets[i].getXPos() < x_min_bound
             || targets[i].getXPos() > x_max_bound
             || targets[i].getYPos() < y_min_bound
             || targets[i].getYPos() > y_max_bound
             || targets[i].getZPos() < z_min_bound
             || targets[i].getZPos() > z_max_bound
             )
            continue; // This can happen when targets are being repositioned at the start of a new target placement - looks ugly

        if ( targets[i].isFound() ) glColor4f( 0.0, 1.0, 1.0, 1.0 );
        else glColor4f( 0.0, 1.0, 0.0, 0.2 );
        GLUquadricObj *quadric=gluNewQuadric();
        gluQuadricNormals(quadric, GLU_SMOOTH);
        glPushMatrix();
        glTranslatef( targets[i].getXPos()-x_center,targets[i].getYPos()-y_center ,targets[i].getZPos()-z_center );
        glPushMatrix();
        gluSphere(quadric, target_display_radius, 10,10);
        glPopMatrix();
        gluDeleteQuadric(quadric);
    }

    restoreGLState();
    //swapBuffers();


    //emit VisFinishedPaintGL();

    QString framesPerSecond;
    framesPerSecond.setNum(frames /(time.elapsed() / 1000.0), 'f', 2);

    painter.setPen(Qt::white);

    painter.drawText(20, 40, framesPerSecond + " fps");

    painter.end();

    swapBuffers();

    frames++;

    if (!(frames % 100)) {
        time.start();
        frames = 0;
    }

    model->drawing = false;

    delete [] targets;
    delete [] searchers;

    // Release the model lock so the model can continue processessing
    model->unlock();

    //glFinish();
    //qApp->processEvents();

}
Esempio n. 23
0
static void UpperLeg(
    char solid)
{
    int i;
    GLUquadricObj *Hamstring = gluNewQuadric();
    GLUquadricObj *Knee = gluNewQuadric();
    GLUquadricObj *joint[2];

    glNewList(SOLID_MECH_UPPER_LEG, GL_COMPILE);
#ifdef LIGHT
    SetMaterial(mat_specular, mat_ambient, mat_diffuse, mat_shininess);
#endif
    glColor3f(1.0, 1.0, 0.0);
    if (!solid) {
        gluQuadricDrawStyle(Hamstring, GLU_LINE);
        gluQuadricDrawStyle(Knee, GLU_LINE);
        }
    glTranslatef(0.0, -1.0, 0.0);
    Box(0.4, 1.0, 0.7, solid);
    glTranslatef(0.0, -0.65, 0.0);
    for (i = 0; i < 5; i++) {
        Box(1.2, 0.3, 1.2, solid);
        glTranslatef(0.0, -0.2, 0.0);
        Box(1.0, 0.1, 1.0, solid);
        glTranslatef(0.0, -0.2, 0.0);
        }
    glTranslatef(0.0, -0.15, -0.4);
    Box(2.0, 0.5, 2.0, solid);
    glTranslatef(0.0, -0.3, -0.2);
    glRotatef(90.0, 1.0, 0.0, 0.0);
#ifdef LIGHT
    SetMaterial(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2);
#endif
    glColor3f(0.5, 0.5, 0.5);
    gluCylinder(Hamstring, 0.6, 0.6, 3.0, 16, 10);
#ifdef LIGHT
    SetMaterial(mat_specular, mat_ambient, mat_diffuse, mat_shininess);
#endif
    glColor3f(1.0, 1.0, 0.0);
    glRotatef(-90.0, 1.0, 0.0, 0.0);
    glTranslatef(0.0, -1.5, 1.0);
    Box(1.5, 3.0, 0.5, solid);
    glTranslatef(0.0, -1.75, -0.8);
    Box(2.0, 0.5, 2.0, solid);
    glTranslatef(0.0, -0.9, -0.85);
#ifdef LIGHT
    SetMaterial(mat_specular2, mat_ambient2, mat_diffuse2, mat_shininess2);
#endif
    glColor3f(0.5, 0.5, 0.5);
    gluCylinder(Knee, 0.8, 0.8, 1.8, 16, 10);
    for (i = 0; i < 2; i++) {
        if (i)
            glScalef(-1.0, 1.0, 1.0);
        joint[i] = gluNewQuadric();
        if (!solid)
            gluQuadricDrawStyle(joint[i], GLU_LINE);
        if (i)
            glTranslatef(0.0, 0.0, 1.8);
        gluDisk(joint[i], 0.0, 0.8, 16, 10);
        if (i)
            glTranslatef(0.0, 0.0, -1.8);
        }
    glScalef(-1.0, 1.0, 1.0);
    glEndList();
}
Esempio n. 24
0
void CsceneRender::loadHardModel(const int modelID)
{
    glutSetWindow(winId);
    glNewList(modelList, GL_COMPILE);

    switch(modelID)
    {
        case DEBUG_SCENE:
            //simple rectangular floor
            glColor3f(0.0,1.0,0.7);
            glBegin(GL_QUADS);//Draws the floor
                glNormal3f( 0.0,0.0, 1.0);
                glVertex3f(-1.0,23.0, 0.0);
                glVertex3f(-1.0,-1.0, 0.0);
                glVertex3f( 23.0,-1.0, 0.0);
                glVertex3f( 23.0, 23.0, 0.0);
            glEnd();

            //draws a red wall
            glColor3f( 1.0, 0.0, 0.0);
            glBegin(GL_QUADS);
                glNormal3f( -1.0, 0.0, 0.0);
                glVertex3f(15.0, 15.0, 0.0);
                glVertex3f(15.0, 7.0, 0.0);
                glVertex3f(15.0, 7.0, 3.0);
                glVertex3f(15.0, 15.0, 3.0);
            glEnd();

            //Draws a magenta wall
            glColor3f( 1., 0., 1.0);
            glBegin(GL_QUADS);
                glNormal3f( -1.0, 0.0, 0.0);
                glVertex3f(14.0, 17.0, 0.0);
                glVertex3f(14.0, 12.0, 0.0);
                glVertex3f(14.0, 12.0, 2.0);
                glVertex3f(14.0, 17.0, 2.0);
            glEnd();

            //draws an orange cone
            glColor3f(0.9,0.6,0.0);
            glTranslatef(12.0,15.5,0.0);// moves model origin
            gluCylinder(gluNewQuadric(),1.2, 0.0, 3.5, 25,25);
            glTranslatef(-12.0,-15.5,0.0);// moves model origin

            //draws a yellow sphere
            glColor3f(1,0.9,0.1);
            glTranslatef(11.0,10.0,0.0);// moves model origin
            gluSphere(gluNewQuadric(),2.0, 40,40);
            glTranslatef(-11.0,-10.0,0.0);// moves model origin
            break;
            
        case SPHERE:
            //draws a yellow sphere
            glColor3f(1,0.9,0.1);
            glTranslatef(3.0,0.0,0.0);// moves model origin
            gluSphere(gluNewQuadric(),2.0, 140,140);
            //glTranslatef(-3.0,0.0,0.0);// comes back
            break;
                 
        default:
            cout << "CsceneRender::loadModel(): Unknown modelID" << endl; 
            break;
            
    }//end switch
      
    //glLoadIdentity();
    glEndList();
    glFinish(); //finish all openGL work
}
Esempio n. 25
0
void TransformerBone::drawSphereJoint(float radius)
{
	GLUquadricObj *qobj = 0;
	qobj = gluNewQuadric();
	gluSphere(qobj, radius, 10, 10);
}
Esempio n. 26
0
void World::Draw()
{
	static GLUquadricObj *quadObj = gluNewQuadric();

    float white[4] = {1.0,1.0,1.0,1.0};
    float grey[4] = {0.8,0.8,0.8,1.0};
    float black[4] = {0.0,0.0,0.0,1.0};
	float red[4] = {1.0,0.0,0.0,1.0};
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, grey);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, black);
    glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black);

    for (unsigned int i = 0; i < m_shapes.size(); i++)
    {
        vec3 pos = m_shapes[i]->pos;
        if (m_shapes[i]->GetType() == SPHERE)
        {
            Sphere* c = (Sphere*) m_shapes[i];
            glPushMatrix();
            glTranslatef(pos[0], pos[1], pos[2]);
	        glutSolidSphere(c->r, 20, 20);   
            glPopMatrix();
        }
        else if (m_shapes[i]->GetType() == CUBE)
        {
            Cube* c = (Cube*) m_shapes[i];
            glPushMatrix();
            glTranslatef(pos[0], pos[1], pos[2]);
            glScalef(c->hx*2, c->hy*2, c->hz*2);
	        glutSolidCube(1.0);   
            glPopMatrix();
        }
        else if (m_shapes[i]->GetType() == CYLINDER)
        {
            Cylinder* c = (Cylinder*) m_shapes[i];
            vec3 forward = c->end - c->start;
            double height = forward.Length();
            double radius = c->r;

            forward.Normalize();

            vec3 left = vec3(0,1,0)^forward;
            vec3 up;
            if (left.Length() < 0.0001)
            {
                up = forward^vec3(1,0,0);
                left = up^forward;
            }
            else
            {
                up = forward^left;
            }

            float m[16];
            m[0] = left[0]; m[4] = up[0]; m[8] = forward[0];  m[12] = 0; 
            m[1] = left[1]; m[5] = up[1]; m[9] = forward[1];  m[13] = 0; 
            m[2] = left[2]; m[6] = up[2]; m[10] = forward[2]; m[14] = 0; 
            m[3] = 0.0;  m[7] = 0.0;  m[11] = 0.0;  m[15] = 1.0;

	        glPushMatrix();
			glTranslated(c->start[0], c->start[1], c->start[2]);
            glMultMatrixf(m); 
	        gluQuadricDrawStyle(quadObj, GLU_FILL);
	        gluQuadricNormals(quadObj, GLU_SMOOTH);
	        gluCylinder(quadObj, radius, radius, height, 12, 12);            
			//endCaps
			glPushMatrix();
			gluDisk(quadObj, 0, radius, 12, 12);
			glTranslated(0, 0, height);
			gluDisk(quadObj, 0, radius, 12, 12);
			glPopMatrix();
			glPopMatrix();
        }
        else if (m_shapes[i]->GetType() == GROUND)
        {
            glBegin(GL_QUADS);
                glNormal3d(0,1,0);
                glVertex3f(100, 0.0, -100.0);
                glVertex3f(100, 0.0, 100.0);
                glVertex3f(-100, 0.0, 100);
                glVertex3f(-100, 0.0, -100);
            glEnd();
        }
    }
}
Esempio n. 27
0
int init(int argc, char **argv)	//initialization function
{
	printf("Beginning initialization\n");

	vectorUp.x=0;			//assign the up vector to (0,1,0)
	vectorUp.y=1;
	vectorUp.z=0;

	cameraDefault.location.x=0;	//set up a default camera
	cameraDefault.location.y=0;
	cameraDefault.location.z=5;
	cameraDefault.target.x=0;
	cameraDefault.target.y=0;
	cameraDefault.target.z=-1;

	cameraCurrent = &cameraDefault;	//set the default camera as the current camera

	windowTitle = (char*) &defaultTitle;	//set the window title to be the default
	windowMain.x = 50;				//set up initial window shape
	windowMain.y = 50;
	windowMain.width = 640;
	windowMain.height = 480;

	ratio = 1.0 * windowMain.width / windowMain.height;

	xRot = 0;
	yRot = 0;
	zRot = 0;

	stateFullScreen = 0;	//default is to start in window mode
							//to start in fullscreen mode do NOT
							//change this value, instead call
							//toggleFullScreen() after the window
							//has been created

	frame = 0;				//set up counters
	timebase = 0;

	//GLUT initialization follows, don't worry about it
	glutInit(&argc, argv);
	glutInitWindowPosition(windowMain.x, windowMain.y);
	glutInitWindowSize(windowMain.width, windowMain.height);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
	printf("Creating window \"%s\"\n", windowTitle);
	glutCreateWindow(windowTitle);
	glutDisplayFunc(draw);
	glutIdleFunc(draw);
	glutReshapeFunc(resize);
	glutKeyboardFunc(normalKey);
	glutSpecialFunc(specialKey);
	glutMouseFunc(mouse);
	glutMotionFunc(mouseActive);
	glutPassiveMotionFunc(mousePassive);
	glutEntryFunc(mouseEntry);

	//initialize timers
	time = glutGet(GLUT_ELAPSED_TIME);
	timepassed = 0;

	//initialize quadratics
	quadratic = gluNewQuadric();
	gluQuadricNormals(quadratic, GLU_SMOOTH);

	printf("Initialization complete\n");

	return 1;
}
Esempio n. 28
0
	virtual void Update()
	{
		PROFILE("CAppTask::Update()", 1);
		if(m_bHDR && m_fb.IsValid())
			m_fb.EnableFrameBuffer();

		// Cheap collision detection/response
		CVector vCamera = CCameraTask::GetPtr()->GetPosition();
		const float camMag = vCamera.Magnitude();
		const float camMagSqr = vCamera.MagnitudeSquared();
		if(camMag < m_fInnerRadius + 0.01f)
		{
			CVector N = vCamera / camMag;
			CVector I = CCameraTask::GetPtr()->GetVelocity();
			float fSpeed = I.Magnitude();
			I /= fSpeed;
			CVector R = N * (2.0f*(-I | N)) + I;
			CCameraTask::GetPtr()->SetVelocity(R * fSpeed);

			vCamera = N * (m_fInnerRadius + 0.01f);
			CCameraTask::GetPtr()->SetPosition(vCamera);
		}

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glPolygonMode(GL_FRONT, m_nPolygonMode);

		// Draw the groud sphere
		CGLShaderObject *pGroundShader;
		if(camMag >= m_fOuterRadius)
			pGroundShader = &m_shGroundFromSpace;
		else
			pGroundShader = &m_shGroundFromAtmosphere;
		pGroundShader->Enable();
		pGroundShader->SetUniformParameter3f("v3CameraPos", vCamera.x, vCamera.y, vCamera.z);
		pGroundShader->SetUniformParameter3f("v3LightPos", m_vLightDirection.x, m_vLightDirection.y, m_vLightDirection.z);
		pGroundShader->SetUniformParameter3f("v3InvWavelength", 1/m_fWavelength4[0], 1/m_fWavelength4[1], 1/m_fWavelength4[2]);
		pGroundShader->SetUniformParameter1f("fCameraHeight", camMag);
		pGroundShader->SetUniformParameter1f("fCameraHeight2", camMagSqr);
		pGroundShader->SetUniformParameter1f("fInnerRadius", m_fInnerRadius);
		pGroundShader->SetUniformParameter1f("fInnerRadius2", m_fInnerRadius*m_fInnerRadius);
		pGroundShader->SetUniformParameter1f("fOuterRadius", m_fOuterRadius);
		pGroundShader->SetUniformParameter1f("fOuterRadius2", m_fOuterRadius*m_fOuterRadius);
		pGroundShader->SetUniformParameter1f("fKrESun", m_Kr*m_ESun);
		pGroundShader->SetUniformParameter1f("fKmESun", m_Km*m_ESun);
		pGroundShader->SetUniformParameter1f("fKr4PI", m_Kr4PI);
		pGroundShader->SetUniformParameter1f("fKm4PI", m_Km4PI);
		pGroundShader->SetUniformParameter1f("fScale", 1.0f / (m_fOuterRadius - m_fInnerRadius));
		pGroundShader->SetUniformParameter1f("fScaleDepth", m_fRayleighScaleDepth);
		pGroundShader->SetUniformParameter1f("fScaleOverScaleDepth", (1.0f / (m_fOuterRadius - m_fInnerRadius)) / m_fRayleighScaleDepth);
		pGroundShader->SetUniformParameter1f("g", m_g);
		pGroundShader->SetUniformParameter1f("g2", m_g*m_g);
		pGroundShader->SetUniformParameter1i("nSamples", m_nSamples);
		pGroundShader->SetUniformParameter1f("fSamples", float(m_nSamples));
		pGroundShader->SetUniformParameter1i("s2Test", 0);
		GLUquadricObj *pSphere = gluNewQuadric();
		//m_tEarth.Enable();
		gluSphere(pSphere, m_fInnerRadius, 100, 50);
		//m_tEarth.Disable();
		gluDeleteQuadric(pSphere);
		pGroundShader->Disable();

		// Draw the sky sphere
		CGLShaderObject *pSkyShader;
		if(camMag >= m_fOuterRadius)
			pSkyShader = &m_shSkyFromSpace;
		else
			pSkyShader = &m_shSkyFromAtmosphere;
		pSkyShader->Enable();
		pSkyShader->SetUniformParameter3f("v3CameraPos", vCamera.x, vCamera.y, vCamera.z);
		pSkyShader->SetUniformParameter3f("v3LightPos", m_vLightDirection.x, m_vLightDirection.y, m_vLightDirection.z);
		pSkyShader->SetUniformParameter3f("v3InvWavelength", 1/m_fWavelength4[0], 1/m_fWavelength4[1], 1/m_fWavelength4[2]);
		pSkyShader->SetUniformParameter1f("fCameraHeight", camMag);
		pSkyShader->SetUniformParameter1f("fCameraHeight2", camMagSqr);
		pSkyShader->SetUniformParameter1f("fInnerRadius", m_fInnerRadius);
		pSkyShader->SetUniformParameter1f("fInnerRadius2", m_fInnerRadius*m_fInnerRadius);
		pSkyShader->SetUniformParameter1f("fOuterRadius", m_fOuterRadius);
		pSkyShader->SetUniformParameter1f("fOuterRadius2", m_fOuterRadius*m_fOuterRadius);
		pSkyShader->SetUniformParameter1f("fKrESun", m_Kr*m_ESun);
		pSkyShader->SetUniformParameter1f("fKmESun", m_Km*m_ESun);
		pSkyShader->SetUniformParameter1f("fKr4PI", m_Kr4PI);
		pSkyShader->SetUniformParameter1f("fKm4PI", m_Km4PI);
		pSkyShader->SetUniformParameter1f("fScale", 1.0f / (m_fOuterRadius - m_fInnerRadius));
		pSkyShader->SetUniformParameter1f("fScaleDepth", m_fRayleighScaleDepth);
		pSkyShader->SetUniformParameter1f("fScaleOverScaleDepth", (1.0f / (m_fOuterRadius - m_fInnerRadius)) / m_fRayleighScaleDepth);
		pSkyShader->SetUniformParameter1f("g", m_g);
		pSkyShader->SetUniformParameter1f("g2", m_g*m_g);
		pSkyShader->SetUniformParameter1i("nSamples", m_nSamples);
		pSkyShader->SetUniformParameter1f("fSamples", float(m_nSamples));
		glFrontFace(GL_CW);
		glEnable(GL_BLEND);
		glBlendFunc(GL_ONE, GL_ONE);
		pSphere = gluNewQuadric();
		gluSphere(pSphere, m_fOuterRadius, 100, 100);
		gluDeleteQuadric(pSphere);
		glDisable(GL_BLEND);
		glFrontFace(GL_CCW);
		pSkyShader->Disable();

		glPolygonMode(GL_FRONT, GL_FILL);

		if(m_bHDR && m_fb.IsValid())
		{
			m_fb.DisableFrameBuffer();
			CVideoTask::GetPtr()->GetFont().Begin();
			m_fb.EnableTexture();
			m_shHDR.Enable();
			m_shHDR.SetUniformParameter1f("fExposure", m_fExposure);
			m_shHDR.SetUniformParameter1i("s2Test", 0);
			glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
			glBegin(GL_QUADS);
			{
				glTexCoord2f(0, 0);     glVertex2i(0, 600);
				glTexCoord2f(800, 0);   glVertex2i(800, 600);
				glTexCoord2f(800, 600); glVertex2i(800, 0);
				glTexCoord2f(0, 600);   glVertex2i(0,  0);
			}
			glEnd();
			m_shHDR.Disable();
			m_fb.DisableTexture();
			CVideoTask::GetPtr()->GetFont().End();
		}

		glColor4ub(255, 255, 255, 255);
		char szBuffer[256];
		CFont &fFont = CVideoTask::GetPtr()->GetFont();
		fFont.Begin();
		fFont.SetPosition(0, 15);
		sprintf(szBuffer, "Samples (+/-): %d", m_nSamples);
		fFont.Print(szBuffer);
		fFont.SetPosition(0, 30);
		sprintf(szBuffer, "Kr (F5/Sh+F5): %-4.4f", m_Kr);
		fFont.Print(szBuffer);
		fFont.SetPosition(0, 45);
		sprintf(szBuffer, "Km (F6/Sh+F6): %-4.4f", m_Km);
		fFont.Print(szBuffer);
		fFont.SetPosition(0, 60);
		sprintf(szBuffer, "g (F7/Sh+F7): %-2.2f", m_g);
		fFont.Print(szBuffer);
		fFont.SetPosition(0, 75);
		sprintf(szBuffer, "ESun (F8/Sh+F8): %-1.1f", m_ESun);
		fFont.Print(szBuffer);
		fFont.SetPosition(0, 90);
		sprintf(szBuffer, "Red (F9/Sh+F9): %-3.3f", m_fWavelength[0]);
		fFont.Print(szBuffer);
		fFont.SetPosition(0, 105);
		sprintf(szBuffer, "Green (F10/Sh+F10): %-3.3f", m_fWavelength[1]);
		fFont.Print(szBuffer);
		fFont.SetPosition(0, 120);
		sprintf(szBuffer, "Blue (F11/Sh+F11): %-3.3f", m_fWavelength[2]);
		fFont.Print(szBuffer);
		fFont.End();
	}
Esempio n. 29
0
void InitGL()     // Inicializamos parametros
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);				// Negro de fondo	

	glEnable(GL_TEXTURE_2D);

	glShadeModel(GL_SMOOTH);
	//Para construir la figura comentar esto
	glLightfv(GL_LIGHT1, GL_POSITION, Position);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, Diffuse);
	//glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, Position2);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	//glEnable(GL_LIGHT1);

	glEnable(GL_COLOR_MATERIAL);					//Habilitar GlColor3f
	//glEnable(GL_CULL_FACE);
	//glCullFace(GL_BACK);
	//glPolygonMode(GL_BACK, GL_LINE);

	glClearDepth(1.0f);									// Configuramos Depth Buffer
	glEnable(GL_DEPTH_TEST);							// Habilitamos Depth Testing
	glDepthFunc(GL_LEQUAL);								// Tipo de Depth Testing a realizar
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	glEnable(GL_AUTO_NORMAL);
	glEnable(GL_NORMALIZE);

	/* setup blending */
	//glBlendFunc(GL_SRC_ALPHA,GL_ONE);			// Set The Blending Function For Translucency
	//glColor4f(1.0f, 1.0f, 1.0f, 0.5); 

	rectoria._3dsLoad("rectoria/rectoria.3ds");
	rectoria.LoadTextureImages();
	rectoria.GLIniTextures();
	rectoria.ReleaseTextureImages();

	biblioteca._3dsLoad("biblioteca/biblioteca.3ds");
	biblioteca.LoadTextureImages();
	biblioteca.GLIniTextures();
	biblioteca.ReleaseTextureImages();

	//islas._3dsLoad("islas/islas.3ds");
	//islas.LoadTextureImages();
	//islas.GLIniTextures();
	//islas.ReleaseTextureImages();

	texturaPasto.LoadTGA("city/pasto01.tga");
	texturaPasto.BuildGLTexture();
	texturaPasto.ReleaseImage();

	facultadD._3dsLoad("derecho3DS/derecho.3ds");
	facultadD.LoadTextureImages();
	facultadD.GLIniTextures();
	facultadD.ReleaseTextureImages();

	t_placasRectoria.LoadTGA("city/pasto01.tga");
	t_placasRectoria.BuildGLTexture();
	t_placasRectoria.ReleaseImage();

	t_escalerasIslas.LoadTGA("cuadrosrectoria/texturaEsc.tga");
	t_escalerasIslas.BuildGLTexture();
	t_escalerasIslas.ReleaseImage();

	quadratic = gluNewQuadric();			// Create A Pointer To The Quadric Object ( NEW )
	gluQuadricNormals(quadratic, GLU_SMOOTH);	// Create Smooth Normals ( NEW )
	gluQuadricTexture(quadratic, GL_TRUE);		// Create Texture Coords ( NEW )


	objCamera.Position_Camera(0, 2.5f, 3, 0, 2.5f, 0, 0, 1, 0);



}
Esempio n. 30
0
 GLUWrapper()
 {
   //std::cerr << __PRETTY_FUNCTION__ << std::endl;
   _quadratic = gluNewQuadric();              // Create A Pointer To The Quadric Object ( NEW )
   gluQuadricNormals(_quadratic, GLU_SMOOTH); // Create Smooth Normals ( NEW )
 }