# TechSpace

6 Articles

## The Lenzmaker Project

#### Overview

Lenzmaker Project is a Game Engine geared toward creating vast open game worlds with procedural content.

Platforms: Cross platform (Windows, Linux, Android – Working on it. 🙂 )

Written with: C/C++, OpenGL/GLSL, wxWidgets, DirectSound, OpenALPython

Architectural pattern: Interface-based programming.

API Documentation: http://lenzmaker.com/

### The beginning

Somewhere around year 2007, I embarked the journey for a game project, the development plan included both game as well as the game engine.  Using a third party engine was not in my plan as most of the commercial engines were not affordable for me during that time.  The free and the open source ones were good, since they are open source I had no idea when the authors of these frameworks discontinues their work.  Some of these Engines comes up with GPL license, integrating which may attract trouble at the time we bring it into the market as a commercial product.  Other than this legal stuff, what motivated me to write a game engine from the scratch is that the freedom it gives us to customize the source code according to the needs.  Almost all the commercial game engine’s are general purpose frameworks geared towards creating all genre of games.  Having control over the whole thing let us specifically customize the required features at the fundamental level to create some stuff, possibly an out of the box stuff like Minecraft or No Man’s Sky.  But writing things from scratch seems hard, time consuming, still its a thrilling experience.  However, adopting a 3rd party engine is an ideal choice when there is a tight “Time to market” constraints.  During the development phase, there were many situations I felt like quitting.  Once I quit and completely disconnected from it. Later, there were some wake up calls, and it put myself back on track.  If you wish to know the development effort required for writing your own game engine, then have a look at these posts on Quora and get demotivated 🙂

There are people exists on earth who is aware of hardships of climbing mount Everest, still they find joy in accomplishing it.

## The Bumblebee Project – NVIDIA Optimus support for Linux

What is the Bumblebee project?

The Ubuntu Wiki has a better explanation:

“Bumblebee aims to provide support for NVIDIA Optimus laptops for GNU/Linux distributions. Using Bumblebee, you can use your NVIDIA card for rendering graphics which will be displayed using the Intel card.Bumblebee is officially supported by Ubuntu in 14.04 newer. However, all releases are supported by the Bumblebee Project community from Ubuntu version 12.04 up to 14.04.”

I came across this while searching a driver for my graphics card.  I’m using a DELL laptop with a hybrid graphics card – NVIDIA GeForce GT 525M.  I found no satisfactory drivers in the linux(Ubuntu) platform that works perfectly.  Even though I tried configuring with different versions of NVIDIA Drivers for Ubuntu, the libGL.so module was always crashing when the application loads.  I setup bumblebee, and it worked.

Click here for the instructions to setup graphics cards for your NVIDIA Optimus laptops with Linux(Ubuntu distribution)

After configuration, use the optirun command to run the application with the NVIDIA card,

optirun ./myapp

To test it, install glmark2 which is a benchmarking tool for Opengl.

sudo apt-get install glmark2

After successful installation, run the command in the terminal,

optirun glmark2

It will show up the details of the graphics card and performs various tests along with preview.

## Blender Coordinate System to OpenGL

Some simple transformations may require when we import a 3d model from a modeling package which uses different coordinate system than the 3D engine we use.   Though both Blender and OpenGL use right handed coordinate system,  Blender is designed to have its z axis point upwards.  So if we import a 3d model which is created in Blender with its height along Z axis, the model seem to aligned with the view direction if we try to draw it in OpenGL with the default model, projection transformations.  We need to apply some rotations, translations as well as some vertex reordering to make the geometry visually appear similar to where we have created it.

I hope Blender has its coordinate system pretty hard coded into this.  And I found this question in a few game development forums asking for a solution.

Differences in Axis orientations in both Blender and OpenGL.

## Writing a scene exporter addon for Blender

This tutorial will explain how to pull the scene data(meshes, lights, cameras, animations) from Blender and dump them into a desired file format for our use.  This is what every addon in the Blender does.  This article emphasize more on how to read the required data from blender scene, not how exactly the procedures to put them into an addon.

First of all, Blender is a 3D modeling/animation platform is built using C++ and Python.  Python is used for extending its existing functionalities and is released as the Blender-Python API.  It can be found here.

## 3D Projection using lens formula

This is how I re-invented the wheel 🙂

This is an alternate approach to do projection in computer graphics using a lens formula. As it is a technique which is derived from lens formula, the focal length of the lens is the major parameter. The traditional projection techniques uses the ‘field of view’ value – which is an angle expressed in degrees or radians.

Anyways, if you are a person who didn’t even experienced the 3D graphics programming, you may ask these following questions to yourself before you get started.

1. How to draw 3D objects on a 2D Plane?

2. How can we plot a 3D vertex(x, y, z) into a 2D plane which has only 2 axes.

I asked this questions to myself long time back before attending some 3D graphics lessons. As a result, after some days of deep thought, I landed up with an idea to go through my Physics book. I flipped through the pages and stopped at the chapter Ray Optics. Finally, after some days, I ended up with some clues to solve the above problems. The final outcome of this was an equation by which we can accomplish projection. Later when I covered computer graphics I came to know that this is called the “Projection” operation in 3D Graphics. Yeah. The moment I came to know that I re-invented the wheel.

Here we start,

$\frac{1}{v} - \frac{1}{u} = \frac{1}{f}$

## Stepping into the 3rd Dimension

This is an old story. During the initial days of my computer graphics experiments, I reinvented the projection technique of 3D graphics.  Being too much excited with the Wolfenstein3D game, I was really curious to know how John Carmack did it.  The dilemma was that I haven’t covered any computer graphics topics since then, it was really doubtful for me to make it possible under dos.  One of the interesting thing is, I used an analogy to evaluate a solution for this problem.  Its nothing but the working principles of human eye, a camera, a convex lens or a mirror.  All of them maps objects in the 3-Dimensional space into a flat surface.  So I went back to take a revisit to the Ray-Optics(Geometrical Optics) taught at school to derive a projection equation based on Lenses or Mirrors.