Today I've been working on getting Doors into the engine. The main gameplay purpose of doors is to restrict the player from going to certain parts of a level. It's also a nice reward to be able to get through a door once that initially blocked your character from proceeding.
Doors will work like so : In the editor, each door will have an entry for a key name, and a skeleton key type that will open it, as well as a lockpicking skill level, and a strength rating. The player can get through the door by :
a) Having the right key. A particular key may open more than one door, or no doors at all. You can carry any # of keys.
b) Using a skeleton key of the right type. There won't be a master key for all doors in the game, rather, many doors on
a particular level may open with the same skeleton key type, but take different keys in the normal case. Using a skeleton key may break the key, but chances of this are reduced on lower lock strength doors and with higher lock picking skill.
c) Picking the lock. Picking easy locks is faster if you are better. If you can't pick the lock in 10 seconds, you can't open it. No point trying it again without upping your skills.
d) Forcing the door with strength. Another option is to break the lock itself, requiring great strength. This is another way to open doors, if your character is strong but not agile enough to be good at lock picking.
Inspecting the door will reveal what type of key opens the door, and possibly the lock-picking and strength ratings.
The idea is to restrict players from going through the whole level easily, but never forcing them to be stuck. If a monster
had a certain key to a door, but drowned in the bottom of a pool or fell off a cliff where the player can't follow, we don't want the player being stuck from completing the level, and not knowing why he can't find the key.
The lock picking, door forcing, and skeleton keys are all mechanisms to force your way through a locked door, possibly requiring the player to buy a skeleton key, or to increase his skills before opening it, but never getting him totally stuck.
Today I added axis aligned bounding box collision objects to the collision system, and got them colliding vs spheres & capsules, so right now I can add a door to a level, and successfully block the character with it.
One problem that the doors have, though, is their large size.
Most 'entities' in the game are very small, like the characters, who are 1x2x1 meters in size, wheras a door may be 4x4x1 meters
in size. Right now, entities are lit per-vertex, and the shadowing is done on a global basis for the whole object via CPU ray-casting. This works fine for small characters, but looks wrong for large things like doors.
Note how the door is not receiving shadow on the lower left, nor from the character :
Another problem is since the lighting is per-vertex, you can't have decals on the doors. Even if I did add decals to the doors, I would need to change the code so they would stick to the door if the door moved to open or close.
I don't want to add a completely special category for doors, so instead, I will probably implement optional shadow receiving for
entities. Right now, the entities cast shadows by creating a frustum from their bounding sphere pointing away from the light. For receiving shadows, they would need to use a frustum starting at the light and going towards their bounding sphere. Any objects in this frustum would have their depth rendered to the shadow map. This way the objects could receive shadows from the environment, other entities, and optionally themselves.
This will imply that I add a path for entities to be rendered with the rest of the per-pixel-lit scene as well.
On another note, I just upgraded my DSL service to double the speed, and my bill went down by $13. Gotta love those promotions...