You are on page 1of 16

BASAVARAJESWARI GROUP OF INSTITUTIONS

BALLARI INSTITUTE OF TECHNOLOGY & MANAGEMENT


NACC Accredited Institution*
(Recognized by Govt. of Karnataka, approved by AICTE, New Delhi & Affiliated
to Visvesvaraya Technological University, Belagavi)
"JnanaGangotri" Campus, No.873/2, Ballari-Hospet Road,
Allipur, Ballar1-583 104 (Karnataka) (India)
Ph: 08392 – 237100 / 237190, Fax: 08392 – 237197

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


A Mini-Project Report

On

“ROTATING FAN”

A report submitted in partial fulfilment of the requirements for the

MINI PROJECT OF COMPUTER GRAPHICS LABORATORY

(18CSL67)

Submitted By
AKSHAY KUMAR USN: 3BR20CS009

AMANATH RASOOL USN: 3BR20CS010

Under the Guidance of


Dr. Yeresime Suresh Assoc. Prof.

Mr. Dadapeer Asst. Prof.


Dept. of CSE

Visvesvaraya Technological University


Belagavi, Karnataka 2022-2023
BASAVARAJESWARI GROUP OF INSTITUTIONS

BALLARI INSTITUTE OF TECHNOLOGY & MANAGEMENT


NACC Accredited Institution*
(Recognized by Govt. of Karnataka, approved by AICTE, New Delhi & Affiliated
to Visvesvaraya Technological University, Belagavi)
"JnanaGangotri" Campus, No.873/2, Ballari-Hospet Road,
Allipur, Ballar1-583 104 (Karnataka) (India)
Ph: 08392 – 237100 / 237190, Fax: 08392 – 237197

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

CERTIFICATE
This is to certify that the MINI PROJECT of COMPUTER
GRAPHICS LABORATORY entitle “ROTATING FAN” has been
successfully presented by AKSHAY KUMAR bearing USN 3BR20CS009
and AMANATH RASOOL bearing USN 3BR20CS010 students of VI
semester B.E for the partial fulfilment of the requirements for the
award of Bachelor Degree in Computer Science and Engineering of
the VISVESVARAYA TECHNOLOGICAL UNIVERSITY, BELGAVI
during the academic year 2022-2023.

Signature of guide Signature of HOD

Dr. Yeresime Suresh Dr. R.N. Kulkarni

Mr. Dadapeer

External viva

Name of the examiners Signature with

date 1.

2.

I
ACKNOWLEDGEMENT

The satisfactions that accompany the successful completion of our mini project on “
ROTATING FAN” would be incomplete without the mention of people who made it possible,
whose noble gesture, affection, guidance, encouragement and support crowned my efforts with
success. It is our privilege to express our gratitude and respect to all those who inspired us
in the completion of our mini-project.

We are extremely grateful to our Guides Dr. Yeresime Suresh and Mr. Dadapeer for their
noble gesture, support co-ordination and valuable suggestions given in completing the mini-
project. We also thank Dr. R. N. Kulkarni, H.O.D. Department of CSE, for his co-ordination
and valuable suggestions given in completing the mini-project. We also thank Principal,
Management and non-teaching staff for their co-ordination and valuable suggestions given to
us in completing the mini-project.

Name USN
Akshay Kumar 3BR20CS009

Amanath Rasool 3BR20CS010

II
TABLE OF CONTENTS

Chapter No Chapter Name Page No

Acknowledgement II

Table of Contents III


1 Introduction 1

1.1 About the Project 1

1.2 Problem Statement 1

1.3Objectives of the Project 2

2 System Requirements and Specifications


2.1 Software Requirements 3
3
2.2Hardware Requirements
3 Design 4

4 Implementation
4.1 Function/Method description 6
8
4.2 Results (Screen shots of the output)
5 Conclusion 9

III
CHAPTER 1

1. INTRODUTION

1.1 About the project

