Giter Site home page Giter Site logo

luna2d-physics-engine's Introduction

Luna2D Physics Engine

Alt text

Table of Contents

Description

Luna2D is a 2D physics engine developed using C++ and OpenGL. It simulates basic physical phenomena such as gravity, collision, friction, and rigid body dynamics. This project is part of a bachelor's degree in computer science at Afeka - The Academic College of Engineering in Tel Aviv, and aims to provide an educational tool for understanding physics simulations in two-dimensional space.

Features

  • Simulates gravity, collisions, friction, and rigid body dynamics.
  • Integrated with OpenGL for visualization and user interaction.
  • Demonstrates fundamental physics principles through realistic simulations.
  • Supports elastic collisions and various material properties.
  • Interactive UI for modifying simulation settings.

Installation

  1. Clone the repository:
    git clone https://github.com/MichaelK4/Luna2D-Physics-Engine.git
  2. Open Luna.sln in Visual Studio.
  3. Build the solution.
  4. Run the executable from the Visual Studio or navigate to the Luna2D folder and run the executable directly.

Note: Ensure that you are running on Windows (x86).

Usage

Controls

  • 'Space': Start the Luna Engine.
  • 'Esc': Exit the program.
  • Left Click: Add polygon to scene.
  • Right Click: Add circle.
  • 'M': Open menu.
  • 'S': Stop simulation, 'F': Go frame by frame.
  • 'C': Clear the scene of any object other than static ones.

Menu Controls

  • 'M': Close menu.
  • 'C': Reset to default settings.
  • 'U': Change surface/object settings.

Object Settings

  • 'T': Switch to custom settings.
  • Left/Right Arrow: Navigate predefined object settings.

Custom Object Settings

  • 'T': Switch back to predefined settings.
  • 'R': Adjust Restitution.
  • 'D': Adjust Dynamic Friction.
  • 'S': Adjust Static Friction.

Surface Settings

  • Left/Right Arrow: Change the surface material.

Project Structure

  • main.cpp: Entry point of the application, sets up the simulation and rendering loop.
  • Vector2.cpp/h: Implements a 2D vector class with basic vector operations.
  • Mat2.cpp/h: Implements a 2D matrix class for matrix operations.
  • Material.h: Defines material properties like restitution and friction.
  • Shape.h: Abstract base class for different shapes (Circle, Polygon).
  • Manifold.cpp/h: Handles collision detection and resolution between shapes.
  • Collider.cpp/h: Manages collision data and interaction between shapes.
  • RigidBody.cpp/h: Represents physical objects with properties like mass, velocity, and forces.
  • Clock.cpp/h: Utility class for timing and frame rate control.
  • Scene.cpp/h: Manages all objects and interactions within the simulation environment.
  • Libs.h: Includes various utility functions and constants.

Measurements and Results for Evaluating the System’s Performance

  • Demonstration of Physics Principles: Accurate representation of mathematical functions and physical interactions.
  • Elastic Collision Implementation: Mostly accurate collision mechanics with minor visual inconsistencies.
  • Core Components Development: Stable performance on Windows with no bugs during test sessions.
  • OpenGL Integration: Effective rendering with minor visual issues when rapidly creating objects.

Recommendations for Further Development

  • Create a website for easier access and complex simulations.
  • Improve and make the UI more interactive.
  • Develop comprehensive tutorials and documentation.
  • Establish a community forum for user support.
  • Create an API for the system.
  • Enhance data visualization and provide detailed information on physical phenomena.
  • Run simulations on powerful servers for better performance.
  • Add options for adjusting gravity, air resistance, and realistic weather effects.
  • Consider using a more powerful library than OpenGL.
  • Prevent object overlap during creation.
  • Add a 3D simulation environment option.

License

This project is licensed under the MIT License - see the LICENSE file for details.

luna2d-physics-engine's People

Contributors

michaelk4 avatar

Watchers

 avatar

Forkers

itayifrach

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.