Well, after doing research all weekend on steering algorithms, I have given up on the large rectangular area approach to storing nodes for a star.
It didn't offer enough benefits over a simpler dense mesh of waypoints. For instance, figuring out which 12x8 meter 'room' your character wanted to walk through doesn't help him steer around dynamic obstacles.
By switching to a dense ( 1x1 meter ) mesh of waypoints, I get several benefits :
1) most of the steering is handled by the mesh, instead of a separate system
2) I have a static & dynamic cost for each node->neighbor path. This lets me add & remove dynamic obtacles easily.
3) It's easier to annotate a dense area with tactical information or hints
...and, a new challenge - there are way more nodes now, from 24->400 for a simple level, taking more memory, and more pathfinding time.
So, to address this, I have changed to a system whereby each node takes only 20 bytes, is stored in a large 2d array, and has implicit neighbors.
One restriction is that the navigation area will be only 2d - so no going over or under a bridge. This restriction will make the astar faster and much simpler to implement.
We can still architecturally have anything geometry we want, but if we want the AI to navigate it, it will have to avoid over->under problems.
Had a good meeting today with my partner, and we have made some great design decisions. I'm really excited about both the ranged and melee combat systems.
Also, I have found a great programmer to help on coding, whom I met through GameDev. I'll let him announce himself if he wishes.
Water Part 5
To finish up on the water topic, I need to talk about the reflection and the water depth effect. Real water scatters light, and ends up tinting the water to some color - blue or green look good, so I wanted things under the water to be sort of fogged based on their depth. You can't use hw fog for this, b/c it is not defined in viewspace, but rather relative to the water plane.
Now, to do this really right, you would need to take into account the angle of the sunlight hitting the water, the angle of the viewer, the exact volume of water that the photons were travelling through to reach the eye, etc.
For a top down game, though, just using a texture mapped to the world Y axis seemed to work pretty well for me. The texture is blended in based on vertical distance from the water surface, scaled to some value so that it maxes out at some depth.
This way you can hide geometry under the water if it is far enough down or the water is dense enough, or just give a sense of depth via fading in the water color.
At level pre-processing time, I take each liquid triangle, create a bbox out of it, grow it a bit in x & z and bring the bottom of the box down vertically like 150 meters. Then I use this to find underwater triangles, and store them to be drawn later.
Then, after drawing the lit world, including the underwater triangles as normal, I then alpha blend in the liquid color, using a ramp texture :
This gives the 'underwater' effect. I could also map an animated 2d map to do a caustics type effect over the x & z axes, possibly skewed by the sunlight direction.
Lastly, the reflection. I didn't like the look of cubemaps, and I also couldn't get the fresnel working the way I wanted, so I decided to solve both problems with a gigantic cheat.
What I do is to have a simple 2d sky texture mapped to x & z in world space that is used for the reflection, and a circular gradient texture that acts as an overhead fresnel term. It makes the water near the character more translucent, and far from him more reflective. It approximates what fresnel & reflection would look like, but it's way easier to tweak to get it to look the way I want.
I could also scroll the sky reflection texture, but haven't bothered yet.
Well, that's it for the description of the water. Let me know if you have questions.
The relativly massive increase in node count is a downer, but still 400 nodes isn't too bad. In the cities in my game I'm pushing close to 20k nodes just for humans...I have a seperate node map for vehicles which is simliar in size. Thank god I don't have to place them by hand ;-)
Your project is looking good as usual, can't wait to see the water in motion!
- Dan