A real-time 3D traffic intersection simulation built with C++ and OpenGL, featuring realistic vehicle physics, traffic light control systems, and multiple camera perspectives.
traffic_simulation_demo.mp4
- Realistic Vehicle Physics: Smooth acceleration, deceleration, and speed-dependent turning
- Traffic Light System: Automated North-South and East-West signal timing with proper state transitions
- Multiple Camera Views: Third-person, top-down, and side-angle perspectives
- 3D Environment: Complete intersection with roads, grass terrain, trees, and infrastructure
- 3D Models: High-quality car, traffic lights, surveillance cameras, and billboard advertisements
- Interactive Controls: Arrow key vehicle control with smooth movement and turning
- HUD Display: Real-time speed, direction, heading, and position information
- Screenshot Feature: Save simulation snapshots as PPM images
- Arrow Keys: Move and turn the vehicle
- ↑ : Accelerate forward
- ↓ : Reverse/brake
- ← : Turn left
- → : Turn right
- R: Reset car to starting position
- B: Apply emergency brakes (stop immediately)
- S: Save screenshot
- ESC: Exit simulation
The simulation uses a component-based architecture:
- ObjModel: Handles loading and rendering of Wavefront .obj 3D models
- TrafficLight: Manages traffic signal states and timing
- BillBoard: Renders textured advertisement billboards
- PPMImage: Handles PPM image format for textures and screenshots
- Simulation Framework: Base classes for extensible simulation systems
- North-South: Green (5s) → Yellow (1s) → Red (6s)
- East-West: Red (6s) → Green (5s) → Yellow (1s)
- Total cycle time: 12 seconds
- Speed-dependent turning radius
- Realistic acceleration/deceleration curves
- Momentum-based movement with friction simulation
- Main View: Third-person camera following the vehicle
- Top-Down: Orthographic overhead view for navigation
- Side Views: Left and right angled perspectives for spatial awareness
Screenshots are saved as Screenshots/snapshot.ppm
and can be converted to other formats using image editing software.
- OpenGL: Core graphics rendering
- GLUT: Window management and input handling
- GLEW: OpenGL extension loading