0% found this document useful (0 votes)
79 views23 pages

CG Mini Project

The document is a mini project report on 'Weather Simulation with Dynamic Effects' submitted by Sumeet Govind Dhumal to Savitribai Phule Pune University as part of the Computer Graphics Laboratory. The project showcases an interactive application simulating various weather conditions like rain, snow, thunderstorms, and sunny weather, utilizing computer graphics techniques for dynamic visual effects. It includes user interaction, educational applications, and potential for future enhancements in graphics programming.

Uploaded by

Sumeet Dhumal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views23 pages

CG Mini Project

The document is a mini project report on 'Weather Simulation with Dynamic Effects' submitted by Sumeet Govind Dhumal to Savitribai Phule Pune University as part of the Computer Graphics Laboratory. The project showcases an interactive application simulating various weather conditions like rain, snow, thunderstorms, and sunny weather, utilizing computer graphics techniques for dynamic visual effects. It includes user interaction, educational applications, and potential for future enhancements in graphics programming.

Uploaded by

Sumeet Dhumal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

A Mini Project Report On

Weather Simulation with Dynamic Effects

SUBMITTED TO THE SAVITRIBAI PHULE PUNE UNIVERSITY,


PUNE IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR
THE AWARD OF

SECOND YEAR COMPUTER ENGINEERING

SUBMITTED BY
SUMEET GOVIND DHUMAL

UNDER THE GUIDANCE OF


PROF. SHOBHA BAMANE MAM

DEPARTMENT OF COMPUTER ENGINEERING ISBM COLLEGE OF


ENGINEERING PUNE – 411041 2023-24

AFFILIATED TO

SAVITRIBAI PHULE PUNE UNIVERSITY


2

CERTIFICATE

This is to certify that the seminar report entities

Weather Simulation with Dynamic Effects

Submitted by

Sumeet Govind Dhumal


ROLL NO:11

is a bonafide work carried out by the aforementioned students under the valuable guidance of
Prof. Shobha Bamane. This project has been successfully completed and approved as part of
the requirements for the Computer Graphics Laboratory – Mini Project, undertaken as a
partial fulfillment of the academic requirements for the Bachelor of Engineering program
under the esteemed Savitribai Phule Pune University.

Prof. S.P. BAMANE DR. V R JOSHI


Subject Teacher HOD, Computer Engineering

DR.P. K SRIVASTAVA
Principal

Place –
Date –

ISBM COE, COMPUTER DEPARTMENT


3

ACKNOWLEDGEMENT
I am deeply grateful to Prof. Shobha Bamane, our esteemed guide, for her invaluable support,
expert guidance, and constant encouragement throughout the duration of this project,
"Weather Simulation with Dynamic Effects." Her insights and suggestions have been
instrumental in the successful completion of this work.
We extend our sincere thanks to the Department of Computer Engineering and the faculty for
providing the necessary resources and an environment conducive to learning and innovation.
We also express our gratitude to the Savitribai Phule Pune University for including this
project as part of the Computer Graphics Laboratory – Mini Project, allowing us to explore
and enhance our technical skills.
We are also grateful to our peers and colleagues for their constructive feedback and support
during the development of this project.

ABSTRACT
This project, "Weather Simulation with Dynamic Effects," demonstrates the implementation
of an interactive computer graphics application designed to simulate various weather
phenomena.
The application allows users to experience four dynamic weather conditions: Rain, Snow,
Thunderstorms, and Sunny Weather. Each condition is enriched with visual elements such
as drifting clouds, animated precipitation, and environmental interactions influenced by wind
speed. Additionally, features like lightning effects during thunderstorms, a glowing sun with
rays, and moving grass contribute to a more immersive experience.
The program incorporates user interaction, enabling the transition between different weather
states through keyboard inputs. Wind effects are applied dynamically, affecting the movement
of rain, snow, and clouds, thereby enhancing realism. Static elements such as a house, trees,
grass, and a deer serve to create a visually appealing background for the simulation.
This project not only demonstrates the practical application of computer graphics concepts
such as animation, transformation, and object rendering but also showcases the creative
potential of programming to replicate natural phenomena. The simulation serves as a stepping
stone for further exploration in graphical programming, such as advanced rendering
techniques and real-time environment modelling.

ISBM COE, COMPUTER DEPARTMENT


4

S NO. Table of contents Page No

1 Introduction 5

2 Scope of project 7

3 Application 9

4 Source code 11

5 Outputs 18

6 Future scope 20

7 References 22

8 Conclusion 23

ISBM COE, COMPUTER DEPARTMENT


5

INTRODUCTION

 Weather simulation is an engaging domain in computer graphics, involving the use of


programming and mathematics to recreate natural phenomena.
 The project, "Weather Simulation with Dynamic Effects," is an interactive graphical
application designed to simulate various weather conditions such as:
 Rain
 Snow
 Thunderstorms
 Sunny weather
 Objective: To utilize the graphics.h library for creating a realistic and interactive weather
environment, demonstrating the practical application of computer graphics techniques.
 Key Features:
 Dynamic elements like drifting clouds, wind-affected precipitation (rain and snow),
lightning during thunderstorms, and a glowing sun.
 Static elements including a house, trees, grass, and a deer to create a visually rich
background.
 Interactive controls allowing users to switch weather states using keyboard inputs.
 Developed as part of the Computer Graphics Laboratory – Mini Project under the
curriculum of Savitribai Phule Pune University.
 Purpose:
 To provide hands-on experience in applying computer graphics concepts such as
animation, transformation, and rendering.
 To offer insights into creating interactive and dynamic simulations.
 Applications:
 Serves as a foundation for more advanced projects in game development, real-time
rendering, and environmental modeling.
 The project showcases the potential of computer graphics in creating realistic
visualizations while fostering a deeper understanding of natural phenomena in virtual spaces.

 The program uses the graphics.h library for rendering graphical elements and
animations.
 It follows a modular approach, with different functions dedicated to specific tasks
such as drawing rain, snow, sun, clouds, trees, grass, and a deer.

ISBM COE, COMPUTER DEPARTMENT


6

 A while loop maintains the continuous rendering of the scene, allowing for real-time
animation and user interaction.
 The program supports four weather states:
 Rain: Raindrops are drawn as slanted lines using the line() function, affected by a
windSpeed variable to simulate wind.
 Snow: Snowflakes are drawn as small circles using the circle() function, with
horizontal drift controlled by windSpeed.
 Thunderstorm: Combines rain and occasional lightning, with lightning generated
randomly using the rand() function.
 Sunny Weather: A glowing sun is drawn using the fillellipse() function, with rays
extending outward created using trigonometry.
 Background Color: Changes dynamically based on the weather state to enhance realism
(e.g., light blue for rain, dark gray for thunderstorms).
 Clouds:
 Clouds are drawn as overlapping ellipses and are animated to drift horizontally across
the screen.
 Their positions are updated in each frame using the applyWindEffect() function,
which shifts their x-coordinates and resets them when they move off-screen.
 Wind Effect:
 The applyWindEffect() function adjusts the positions of rain, snow, and clouds,
simulating the horizontal motion caused by wind.
 Lightning:
 Lightning strikes are drawn randomly during thunderstorms using white lines.
 The randomness is controlled by rand(), and the screen briefly clears after the strike
for a flashing effect.

ISBM COE, COMPUTER DEPARTMENT


7

SCOPE OF PROJECT
The project, "Weather Simulation with Dynamic Effects," showcases the potential of
computer graphics in creating realistic and interactive weather simulations. The scope of this
project extends across multiple domains and offers a foundation for future enhancements.
1. Educational Scope
 Learning Platform: This project serves as an excellent learning tool for
understanding the fundamentals of computer graphics, including drawing primitives,
animation, and rendering techniques.
 Practical Application: Demonstrates how theoretical knowledge of graphics is
applied to create dynamic visual simulations.
 Foundation for Advanced Projects: Provides a base for exploring more complex
topics such as 3D modeling, real-time rendering, and game development.

2. Technological Scope
 Graphics Programming:
