0% found this document useful (0 votes)
10 views

CG Mini Project Report Format

Uploaded by

jeevan kuncham
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

CG Mini Project Report Format

Uploaded by

jeevan kuncham
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

A

MINI PROJECT REPORT


ON,

“Yoyo animation”

SUBMITTED TO THE SAVITRIBAI PHULE PUNE UNIVERSITY, PUNE

SUBMITTED BY

Shivam Nalawade Roll No: S5491(div-2)

DEPARTMENT OF COMPUTER ENGINEERING


NBN SINHGAD SCHOOL OF ENGINEERING, PUNE-41
SAVITRIBAI PHULE PUNE UNIVERSITY
2024 - 25

1
CERTIFICATE

This is to certify that the project report entitles


“Yoyo animation”

Submitted by
Shivam Nalawade SE Div 2 Roll No: S5491

is a bonafide work carried out by him under the supervision of Prof. P.S.Sajjashetti and it is
approved for the partial fulfillment of the requirement of University of Pune as a part of Laboratory
Practice III work syllabus (second year Computer Engineering).

(Prof.P.S.Sajjanshetti) (Dr. S. P. Bendale )

Head, Department of
Subject In-charge
Computer Engineering

2
ACKNOWLEDGEMENT

It is indeed a great pleasure and moment of immense satisfaction for we to present a mini
project report on “YoYo animation" amongst a wide panorama that provided us inspiring guidance
and encouragement, we take the opportunity to thanks those who gave us the indebted assistance.
We wish to extend our cordial gratitude with profound thanks to our internal guide
Prof.P.S.Sajjashetti for her everlasting guidance. It was his inspiration and encouragement which
helped us in completing our project.
Our sincere thanks and deep gratitude to Head of Department, Dr.S.P.Bendale and other faculty
member; but also to all those individuals involved both directly and indirectly for their help in all
aspect of the project.

Name: Shivam

Nalawade

Roll no: S5491

3
Title: Yoyo animation using opengl

Aim: Design and implement a 3D YoYo model using OpenGL primitives (e.g., spheres,
cylinders).

Theory:

This OpenGL project simulates a 3D YoYo animation, showcasing smooth motion and
rotation. The YoYo moves up and down along a virtual string, switching directions at
the top and bottom points. User input is not required. The animation runs continuously,
demonstrating realistic physics-based movement. This project utilizes GLUT and
OpenGL libraries for rendering and animation. The outcome is a visually appealing and
interactive 3D graphics simulation

 Functions Used:

 1. glutInit()
Initializes the GLUT library.
Sets up the OpenGL rendering context.

 2. glutInitDisplayMode()
Specifies the display mode for the window.
Options include RGB, single buffer, and double buffer.

 3. glutInitWindowSize()
Sets the initial width and height of the window.
Defines the viewport size for rendering.

 4. glutCreateWindow()
Creates a window with a specified title.
Displays the animated YoYo.
4
 5. glutDisplayFunc()
Registers a callback function for display updates.
Calls the display function repeatedly.

 6. glutTimerFunc()
Schedules a callback function at a specified interval.
Updates the YoYo animation periodically.

 7. glClear()
Clears buffers to prepare for rendering.
Sets the background color and clears depth buffer.
 Approach:

To create the YoYo Animation project, we start by setting up the necessary


libraries (GLUT and OpenGL) to create a 3D graphics environment. We then
define a 3D space (viewport) where our YoYo will move. Next, we create the
YoYo object using basic shapes like circles and lines.

To animate the YoYo, we use a timer to update its position and rotation at regular
intervals. We then render the updated scene using OpenGL's rendering pipeline.
Finally, we continuously display and update the animation to achieve smooth
motion.

This process is repeated continuously to create the illusion of the YoYo moving
up and down along a virtual string.

Source Code:
#include<iostream>
#include<GL/glut.h>
#include<cmath>

5
float qr;
int height = 100; //height of yoyo string

//initializes the viewport


void initDraw()
{
glClearColor(0.0,0.0,0.0,1.0);
glViewport(0,0,400,400);
glOrtho(-300.0,300.0,-300.0,300.0,-300.0,300.0);
}

int fx=0, fy=300, sx=fy, sy=fy;

//method to draw a circle


void drawCircle(int x, int y, int r)
{
glBegin(GL_POLYGON);
glTranslatef(0.0,0.0,0.0);
for(int i=0;i<360;i++){
float theta=i*2*M_PI/360;
glColor3f(0.0,0.0,1.0);
glVertex3f(x+r*cos(theta),qr+r*sin(theta),100);
glColor3f(1.0,0.0,0.0);
glVertex3f(x+r*cos(theta),qr+r*sin(theta),50);
}
glEnd();
}

//Display the yoyo in 3d


void display(){
6
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINE_STRIP);
glVertex2i(fx,fy);
glVertex2i(sx,sy);
glEnd();
glPushMatrix();
glTranslatef(0.0,sy,0.0);
glRotatef(sy,1.0,0.0,0.0);
drawCircle(0,sy,50);
glPopMatrix();
glColor3f(1.0,1.0,1.0);
glPushMatrix();
glPopMatrix();
glFlush();
}
bool poshte=1; //if yoyo is going downwards

void update(int value)


{
if(poshte){
sy=sy-10; //go lower
if(sy<=0){
poshte=false; //if yoyo id on ground
}
}
//if the yoyo is going upwards
if(!poshte){
sy+=10; //go higher
if(sy>=300) //at highest point start going lower
{
7
poshte=true;
}
}
glutPostRedisplay();
glutTimerFunc(90,update,0); //timer function that executes method each 90 ms
}
//main Functiom
int main(int argc, char*argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(600,600);
glutCreateWindow("yoyo");
initDraw();
update(0);
glutTimerFunc(90,update,0);
glutDisplayFunc(display);
glutMainLoop();
}

Conclusion:

Thus we have successfully implemented yoyo animation mini project by using various
Open gl fucntions

You might also like