Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualMizmoon

Posted 02 September 2013 - 10:54 AM

Hello everyone!

 

I am trying to make a space RTS where ships have 2 rotation DOF (pitch, yaw) and 3 translation DOF (x,y,z). Each ship has a set of turrets, some of which have their pivot angles restricted. The turret itself pivots around it's yaw axis, and the barrels on their pitch axis, and each axis has its own restrictions. Each turret has one quaternion for the base orientation, and one for the barrel orientation. The turret also has a set traverse speed on each axis. 

 

My problem is that I don't know how to find the rotation needed on each axis to traverse the turret towards it's target. Ofcourse, i also need to find wether it can reach the target at all, or if it should find something else to shoot at. My first thought was to convert the target coordinates into the turrets local space and find the angles using trig (is this possible?). What way would you do it? Do i need to save the local euler orientation or can this be done entirely with quaternions? What is the fastest and easiest way of doing this? 

 

These are the functions i want to make:

private bool isObjectInField (object o)

public bool rotateTowardsPoint (vector v)

But first, some background:

 

*I am making this inside the Warcraft III engine. The language I use is object oriented and similar to Java. 

 

*Z axis is "up", and X is "forward" (in model space).

 

*I am using my own vector and quaternion libraries which have most of the funcitons necessary. I would, however, like to refrain from using SLERP since it is too slow. 

 

Any help is very much appreciated. I can uderstand most code languages, so do feel free to post code examples. 


#1Mizmoon

Posted 02 September 2013 - 08:13 AM

Hello everyone!

 

I am trying to make a space RTS where ships have 2 rotation DOF (pitch, yaw) and 3 translation DOF (x,y,z). Each ship has a set of turrets, some of which have their pivot angles restricted. The turret itself pivots around it's yaw axis, and the barrels on their pitch axis, and each axis has its own restrictions. Each turret has one quaternion for the base orientation, and one for the barrel orientation. The turret also has a set traverse speed on each axis. 

 

My problem is that I don't know how to find the rotation needed on each axis to traverse the turret towards it's target. My first thought was to convert the target coordinates into the turrets local space and find the angles using trig (is this possible?). Do i need to save the local euler orientation or can this be done entirely with quaternions? What is the fastest and easiest way of doing this? 

 

These are the functions i want to make:

private bool isObjectInField (object o)

public bool rotateTowardsPoint (vector v)

But first, some background:

 

*I am making this inside the Warcraft III engine. The language I use is object oriented and similar to Java. 

 

*Z axis is "up", and X is "forward" (in model space).

 

*I am using my own vector and quaternion libraries which have most of the funcitons necessary. I would, however, like to refrain from using SLERP since it is too slow. 

 

Any help is very much appreciated. I can uderstand most code languages, so do feel free to post code examples. 


PARTNERS