camSetDive: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(broken category)
m (Text replacement - "{{Feature|Warning|" to "{{Feature|warning|")
 
(54 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Scripting Commands|CAMSETDIVE]]
{{RV|type=command
[[Category:Scripting Commands OFP 1.96|CAMSETDIVE]]
[[Category:Scripting Commands OFP 1.46|CAMSETDIVE]]
[[Category:Scripting Commands ArmA|CAMSETDIVE]]
[[Category:Command Group: Camera Control|CAMSETDIVE]]


{{Command|= Comments
|game1= ofp
____________________________________________________________________________________________
|version1= 1.00


| ofp |= Game name
|game2= ofpe
|version2= 1.00


|1.00|= Game version
|game3= arma1
____________________________________________________________________________________________
|version3= 1.00


| Sets camera dive angle. Does not commit changes.
|game4= arma2
<br><br>{{warning|This command is '''non-functional'''!}} |= Description
|version4= 1.00
____________________________________________________________________________________________


| camera '''camSetDive''' dive |= Syntax
|game5= arma2oa
|version5= 1.50


|p1 = camera: [[Object]]
|game6= tkoh
|version6= 1.00


|p2 = dive: [[Number]]
|game7= arma3
|version7= 0.50


| [[Nothing]]|= Return value
|gr1= Broken Commands
____________________________________________________________________________________________
|gr2= Camera Control
|x1 = <code> _camera '''camSetDive''' -0.1</code>
| [[camSetBank]], [[setVectorUp]], [[fn vbs setPitchBank (VBS2)]] |= See also


|descr= Sets camera dive angle. Does not commit changes.
{{Feature|warning|This command is '''non-functional'''!}}
|s1= camera [[camSetDive]]  dive
|p1= camera: [[Object]]
|p2= dive: [[Number]]
|r1= [[Nothing]]
|x1= <sqf>_camera camSetDive -0.1;</sqf>
|seealso= [[camSetBank]] [[setVectorUp]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Kronzky
<!-- Note Section BEGIN -->
|timestamp= 20100415182900
|text= Command is non-functional.<br>
Instead use [[setVectorUp]] or {{Link|http://forums.bistudio.com/showthread.php?t{{=}}67384|this user function}} in {{arma1}}.
<spoiler text="Function backup">
<sqf>
// Get Pitch and Bank
// By General Barron (aw_barron@hotmail.com) and vektorboson
// Parameters: object
// Returns: [pitch, bank]
// Returns the pitch and bank of an object, in degrees.
// Yaw can be found using the getdir command.
// Pitch is 0 when the object is level; 90 when pointing straight
// up; and -90 when pointing straight down.
// Bank is 0 when level; 90 when the object is rolled to the right,
// -90 when rolled to the left, and 180 when rolled upside down.
 
// extract parameters
private ["_obj", "_pitch", "_bank", "_yaw", "_vdir", "_vup", "_sign", "_rotate"];
_obj = _this;
// find the yaw (direction) of the object
// note that map compass directions go CW, while coordinate (vector) directions go CCW
// so when we rotate vectors by this much (below), we are actually adjusting the vector as though the object were pointing north
_yaw = getDir _obj;
 
//----------------------------
// function to rotate a 2d vector around the origin
//----------------------------
_rotate =
{
private ["_v", "_d", "_x", "_y"];


<dd class="notedate">Posted on Apr 15, 2010
// extract parameters
<dt class="note">'''[[User:Kronzky|Kronzky]]'''
_v = +(_this select 0); // we don't want to modify the originally passed vector
<dd class="note">Command is non-functional.<br>Instead, use [[fn vbs setPitchBank (VBS2)|fn vbs setPitchBank]] in VBS2, or [[setVectorUp]] or [http://forums.bistudio.com/showthread.php?t=67384  this user function] in Arma.
_d = _this select 1;
<!-- Note Section END -->
</dl>


<h3 style="display:none">Bottom Section</h3>
// extract old x/y values
[[Category:Scripting Commands OFP 1.99|CAMSETDIVE]]
_x = _v select 0;
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
_y = _v select 1;
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
// if vector is 3d, we don't want to mess up the last element
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
_v set [0, (cos _d)*_x - (sin _d)*_y];
[[Category:Broken Scripting Commands|{{uc:{{PAGENAME}}}}]]
_v set [1, (sin _d)*_x + (cos _d)*_y];
// return new vector
_v;
};
//----------------------------
// find pitch
//----------------------------
// get vector dir (pitch)
_vdir = vectorDir _obj;
 
// rotate X & Y around the origin according to the object's yaw (direction)
// we will then be left with the objects vectordir if it were facing north
_vdir = [_vdir, _yaw] call _rotate;
 
// if we reverse the process we used to set pitch when facing north, we can now get pitch
if ((_vdir select 1) != 0) then
{
_pitch = atan ((_vdir select 2) / (_vdir select 1));
}
else
{
// we need a fail-safe here to prevent divide-by-zero errors
// if X is zero, that means pitch is +/-90, we just need to figure out which one
if ((_vdir select 2) >= 0) then { _pitch = 90 } else { _pitch = -90 };
};
 
//----------------------------
// find bank
//----------------------------
// get vector up (bank)
_vup = vectorUp _obj;
 
// rotate X & Y around the origin according to the object's yaw (direction)
// we will then be left with the objects vectorup if it were facing north
_vup = [_vup, _yaw] call _rotate;
 
// rotate Y & Z around according to the object's pitch
_vup = [_vup select 0] + ([[_vup select 1, _vup select 2], 360 - _pitch] call _rotate);
 
// if we reverse the process we used to set bank when facing north, we can now get bank
if ((_vup select 2) != 0) then
{
_bank = atan ((_vup select 0) / (_vup select 2));
}
else
{
// we need a fail-safe here to prevent divide-by-zero errors
// if Z is zero, that means bank is +/-90, we just need to figure out which one
if ((_vdir select 2) >= 0) then { _bank = 90 } else { _bank = -90 };
};
 
// if we are rolled over (abs bank > 90), we need to adjust our result
if ((_vup select 2) < 0) then
{
_sign = [1, -1] select (_bank < 0);
_bank = _bank - _sign*180;
};
 
//----------------------------
// return value
//----------------------------
[_pitch, _bank];
</sqf>
</spoiler>
}}

Latest revision as of 01:26, 2 February 2024

Hover & click on the images for description

Description

Description:
Sets camera dive angle. Does not commit changes.
This command is non-functional!
Groups:
Broken CommandsCamera Control

Syntax

Syntax:
camera camSetDive dive
Parameters:
camera: Object
dive: Number
Return Value:
Nothing

Examples

Example 1:
_camera camSetDive -0.1;

Additional Information

See also:
camSetBank setVectorUp

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Kronzky - c
Posted on Apr 15, 2010 - 18:29 (UTC)
Command is non-functional.
Instead use setVectorUp or this user function in Armed Assault.

// Get Pitch and Bank // By General Barron (aw_barron@hotmail.com) and vektorboson // Parameters: object // Returns: [pitch, bank] // Returns the pitch and bank of an object, in degrees. // Yaw can be found using the getdir command. // Pitch is 0 when the object is level; 90 when pointing straight // up; and -90 when pointing straight down. // Bank is 0 when level; 90 when the object is rolled to the right, // -90 when rolled to the left, and 180 when rolled upside down. // extract parameters private ["_obj", "_pitch", "_bank", "_yaw", "_vdir", "_vup", "_sign", "_rotate"]; _obj = _this; // find the yaw (direction) of the object // note that map compass directions go CW, while coordinate (vector) directions go CCW // so when we rotate vectors by this much (below), we are actually adjusting the vector as though the object were pointing north _yaw = getDir _obj; //---------------------------- // function to rotate a 2d vector around the origin //---------------------------- _rotate = { private ["_v", "_d", "_x", "_y"]; // extract parameters _v = +(_this select 0); // we don't want to modify the originally passed vector _d = _this select 1; // extract old x/y values _x = _v select 0; _y = _v select 1; // if vector is 3d, we don't want to mess up the last element _v set [0, (cos _d)*_x - (sin _d)*_y]; _v set [1, (sin _d)*_x + (cos _d)*_y]; // return new vector _v; }; //---------------------------- // find pitch //---------------------------- // get vector dir (pitch) _vdir = vectorDir _obj; // rotate X & Y around the origin according to the object's yaw (direction) // we will then be left with the objects vectordir if it were facing north _vdir = [_vdir, _yaw] call _rotate; // if we reverse the process we used to set pitch when facing north, we can now get pitch if ((_vdir select 1) != 0) then { _pitch = atan ((_vdir select 2) / (_vdir select 1)); } else { // we need a fail-safe here to prevent divide-by-zero errors // if X is zero, that means pitch is +/-90, we just need to figure out which one if ((_vdir select 2) >= 0) then { _pitch = 90 } else { _pitch = -90 }; }; //---------------------------- // find bank //---------------------------- // get vector up (bank) _vup = vectorUp _obj; // rotate X & Y around the origin according to the object's yaw (direction) // we will then be left with the objects vectorup if it were facing north _vup = [_vup, _yaw] call _rotate; // rotate Y & Z around according to the object's pitch _vup = [_vup select 0] + ([[_vup select 1, _vup select 2], 360 - _pitch] call _rotate); // if we reverse the process we used to set bank when facing north, we can now get bank if ((_vup select 2) != 0) then { _bank = atan ((_vup select 0) / (_vup select 2)); } else { // we need a fail-safe here to prevent divide-by-zero errors // if Z is zero, that means bank is +/-90, we just need to figure out which one if ((_vdir select 2) >= 0) then { _bank = 90 } else { _bank = -90 }; }; // if we are rolled over (abs bank > 90), we need to adjust our result if ((_vup select 2) < 0) then { _sign = [1, -1] select (_bank < 0); _bank = _bank - _sign*180; }; //---------------------------- // return value //---------------------------- [_pitch, _bank];

↑ Back to spoiler's top