OpenGL : Swinging camera

This is a discussion on OpenGL : Swinging camera within the Game Programming forums, part of the General Programming Boards category; Hi people !
My friend is starting a resident evil site , and he wants me to program some games ...

OpenGL : Swinging camera

Hi people !

My friend is starting a resident evil site , and he wants me to program some games for him. So I started working.

I fired up my compiler and got stuck. So I have a 2. questions.

1.

Since he wants it to be 3rd person , I need to create a "person" , and have him move his legs in a walking motion. How would I do this ? I thought I could just make a polygon , (and texture map it with a face and clothes and stuff,) and then just rotate his legs.

Would this work ?

2.

I need the camera to swing around the player object. How can this be done ?

For walking you can do several things. Easiest would be keyframing. Create your model in a 3D editor and keyframe the frames. Save to disk and load. I don't know about OpenGL but Direct3D natively supports keyframing.

Using mathematics and rotation will not make the movements look realistic. To do that you need some expensive hardware to do rotoscoping of an actual human walking. This finds the vertexes and creates the model. The rest is completed on a modelling program.

Same as always: GL only does primitive rendering, you get to do the rest of it!

but yeah, what bubba said is correct: just rotating the legs won't look realistic. Animating is, in short, really hard. There are two 'types' of animation systems: the 'quake2' animation system where you just build the character at each keyframe, and you tween (interpolate) between each keyframe based on time (a keyframe holds the X,Y,Z coordinate of each vertex of the model).

The other way is by using a skeletal animation system, where you build a skeleton out of bones and joints, and each keyframe instead holds the orientation of each bone at each point in time. Therefore, instead of interpolating vertexes, you are interpolating orientations (hard!)

Quake3 and most modern games use skeletal animation

The first method is easiest to implement but doesn't look as good. The second is harder to implement but looks better. I suggest reading a tutorial on the first method and implementing that.

This doesn't 'really' relate to your question all that much, but the rabbit hole gets even deeper with 'skinning'. It only applies to the skeletal animation paradigm of animations, where each vertex of the model is weighted to move along with each bone, based on how far away it is from the bone. I don't know the specifics of it because I've never implemented skinning, but basically when your body moves your skin stretches and slides over the bones, i.e, the skin on your back stretches differently when you move your left arm, right arm, or both arms. Hard stuff.

I would suggest using some simple format like md2 (Quake 2 models). It's very well documented and you could even use someone elses loader if you wanted. The format is really basic you should have no problem at all using those.

"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

What does it use then? I wrote an md3 loader for quake3 (.md3) models a couple of years ago and I distinctly remember having to load data pertinent to a skeletal animation system (linkage and bone data, etc)

What does it use then? I wrote an md3 loader for quake3 (.md3) models a couple of years ago and I distinctly remember having to load data pertinent to a skeletal animation system (linkage and bone data, etc)

It's known as 'vertex animation'. I believe MD3 just has 3 sections like head torso and legs. For instance you can't actually move the head to turn and look one way while the body remains oriented in the original way. I mean, I guess it has those three joints or whatever but you won't find a skeleton in the file.

"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

A keyframe is a representation of the model at various times throughout the animation sequence. Imagine animating a cartoon of someone walking, you draw the person at various instances at each point in the motion. In a computer animation you interpolate between the current keyframe and the next keyframe to get the current position of each vertex of the model.

Skinning is just what you explained Darkness. To impliment it, each vertex is associated with one or more joints (usually 2 joints) and a weight for each of those joints(usually from 0.0 - 1.0). The weight determines the influence of a joints on a vertex and are used when concatenating the matrices:

So if you have multiple joints affecting one vertex, the total has to equal 1 unless you want some funky stuff to happen. You also have to first multiply the vertex by the inverse of the joints so that the transform is relative to an origin.

Necrofear - animation is a pretty heavy task if using OpenGL. If you decide to use some of the formats already suggested then you will have less trouble since they are already solved problems. Exporting yourself from a modeling suite will be a bit more of a challenge, because you have to be familiar with that suite's API or format. I myself am only familar with Maya's API and MEL.

Your camera problem is a bit easier. If you're not keen with your matrix math, I suggest you fix that. If you are, a common approach is to set the camera's position to the player, translate it back so that it isn't inside the player, then rotate it by the current "swing" value. Then have the camera "LookAt" the player. We're talking about that over here: Vector rotation

no it isn't, I explained the basic idea of what a keyframe is, and I used the idea of linearlly interpolating between the vertexes of keyframes (i.e the quake2 style of animating). Skeletal animation still relies on keyframes, but each keyframe typically stores orientations of each bone. But I've explained all of that earlier.

afaik skinning is something only pertinent if you choose the skeletal animation scheme.

I don't know the specifics of it because I've never implemented skinning, but basically when your body moves your skin stretches and slides over the bones, i.e, the skin on your back stretches differently when you move your left arm, right arm, or both arms. Hard stuff.