Jump to content
Sign in to follow this  
Prospero

Scripted rotations

Recommended Posts

Hi all,

Many people have asked whether an object's pitch and roll (as well as yaw, or direction) can be specified using a script. And up till now, although I have been able to determine the yaw, pitch and roll of any object (via script), I have never been able to _set_ an object's pitch and roll. However, now that I've finally got my hands on O2 (I'm a scripter, not a modeller!wink.gif, I suspect that there may be a way:

Firstly, you have to make a "special" version of the object in question. It would be identical to the original, except that you define the object as the "turret" of an invisible base object, this turret being assigned pitch and roll axes. You then use the recently introduced animation phase commands to provide you with the ability to set pitch and roll. Yaw is achieved in the normal fashion via setDir.

I have experimented with door position-setting scripts which work very well. I see no reason why this method could not be expanded.

Thoughts?

Prospero

Share this post


Link to post
Share on other sites

A follow-up whilst it occurs:

Some people have wondered how to do translation animations instead of rotation animations. It is fairly obvious, but I may as well point out that if you displace the axis of rotation away from the object, you can of course achieve a fairly effective translation by a rotation. So, sliding doors etc.

Prospero

Share this post


Link to post
Share on other sites

Group: Members

Posts: 22

Joined: July 2002

Posted: Sep. 19 2002,15wow.gif0

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

Hi all,

I've been trying to create objects whose pitch and roll can be set via script. As we all know, you can set the yaw (or direction) via a setDir, but you can't do the same for pitch and roll.

Well, I'm halfway there! To explain...

I was messing around with Zwadar's openable gate model, as he uses one axis of rotation animation to raise and lower the gate arm. I modified the config.cpp to look like this:

----------

class CfgPatches

{

class kkb_gate

{

units[] = {"kkb_gate"};

weapons[] = {};

requiredVersion = 1.75;

};

};

class CfgModels

{

class Default { };

class kkb_gate: Default

{

sections[]={"arm"};

sectionsInherit="";

};

};

class CfgVehicles

{

class All {};

class Static: All {};

class Building: Static {};

class NonStrategic: Building {};

class Fence: NonStrategic {};

class kkb_gate_dummy: Fence

{

accuracy=1.000;

scope=0;

vehicleClass="Objects";

model="\kkb_gate\kkb_gate.p3d";

displayName="Gate";

destrType=destructtree;

cost=100;

icon="\kkb_gate\kkb_gate.paa";

};

class kkb_gate:kkb_gate_dummy

{

Scope=2;

accuracy=1000;

displayName="KKB Gate";

animated=1;

class Animations

{

class roll

{

type="rotation";

animPeriod=0.0000001;

selection="arm";

axis="osa_roll";

angle0=0;

angle1=6.284;

};

class pitch

{

type="rotation";

animPeriod=0.0000001;

selection="arm";

axis="osa_pitch";

angle0=0;

angle1=6.284;

};

};

};

};

----------

I then modified the .p3d by adding a second axis of rotation (by adding two vertices to form the axis in the appropriate place), and as you can see, I've called these axes "osa_roll" and "osa_pitch". Both are set to operate on the selection "arm".

Now, in my script, I can use the following commands to set the roll and pitch of the gate arm:

mygate animate ["pitch", _a]

mygate animate ["roll", _b]

...where mygate is the name I've assigned to the gate, and _a and _b are values between 0 and 1. Going from 0 to 1 gives you one full 360 rotation.

Well, it half works. If I use the config .cpp exactly as quoted above, the pitch will work but the roll won't. If I simply then swap the order in which the animations are written in the config.cpp, the roll will work but the pitch won't!

Any ideas chaps?

Prospero

Edited by Prospero on Sep. 19 2002,15wow.gif3

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

denoir

Veni, Vidi, Volvo

Group: Moderator

Posts: 3840

Joined: Aug. 2001

Posted: Sep. 19 2002,15wow.gif9

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

What was wrong with this thread?

http://www.flashpoint1985.com/cgi-bin....otation

Oh do go away Denoir! You must be the official forum's equivalent of Sefe at OFPEC. Trade in some of that officiousness for a modicum of charm.

Share this post


Link to post
Share on other sites

My guess is that an object is only allowed one animation. I messed around with that gate too, great example.

Hopefully we'll discover exactly how these animations work. Wouldn't it be nice if BIS put up a post about how their new functions that came with resistance can be used?

Share this post


Link to post
Share on other sites
Guest

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Oh do go away Denoir! You must be the official forum's equivalent of Sefe at OFPEC. Trade in some of that officiousness for a modicum of charm. <span id='postcolor'>

If you feel that you cannot follow our rules then I will gladly spare you the trouble of visiting these forums again. Just let me know and I'll arrange it smile.gif

Share this post


Link to post
Share on other sites

Hi all,

A further note.

I was playing round with Kegetys's AGS-17 (it's basically like the M2 - a gun on a turret). I was able to pitch the barrel up and down via the animate script command by simply adding animation to the config.cpp, and specifying the axis & selection of interest (i.e. you don't have to add any custom rotation axes). Still trying to get two axes to work at the same time though...

And yes, it would be lovely to have a steer from Suma on this - the question being: Can one have two (or more) rotation animations on the same selection so that both roll and pitch can be set via script?

The number of things one could do then would be awesome...

Prospero

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 (Prospero @ Sep. 19 2002,22:29)</td></tr><tr><td id="QUOTE">I was messing around with Zwadar's openable gate model<span id='postcolor'>

Huh?  confused.gif

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 (Prospero @ Sep. 21 2002,10:14)</td></tr><tr><td id="QUOTE">And yes, it would be lovely to have a steer from Suma on this - the question being: Can one have two (or more) rotation animations on the same selection so that both roll and pitch can be set via script?<span id='postcolor'>

No.

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  

×