I was browsing today through the Genesis 3D Forum, and I noticed several posts asking about different camera angles. I myself hadn't really thought about the idea, but I decided what the heck, let's give her a go. Well a few hours, and quite a few beers later, I have prepared this small programming example to show you how to implement a quick and dirty overhead camera. This overhead camera is similar to the ones used in games such as Loaded.
It does not look right with the map that ships with Genesis 3D. This is because of all walls on top of walls and such. Maps should be specifically designed for a game like this. To give an example of how to design a map for an overhead game, I wrote a simple two roomed map which can be grabbed by clicking here. I have also included an executable example, for those who do not have a C++ compiler handy. You can grab the executable by clicking here. To launch the map use the command line option: Overhead -map overhead.
Okay, all the modifications that we need to make are in the Client.c file. I have tried to give the correct
line #'s in each case. However I may be off a line or two, as my files are not exactly the same as the last Beta
release.
The first thing we have to do is let the engine know to render our player. The game defaults to only displaying
your character when looking into a mirror. This is a very trivial change. Go to line #1359, it should look something
like the code below:
Player->Actor = geWorld_CreateActor(Host->World, ActorDef, GE_ACTOR_RENDER_MIRRORS|GE_ACTOR_COLLIDE,
0xffffffff);
We need to change this to draw your character at all times. We do this by changing the line to look like so:
Player->Actor = geWorld_CreateActor(Host->World, ActorDef, GE_ACTOR_RENDER_NORMAL|GE_ACTOR_COLLIDE,
0xffffffff);
If we ran our code now we would be able to see our characters arms and weapon, however due our angle we would have
phantom polygons. Besides this is not what we are setting out to do. We now need to edit our camera settings change
our angle(to look down rather than straight ahead) and to be far overhead of our player.
To change our angle we need to modify line 1524 which looks something like this:
geXForm3d_RotateX(&Client->ViewXForm, Client->Angles.X);
This is fine looking dead ahead, but we need our camera to be facing down(from overtop of us). So we will modify
our code to look like this:
geXForm3d_RotateX(&Client->ViewXForm, Client->Angles.X-1.69);
If we ran our program now we would be looking down and get a glimpse of phantom shoes. There is only one more thing
we need to change and our camera position will be perfect. We need to raise our camera level to be quite a bit
over our head. We do that by modifying line 1532 which looks like the code below:
Client->ViewXForm.Translation.Y += 140.0f;
This code was set into place so our player would not be scraping the ground as he moved. However we need to be
quite a bit higher than eye level to make this mod work, so we are going to change line 1532 to look like so:
Client->ViewXForm.Translation.Y += 800.0f;
The larger you set the value to(800) the higher your camera will hover above your character. You may edit this
setting to meet your preferences(this is also an easy way to increase your field of view).
Okay, now that we have our camera set to the proper angle we are left with only one more problem. Moving the mouse
up or down changes our viewing angle and it should not in an overhead game. So go to line #502, and you will see
four lines that look like this:
if (MouseInvert)
Client->Angles.X -= GlobalMouseSpeedY;
else
Client->Angles.X += GlobalMouseSpeedY;
Simply comment these four lines out. We do not need them.
We are now ready to run our level. Keep in mind that this modification will not look very good on maps with floors
on top of floors. You will not be able to see your character below them. Likewise if your ceiling is not high enough,
your camera will be on the wrong side of it, causing headaches. This mod requires you to create new maps, you may
use our provided map as a guideline as to how to make this mod work.
As always, questions and/or comments can be mailed to me by clicking here.