예제 #1
0
///helper function tells you how int elements are identical between two sets.
///This probably should be in a library... but its too special purpose
int SurfaceObject::countNumCommon(set_t set1, set_t set2)
{
	int i = 0;
	int result = 0;

	int s1 = size_set(set1);		
	int s2 = size_set(set2);
	set_t tempSet1 = set1;		
	set_t tempSet2 = set2;

	if(s2 > s1){ 
		tempSet1 = set2;
		tempSet2 = set1;
		s1 = size_set(set2);
		s2 = size_set(set1);
	}
	
	///now tempSet1 is always at least as large as tempset2.
	for(i = 0; i<size_set(tempSet2); i++){
		if( contains_set(tempSet1, tempSet2[i]) ){
			result++;
		}
	}
	
	return result;
}
예제 #2
0
GW_Game_Pancake::GW_Game_Pancake() :
    GW_GameEngine_VTech_Condor(EO_NONE, GO_HAVEITEM0|GO_HAVELEFT0|GO_HAVERIGHT1A|GO_HAVERIGHT6)
{
    gamepath_set("pancake");
    size_set(560, 372);

    // game screen position
    GW_PLATFORM_RECT(gr, 151, 52, 257, 192);
    gamerect_set(gr);

    // character
    data().
        position_change(PS_CHAR, 1, 177, 171)->
        position_change(PS_CHAR, 2, 262, 177)->
        position_change(PS_CHAR, 3, 306, 177);

    // item
    data().
        position_change(PS_ITEM, 0, 372, 117)->
        position_change(PS_ITEM, 1, 365, 106)->
        position_change(PS_ITEM, 2, 343, 103)->
        position_change(PS_ITEM, 3, 328, 114)->
        position_change(PS_ITEM, 4, 320, 130)->
        position_change(PS_ITEM, 5, 314, 148)->
        position_change(PS_ITEM, 6, 312, 166)->
        position_change(PS_ITEM, 7, 311, 179)->
        position_change(PS_ITEM, 8, 308, 156)->
        position_change(PS_ITEM, 9, 306, 136)->
        position_change(PS_ITEM, 10, 300, 119)->
        position_change(PS_ITEM, 11, 290, 104)->
        position_change(PS_ITEM, 12, 277, 115)->
        position_change(PS_ITEM, 13, 270, 131)->
        position_change(PS_ITEM, 14, 267, 148)->
        position_change(PS_ITEM, 15, 266, 165)->
        position_change(PS_ITEM, 16, 267, 178)->
        position_change(PS_ITEM, 17, 263, 156)->
        position_change(PS_ITEM, 18, 258, 136)->
        position_change(PS_ITEM, 19, 248, 118)->
        position_change(PS_ITEM, 20, 233, 132)->
        position_change(PS_ITEM, 21, 225, 149)->
        position_change(PS_ITEM, 22, 220, 165)->
        position_change(PS_ITEM, 23, 221, 178)->
        position_change(PS_ITEM, 24, 218, 156)->
        position_change(PS_ITEM, 25, 213, 140)->
        position_change(PS_ITEM, 26, 205, 131)->
        position_change(PS_ITEM, 27, 191, 137)->
        position_change(PS_ITEM, IDX_MISS_1, 219, 191)->
        position_change(PS_ITEM, IDX_MISS_2, 243, 189)->
        position_change(PS_ITEM, IDX_MISS_3, 306, 193);

    data().
        position_change(PS_ITEMLEFT, 0, 162, 117)->
        position_change(PS_ITEMLEFT, 1, 180, 138)->
        position_change(PS_ITEMLEFT, 2, 179, 129);

    // item right
    data().
        position_change(PS_ITEMRIGHT, 0, 335, 123)->
        position_change(PS_ITEMRIGHT, 1, 366, 163)->
        position_change(PS_ITEMRIGHT, 2, 370, 146)->
        position_change(PS_ITEMRIGHT, 3, 375, 146)->
        position_change(PS_ITEMRIGHT, 4, 360, 110)->
        position_change(PS_ITEMRIGHT, 5, 366, 129)->
        position_change(PS_ITEMRIGHT, 6, 366, 122);


    // numbers
    data().
        position_change(PS_NUMBER, 1, 253, 63)->
        position_change(PS_NUMBER, 2, 268, 63)->
        position_change(PS_NUMBER, 3, 288, 63)->
        position_change(PS_NUMBER, 4, 303, 63)->
        position_change(PS_SEMICOLON, 0, 283, 68);

    // miss
    data().
        position_change(PS_MISS, 1, 332, 63)->
        position_change(PS_MISS, 2, 347, 63)->
        position_change(PS_MISS, 3, 361, 63)->
        position_change(PS_MISS, 4, 375, 63)->
        position_change(PS_MISS, 5, 389, 63)->
        position_change(PS_MISS, 6, 333, 77)->
        position_change(PS_MISS, 7, 348, 77)->
        position_change(PS_MISS, 8, 362, 77)->
        position_change(PS_MISS, 9, 375, 77)->
        position_change(PS_MISS, 10, 389, 77);

    // options
    data().
        position_change(PS_GAMEA, 0, 155, 63)->
        position_change(PS_GAMEB, 0, 155, 79)->
        position_change(PS_ALARM, 0, 201, 79)->
        position_change(PS_BELL, 0, 182, 65)->
        position_change(PS_CHRONO, 0, 219, 79)->
        position_change(PS_DATE, 0, 233, 79)->
        position_change(PS_TIME1, 0, 224, 63)->
        position_change(PS_TIME2, 0, 201, 63)->
        position_change(PS_AM, 0, 317, 63)->
        position_change(PS_PM, 0, 317, 78);
}
예제 #3
0
void SurfaceObject::draw(bool drawPoints, bool drawLines, bool drawTransparent, bool pocketView, double * offset, double * c)
{
	int i = 0;
	int j = 0;
	int pt1, pt2, pt3;

	////Declare Materials
	GLfloat mat_solid[] = { 1.0, 1.0, 1.0, 1.0 };
	GLfloat mat_zero[] = { 0.0, 0.0, 0.0, 1.0 };
	GLfloat mat_transparent[] = { 0.2, 0.2, 0.2, 0.2 };
	GLfloat mat_emission[] = { 0.0, 0.0, 0.0, 1.0 };
	GLfloat mat_specular[] = { 0.1, 0.1, 0.1, 0.0 };
	GLfloat low_shininess[] = { .5 };

	float amb[] = {0.20f, 0.50f, 1.0f, 0.1f};
	float diff[] = {0.20f, 0.50f, 1.0f, 0.1f};
	float spec[] = {1.0f, 1.0f, 1.0f, 1.0f};
	float shine[] = {0.8 * 128.0f}; // The glass is very shiny

	double * cent = new double[3];
	cent[0] = 0; cent[1] = 0; cent[2] = 0;
	if(offset != NULL){
		delete[](cent);
		cent = offset;
	}

	///drawPoints
	if(drawPoints){
		glBegin(GL_POINTS);
		glColor3f(1.00000f, 1.00000f, 1.00000f);
		for(i = 0; i<numTriangles; i++){
			pt1 = triangles[3*i+0];
			pt2 = triangles[3*i+1];
			pt3 = triangles[3*i+2];
			glVertex3f( surfacePoints [3*pt1+0]-cent[0],surfacePoints [3*pt1+1]-cent[1],surfacePoints [3*pt1+2]-cent[2] );
			glVertex3f( surfacePoints [3*pt2+0]-cent[0],surfacePoints [3*pt2+1]-cent[1],surfacePoints [3*pt2+2]-cent[2] );
			glVertex3f( surfacePoints [3*pt3+0]-cent[0],surfacePoints [3*pt3+1]-cent[1],surfacePoints [3*pt3+2]-cent[2] );
		}
		glEnd();
	}
	if(drawLines){
		glBegin(GL_LINES);
		glColor3f(0.00000f, 1.00000f, 0.00000f);
		for(i = 0; i<numTriangles; i++){
			pt1 = triangles[3*i+0];
			pt2 = triangles[3*i+1];
			pt3 = triangles[3*i+2];
			glVertex3f( surfacePoints [3*pt1+0]-cent[0],surfacePoints [3*pt1+1]-cent[1],surfacePoints [3*pt1+2]-cent[2] );
			glVertex3f( surfacePoints [3*pt2+0]-cent[0],surfacePoints [3*pt2+1]-cent[1],surfacePoints [3*pt2+2]-cent[2] );
			glVertex3f( surfacePoints [3*pt2+0]-cent[0],surfacePoints [3*pt2+1]-cent[1],surfacePoints [3*pt2+2]-cent[2] );
			glVertex3f( surfacePoints [3*pt3+0]-cent[0],surfacePoints [3*pt3+1]-cent[1],surfacePoints [3*pt3+2]-cent[2] );
			glVertex3f( surfacePoints [3*pt3+0]-cent[0],surfacePoints [3*pt3+1]-cent[1],surfacePoints [3*pt3+2]-cent[2] );
			glVertex3f( surfacePoints [3*pt1+0]-cent[0],surfacePoints [3*pt1+1]-cent[1],surfacePoints [3*pt1+2]-cent[2] );
		}
		glEnd();
	}
	bool drawNormals = false;
	if(drawNormals){
		glColor3f(1.00000f, 1.00000f, 1.00000f);
		glBegin(GL_LINES);
		for(i = 0; i<numTriangles; i++){
			pt1 = triangles[3*i+0];
			pt2 = triangles[3*i+1];
			pt3 = triangles[3*i+2];
			double * p1 = new double[3];
			p1[0] = surfacePoints [3*pt1+0]-cent[0]; p1[1] = surfacePoints [3*pt1+1]-cent[1]; p1[2] = surfacePoints [3*pt1+2]-cent[2];
			double * p2 = new double[3];
			p2[0] = surfacePoints [3*pt2+0]-cent[0]; p2[1] = surfacePoints [3*pt2+1]-cent[1]; p2[2] = surfacePoints [3*pt2+2]-cent[2];
			double * p3 = new double[3];
			p3[0] = surfacePoints [3*pt3+0]-cent[0]; p3[1] = surfacePoints [3*pt3+1]-cent[1]; p3[2] = surfacePoints [3*pt3+2]-cent[2];
			double * v1 = new double[3];
			v1[0] = p2[0] - p1[0]; v1[1] = p2[1] - p1[1]; v1[2] = p2[2] - p1[2];
			double * v2 = new double[3];
			v2[0] = p3[0] - p1[0]; v2[1] = p3[1] - p1[1]; v2[2] = p3[2] - p1[2];
			double * cross = crossProd(v1, v2);
			double * norm = normalizeVector(cross);
			double * avg = new double[3];
			avg[0] = (p1[0]+p2[0]+p3[0])/3; avg[1] = (p1[1]+p2[1]+p3[1])/3; avg[2] = (p1[2]+p2[2]+p3[2])/3;
			double * newPt = new double[3];
			newPt[0] = avg[0] + norm[0];
			newPt[1] = avg[1] + norm[1];
			newPt[2] = avg[2] + norm[2];
			glVertex3f(   avg[0],   avg[1],   avg[2] );
			glVertex3f( newPt[0], newPt[1], newPt[2] );
			//printf("vectorSize: %lf\n", vectorSize( newPt[0]-avg[0], newPt[1]-avg[1], newPt[2]-avg[2]) ); 
			delete[](p1); delete[](p2); delete[](p3); delete[](v1); delete[](v2); 
			delete[](cross); delete[](norm); delete[](avg); delete[](newPt);
		}
		glEnd();
	}
	
	//set material properties
	if(drawTransparent == true){
		glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);

		glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, amb);
		glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);
		glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
		glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shine);

		glEnable(GL_BLEND);
		glDepthMask(GL_FALSE);
//		glBlendFunc(GL_SRC_ALPHA, GL_ONE);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}
	else{
		glMaterialfv(GL_FRONT, GL_EMISSION, mat_zero);
		glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_solid);
	}

	double * color = new double[3];
	if(c != NULL){ color[0] = c[0]; color[1] = c[1]; color[2] = c[2]; }
	else{
		if(drawTransparent){ color[0] = 0.5f; color[1] = 0.5f; color[2] = 0.0f; }
		else{ color[0] = 0.0f; color[1] = 0.5f; color[2] = 0.5f; }
	}

	set_t debug_triangleSet = alloc_set(0);
//	debug_triangleSet = put_set(debug_triangleSet, 37);
//	debug_triangleSet = put_set(debug_triangleSet, 38);
//	debug_triangleSet = put_set(debug_triangleSet, 39);
//	debug_triangleSet = put_set(debug_triangleSet, 213);
//	debug_triangleSet = put_set(debug_triangleSet, 215);

	///render the triangles
	glBegin(GL_TRIANGLES);
	for(i = 0; i<numTriangles; i++){
		pt1 = triangles[3*i+0];	pt2 = triangles[3*i+1];	pt3 = triangles[3*i+2];
		double s = 1.00;	///surface geometry hack - scales up slightly so there isnt so much z-buffer collision.

//		if(i == 215){ glColor4f(1, 0, 0, .5); }

		if(drawTransparent){///surface geometry hack
			glColor4f(color[0], color[1], color[2], .5);
			if( contains_set(debug_triangleSet, i) ){ glColor4f(1, 0, 0, .5); }
			glNormal3f( surfaceNormals[3*pt1+0],		surfaceNormals[3*pt1+1],		surfaceNormals[3*pt1+2] );
			glVertex3f( s*(surfacePoints [3*pt1+0]-cent[0]),s*(surfacePoints [3*pt1+1]-cent[1]),s*(surfacePoints [3*pt1+2]-cent[2]) );
			glNormal3f( surfaceNormals[3*pt2+0],		surfaceNormals[3*pt2+1],		surfaceNormals[3*pt2+2] );
			glVertex3f( s*(surfacePoints [3*pt2+0]-cent[0]),s*(surfacePoints [3*pt2+1]-cent[1]),s*(surfacePoints [3*pt2+2]-cent[2]) );
			glNormal3f( surfaceNormals[3*pt3+0],		surfaceNormals[3*pt3+1],		surfaceNormals[3*pt3+2] );
			glVertex3f( s*(surfacePoints [3*pt3+0]-cent[0]),s*(surfacePoints [3*pt3+1]-cent[1]),s*(surfacePoints [3*pt3+2]-cent[2]) );
		}
		else{
			if(colorFlag == true){
				glColor4f( colors[3*pt1+0],		colors[3*pt1+1],		colors[3*pt1+2], 1.0 );
				glNormal3f( surfaceNormals[3*pt1+0],		surfaceNormals[3*pt1+1],		surfaceNormals[3*pt1+2] );
				glVertex3f( surfacePoints [3*pt1+0]-cent[0],surfacePoints [3*pt1+1]-cent[1],surfacePoints [3*pt1+2]-cent[2] );
				glColor4f( colors[3*pt2+0],		colors[3*pt2+1],		colors[3*pt2+2], 1.0 );
				glNormal3f( surfaceNormals[3*pt2+0],		surfaceNormals[3*pt2+1],		surfaceNormals[3*pt2+2] );
				glVertex3f( surfacePoints [3*pt2+0]-cent[0],surfacePoints [3*pt2+1]-cent[1],surfacePoints [3*pt2+2]-cent[2] );
				glColor4f( colors[3*pt3+0],		colors[3*pt3+1],		colors[3*pt3+2], 1.0 );
				glNormal3f( surfaceNormals[3*pt3+0],		surfaceNormals[3*pt3+1],		surfaceNormals[3*pt3+2] );
				glVertex3f( surfacePoints [3*pt3+0]-cent[0],surfacePoints [3*pt3+1]-cent[1],surfacePoints [3*pt3+2]-cent[2] );
			}
			else{
				glColor4f(color[0], color[1], color[2], 1.0);
				if( contains_set(debug_triangleSet, i) ){ glColor4f(1, 0, 0, 1); }
				glNormal3f( surfaceNormals[3*pt1+0],		surfaceNormals[3*pt1+1],		surfaceNormals[3*pt1+2] );
				glVertex3f( surfacePoints [3*pt1+0]-cent[0],surfacePoints [3*pt1+1]-cent[1],surfacePoints [3*pt1+2]-cent[2] );
				glNormal3f( surfaceNormals[3*pt2+0],		surfaceNormals[3*pt2+1],		surfaceNormals[3*pt2+2] );
				glVertex3f( surfacePoints [3*pt2+0]-cent[0],surfacePoints [3*pt2+1]-cent[1],surfacePoints [3*pt2+2]-cent[2] );
				glNormal3f( surfaceNormals[3*pt3+0],		surfaceNormals[3*pt3+1],		surfaceNormals[3*pt3+2] );
				glVertex3f( surfacePoints [3*pt3+0]-cent[0],surfacePoints [3*pt3+1]-cent[1],surfacePoints [3*pt3+2]-cent[2] );
			}
		}
	}
	for(i = 0; i<numTriangles; i++){
		double s = 1.00;	///surface geometry hack - scales up slightly so there isnt so much z-buffer collision.
		pt1 = triangles[3*i+0];	pt2 = triangles[3*i+1];	pt3 = triangles[3*i+2];
		if(pocketView){/// we render both sides by drawing backwards triangles too.
			//glColor4f(color[0]/2, color[1]/2, color[2]/2, 1.0);
			if(drawTransparent){///surface geometry hack
				glColor4f(color[0], color[1], color[2], .3);
				if( contains_set(debug_triangleSet, i) ){ glColor4f(1, 0, 0, .5); }
				glNormal3f(   -surfaceNormals[3*pt1+0],	          -surfaceNormals[3*pt1+1],           -surfaceNormals[3*pt1+2] );
				glVertex3f( s*(surfacePoints [3*pt1+0]-cent[0]),s*(surfacePoints [3*pt1+1]-cent[1]),s*(surfacePoints [3*pt1+2]-cent[2]) );
				glNormal3f(   -surfaceNormals[3*pt3+0],	          -surfaceNormals[3*pt3+1],           -surfaceNormals[3*pt3+2] );
				glVertex3f( s*(surfacePoints [3*pt3+0]-cent[0]),s*(surfacePoints [3*pt3+1]-cent[1]),s*(surfacePoints [3*pt3+2]-cent[2]) );
				glNormal3f(   -surfaceNormals[3*pt2+0],	          -surfaceNormals[3*pt2+1],	          -surfaceNormals[3*pt2+2] );
				glVertex3f( s*(surfacePoints [3*pt2+0]-cent[0]),s*(surfacePoints [3*pt2+1]-cent[1]),s*(surfacePoints [3*pt2+2]-cent[2]) );
			}
			else{
				glColor4f(color[0]/4, color[1]/4, color[2]/4, 1.0);
				glColor3f(0.00000f, 0.250000f, 0.2500000f);
				if( contains_set(debug_triangleSet, i) ){ glColor4f(1, 0, 0, 1); }
				glNormal3f( surfaceNormals[3*pt1+0],		surfaceNormals[3*pt1+1],		surfaceNormals[3*pt1+2] );
				glVertex3f( surfacePoints [3*pt1+0]-cent[0],surfacePoints [3*pt1+1]-cent[1],surfacePoints [3*pt1+2]-cent[2] );
				glNormal3f( surfaceNormals[3*pt3+0],		surfaceNormals[3*pt3+1],		surfaceNormals[3*pt3+2] );
				glVertex3f( surfacePoints [3*pt3+0]-cent[0],surfacePoints [3*pt3+1]-cent[1],surfacePoints [3*pt3+2]-cent[2] );
				glNormal3f( surfaceNormals[3*pt2+0],		surfaceNormals[3*pt2+1],		surfaceNormals[3*pt2+2] );
				glVertex3f( surfacePoints [3*pt2+0]-cent[0],surfacePoints [3*pt2+1]-cent[1],surfacePoints [3*pt2+2]-cent[2] );
			}
			
		
		}

	}
	glEnd();

	free_set(debug_triangleSet);

	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	if( highlights != NULL ){
		glBegin(GL_POINTS);
		for(i = 0; i<numPoints; i++){
			if(contains_set(highlights, i)){
				//glPushMatrix();
				glVertex3f( surfacePoints[3*i+0]-cent[0], surfacePoints[3*i+1]-cent[1], surfacePoints[3*i+2]-cent[2] );
				//glTranslatef(surfacePoints[3*i+0], surfacePoints[3*i+1], surfacePoints[3*i+2] );
				//glutSolidSphere  ( .3, 4, 4) ;
				//glPopMatrix();
			}
		}
		glEnd();
	}
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	if(edges != NULL && drawTransparent == false){
		glBegin(GL_LINES);
		for(i = 0; i<size_set(edges); i++){
			set_t tempSet = (set_t) mapsto_set(edges, edges[i]);
			for(j = 0; j<size_set(tempSet); j++){
				if(tempSet[j] > edges[i]){
					glVertex3f( surfacePoints[3*edges[i]+0]-cent[0], surfacePoints[3*edges[i]+1]-cent[1], surfacePoints[3*edges[i]+2]-cent[2] );
					glVertex3f( surfacePoints[3*tempSet[j]+0]-cent[0], surfacePoints[3*tempSet[j]+1]-cent[1], surfacePoints[3*tempSet[j]+2]-cent[2] );
				}
			}
		}
		glEnd();
	}



	///fix material properties
	if(drawTransparent == true){
		glDepthMask(GL_TRUE);
		glDisable(GL_BLEND);
	}

	if(offset == NULL){
		delete[](cent);
	}
	delete[](color);

}
예제 #4
0
///identifies edges which are not surrounded by triangles - locations where the surface
///is non manifold.
///This turns the edges variable non-null.
//
//NOTE: THIS FUNCTION IS CURRENTLY BROKEN
//
//
void SurfaceObject::identifyNonManifoldEdges(void)
{
	int i = 0;
	int j = 0;
	
	///create a set of sets to hold non-manifold edges
	set_t nonManifold = alloc_set(SP_MAP);
		
	///Create a set of sets to remember which triangles associate with which vertex.  Allocate that here.
	set_t verticesMappingToTris = alloc_set(SP_MAP);
	for(i = 0; i<numPoints; i++){
		set_t tris = alloc_set(0);
		verticesMappingToTris = associate_set(verticesMappingToTris, i, tris);
	}

	///associate each vertex with a list of triangles it is part of.
	///we do this by interating through all triangles
	set_t tris;
	for(i = 0; i<numTriangles; i++){
		tris = (set_t) mapsto_set(verticesMappingToTris, triangles[3*i+0]);
		tris = put_set(tris, i);
		verticesMappingToTris = associate_set(verticesMappingToTris, triangles[3*i+0], tris);

		tris = (set_t) mapsto_set(verticesMappingToTris, triangles[3*i+1]);
		tris = put_set(tris, i);
		verticesMappingToTris = associate_set(verticesMappingToTris, triangles[3*i+1], tris);
		
		tris = (set_t) mapsto_set(verticesMappingToTris, triangles[3*i+2]);
		tris = put_set(tris, i);
		verticesMappingToTris = associate_set(verticesMappingToTris, triangles[3*i+2], tris);
	}

	int min = 100000;
	int max = 0;
	int counter = 0;
	for(i = 0; i<size_set(verticesMappingToTris); i++){
		tris = (set_t) mapsto_set(verticesMappingToTris, verticesMappingToTris[i]);
		if(min > size_set(tris)){ 
			min = size_set(tris); 
			if(size_set(tris) == 0){
				counter++;
			}
		}
		if(max < size_set(tris)){ max = size_set(tris); }
	}

	printf("MAXIMUM NUMBER OF TRIANLGES ASSOCIATED WITH A point: %i\n", max);
	printf("MINIMUM NUMBER OF TRIANLGES ASSOCIATED WITH A point: %i  (total 0: %i)\n", min, counter);


	set_t set1;
	set_t set2;
	set_t tempSet;
	int numCommon;
	int * tri = new int[3];
	///iterate through all triangles, 
	for(i = 0; i<numTriangles; i++){
		tri[0] = triangles[3*i+0];
		tri[1] = triangles[3*i+1];
		tri[2] = triangles[3*i+2];

		///for each edge on the triangle, verify that exactly two 
		///distinct triangles are part of that edge.  otherwise it is
		///a non-manifold edge.
		for(j = 0; j<3; j++){
			//set the two vertices of the edge we are working on
			int t1 = tri[(j+0)%3];
			int t2 = tri[(j+1)%3];
			//identify the set of triangles adjacent to each endpoint
			set1 = (set_t) mapsto_set(verticesMappingToTris, t1);
			set2 = (set_t) mapsto_set(verticesMappingToTris, t2);
			///find out how many triangles are common between these endpoints
			numCommon = countNumCommon(set1, set2);

			//if numCommon == 1, then this is an edge of a nonmanifold surface.  Store it.
			if(numCommon == 1){
				if(!contains_set(nonManifold, t1)){ tempSet = alloc_set(0); }
				else{ tempSet = (set_t) mapsto_set(nonManifold, t1); }
				tempSet = put_set(tempSet, t2);
				nonManifold = associate_set(nonManifold, t1, tempSet);

				if(!contains_set(nonManifold, t2)){ tempSet = alloc_set(0); }
				else{ tempSet = (set_t) mapsto_set(nonManifold, t2); }
				tempSet = put_set(tempSet, t1);
				nonManifold = associate_set(nonManifold, t2, tempSet);
//				printf("Edge: %i %i\n", t1, t2);
			}

			//if numCommon is zero, then there is a serious issue with triangle topology.  Report it.
			if(numCommon == 0){
				printf("ERROR: Two vertices of the same triangle (vertex %i and %i in triangle %i) \n", t1, t2, i);
				printf("ERROR: are not members of at least one triangle, according to our data!!\n");
			}

			//if numCommon is greater than two, there is impossible surface occuring.  Report it.
			if(numCommon > 2){
				printf("ERROR: Vertices %i and %i appear to be adjacent to an edge which is part of \n", t1, t2);
				printf("ERROR: more than two triangles, creating a non-manifold surface! error!\n");
			}
			
			///if numCommon is equal to two, that is fine.  Report nothing.
		}

		///The end of this loop creates a list of non-manifold edges at the border of the surface, if it exists.
	}
	
	edges = nonManifold;
	
	delete[](tri);
	//free the data structure
	for(i = 0; i<numPoints; i++){ tris = (set_t) mapsto_set(verticesMappingToTris, i); free_set(tris); }
	free_set(verticesMappingToTris);
	
}
예제 #5
0
GW_Game_DKong::GW_Game_DKong() :
    GW_Game()
{
    gamepath_set("dkong");
    size_set(464, 571);

    // game screen position
    GW_PLATFORM_RECT(gr, 125, 78, 212, 412); // full screen
    //GW_PLATFORM_RECT(gr, 125, 349, 214, 139); // first screen
    gamerect_set(gr);

/*
    // second screen
    GW_PLATFORM_RECT(gr, 125, 177, 213, 139);
    gamerect_set(gr);
*/
    char sname[50];


    // transparent colors
    GW_PLATFORM_RGB(tcolor_bg, 255, 0, 255);
    GW_PLATFORM_RGB(tcolor_img, 255, 255, 255);

    // life
    data().
        position_add(PS_LIFE, 1, 216, 470, IM_LIFE, 1, "vite.bmp", &tcolor_img)->
        position_add(PS_LIFE, 2, 229, 470, IM_LIFE, 1)->
        position_add(PS_LIFE, 3, 242, 470, IM_LIFE, 1);

    // bg
    data().
        image_add(IM_BG, GW_INDEX_DEFAULT, "bg.bmp", &tcolor_bg);

    // barrel
    data().
        position_add(PS_BARREL, 1, 137, 200, IM_BARREL, 1, "bar_14.bmp", &tcolor_img)->
        //position_add(PS_BARREL, 2, 136, 372, IM_LIFE, 1)-> // 15
        position_add(PS_BARREL, 3, 136, 397, IM_BARREL, 2, "bar_16.bmp", &tcolor_img)->
        position_add(PS_BARREL, 4, 136, 461, IM_BARREL, 3, "bar_17.bmp", &tcolor_img)->
        position_add(PS_BARREL, 5, 169, 197, IM_BARREL, 4, "bar_24.bmp", &tcolor_img)->
        position_add(PS_BARREL, 6, 169, 400, IM_BARREL, 1)-> // 26
        position_add(PS_BARREL, 7, 169, 457, IM_BARREL, 6, "bar_36.bmp", &tcolor_img)-> // 27
        position_add(PS_BARREL, 8, 189, 196, IM_BARREL, 5, "bar_34.bmp", &tcolor_img)->
        position_add(PS_BARREL, 9, 202, 403, IM_BARREL, 6, "bar_36.bmp", &tcolor_img)->
        position_add(PS_BARREL, 10, 202, 454, IM_BARREL, 8, "bar_46.bmp", &tcolor_img)-> // 37
        position_add(PS_BARREL, 11, 208, 195, IM_BARREL, 7, "bar_44.bmp", &tcolor_img)->
        position_add(PS_BARREL, 12, 233, 406, IM_BARREL, 8, "bar_46.bmp", &tcolor_img)->
        position_add(PS_BARREL, 13, 233, 452, IM_BARREL, 2)-> // 47
        position_add(PS_BARREL, 14, 228, 194, IM_BARREL, 9, "bar_54.bmp", &tcolor_img)->
        position_add(PS_BARREL, 15, 263, 409, IM_BARREL, 2)-> // 56
        position_add(PS_BARREL, 16, 264, 450, IM_BARREL, 1)-> // 57
        position_add(PS_BARREL, 17, 245, 193, IM_BARREL, 4)-> // 64
        position_add(PS_BARREL, 18, 294, 413, IM_BARREL, 9)-> // 66
        position_add(PS_BARREL, 19, 294, 447, IM_BARREL, 6); // 67

    // barrel fall
    data().
        position_add(PS_BARRELFALL, 1, 167, 127, IM_BARRELFALL, 1, "bar_f21.bmp", &tcolor_img)->
        position_add(PS_BARRELFALL, 2, 168, 149, IM_BARRELFALL, 2, "bar_f22.bmp", &tcolor_img)->
        position_add(PS_BARRELFALL, 3, 169, 177, IM_BARRELFALL, 3, "bar_f23.bmp", &tcolor_img)->
        position_add(PS_BARRELFALL, 4, 206, 127, IM_BARRELFALL, 1)-> // 41
        position_add(PS_BARRELFALL, 5, 207, 148, IM_BARRELFALL, 4, "bar_f42.bmp", &tcolor_img)->
        position_add(PS_BARRELFALL, 6, 209, 178, IM_BARRELFALL, 5, "bar_f43.bmp", &tcolor_img)->
        //position_add(PS_BARRELFALL, 7, 302, 384, IM_BARRELFALL, 6, "bar_f44.bmp", &tcolor_img)->
        position_add(PS_BARRELFALL, 8, 243, 127, IM_BARRELFALL, 1)-> // 61
        position_add(PS_BARRELFALL, 9, 244, 147, IM_BARRELFALL, 6, "bar_f44.bmp", &tcolor_img)-> // 62
        position_add(PS_BARRELFALL, 10, 245, 178, IM_BARRELFALL, 7, "bar_f63.bmp", &tcolor_img);

    // hook
    data().
        position_add(PS_HOOK, 1, 275, 128, IM_HOOK, 1, "gancio1.bmp", &tcolor_img)->
        position_add(PS_HOOK, 2, 283, 131, IM_HOOK, 2, "gancio2.bmp", &tcolor_img)->
        position_add(PS_HOOK, 3, 293, 132, IM_HOOK, 3, "gancio3.bmp", &tcolor_img)->
        position_add(PS_HOOK, 4, 298, 134, IM_HOOK, 4, "gancio4.bmp", &tcolor_img)->
        position_add(PS_HOOK, 5, 304, 135, IM_HOOK, 5, "gancio5.bmp", &tcolor_img);

    // crane
    data().
        position_add(PS_CRANE, 1, 306, 151, IM_CRANE, 1, "gru1.bmp", &tcolor_img)->
        position_add(PS_CRANE, 2, 294, 125, IM_CRANE, 2, "gru2.bmp", &tcolor_img)->
        position_add(PS_CRANE, 3, 288, 88, IM_CRANE, 3, "gru3.bmp", &tcolor_img);

    // heart
    data().
        position_add(PS_HEART, 1, 144, 91, IM_HEART, 1, "heart1.bmp", &tcolor_img)->
        position_add(PS_HEART, 2, 149, 85, IM_HEART, 2, "heart2.bmp", &tcolor_img);

    // key
    data().
        position_add(PS_KEY, 1, 266, 102, IM_KEY, 1, "key1.bmp", &tcolor_img)->
        position_add(PS_KEY, 2, 271, 102, IM_KEY, 2, "key2.bmp", &tcolor_img)->
        position_add(PS_KEY, 3, 276, 102, IM_KEY, 3, "key3.bmp", &tcolor_img)->
        position_add(PS_KEY, 4, 280, 192, IM_KEY, 4, "key4.bmp", &tcolor_img);

    // kong up
    data().
        position_add(PS_KONGUP, 1, 160, 84, IM_KONGUP, 1, "kong2up.bmp", &tcolor_img)->
        position_add(PS_KONGUP, 2, 200, 84, IM_KONGUP, 2, "kong4up.bmp", &tcolor_img)->
        position_add(PS_KONGUP, 3, 232, 84, IM_KONGUP, 3, "kong6up.bmp", &tcolor_img);

    // kong down
    data().
        position_add(PS_KONGDOWN, 1, 154, 96, IM_KONGDOWN, 1, "kong2dwn.bmp", &tcolor_img)->
        position_add(PS_KONGDOWN, 2, 193, 95, IM_KONGDOWN, 2, "kong4dwn.bmp", &tcolor_img)->
        position_add(PS_KONGDOWN, 3, 228, 95, IM_KONGDOWN, 3, "kong6dwn.bmp", &tcolor_img);

    // kong fall
    data().
        position_add(PS_KONGFALL, GW_INDEX_DEFAULT, 258, 180, IM_KONGFALL, GW_INDEX_DEFAULT, "kongfall.bmp", &tcolor_img);

    // lever
    data().
        position_add(PS_LEVER, 1, 149, 172, IM_LEVER, 1, "leva_giu.bmp", &tcolor_img)->
        position_add(PS_LEVER, 2, 145, 162, IM_LEVER, 2, "leva_su.bmp", &tcolor_img);

    // mario
    data().
        position_add(PS_MARIO, 1, 153, 155, IM_MARIO, 1, "mario22a.bmp", &tcolor_img)->
        position_add(PS_MARIO, 2, 157, 155, IM_MARIO, 2, "mario22b.bmp", &tcolor_img)->
        position_add(PS_MARIO, 3, 150, 187, IM_MARIO, 3, "mario24.bmp", &tcolor_img)->
        position_add(PS_MARIO, 4, 149, 371, IM_MARIO, 4, "mario25.bmp", &tcolor_img)->
        position_add(PS_MARIO, 5, 149, 389, IM_MARIO, 5, "mario26.bmp", &tcolor_img)->
        position_add(PS_MARIO, 6, 148, 450, IM_MARIO, 6, "mario27.bmp", &tcolor_img)->
        position_add(PS_MARIO, 7, 151, 431, IM_MARIO, 7, "mario27j.bmp", &tcolor_img)->
        position_add(PS_MARIO, 8, 181, 391, IM_MARIO, 8, "mario36.bmp", &tcolor_img)->
        position_add(PS_MARIO, 9, 183, 446, IM_MARIO, 9, "mario37.bmp", &tcolor_img)->
        position_add(PS_MARIO, 10, 203, 156, IM_MARIO, 10, "mario42.bmp", &tcolor_img)->
        position_add(PS_MARIO, 11, 213, 395, IM_MARIO, 11, "mario46.bmp", &tcolor_img)->
        position_add(PS_MARIO, 12, 214, 376, IM_MARIO, 12, "mario46j.bmp", &tcolor_img)->
        position_add(PS_MARIO, 13, 214, 444, IM_MARIO, 13, "mario47.bmp", &tcolor_img)->
        position_add(PS_MARIO, 14, 245, 397, IM_MARIO, 14, "mario56.bmp", &tcolor_img)->
        position_add(PS_MARIO, 15, 245, 380, IM_MARIO, 15, "mario56j.bmp", &tcolor_img)->
        position_add(PS_MARIO, 16, 245, 441, IM_MARIO, 16, "mario57.bmp", &tcolor_img)->
        position_add(PS_MARIO, 17, 245, 423, IM_MARIO, 17, "mario57j.bmp", &tcolor_img)->
        position_add(PS_MARIO, 18, 234, 154, IM_MARIO, 18, "mario62.bmp", &tcolor_img)->
        position_add(PS_MARIO, 19, 257, 136, IM_MARIO, 19, "mario62a.bmp", &tcolor_img)->
        position_add(PS_MARIO, 20, 284, 151, IM_MARIO, 20, "mario62b.bmp", &tcolor_img)->
        position_add(PS_MARIO, 21, 273, 164, IM_MARIO, 21, "mario62c.bmp", &tcolor_img)->
        position_add(PS_MARIO, 22, 286, 188, IM_MARIO, 22, "mario62d.bmp", &tcolor_img)->
        position_add(PS_MARIO, 23, 309, 187, IM_MARIO, 23, "mario62e.bmp", &tcolor_img)->
        position_add(PS_MARIO, 24, 272, 400, IM_MARIO, 24, "mario66.bmp", &tcolor_img)->
        position_add(PS_MARIO, 25, 274, 439, IM_MARIO, 25, "mario67.bmp", &tcolor_img);

    // platform
    data().
        position_add(PS_PLAT, 1, 137, 130, IM_PLAT, 1, "sbarregi.bmp", &tcolor_img)->
        position_add(PS_PLAT, 2, 152, 122, IM_PLAT, 2, "sbarresu.bmp", &tcolor_img);

    // binder
    data().
        position_add(PS_BINDER, 1, 148, 359, IM_BINDER, 1, "trave2.bmp", &tcolor_img)->
        position_add(PS_BINDER, 2, 177, 362, IM_BINDER, 2, "trave3.bmp", &tcolor_img)->
        position_add(PS_BINDER, 3, 209, 365, IM_BINDER, 3, "trave4.bmp", &tcolor_img)->
        position_add(PS_BINDER, 4, 239, 368, IM_BINDER, 4, "trave5.bmp", &tcolor_img)->
        position_add(PS_BINDER, 5, 271, 370, IM_BINDER, 5, "trave6.bmp", &tcolor_img);


    // numbers
    data().
        position_add(PS_NUMBER, 1, 274, 468)->
        position_add(PS_NUMBER, 2, 286, 468)->
        position_add(PS_NUMBER, 3, 304, 468)->
        position_add(PS_NUMBER, 4, 316, 468)->
        position_add(PS_SEMICOLON, 0, 298, 472, IM_SEMICOLON, 0, "time_pp.bmp", &tcolor_img);

    for (int i=0; i<10; i++)
    {
        sprintf(sname, "num%d.bmp", i);
        data().image_add(IM_NUMBER, i, sname, &tcolor_img);
    }

    display_number(1, 1, false);
    display_number(2, 2, false);
    display_number(3, 9, false);
    display_number(4, 9, false);

    // options
    data().
        position_add(PS_GAMEA, GW_INDEX_DEFAULT, 302, 384, IM_GAMEA, GW_INDEX_DEFAULT, "game_a.bmp", &tcolor_img)->
        position_add(PS_GAMEB, GW_INDEX_DEFAULT, 302, 394, IM_GAMEB, GW_INDEX_DEFAULT, "game_b.bmp", &tcolor_img)->
        position_add(PS_ALARM, GW_INDEX_DEFAULT, 302, 402, IM_ALARM, GW_INDEX_DEFAULT, "alarm.bmp", &tcolor_img)->
        position_add(PS_AM, GW_INDEX_DEFAULT, 263, 468, IM_AM, GW_INDEX_DEFAULT, "time_am.bmp", &tcolor_img)->
        position_add(PS_PM, GW_INDEX_DEFAULT, 263, 478, IM_PM, GW_INDEX_DEFAULT, "time_pm.bmp", &tcolor_img);

    // sounds
    data().
        sound_add(SND_BARREL, "barrel.wav")->
        sound_add(SND_BONUS, "bonus.wav")->
        sound_add(SND_FALL, "fall.wav")->
        sound_add(SND_JUMP, "jump.wav")->
        sound_add(SND_KONGFALL, "kongfall.wav")->
        sound_add(SND_MISS, "miss.wav")->
        sound_add(SND_OVER, "over.wav")->
        sound_add(SND_STEP, "step.wav");

    // timers
/*
    data().
        timer_add(TMR_GAME, 250, true)->
        timer_add(TMR_GAMESTART, 1800, false)->
        timer_add(TMR_REPRISE, 1100, false)->
        timer_add(TMR_GAMEOVER, 100, false)->
        timer_add(TMR_GAMEOVERSOUND, 3500, false)->
        timer_add(TMR_GAMEOVERWAIT, 30000, false);
*/
}