Skip to content

Hanaa-22/3D-Orbit-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ 3D Orbit System

A realistic solar system simulation with Earth, Moon, and Sun orbiting in 3D space !

๐ŸŽฎ Overview

An interactive 3D visualization of a solar system where you can freely navigate and observe celestial bodies in motion with realistic lighting and dynamic effects.

> Scene Description:

A cosmic environment featuring the Sun at the center, Earth orbiting around it while rotating on its axis, and the Moon circling Earth. The background contains 1000 twinkling stars creating a stellar atmosphere, with 30 falling stars streaking across space. Dynamic dual-lighting system from both the Sun and Moon illuminates the scene realistically.

> Navigation:

  1. Move freely in 3D space with WASD and arrow keys
  2. Rotate camera with LEFT/RIGHT arrows
  3. Zoom in/out to observe planets in detail
  4. Control time to speed up or slow down orbital motion
  5. Watch realistic planetary rotations and orbital mechanics

> Key Controls:

WASD          : Move Forward/Backward/Left/Right
UP/DOWN       : Move Up/Down
LEFT/RIGHT    : Look Left/Right
Z / X         : Zoom In/Out
+ / -         : Speed Up/Slow Down Time (0.1x to 5x)
R             : Reset Time to Normal Speed
ESC           : Exit

๐Ÿ› ๏ธ Implemented Technical Features

  • Free camera movement with full 3D navigation
  • Hierarchical transformations for orbital mechanics (Earth around Sun, Moon around Earth)
  • Phong lighting model with ambient, diffuse, and specular
  • Dual light sources (Sun as primary, Moon as secondary)
  • Dynamic textures on all celestial bodies
  • Particle systems for background and falling stars
  • Time control for animation speed

> Technologies Used:

  • C++17 with procedural programming
  • OpenGL 3.3+ (Core Profile) for 3D rendering
  • GLFW for window management and inputs
  • GLAD as OpenGL loader
  • GLM for 3D mathematics
  • STB Image for texture loading
  • CMake for build system
  • MinGW-w64 as Windows compiler

> Shader Structure:

  • Vertex Shader: MVP transformations + normal calculations + texture coords
  • Fragment Shader: Phong lighting + multi-texture support + dual light sources + star effects

> 3D Models:

  • Procedural spheres for Sun, Earth, Moon (parametric generation)
  • OBJ loader for falling stars (comet.obj)
  • Efficient mesh system with VAO/VBO/EBO

> Used Textures:

  • earth.jpg - Earth surface map
  • sun.jpg - Solar surface texture
  • moon.jpg - Lunar surface detail
  • Loaded via STB Image with automatic mipmap generation

๐ŸŽฌ ANIMATION:

1. Celestial Bodies

  • Sun: Slow axial rotation
  • Earth: Rotation on axis + orbit around Sun
  • Moon: Rotation on axis + orbit around Earth
  • Frame-independent timing for smooth animation

2. Falling Stars

  • 30 falling stars with left-to-right comet trajectory
  • High speed (15-30 units) without rotation
  • Red-blue color palette (red/blue/purple variants)
  • Respawn system when exiting boundaries

3. Background Stars

  • 1000 stars in spherical distribution
  • Twinkling effect with brightness variation
  • Point sprite rendering for circular shapes

๐Ÿ’ก LIGHTING (Phong Model):

1. Ambient Light

  • Global illumination at base intensity (0.2)
  • Uniform distribution across all objects

2. Diffuse Light

  • Sun light source: White light (1.0, 1.0, 1.0) from origin
  • Moon light source: Weak blue-ish light (0.03) from Moon position
  • Normal-based calculation: max(dot(normal, lightDir), 0.0)

3. Specular Light

  • Reflections on surfaces with Phong model
  • Material shininess:
    • Earth: 32.0 (moderate)
    • Sun: 16.0 (self-illuminated, 10x brightness boost)
    • Moon: 8.0 (rough surface)
  • View direction calculation for accurate highlights

4. Dual Light System

  • Primary source: Sun at origin with full white light
  • Secondary source: Moon with weak reflected light
  • Combined contribution in fragment shader
  • Dynamic moon position following orbital calculations

๐Ÿ“Š Important Technical Points

> Performance:

  • Optimized VAO/VBO usage with minimal state changes
  • Index buffers (EBO) for sphere geometry
  • Depth testing enabled for proper rendering
  • Efficient draw calls for all objects

> Extensibility:

  • Modular CelestialBody struct for easy planet addition
  • Configurable orbital parameters (radius, speed, size)
  • Shader-based rendering for easy effect additions

> Current Limitations:

  • Simplified physics (no real gravitational simulation)
  • Fixed orbital planes (no inclination)
  • Limited to 3 celestial bodies
  • No collision detection

๐Ÿ”ฎ Possible Future Improvements

  1. Additional planets (Mars, Jupiter, Saturn with rings)
  2. Realistic gravitational physics (N-body simulation)
  3. Planetary atmospheres with volumetric effects
  4. Shadow mapping between celestial bodies
  5. Orbit trail visualization
  6. Information overlay with real-time data
  7. Screenshot capture functionality

๐Ÿš€ How to Run the Project

> Requirements:

  • Windows 10/11 (tested on MinGW-w64)
  • CMake 3.15+
  • OpenGL 3.3+ compatible GPU

> Quick Start:

# 1. Clone/Download the project
git clone [https://github.com/Hanaa-22/3D-Orbit-System]

# 2. Navigate to project
cd tp

# 3. Compile and Launch
build_run.bat

# 4. Simulation window opens HEY HEY HEY !!

๐Ÿ“ Project Structure and Libraries

3D-OrbitSystem/
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ README.md                    
โ”œโ”€โ”€ tp/ 
โ”‚   โ”œโ”€โ”€ (build folder)                 
โ”‚   โ”œโ”€โ”€ main.cpp                 # Main entry point
โ”‚   โ”œโ”€โ”€ objload.cpp/.hpp         # OBJ model loader
โ”‚   โ”œโ”€โ”€ CMakeLists.txt           # Build configuration
โ”‚   โ””โ”€โ”€ build_run.bat            # Automatic build script
โ”‚
โ””โ”€โ”€ libs/                        
    โ”œโ”€โ”€ glad/                    # OpenGL Loader
    โ”œโ”€โ”€ GLFW/                    # Window management
    โ”œโ”€โ”€ glm-1.0.2/               # 3D mathematics
    โ”œโ”€โ”€ mingw64/                 # MinGW compiler
    โ”œโ”€โ”€ shader/                  
    โ”‚   โ”œโ”€โ”€ shader.cpp/.hpp      # Shader manager
    โ”‚   โ””โ”€โ”€ Shader.vertexshader/.fragmentshader
    โ”œโ”€โ”€ model/                   
    โ”‚   โ””โ”€โ”€ comet.obj       # Falling star 3D model
    โ”œโ”€โ”€ stb/                     
    โ”‚   โ””โ”€โ”€ stb_image.h          # Image loader
    โ””โ”€โ”€ textures/                
        โ”œโ”€โ”€ earth.jpg
        โ”œโ”€โ”€ sun.jpg
        โ””โ”€โ”€ moon.jpg

๐ŸŽ“ Project Context

This project was developed within the educational TP Project for the Image Synthesis course in C++/OpenGL.

Project Requirements (Fulfilled):

โœ… Animation - Planetary rotations, orbits, falling stars
โœ… User Interaction - Camera control, time manipulation, zoom
โœ… Lighting - Phong model with dual light sources (Sun + Moon)
โœ… Additional Features - Textures, particle systems, OBJ loading

โœจ Developed By

By: "[B.Hanaa]" - Final year student in Visual Computing master; passionate about graphics programming.

License: This project is open-source under MIT license. Feel free to use it as a base for your own educational projects!


Last Updated: [22-01-2026] Version: 1.0.0
Status: Complete and functional

About

๐Ÿ“Œ A realistic solar system simulation with Earth, Moon, and Sun orbiting in 3D space !

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors