Mar 17 2009

First VectorStorm Lighting Test

Tag: VectorStormtrevor @ 10:55 pm

lightingtestStill heavily in progress, but we’re on our way!  Proper real 3D lighting in VectorStorm;  calculated on the video card and everything, like a proper 3D game!

Still early days;  in the above shot, the light is hardcoded, as are the parameters of the specular hilight on the red ball.  But other than that, it’s all really working in the API;  the ball is just a regular display list, using the new API calls to specify normals for its vertices..  it’s red because it called SetColor( vsColor::Red );, using the existing API functions..  so it’s  slowly getting there!

I’m thinking about trying to simplify some of the display list rendering code;  putting the smarts into the assembly of the display list, instead of the processing of it.  That low-level code is starting to be a bear to extend, because of how clever it’s trying to be…


Mar 15 2009

[Tech] Musing on VectorStorm lights

Tag: Engine,VectorStormtrevor @ 6:31 pm

So I mentioned earlier that I’ll be adding lighting support to VectorStorm.  This breaks down into a number of little tasks.  In particular:

  • Need a ‘vsLight’ class for setting up and positioning lights.
  • Need to add ‘normal vector’ support to the vsDisplayList and vsVectorBuffer objects.  And, of course, to the vsRendererSimple.
  • Need to add some sort of ‘vsMaterial’ which defines the various color properties of an object to be lit (diffuse, specular, emissive, etc).  I should probably integrate the existing “DrawMode” additive/opaque settings into this class;  that was pretty messy before, and having it all together in a nicely organised vsMaterial class would be good.
  • Need to think about how to specify and enable/disable vsLights.  If I’m going to stay with the current “vsLayer” system, then the lights should be specified on the vsLayer in the same way that the vsCamera and vsCamera3D are.  This approach is very clean and easy-to-understand, but isn’t very flexible.  In real-world games, you often want fancy behaviours like “each object picks the three nearest lights and renders using only them”, or “this light only illuminates the player, not anything else around him”.  These sorts of tricks can’t be done if lights are set on the layer and affect everything within the layer.  To do these types of tricks, you really want the lights to be pushed onto the display list, and popped off again when they’re no longer being used.  Need to think about this some more.

Also, I notice that the “Asteroids” testbed game is still not working quite right, as its objects are trying to move faster than Box2D will allow.  I either need to modify the Asteroids game to bring the scale of the game objects down, or else modify Box2D to allow objects to move faster.

Also also, apologies for two tech posts in a row.  I’m going to have to write something game designery tomorrow to make up for this.  :)


Mar 14 2009

[Tech] VectorStorm engine updates

Tag: Engine,VectorStormtrevor @ 7:52 pm

I’ve now brought across changes to the core VectorStorm library, which I made during the development of Lord.  The following is probably only of interest to coders.  Sorry, everyone else;  please feel free to skip this post.  :)

I mentioned once before that folks shouldn’t be using the VectorStorm 3D API until I posted an “all clear” that I thought I’d worked all the bugs out of it.  Well, I think that’s now the case.

The most important change to note is that the coordinate axes (by default) have ‘x’ travelling to the right, ‘y’ up, and ‘z’ INTO the screen.  These axes are different from those used by OpenGL by default, but it’s the coordinate space that I prefer to work in, personally.  If you have some reason to want to change them for your own use, it’s not difficult to do, as long as you don’t change the handedness (in which case all of the matrix and quaternion maths will stop working properly.  Sorry about that).  Previously, ‘x’ was to the left, and ‘z’ was extending OUT of the screen.

I’ve also modified the way that textures are loaded and freed;  now you treat them exactly like any other object;  just ‘new’ or ‘delete’ them.  Previously, VectorStorm could not deallocate textures, and so would keep them loaded until the program terminated.  Now it can, and will complain noisily if you don’t free your textures before exiting.  Of course, textures loaded via a .vec file will be deleted automatically when the display list is deleted.  Also note that internally, VectorStorm keeps a cache of loaded textures, so having twenty objects which all use the same texture won’t result in twenty copies of the texture being loaded.  That all happens invisibly, inside the library.

I’ve created a new “box” class, which contains information about axis-aligned boxes, both in 2D and 3D, and have adjusted bounding box code over to using them.  If you were calling any of the API to do with bounding boxes, you’ll need to make a few minor adjustments to that calling code, but this simplified code within the engine an awful lot.

Finally, I’ve added a series of “buffer” objects.  The chief one you’re likely to want to use is ‘vsVectorBuffer’, which is a wrapper around the OpenGL Vertex Buffer Object extension, which basically lets you store data semi-permanently on the video card, so that it doesn’t have to be transferred every frame.  The vsVectorBuffer object will transparently fall back to using simple arrays, if it’s running on hardware which doesn’t support Vertex Buffer Objects, so there’s no penalty for using these.  In practice, you can use these exactly like the old vsDisplayList->VertexArray(array, count); code, just instead calling vsDisplayList->VertexBuffer(buffer);  These work for vertices, colors, and texture coordinates, and soon will work for normals as well.

