Scene graph in, lights out. Hmm....

Daily 09/15/03

Left-handed or Right-handed. That is the question. Cari and I had a discussion today about the merits of each system. What do you think? I prefer the right handed system. Here's why:

  1.  It's more natural.
    All through high school, I've been taught that up is up. All through college, elevation has always been in the positive Z direction.
  2. Our modeling software uses a right handed coordinate system.
    This is a weak argument because the exporting software we use has a left handed option.

Boy, there seemed like stronger arguments earlier this morning. Oh well.

Quick and dirty scene graph. I started modifying our code to use a scene graph. Because of the speed at which I need to get an implementation, I've decided to overlay the interface onto our existing objects. Here are the interfaces.

struct ISceneNode
{
   // Node name
   virtual const char* GetName() const = 0;

   // Updating
   virtual HRESULT Update(float fElapsedSeconds) = 0;

   // Rendering
   virtual HRESULT PreRender(PScene pScene) = 0;
   virtual HRESULT Render(PScene pScene) = 0;
   virtual HRESULT PostRender(PScene pScene) = 0;

   // Adding/Searching/Removing
   virtual HRESULT AddChild(PSceneNode pNode) = 0;
   virtual HRESULT RemoveChild(PSceneNode pNode) = 0;
   virtual HRESULT AddSibling(PSceneNode pNode) = 0;
   virtual HRESULT RemoveSibling(PSceneNode pNode) = 0;

   virtual PSceneNode FindNode(const char* pName) = 0;
   virtual PSceneNode GetSibling() const = 0;
   virtual PSceneNode GetChild() const = 0;

   // Destruction
   virtual void Destroy() = 0;
};

struct IScene
{
   // Updating
   virtual HRESULT Update(float fElapsedSeconds)= 0;

   // Rendering
   virtual HRESULT Render(LPDIRECT3DDEVICE9 pDevice)= 0;

   // DX specific
   virtual LPDIRECT3DDEVICE9 GetDevice() const = 0;
};

OK, I learned something new today about the project. Here's the current object topological graph:
StarMap is a list of TileMaps. Each TileMap contains a list of objects. Also, the planets are in a different list and the ships are in the tilemap.

I got all the stuff modified, then  turned it on. It worked!!! Slight problem though, the lights weren't working. Had to spend some time figuring that out :(

Ok, I spent all afternoon trying to figure out what's busted with the lighting. There's something severely wrong there. If I draw the planets after I draw the ships, then the lighting works great. Otherwise, it doesn't. What's up with those ships? I'll try to solve this mystery tonight.

Other than that, the scene graph seems to work fine. I'll try to mock up some rings tonight too :)

18,165 views 3 replies
Reply #1 Top
Sure. You can add those things to the graph. They're short term objecst so it may be inefficient to keep adding and removing them from the graph. No big deal though it's better their than just lying about in the game loop. Maybe I'll create special short list for these kinds of objects. That'll make the add/remove time quick.
Reply #2 Top
So are you putting in stuff so that I can add photons and explosions that I create in my battle processes to a list to be rendered? Other than figuring out why the ships don't turn all the way, that's all I need to finish the battle "script". I checked in my code, but disabled the battles until I can render the photons and explosions.
Reply #3 Top
Yeah, I was thinking of an list for temporary objects, too.