The 3D character is a very important part of the VR project. To be able to view a 3D world and move around in it you only need a camera which is very easy to set up and control, but when multiplay is added each player will need to be seen by the other. I also want the realism of being able to look down and see myself too, or see myself in reflections. To do this the player will need a moveable, animated model that can be controlled in many different ways. In this section I will be including everything to do with the players model, from building the model, to moving and controlling it. Many other things will also come into play as well such as gravity and collision detection. These features will be an important part in making the experience as realistic as possible. This will make up quite a large part of the total project. If someone has any suggestions or requests, please don't hesitate to contact me through the Contact page.
Most games use fully animated character models for the player. You then program in which animation to run depending on the controller input ie, running, jumping, strafing, crouching, shooting etc. I have to take a different approach as I need to be able to move the characters head and hands to exact positions based on the input from the VR hardware. To do this in DarkBasic Pro I will use what they call 'limbs'. A model can be constructed of a number of limbs, and a limb can also have a child limb attached to it, and a child limb can have it's own child limb attached etc. This allows a limb to be rotated, and any child limb attached to that limb will move with it. This saves me having to do a lot of complicated maths when moving the body parts. I will still use normal animations for a lot of movement as I will not have positional trackers on my legs. So for walking, running etc I will use normal model animations, but to move my head, arms and hands I will use individual limbs.
As my knowledge of game programming is very limited I have started with very basic stuff and will build on that. The first character model I have constructed I built using a cube for the body, a sphere for the head and I have attached a gun model that was part of a demo as a limb. With this simple model I will be testing the controlling of the individual body parts to see how difficult it will be. I want to test the ability to walk one direction, while looking in another direction, while aiming a weapon in a third direction.
In the video to the right you can see my crude character model looking in a mirror while I moved it's head using the mouse, turned the body using some keys and aimed the weapon using another set of keys. This proved to me that controlling the individual parts of the character should not be too difficult. While I was learning to code these parts I also played with other features that will be needed. To make the character bob up and down while walking I had to code in a change in the characters Y position using a sin wave. I also added the ability to change speed from a walk to a run, to be able to jump and also implemented a couple of different types of collision. The main collision type is sliding collision which means the character will slide along an object when it collides with it, and also bump collision which allows the character to push other objects around. I also spent a fair bit of time including a crosshair for the weapons aiming. Normal games just have a crosshair fixed to the centre of the screen as the view and weapons aiming are combined. But in this game the weapon is aimed independently to the view so I had to use a different method. What I have done is draw an invisible line straight out from the weapon until it collides with the terrain or other object. I then move back a small amount and then position an flat plain object which is using a crosshair for the texture. It has worked well so far.
Now to work on a real character model.
To model my character I am using a program called 3D Canvas Professional as it came as part of the DarkBasic Pro bundle that I purchased. I decided to start by modelling a hand which will be made up of individual limbs for each joint of the fingers. That way I can use the data from my data gloves and bend the fingers to match. I have made a short video of my first attempt of the hand in wireframe mode showing how the finger joints are joined to each other as limbs. When I bend the top knuckle, the whole finger bends etc. Each finger joint is made from a cylinder and a sphere that I cut in half and placed on the end. I then scaled the size by squashing and stretching them into the shape I wanted.
Just to see that I am on the right track I have imported the hand model into DarkBasic Pro. To move the hand I have set up some keys to simulate values that will be available from the data glove bend sensors. I have also included some tilt, roll and yaw movement that would come from a 3DOF tracker attached to the data glove. The model is pretty poor but I am sure I will get better as I go along and I will probably rebuild a lot of this earlier work. Please excuse the poor video quality.
Next I will look at adding some collision detection to the hand and writing some code so it can pick up objects.
Well quite a lot of time has gone by as I have been busy studying but I am now back to the project. I have now decided to get serious with the game programming and have taken a new look at how the character models will work. I have discovered I was taking the wrong approach to the character modelling. By experimenting with a character model in one of the DarkBasic Pro demos I have found that an animated character made from a single mesh can still be manipulated using limb commands. So rather than build a character model with individual sections for each moveable limb as I did with my hand model I can use a single mesh character model. By placing bones into the model and mapping the different parts of the model to each bone the model is then split into limbs automatically when it is exported to a directx model. The result is a model with a skin that will stretch with the movement rather than have a bundle of pieces with visible seams. Using this method I can have a character model where the legs will move using animations, but will have the head and hands move based on data from the trackers and data gloves.
While reading the forums on The Game Creators website I noticed a lot of people recommended using Milkshape 3D to model and animate game characters so I decided to check it out. I also found quite a few tutorials that have been very helpful in learning to use Milkshape 3D. My initial test was to make a simple model, add some bones, record some animations and export the model into Directx format. Then I loaded the model into DarkBasic Pro and confirmed that I could play the recorded animations as well as rotate the individual limbs using seperate commands. Now I need to do a lot of practise with Milkshape to get good enough to build a whole character.
I did play around with Milkshape 3D for a while but soon realised the limitations of it so I did some more research into 3D modelling. There are a lot of different programs that people use and everyone has their own preference. I found an in-depth character tutorial for 3DS Max and so I decided to give it a try. 3DS Max is a professional modeling program and is very powerful. It certainly won't hurt to take the time to learn how to use it. The tutorial is Modeling Joan of Arc and goes through a lot of detailed steps.
I spent about a month going through the 3DS Max tutorial and learnt a lot along the way. I managed to finish the model and completed all of the UV mapping. I started to play a bit with making the textures in photoshop but I am not very good with photoshop so that will be a whole other learning experience. I did manage to map some parts of the model and apply textures so I know how it all works now. As you can see from my screenshot some of the textures have been applied and the rest have a standard checker pattern applied. I also went through the skinning section of the tutorial, added bones to the model and setup the skin to follow the bones. All that was left was to add some animations to the model. I soon found out this is a whole new art that I need to learn. My attemps at animations were dismal. Finally I managed to export the model into direct x format and load it into DarkBasic Pro successfully.
Because of my hopeless attempts at animating my own model I decided to look into models that were already available. Some of my DarkBasic Pro demos had animated characters included and The Game Creators Store also has some free characters available for download. These are all in direct x format and unfortunately 3DS Max does not import direct x models. What I did was import the direct x model into 3D Canvas Professional and then export it into a *.3DS file. I could then import the 3DS file into 3DS Max. By doing this I ended up with a textured character but the animations were lost. Luckily I managed to find a *.bip file that someone had captured from a FPSC character. A bip file is a file that has bone and animation data for a 3DS Max biped. A biped is a set of bones that are already configured for a person. By creating a biped and skinning the character around the biped I could then load the *.bip file and I ended with a character complete with animations.
Loading the character into DarkBasic Pro meant exporting the model from 3DS Max in direct x format using the KW Xport plugin. Finally I had a character model complete with animations in DarkBasic Pro that I had constructed myself, even if it was from borrowed components. Keep in mind this character is very poor quality as it has a very low poly count and the textures are not that great either. I plan on using much better quality characters once the game takes shape, this is all about learning to animate and manipulate the character model using trackers and other user input. The next challenge was adding controls and learning how to play the animations. This ended up pretty simple but what I found was the animations would jump from one to the next when I changed them. I wasn't happy with this and was imagining having to play transitional animations until I discovered Enhanced Animations.
Enhanced animations is a plugin for DarkBasic Pro that handles the animations for you, allowing smooth transitions from one animation to the next. It also allows the animation data to be removed from the model and saved as separate animation files. This means the models load fast and the same animations can be applied to any model with a similar bone structure. Enhanced animations also allows different animations to be applied to different parts of the body which was perfect for my application. After purchasing Enhanced Animations and studying the demo files it was quite easy to use the animations in my game code. A video of the character in DarkBasic Pro can be seen by clicking the image to the right. This is a capture of some basic test code showing Enhanced animations animating the top half of the character to aim the gun, while animating the lower half to run and stop. At the same time I am showing how the head and torso can be moved around independently of the animations. For this demo I have the camera fixed out in front of the character so you can see what it is doing. For game play the camera will be attached to the characters head. I am only using mouse and keyboard to move the torso and head for this demo but I have done some testing with my trackers and they will work in nicely.
While I was reading the DarkBasic Pro forums I found that the author of Enhanced Animations was also working on a utility called 3D Character Maker. 3D Character Maker will make building custom character models very easy and they will all be able to be used in DarkBasic Pro with Enhanced Animations. This is another tool that will make progress in this project much easier. Rather than spend more time learning to improve my modeling and animation skills my time will be better spent on other parts of the project. I will wait until 3D Character Maker is complete before I get back to adding in better characters.