Beispiel #1
0
void Patch::draw(){
	
	glEnable(GL_MAP2_VERTEX_3);
	glEnable(GL_MAP2_NORMAL);
	glEnable(GL_MAP2_TEXTURE_COORD_2);
	glEnable(GL_TEXTURE_2D);
	
	GLint currentCullFace;
	glGetIntegerv( GL_CULL_FACE_MODE, &currentCullFace );

	glEnable(GL_CCW);
	glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, this->order,  0.0, 1.0, this->order*3, this->order, cpMatrix);
	glEnable(GL_CW);
	glEnable(GL_AUTO_NORMAL);
	glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2,  0.0, 1.0, 4, 2,  &patchTextpoints[0][0]);

	glMapGrid2f(this->partsU, 0.0,1.0, this->partsV, 0.0,1.0); 
	if( strcmp( "fill", this->compute.c_str() ) == 0 )
		glEvalMesh2(GL_FILL, 0,partsU, 0,partsV);
	else
		if( strcmp( "line", this->compute.c_str() ) == 0 )
			glEvalMesh2(GL_LINE, 0,partsU, 0,partsV);
		else
			if( strcmp( "point", this->compute.c_str() ) == 0 )
				glEvalMesh2(GL_POINT, 0,partsU, 0,partsV);

	glEnable(currentCullFace);
	
	glDisable(GL_MAP2_VERTEX_3);
	glDisable(GL_MAP2_NORMAL);
	glDisable(GL_MAP2_TEXTURE_COORD_2);
	glDisable(GL_TEXTURE_2D);
}
Beispiel #2
0
static void
teapot(GLint grid, GLdouble scale, GLenum type)
{
    float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
    long i, j, k, l;

    glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
    glEnable(GL_AUTO_NORMAL);
    glEnable(GL_NORMALIZE);
    glEnable(GL_MAP2_VERTEX_3);
    glEnable(GL_MAP2_TEXTURE_COORD_2);
    glPushMatrix();
    glRotatef(270.0, 1.0, 0.0, 0.0);
    glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
    glTranslatef(0.0, 0.0, -1.5);
    for (i = 0; i < 10; i++) {
        for (j = 0; j < 4; j++) {
            for (k = 0; k < 4; k++) {
                for (l = 0; l < 3; l++) {
                    p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
                    q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
                    if (l == 1)
                        q[j][k][l] *= -1.0;
                    if (i < 6) {
                        r[j][k][l] =
                            cpdata[patchdata[i][j * 4 + (3 - k)]][l];
                        if (l == 0)
                            r[j][k][l] *= -1.0;
                        s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
                        if (l == 0)
                            s[j][k][l] *= -1.0;
                        if (l == 1)
                            s[j][k][l] *= -1.0;
                    }
                }
            }
        }
        glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
                &tex[0][0][0]);
        glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
                &p[0][0][0]);
        glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
        glEvalMesh2(type, 0, grid, 0, grid);
        glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
                &q[0][0][0]);
        glEvalMesh2(type, 0, grid, 0, grid);
        if (i < 6) {
            glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
                    &r[0][0][0]);
            glEvalMesh2(type, 0, grid, 0, grid);
            glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
                    &s[0][0][0]);
            glEvalMesh2(type, 0, grid, 0, grid);
        }
    }
    glPopMatrix();
    glPopAttrib();
}
Beispiel #3
0
void Teapot(long grid)
{
    float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
    long i, j, k, l;

    teaList = 1;
    glNewList(teaList, GL_COMPILE);
    glPushMatrix();
    glRotatef(270.0, 1.0, 0.0, 0.0);
    for (i = 0; i < 10; i++) {
	for (j = 0; j < 4; j++) {
	    for (k = 0; k < 4; k++) {
		for (l = 0; l < 3; l++) {
		    p[j][k][l] = cpData[patchData[i][j*4+k]][l];
		    q[j][k][l] = cpData[patchData[i][j*4+(3-k)]][l];
		    if (l == 1) {
			q[j][k][l] *= -1.0;
		    }
		    if (i < 6) {
			r[j][k][l] = cpData[patchData[i][j*4+(3-k)]][l];
			if (l == 0) {
			    r[j][k][l] *= -1.0;
			}
			s[j][k][l] = cpData[patchData[i][j*4+k]][l];
			if (l == 0) {
			    s[j][k][l] *= -1.0;
			}
			if (l == 1) {
			    s[j][k][l] *= -1.0;
			}
		    }
		}
	    }
	}
	glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &p[0][0][0]);
	glEnable(GL_MAP2_VERTEX_3);
	glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
	glEvalMesh2(GL_FILL, 0, grid, 0, grid);
	glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &q[0][0][0]);
	glEvalMesh2(GL_FILL, 0, grid, 0, grid);
	if (i < 6) {
	    glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &r[0][0][0]);
	    glEvalMesh2(GL_FILL, 0, grid, 0, grid);
	    glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &s[0][0][0]);
	    glEvalMesh2(GL_FILL, 0, grid, 0, grid);
	}
    }
    glDisable(GL_MAP2_VERTEX_3);
    glPopMatrix();
    glEndList();
}
Beispiel #4
0
void Ppatch::draw(){
	int font;
	glGetIntegerv(GL_FRONT_FACE, &font);

	glEnable(GL_CW);
	glEnable(GL_AUTO_NORMAL);

	if(order==1){
		GLfloat grid_1_2[4][2] = {
			{0.0, t}, {s,t},
			{0.0, 0.0}, {s, 0.0}};

			glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2 ,0.0, 1.0, 6, 2, &grid_1[0][0]);
			glMap2f(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2,0.0, 1.0, 4, 2,  &grid_1_2[0][0]);
	}else if(order==2){
		GLfloat grid_2_2[9][2] = {
			{0.0,t}, {s/2, t},{s,t},
			{0.0,t/2},{s/2, t/2},{s, t/2},
			{0.0,0.0},{s/2,0.0},{s,0.0}};

			glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 3 ,0.0, 1.0, 9, 3, &grid_2[0][0]);
			glMap2f(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 3 ,0.0, 1.0, 6, 3,  &grid_2_2[0][0]);
	}else if(order==3){
		GLfloat grid_3_3[16][2] = {
			{0.0,t}, {s/3, t},{2*s/3,t},{s,t},
			{0.0,2*t/3},{s/3,2*t/3},{2*s/3,2*t/3},{s,2*t/3},
			{0.0,t/3},{s/3,t/3},{2*s/3,t/3},{s,t/3},
			{0.0,0.0},{s/3,0.0},{2*s/3,0.0},{s,0.0}};

			glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4 ,0.0, 1.0, 12, 4, &grid_3[0][0]);
			glMap2f(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 4 ,0.0, 1.0, 8, 4,  &grid_3_3[0][0]);
	}

	glEnable(GL_MAP2_VERTEX_3);
	glEnable(GL_MAP2_NORMAL);
	glEnable(GL_MAP2_TEXTURE_COORD_2);

	glMapGrid2f(partsU, 0.0,1.0, partsV, 0.0,1.0);

	if(compute=="line"){
		glEvalMesh2(GL_LINE, 0,partsU, 0,partsV);
	}else if(compute=="point"){
		glEvalMesh2(GL_POINT, 0,partsU, 0,partsV);
	}else if(compute=="fill"){
		glEvalMesh2(GL_FILL, 0,partsU, 0,partsV);
	}
	glEnable(font);
}
Beispiel #5
0
void Plane::draw ()
{
    glEnable (GL_AUTO_NORMAL);
    glPushMatrix ();
	terrainAppearance->apply();
	glTranslated(25,0,25);
			glScaled(50,1.5,50);	
    glMap2f (GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2, 0.0, 1.0, 6, 2, &controlpoints[0][0]);
    glMap2f(GL_MAP2_COLOR_4,  0.0, 1.0, 4, 2,  0.0, 1.0, 8, 2,  &colorpoints[0][0]);
	glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2,  0.0, 1.0, 4, 2,  &textpoints[0][0]);
    
    glEnable (GL_MAP2_VERTEX_3);
    glEnable (GL_MAP2_NORMAL);
    glEnable(GL_MAP2_COLOR_4);
    glEnable(GL_MAP2_TEXTURE_COORD_2);

    //glEnable(GL_TEXTURE_2D);
    //glBindTexture(GL_TEXTURE_2D, 1);
    glMapGrid2f (parts, 0.0, 1.0, parts, 0.0, 1.0);

    glEvalMesh2 (GL_FILL, 0, parts, 0, parts);
    //glDisable(GL_TEXTURE_2D);
    glPopMatrix ();

}
Beispiel #6
0
void Plane::draw(float s, float t)
{
	glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2,  0.0, 1.0, 6, 2,  &ctrlpoints[0][0]);
	glMap2f(GL_MAP2_NORMAL,   0.0, 1.0, 3, 2,  0.0, 1.0, 6, 2,  &nrmlcompon[0][0]);
	glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2,  0.0, 1.0, 4, 2,  &textpoints[0][0]);

	glEnable(GL_MAP2_VERTEX_3);
	glEnable(GL_MAP2_NORMAL);
	glEnable(GL_MAP2_TEXTURE_COORD_2);

	glMapGrid2f(nDivisions, 0.0,1.0, nDivisions, 0.0,1.0); 

	glEnable(GL_LIGHTING);
	glEnable(GL_COLOR_MATERIAL);
	glEnable(GL_TEXTURE_2D);

	glEvalMesh2(GL_FILL, 0,nDivisions, 0,nDivisions);

	glColor3f(1.0, 1.0, 0.0);
	for (int i = 0; i < 4; i++)
	{
		glRasterPos3f(ctrlpoints[i][0],ctrlpoints[i][1],ctrlpoints[i][2]+0.5);
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '0'+i);
	}

	glDisable(GL_TEXTURE_2D);
	glDisable(GL_COLOR_MATERIAL);
}
void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glEvalMesh2(GL_FILL, 0, 20, 0, 20);
    glFlush();
}
Beispiel #8
0
void
evaluateGrid(void)
{
  glColor3f(1.0, 1.0, 1.0);
  glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, uSize, 0, 1, uSize * 3, vSize, grid);
  glEvalMesh2(GL_LINE, 0, gridSize, 0, gridSize);
}
void beziertexturesurface::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glEvalMesh2(GL_FILL, 0, 20, 0, 20);
    glFlush();
}
Beispiel #10
0
/***************************************************
 * 用求值器的方式渲染水波纹
 **************************************************/
void drawWave1(void)
{
  int i, j, k;
  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      for (k = 0; k < 90; k++) {
      }
    }
  }
   
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glMaterialfv(GL_FRONT, GL_DIFFUSE, wave_diffuse);
  glMaterialfv(GL_FRONT, GL_SPECULAR, wave_specular);
  glMaterialfv(GL_FRONT, GL_SHININESS, wave_shininess);

  glEnable(GL_MAP2_VERTEX_3);
  if (du % 2 == 0) {
    glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3 * ORDER * 2, 2 * ORDER,
	    0, 1, 3, 2 * ORDER, &ctlPoints[0][0][0]);
  } else {
    glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3 * ORDER * 2, 2 * ORDER,
	    0, 1, 3, 2 * ORDER, &ctlPoints1[0][0][0]);
  }
  glMapGrid2f(20, 0, 1, 20, 0, 1);
  glEvalMesh2(GL_FILL, 0, 20, 0, 20);
  glPopMatrix();
}
Beispiel #11
0
static void _bezier_patch(
		GLint grid,
		GLenum type,
		int num,
		float(*vertices)[3],
		int(*patches)[16])
{
	float p[16][3];
	int i, k, l;

	glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
	glEnable(GL_AUTO_NORMAL);
	glEnable(GL_NORMALIZE);
	glEnable(GL_MAP2_VERTEX_3);
	glEnable(GL_MAP2_TEXTURE_COORD_2);

	for (i = 0; i < num; ++i)
	{
		for (k = 0; k < 16; ++k)
		{
			for (l = 0; l < 3; ++l)
				p[k][l] = vertices[patches[i][k]][l];
		}

		glMap2f(GL_MAP2_TEXTURE_COORD_2, 0.f, 1.f, 2, 2, 0.f, 1.f, 4, 2,
				&tex[0][0][0]);
		glMap2f(GL_MAP2_VERTEX_3, 0.f, 1.f, 3, 4, 0.f, 1.f, 12, 4, &p[0][0]);
		glMapGrid2f(grid, 0.f, 1.f, grid, 0.f, 1.f);
		glEvalMesh2(type, 0, grid, 0, grid);
	}

	glPopAttrib();
}
//Called to draw scene
void RenderScene(void)
{
	//Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT);
	
	glColor3f(redC, greenC, blueC);
	//Save the modelview matrix stack
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	//Rotate the mesh around to make it easier to see
	//if(count%3==0)
	//glRotatef(rot++, 1.0f, 1.0f, 0.0f);
	//else if (count%3==1)
	//glRotatef(rot++, 0.0f, 1.0f, 0.0);
//	else
//		glRotatef(rot++, 0.0f, 0.0f, 1.0f);

	//if(rot>=100) rot=0;
	//if(count>=30) count=0;

	//glRotatef(10.0f, 1.0f, 1.0f, 1.0f);


	//Sets up the Bezier
	//This actually only needs to be called once and could go in
	//the setup function
	glMap2f(GL_MAP2_VERTEX_3, //tYPE OF data generated
		0.0f,   //lower u range
		10.0f, //upper u range
		3,   //distance between points in the data
		4,   //dimension in u direction (order)
		0.0f,   //Lower v range
		10.0f, //Upper v range
		12,    //Distance betwen points in the data
		4,   //Dimension in v direction(order)
		&ctrlPoints[0][0][0]);   //array of control points
		
	//Enable the evaluator
	glEnable(GL_MAP2_VERTEX_3);
	glRotatef(10.0f, 1.0f, 1.0f, 0.0f);
	//use higher level functions to mapto a grid, then evaluate the entire thing.

	//Map a grid of 10 points from 0 to 10
	glMapGrid2f(10, 0.0f, 10.0f, 10, 0.0f, 10.0f);

	
	//Evaluate the grid, using lines
	glEvalMesh2(GL_FILL, 0, 10, 0, 10);
	//glEnable(GL_AUTO_NORMAL);

	//Draw the control points
	DrawPoints();

	glPopMatrix();

	//Display the image
	glutSwapBuffers();
}
Beispiel #13
0
void ScenePatch::draw()
{
	glPushMatrix();
	int frontFace;
	glGetIntegerv(GL_FRONT_FACE,&frontFace);
	//glEnable(GL_CW);
	glFrontFace(GL_CW);
	if(order==1)
	{
		glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2,  0.0, 1.0, 6, 2,  &cntPoints1[0][0]);
		glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2,  0.0, 1.0, 4, 2,  &textPoints1[0][0]);
		glEnable(GL_MAP2_VERTEX_3);
		glEnable(GL_AUTO_NORMAL);
		glEnable(GL_MAP2_TEXTURE_COORD_2);
		glMapGrid2f(partsU, 0.0,1.0, partsV, 0.0,1.0); 
		glEvalMesh2(drawmode, 0,partsU, 0,partsV);	
	}

	else if(order==2)
	{
		glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 3,  0.0, 1.0, 9, 3,  &cntPoints2[0][0]);
		glMap2f(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 3,  0.0, 1.0, 6, 3, &textPoints2[0][0]);
		glEnable(GL_MAP2_VERTEX_3);
		glEnable(GL_AUTO_NORMAL);
		glEnable(GL_MAP2_TEXTURE_COORD_2);
		glMapGrid2f(partsU, 0.0,1.0, partsV, 0.0,1.0); 
		glEvalMesh2(drawmode, 0,partsU, 0,partsV);	
		
	}

	else if(order==3)
	{
		glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4,  0.0, 1.0, 12, 4,  &cntPoints3[0][0]);
		glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 4,  0.0, 1.0, 8, 4,  &textPoints3[0][0]);
		glEnable(GL_MAP2_VERTEX_3);
		glEnable(GL_AUTO_NORMAL);
		glEnable(GL_MAP2_TEXTURE_COORD_2);
		glMapGrid2f(partsU, 0.0,1.0, partsV, 0.0,1.0); 
		glEvalMesh2(drawmode, 0,partsU, 0,partsV);	
	}

	//glEnable(frontFace);
	glFrontFace(frontFace);
	glPopMatrix();
}
void display(void)
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glPushMatrix();
   glRotatef(85.0, 1.0, 1.0, 1.0);
   glEvalMesh2(GL_FILL, 0, 20, 0, 20);
   glPopMatrix();
   glFlush();
}
Beispiel #15
0
void Sample_12_4::draw()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
    glRotatef(85.0, 1.0, 1.0, 1.0);
    glColor3f(1.0, 1.0, 1.0);
    glEvalMesh2(GL_FILL, 0, 20, 0, 20);
    glPopMatrix();
}
Beispiel #16
0
void Draw::drawBezier (int which)
{
	loadBezier(which);

	glPushMatrix();
	  glEvalMesh2(GL_FILL, 0, 20, 0, 20);

	glPopMatrix();
}
Beispiel #17
0
void __glXDisp_EvalMesh2(GLbyte *pc)
{
	glEvalMesh2( 
		*(GLenum   *)(pc + 0),
		*(GLint    *)(pc + 4),
		*(GLint    *)(pc + 8),
		*(GLint    *)(pc + 12),
		*(GLint    *)(pc + 16)
	);
}
Beispiel #18
0
void Plane::draw(float s = 1, float t =1){
	// INICIALIZACOES RELACIONADAS COM OS "EVALUATORS"

	// declaram-se quatro interpoladores, de coordenadas, de
	//     normais, de cores e de texturas:
	// o parâmetro de controlo dos interpoladors varia de 0 a 1,
	//     tanto em U como em V
	// os strides (ordem de visita no array de dados final) são:
	//     3 e 6 para o interpol. de coord. (respectivamente U e V)
	//     3 e 6 para o interpol. de normais (respectivamente U e V)
	//     4 e 8 para o interpolador de cores (respectivamente U e V)
	//     2 e 4 para o interpolador de texturas (respectivamente U e V)
	// a interpolação é linear (de grau 1) pelo que se coloca o
	//     valor "2" (grau + 1) nos quatro casos
	
	glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2, 0.0, 1.0, 3*2, 2,  &ctrlpoints[0][0]);
	
	glMap2f(GL_MAP2_NORMAL,   0.0, 1.0, 3, 2, 0.0, 1.0, 3*2, 2,  &nrmlcompon[0][0]);
	
	glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2, 0.0, 1.0, 2*2, 2,  &textpoints[0][0]);

	// os interpoladores activam-se:
	glEnable(GL_MAP2_VERTEX_3);
	glEnable(GL_MAP2_NORMAL);
	glEnable(GL_MAP2_COLOR_4);
	glEnable(GL_MAP2_TEXTURE_COORD_2);

	// para este conjunto de interpoladores:
	//    na direccao U, serao efectuadas divisoes em 40 passos
	//        quando a variável U varia de 0 a 1
	//    na direccao V, serao efectuadas divisoes em 60 passos
	//        quando a variável U varia de 0 a 1
	glMapGrid2f(parts, 0.0, 1.0, parts, 0.0, 1.0); 

	
	// SEGUE-SE EXEMPLO DE UTILIZACAO DE "EVALUATORS"
	//glShadeModel(GL_SMOOTH);					// GL_FLAT, GL_SMOOTH
	//glEnable(GL_LIGHTING);
	//glEnable(GL_COLOR_MATERIAL);
	//glEnable(GL_TEXTURE_2D);


	glEvalMesh2(GL_FILL, 0, parts, 0, parts);		// GL_POINT, GL_LINE, GL_FILL
	//glEvalMesh2(GL_FILL, 10,30, 20,40);	// poligono incompleto...
	//glEvalMesh2(GL_FILL, -10,50, -20,70);	// ...ou "transbordante"
	// NOTA: os 4 ultimos parametros da funcao glEvalMesh2() nao sao 
	//		 coordenadas mas sim indices de passos (do passo -10
	//		 ao passo 50; do passo -20 ao passo 70...

	//glDisable(GL_TEXTURE_2D);
	//glDisable(GL_COLOR_MATERIAL);

	
	glDisable(GL_AUTO_NORMAL);
}
Beispiel #19
0
void CSceneNodeAABB::DrawFace(const FixedArray<vector3,4> &r,unsigned int divA,unsigned int divB) const{
	glPushAttrib(GL_ALL_ATTRIB_BITS);
	glEnable(GL_MAP2_VERTEX_3);
	glEnable(GL_AUTO_NORMAL);
	glMap2f( GL_MAP2_VERTEX_3,0.0f,1.0f,3,2,0.0f,1.0f,6,2,(GLfloat*)r.PtrBegin());
	GLenum err(glGetError());
	glMapGrid2f(divA,0,1,divB,0,1);
	err = glGetError();
	glEvalMesh2(GL_FILL,0,divA,0,divB);
	err = glGetError();
	glPopAttrib();
}
Beispiel #20
0
void render_surface(SURFACE *surface) {
  int i,j;
  // dibujo los parches de bezier
  glPushMatrix();
  glScalef(1.0,1.0,1.0);
  set_material(plane->material);
  for (i=0;i<8;i++) {
    for (j=0;j<8;j++) {
      GLfloat parche[4][4][3];
      bspline2bezier(surface,i,j,parche);
      glMap2f(GL_MAP2_VERTEX_3,
	      0.0,1.0,3,4,
	      0.0,1.0,12,4,
	      &parche[0][0][0]);
      glEnable(GL_MAP2_VERTEX_3);
      glEnable(GL_AUTO_NORMAL);
      glEnable(GL_NORMALIZE);
      glMapGrid2f(resolucion,0.0,1.0,
		  resolucion,0.0,1.0);
      // si estoy seleccionando entonces dibujo modo wireframe
      if (selected != -1 || wire_mode)
	glEvalMesh2(GL_LINE,0,resolucion,0,resolucion);
      else
	glEvalMesh2(GL_FILL,0,resolucion,0,resolucion);
    }
  }
  glPopMatrix();

  // pintar normal para ver que tal 
  POINT3D mipunto, minormal;
  calculateNormalNotRotated(surface,ball->position.u,ball->position.v,&mipunto,&minormal);
  glBegin(GL_LINES); 
  set_material(plane->material); 
  glVertex3f(mipunto.x,mipunto.y,mipunto.z); 
  glVertex3f(mipunto.x+5*minormal.x,mipunto.y+5*minormal.y,mipunto.z+5*minormal.z);  
  glEnd(); 

}
Beispiel #21
0
// Called to draw scene
void RenderScene(void)
    {
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT);

    // Save the modelview matrix stack
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();

    // Rotate the mesh around to make it easier to see
    glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
    glRotatef(60.0f, 1.0f, 0.0f, 0.0f);

    // Sets up the Bezier
    // This actually only needs to be called once and could go in
    // the setup function
    glMap2f(GL_MAP2_VERTEX_3,	// Type of data generated
    0.0f,						// Lower u range
    10.0f,						// Upper u range
    3,							// Distance between points in the data
    3,							// Dimension in u direction (order)
    0.0f,						// Lover v range
    10.0f,						// Upper v range
    9,							// Distance between points in the data
    3,							// Dimension in v direction (order)
    &ctrlPoints[0][0][0]);		// array of control points

    // Enable the evaluator
    glEnable(GL_MAP2_VERTEX_3);

    // Use higher level functions to map to a grid, then evaluate the
    // entire thing.

    // Map a grid of 10 points from 0 to 10
    glMapGrid2f(10,0.0f,10.0f,10,0.0f,10.0f);

    // Evaluate the grid, using lines
    glEvalMesh2(GL_LINE,0,10,0,10);

    // Draw the Control Points
    DrawPoints();

    // Restore the modelview matrix
    glPopMatrix();

    // Dispalay the image
    glutSwapBuffers();
    }
Beispiel #22
0
static void hugsprim_glEvalMesh2_20(HugsStackPtr hugs_root)
{
    HsWord32 arg1;
    HsInt32 arg2;
    HsInt32 arg3;
    HsInt32 arg4;
    HsInt32 arg5;
    arg1 = hugs->getWord32();
    arg2 = hugs->getInt32();
    arg3 = hugs->getInt32();
    arg4 = hugs->getInt32();
    arg5 = hugs->getInt32();
    glEvalMesh2(arg1, arg2, arg3, arg4, arg5);
    
    hugs->returnIO(hugs_root,0);
}
Beispiel #23
0
void ScenePlane::draw()
{
	glPushMatrix();

	int frontFace;
	glGetIntegerv(GL_FRONT_FACE,&frontFace);
	glFrontFace(GL_CW);

	glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2,  0.0, 1.0, 6, 2,  &ctrlPoints[0][0]);
	glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2,  0.0, 1.0, 4, 2,  &textPoints[0][0]);
	glEnable(GL_MAP2_VERTEX_3);
	glEnable(GL_AUTO_NORMAL);
	glEnable(GL_MAP2_TEXTURE_COORD_2);
	glMapGrid2f(part, 0.0,1.0, part, 0.0,1.0); 
	glEvalMesh2(GL_FILL, 0,part, 0,part);	

	glFrontFace(frontFace);
	glPopMatrix();
}
Beispiel #24
0
    void draw_local()
    {
        const int Nx = 8;
        const int Ny = 8;

        double Lx0=-0.5, Lx1=0.5, Ly0=-0.5, Ly1=0.5;

        const int sx = Ny;
        const int sy = 1;

        const double dx = (Lx1 - Lx0) / (Nx - 1);
        const double dy = (Ly1 - Ly0) / (Ny - 1);

        GLfloat *surfdata = (GLfloat*) malloc(Nx*Ny*3*sizeof(GLfloat));

        for (int i=0; i<Nx; ++i) {
            for (int j=0; j<Ny; ++j) {

                const double x = Lx0 + i*dx;
                const double y = Ly0 + j*dy;
                const double z = x*x + y*y;
                const int m = i*sx + j*sy;

                surfdata[3*m + 0] = x;
                surfdata[3*m + 1] = z;
                surfdata[3*m + 2] = y;
            }
        }

        for (int i=1; i<Nx-1; ++i) {
            for (int j=1; j<Ny-1; ++j) {

                const double x = Lx0 + i*dx;
                const double y = Ly0 + j*dy;
                const GLfloat *s = &surfdata[3*((i-1)*sx + (j-1)*sy)];

                glMap2f(GL_MAP2_VERTEX_3, x-dx, x+dx, 3*sx, 3, y-dy, y+dy, 3*sy, 3, s);
                glMapGrid2f(4, x-dx/2, x+dx/2, 4, y-dy/2, y+dy/2);
                glEvalMesh2(GL_LINE, 0, 4, 0, 4);
            }
        }
        free(surfdata);
    }
