Ejemplo n.º 1
0
	//--------------------------------------------------------------------------------------
	// Metodo para importar un modelo desde un fichero 3DS.
	//--------------------------------------------------------------------------------------
	bool CStaticMesh::Import (const char * name)
	{
		//----------------------------------------------------------------------------------
		// Primero eliminamos el contenido del objeto.
		//----------------------------------------------------------------------------------
		appResetLastError();
		this->Release();

		//----------------------------------------------------------------------------------
		// Luego cargamos en la clase para ficheros 3DS el modelo.
		//----------------------------------------------------------------------------------
		Model_3DS model;
		model.Load((char *) name);

		this->NumObjects   = model.numObjects;
		this->NumMaterials = model.numMaterials;

		//----------------------------------------------------------------------------------
		// Vamos leyendo objeto por objeto del modelo.
		//----------------------------------------------------------------------------------
		this->Objects = new Geometry::CObject[this->NumObjects];
		if(this->Objects != NULL)
		{
			for(unsigned int i = 0; i < this->NumObjects; ++i)
			{
				this->Objects[i].CopyFrom(model.Objects[i]);
			}
		}
		else
		{
			return appSetLastError(GEOERR_SMIMP_OBJSNULL);
		}

		//----------------------------------------------------------------------------------
		// Y por último leemos cada material del modelo.
		//----------------------------------------------------------------------------------
		this->Materials = new Geometry::CMaterial[this->NumMaterials];
		if(this->Materials != NULL)
		{
			for(unsigned int i = 0; i < this->NumMaterials; ++i)
			{
				this->Materials[i].CopyFrom(model.Materials[i]);
			}
		}
		else
		{
			return appSetLastError(GEOERR_SMIMP_MATSNULL);
		}

        return (appGetLastError() == EVERYTHING_ALL_RIGHT);
	}
Ejemplo n.º 2
0
int main(int argc, char** argv) {
	glutInit(&argc, argv);
	cameraX = 0;
	cameraY = 30;
	cameraZ = 150;
	eyeX = 0;
	eyeY = 0;
	eyeZ = 0;
	lastLevel = 0;
	cameraAcceleration = 0.1;
	timerTime = 2 * 1000;
	lastLevel += ((rand() % 10) + 40);
	jump = false;
	characterSpeed = 0.8;
	jumpTime = clock();
	jumpBeginY = clock();
	/*
	int x = ((rand() % 10) + 45);
	int direction = ((rand() % 10) - 15);*/
	int x = ((rand() % 10) + 705);
	int direction = 0;
	character.x = direction;
	character.y = lastLevel + 5;

	Level level1 = *new Level(x, lastLevel, direction);
	level1.levelBefore = new Level(-1000021, -111, 0);
	Levels.push_back(level1);
	character.setLevel(level1);
	glutInitWindowSize(800, 1000);
	glutInitWindowPosition(50, 50);
	glutCreateWindow("Icy Tower");
	glutDisplayFunc(Display);
	
	glutIdleFunc(Anim);
	glutKeyboardFunc(key);
	glutMouseFunc(Mouse);
	glutTimerFunc(0, Timer, 0);
	glutTimerFunc(0, Timer2, 0);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
	glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHT1);
	glEnable(GL_NORMALIZE);
	glEnable(GL_COLOR_MATERIAL);

	glShadeModel(GL_SMOOTH);
	character.c.Load("Models/character.3ds");

	banana.Load("Models/banana.3ds");
	level.Load("Textures/brick3.bmp");
	skyFront.Load("Textures/brick.bmp");
	skyBack.Load("Textures/brick.bmp");
	skyLeft.Load("Textures/brick2.bmp");
	skyRight.Load("Textures/brick2.bmp");
	skyUp.Load("Textures/brick.bmp");
	skyDown.Load("Textures/grass2.bmp");
	glutMainLoop();
}
Ejemplo n.º 3
0
void drawBanana(float x, float y,float z){
	glPushMatrix();
	glTranslated(x, y, -z);
	glScaled(1.5, 1.5, 1.5);
	banana.Draw();
	glPopMatrix();
}
Ejemplo n.º 4
0
	void drawCharacter() {

		glPushMatrix();
		glColor3f(1,1,1);
		
		glTranslated(this->x, this->y+3.5, 0);
		glRotated(angleOfLooking, 0, 1, 0);
		//for (int i = 0; i<100000; i++);
		//glRotated(-1*angleOfLooking, 0, 1, 0);

		if (jump) {
			if (characterSpeed > 0)
				glRotated(rotate, 0, 0, 1);
				//glRotated(-45, 0, 0, 1);
			else
				glRotated(45, 0, 0, 1);

		}
		//if (fall)
		//	glRotated(180, 0, 0, 1);

		glScalef(5, 5, 5);
		c.Draw();
		glPopMatrix();
	}