In this project, we have created a computer-generated model of a rotating fan using computer
graphics techniques. A rotating fan is a common household appliance that cools the surrounding air
by circulating it. Our goal was to simulate the realistic motion and appearance of a fan in a virtual
environment.
To achieve this, we employed various computer graphics algorithms and concepts. We began by
creating a model of the fan, incorporating the different components such as blades, motor, and base
Next, we focused on animating the fan's motion. By applying transformation and rotation matrices,
we were able to simulate the spinning motion of the fan blades. We took into account factors like
speed, direction, and acceleration to create a convincing and dynamic animation.
Furthermore, we implemented user interaction by allowing the viewer to control the fan's speed and
direction through a graphical interface. This provided an immersive experience where users could
adjust the fan's settings and observe the corresponding changes in the animation.
Throughout the project, we aimed to strike a balance between accuracy and computational
efficiency, ensuring smooth and visually appealing animations even on modest hardware
configurations. By leveraging the principles of computer graphics, we have successfully brought a
rotating fan to life in a virtual environment.
We hope that our rotating fan CG mini project offers an engaging and realistic experience,
showcasing the application of computer graphics techniques in creating visually compelling
simulations.

1.2 Problem Statement

To design and develop a software system for simulating Rotation of Fan , using OpenGL, where the
speed of rotation of the fan can be controlled by the user.

1
1.3 Objectives

 To create a menu that allows users to control the fan's settings, such as speed, direction, and
power on/off.

 To Create a model of a rotating fan with relevant components using computer-graphics (CG)
software.

2
CHAPTER 2

2. REQUIREMENTS SPECIFICATION

Visual Studio 2005 delivers on Microsoft’s vision of smart client applications by


letting developers quickly create connected applications that deliver the highest
quality rich user experiences. This new version lets any size organization create more
secure, more manageable, and more reliable applications that take advantage of
Windows Vista, windows7, 2007 Office System and the Web. By building these new
types of applications, organizations will find it easier than ever to capture and analyze
information so that they can make effective business decisions.

2.1 Software Requirements

An MS-DOS based operating system like Windows 98, Windows 2000 or


WindowsXP, vista, windows 7 is the platform required to develop the 2D and 3D
graphics applications.
A Visual C/C++ compiler is required for compiling the source code to make the
executable file which can then be directly executed.
A built in graphics library like glut and glut32, and header file like GL\glut.h and
also dynamic link libraries like glut and glut32 are required for creating the 3D
layout.

2.2 Hardware Requirements


The hardware requirements are very minimal and the software can run on most of
the machines.

Processor - Intel 486/Pentium processor or


above. Processor Speed - 500 MHz or above
RAM - 64MB or above Storage Space - 2 MB or above, hard disk -10MB.
Monitor resolution - A color monitor with a minimum resolution of 1000*700
Support both single & double buffering

Please note that the provided code is specific to Windows operating systems due to the inclusion
of `<windows.h>`. If you intend to run the code on a different operating system, you may need to
modify the code accordingly 3
CHAPTER 3

3. DESIGN

1. Header Files: The necessary header files, including `windows.h`, `GL/glut.h`, `stdlib.h`, and
`math.h`, are included.

2. Lighting Properties: The lighting properties, such as light position, ambient, diffuse, and
specular properties, as well as material properties, are defined using `GLfloat` arrays.

3. Global Variables: `spin` is a global variable that keeps track of the rotation angle of the fan.
`isSpinning` is a flag that indicates whether the fan is currently spinning.

4. Display Function: The `display` function is responsible for rendering the scene. It clears the
color buffer and depth buffer. Then it sets up the rotation using `glPushMatrix` and `glRotatef`.
It draws two rectangles and a torus using `glRectf`’ and `glutSolidTorus`, respectively. Finally, it
restores the previous transformation using `glPopMatrix` and flushes the rendering pipeline.

5. Spin Display Functions: The `spinDisplay_right1` and `spinDisplay_left1` functions are


responsible for updating the `spin` variable and requesting a redisplay to animate the fan rotation.

6. Initialization Function: The `init` function is used to initialize the rendering settings. It sets
the clear color, enables lighting and depth testing, sets the lighting properties, and sets the
projection matrix.

7. Keyboard Function: The `my_keyboard` function handles keyboard input. It toggles the fan
rotation on/off, increases or decreases the rotation speed, and exits the program based on the
pressed keys.

8. Menu Function: The `menu` function handles the menu choices. It toggles the fan rotation
on/off, increases or decreases the rotation speed, changes the rotation direction to clockwise or
counterclockwise, and exits the program based on the selected menu options.
4
9. Main Function: The `main` function initializes GLUT, creates a window, sets the display
mode, size, and position. It sets the display and keyboard functions, creates a menu, and attaches
it to the right mouse button. Finally, it enters the main event loop using `glutMainLoop`.