o Focuses on the use of graphics.h to create interactive environments.
o Introduces techniques like wind effects, dynamic object movement, and
randomization for realistic animations.
 User Interaction: Highlights how interactive systems can be designed, with keyboard
input driving real-time state changes.
 Modularity: The code structure ensures flexibility for integrating additional weather
effects or enhancing existing ones.

3. Creative Scope
 Realistic Visual Effects: Encourages creativity in designing visually appealing
scenes, such as animated clouds, precipitation, and environmental interactions.
 Customization: Opens opportunities for tailoring visual elements, like adding more
detailed environments (e.g., cities, forests) or seasonal themes.

4. Application Scope
 Weather Visualization:
o Can be expanded into tools for visualizing weather forecasts or educational
demonstrations of weather phenomena.
 Game Development: Forms the basis for incorporating weather effects in video
games or simulations, enhancing immersion and realism.

ISBM COE, COMPUTER DEPARTMENT


8

 Entertainment and Art: Can be used to create visually captivating animations for
artistic or entertainment purposes.

5. Future Expansion
 Advanced Graphics: The project can be extended to include 3D weather simulations
using libraries like OpenGL or DirectX.
 Real-World Data Integration: Incorporating real-time weather data for accurate
simulations.
 Enhanced Interactivity: Adding mouse-based controls or touch screen compatibility
for improved user experience.
 Complex Animations: Integrating effects like fog, shadows, and light reflections to
increase realism.

6. Industry and Research Applications


 Training Simulations: Developing training modules for meteorologists or
environmental scientists.
 Research Tools: Creating interactive platforms to study weather patterns or
environmental effects.

ISBM COE, COMPUTER DEPARTMENT


9

APPLICATIONS

The "Weather Simulation with Dynamic Effects" project has a broad range of potential
applications across various fields. By leveraging computer graphics and interactive weather
simulation techniques, this project can be adapted for use in multiple domains. Below are
some of the key applications:

1. Educational Tools and Training


 Meteorology Education:
o The simulation can be used as an educational tool to teach students about
weather phenomena, including how different weather conditions such as rain,
snow, and thunderstorms develop and interact.
o It can also help students understand the effects of environmental factors, like
wind speed and cloud formation, on weather behavior.
 Environmental Science:
o The project can be used to demonstrate the impact of weather on ecosystems,
including how rainfall, temperature, and wind influence plant growth and
animal behavior.
 Interactive Learning Platforms:
o In educational platforms, the simulation could be integrated as a part of a more
complex system for teaching physics, climate science, or geography.

2. Gaming Industry
 Weather Effects in Games:
o Weather effects play a critical role in many modern games, impacting
gameplay, visual aesthetics, and player experience. This project could serve as
the foundation for developing dynamic weather systems in video games,
where rain, snow, fog, and storms can affect visibility, mobility, and other in-
game mechanics.
 Survival Games:
o The simulation could be expanded for use in survival or adventure games
where the weather influences player decisions. For example, players may need
to shelter from a thunderstorm or prepare for blizzards, making the gameplay
more immersive.

ISBM COE, COMPUTER DEPARTMENT


10

3. Real-Time Weather Visualization


 Weather Forecasting Visualization:
o By integrating real-time weather data from weather APIs, this simulation
could be transformed into a tool for visualizing live weather conditions in
specific geographic locations.
o Meteorologists could use the system to demonstrate weather patterns or create
forecasts that are visually represented for public understanding.
 Environmental Research:
o The simulation could serve as a tool for research projects that require real-time
or historical weather data, providing a visual medium for understanding
climate change or atmospheric studies.

4. Simulation and Virtual Reality (VR)


 Weather Simulations for VR Environments:
o In virtual reality (VR), the project can be expanded to create immersive
environments where users experience weather changes, from thunderstorms to
clear skies, in a fully interactive 3D space.
 Training Simulators:
o Weather simulations can be used for training purposes, such as preparing
pilots or ship captains for navigating through different weather conditions. It
can also be applied in disaster management training where users learn how to
respond to extreme weather events like hurricanes or floods.

5. Weather-based Decision Making Systems


 Agriculture:
o The simulation can be used to model how weather impacts crop growth,
harvest times, and pest behavior, aiding farmers in making weather-based
decisions for optimal planting and harvesting.
 Travel and Transportation:
o In transportation and logistics, weather conditions play a crucial role in
decision-making. Airlines, shipping companies, and ground transport
companies could integrate this kind of simulation to predict how weather will
affect routes, delays, and safety measures.

ISBM COE, COMPUTER DEPARTMENT


11

SOURCE CODE

#include <graphics.h>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <conio.h>

// Function Prototypes
void drawRain(int count, int windSpeed);
void drawSnow(int count, int windSpeed);
void drawCloud(int x, int y);
void drawSun();
void drawLightning();
void drawEnvironment();
void drawGrass();
void drawDeer();
void drawTree(int x, int y, int type);
void applyWindEffect(int &x, int windSpeed);

// Global Constants
const int screenWidth = 800;
const int screenHeight = 600;

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, (char*)"");

srand(time(0));

ISBM COE, COMPUTER DEPARTMENT


12

int weatherState = 0; // 0 = Rain, 1 = Snow, 2 = Thunderstorm, 3 = Sun


int windSpeed = 2; // Wind speed affecting rain/snow
int cloudX1 = 0; // Position of cloud group 1
int cloudX2 = 300; // Position of cloud group 2
bool running = true;

while (running) {
cleardevice();

drawEnvironment();

switch (weatherState) {
case 0: // Rain
setbkcolor(LIGHTBLUE);
drawRain(100, windSpeed);
break;
case 1: // Snow
setbkcolor(COLOR(0, 0, 128)); // Dark blue background
drawSnow(100, windSpeed);
break;
case 2: // Thunderstorm
setbkcolor(DARKGRAY);
drawRain(50, windSpeed);
drawLightning();
break;
case 3: // Sun
setbkcolor(LIGHTCYAN);
drawSun();
break;
}

ISBM COE, COMPUTER DEPARTMENT


13

drawCloud(cloudX1, 100);
drawCloud(cloudX1 + 200, 120);
drawCloud(cloudX2, 80);
drawCloud(cloudX2 + 250, 140);
applyWindEffect(cloudX1, windSpeed);
applyWindEffect(cloudX2, windSpeed);

drawGrass();
drawDeer();

if (_kbhit()) {
char key = _getch();
if (key == '1') weatherState = 0; // Rain
if (key == '2') weatherState = 1; // Snow
if (key == '3') weatherState = 2; // Thunderstorm
if (key == '4') weatherState = 3; // Sun
if (key == 'q') running = false; // Quit
}

delay(50);
}

closegraph();
return 0;
}

void drawRain(int count, int windSpeed) {


setcolor(CYAN);
for (int i = 0; i < count; i++) {

ISBM COE, COMPUTER DEPARTMENT


14

int x = rand() % screenWidth;


int y = rand() % screenHeight;
line(x, y, x + windSpeed, y + 10);
}
}

void drawSnow(int count, int windSpeed) {


setcolor(WHITE);
for (int i = 0; i < count; i++) {
int x = rand() % screenWidth;
int y = rand() % screenHeight;
circle(x + windSpeed, y, 2);
}
}

void drawCloud(int x, int y) {


setfillstyle(SOLID_FILL, LIGHTGRAY);
fillellipse(x, y, 50, 30);
fillellipse(x + 30, y, 50, 30);
fillellipse(x - 30, y, 50, 30);
}

void drawSun() {
setcolor(YELLOW);
setfillstyle(SOLID_FILL, YELLOW);
fillellipse(screenWidth - 100, 100, 50, 50);

for (int i = 0; i < 360; i += 30) {


int x1 = screenWidth - 100 + 50 * cos(i * M_PI / 180.0);
int y1 = 100 + 50 * sin(i * M_PI / 180.0);

ISBM COE, COMPUTER DEPARTMENT


15

int x2 = screenWidth - 100 + 70 * cos(i * M_PI / 180.0);


int y2 = 100 + 70 * sin(i * M_PI / 180.0);
line(x1, y1, x2, y2);
}
}

void drawLightning() {
if (rand() % 20 < 2) {
setcolor(WHITE);
for (int i = 0; i < 3; i++) {
int x = rand() % screenWidth;
line(x, 0, x + 30, 100);
line(x + 30, 100, x, 200);
delay(100);
}
cleardevice();
}
}

void drawEnvironment() {
setcolor(GREEN);
setfillstyle(SOLID_FILL, GREEN);
bar(0, screenHeight - 100, screenWidth, screenHeight);

setcolor(DARKGRAY);
setfillstyle(SOLID_FILL, DARKGRAY);
bar(0, screenHeight - 50, screenWidth, screenHeight);

setcolor(RED);
setfillstyle(SOLID_FILL, RED);

ISBM COE, COMPUTER DEPARTMENT


16

bar(50, screenHeight - 200, 200, screenHeight - 100);

setcolor(BROWN);
setfillstyle(SOLID_FILL, BROWN);
int roof[] = {50, screenHeight - 200, 200, screenHeight - 200, 125, screenHeight - 250, 50,
screenHeight - 200};
fillpoly(4, roof);

drawTree(300, screenHeight - 150, 1);


drawTree(500, screenHeight - 150, 2);
drawTree(650, screenHeight - 150, 1);
}

void drawGrass() {
setcolor(GREEN);
for (int i = 0; i < screenWidth; i += 20) {
line(i, screenHeight - 100, i + 10, screenHeight - 110);
}
}

void drawDeer() {
setcolor(BROWN);
setfillstyle(SOLID_FILL, BROWN);
bar(400, screenHeight - 130, 430, screenHeight - 100);
circle(435, screenHeight - 120, 10);
line(430, screenHeight - 130, 420, screenHeight - 150);
line(435, screenHeight - 130, 445, screenHeight - 150);
}

void drawTree(int x, int y, int type) {


setcolor(BROWN);

ISBM COE, COMPUTER DEPARTMENT


17

setfillstyle(SOLID_FILL, BROWN);
bar(x, y, x + 20, y + 50);

setcolor(GREEN);
setfillstyle(SOLID_FILL, GREEN);
if (type == 1) {
fillellipse(x + 10, y - 20, 30, 40);
} else {
int leaves[] = {x - 20, y, x + 40, y, x + 10, y - 60, x - 20, y};
fillpoly(4, leaves);
}
}

void applyWindEffect(int &x, int windSpeed) {


x += windSpeed;
if (x > screenWidth) x = 0;
}

ISBM COE, COMPUTER DEPARTMENT


18

OUTPUT

ISBM COE, COMPUTER DEPARTMENT


19

ISBM COE, COMPUTER DEPARTMENT


20

FUTURE SCOPE

The project, "Weather Simulation with Dynamic Effects," has immense potential for future
enhancements and expansions. Below are the key areas where the project can be further
developed:

1. Advanced Graphics and Realism


 3D Rendering: Transition from 2D to 3D simulations using advanced graphics
libraries like OpenGL, DirectX, or Unity for more realistic visuals.
 Enhanced Animation: Add detailed animations such as fluttering leaves, rippling
water during rain, and swaying grass or trees in windy conditions.
 Lighting and Shadows: Introduce dynamic lighting and shadows based on the time
of day or weather type.
 Fog and Mist Effects: Simulate atmospheric phenomena like fog, mist, or haze to
make the environment more immersive.

2. Integration with Real-World Data


 Live Weather Data: Connect the simulation to real-time weather data APIs to
visualize current weather conditions in specific locations.
 Seasonal Changes: Implement dynamic seasonal effects, such as blooming flowers in
spring or falling leaves in autumn.
 Geographical Features: Add realistic terrain features like mountains, rivers, or
oceans based on actual geographical data.

3. User Interaction Enhancements


 Mouse and Touch Controls: Enable users to interact with the simulation using
mouse clicks or touch gestures.
 Weather Customization: Allow users to control parameters like wind speed,
precipitation intensity, or cloud density in real time.
 Time-of-Day Transitions: Include a time progression feature with weather changes
based on day or night.

