Giter Site home page Giter Site logo

ray-tracing's Introduction

Ray Tracing Simulator

A simple, fast and friendly program to experience the power of ray tracing.

Introduction

There are 5 basic class in the program:

  • rtMgr: ray tracing manager, which manages objects and lights and provides functions relating to ray tracing.
  • mVector: Vectors and points in the space.
  • mObj: A base class about objects that can be inherited to create more complicate objects(e.g. ellipsoid).
  • mLight: Lights in the space. The position and color are adjustable.
  • pixel: Used to store RGB information with normalized value.(i.e. values are in the range of 0 ~ 1)

Usage

Objects and lights should be created through pointer and be passed to rtMgr via addObj(mObj*) or addLight(mLight*).

mObj* obj = new sphere(mVector(100,200,300),250);
mLight* light = new mLight(mVector(-150,0,500),pixel(1,1,1));
mgr -> addObj(obj);
mgr -> addLight(light);

Note: You HAVE TO free these pointers in main on your own.

To develop your own object models, you can construct object classes inheriting the base class "mObj". In each class, there are two functions necessary to be defined:

  • double isHit(mRay&): Determine when the given ray hits the object. If there is no hitting, return -1.
  • mVector nVec(mVector&): Determine the normal vector at the given point. Assume the point is on the object surface.

Known Constraints

  • The width and height must be odd numbers.
  • The window is vertical to x-y plane.
  • The x-coordinate of the window should be greater than that of the eyes. Otherwise, the y-coordinate may be opposite.

Bug Reporting

If finding any bugs, please contact me via email: [email protected] or Facebook, thanks.

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.