Ejemplo n.º 1
0
/*
====================
OptimizeIsland

At this point, all needed vertexes are already in the
list, including any that were added at crossing points.

Interior and colinear vertexes will be removed, and
a new triangulation will be created.
====================
*/
static void OptimizeIsland( optIsland_t *island ) {
	// add space-filling fake edges so we have a complete
	// triangulation of a convex hull before optimization
	AddInteriorEdges( island );
	DrawEdges( island );

	// determine all the possible triangles, and decide if
	// the are filled or empty
	BuildOptTriangles( island );

	// remove interior vertexes that have filled triangles
	// between all their edges
	RemoveInteriorEdges( island );
	DrawEdges( island );

	ValidateEdgeCounts( island );

	// remove vertexes that only have two colinear edges
	CombineColinearEdges( island );
	CullUnusedVerts( island );
	DrawEdges( island );

	// add new internal edges between the remaining exterior edges
	// to give us a full triangulation again
	AddInteriorEdges( island );
	DrawEdges( island );

	// determine all the possible triangles, and decide if
	// the are filled or empty
	BuildOptTriangles( island );

	// make mapTri_t out of the filled optTri_t
	RegenerateTriangles( island );
}
Ejemplo n.º 2
0
void ModelType::DrawEdges(OBJEdge *theEdge)
{
   if (theEdge == NULL)
      return;

   Normalise_Vector(theEdge->lEdgeNorm);
   Normalise_Vector(theEdge->gEdgeNorm);

   glNormal3f(theEdge->lEdgeNorm.x, theEdge->lEdgeNorm.y, theEdge->lEdgeNorm.z);
   if (theEdge->lEdgeText >= 0)
      glTexCoord3f(tDispObj->objTexts[theEdge->lEdgeText].u, tDispObj->objTexts[theEdge->lEdgeText].v, tDispObj->objTexts[theEdge->lEdgeText].w);
   glVertex3d(tDispObj->objVerts[theEdge->lEdge].x, tDispObj->objVerts[theEdge->lEdge].y, tDispObj->objVerts[theEdge->lEdge].z);

   glNormal3f(theEdge->gEdgeNorm.x, theEdge->gEdgeNorm.y, theEdge->gEdgeNorm.z);
   if (theEdge->gEdgeText >= 0)
      glTexCoord3f(tDispObj->objTexts[theEdge->gEdgeText].u, tDispObj->objTexts[theEdge->gEdgeText].v, tDispObj->objTexts[theEdge->gEdgeText].w);
   glVertex3d(tDispObj->objVerts[theEdge->gEdge].x, tDispObj->objVerts[theEdge->gEdge].y, tDispObj->objVerts[theEdge->gEdge].z);

   DrawEdges(theEdge->smlNext);
   DrawEdges(theEdge->gtrNext);
}
Ejemplo n.º 3
0
void TestOLED()
{
	/* if your display isn't working, this is a good place to start -- see
	   if you can read the command register */
	TestReadStatus();

	EnableFill(true);

//	FindEdges();
	DrawEdges();
	DrawFullRect();
	ScrollDisplay();
//	DrawColorBars();
	FillScreenPixels();
	DrawCircles();
	
	TestReadPixel();
}
Ejemplo n.º 4
0
void NaDbSurface::InitDisplayList()
{
    //wire list
    wireList = glGenLists(1);
    glNewList(wireList, GL_COMPILE);
    DrawWired();
    glEndList();

    //edges list
    edgeList = glGenLists(1);
    glNewList(edgeList, GL_COMPILE);
    DrawEdges();
    glEndList();

    //shaded list
    shadList = glGenLists(1);
    glNewList(shadList, GL_COMPILE);
    DrawShaded();
    glEndList();
}
Ejemplo n.º 5
0
void ModelType::GenEdgeObj()
{
   for (int i = 0; i < numObjects; i++)
   {
      if (!tDispObj->mtrl[i].SmthType)
         break;

      cDispObj[i].hasEdges = true;
      cDispObj[i].EdgeList = glGenLists(1);
      glNewList(cDispObj[i].EdgeList, GL_COMPILE);

      glBegin(GL_LINES);
      {
         DrawEdges(tDispObj->group[i].objEdges);
      }
      glEnd();

      glEndList();
   }
}
Ejemplo n.º 6
0
void NaDbSurface::DefineDisplay()
{
    GLfloat bgcol[4];
    glGetFloatv(GL_COLOR_CLEAR_VALUE, bgcol);
    GLfloat  specref[] =  { 1.0f, 1.0f, 1.0f, 1.0f };
    // Enable Depth Testing
    glEnable(GL_DEPTH_TEST);


    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

    // Enable lighting
    glEnable(GL_LIGHTING);


    // Enable color tracking
    glEnable(GL_COLOR_MATERIAL);

    // Set Material properties to follow glColor values
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);

    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,specref);
    glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,128);

    glShadeModel(GL_SMOOTH);

    glEnable(GL_AUTO_NORMAL);
    glEnable(GL_NORMALIZE);

    if(displayMode == GLSHADED)
    {	
		glPushAttrib(GL_LIGHTING_BIT);
		ApplyMaterial();
		glEnable(GL_POLYGON_OFFSET_FILL);
		glPolygonOffset(8, 8);
		DrawShaded();	
		glDisable(GL_LIGHTING);
		glDisable(GL_COLOR_MATERIAL);
		glColor3ub(25, 25, 25);
		DrawEdges();
		glDisable(GL_POLYGON_OFFSET_FILL);
		glPopAttrib();
    }	
    else if(displayMode == GLWIREFRAME)
    {
		glPushAttrib(GL_LIGHTING_BIT);
		glDisable(GL_LIGHTING);
		glDisable(GL_COLOR_MATERIAL);
		glDisable(GL_DEPTH_TEST);
		glColor3ub(itsRed, itsGreen, itsBlue);
		DrawWired();
		glPopAttrib();
    }
    else if(displayMode == GLHLREMOVED)
    {	
		glPushAttrib(GL_LIGHTING_BIT);
		glDisable(GL_LIGHTING);
		glDisable(GL_COLOR_MATERIAL);
		glEnable(GL_DEPTH_TEST);

		glColor3f(bgcol[0], bgcol[1], bgcol[2]);
		glEnable(GL_POLYGON_OFFSET_FILL);
		glPolygonOffset(5, 5);
		DrawShaded();
		DrawWired();

		glDisable(GL_POLYGON_OFFSET_FILL);
		glPopAttrib();
    }
}
Ejemplo n.º 7
0
// Rajzolas, ha az alkalmazas ablak ervenytelenne valik, akkor ez a fuggveny hivodik meg
void onDisplay()
{
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);		// torlesi szin beallitasa
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // kepernyo torles

	glViewport(0, 0, screenWidth, screenHeight);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	gluPerspective(90,1.0,1.0,-200.0);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

    glTranslatef(X,Y,Z);
	
	glRotatef(CameraAngle,0.0,1.0,0.0);

	glEnable(GL_DEPTH_TEST);
	
	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);
	
	//glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
	
	glPushMatrix();
		glColor3f(0.0,0.0,1.0);
		glBegin(GL_POINTS);
		for(lmVector3D &Vertex : PyramidVertices)
		{
			glVertex3f(Vertex[0],Vertex[1],Vertex[2]);
		}
		glEnd();
		
		DrawEdges(Pyramid);
		
		glTranslatef(40,0,0);
		DrawFacesAlongSucc(Pyramid);
		
		glTranslatef(40,0,0);
		DrawFacesAlongPred(Pyramid);
	glPopMatrix();
	
	glPushMatrix();
		glColor3f(0.0,0.0,1.0);
		glBegin(GL_POINTS);
		for(lmVector3D &Vertex : HulyeVertices1)
		{
			glVertex3f(Vertex[0],Vertex[1],Vertex[2]);
		}
		glEnd();
		
		DrawEdges(HulyeAlakzat1);
		
		glTranslatef(40,0,0);
		DrawFacesAlongSucc(HulyeAlakzat1);
		
		glTranslatef(40,0,0);
		DrawFacesAlongPred(HulyeAlakzat1);
	glPopMatrix();
	
	glPushMatrix();
		glColor3f(0.0,0.0,1.0);
		glBegin(GL_POINTS);
		for(lmVector3D &Vertex : HulyeVertices2)
		{
			glVertex3f(Vertex[0],Vertex[1],Vertex[2]);
		}
		glEnd();
		
		DrawEdges(HulyeAlakzat2);
		
		glTranslatef(40,0,0);
		DrawFacesAlongSucc(HulyeAlakzat2);
		
		glTranslatef(40,0,0);
		DrawFacesAlongPred(HulyeAlakzat2);
	glPopMatrix();
	
    glutSwapBuffers();     				// Buffercsere: rajzolas vege
}
Ejemplo n.º 8
0
void onDisplay()
{
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);		// torlesi szin beallitasa
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // kepernyo torles

	glViewport(0, 0, screenWidth, screenHeight);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	gluPerspective(90,1.0,1.0,-200.0);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

    glTranslatef(X,Y,Z);
	
	glRotatef(CameraAngle,0.0,1.0,0.0);

	glEnable(GL_DEPTH_TEST);
	
	glDisable(GL_CULL_FACE);
	
	//glEnable(GL_CULL_FACE);
	//glCullFace(GL_BACK);
	
	//glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
	
	for(int i=0;i < NUM_TRIANGLES;i++)
	{
		glColor3f((float)i / (float) NUM_TRIANGLES,1.0,0.0);
		DrawTriangle(triangles[i]);
	}
	
	for(int i=0;i < NUM_TRIANGLES_2;i++)
	{
		glColor3f((float)i / (float) NUM_TRIANGLES_2,1.0,0.0);
		DrawTriangle(triangles2[i]);
	}
	
	for(int i=0;i < NUM_TRIANGLES_3;i++)
	{
		glColor3f((float)i / (float) NUM_TRIANGLES_3,1.0,0.0);
		DrawTriangle(triangles3[i]);
	}
	
	for(int i=0;i < NUM_TRIANGLES_4;i++)
	{
		glColor3f((float)i / (float) NUM_TRIANGLES_4,1.0,0.0);
		DrawTriangle(triangles4[i]);
	}
	
	for(int i=0;i < NUM_TRIANGLES_5;i++)
	{
		glColor3f((float)i / (float) NUM_TRIANGLES_5,1.0,0.0);
		DrawTriangle(triangles5[i]);
	}
	
	for(int i=0;i < NUM_TRIANGLES_6;i++)
	{
		glColor3f((float)i / (float) NUM_TRIANGLES_6,1.0,0.0);
		DrawTriangle(triangles6[i]);
	}
	
	int I = 0;
	for(const Q3Line &Line : Lines)
	{
		glColor3f(1.0,(float)I / (float) Lines.size(),0.0);
		I++;
		DrawLine(Line);
	}
	
	glColor3f(0.0,0.0,1.0);
	glBegin(GL_POINTS);
	for(lmVector3D &Vertex : Vertices)
	{
		glVertex3f(Vertex[0]/DOWNSCALE,Vertex[1]/DOWNSCALE,Vertex[2]/DOWNSCALE);
		
		std::cout << "[" << Vertex[0] << "," << Vertex[1] << "," << Vertex[2] <<  "]" << std::endl;
	}
	glEnd();
	
	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-200.0);
		
		glTranslatef(-1024.0,0.0,0.0);
		
		DrawEdges(Result);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-400.0);
		
		glTranslatef(-1024.0,0.0,0.0);
		
		DrawFacesAlongPred(Result);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-600.0);
		
		glTranslatef(-1024.0,0.0,0.0);
		
		DrawFacesAlongSucc(Result);
	glPopMatrix();
	
	I = 0;
	for(const Q3Line &Line : TeglaLines)
	{
		glColor3f(1.0,(float)I / (float) Lines.size(),0.0);
		I++;
		DrawLine(Line);
	}
	
	glColor3f(0.0,0.0,1.0);
	glBegin(GL_POINTS);
	for(lmVector3D &Vertex : TeglaVertices)
	{
		glVertex3f(Vertex[0]/DOWNSCALE,Vertex[1]/DOWNSCALE,Vertex[2]/DOWNSCALE);
		
		std::cout << "[" << Vertex[0] << "," << Vertex[1] << "," << Vertex[2] <<  "]" << std::endl;
	}
	glEnd();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-200.0);
		
		glTranslatef(-1024.0,0.0,0.0);
		
		DrawEdges(Tegla);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-400.0);
		
		glTranslatef(-1024.0,0.0,0.0);
		
		DrawFacesAlongPred(Tegla);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-600.0);
		
		glTranslatef(-1024.0,0.0,0.0);
		
		DrawFacesAlongSucc(Tegla);
	glPopMatrix();
	
	I = 0;
	for(const Q3Line &Line : HulyeLines)
	{
		glColor3f(1.0,(float)I / (float) Lines.size(),0.0);
		I++;
		DrawLine(Line);
	}
	
	glColor3f(0.0,0.0,1.0);
	glBegin(GL_POINTS);
	for(lmVector3D &Vertex : HulyeVertices)
	{
		glVertex3f(Vertex[0]/DOWNSCALE,Vertex[1]/DOWNSCALE,Vertex[2]/DOWNSCALE);
		
		std::cout << "[" << Vertex[0] << "," << Vertex[1] << "," << Vertex[2] <<  "]" << std::endl;
	}
	glEnd();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,200.0);
		
		glTranslatef(-1024.0,0.0,0.0);
		
		DrawEdges(Hulye);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,400.0);
		
		glTranslatef(-1024.0,0.0,0.0);
		
		DrawFacesAlongPred(Hulye);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,600.0);
		
		glTranslatef(-1024.0,0.0,0.0);
		
		DrawFacesAlongSucc(Hulye);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		//glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-100.0);
		
		//glTranslatef(-1024.0,0.0,0.0);
		
		DrawEdges(Pyramid);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		//glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-200.0);
		
		//glTranslatef(-1024.0,0.0,0.0);
		
		DrawFacesAlongPred(Pyramid);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		//glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-300.0);
		
		//glTranslatef(-1024.0,0.0,0.0);
		
		DrawFacesAlongSucc(Pyramid);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		//glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-100.0);
		
		glTranslatef(-128.0,0.0,0.0);
		
		DrawEdges(GyokerPyramid);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		//glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-200.0);
		
		glTranslatef(-128.0,0.0,0.0);
		
		DrawFacesAlongPred(GyokerPyramid);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		//glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-300.0);
		
		glTranslatef(-128.0,0.0,0.0);
		
		DrawFacesAlongSucc(GyokerPyramid);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		//glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-100.0);
		
		glTranslatef(-128.0,0.0,0.0);
		
		DrawEdges(GyokerHulye);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		//glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-300.0);
		
		glTranslatef(-128.0,0.0,0.0);
		
		DrawFacesAlongPred(GyokerHulye);
	glPopMatrix();
	
	glPushMatrix();
		glTranslatef(100,0,0);
		
		//glScalef(1.0/10.0,1.0/10.0,1.0/10.0);
		glTranslatef(0.0,0.0,-500.0);
		
		glTranslatef(-128.0,0.0,0.0);
		
		DrawFacesAlongSucc(GyokerHulye);
	glPopMatrix();
	
    glutSwapBuffers();
}