If you’re a fan of using indexed arrays for drawing triangle strips, there’s a vsIndexBuffer as well, which provides similar functionality to the vsVectorBuffer;  it speeds up rendering by storing the indices directly onto the video card (if supported).  Check VS_GPUBuffer.h for details on how all of this works, but it should be pretty self-explanatory.

I have not yet swapped .vec files over to using these buffers, but that would be a good thing for me to do, eventually.   I’m sure I’ll get there in the fullness of time.  :)


Mar 14 2009

Ramping Up for MMORPG Tycoon 2.0

Tag: Full Games,MMORPG Tycoontrevor @ 2:53 pm

So it’s time to move on.  I’ve had a lot of time to think about what’s going to go into MMORPG Tycoon 2.0, and have begun working on a list of things that need to get done before I can really start work on it.  These are basic VectorStorm features that need to be implemented:

Definite Things:

  • Lighting.  The lighting in Lord was all faked (nothing which was lit ever moved, so fake lighting was just calculated once during startup);  I’ll need proper lighting support for MMORPG Tycoon, because there’ll just be too much geometry (and lights!) moving around to be recalculating it on the CPU all the time.
  • Animation.  The animation I’ve used in VectorStorm games has always been hardcoded.  For MMORPG Tycoon, I’m going to need to be able to export some simple animation from an art package, and play it back in-game.  This will be essential for subscribers and monsters.
  • 3D Models.  Connected to the above, in order to export animations into VectorStorm games, I expect I’ll need to be able to have VectorStorm load and use models exported by 3D packages.  I’m not planning anything too fancy or extensive;  probably just being able to convert some standard 3D file format into VectorStorm’s internal display list format.  With that said, I’m not expecting to actually use many models this way;  MMORPG Tycoon will be generating visual geometry procedurally, not using lots of pre-created models.
  • Unicode and Localisation.  The text systems in VectorStorm currently only work with plain ASCII text.  This will need to be changed to work with some form of Unicode text (probably UTF-8), and I’ll need to build a solution whereby text strings are not hardcoded in the game or in general data files, to make translations into other languages possible.  There’s a standard method of doing this under OS X, but I need to build (or find;  suggestions are welcome!) something which will work cross-platform.
  • Support for creating textures at runtime.  Right now, textures have to be loaded from disk;  I want to be able to generate them in code, to reduce download sizes.  Or maybe MMORPG Tycoon won’t use (m)any textures.  I’m still trying to settle on an art style for it.

Maybe Things:

  • An API for reading cursor location in 3D, and picking of 3D objects;  this will involve reading back from the Z-buffer to unproject a 2D point in the window to a 3D point in the world, and potentially tagging rendered objects within OpenGL, for easier selection.  I kind of worked around not having this in Lord, but MMORPG Tycoon will have much larger UI requirements, and so it’d be nice to have better abilities with this.
  • Do I need 3D physics?  I don’t think so;  MMORPG Tycoon 2.0 should be able to make due without any physics at all, I think.
  • Do I need 3D collision detection?  Maybe.  If the levels are simple heightmaps with props on them, then probably no need for complicated collision detection.  But if I was going to let human players wander around in the zones, then this would absolutely be essential.
  • Maybe adjust VectorStorm’s rendering infrastructure to separate the organisational scenegraphs from the rendering layers.  That made sense for simple 2D vector graphic games, but in the world of 3D, there are lots of instances where you want to have bits of a single model render at different times…
  • Shadows.  Oddly enough, in most computer games, shadows are separate from lighting.  I need to decide whether or not I need stencil shadows or something similar..
  • Threads.  MMORPG Tycoon is going to have a lot of processes creating a lot of geometry during runtime;  it might make sense to put this processing into threads.  Having a generic cross-platform and easy-to-use thread implementation within VectorStorm could potentially be a really useful thing.

There’s probably more, but these are the likely engine requirements I’ve worked out so far.  I’m going to be starting with lighting, and will then move on to terrain creation, to try to settle on an art style.


Mar 13 2009

A Long-Awaited Post-Mortem

Tag: #6: Lord, Save Us,Game in a Weektrevor @ 7:45 pm

First, I would like to say that I’m not entirely happy with Lord’s state.  It has a lot of things wrong with it that are immediately visible to anyone who plays it;  the pacing is the biggest offender here, I think I totally failed to convey the feeling that I was striving for.  But that’s not such a bad thing;  the point, after all, of trying to make a game in a week is to finish a game in a week, not necessarily to have a fantastic game at the end of it.

No, the chief failure of Lord was that it took me more than 7 days to complete.  In fact, it took me 77 days to complete (that number wasn’t planned).  This is the story of what happened, in the hopes that telling the story will help me keep it from happening again.

It was the day after Christmas, 2008.  Picture a younger me, more hale and hardy, his cheeks still flush and aglow, strong in limb and body, his hair not yet gone grey.  Flush with his youthful vigour, he thought, “Why, it’s been a long time since I’ve done a Game in a Week.. and I have a full week of vacation left before I must return to work!  And work will be quite busy, so I should have fun now while I can, for I will not be able to consider a Game in a Week for a long time into the New Year!”

More beneath the fold.

Continue reading “A Long-Awaited Post-Mortem”


« Previous PageNext Page »