August 13, 2009

The new face of a conspiracy

Posted in Computer Graphics tagged , , , , , , , , , , , , , , , , , , at 6:48 pm by sagito

Hi everyone! It was a long time since I posted something new here, because my network keeps going down… But this time, I’m bringing you news about the Conspiracy engine. Missed him? Me too… 😛 Well, it has a brand new face since many new features have been added that make him stand much higher then before.

To start, a small problem with the vertices was corrected. Somehow the vertex data was getting scrambled all the way through the CMOL (Conspiracy Mesh Optimization Pipeline), and I ended up removing some of the optimization routines that could be handled in another way by DirectX himself. And by doing so, the GenerateAdjacency problem was also solved! This way, the meshes are more perfect and faster than ever! 😀

Also, I’ve implemented a XML parser system from scratch. With that, I created implicit support for something else: Scene graphs! And this is a very important part of the engine, as some objects might now be loaded directly through a simple configuration file. This is great for scenarios, lights, etc., but also for the future creation of a visual editor for the engine!

With so many new features, something logical occurred! A game is being developed on top of it and I can guarantee that it is already in a very advanced state! Stand by for more news! 😉

August 10, 2009

The piano…

Posted in Computer Graphics tagged , , , , , , , , , , , , at 6:38 pm by sagito

Hello again! 🙂 This time I’m bringing you an amazing short story, created in CG by Aidan Gibbons, from Aniboom. The film is about a grandfather who is telling his story to his grandchildren through the piano music. Although very simple, I found it really great. Hope you like it:

July 31, 2009

Constraints

Posted in Computer Graphics tagged , , , , , , , , , , , at 11:11 pm by sagito

Hi everyone! After some absence due to the lost of someone who was very close to me, I’m back to posting… This time to talk about a constraining system that I will attempt to implement within the Conspiracy Engine.

I have been having some problems with some DirectX functions, namely GenerateAdjacency and OptimizeInplace. These functions just crash unexplainably in some memory address that is not in my addressing space. Also, neither the DirectX debugger nor the PIX (tried it in despair), not even the Visual Studio 2008 debugger could do anything to show me the problem… So, I analyzed the assembly code, to find out that something inside the mesh is not properly set. However, I don’t have the means to find out what, so I just commented out the functions and moved on until I have the patience to deal with Microsoft’s brilliant lack of information.

So, I decided to implement a constraining system. Now, what the hell is that? Basically a system of something that constraints something to some other something. 😛 Ideally, this will, for example, stick a camera to a travelling object! Imagine a car in a racing game. We want the camera to be able to follow the car along the track as it moves, otherwise the camera would just be left in the beginning of the track.

It is important to say that… I never, ever, whatsoever, tried anything even near such a thing… My basic idea so far is really making an object stick with other… You could say that this can be achieved using hierarchy. Yes it could! However, I think some more flexibility is desirable… For example, if I want to attach a gun to my vehicle, I would probably like to place it in the door or in the roof… I need something that allows me to control its position and the constraining system will hopefully give me that kind of offset.

I know that there is a huge number of possible constraints to be implemented. However, I will stick to this one at the moment, but I will create a solid enough structure that can be expanded to some other constraint types further on… For now on, I will be keeping you posted! 😉

July 26, 2009

Octree in DirectX

Posted in Computer Graphics tagged , , , , , , , , , , , , , at 11:27 am by sagito

Hello everyone! Back to some news from the Conspiracy… 😉 This time I’m implementing a feature that is quite new for me. An octree! Ok… Wait… What’s an octree? Well, an octree is basically a technique for dividing the drawing space. You start with a huge cube which surrounds the entire scene. If there is something inside it, then you subdivide that cube in eight smaller and identical cubes. Then, for each of these cubes, we must check if there is something inside them, if there is we subdivide them again, and so on…

Ok, now… Why is this so useful? Lets consider rendering… It is not necessary to render everything that we don’t see (because its behind us for example). This seems quite logic to me. But, the DirectX backface culling and occlusion system should be capable of doing this, right? Yes and no! In a matter of fact it really does not render the objects that we can’t see… However, it sends them to the graphics pipeline, executes a draw and only checks if they are visible afterwards. Only at this moment it decides if it really sent to the screen or not. With an octree, we are actually able to avoid such a thing, because we just don’t sent the objects which belong to an octant that we cannot see to the pipeline, avoiding some unwanted overhead.

Another example is the picking! Why try to perform picking on something that we cannot select? It is a heavy operation and we want to be able to ignore such operations if they are unnecessary!