4. Applications in Game Development


 Interactive Games: Use the weather simulation as a core component in adventure or
survival games where weather affects gameplay.

ISBM COE, COMPUTER DEPARTMENT


21

 Dynamic Environments: Create games with weather-influenced terrains, such as


slippery roads during rain or reduced visibility in fog.

5. Educational and Research Tools


 Weather Education: Develop tools for teaching meteorology or environmental
science, showcasing how weather phenomena form and behave.
 Climate Research: Use the simulation as a platform to model climate patterns or
study environmental effects.

6. Advanced Environmental Effects


 Natural Events: Add simulations for rare weather events like hurricanes, tornadoes,
or blizzards.
 Interactive Ecosystem: Introduce wildlife interactions and plant growth affected by
weather conditions.
 Urban Scenarios: Simulate weather in urban environments with effects like rainwater
runoff or traffic disruptions.

7. Multi-Platform Support
 Mobile Applications: Port the project to Android or iOS platforms for a wider
audience.
 Web Integration: Develop a web-based version using technologies like WebGL or
HTML5 Canvas.
 VR/AR Compatibility: Extend the project to Virtual Reality (VR) or Augmented
Reality (AR) platforms for an immersive experience.

8. Machine Learning and AI Integration


 Predictive Weather Modeling: Incorporate AI algorithms to predict and visualize
future weather conditions.
 Intelligent Interactions: Use AI to simulate realistic animal behaviors or
environmental changes based on weather.

ISBM COE, COMPUTER DEPARTMENT


22

REFERENCES

The development of the project "Weather Simulation with Dynamic Effects" was guided by
concepts, techniques, and resources from various areas of computer graphics and
programming. The following references were utilized:
1. Libraries and APIs:
o Borland Graphics Interface (BGI): The graphics.h library was extensively used
for rendering graphical elements and animations.
2. Online Documentation and Tutorials:
o GeeksforGeeks: Articles on graphics.h basics and implementation of graphical
projects.
https://www.geeksforgeeks.org
o TutorialsPoint: Reference for trigonometry and mathematical calculations in
programming.
https://www.tutorialspoint.com
3. Academic Resources:
o Computer Graphics Laboratory Manual, Savitribai Phule Pune University
syllabus guidelines.
o Example projects and case studies from academic archives on weather
visualization and animation.
4. Open Source Inspiration:
o GitHub repositories and code snippets showcasing implementations of basic
weather simulation concepts.
o Forums such as Stack Overflow for debugging and optimization solutions.
5. Mathematical Foundations:
o Use of trigonometric functions (sin, cos) and randomization techniques (rand)
for creating animations and effects.
o Basic physics principles for simulating wind and precipitation effects.

ISBM COE, COMPUTER DEPARTMENT


23

CONCLUSION

The project "Weather Simulation with Dynamic Effects" successfully demonstrates the
application of computer graphics in creating a dynamic and interactive simulation of various
weather conditions. By using the graphics.h library, we have simulated weather states such as
rain, snow, thunderstorms, and sunny weather, each with corresponding visual effects like
raindrops, snowflakes, lightning, and sun rays.
Key Highlights of the Project:
1. Interactive Design: Users can control the weather state in real-time using simple
keyboard inputs, enhancing user engagement.
2. Dynamic Weather Effects: The simulation adapts based on the selected weather
state, with elements like clouds, wind effects, and precipitation reacting to changes in
the environment.
3. Educational Value: This project serves as a powerful learning tool for understanding
computer graphics, animation, and the integration of real-time interactive systems.
4. Modular Approach: The code is structured in a way that makes it easy to add more
features, such as additional weather types, advanced animations, or interactive
elements.
Achievements and Insights:
 The use of basic graphics primitives such as lines, circles, and polygons effectively
created a realistic and visually appealing simulation.
 The application of trigonometry for sun rays and randomness for cloud and
precipitation movement added a layer of realism to the simulation.
 The project showcased practical programming techniques like animation, event-
driven programming, and real-time updates that are key to interactive graphics
applications.

ISBM COE, COMPUTER DEPARTMENT

You might also like