Tuesday, August 14, 2007

Fixing the problems

As I said earlier I will now explain what the problem is with my current engine and how I intend to fix these things.

1) The lack of sloped polygons and small collision detection/response bugs.

This problem is caused by the fact that the actual polygons of each scene are stored in a 2 dimensional bsp tree, the nodes of the tree contain any polygons that are vertical and the leaves contain the roof and floor polygons. This way I could simplify the collision detection because I would only have to worry about the x and z dimensions. Y-axis collisions were simple, each leaf in the tree had a roof and floor height, if the player was in a particlar leaf it would fall until it hit the floor and would stop if it tried to move higher than the roof height.

The problem with this is that collisions with a polygon that is not vertical or horizontal but sloped would cause unexpected results (let alone placing them in the bsp tree in the first place). This is because the collision is no longer with a line (as seen from above) but a plane which could be orientated in any direction. Also if a players bounding box was located on more than 1 leaf sometimes problems would occour with certain special cases.

To fix this I have decided to go back to the start and create a system where all polygons are kept in a 3d bsp tree, this way collisions on any polygon are4 performed with the same collision functions and slopes will be allowed. Also there will no longer be the collision problems associated with when the player is located on more than one leaf.

2) Lighting problems.

In the current build of the engine, wall materials have only a color or texture, there is no multipass texture mapping and the frustum clipping only calculates a set of persective correct texture co-ordinates.

I wish to have lightmaps that are generated by the map editor to help create a better atmosphere in the levels, this requires multiple textures to be applied to one surface. Also the clipping has to be able to calculate the lightmap texture co-ords as well.

For this, a complete re-write of how the polygons are stored, clipped and rendered is in the works.

Hopefully I can complete this engine in a quicker time than my previous one because of the fact that I have learned alot and gained some valuable experience in working with bsp trees.

PS. Sorry for some of the formatting problems in the previous post, blogspot seems to have alot of problems with formatting.

No comments: