Category Archives: Programming

Lua experiment

For some reasons, I had the opportunity to test the LUA language. I spent one evening on it, then switched to Squirrel (which is very close). What I appreciate the most with scripted languages is that the classic C++ turnaround loop (Stop — Debug — Compile — Link — Start) is made a lot easier.

I took a moment to see how basic scripting turns out in LUA, then practicing things like tables, list, sort, file IO, it ended up in this :

Table / Linked list test : put values in a table, then in a list, display them.

Sort table of values : put randomized values in a table, sort it, and display it.

Bitmap output : throw RGB pixels in a binary file. This creates a RAW file, that you can open in Photoshop as long as you know its size & depth. The purpose of this was to be able to render a Mandelbrot figure to a file.

Mandelbrot fractal : using the previous routine, this sample simply computes the famous Mandelbrot figure. Left is the result.

C++ | Empirical raytracer

Yesterday, I decided add a windowed output to a a very basic raytracer I started to write 2 years ago. I wanted to figure out how a renderer is built inside. It comes with the following features :

  • unlimited pointlights
  • load/save alias|wavefront mesh file
  • load/save tga files
  • un-efficient antialiasing, variable sampling rate
  • no space partitionning strategy (hence VERY slow)
  • bitmap manipulation(copy, box blur…)
  • mesh manipulation(translate, scale, autofit…)
  • Render window using SDL

Here’s a row output of that thing. Text stream …

Rrenderer::Rrenderer(512, 512) Rmesh::loadFileWavefront() found 861 points, 1674 triangles Rrenderer::loadFiles(), loaded 1 file(s) Rrenderer::computeNormals(), 1 mesh(es) Rrenderer::computeBoundingBoxes(), 1 mesh(es) Rrenderer::fitScene(0.750000), scale scene by (0.806781) Rrenderer::computeBoundingBoxes(), 1 mesh(es) Rrenderer::renderScene(), rendering ... line 511 Rrenderer::renderScene(), 8794 ray/polygon hit, 11520044 ray Rrenderer::renderScene(), ray casting accuracy : 0.076337 %

… and bitmap.

Things to implement, as soon as possible : a decent adaptative AA, shadow casting, a BSP, gouraud shading.
Get a snapshot here.