CGR Microproject
CGR Microproject
MICRO PROJECT
DIPLOMA IN COMPUTER ENGINEERING
GOYANKA DEVESH
RATHOD GOPAL
PALE ISHWARI
RAUT AVINASH
The core of the program utilizes graphics libraries such as OpenGL, DirectX, or
higher-level frameworks like Pygame (Python) or Java's AWT and Swing to
render 2D and 3D objects on the screen. The implementation involves applying
fundamental geometric transformations—translation, rotation, and scaling—to
create motion and interaction between graphical elements. Keyframe animation
techniques and interpolation methods are used to produce smooth transitions and
object movement across the screen.
The screen saver’s visual complexity is enhanced through the use of shaders,
lighting models, and texture mapping, enabling the creation of realistic or
abstract graphical patterns. Particle systems are employed to simulate natural
phenomena such as fireworks, snowfall, or flowing water, adding a dynamic
aspect to the visual display. Additionally, procedural graphics techniques, such
as fractals and noise functions, are used to generate intricate patterns and
animations that evolve over time.
Rotation: Balloons can be made to rotate slowly as they float. In 3D, this
would involve applying a rotational matrix to the balloon around its own
axis or around a world axis (for example, rotating slightly as if swaying in
the wind).
Shearing: In 2D animations, a slight shearing transformation could be
applied to simulate wind effects, causing the balloons to tilt sideways as
they drift upward. This adds a more dynamic and natural movement to the
scene.
Forces: By simulating natural forces like gravity, drag, and wind, the
motion of the balloons can be modeled more realistically. Though the
balloons float upwards, a subtle drag force can slow their ascent, while
wind forces can push them laterally. This can be achieved by applying
Newtonian physics equations to each balloon's movement:
o Velocity update: v = v + a * dt
o Position update: p = p + v * dt
Wind Simulation: Using a random or sinusoidal function, wind can be
simulated to blow the balloons left and right. The wind’s strength can vary
over time, creating unpredictable movements in the balloons' paths. This
can be combined with procedural generation to make each balloon’s
movement unique.
5. Physics-Based Interactions
Incorporating such physics interactions makes the screen saver more dynamic,
allowing balloons to interact with one another in a realistic manner.
Efficient Memory Use: Given that the screen saver runs continuously, it
is essential to minimize memory leaks. Garbage collection and object
pooling techniques can ensure that balloons are efficiently reused or
deleted when no longer visible.
LOD (Level of Detail): For 3D implementations, using a Level of Detail
system can reduce the complexity of balloon models when they are far
away. Farther balloons can use lower-resolution meshes, improving
performance by reducing the number of polygons rendered.
Multithreading: If the system allows, rendering and updating balloon
positions can be handled in separate threads, improving performance and
responsiveness by dividing the workload between the CPU and GPU.
To ensure that the screen saver never looks exactly the same, procedural
generation techniques are used to introduce endless variations in balloon size,
color, movement, and positioning:
Random Seed: A random seed can be applied each time the screen saver
is launched, generating a unique combination of balloon attributes and
motion patterns.
Perlin Noise: Using Perlin noise or other coherent noise functions can
create more organic and smooth balloon drift patterns. This can be used
for both horizontal movement (simulating gentle wind) and vertical speed
variation.
This user interaction makes the screen saver more engaging and adaptable to
user preferences.
For broader usability, the screen saver can be made cross-platform, allowing it
to run on Windows, macOS, and Linux systems. This requires:
Cross-Platform Graphics Libraries: Choosing a cross-platform graphics
library like OpenGL, Vulkan, or a higher-level library such as SDL or
Pygame ensures compatibility across multiple operating systems.
Handling Platform-Specific APIs: Detecting system inactivity or
managing windowed fullscreen mode requires platform-specific API calls.
Wrapping these system calls in platform-agnostic code allows the screen
saver to be portable.
CODE
#include <graphics.h>
#include <conio.h>
#include <dos.h>
x
void drawBalloon(int x, int y) {
// Balloon string
line(x, y + 50, x, y + 100);
// Balloon body
setcolor(RED);
setfillstyle(SOLID_FILL, RED);
ellipse(x, y, 0, 360, 30, 50);
floodfill(x, y, RED);
}
int main() {
int gd = DETECT, gm;
int x = 200, y = 350;
int direction = -1; // Initially moving upwards
while (!kbhit()) {
cleardevice(); // Clear the screen
drawBalloon(x, y); // Draw the balloon at the current position
1. Rendering Shapes: The balloons are rendered using circles, which are a
basic geometric shape. The program teaches how to draw shapes and fill
them with color.
2. Animation: The upward movement of balloons illustrates the concept of
frame-based animation, where each frame updates the position of the
objects (balloons) and then redraws them. This method is central to
creating any animated screen saver or graphical simulation.
3. Randomization: Randomizing properties such as balloon size, color,
speed, and starting position adds variety to the animation, making it look
more dynamic and realistic.
4. Basic Physics Simulation: The balloon movement gives an elementary
introduction to simulating physical behavior (in this case, simulating
floating by moving balloons upwards at various speeds).
5. Event-Driven Programming: In some versions (such as SDL2 or SFML),
the program responds to user input events, like detecting when the user
closes the program or presses a key, making it interactive and adaptable.
Learning Outcomes:
Overall, this screen saver project offers a simple yet effective way to learn key
concepts of computer graphics and animation, and serves as an excellent starting
point for more complex graphical projects in C/C++.
REFERENCE
WEB 1 : https://www.geeksforgeeks.org/computer-graphics-2/
WEB 2: https://www.javatpoint.com/computer-graphics-tutorial
WEB 3:
https://www.tutorialspoint.com/computer_graphics/index.htm