my place


Bejeweled 3D - Star Wars



A funny Star Wars themed Bejeweled game made in Java for the Object Oriented Programming course. Swap ships and try to make lines (columns or rows) of three or more objects. When you make a combo, the ships fly out of the screen and you get new ones! Try to make super combos with multiple lines and even falling ships while seeing all of that Star Wars stuff moving everywhere.

I wrote the 3D interface using the [jPCT] library with the OpenGL backend and modelled the world. My colleague Inês Coelho wrote the game logic and Swing interface. André Estévão helped with the audio module.

Note: do not distribute this game, it has copyrighted content from Lucas Arts.


Bejeweled 3D - Star Wars pic 4

Bejeweled 3D - Star Wars pic 1Bejeweled 3D - Star Wars pic 2Bejeweled 3D - Star Wars pic 3Bejeweled 3D - Star Wars pic 5

Source code included.


OpenGL shadow mapping engine with third degree path interpolation


The project was written in C/C++ and is a simple modular 3D engine. The main focus was providing a base engine with shadow mapping, multi-texturing, transparency support, Wavefront 3D object loading, multiple viewports, and “first-person-shooter” controls for further experiments. The work supports cubic interpolation (Catmull-Rom spline) which is used for controlling the path and direction of the cameras and lights composing the scene. The shadow mapping algorithm is done using the fixed-pipeline with a three pass rendering, where the first pass creates the depth buffer from the light view, and both the second and third passes render the scene with the objects either in the shadow or lit. In order to show detailed shadows the engine renders the first pass in a Frame Buffer Object and then uses the depth texture in the following passes.

Future work:

Use additive blending instead of the accumulation buffer

Use cube mapping to produce shadows for the entire scene

I have to thank these tutorials, without them this work would have been 0x0000h:

shadow mapping demo 1

shadow mapping demo 2shadow mapping demo 3shadow mapping demo 4

Source code included.


Goal Game Simulation




AI project done for the same course as the Omni-Bot presentation. Has kind of a dumb name, but does exactly what it says.

Comprises of an virtual environment where two teams of bots try to steal gifts from each other and take them to capture points. The purpose of the project was to implement a multi agent system where different and autonomous agents try to complete common goals, while at the same time they negotiate between them who gets which goals. Also, the communication between all system agents are done with messages based on a common ontology.

Has a very nice 3D graphics engine, courtesy of the jPCT library. The application runs on two threads, one for the graphics and the other for the 'AI' engine.

Sorry about the extremely well designed report, I had more to worry about.


ia project

Source code included.


Omni-Bot - Artificial Intelligence bot for First Person Shooters


Short (20 minutes) presentation I did for the course 'Artificial Intelligence' regarding Omni-bot. If you don't know what it is, click this link and see what's it all about.

omnibot presentation

High resolution / performance time for Java (win32)


Java's System.nanoTime() is interesting but may have a heavy overhead depending on what happens behind the scene, so I decided to code this simple library. I also used this as an excuse to learn JNI.

Adds win32's QueryPerformanceCounter(), QueryPerformanceFrequency() and x86's RDTSC (read time stamp counter) to Java. Basically it uses JNI to make these calls from a native DLL, so if you want to run this on non windows OS, you must convert the native library.


Some warnings:

- Remember that the TSC is read as an signed long, so watch out for it's sign and wrapping (Java doesn't have an unsigned long).

- As you know, on some processors the TSC stores the number of cycles executed since the cpu's reset, so if it changes speed, the TSC no more reflects a constant unit of time. Actual solution? Pause for some time and compute it's new speed... You have been warned.

- Because a Java's thread can't be assigned to a single processor (affinity) two consecutive calls to getRDTSC() may be executed in different processors, so the returned values may be incorrect. This may be corrected by forcing the execution of the native call to be always done in the same CPU (using window's SetThreadAffinityMask() for instance). I may implement this in the near future, when I get the time.

- A last detail... If you check both QueryPerformanceCounter() and QueryPerformanceFrequency() calls you'll conclude they always take a minimum of 1.6 micro seconds (us) to execute, exactly the same taken by Java's System.nanoTime() function (this on windows), as well as it's finest time resolution. Coincidence?


Source code included.


(C) João Carlos Gonçalves

Valid XHTML 1.0 Transitional