Overall, the code follows a structured design pattern where the different functions handle specific
tasks such as initialization, rendering, user input, and menu handling. The lighting effects are
achieved by enabling lighting, setting up lighting properties, and material properties. The menu
provides an interactive way to control the fan rotation, direction, and speed.
5
CHAPTER 4
4. IMPLEMENTATION

4.1 Functions used

1. `display` function module:


- `void display(void)`: Renders the scene by clearing the color buffer and depth buffer using
`glClear`. It sets up the rotation using `glPushMatrix` and `glRotatef`’. Then it draws two
rectangles using `glRectf` and a torus using `glutSolidTorus`. Finally, it restores the
previous transformation using `glPopMatrix` and flushes the rendering pipeline using
`glFlush`.

2. Fan Rotation Animation function modules:


- `void spinDisplay_right1(void)`: Updates the `spin` variable by incrementing it and
requests a redisplay using `glutPostRedisplay` to animate the fan rotation in a clockwise
direction.
- `void spinDisplay_left1(void)`: Updates the `spin` variable by decrementing it and
requests a redisplay to animate the fan rotation in a counterclockwise direction.

3. Initialization function module:


- `void init(void)`: Initializes the rendering settings by calling `glClearColor` to set the clear
color, enabling lighting and depth testing using `glEnable`, and setting up lighting and
material properties using `glLightfv` and `glMaterialfv`. It also sets the projection matrix
using `glMatrixMode` and `glOrtho`.

4. Keyboard Input function module:


- `void my_keyboard(unsigned char key, int x, int y)`: Handles keyboard input by taking
the pressed key as input. It toggles fan rotation on/off by checking the `isSpinning` flag and
setting the idle function using `glutIdleFunc`. It also handles keys 'k' and 'i' to increase and
decrease the rotation speed respectively by calling `glRotatef`. Pressing the 'Esc' key exits
the program using `exit`.
6

5. Menu function module:


- `void menu(int choice)`: Handles menu choices by taking the selected menu option as
input. It toggles fan rotation on/off, increases or decreases the rotation speed, changes the
rotation direction to clockwise or counterclockwise, or exits the program based on the
selected choice.

6. Main function module:


- `int main(int argc, char** argv)`: Initializes GLUT using `glutInit`, sets the display
mode using `glutInitDisplayMode`, creates a window using `glutInitWindowSize` and
`glutInitWindowPosition`, and creates the window with a specified title using
`glutCreateWindow`. It then initializes the rendering settings using `init`, sets the display
and keyboard functions using `glutDisplayFunc` and `glutKeyboardFunc`, creates a menu
using `glutCreateMenu`, adds menu entries using `glutAddMenuEntry`, attaches the
menu to the right mouse button using `glutAttachMenu`, and enters the main event loop
using `glutMainLoop`.

7. Clockwise and Counterclockwise Rotation Modules:


- `void spinDisplay_right1(void)`: Updates the `spin` variable by incrementing it and
requests a redisplay to animate the fan rotation in a clockwise direction.
- `void spinDisplay_left1(void)`: Updates the `spin` variable by decrementing it and
requests a redisplay to animate the fan rotation in a counterclockwise direction.
7
4.2 SNAPSHOTS

Figure 4.2.1: Home Screen

Figure 4.2.2: Menu Screen

8
CHAPTER 5
5. CONCLUSION

In conclusion, the rotating fan CG mini project successfully achieved its objective of
creating a realistic and visually appealing 2D model of a rotating fan. Through careful
design and animation, the fan blades were brought to life, giving the illusion of movement
and functionality. The project incorporated realistic lighting and shading effects, enhancing
the overall visual experience. Attention to detail and accuracy in modeling contributed to
the project's success. Overall, the rotating fan CG mini project showcased the capabilities
of computer graphics in simulating real-world objects and provided an engaging and
immersive virtual experience.

REFERENCES

 Computer Graphics Using OpenGL – F.S. Hill Jr. 2nd Edition,


Pearson Education,2001.

 Computer Graphics – James D Foley, Andries Van Dam, Steven


K Feiner,John F Hughes, Addison-Wesley 1997.
 Computer Graphics - OpenGL Version – Donald Hearn and
 Pauline Baker, 2nd Edition, Pearson Education, 2003.
 www.google.com
 www.openglforum.org

You might also like