Tag Archives: Projects

C-A-Day

One of the suggestions my C programming professor gave us was to try to use a command line editor to do as many assignments as possible if we weren’t already familiar with one. Given that I fall in the “never used one” category, I decided to take it a bit further and do a sort of “c program a day” using Vim via the OS X terminal. The purpose is actually two-fold; I’m also using it to learn new algorithms as each program deals with an algorithm I’ve never tried writing before.

I started on the 16th by implementing Newton’s Method for finding the roots of the function x^2 = 916; in other words, the square root of 916. Yesterday I wrote a prime number sieve, and today I wrote a MergeSort implementation. I’m getting to know Vim pretty well too, and although I still prefer using an IDE I could probably survive with command line if I had to.

With regards to Ion Engine, I’ve done a bit of work on some small items over the last few days. I haven’t had time to sit down and work for a solid block of time so progress has been rather limited. Hopefully during this week I’ll be able to work on some other larger features on my list (terrain engine in particular).

Taylor

Advertisements

Mesh loader

I’ve started to work on fleshing out a proper set of mesh classes for handling mesh instancing, animation and whatnot. I scrapped my old .obj loader and wrote a new one that’s more compliant with current codebase. Here are a few shots of the space scene running with different meshes:

Given that I do my modeling in Blender 3D, I felt obligated to include Susanne, a.k.a the “Blender monkey” as one of my test objects. I haven’t setup trimesh collisions for Bullet yet, so Susanne is stuck with (rather poorly sized) bounding box. The tori use a cylinder. I’m really happy with how the lighting is working on smoother objects though, and with the scene’s performance in general.

T


Math and Campus Maps

It’s been a few days since I’ve posted as I’ve been pretty busy with frosh week events here at Waterloo. Since I’m going into software engineering, I’m technically part of both the engineering faculty and math faculty and therefore participate in events from both faculties. At this point, all “softies” have earned their engineering hard hats and pink math ties:

The other night, one of the Comp Sci guys on my floor came to my room with a pretty cool math problem that would have fit well on Project Euler. It basically wanted to know how many downward-pointing triangles were present in a pyramid made of triangles. Of course, these downward-pointing triangles could be built from multiple triangles; for 4 layers of pyramid the answer is 7 because of one bigger multi-triangle:

Arriving at a computer-friendly answer is very easy, and requires a simple nested for-loop. I also found a slightly more elegant solution with only a single for-loop, but again this solution was fairly easy to come by. The hard part began when a few more CS/Eng students arrived and asked if we could find a single equation that would work for all cases that was “calculator-friendly”, i.e. without any looping. This was tougher.

We worked for several hours that night and didn’t really produce any solid results. I decided to try again earlier this morning and I’ve finally come up with an extremely ugly solution for cases were the number of layers (n) is greater than 4:

I’m still not satisfied, but I’m putting it away because I’ve already put way too much time into it.

 The second item I mentioned in my title is an idea for an app I’ve started working on. I used my iPhone + Google Maps to get around campus for the first few days, but this required some looking back/forth between the phone and the actual campus map. I think it would be handy to have a campus map super imposed onto Google Maps. In addition this map could take building names as start/end locations and plot the optimal route. I’m hoping to have this done by the time class starts on Monday. 😛

T


New Light Manager and Deferred Rendering

I haven’t had as much time to work on Ion over the last few days, however I put in a few solid hours of coding today and finished the first version of my light manager. It’s only hooked into the deferred renderer at the moment, since I still need to finish the code that’ll allow the forward render to pull a limited number of lights based on some input factors. At the moment lights can have custom position, color, intensity and a variety of different fall-off equations. I’d like to add support for lens flares and cubemap masks later on, to add some extra visuals.

For the deferred renderer, the light values are stored in a pixel buffer which is passed into the final deferred shader. Unfortunately I’m doing something wrong with glTexSubImage2D and isn’t working properly, so I haven’t been able to add light animation to the system quite yet.

The scene setup I’m using to test things out has 7 lights in it; a white light at the center, four colored lights at the four sides of the cube stack, and then two small, bright lights (pink and cyan) directly next to the stack. I setup the scene to be in a 0-gravity space environment as well, so the effects of the lighting were more obvious. Here are a handful of screenshots of the test scene:

I also recorded a video, however QuickTime dropped the FPS down a bit. In the video each click adds another 6x6x6 group of physics cubes; at the end of the recording there are several thousand floating around. At one point there’s a bit of visual lag since I added several groups in quick succession, and the physics and render loop are tied together. Anyways, here’s the video: http://vimeo.com/28528048.

That’s it!

T


Rubik’s Cupe Map – Part 2

Earlier in the week I mentioned that I was working on “cube mapping” one of the may ways to solve a Rubik’s Cube. I’ve finished rendering out the final video of the process, starting with a scrambled cube and ending at a solved Rubik’s Cube. The movement in the cube is admittedly a bit harder to follow than I expected it to be, but the results were still quite interesting.

I’ve uploaded two versions of the video. One’s rendered at 24 fps and the other at 8 fps:

Rubik’s Cube Map Fast (24 fps)

Rubik’s Cube Map Slow (8 fps)

T


Python Support for Ion

I’ve been a bit quiet on the Ion Engine front for a few day now, mainly because I’ve been reacquainting myself with Python. As I mentioned before, I picked up a book on the language as I was considering using it as the scripting language for my engine. I’ve decided that it’s the route I want to take, so I took a look at it today to see what sort of work would have to be done.

There are two ways to integrate Python with a C++ application: compile the application as a Python module and load it into Python, or compile Python into the application and run it as an embedded interpreter. The Torque MMOKit, a package I used extensively a few years back, makes use of the first method. It caused a lot problems with packaging, since end users expect an .app or .exe file to run, not a .py file. The tool chain used a Python utility called Py2Exe to solve this, but it wasn’t without its problems and was often challenging to set up correctly. I eventually ended up moving over to the second method, which required significant work upfront but greatly simplified the overall distribution process. I plan to use the embedded method again for Ion Engine.

On the Windows platform, Python is extremely straightforward to integrate. There are pre-built .lib files included in the binary package, so no source building is required. The Mac platform is kinda in between. Apple provides Python support as part of the default libraries, but unfortunately it’s a little bit outdated at this point. I intend to use Python 3.2.x, while Snow Leopard shipped with version 2.7.x. It was fairly easy to upgrade though,and a Python.Framework is provided so I won’t need to compile source in this case either. The iPhone is a huge pain in the ass.The iPhone has very little support for Python at all; in fact until recently the App Store wouldn’t even allow embedded Python in any apps.

I haven’t been able to find compiled versions of Python 3.2 for the iPhone, so I decided to try compiling it myself. Python’s make compile settings worked just fine on my Mac, but I have no idea how to set up make to compile an iPhone library. I had to move everything over to Xcode to do this, which turned to be a lot more tedious than I expected. Eventually it all worked out though, and I was able to test a very basic “hello world” Python script in the iPhone simulator.

I intend to start integrating the Python stuff into Ion tomorrow. The end goal is to be able to control most of the game logic and world building with Python, leaving networking, rendering, scene management, etc to the core C++ engine. Since it’s a pretty big task and I’m not sure how long it will take, I plan to develop it in parallel with some of the other components I’m working on. That way I won’t get sucked into working on the one thing and burn out.

T


Rubik’s Cube Map – Part 1

As mentioned in my Chapters post, I’ve recently picked up a new classic 3x3x3 Rubik’s Cube. I’ve relearned a fairly simple solving method that only requires 6 unique move types to complete the entire cube, although it does take a lot longer than more advanced methods. Out of curiosity, I decided to try mapping the entire solving process into a series of images. The most logical way to do this was with a cube map, i.e “unfolding” the cube into 6 connected squares. A solved cube would look something like this:

There were only really two options to go about doing this. Solve it step by step and take 6 photos after each turn, or make a digital model in Blender3D. I chose the latter option, and built a digital Rubik’s cube from 27 unique cube objects. Animating the cube was simple; all I had to do was move the cubes I needed and insert them into new keyframes. I didn’t want any sort of rotational movement in the cube, just changing colors, so the keyframes are all one frame apart.

The first step was to “mess up” the digital cube. I rendered out an animation of this process, which is uploaded here:

http://vimeo.com/28371240

I realized quickly that moving the cube around digitally wasn’t going to be as easy as using the physical cube. To make the process easier, I decided to solve the physical cube simultaneously and make sure the digital model matched. This worked very well, until I messed up on the physical cube and couldn’t undo the error without bringing the two models out of sync. I ended up solving the physical cube completely and then following the steps from the digital cube’s animation to get back to where I needed to be. This was also around the same time when I began to wonder how good of an idea this whole project was. 😛

Eventually I got all 167 frames keyed in, including the scrambling process and a small delay after it. It was already pretty late, so I decided to leave things for the night and do the rendering and compositing today instead.

I ran the rendering process this morning, and I’ve now got a nice stack of 1,002 images that need to be merged into cube maps. Unfortunately I have no idea how to do this, aside from manually making each cube map. The Photoshop batch job system should be able to handle the task, I think, but I don’t know enough about it yet to make it do what I need. I’m looking into this now.

T


%d bloggers like this: