Update: Back into shape….

May 31st, 2011

Hello Everyone!

It has been a while since i have last updated, which is not very nice of me.
Things have been rather quiet on the game front… The networking prototype proved to be just that, a prototype. We have redesigned the networking from scratch to handle the more robust set of requirements needed for a full fledged online game!

Aside from that, i have started a DX11 research project. I hope to do some of the lighting things in my old engine, as well as establish a good working knowledge of the d3d 11 api. Right now I am working on mesh importing, and have been getting into fbx.

SO, redesigning/reimplementing networking and asset importing are keeping me busy.

I am so proud of the Lua and AssetManager stuff from the older engine that i have brought that stuff over. I will be integrating it when the time is right.

until then… see ya!
I will be better and post more!
-J

Unity Engine, Networking, and Excitement!

November 19th, 2010

Hello Everyone,

Huge news for our little establishment. We are archiving our engine and have switched over to Unity Engine. They have basically everything we wanted to put into our own, and it is very affordable! A perfect example of why we did so, is that we managed to implement networking (a full server/client system complete with game lobby) in one week with Unity, where as it would take half a year for us to do it on our own from scratch and it would not be as fully featured as what we are doing with Unity.

So, it is safe to assume that our game will have multi-player! The year is almost over, so we better get to announcing something shall we? Stay tuned!

OpenGL 3.0 and beyond

October 1st, 2010

Hello Everyone,

Aside from being busy from writing demos for JavaOne (my other job as a Graphics Engineer for JavaFX) I had re-written my renderer for a presentation on modern lighting algorithms. I was not able to get it where I wanted but that hasnt stopped me from working on it. The reason for the re-factor was simple. The current renderer we had was based on OpenGL 2.1 fixed functionality, and although we had shaders, we were still very reliant on things like the matrix stack, which were starting to really impact our productivity.

So this is for anyone on the fence about moving. DO IT.

I consider a new age OpenGL renderer to have the following:
1) No Matrix Stack. Pass ALL matrices to the shaders and mult them on the CPU if neccesary. This becomes much cleaner in terms of implementation. If you have trouble implementing your own math library for matrices, you can grab OpenGL Mathematics which is a CPU version of GLSL.

2) State Objects. Much how DirectX Manages it’s state, you can wrap the OpenGL state machine with state objects, for example a rasterizer object would contain an enum type for Wireframe, fill, or none. you would then have a setState function which would set the state. State objects also make it easy to port your renderer to DirectX.

3) Render Target Objects. Similar to above, making you less error prone when dealing with the ins and outs of FBOs.

Good luck to anyone thinking about this, i highly suggest moving your old renderers forward in time (or rewrite new ones). the newer opengl stuff is great!.

-Joe

PS. I havent forgotten about quaternions!

Update: Quaternions Part 2 coming soon….

August 6th, 2010

Lots going on!

Sorry for the delay!

I thhhinnkkk there is still a bug in the code, i have the post written up i just want to do some tests to make sure.

Quaternions Part 1

April 15th, 2010

The very first thing I’m going to say about Quaternions is that they are EASY to understand how to use! They are hard to understand why they work (ie. proofs and such). With that said… us game/graphics programmers care a lot about how to use stuff, which is what I’m going to talk about.

When you rotate an object, you use some matrix math to rotate on either the X, Y, or Z axis.

A look at matrix transformations on wikipedia will give an idea. When you are limited to these 3 axes, problems arise when you you rotate a certain amount on one axis you can align it with another, and then rotating on another axis becomes the same. VERY CONFUSING i know, but the important thing to realize is that you are limited to 3 axes when rotating an object with a standard matrix.

A quternion is just a vector with a rotation applied to it. THAT is it! this vector represents an arbitrary (meaning you define it) axis which the rotation value is applied to.

what makes this different than matrices is you can add quaternions together to get ONE rotation, as opposed to 3 separate rotations! When you are done with the rotation, you can simply compose a matrix out of the quaternion and use that matrix with your translations to get the proper rotation!

I will leave it to you to research teh functions.

Part 2 will show some code for our camera.

-DB

Event Data from C++ to Lua using Luna(r).

April 8th, 2010

It has been a while since I have updated, but I have a couple of posts I will make within the next week. The first post is on the enhancements I have made to our Event System.

The basic implementation of this event system is from lua programming gems (very nice book). It consists of a lua object (otherwise known as a table) that contains a couple of tables that stores Events, Pending Subscribers and Pending Unsubscribers, as well as a couple of functions for updating subscribers and firing events. You can get the full source for the Event System here (toward the bottom, 21 I believe). This Event system has a C++ implementation that simply pushes a string onto the stack and calls the lua function like so.

The Fire Event function looks something like:

 function EventManager:FireEvent( eventName, ... )
   self.Events[ eventName ] = self.Events[ eventName ] or {}
   for subscriber,_ in pairs( self.Events[ eventName ] ) do
     subscriber[ eventName ]( subscriber, ... )
   end
 end

and in C++ looks like:

void FireEvent( lua_State* L, std::string eventName )
{
  //Call the lua FireEvent on this event manager object.
  lua_pushlightuserdata( L, this ); //STACK: em
  lua_gettable( L, LUA_REGISTRYINDEX ); //STACK: self
  lua_pushstring( L, "FireEvent" ); //STACK: "FireEvent", self
  lua_gettable( L, -2 ); //STACK: FireFunc, self
  lua_pushvalue( L, -2 ); //STACK: self, FireFunc, self
  lua_pushstring( L, eventName.c_str() ); //STACK: self, eventName, FireFunc, self
  lua_pcall( L, 2, 0, 0 ); //STACK: self
}

As you may see, there is some lost functionality in this process. Although the lua fire event function takes additional arguments (note the “…” ), the C++ function does not account for this. This allows event data to be passed around at the lua level, but not from C++ to lua. This is the primary use of an Event! when you have keyboard and mouse input you would like to fire an input event that contains the bytecodes of the input used!

This is okay, with a little effort and C++ template magic we can fill in the little gap. we need to be able to pass in any type of data and include it in the arguments to lua like anything else.
In order to do this, we need 2 things.

First we need to change the C++ FireEvent function to a template function, allowing us to only write it once, and still be able to take many types of event data.

Secondly, we need to expose our EventData classes to lua, and be able to push each EventData type onto the lua stack. This can get very complicated, and as i said before, there are many ways to expose data to lua, this is just one of them.

I used luna (actually lunar but I copy and pasted some of it into my luna class). Luna is somewhat of a pain if you want to expose multiple things into your lua environment from C++, but I find that it is mostly copy and paste and chaging names once you got it down.

Here now, is the new code:

C++ FireEvent and Push Function for a collision event

    template <typename T1>
    inline void fireEvent(std::string eventName, T1 a1)
    {
         EventLog << "FireEvent:: " << eventName << "\n";
        //Call the lua FireEvent on this event manager object.
        lua_pushlightuserdata( L, this );            //STACK:    em
        lua_gettable( L, LUA_REGISTRYINDEX );        //STACK:    self
        lua_pushstring( L, "FireEvent" );            //STACK:    "FireEvent", self
        lua_gettable( L, -2 );                        //STACK:    FireFunc, self
        lua_pushvalue( L, -2 );                        //STACK:    self, FireFunc, self
        lua_pushstring( L, eventName.c_str() );        //STACK:    self, eventName, FireFunc, self
        PushArg(a1);
        lua_pcall( L, 3, 0, 0 );
    }
 
    void PushArg(CollisionEvent* EV);
    void PushArg(PickEvent* PE);
    void PushArg(InputEvent * IE);
 
    //here is what the PushArg for a Collision event looks like and how the new fire event is    
    //used.
    void EventManager::PushArg(CollisionEvent* EV)
    {
        Luna<CollisionEvent>::push(L, EV, true);
    }
 
    //Here is the Event System in action, using a Collision Event to pass collision data to lua.    
 
    CollisionEvent* CE = new CollisionEvent();
    void* id1 = pair.actors[0]->userData;
    void* id2 = pair.actors[1]->userData;
    std::cout << "collision:" << (*(int*)id1) << "::"<< (*(int*)id2) << std::endl;
    CE->Obj1_ID = (*(int*)id1); //GameObject ID set at actor creation
    CE->Obj2_ID = (*(int*)id2);
    Events->fireEvent<CollisionEvent*>("Collision" , CE );
 
   //and lastly, the luna(r) implementation of a collision event 
 
#ifndef COLLISIONEVENT_H
#define COLLISIONEVENT_H
 
#include "luna.h"
#include <iostream>
 
using namespace std;
 
class CollisionEvent
{
  public:
    CollisionEvent();
    CollisionEvent(lua_State *L);
    ~CollisionEvent();
 
    static const char className[];
    static Luna<CollisionEvent>::RegType methods[];
    //static const Luna<Foo>::RegType Register[];
    int getObj1ID(lua_State *L);
    int getObj2ID(lua_State *L);
  //private:
    int Obj1_ID;
    int    Obj2_ID;
};
typedef struct { CollisionEvent *pT; } CollisionEventdataType;
 
#endif

Phew, quite a bit. Here is how that very collision event code example is handled by a subscriber in lua.

    function Obj:Collision( CEvent )
            t = CEvent:getObj2ID()
            d = CEvent:getObj1ID()
            print( t .. "," .. d .. ":and my ID:" .. self.ID )
    end

Not too bad huh?!

In conclusion, you can see that template functions and classes can go a long way in making it easy to provide many kinds of event types for an Event System. In Particular, you see how the update function in this event system lends itself to such an implementation in C++. I hope you found this post useful! Next will be on quaternions!

DB
PS. thanks to dmail, ddn, and m_switch on the gamedev forums for the help in coming up with this.

GDC, focus, and prototyping.

March 16th, 2010

The GDC was last week, and it gave me some perspective about what I’m doing and what we need. We have shifted gears and put this project into overdrive. We have prioritized what we need and have begun prototyping gameplay using the systems and sub-systems of the engine. It’s go time, crunch time, it’s time to make a game, make it happen, and show the world what we can do.

Be excited for some upcoming announcements!

DB

Checkin out the gdc today

March 12th, 2010

Hey everyone!

On my way to the gdc right now. I’ll provide a full update when I get back. Maybe I’ll see you there!

Db

Using Expression Blend to spiffy up the interface

February 27th, 2010

So I was referred to Microsofts Expression Blend 3 by my friend who works with silverlight. Expression Blend is a nice editor like tool used to design fancy shmancy gui’s in WPF and Silverlight.

The learning curve for it is slightly high (for the non designer, developer type like myself that at the moment is still new to WPF), but given a couple weeks and with my backend in need of a more robust frontend, i think the time invested will have a nice payoff. The problem is i need to take some time to learn the thing. anyways, here is a picture of the interface.

Expression Blend Interface

Expression Blend Interface

Excited for Nvidia’s Parallel Nsight

February 18th, 2010

I just watched the following video and I have to say this is what i have been waiting for! I hope the OpenGL support is as good as the D3D support.