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 ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    183

    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 ?

    Thanks to anyone who helps.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    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.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    I don't know about OpenGL but Direct3D natively supports keyframing.
    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.
    Last edited by Darkness; 04-10-2005 at 02:32 PM.
    See you in 13

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Actually Quake3 does not use skeletal animation.

    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

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    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)
    See you in 13

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Quote Originally Posted by Darkness
    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

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    Well I just plain don't remember.
    See you in 13

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    183

    Smile

    Okay , thanks for your help.

    But I have a question. This will sound really stupid to you people who are , well clever , but what the hell are keyframes ?

    Also , I know these are to complicated for me , but these "bones" , I make them how ?

    Thanks again.

  9. #9
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    No question is a bad one.

    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.

    You make the bones in a 3D modeling program.
    See you in 13

  10. #10
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    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:
    Code:
    Transform = (jointMatrix1 * weight1) * (jointMatrix2 * weight2);
    newVertPos = Transform * oldVertPos;
    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

  11. #11
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    Skinning is just what you explained Darkness
    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.
    See you in 13

  12. #12
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    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.
    Thats the explanation I was talking about. Brief, but correct.

  13. #13
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    Ohh, my bad.
    See you in 13

  14. #14
    Registered User
    Join Date
    Jan 2005
    Posts
    183
    Okay. Sounds hard.

    Anyway thanks for all your help , things are alot clearer now. The camera problem sounds pretty simple , I'll sort that out first.

    Again thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. camera rotation matrix
    By Vick jr in forum Game Programming
    Replies: 5
    Last Post: 05-26-2009, 08:16 AM
  2. LNK2001 ERROR!!! need help
    By lifeafterdeath in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2008, 05:05 PM
  3. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  4. OpenGL camera errors..can't find 'em!?
    By psychopath in forum Game Programming
    Replies: 12
    Last Post: 04-22-2004, 06:17 PM
  5. Camera rotation/movement in 3D world
    By tegwin in forum Game Programming
    Replies: 11
    Last Post: 01-24-2003, 12:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21