Esempio n. 1
0
Floor *Room::pointer_to_floor() {
	if (floor == NULL) create_floor();
//   floor->about_to_redisplay();
	return(floor);
};
Esempio n. 2
0
File: main.c Progetto: ErikHK/tsbk03
/////////////////////////////////////////
//		M A I N
//
int main(int argc, char **argv)
{
	srand(time(NULL));
	mouse_x = 0;
	old_mouse_x = 0;
	mouse_y = 0;
	old_mouse_y = 0;

	m_angle = -300*M_PI; //FOULHACK!


	glutInit(&argc, argv);


	initKeymapManager();
	glutPassiveMotionFunc(mouse);

	//glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GL_MULTISAMPLE);
	glutInitWindowSize(800, 600);
	glutInitContextVersion(3, 2); // Might not be needed in Linux
	glutCreateWindow("Farm Escape");
	glutDisplayFunc(DisplayWindow);

	create_floor(&f);
	//create_plank(&p, SetVector(4,4,0), SetVector(0,5,0));
	create_fence(&ff, 14, SetVector(0,0,0));
	//f.model = generate_terrain(32);
	create_ball(&ball, SetVector(5,0,0));
	create_wall(&wall, SetVector(0,10,0), SetVector(2,5,2));

	create_joint(&legbase_joint[0], SetVector(-2.2, 3.8, .7), 
	"legjoint0", "legcurrpos0", "legbonepos0", 0);
	create_joint(&legbase_joint[1], SetVector(-2.2, 3.8, -.7),
	"legjoint1", "legcurrpos1", "legbonepos1", 0);
	create_joint(&legbase_joint[2], SetVector(.2, 3.9, -.7),
	"legjoint2", "legcurrpos2", "legbonepos2", 0);
	create_joint(&legbase_joint[3], SetVector(.2, 3.9, .7),
	"legjoint3", "legcurrpos3", "legbonepos3", 0);

	create_joint(&thigh_joint[0], SetVector(-2.3, 1.8, .4),
	NULL, NULL, NULL, 0);
	create_joint(&thigh_joint[1], SetVector(-2.3, 1.8, -.4),
	NULL, NULL, NULL, 0);
	create_joint(&thigh_joint[2], SetVector(.1, 2, -.4),
	NULL, NULL, NULL, 0);
	create_joint(&thigh_joint[3], SetVector(.1, 2.0, .4),
	NULL, NULL, NULL, 0);

	create_joint(&knee_joint[0], SetVector(-2.6, .9, .4),
	NULL, NULL, NULL, 0);
	create_joint(&knee_joint[1], SetVector(-2.6, .9, -.4),
	NULL, NULL, NULL, 0);
	create_joint(&knee_joint[2], SetVector(.4, .9, -.4),
	NULL, NULL, NULL, 0);
	create_joint(&knee_joint[3], SetVector(.4, .9, .4),
	NULL, NULL, NULL, 0);
	create_joint(&foot_joint[0], SetVector(-2.75, 0, .4),
	NULL, NULL, NULL, 0);
	create_joint(&foot_joint[1], SetVector(-2.75, 0, -.4),
	NULL, NULL, NULL, 0);
	create_joint(&foot_joint[2], SetVector(.34, 0, -.4),
	NULL, NULL, NULL, 0);
	create_joint(&foot_joint[3], SetVector(.34, 0, .4),
	NULL, NULL, NULL, 0);


	//BODY JOINTS
	create_joint(&body_joint[0], SetVector(-1.8, 3.6, 0),
	"bodyjoint", "bodycurrpos", "bodybonepos", 0);
	create_joint(&body_joint[1], SetVector(-1, 3.3, 0),
	NULL, NULL, NULL, 0);
	create_joint(&body_joint[2], SetVector(.14, 3.9, 0),
	NULL, NULL, NULL, 0);


	//TAIL JOINTS
	create_joint(&tail_joint[0], SetVector(.7+.3, 3.75, 0),
	"tailjoint", "tailcurrpos", "tailbonepos", 0);
	create_joint(&tail_joint[1], SetVector(2.2, 3.8, 0),
	NULL, NULL, NULL, 0);
	create_joint(&tail_joint[2], SetVector(3.0, 3.75, 0),
	NULL, NULL, NULL, 0);
	create_joint(&tail_joint[3], SetVector(3.9, 3.65, 0),
	NULL, NULL, NULL, 0);

	//HEAD JOINTS
	create_joint(&head_joint[0], SetVector(-2.9, 3.2, 0),
	"headjoint", "headcurrpos", "headbonepos", 0);
	create_joint(&head_joint[1], SetVector(-3.85, 4, 0),
	NULL, NULL, NULL, 0);
	create_joint(&head_joint[2], SetVector(-4.7, 3, 0),
	NULL, NULL, NULL, 0);

	//EAR JOINTS
	//create_joint(&left_ear_joint[0], SetVector(-2.9, 3.2, -.4),
	//"leftearjoint", "leftearcurrpos", "leftearbonepos", 0);
	create_joint(&left_ear_joint[0], SetVector(-2.9, 3.2, .6),
	NULL, NULL, NULL, 0);
	create_joint(&right_ear_joint[0], SetVector(-2.9, 3.2, -.6),
	NULL, NULL, NULL, 0);
	//create_joint(&left_ear_joint[1], SetVector(-2.9, 3.2, .6),
	//NULL, NULL, NULL, 0);
	//create_joint(&right_ear_joint[1], SetVector(-2.9, 3.2, -.6),
	//NULL, NULL, NULL, 0);

	//create_joint(&right_ear_joint[0], SetVector(-2.9, 3.2, -.6),
	//"rightearjoint", "rightearcurrpos", "rightearbonepos", 0);

	//create_joint(&right_ear_joint[1], SetVector(-2.9, 3.2, -.8),
	//"rightearjoint", "rightearcurrpos", "rightearbonepos", 0);


	//SET CHILDREN!
	body_joint[0].child[0] = &body_joint[1];
	body_joint[1].child[0] = &body_joint[2];
	body_joint[2].child[0] = &tail_joint[0];
	body_joint[2].child[1] = &legbase_joint[2];
	body_joint[2].child[2] = &legbase_joint[3];

	tail_joint[0].child[0] = &tail_joint[1];
	tail_joint[1].child[0] = &tail_joint[2];
	tail_joint[2].child[0] = &tail_joint[3];
	tail_joint[3].child[0] = NULL;

	head_joint[0].child[0] = &head_joint[1];
	head_joint[1].child[0] = &head_joint[2];
	head_joint[2].child[0] = NULL;
	//head_joint[2].child[0] = &right_ear_joint[1];
	head_joint[2].child[1] = &left_ear_joint[0];
	head_joint[2].child[2] = &right_ear_joint[0];

	//left_ear_joint[0].child[0] = &left_ear_joint[1];
	//right_ear_joint[0].child[0] = &right_ear_joint[1];

	//left_ear_joint[1].child[0] = NULL;
	//right_ear_joint[1].child[0] = NULL;

	//head_joint[0].child = &legbase_joint[0];
	int i;
        for(i=0;i<4;i++)
	{
	  legbase_joint[i].child[0] = &thigh_joint[i];
	  thigh_joint[i].child[0] = &knee_joint[i];
	  knee_joint[i].child[0] = &foot_joint[i];
	  foot_joint[i].child[0] = NULL;
	}

	//SET PARENTS
	legbase_joint[2].parent = &body_joint[2];
	legbase_joint[3].parent = &body_joint[2];

	//left_ear_joint[1].parent = &left_ear_joint[0];
	left_ear_joint[0].parent = &head_joint[2];

	//right_ear_joint[1].parent = &right_ear_joint[0];
	right_ear_joint[0].parent = &head_joint[2];


	create_cow(&cow);
	create_farmer(&farmer, SetVector(0,0,0));

	create_ragdoll(&ragdoll);

	g_shader = loadShaders("shader.vert" , "shader.frag");
	glUseProgram(g_shader);

	// Set up depth buffer
	glEnable(GL_DEPTH_TEST);

	//glEnable (GL_BLEND);
	//glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	// initiering
//#ifdef WIN32
//	glewInit();
//#endif

	//glutSetCursor(0);

	//terr = generate_terrain(512);


	glutTimerFunc(20, &OnTimer, 0);

	glutMainLoop();
	exit(0);
}
Esempio n. 3
0
void glApartment::create_components( )
{
    create_apartment();
    create_floor();
}