Beispiel #25
0
void Plane::draw(){

		glColor3f(1.0,1.0,1.0);
		glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2,  0.0, 1.0, 6, 2,  &ctrlpoints[0][0]);
		glMap2f(GL_MAP2_NORMAL,   0.0, 1.0, 3, 2,  0.0, 1.0, 6, 2,  &nrmlcompon[0][0]);

		glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2,  0.0, 1.0, 4, 2,  &texpoints[0][0]);

		// os interpoladores activam-se:
		glEnable(GL_MAP2_VERTEX_3);
		glEnable(GL_MAP2_NORMAL);

		glEnable(GL_MAP2_TEXTURE_COORD_2);

		glMapGrid2f(this->step, 0.0,1.0, this->step, 0.0,1.0);

		glEvalMesh2(GL_FILL, 0,this->step, 0,this->step);		// GL_POINT, GL_LINE, GL_FILL


}
Beispiel #26
0
    void draw_local()
    {
        const int sx = Ny;
        const int sy = 1;

        const double dx = (Lx1 - Lx0) / (Nx - 1);
        const double dy = (Ly1 - Ly0) / (Ny - 1);

        for (int i=1; i<Nx-1; ++i) {
            for (int j=1; j<Ny-1; ++j) {

                const double x = Lx0 + i*dx;
                const double y = Ly0 + j*dy;
                const GLfloat *s = &surfdata[3*((i-1)*sx + (j-1)*sy)];

                glMap2f(GL_MAP2_VERTEX_3, x-dx, x+dx, 3*sx, 3, y-dy, y+dy, 3*sy, 3, s);
                glMapGrid2f(1, x-dx/2, x+dx/2, 1, y-dy/2, y+dy/2);
                glEvalMesh2(GL_LINE, 0, 1, 0, 1);
            }
        }
    }
Beispiel #27
0
void Board::draw() {
	glPushMatrix();
	glEnable(GL_TEXTURE_2D);
	tex.apply();

	glScalef(13,1,13);


//	glColor3f(1.0,1.0,1.0);
	glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2,  0.0, 1.0, 6, 2,  &ctrlpoints[0][0]);
	glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2,  0.0, 1.0, 4, 2,  &texpoints[0][0]);
	// os interpoladores activam-se:
	glEnable(GL_MAP2_VERTEX_3);
	glEnable(GL_AUTO_NORMAL);
	glEnable(GL_MAP2_TEXTURE_COORD_2);

	glMapGrid2f(this->step, 0.0,1.0, this->step, 0.0,1.0);
	glEvalMesh2(GL_FILL, 0,this->step, 0,this->step);		// GL_POINT, GL_LINE, GL_FILL
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();

}
void Plane::draw()
{
    /** Applying the appearance */
    if (appearance != NULL)
        appearance->apply();

    GLint cull_face_mode;
    glGetIntegerv(GL_CULL_FACE_MODE, &cull_face_mode);

    if (glIsEnabled(GL_CULL_FACE))
        if (cull_face_mode == GL_FRONT)
            glCullFace(GL_BACK);
        else if (cull_face_mode == GL_BACK)
            glCullFace(GL_FRONT);
        else
            glCullFace(GL_FRONT_AND_BACK);
    
    /** Declaration of vertex and texture evaluators */
    glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2, 0.0, 1.0, 6, 2, &control_points[0][0]);
    glMap2f(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2, &texture_points[0][0]);

    /** Enables automatic calculation of normals */
    glEnable(GL_MAP2_NORMAL);
    glEnable(GL_AUTO_NORMAL);

    /** Enables the vertex and texture evaluators */
    glEnable(GL_MAP2_VERTEX_3);
    glEnable(GL_MAP2_TEXTURE_COORD_2);

    /** Defines the number of divisions of the grid */
    glMapGrid2f(divisions[0], 0.0, 1.0, divisions[1], 0.0, 1.0);

    /** Draw the whole thing */
    glEvalMesh2(GL_FILL, 0, divisions[0], 0, divisions[1]);

    
    if (glIsEnabled(GL_CULL_FACE))
        glCullFace(cull_face_mode);
}
Beispiel #29
0
void Pplane::draw()
{ 
	GLfloat grid[4][3] = {
		{-0.5,0.0, -0.5}, {0.5, 0.0, -0.5},
		{-0.5, 0.0, 0.5}, {0.5, 0.0, 0.5}};
		GLfloat grid2[4][3] = {
			{0.0, 1.0, 0.0}, {0.0, 1.0, 0.0},
			{0.0, 1.0, 0.0}, {0.0, 1.0, 0.0}};
			GLfloat grid3[4][2] = {
				{0.0, t}, {s,t}, 
				{0.0, 0.0}, {s, 0.0}};

				glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2,0.0, 1.0, 6, 2, &grid[0][0]);
				glMap2f(GL_MAP2_NORMAL, 0.0, 1.0, 3, 2, 0.0, 1.0, 6, 2, &grid2[0][0]);
				glMap2f(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2,0.0, 1.0, 4, 2,  &grid3[0][0]);

				glEnable(GL_MAP2_VERTEX_3);
				glEnable(GL_MAP2_NORMAL);
				glEnable(GL_MAP2_TEXTURE_COORD_2);

				glMapGrid2f(parts, 0.0,1.0, parts, 0.0,1.0); 
				glEvalMesh2(GL_FILL, 0,parts, 0,parts);
}
Beispiel #30
0
void Plane::draw()
{
	pair<float,float> coord;

	if(scene != NULL)
	{
		Data * mydata = (((YAFScene*) scene)->getData());
		coord = mydata->getCurrentTextureCoord();
	}
	else
	{
		coord.first = 1;
		coord.second = 1;
	}
	

	GLfloat textpoints[4][2] = {{ 0.0, 0.0},
	{ 0.0, 1.0 / coord.second}, 
	{ 1.0 / coord.first, 0.0},
	{ 1.0 / coord.first, 1.0 / coord.second} };

	glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2,  0.0, 1.0, 6, 2,  &ctrlpoints[0][0]);
	glMap2f(GL_MAP2_NORMAL,   0.0, 1.0, 3, 2,  0.0, 1.0, 6, 2,  &nrmlcompon[0][0]);
	glMap2f(GL_MAP2_TEXTURE_COORD_2,  0.0, 1.0, 2, 2,  0.0, 1.0, 4, 2,  &textpoints[0][0]);

	glEnable(GL_MAP2_VERTEX_3);
	glEnable(GL_MAP2_NORMAL);
	glEnable(GL_MAP2_TEXTURE_COORD_2);

	glMapGrid2f(partsU, 0.0,1.0, partsV, 0.0,1.0); 

	glEvalMesh2(GL_FILL, 0,partsU, 0,partsV);

	/*free(ctrlpoints);
	free(nrmlcompon);*/
}