However, there is a small problem, at least, with my implementation. I can reach 6 iterations of depth in an admissible time… Seems that these are few iterations, and maybe they really are… But if we think it through, each subdivision creates 8 space divisions. So, for 6 iterations, that stands for 8^6 = 262144 divisions (maximum). After doing the maths, this seems quite acceptable now… 😛

So, standby for new updates, as they are coming fast! 😀

July 23, 2009

Physics of Conspiracy

Posted in Computer Graphics tagged , , , , , , , at 10:58 pm by sagito

Hi again! This time I dwelling through some unknown ground and finding some real big monster-problems as I go. I’m trying to create a physics engine for the Conspiracy Engine! Well, as some of you might now, the ideia behind a physics engine is to predict where will something be in a future moment! (Yes, we, the computer people can predict the future!).

For example, if I have a ball and I drop it from a tall building, I want to be able to predict where will the ball be after 1 second, after 2 seconds, 3 seconds and so on, so I can be able to draw it on the screen. And I also want to do this in a minimally realistic way, so that the ball doesn’t start to fall and comes back up or something. So, many laws must be considered here and all of those come from general physics. These are not my big problems, because fortunately, many scientists around the world have already documented those.

The biggest problems are integration and programming. The first one can be solved in three possible ways. Give up, which is never considered in my life; using the Euler method; using the Runge-Kutta 4 Solver. As I have read through some documentation, Euler has some huge mistakes and can easily lead to big problems in a short interval of time. Runge-Kutta needs some more calculations, but guarantees pleasant results! As Gaffer On Games says: “If you use Euler, then you are a bloody idiot!” 😀

The second problem is how to integrate this in an existing engine. This can be done either as a separate DLL (which I think its best) or within the engine itself. The last approach is probably the reason for many suicidal or depressive mental states. So, I’m thinking about creating a separate engine that is able to represent the physics laws and somehow connect both in order to create a nice realistic environment.

And meanwhile, I will keep you posted… 😉

July 19, 2009

Conspiracy Menu System

Posted in Computer Graphics at 10:53 pm by sagito

Hi all! There is a brand new feature on the Conspiracy Engine! Now it can render a menu system. Everyone knows and loves menu systems, those nice menus that serve as an intro for a game, for setting options, etc. So, how do you set up a menu system with DirectX? The base idea is quite simple. DirectX provides a nice support for this kind of stuff called Sprites. What can sprites do? They are 2D entities that live either in a 2D or 3D space. So, they can be used for menus, HUD, life bars, 2D animations and static scenarios, etc.

So, to start things off, I created a Sprite class that deals with every sprite related problem, such as creation, deletion, rendering, transformations, etc… Then, on top of this I created a menu system that features hierarchy, selection, positioning, and above all… I’m developing an external editor to customize the menus! Of course that since the Windows API is such a pain, I’m creating the editor in C#. The menus are configured through a file that can be easily loaded through a specialized parser called MenuReader.

The parser was build using the partial reflection mentioned before and is capable of easily configuring everything that can be customized on the menu, from the position of each element to the hierarchy, passing by the order and actions that each menu item will have. However, I’m still facing some problems. For example, in the DirectX Documentation the ID3DXFont class says that can be rendered over a Sprite. This would be great for menus, as they could actually have their own contained text. However, that does not seem to be working at all. And I’ve proof that the Font interface is working, because it is rendered nicely if there is no sprite. I’ll be working a little bit more before I post a screenshot of this system… 😛 And of course, I will give you news very soon! 😉

July 16, 2009

Project Natal: The Aftermath

Posted in Computer Graphics at 10:57 pm by sagito

For those of you who didn’t read the comment, this one really had to be posted after my yesterday’s post about Microsoft’s Project Natal! Credits go to Fernando Moreira for this brilliant video:

Project Natal Parody

This video reflects exactly what I think of Project Natal! It’s just another way that Microsoft found to take some innocent people’s money away! However, it is totally worth it just because of this kind of videos that are now showing up on the internet! xD

Thanks Fernando! 😉

July 15, 2009

Project Natal

Posted in Computer Graphics tagged , , , , , , , , , , , at 10:50 pm by sagito

For those of you who never heard of it, Project Natal is a new Microsoft project for the XBox360… Ok, let’s see this from a real-world perspective. I build games and play games. I have a XBox 360 and a Wii. The concept of Wii is just brilliant, I loved every cent I paid for each and every one of the games I bought. The very same can be said for XBox 360, except for the concept which is pretty much common nowadays…

Ok, so what is Project Natal? Microsoft’s attempt to control a console without controllers… Ok, right… So, what can I do? If I move my arms, then the character moves the arms in the screen. One of the videos from this year E3 shows someone playing a dodge ball-like game in a XBox360 without controllers. Hmm, nice, but I would prefer to actually PLAY the game with some friends in a real-world field rather then making a fool out of myself in front of a TV. But you can say: “Yeah right, but you could say the same about Wii”. Yes I could, but Wii was created as a party-game console from the beginning. XBox 360 was created for Halo 3 and Gears of War, and you can’t really make a party out of those…

Moving on… What if I don’t have an arm? What will the console do? Throw a NullReferenceException? What if I’m on a wheel chair? Or if I am a midget? Or if I’m tired and just want to sit down? Yes, I sometimes play Wii while I’m confortably sitting on the couch…

For more technical stuff… How the hell do you play a FPS with this system? The answer is simple, you probably don’t… Once again, you could say: “But wait… This is meant for party games”. Yes, I think that Microsoft has already planned the “DodgeBall Instincts Trilogy”, “Overdrive that cube!” and the “Kill the old blocky man – Collector’s Edition: Director’s cut”. Trying to transform a console which was prepared for bleeding-edge graphics into a party-game console seems to be a complete failure to me… You should have thought of that before, Microsoft… 😛

Here is the project Natal video from E3:

July 12, 2009

C++ Reflection

Posted in Computer Graphics tagged , , , , , , , , , , , at 10:48 pm by sagito

Today I faced a different problem while trying to build an external interface for the Conspiracy Engine… As it was built on C++, which is a compiled (not interpreted) language, the compiler does not have the concept of reflection. In the first place, what is reflection? Reflection is a technique that makes a language able to know, observe and modify its own structure and behaviour. For example, if I have a class A that wants to know which methods and variables are in class B, I just ask the compiler to tell me. This happens, for example in C#, where we can ask the compiler for class methods, variables, and even execute the methods if we want.

Problem is: There is no direct support for this in C++… However, I need that, because my intention is to build an external editor that can interact directly with the engine like the CryEditor, for example. So, I’m trying to find a solution! There are several ways of attempting such a thing. The first one is to read through the debug information… This is not viable because different compilers use different approaches for debug and the program would have to be always built with debug information (which is huge).

Second solution would be to create a compiler that supported reflection for C++… I have already create one (not for the C++ language!) and I guarantee that it is not something neither pretty to see nor easy to implement. Third solution: Create a specialized pre-processor that could build over the class descriptions… This solution could be viable… However, parsing the C++ language is not trivial and would require a two-pass-process which would introduce a huge overhead.

So, there is no solution for this problem? What if the engine had a specialized class that would store the data for reflection? Every class that derived from this base would register their variables and methods in a global storage that could be accessed from any other class. This is not the real reflection that we are to, but it seems like a nice approach. And it contemplates the cases in which a variable (or class) is sealed, i.e., not accessible through reflection. In that case, the class simply does not register its variables or methods! This approach seems to be the best one so far and I have already implemented it on Conspiracy.

So far it is working fine! 😀 I should give you some news very soon about the new editor for Conspiracy! 😉

July 8, 2009

Sky is not the limit!

Posted in Computer Graphics tagged , , , , , , , , , , , at 9:40 pm by sagito

After a short break due to WordPress maintenaince, I’m back to post about the new stuff that I implemented in the Conspiracy Engine! It now features skybox support, collision detection and a very complete particle engine!

Implementing a skybox was pretty easy. For those of you that do not know what a skybox is… Well, it is pretty much that, a box that represents the sky. So, what about that, why can’t it be just a cube with some texture mapped like every other object? Because unlike other objects, the skybox must move with the viewer… I.e., the user cannot get out of the box as the skybox itself must move with the camera. Just like a person can’t reach the horizon! So, how can one implement a skybox? Pretty easy, you get the view matrix (through IDirect3DDevice9::GetTransform(D3DTS_VIEW, &view);), reset the last row to 0.0 except for the last value and set the new view matrix. After that, the world matrix must be set as an identity too in order to remove any unwanted transformation. Then we can render the skybox! After rendering, we put back the old view and world matrix.

For collision detection, DirectX already provides some very useful functions that automatically calculate the bounding box and sphere for a given object! After that, I just took some optimization measures and converted the bounding box to an axis-aligned oriented bounding box (see http://www.toymaker.info/Games/html/collisions.html for more info). Then, the objects are tested for collision… If a collision happened, it is propagated through a chain of responsability to some entity that handles the event or discard if no one does…

Finally, the particle system was based on a tutorial from CodeSampler (http://www.codesampler.com/dx9src/dx9src_7.htm). The system described in this tutorial is awsome and very complete! Also, the code is very well structured and commented, so it was pretty easy to implement this too.

To end this (already long) post, here is an image of the engine with the skybox and the textured cube:

skybox

Next page