On Apr 18, 2006, at 2:23 PM, Chris Halford wrote:
I was hoping to use the orientation as I have an object that needs
to point in one of 6 directions and smoothly rotate from one to the
other. I didn't want to necessarily track what way it was facing,
but rather get it to rotate to an absolute orientation. It is only
a little more code to do it using yaw, pitch and roll, so I'm OK
with this.
Well, Orientation is useful for things like this but, as Joe stated,
not by using the individual values.
You could create six Quaternions and store them in an array. Then
using SetRotateByAxis you'd create a different orientation about the
Y axis for each Quaternion.
Q(0).SetRotateByOrientation 0,1,0, value for "N"
Q(1).SetRotateByOrientation 0,1,0, value for "NE"
Q(2).SetRotateByOrientation 0,1,0, value for "E"
etc.
Your Group3D can then be smoothly set between the "current" position
and the "next" position using SetBetween:
Group.Orientation.SetBetween Q(current), Q(Next), a value from 0 to 1
When you reach 1, you then make current = next and next = next + 1
(factoring in the end of the array, of course).
So you'd need a Double that varies from 0 to 1 and an Integer that is
the index for the array.
THAT SAID, it's usually pretty easy to keep track of the Yaw value.
You can use a Quaternion to Euler Angle method to extract the Yaw
value, too. That's pretty complicated, though.
On the same topic. What is the normal way to get a smooth rotation
in a 3d space? I can just loop through a rotation with updates
after each adjustment, or I can use a timer firing N times. Using a
timer seems to be a good way to control the speed, but then I have
to either disable further commands to rotate when it isn't done, or
dynamically recalculate where it is rotating to. In the second
option, I need a way to be able to calculate where the object is
pointing, and without knowing how to use the orientation properly,
I think it might be complicated.
I think understand what your asking here. After a LOT of pain, I use
a Timer with a period set to zero and put my main update loop in
there. I have a double property called deltaTime that is calculated
every "frame" or update. It is then used to adjust the rotation
amount. Why? Because it's almost impossible to keep the rate of
update even. Here are the basics. Joe Strout had an example in the
Plane Simulation that was "flying" around the game list a year or so
ago. I think that it's in the RB examples. Joe?
// some setup someplace
Dim RotationAmount As Double = 0.05 // radians per second
Dim LastFrameTime As Double
Inside the Timer's Action event:
Dim timeStamp As Double
Dim deltaTime As Double
// calculate start frame timing, fac
timeStamp = Microseconds * 0.000001
deltaTime = Min(timeStamp - Self.LastFrameTime, 0.25)
// now call your method that rotates, using deltaTime to adjust
RotateMyObject( RotationAmount * deltaTime)
// update end frame timing
LastFrameTime = timeStamp
Again, just enough to get you in the door.
HTH
--
Joseph Nastasi
Pyramid Design - a software development firm
http://www.pyramiddesign.us
Voice 609 601-0814 Fax 609 601-0815
Products:
A-OK! The Wings of Mercury http://www.aokwom.com
A-OK! Spacecraft Simulation System - http://www.aoksss.com
FTP Suite for REALbasic - http://www.ftpsuite.com
Columnist for REALbasic Developer Magazine
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>