Giter Site home page Giter Site logo

render's Introduction

3D OpenGL Rendering Engine - Ginkgo

Gravitational Lensing Simulation

Click images below for live demos:

Using data from MROBS project Simulation with Grid image Simulation with seas skybox

Engine Examples

Click images below for live demos:

Saucy Spheres Chalet Shenanigans Sphere Showdown Monkey Madness Tango Toruses

Still Images:

Basic Documentation

Each renderable is something that can be drawn to the screen. Each renderable has a mesh and a material. A mesh consists of the objects vertices/positions, index list that specify the order of the vertices to be drawn, a UV list for the texture coordinates for texture mapping, and a normal list for lighting. Such data can be loaded from a Wavefront obj file using the Objloader class.

Together, the code would look like this:

Mesh *cmesh = new Mesh();
ObjLoader obj("Render/res/models/cube.obj"); //filepath of obj file
cmesh->addData(obj.getPositionList(), obj.getIndexList(), obj.getUVList(), obj.getNormalList());

Then the renderable can be created as follows:

Renderable* cube = new Renderable(cmesh, new Material(Material::REFLECT));

In this example, the material passed can only reflect the light from its environment. There are no other properties to its material. The properties of a material are:

  • Reflective and Refractive, as specified by refractiveIndex (if refractiveIndex < 1 then reflect function will automatically be used)
  • Base Color, as specified by color
  • Lighting, as specified by specularIntensity and specularPower

The above could be used in any combination to create a variety of renderable objects. This example shows

Renderable* hi_cube = new Renderable(cmesh, new Material(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), new Texture("Render/res/textures/Hi.png")));

A layer is a group of renderables. Each renderable must be placed within a layer. A layer can be created by the following:

Layer *layer = new Layer({ cube, hi_cube });

Each renderable in the layer can be changed using the index in which it was passed in; In this example, to change the cube:

layer->alterRenderable(0)->alterModel().translateMatrix(glm::vec3(0.0f, -1.0f, -3.0f));

This retrieves cube and then retrieve's its model matrix and translates its matrix by the given vector.

The layer and all of its renderables can be moved together using the same alterModel method, which returns an object of the Transform class. The Transform class creates flexibility in changing an object's model matrix for movement.

void Game::render()				
{	
	//Start out with:			
	
	//If drawing to single texture, also include this line:
	screen->drawToTexture();

	//Initalize drawing to screen	
	ScreenBuffer::initalize();	
	//Get camera matrix
	glm::mat4 transformProjectionViewCamera = camera->getProjection() * camera->getView() * camera->getCameraPositionTranslation();

	/*
		Have rendering code here
	*/

	//If drawing to single texture, also include this line:
	screen->drawTextureToScreen();
}

Rendering code involves several aspects. The layer must call the draw function and pass in a Camera model matrix for the user's viewpoint, a PhongShader for lighting, and a CubeMap for a skybox and environmental mapping. For the lensing simulation, a LensShader can also be passed in.

render's People

Contributors

adharsh avatar

Stargazers

tnqiang avatar

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.