Might as well…
...show you what flyght 8 was. Here's a clip:
The video was recorded way back of last year. It shows off the sample-accurate audio/visual synchronization and 3D to 2D hud target handling. The project was initially demonstrated for my presentation on "Audio Programming". The current status of the project is going through a complete rewrite.
Flickering/tearing graphics solved.
There's a reason why we learned about Depth Sorting in Computer Graphics class and that is to solve this visual tearing. When you have multiple transparent objects being rendered over one another, you need to draw them from the back to the front (farthest to closest to the camera). That way, they will blend nicely. I'm currently making a parent object "genericDraw" as an array and attaching all the addresses of objects that need drawing. Then write a method to return the center of the object, and do a quicksort based on distance from the camera.
Frustum
The problem with my game at the moment seems to be the culling objects from the scene. For example, I have a cube which players can shoot at to destroy. The cube has a targeting area for players to lock on. My game draws a small 10x10 pixel rectangle around the targeting area. To do this, I have to convert the 3D targeting point into a 2D point on the screen in which the game engine will draw the rectangle around. I do this by using the glProject method which does exactly that. The problem however is that when the cube object goes off screen, even behind you, the glProject still returns a 2D value on screen. So when the cube goes behind the player, the game engine still draws a rectangle around some point on screen. To fix this, I need to implement some culling system.
I'm still figuring out how am I going to implement the glFrustum method. So far I only know it's purpose which is to set the clipping area of the scene to render only what is in sight. After a quick glance over a tutorial, the method does seem a bit limiting. The implementation requires a different function for each set of custom primitives, such as a sphere. The tutorial goes over how to implement a culling system specifically for spheres. That brings up quite a few questions. What if the sphere isn't perfectly round, such as morphing a sphere to be thinner? Does this mean I would need a new function for every new visual object I bring into the scene? How much overhead will this system create? Would it be better for me to simply have timers for each object and remove them once they have passed the player's camera?
Slow but steady progress.
I was able to get more of a generic form for my visual objects in the scene. Instead of having the main OpenGL loop to call a bunch of Cube arrays to render, I can now stuff all types of visual objects into a single array (will change this to a vector/dynamic list) and have OpenGL to call each element in the array to render. This makes it much easier to handle than having a bunch of arrays to juggle. Though, I'm not sure if this is the way to go, it will be harder to manage if I were to want specific items to handle. I'll change it if it will cause problems later.
I think I got a handle on pointers now. I'll post a sample program in using pointers with Vector lists and how to add/erase elements to it.
Project Eyght progress.
I was in Vegas recently so I haven't done much to the game. I've gotten on-screen target detection working and a projectile system set up sort-of. I plan to move most of the level objects code to a scenemanager class which is what I should have done in the first place. Right now all the level code lies on a "renderLoop" function. It is going to be a problem since the only type of level objects I have in the scene are Cubes. I'm going to need to make a parent class that takes in a more generic object type so I can easily target any type of object I want and return its position coordinates to the projectile class for targeting.
gluProject function
So it took me a few hours to figure out why it wasn't returning the correct x/y screen coordinates. It turns out you have to update the matrices (model matrix, projection matrix, and the viewport matrix) after using the gluLookAt function. Just a tip for those who are out there having the same problem as I am.
Sticking with gluLookAt
I googled up and found this page which allows for the implementation of the gluLookAt on the iPhone SDK. So I'm going to go ahead and stick with using gluLookAt.
GLUT to SDL
I still can't figure out the tearing in the visuals. I'm about to try and force my display driver to turn on VSync and see if that fixes it. While my slow DSL connection is downloading the nVidia display drivers, I was busy translating my code to use SDL instead of GLUT for setting up the window. So far I got the rendering pipeline up, I just need to figure out how to translate the camera. I'm also going to see if SDL can manage my audio content so I won't need to pay FMOD royalties when I release the game.
No Progress…
This past few days, I've been stuck with this problem in my game. Whenever I move my mouse over the render window, the framerate becomes inconsistent and kinetic items in my scene "tears" visually. Even when I remove my mouse detection code, it still happens. I printed out every elapsed time frame and it shows that even frames render at around 0.03 seconds and odd frames render at around 0.0016 seconds. I'm not sure if the problem lies in GLUT or what...
Slight progress
Not much done today. I got mouse detection working with a few simple lines of code using GLUT callbacks. Next thing is to implement the hud system and collision detection so that I can get a targeting system up and running.