Ejemplo n.º 1
0
/*******************************************************************************
Function that handles the window being resized
*******************************************************************************/
void myReshape(int w, int h)
{
	g_width = w;
	g_height = h;

	float asp = (float) w / (float) h ;

	std::cout << "New aspect ratio " << asp << std::endl;

	glViewport(0, 0, w,h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
    
	// This defines the field of view of the camera.
    // Making the first 4 parameters larger will give a larger field of 
	// view, therefore making the objects in the scene appear smaller.
	glOrtho(-asp*15, asp*15, -15, 15, -500, 2000);

	// Use either of the following functions to set up a perspective view
	//gluPerspective(20,(float) w/(float) h,1,100) ;
	//glFrustum(-1,1,-1,1,4,100);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

    // This sets the virtual camera:
    // gluLookAt( x,y,z,   x,y,z   x,y,z );
    //            camera  look-at camera-up
    //            pos'n    point   vector
    gluLookAt(g_eye[X], g_eye[Y], g_eye[Z],	g_ref[X], g_ref[Y], g_ref[Z], 0, 1, 0);

	HMatrix arcball_rot;
	Ball_Value(g_arcBall,arcball_rot);
	glMultMatrixf((float *)arcball_rot);
}
Ejemplo n.º 2
0
void CMassView::Draw(BRect updateRect)												//	draw the view
	{
	if (!inGLMode)
		{
		//DrawBitmap(theBlitMap, updateRect, updateRect);								//	blit the bits
		return;
		} // end of simple case
	else
		{
		LockGL();																	//	lock in preparation for drawing
		GLfloat mNow[16];															//	local matrix for ball routines							
		Ball_Update(&ball);															//	update the data for the ball								
		Ball_Value(&ball, mNow);													//	retrieve the ball's position as a matrix						
		glMatrixMode(GL_MODELVIEW);													//	make sure that we are set to the model matrix				
		glClearColor(0.0, 0.0, 0.0, 1.0);											//	and set the "clear" colour to black						
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);							//	clear the window to black								
		glPushMatrix();																//	push the GL stack to get a new matrix						
		glLoadIdentity();															//	load the identity matrix								
		glTranslatef(0, 0, -600.0);													//	translate the model matrix									
		glMultMatrixf(mNow);														//	multiply by this matrix								
		glEnable(GL_TEXTURE_2D);													//	enable 2D textures
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);				//	set the vertical (?) wrap
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);				//	and the horizontal
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);			//	set magnification filter
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);			//	set shrinking filter
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, theBlitMap->Bounds().Width() + 1, theBlitMap->Bounds().Height() + 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, theBlitMap->Bits());
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);				//	just stick the texture on		
		glBindTexture(GL_TEXTURE_2D, texName);										//	bind the texture to the name (again?)
		glCallList(torusDisplayListID);												// and call the display list							
		glPopMatrix();																//	pop the matrix back off the stack
		SwapBuffers();																//	swap the buffers to draw it
		glDisable(GL_TEXTURE_2D);													//	switch textures back off
		UnlockGL();																	//	unlock GL
		} // end of GL case	
	} // end of Draw()
Ejemplo n.º 3
0
/*********************************************************
**********************************************************
**********************************************************

    PROC: display()
    DOES: this gets called by the event handler to draw
          the scene, so this is where you need to build
          your ROBOT --  
      
        MAKE YOUR CHANGES AND ADDITIONS HERE

    Add other procedures if you like.

**********************************************************
**********************************************************
**********************************************************/
void display(void)
{
    // Clear the screen with the background colour (set in myinit)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    model_view = mat4(1.0f);
    
    model_view *= Translate(0.0f, -5.0f, -15.0f);
    HMatrix r;
    Ball_Value(Arcball,r);

    mat4 mat_arcball_rot(
        r[0][0], r[0][1], r[0][2], r[0][3],
        r[1][0], r[1][1], r[1][2], r[1][3],
        r[2][0], r[2][1], r[2][2], r[2][3],
        r[3][0], r[3][1], r[3][2], r[3][3]);
    model_view *= mat_arcball_rot;
        
    glUniformMatrix4fv( uView, 1, GL_TRUE, model_view );


    // Previously glScalef(Zoom, Zoom, Zoom);
    model_view *= Scale(Zoom);

    //draw objects
    drawGround();
    drawBee();
    drawFlower();

    glutSwapBuffers();
    if(Recording == 1)
        FrSaver.DumpPPM(Width, Height);
}
Ejemplo n.º 4
0
void ReshapeCB(int w, int h)
{
	g_width = w;
	g_height = h;

	glViewport(0, 0, w, h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	/*** this defines the field of view of the camera   ***/
	/*** Making the first 4 parameters larger will give ***/
	/*** a larger field of view, therefore making the   ***/
	/*** objects in the scene appear smaller            ***/
	// glFrustum(-1,1,-1,1,7,100);
	glOrtho(-6,6,-6,6,-500,500) ;
	//glOrtho(-6,6,-6,6,-500,500) ;
	//gluPerspective(20,(float) w/(float) h,1,100) ;
	//glFrustum(-1,1,-1,1,4,100);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	/*** this sets the virtual camera          ***/
	/*** gluLookAt( x,y,z,   x,y,z   x,y,z );  ***/
	/***            camera  look-at camera-up  ***/
	/***            pos'n    point   vector    ***/

	gluLookAt(g_eye[X],g_eye[Y],g_eye[Z],
		g_ref[X],g_ref[Y],g_ref[Z], 0,1,0);
	HMatrix arcball_rot;
	Ball_Value(g_arcball,arcball_rot);
	glMultMatrixf((float *)arcball_rot);
}
Ejemplo n.º 5
0
/*********************************************************
**********************************************************
**********************************************************

    PROC: display()
    DOES: this gets called by the event handler to draw
          the scene, so this is where you need to build
          your ROBOT --  
      
        MAKE YOUR CHANGES AND ADDITIONS HERE

    Add other procedures if you like.

**********************************************************
**********************************************************
**********************************************************/
void display(void)
{
    // Clear the screen with the background colour (set in myinit)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    model_view = mat4(1.0f);
    
    
    model_view *= Translate(0.0f, 0.0f, -15.0f);
    HMatrix r;
    Ball_Value(Arcball,r);

    mat4 mat_arcball_rot(
        r[0][0], r[0][1], r[0][2], r[0][3],
        r[1][0], r[1][1], r[1][2], r[1][3],
        r[2][0], r[2][1], r[2][2], r[2][3],
        r[3][0], r[3][1], r[3][2], r[3][3]);
    model_view *= mat_arcball_rot;
    
    mat4 view = model_view;
    
    
    //model_view = Angel::LookAt(eye, ref, up);//just the view matrix;

    glUniformMatrix4fv( uView, 1, GL_TRUE, model_view );

    // Previously glScalef(Zoom, Zoom, Zoom);
    model_view *= Scale(Zoom);

    // Draw Something
    set_colour(0.8f, 0.8f, 0.8f);
    drawSphere();

    // Previously glTranslatef(3,0,0);
    model_view *= Translate(3.0f, 0.0f, 0.0f);

    // Previously glScalef(3,3,3);
    model_view *= Scale(3.0f, 3.0f, 3.0f);

    drawCube();

    // And extra shapes!
    model_view *= Scale(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f);
    model_view *= Translate(3.0f, 0.0f, 0.0f);
    set_colour(1.0f, 1.0f, 0.0f);
    drawCone();

    model_view *= Translate(-9.0f, 0.0f, 0.0f);
    set_colour(1.0f, 1.0f, 1.0f);
    drawCylinder();


    glutSwapBuffers();
    if(Recording == 1)
        FrSaver.DumpPPM(Width, Height) ;
}
Ejemplo n.º 6
0
Archivo: anim.cpp Proyecto: 4solo/cs174
/*********************************************************
**********************************************************
**********************************************************
 
    PROC: display()
    DOES: this gets called by the event handler to draw
          the scene, so this is where you need to build
          your ROBOT --  
      
        MAKE YOUR CHANGES AND ADDITIONS HERE
 
    Add other procedures if you like.
 
**********************************************************
**********************************************************
**********************************************************/
void display(void)
{
	// Clear the screen with the background colour (set in myinit)
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	mat4 model_trans(1.0f);
	mat4 view_trans(1.0f);

	view_trans *= Translate(0.0f, 0.0f, -15.0f);
	HMatrix r;
	Ball_Value(Arcball, r);

	mat4 mat_arcball_rot(
		r[0][0], r[0][1], r[0][2], r[0][3],
		r[1][0], r[1][1], r[1][2], r[1][3],
		r[2][0], r[2][1], r[2][2], r[2][3],
		r[3][0], r[3][1], r[3][2], r[3][3]);
	view_trans *= mat_arcball_rot;
	view_trans *= Scale(Zoom);

	glUniformMatrix4fv(uView, 1, GL_TRUE, model_view);

	model_view = view_trans;

	mvstack.push(model_view);
	drawGround(view_trans);
	model_view = mvstack.top();
	mvstack.pop();

	model_view *= Translate(0, -10, 0);

	drawFlower();
	drawBee();
	glutSwapBuffers();
	if (Recording == 1)
		FrSaver.DumpPPM(Width, Height);
}
Ejemplo n.º 7
0
void CMassView::MouseDown(BPoint where)												//	reacts to mouse clicks
	{
	long whichButtons = 1;															//	used for tracking which buttons are down
	Window()->CurrentMessage()->FindInt32("buttons", &whichButtons);				//	find out which buttons are down
	
	if (inGLMode && (whichButtons & B_SECONDARY_MOUSE_BUTTON))						//	if we are in GL mode, and button 2 is down
		{
		float frameWidth = Frame().Width(), frameHeight = Frame().Height();			//	find the width & height
		dragMode = dragBall;														//	drag the arcball to rotate									
		HVect vNow;																	//	vector type for passing to ball functions					
		vNow.x = (2.0 * where.x - frameWidth)/frameWidth;							//	set the vector										
		vNow.y = -(2.0 * where.y - frameHeight)/frameHeight;							//	in both dimensions									
		Ball_Mouse(&ball, vNow);													//	and pass it to the Ball functions							
		Ball_BeginDrag(&ball);														//	start dragging										
		while (whichButtons)														//	loop until drop the mouse
			{
			snooze(20 * 1000);														//	snooze for 20 µs
			GetMouse(&where, (ulong *)&whichButtons, true);									//	get the mouse location, &c.
			vNow.x = (2.0 * where.x - frameWidth)/frameWidth;						//	set the vector	
			vNow.y = -(2.0 * where.y - frameHeight)/frameHeight;						//	in both dimensions
			Ball_Mouse(&ball, vNow);												//	and pass it to the Ball functions
			Draw(Frame());															//	redraw the entire frame
			} // end of while (whichButtons)
		Ball_EndDrag(&ball);														//	stop dragging	
		} // end of case where dragging

	else if (acceptClicks)															//	if we have "accept" switched on
		{
		long row, col;																//	the board coordinates of the click
		if (!inGLMode)																//	if it's the regular board
			{
			row = where.y / CELL_SIZE;												//	calculate which row to look in
			col = where.x / CELL_SIZE;												//	and which column
			} // end of normal mode
		else 
			{
			GLubyte theColour[4];													//	array for retrieving "colour"
			LockGL();																//	lock in preparation for drawing
			GLfloat mNow[16];														//	local matrix for ball routines							
			Ball_Update(&ball);														//	update the data for the ball								
			Ball_Value(&ball, mNow);												//	retrieve the ball's position as a matrix						
			glDisable(GL_LIGHTING);													//	disable lighting
			glShadeModel(GL_FLAT);													//	switch to flat shading
			glMatrixMode(GL_MODELVIEW);												//	make sure that we are set to the model matrix				
			glClearColor(0.0, 0.0, 0.0, 1.0);										//	and set the "clear" colour to black						
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);						//	clear the window to black								
			glPushMatrix();															//	push the GL stack to get a new matrix						
			glLoadIdentity();														//	load the identity matrix								
			glTranslatef(0, 0, -600.0);												//	translate the model matrix									
			glMultMatrixf(mNow);													//	multiply by this matrix								
			glCallList(torusPickListID);											// and call the display list							
			glReadPixels(where.x, Frame().Height() - where.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, theColour);
																					//	read a single pixel at the mouse location
			glPopMatrix();															//	pop the matrix back off the stack
			glEnable(GL_LIGHTING);													//	re-enable lighting
			glShadeModel(GL_SMOOTH);												//	and smoothness
			UnlockGL();																//	unlock GL
			Draw(Frame());															//	redraw the entire picture
			row = theColour[1] - 128; col = theColour[0] - 128;						//	retrieve the row & column
																					//	(background is black & returns -128)
//			printf("%d %d\n", row, col); return;
			} // end of GL mode code
		if (row < 0) return;														//	make sure it is a legal cell
		else if (row >= theBoard.getHeight()) return;										//	i.e. not off top or bottom
		if (col < 0) return;														//	same with left & right
		else if (col >= theBoard.getWidth()) return;	
		
		BMessage *theMessage = new BMessage(CM_MSG_MOVE_CHOSEN);					//	create a message for it
		acceptClicks = false;														//	turn off "accept clicks"
		theMessage->AddInt32("row", row); theMessage->AddInt32("column", col);		//	add the coordinates to the message
		be_app->PostMessage(theMessage);											//	send the message off
		delete theMessage;															//	get rid of the message when done
		} // end of case where we accept clicks
	} // end of MouseDown()
Ejemplo n.º 8
0
void display(void)
{
    // Clear the screen with the background colour (set in myinit)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    model_view = mat4(1.0f);
    
	double curprev = TM.GetElapsedTime() - prev;
	frames++;

	if (curprev > 1)
	{
		prev = TM.GetElapsedTime();
		fps = frames / curprev;
		frames = 0;
		printf("FPS: %i\n", fps);
	}
    model_view *= Translate(0.0f, 0.0f, -15.0f);
    HMatrix r;
    Ball_Value(Arcball,r);

    mat4 mat_arcball_rot(
        r[0][0], r[0][1], r[0][2], r[0][3],
        r[1][0], r[1][1], r[1][2], r[1][3],
        r[2][0], r[2][1], r[2][2], r[2][3],
        r[3][0], r[3][1], r[3][2], r[3][3]);
    model_view *= mat_arcball_rot;
    
    mat4 view = model_view;
    
    
   // model_view = Angel::LookAt(eye, ref, up);//just the view matrix;

    glUniformMatrix4fv( uView, 1, GL_TRUE, model_view );

    // Previously glScalef(Zoom, Zoom, Zoom);
    model_view *= Scale(Zoom);

	
    // Draw Something
	mvstack.push(model_view);
	drawWorld();
	model_view = mvstack.pop();
	//guy 1
	mvstack.push(model_view);
	model_view *= Translate (0, 8, -40);
	model_view *= Scale(1.5, 1.5, 1.5);
	model_view *= RotateY(180);
	// turn
	if (TIME >= 5 && TIME < 6)
	{
		model_view *= RotateY(-900 + TIME*180);
	}
	// move up
	else if (TIME >= 6 && TIME < 6.5)
	{
		model_view *= RotateY(180);
		model_view *= Translate (0, 0 , -36 + TIME*6);
	}
	// jump on bench
	else if (TIME >= 6.5 && TIME < 7)
	{
		model_view *= RotateY(180);
		model_view *= Translate (0, 0, 3);
		model_view *= Translate (0, -16.25 + TIME*2.5, -13 + TIME*2);
	}
	// jump off bench
	else if (TIME >= 7 && TIME < 7.5)
	{
		model_view *= RotateY(180);
		model_view *= Translate(0, 1.25, 4);
		model_view *= Translate(0, -112 + TIME*16, -112 + TIME*16);
		model_view *= RotateX(-5040 + TIME*720);
	}
	// land
	else if (TIME >= 7.5 && TIME < 8)
	{
		model_view *= RotateY(180);
		model_view *= Translate(0, 9.25, 15);
		model_view *= Translate (0, 138.75-TIME*18.5, 0);
	}
	// walk toward other guy
	else if (TIME >= 8 && TIME < 9)
	{
		model_view *= RotateY(180);
		model_view *= Translate(0, 0, 15);
		model_view *= Translate(0, 0, -64 + TIME*8);
	}
	// stand for a bit
	else if (TIME >= 9 && TIME < 15)
	{
		model_view *= RotateY(180);
		model_view *= Translate(0, 0, 23);
		model_view *= RotateY(3*sin(5*TIME));
	}
	// spin thing
	else if (TIME >= 15 && TIME < 16)
	{
		model_view *= RotateY(180);
		model_view *= Translate (0, 0, 23);
		model_view *= RotateY(-5400 + TIME*360);
	}
	// backflip thing
	else if (TIME >= 16 && TIME < 16.5)
	{
		model_view *= RotateY(180);
		model_view *= Translate (0, 0, 23);
		model_view *= RotateX(5040 - TIME*720);
	}
	//walk backwards
	else if (TIME >= 16.5 && TIME < 17)
	{
		model_view *= RotateY(180);
		model_view *= Translate (0, 0, 23);
		model_view *= Translate (0, 0, 264 - TIME*16);
	}
	//fall
	else if (TIME >= 17 && TIME < 17.5)
	{
		model_view *= RotateY(180);
		model_view *= Translate (0, 0, 15);
		model_view *= Translate (0, (17*9) - TIME*9, 0);
		model_view *= RotateX (3060 - TIME*180);
	}
	// lay on ground
	else if (TIME >= 17.5)
	{
		model_view *= RotateY(180);
		model_view *= Translate (0, -4.5, 15);
		model_view *= RotateX (-90);
	}
	drawGuy1();
	model_view = mvstack.pop();

	//GUY 2
	mvstack.push(model_view);
	model_view *= Translate (-20, 8, 35);
	model_view *= Scale(1.5, 1.5, 1.5);
	model_view *= RotateY(180);
	if (TIME >= 6 && TIME < 8)
	{
		model_view *= Translate(39 - TIME*6.5, 0, 0);
		model_view *= RotateY(270 - TIME*45);
	}
	else if( TIME >= 8 && TIME  < 10)
	{
		model_view *= Translate (-13, 0, 0);
		model_view *= Translate (0, 0, -(8*10.5) + TIME*10.5);
	}
	else if (TIME >= 10 && TIME < 15)
	{
		model_view *= Translate (-13,0, 21);
		model_view *= RotateY(3*sin(5*TIME));
	}
	else if (TIME >= 15 && TIME < 26.5)
	{
		model_view *= Translate(-13, 0, 21);
	}
	else if (TIME >= 26.5 && TIME < 28.5)
	{
		model_view *= Translate (-13, 0, 21);
		model_view *= Translate (0, 0, (26.5*5) - TIME*5);
	}
	else if (TIME >= 28.5 && TIME < 29.5)
	{
		model_view *= Translate (-13, 0, 11);
		model_view *= RotateY((180*28.5) - TIME*180);
	}
	else if (TIME >= 29.5 && TIME < 31.5)
	{
		model_view *= Translate(-13, 0, 11);
		model_view *= RotateY(180);
		model_view *= Translate (0, 0, -(29.5*15) + 15*TIME);
	}


	drawGuy2();
	model_view = mvstack.pop();

	cam();
	


	if (TIME > 31.5)
		exit(0);

    glutSwapBuffers();
    if(Recording == 1)
        FrSaver.DumpPPM(Width, Height) ;
}
Ejemplo n.º 9
0
void display(void)
{


	static double oldTime = GlobalResourceManager::use()->getActualTime();
	oldTime = g_globalTimer.GetElapsedTime() ;


	glClearColor(0.2f,0.2f,1.0f,0.5f);   /* set the background colour */
	/* OK, now clear the screen with the background colour */
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


	glMatrixMode(GL_MODELVIEW) ;
	glLoadIdentity();

	g_eye[Z] = 8 ;
	gluLookAt (g_eye[X], g_eye[Y], g_eye[Z],
		g_ref[X], g_ref[Y], g_ref[Z], 0.0,1.0,0.0);

	HMatrix arcball_rot;
	Ball_Value(g_arcball,arcball_rot);
	glMultMatrixf((float *)arcball_rot);

	glScalef(g_zoom, g_zoom, g_zoom) ;
	DrawScene() ;

	glMatrixMode(GL_PROJECTION) ;
	glPushMatrix() ;
	glLoadIdentity();

	glMatrixMode(GL_MODELVIEW) ;
	glPushMatrix() ;
	glLoadIdentity();

	// display frame rate
	glPushAttrib(GL_LIGHTING|GL_TEXTURE_2D) ;
	glDisable(GL_LIGHTING) ;
	glDisable(GL_TEXTURE_2D) ;
	glColor3f(1,1,1) ;
	//	int fps  =  (int) ((float) 1.0) / (TIME - oldTime) ;
	int fps  =  (int) ((float) 1.0) / (g_globalTimer.GetElapsedTime() - oldTime) ;
	oldTime = GlobalResourceManager::use()->getActualTime() ;
	char s[80] ;
	sprintf(s,"FPS: %5d  TIME %6.3lf SIMTIME %6.3lf%c", 
		fps,GlobalResourceManager::use()->getActualTime(),
		GlobalResourceManager::use()->getSimulationTime(),'\0') ;

	glRasterPos2f(-0.98,-0.98) ;
	GLlabel(s, 15) ;

	glPopAttrib() ;

	glMatrixMode(GL_PROJECTION) ;
	glPopMatrix() ;
	glMatrixMode(GL_MODELVIEW) ;
	glPopMatrix() ;



	glutSwapBuffers();
	if( g_frameDumping == 1) g_frameSaver.DumpPPM(g_width,g_height) ;

}
Ejemplo n.º 10
0
void display(void)
{
    // Clear the screen with the background colour (set in myinit)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    model_view = mat4(1.0f);
    model_view *= Translate(0.0f, 0.0f, -15.0f);
    HMatrix r;
    Ball_Value(Arcball,r);

    mat4 mat_arcball_rot(
        r[0][0], r[0][1], r[0][2], r[0][3],
        r[1][0], r[1][1], r[1][2], r[1][3],
        r[2][0], r[2][1], r[2][2], r[2][3],
        r[3][0], r[3][1], r[3][2], r[3][3]);
    model_view *= mat_arcball_rot;

    mat4 view = model_view;
    glUniformMatrix4fv( uView, 1, GL_TRUE, view );

    // Previously glScalef(Zoom, Zoom, Zoom);
    model_view *= Scale(Zoom);
	model_view *= Translate(0.0f, 0.0f, -10.0f);
	model_view *= RotateX(10);


	//if(prologue < 20) {
	//	model_view *= Translate(0.0f, -20.0f+prologue, 0.0f);
	//	cam_eye = vec4(rotateX, 0.0, rotateZ, 1.0);
	//	model_view *= LookAt(cam_eye, cam_ref, cam_up);
	//}
	
	//if(timeline > 57)
	//	model_view *= Translate(0.0f, -temp3, -0.0f);

	// Draw Scene
	drawScene();

	// Draw Leaf
	if(timeline < 8.0f) {
		mvstack.push(model_view);
			model_view *= Translate(0.0f, 25.0f-prologue, 0.0f);
			model_view *= RotateZ(leafSway);
			model_view *= Translate(4.0f, -1.0f-prologue, 3.0f);
			drawLeaf();
		model_view = mvstack.pop();
	}

	/*/ // Draw Bee
	if(timeline > 35.0f && timeline < 38.0f) {
		mvstack.push(model_view);
			model_view *= Translate(15.0f-(temp2-230), pathBeeVert, 4.5f);
			model_view *= Scale(0.5f, 0.5f, 0.5f);
			drawBee();
		model_view = mvstack.pop();
	}
	/*/ 
    //draw GFS
	mvstack.push(model_view);

	if(timeline>28&&timeline<36)
		{
			model_view *= Translate(47.5f-temp5/2, 0.0f, 3.0f);
		    model_view*=RotateY(-90);
			record=40.0f-temp5/2;
	    }

	else if(timeline>=36&&timeline<=40)
	{

		model_view *= Translate(7.5f, 0.0f, 4.0);
		model_view*=RotateY(-135);
	}
	else if(timeline>40&&timeline<59)
	{
		model_view *= Translate(7.5f+temp6/4, 0.0f, 2.0f);
		model_view *= RotateY(90);
	}
	if(timeline>=28)
		drawGFS(1,1,1);

	model_view = mvstack.pop();

	// Draw Male
	mvstack.push(model_view);
		if(timeline > 20.0f && timeline < 24.0f) {
			model_view *= Translate(-5.0f+temp, 0.0f, 2.25f);
			prevX = -5.0+temp;
		}
		else if(timeline >= 24.0f && timeline < 27.0f)
			model_view *= Translate(prevX-temp, 0.0f, 2.25f);
		else if(timeline > 30.5 && timeline < 36.0) {
			model_view *= Translate(-25.0+temp2/10, -.75f, 4.5f);
			prevX = -25.0+temp2/10;
			model_view *= RotateY(90);
		}
		else if(timeline >= 35.0f && timeline < 55.0) {
			model_view *= Translate(prevX, -.75f, 4.5f);
			model_view *= RotateY(135);
		}
		drawDiaoSi(0.3f, 0.6f, .6f);
	model_view = mvstack.pop();

	// Draw Female
	if(timeline > 8.0f) {
		mvstack.push(model_view);
			if(timeline < 12.0f) {
				model_view *= Translate(29.0f-2*timeline, -1.25f, 4.5f);
				model_view *= RotateY(-90);
			}

			if(timeline > 12.0f && timeline < 13.5) {
				model_view *= Translate(5.0f, -1.25f, 4.5f);
				model_view *= RotateY(-90+temp*1.25);
			}

			if(timeline > 13.5f && timeline < 40.0f || timeline > 53.75)
				model_view *= Translate(5.0f, 0.0f, 2.25f);

			if(timeline >= 40.0f && timeline < 59.0f) {
				model_view *= Translate(5.5f+temp6/4, -1.25f, 4.5f);
				model_view *= RotateY(90);
			}

		/*/	if(timeline > 50.0f && timeline < 53.75) {
				if(15.0f-(temp2-560)/10 > 5.0) {
					model_view *= Translate(15.0-(temp2-560)/10, -1.25f, 4.5f);
					prevY = 15.0-(temp2-560)/10;
				}
				else
					model_view *= Translate(prevY, -1.25f, 4.5f);

				if(timeline < 52.6f)
					model_view *= RotateY(-90);
				else
					model_view *= RotateY(-90+temp*2);
			}
		 /*/
			if(timeline < 59.0)
				drawFemale(1.0f, 0.0, 1.0f);
			//else
			//	drawFemale(1.0f, 1.0f, 1.0f);

		model_view = mvstack.pop();
	}

	if(timeline > 59.0)
		exit(0);

	getFPS();

    glutSwapBuffers();
    if(Recording == 1)
        FrSaver.DumpPPM(Width, Height) ;
}
Ejemplo n.º 11
0
/*******************************************************************************
Function that gets called by the event handler to draw the scene.
*******************************************************************************/
void display(void)
{
	//glClearColor (red, green, blue, alpha)
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);		//Set the background color.
	
	//OK, now clear the screen with the background color.
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//Load initial matrix transformation.
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	//Locate the camera.
	gluLookAt (g_eye[X], g_eye[Y], g_eye[Z], g_ref[X], g_ref[Y], g_ref[Z], 0.0, 1.0, 0.0);

	HMatrix arcball_rot;
	Ball_Value(g_arcBall,arcball_rot);
	glMultMatrixf((float *)arcball_rot);

	//Scale the scene in response to mouse commands.
	glScalef(g_zoom, g_zoom, g_zoom); 

	////////////////////// Draw the geometries in World ////////////////////////

	//drawGeom( Object.Geom );
	//drawGeom( Rod.Geom );
	drawGeom(body.Geom);
	drawGeom(middleRightLeg.Geom);
	drawGeom(middleLeftLeg.Geom);
	drawGeom(middleLeftOuterLeg.Geom);
	drawGeom(middleRightOuterLeg.Geom);
	drawGeom(brLeg.Geom);
	drawGeom(backRightOuterLeg.Geom);
	drawGeom(blLeg.Geom);
	drawGeom(backLeftOuterLeg.Geom);
	drawGeom(frLeg.Geom);
	drawGeom(frontRightOuterLeg.Geom);
	drawGeom(flLeg.Geom);
	drawGeom(frontLeftOuterLeg.Geom);

	for (auto i = 0; i < animator.foodParticles.size(); ++i)
	{
		drawGeom(animator.foodParticles.at(i).odeObject.Geom, animator.foodParticles.at(i).colored );

	}

	drawGeom(target.Geom);

	glPushMatrix();						//Draw the collision plane.
	glTranslated( 0.0, -0.05, 0.0 );
	glScaled( 140.0, 0.1, 140.0 );
	GDrawing::setColor( 0.4, 0.4, 1.0 );
	GDrawing::drawCube();
	glPopMatrix();

	////////////////////////////////////////////////////////////////////////////

	glutSwapBuffers();
	if( g_recording == 1)
		g_frameSaver.DumpPPM(g_width,g_height);
}