Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Maintain alignment of two objects with modelview

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 tkdd08   Members   

102
Like
0Likes
Like

Posted 07 April 2013 - 09:58 AM

Hi all,

I'm rather new to the world of OpenGL and I've been banging my head against the desk for a while now trying to figure this out so hopefully you guys can help me with that. I have two objects, both of which are modelled statically and maintain their own transformation matrices for any transformations done to them.

One object - the enemy in my game - I want the user to always be staring at, so I maintain a point that represents it's center, and use gluLookAt to accomplish that. Now I want this enemy to be able to rotate up and down around the x axis and left and right around the y axis with respect to the eye point at (0, 0, 0), and when it does the other object - my weapon - will follow it.

Here's a screenshot so you can get a better idea of what I'm working with

All works fine and dandy for the enemy if I am only rotating in one direction, but as soon as I start to mix, things start to break. For example:

Enemy starts at origin, rotate around y-axis 90 degrees so that enemy is now to our right, try to rotate around x-axis relative to view, and enemy/weapon rotate almost in place, this is because the modelview's x-axis is now parallel to the enemy. I would have to rotate around the z-axis to get the effect of rotating up or down.

The other challenge, is that the weapon object is always following the cursor (ie x, y of cursor -> x, y, z on world coordiantes, with z held at -10.0). But if I rotate the enemy+weapon roughly 90 degrees around the y-axis, and then try to move my weapon, it won't move in the x direction anymore (since we're parallel to the modelview's x-axis). 

Any ideas on how to accomplish all this? Any help would be greatly appreciated!!






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.