Results 1 to 4 of 4

Thread: Move an object

  1. #1
    Junior Member Newbie
    Join Date
    May 2007
    Posts
    2

    Move an object

    Hi,

    My goal is to creat a demo with a md2 file.
    I have load a md2 file and creat a camera with glulookat.
    The md2 object is a gun (M16) and I have put the camera behind the gun (first person view)
    I can move the "look at" of the camera with the mouse as if a man moves his head but now I want move the gun as if the man walks and I don't know how do that.
    If the eyes are the camera when the man moves the position of the camera change and the gun is behind the man but I want the gun moves with the man.

    Can you give me a solution ?
    I must use glTranslate and glRotate ?

    thanks,

    Julien

  2. #2
    Senior Member Frequent Contributor plasmonster's Avatar
    Join Date
    Mar 2004
    Posts
    739

    Re: Move an object

    MD2 models don't have bones or hard bind points, so this'll probably amount to defining some attack points yourself to track the weapon position and orientation.

    As I recall, the Quake2 models have all the key-frame animation info for weapons built-in, but you could probably derive it with some clever analysis of the frames (don't think I'd want to try it).

    You might want to try the Quake3 models (MD3), since they have well defined tags for mounting weapons and flags and so forth. I actually tinkered with a camera mounted on the head tag just as you did, but it didn't work so hot, wobbled and shimmied like all get out, kinda made me sea sick

  3. #3
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: Move an object

    Before paypal, before youtube, there was....

    http://www.jawed.com/programs/quake.html

    This accompanied a Dr Dobbs Article.

    The MD2 file has exchangable weapons for players so it probably has some kind of information in there to animate it unless it's implicit. Not used in Jawed's code AFAIK.

    http://tfc.duke.free.fr/coding/md2-specs-en.html

    If you know where to stick the gun then the rest is simple, that's the only tricky part. It's not really about the gun it's about the transform to hand position...

    THAT IS ALL WAY MORE COMPLEX THAN YOUR EXERCISE I THINK....

    NOW if your goal is JUST to draw the own gun in an FPS then it's really simple. This is an exercise to teach you about eyespace vs. world space.

    You need an FPS kind of an animation where yu can run around. When you have this you simply load the gun while identity in son the modelview stack, pushmatrix, transform to the position relative to the eye, popmatrix and draw everything as normal including the viewing transformation. Simple really.

    The links I supplied should help you with the basics of loading and drawing the gun model.

  4. #4
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: Move an object

    P.S. so in conclusion this is not really about moving an object, it's about positioning an object relative to eyespace on the transformation stack. You can use glTranslate and rotate to position the gun relative to the eye. You Can also use it to run around (inverse and in reverse order since eye transforms are the inverse of model transforms on the modelview).

    FWIW it's a very good lesson IMHO.

Similar Threads

  1. Move object with mouse
    By roband915 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-25-2011, 07:33 AM
  2. move object on screen
    By lenna in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-26-2004, 04:36 PM
  3. object move?
    By kayouti in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-26-2003, 01:21 PM
  4. object move help
    By adityask in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-18-2002, 08:14 PM
  5. select and move object
    By adityask in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-11-2002, 08:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean