September 15, 2006

[XNA] My Content Pipeline

Because we still don't have the content pipeline for the XNA Framework, I've been working on creating my own content pipeline to get information into my engine.

Content pipelines are extremely difficult to create because not only do you have to get your content into the game, but you have to make your the content function appropriately once it is in the engine.

There are an infinite number of ways to implement a content pipeline. I'm trying to stick with a traditional world/entity pipeline for my level for simplicity's sake. A world/entity pipeline simply means that if it isn't part of the world, it is an entity that belongs to the world. Let's work on an pseudocode example.

The base type for everything is an entity.
public class Entity // C# pseudo-code for the rest of you
{
Entity Parent;
Vector3 Location;
[Depends on implementation] Orientation;
Mesh Geometry;
List<Entity> Entities;
bool Visible;
}
Entity.Location is just the position of the entity in the world in relation to the parent entity. The root entity will always be located at {0,0,0}.

Entity.Orientation contains the yaw/pitch/roll of the entity, or the rotation, or any number of items necessary to properly position the entity in the world. The root entity will always have null orientation.

Entity.Geometry contains a reference to any geometry (if any) associated with the entity. The root entity contains the geometry for the world, enemy entities contain references to their meshes, etc. If you are using a Quake-style map format, you may have brush geometry attached to items like a "func_mover," so this is where you'd drop that.

Entity.Entities is just a list of references pointing into the entity list, and is used for moving related items (like attached weapons and/or light sources).

Entity.Visible right now is a boolean saying whether or not I should try to render the entity and children, but will eventually be a property so I can include visibility/frustrum checks at the entity level.

It's scaling nicely, allowing me to use raw .MAP files for input, and I'm writing it in VB.NET. Why? Because the world doesn't work on curly braces alone.

No comments: