Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Finally got useful free flight rotation!

Author
Message
BN2 Productions
16
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 27th Aug 2012 03:29 Edited at: 27th Aug 2012 09:32
Sorry for the unhelpful subject line, but after way way way too long (off and on for a couple years) I finally created my own set of free flight rotation commands. These are purely math based and easy to control. The command set the DBC comes with is nice, but gives you pretty useless Angle commands and your hands are tied, since you can't really do a whole lot without those.

The downsides to this system:
Object Angle X(),Y(),and Z() as well as Move Object no longer work. I am working on a function that will return the pitch, yaw, and roll offsets between the object and the two points.

I'll be posting the functions shortly, but while I\\\'m working on support functions, I wanted to know what functions would be necessary/desirable from you guys.

Ones I assume will be necessary (other than actual rotation commands):
-Find PYR offset
-Point Object
-Move Object
-Return Heading data

Anything else?

And I know there are other (probably better) solutions to this method, but they all seemed like they made things more complicated than they should be. This was an attempt at a purely math based one (though there are 3 limbs required, but they don't do anything but sit there and help with calculations).

[EDIT]
Here's the function set. I'm a little disappointed though. While it seems to work like a charm, it does create issues if you want the camera to interact with it. Maybe people here have some ideas?

To use it, use the function

X axis limb=FFR_PrepObject(Object Number, X offset#, Y offset#, Z offset#)

Basically, the way this works is it sets up a local coordinate axis for the object and then uses some basic vector math to figure out what the global rotation values are for the local rotations (so Pitch is done by rotating around the local X axis which is some combination of the other axes). In order to make it work I had to use FIX OBJECT PIVOT in the functions, making it's angle and orientation data useless. Had I not, it would get stuck at the 90 degree marks. Basically, instead of Euler rotation (DBC's native set) which uses a mix of local and global rotation axes, this will use purely global rotation axes.

The Prep function will:
Add 4 Limbs: 1 at the new origin (Object Position + the offsets given in the function call) and 3 offset from the new origin at 1 unit in each direction (so one limb is 1 unit to the right, one is 1 unit forward, and one is 1 unit up). The function returns the limb number of the X axis limb. Store this value as it is required for all other functions.

The other functions are:
FFR_PitchObject(ObjNum,XLimb,angle#)
FFR_YawObject(ObjNum,XLimb,angle#)
FFR_RollObject(ObjNum,XLimb,angle#)
FFR_FindAngle#(ObjNum,XLimb,X#,Y#,Z#) : this function will determine the pitch, yaw, and roll angles from the object's new origin to the given point.

FFR_MoveObject(ObjNum,XLimb,distance#): This will move the object along its heading. This is included since the FIX OBJECT PIVOT command is being used, thus rendering the MOVE OBJECT command useless.

FFR_PointObject(ObjNum,XLimb,X#,Y#,Z#): (A little buggy) This will point the object at the given point.

FFR_GetHeading(ObjNum,XLimb): This will load the components of the local z axis (the one that points forward) into the array FFR_Heading# in slots 1 (x), 2(y), and 3(z).

FFR_SetCam(ObjNum,XLimb): This positions the camera at the local origin and (should) rotate it to point forward. Unfortunately, the camera rotation math is buggy.

FFR_CameraRoll(ObjNum,XLimb): This is part of the SetCam system. It will zrotate the camera until it is rolled correctly with the object's orientation. I had hoped that you could position the camera at the origin, point it at the z axis limb, and the rotate it but rotating it seemed to mess up the POINT CAMERA function.

These are included as well:
VectorDotProduct(x1#,y1#,z1#,x2#,y2#,z2#): Will return the value of vector <x1#,y1#,z1#> dotted with vector <x2#,y2#,z2#>

VectorCrossProduct(x1#,y1#,z1#,x2#,y2#,z2#): Will return the value of the cross product of vectors <x1#,y1#,z1#> and <x2#,y2#,z2#>. The three components turned into a unit vector, multiplied by 255 and combined using the RGB command. The computed color value is returned. To get the data out, use the RGBR, RGBG, and RGBB commands for the X, Y, and Z components of the result and then divide each by 255.




EDIT2

I solved the FFR_PointObject problem. It was in the functions FFR_FindAngle#() and the VectorCrossProduct#(). Here is the updated function:


VectorCrossProduct#() will still return a color value. However, instead of each unit vector component being multiplied by 255, it is multiplied by 127, and then added to 127. This way, it will preserve negative values. To unpackage it, just take the RGBR,RGBG,and RGBB values, subtract 127, then divide by 127.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose

Login to post a reply

Server time is: 2020-08-05 03:17:09
Your offset time is: 2020-08-05 03:17:09