Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Preface

First dedicated project for a 2d emulation of laser light physics using mirrors and laser pointers

Abilities

This project offers multiple realistic features like laser light reflection and color mixing. It can be used to simulate real-life scenarios with accuracy up to an angle of 0.1 degrees.

Due to the nature of this project, being coded heavily using OOP it allows for very easy extensibility and the addition of new features like refraction and lamps can easily be done (future plans)

How to use

On running main.py you will be greeted with this screen
start_screen

The buttons on the bottom left are the available objects you can place on the screen. Pressing these buttons will create an object of that type on the screen. The buttons from left to right are:

  • Pointer
  • Poly Mirror
  • Plane Mirror
    image

In this case, I created a pointer and a mirror on the screen.
image

Selecting Objects

To select an object, hold down the select_object key default: S and left-click on an object, This will select the object and create a white outline around it. This means that you can now change the position and behavior of this object. Clicking again while pressing the select_object key will deselect the currently selected object.

image

While an object is selected, 3 textboxes with info about the objects will be shown on the top left of the screen.

image

To precisely set the position or rotation of the selected objects, type in a value in these textboxes and hit Enter, this will change the object's state.

Transforming Objects

To transform an object, select an object and then hold down the transform_object key default: T and do the following:

  • Moving an object
    Left-click anywhere on the screen and the selected object will be moved to the current position of the mouse pointer. Holding down the left-click will make the selected object follow the mouse pointer as it moves.
  • Rotating an object
    Use the right and left arrow keys to rotate the selected object.
  • Enlarging or shrinking an object
    Use the up and down arrow keys to rotate the selected objects.

image

Custom options for objects

To view the custom options for an object, select the object, hold down the custom_object key default: C, and do the following:

  • Pointers
    A slider will appear on the right side of the screen. Clicking on the slider will select the corresponding color. Clicking and dragging on the slider will allow for a precise selection of colors.

    The color determines the color of the selected laser pointer.

    image

  • Poly Mirror
    Blue buttons will be visible, which you can click and drag to move the respective vertices around. Right-clicking on the screen will create a new vertice on the nearest edge to the mouse pointer on the selected polygon.

    The red dot represents the anchor of the shape, around which the shape will be rotated and moved.

    image

Running the simulation

Pressing the green play button at the bottom right will simulate the build, and you can view how the setup works.

image

The light button on the top right determines whether the 'shaders' are toggled on or off, pressing this button will toggle the 'shader' feature (Bloom).

The pause button on the bottom right will open the build screen.

Saving the build

Pressing the escape key will open the options menu with the following options.

image

The button next to the "SAVES" button saves the current build.

Pressing the "BACK" option will return you to the build.

Manipulating saves

Pressing the "SAVES" option will open the saves screen where each available save will be listed.

image

Clicking on the name of the save will open the corresponding save, and clicking on the dustbin button will delete the corresponding save.

To create a new save, enter the name of the desired save into the textbox (only alphanumerics and _ ) and press the '+' button

Closing Notes

This project can be used for solving physics problems based on reflection of light or just to mess around with. This was just a fun project I decided to work on. Any bug reports or suggestions are welcome.

About

Emulation of Light Physics using Python and Pygame

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages