Jump to content
Sign in to follow this  
Prospero

Animation phase - mils or radians?

Recommended Posts

The topic says it all:)

Animation phase - is it based on mils or radians? It's just quite difficult to be certain...

Anyone know for definite?

Prospero

Share this post


Link to post
Share on other sites

Definitely mils. If you use a final angle of 3.14, you will only get a 180 degree turn. If it were radians, that would have been a full circle.

the minimum is of course 0, the maximum is 6.4

Share this post


Link to post
Share on other sites

Edit: :counts on his fingers:....

But if you rotate something by 3.14 radians, it is rotated by 180 degrees (approx to 1 dp) by very definition...

How does that prove this?

Prospero

Share this post


Link to post
Share on other sites

Here it's said that

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">

[...] I think the angles are in mils, meaning on a 64000 : 360 scale

For example, if the angle is 3.2 it is at 32000 mils or 180 degrees[...]

<span id='postcolor'>

I tried this (6.4^=360°, 3.2^=180°, 1.6^=90°) and it worked fine. Mils is the answer!?

btw.: calculations...

2pi ^= 360°;    x[rad] = pi * y[°] / 180°

Share this post


Link to post
Share on other sites

Yup, what I was getting at is this:

Say, for example, I want to rotate something by 180 degrees using the Animate command...

If I think it's expecting radians, I'll specify a value of 3.14 (pi)

If I think it's expecting mils(/1000), I'll specify a value of 3.2

Problem is... which is it? They're relatively close... so it's hard to tell. I know that the various sample configs available make it look like mils, but elsewhere BIS seem to have used radians. So, my question still stands. I'll pray that someone from BIS can spare one word - "mils" or "radians"wink.gif Otherwise I'll have to conduct an in-game experiment that'll probably take me half a day;) Hey I'm a perfectionist... I don't care;)

Prospero

PS: And by the way, there are 6400 mils to 360 degrees, not 64000 mils.

Share this post


Link to post
Share on other sites

Possible experiment:

Create two very long cylinders (approx 100m) parallel to each other and to the ground, and animate one of these to rotate around an axis perpendicular to the ground. Ingame, activate the animation and look for any differences between the cylinders after the animation is complete. Try both possible values: 6.4 and 6.28(=2pi).

Write a protocoll and document this important scientific experiment, also known as the bastler-rotation... wink.gif

Hm, perhaps tomorrow...

*yawns*

btw: I was quoting this 64000mil-thingy; I didn't came across this unit before -I'm used to work with rad or °

Share this post


Link to post
Share on other sites

Salutations!

Let's see if I may be of assistance at this hour... it's already 02:35.

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">btw: I was quoting this 64000mil-thingy; I didn't came across this unit before -I'm used to work with rad or ° <span id='postcolor'>

Although radians are the SI standart, the fundamental unit to measure angles is degrees, since we can work with them, convert and perform calculations of small fractions, without the use of pi.

If I remember right, mils (mil of angle) is a unit derived from the SI radian, with the goal to provide resolution and avoid the use of the irrational pi. If we divide the rad by 1000 to provide resolution, we will have a milliradian. A circle comprises 6283.185... milliradians, what is a good resolution but still irrational. Then, if a unit is defined as 1/6400 of a circle, we have resolution and won't need pi. This unit is mil, a rough milliradian. (1mil = 0.9817477042468104...rad)

hope it helps...

té mais

PakoAry

Share this post


Link to post
Share on other sites

Excellent discussion, guys. Does anyone know how to make the animation run indefinite (foreaver), or a tleast until a command to stop is given. Then perhaps another command to start again from the last stop point. Just a thought.

Share this post


Link to post
Share on other sites

Interesting point!

A problem I came across:

There might be more than one radar device, e.g. a long range radar (slow 360°-rotation, spotting targets) and 2-sector short range radar devices (fast oscillating movement, exact target identification). Well, the long range radar could be defined as the vehicle's radar, but what's about the others?

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Colonel_Klink @ Oct. 19 2002,13:11)</td></tr><tr><td id="QUOTE">Excellent discussion, guys. Does anyone  know how to make the animation run indefinite (foreaver), or a tleast until a command to stop is given. Then perhaps another command to start again from the last stop point. Just a thought.<span id='postcolor'>

Yes, I'll try to post the code later today (I'll base it on rads - you can always change it to mils if this turns out to be incorrect). Right in the middle of some addAction stuff right now.

Prospero

Share this post


Link to post
Share on other sites

Script-controllable Rotations - via angle and rate.

---------------------------------------------------------

OK, this assumes that animations are based on radians. If it's mils, it's obvious how to change it. OK, let's go...

1) Have this in your config.cpp - anywhere in the CfgVehicles section:

----------

animated=1;

class Animations

{

class Yaw

{

type="rotation";

animPeriod=0.0000001;

selection="myselection";

axis="osa_yaw";

angle0=0;

angle1=6.2831853;

//angle1=6.4<-------- If it's mils. I've yet to find out.

};

};

----------

2) Notice that I've created a rotation axis called "osa_yaw" and I've named the selection I want to rotate about this axis as "myselection". We'll say that "myselection" is a component part of an object called "myobject". You can call the axis, the selection and, of course, the object whatever you like. You don't have to learn Czech for custom rotations;)

3) Now, here's the script snippet to control the rotation:

----------

; Specify desired rotation angle _dir in DEGREES (_dir can be > 360 degrees or < 0 degrees if you like). Then...

_yaw = abs((_dir % 360) / 360)

?(_dir < 0): _yaw = 1 - _yaw

myobject animate ["Yaw", _yaw]

----------

4) And you're done;)

5) You can set the angle _dir to any specific angle you like - it can be negative - you can incremement or decrement it in a fast loop to get a continuous rotation. Whatever. Up to you.

Prospero

Edit:

I wonder if the two lines...

_yaw = abs((_dir % 360) / 360)

?(_dir < 0): _yaw = 1 - _yaw

... could be contracted to one, and without a condition?

Further edit:

If you just increment / decrement _dir for infinitely long rotations, ensure _dir doesn't overflow. To avoid this, reset it to 0 when it's any multiple of 360, for example.

Further edit:

OK, now some of you may be wondering how to get an *accurately timed* rotation *rate* using the above method. Here:

----------

; Note that _directionrate is in DEGREES PER SECOND.

_dir = 0

_directionrate = 45

_ot = Time

#lp

~0.0001

_nt = Time

_dt = (_nt - _ot)

?(_dt == 0): goto "lp"

_yaw = abs((_dir % 360) / 360)

?(_dir < 0): _yaw = 1 - _yaw

myobject animate ["Yaw", _yaw]

_dir = _dir + _directionrate * _dt

_ot = _nt

goto "lp"

----------

Further edit:

If you define a whole object as the selection to be rotated, you can of course then yaw the object with setDir, and pitch it using a custom animation around a named pitch axis. This gives you the ability to "kinda" set an object's yaw *and* pitch. Here's a 2-Axis rate controller script:

----------

_yaw = 0

_yawrate = 45

_pitch = 0

_pitchrate = 90

_ot = Time

#lp

~0.0001

_nt = Time

_dt = (_nt - _ot)

?(_dt == 0): goto "lp"

_ph = abs((_pitch % 360) / 360)

?(_pitch < 0): _ph = 1 - _ph

myobject setdir _yaw

myobject animate ["Pitch", _ph]

_yaw = _yaw + _yawrate * _dt

_pitch = _pitch + _pitchrate * _dt

_ot = _nt

goto "lp"

----------

And you would have the following in your config.cpp - again, anywhere in the CfgVehicles section, and this time I've called the selection "All". Remember, you have to make and name this selection manually - click & drag a box over the whole thing;)

----------

animated=1;

class Animations

{

class Pitch

{

type="rotation";

animPeriod=0.0000001;

selection="All";

axis="osa_pitch";

angle0=0;

angle1=6.2831853;

};

};

----------

Further edit:

Many separate custom rotation axes can be defined on one .p3d model, but sadly, you cannot assign two rotation axes to rotate one selection, although obviously, you can assign several components to one selection. Therefore, you can't setDir an object's yaw, then pitch and roll the selection (the selection being the entire object) with two custom axes. Damn shame...

However, to define two *separate* rotation animations in your config.cpp, you would add this:

----------

animated=1;

class Animations

{

class Rotation1

{

type="rotation";

animPeriod=0.0000001;

selection="selection1";

axis="osa_rot1";

angle0=0;

angle1=6.2831853;

};

class Rotation2

{

type="rotation";

animPeriod=0.0000001;

selection="selection2";

axis="osa_rot2";

angle0=0;

angle1=6.2831853;

};

};

----------

As you can see, I've defined the two rotatable selections as "selection1" and "selection2". Remember, you can call these anything you like.

Further edit:

It should also be pointed out that you can control ANY selection by manual animation script (as above) - For example, add an entry in the config.cpp for a rotation animation for one of the "reserved" (Czech-named) selections. Just ensure that your script addresses the correct axis & selection. To find out the correct axis and selection names, examine the object's original MLOD single-player demo .p3d file. Now, if you were to call that object "myobject", then...

myobject animate ["osa_<something>", <angle>]

So, say you wanted a cutscene where a technician is testing out an AH-64's pan/tilt cannon as the helicopter sits on the ground in a hangar. This way you can make that cannon pan and tilt as you want. Well, pan OR tilt. I'm not sure if you can do both at the same time...

Share this post


Link to post
Share on other sites

Thanks Prospero

I've managed to get a sort of continuous animation be setting the following:

animPeriod=10000;

angle1=360000;

The only problem is that the animation does stop eventually.

I'll try the code you've posted.

I'm using it on a revamped radar station - th old radar addon but using animation rather than 'tank' classes. there will only be one model and have the antenna, the radar screen and doors animating.

Question: I presume the code  to start the animation is in script form to be called within OFP. Is there any way to have that in the cpp?

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Colonel_Klink @ Oct. 19 2002,14:27)</td></tr><tr><td id="QUOTE">Question: I presume the code  to start the animation is in script form to be called within OFP. Is there any way to have that in the cpp?<span id='postcolor'>

Good question. I believe this may be possible with v1.85, but I haven't got round to trying it. Perhaps someone else who has could contribute?

Prospero

Share this post


Link to post
Share on other sites

I'm bumping this topic as I added many edits to my last-but-one message here (see above). I suspect that people may find the information useful.

Prospero.

Share this post


Link to post
Share on other sites

Salutations!

I'd like to be more active in the forum, but unfortunatly, since I don't play lotto, work will still consume a lot of time. I know everybody works and this is a placebo complain but, since I'm unable to devote some time to projects I want, I felt like snivelering out.... done.

emptied chest...  to the point then:

I was reading that cfgVehicles.hpp when I found this line:

landingAoa = 10*3.1415/180;

Assuming that this line is setting a landing Angle of attack of aprox. 10 degrees, we can conclude that rotation unit is radian, since it converts degrees to rad using an aprox pi.

té mais

PakoAry

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×