setObjectScale: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Article creation)
 
m (Text replacement - "[[Arma 3 " to "[[Arma 3: ")
 
(22 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Command
{{RV|type=command


|game1= arma3dev |Game name=
|game1= arma3
|version1= 2.02


|version= 2.01 |Game version=
|arg= local


|arg= |Multiplayer Arguments ("local" or "global")=
|eff= global


|eff=  |Multiplayer Effects ("local" or "global")=
|gr1= Object Manipulation


|serverExec= |Multiplayer Execution ("server" or empty)=
|descr= Scales an [[attachTo|attached object]] or a [[Arma 3: Simple Objects|Simple Object]]'s model - see {{Link|#Example 3}} for various configurations' examples.
____________________________________________________________________________________________


|descr= Scales an [[attachTo|attached object]] or a [[Arma_3_Simple_Objects|Simple Object]]'s model scale. |Description=
|pr= The {{arma3}} [[LOD]] limits still apply, meaning walkable surfaces can only be (~70?)m in size, and collision in general will only work up to (?)m from object center.
This command works on all objects in [[:Category:Eden Editor|Eden Editor]] or scenario preview, but it will not save and will reset when objects get moved. [[:Category:Eden Editor|Eden Editor]] support is only intended for artists.


|mp= |Multiplayer Behaviour=
{{Feature|informative|
Setting the scale of non-simple objects, such as vehicles with players/AI in them, static objects (<syntaxhighlight lang="cpp" inline>simulation = "house"</syntaxhighlight> in config), etc. might be possible,
but not officially supported. You may encounter issues.
}}
 
{{Feature|important|
Changing the direction of the object (e.g. using [[setDir]], [[setVectorDir]], etc.) will reset the object back to its original size (probably because the engine normalises the directions,
thus the scale in the transformation matrix becomes 1), so those commands should be run '''before''' resizing the object.
}}
 
|s1= object [[setObjectScale]] scale
 
|p1= object: [[Object]] - must be either an [[attachTo|attached object]] or [[Arma 3: Simple Objects|Simple Object]] - see {{Link|#Example 3}}
 
|p2= scale: [[Number]] - in range 0.0001..65504, relative to the object model's normal scale
 
|r1= [[Nothing]]
 
|x1= <sqf>
_vehicle attachTo [player, [0,0,0]];
_vehicle setObjectScale 0.1;
</sqf>
 
|x2= <sqf>
// select an object in Eden Editor and execute the following code in the Debug Console. When moving the object, the effect is reset!
private _object = get3DENSelected "Object" select 0;
_object setObjectScale 0.1;
</sqf>
 
|x3= <sqf>
// multiple MP-compatible options


|pr= The Arma LOD limits (link to lod page) still apply, meaning walkable surface can only be XXm in size, and collision in general will only work up to XXm from object center.
// global simple object
This command works on all objects while in Eden Editor or Preview, but it will not save and will reset when object gets moved. Eden Editor support is only intended for artists.
private _globalSimpleObject = createSimpleObject ["C_Offroad_01_F", getPosASL player, false];
Setting the scale of actively simulated objects (Vehicles with players/AI in them) is possible, but not officially supported, you may encounter issues. |Problems=
_globalSimpleObject setObjectScale 0.1; // once is enough as long as it is not moved
____________________________________________________________________________________________


|s1= object [[setObjectScale]] scale |Syntax=
// local normal object
private _localNormalObject = "C_Offroad_01_F" createVehicleLocal getPosATL player;
_localNormalObject attachTo [player, [0, 2, 1.5]]; // normal object must be attached
_localNormalObject setObjectScale 0.1; // once is enough as long as it is not moved


|p1= object: [[Object]] - Must be either an attached object or Simple Object |Parameter 1=
// local simple object
private _localSimpleObject = createSimpleObject ["C_Offroad_01_F", getPosASL player, true];
_localSimpleObject setObjectScale 0.1; // once is enough as long as it is not moved
</sqf>


|p2= scale: [[Number]] - Limited to 0.0001 to 65504, relative to the object model's normal scale |Parameter 2=
|x4= <sqf>
____________________________________________________________________________________________
// a not-so-great EachFrame workaround for a non-attached object


|x1= <code>_mrap [[attachTo]] <nowiki>[</nowiki>[[player]],[0,0,0]];
// a normal object that is not attached must be scaled each frame
_mrap [[setObjectScale]] 0.1;</code> |Example 1=
// make sure the object is LOCAL in order to not saturate the network!
____________________________________________________________________________________________
private _localNormalObject = "C_Offroad_01_F" createVehicleLocal getPosATL player;
// the object is not attached to anything
addMissionEventHandler [
"EachFrame",
{ _thisArgs params ["_obj", "_scale"]; _obj setObjectScale _scale; },
[_localNormalObject, 0.1]
];
</sqf>


|seealso= [[getObjectScale]] |See Also=
|x5= <sqf>
// only do the following in single player;
// NEVER do such EachFrame in multiplayer!!
// the performance will be terrible, the network will be saturated, the scaling may desync and not be perfect
private _globalNormalObject = "C_Offroad_01_F" createVehicle getPosATL player;
addMissionEventHandler [
"EachFrame",
{ _thisArgs params ["_obj", "_scale"]; _obj setObjectScale _scale; },
[_globalNormalObject, 0.1]
];
</sqf>
 
|seealso= [[getObjectScale]] [[createVehicleLocal]], [[createSimpleObject]] [[BIS_fnc_createSimpleObject]] [[Multiplayer Scripting]]
}}
}}


<dl class="command_description">
{{Note
<!-- BEGIN Note Section -->
|user= P1ker1
<!-- For example:
|timestamp= 20220104221733
<dd class="notedate">Posted on Month Day, Year - Time (UTC)</dd>
|text= Note that
<dt class="note">[[User:User Name|User Name]]</dt>
<sqf>_obj setObjectScale 2;</sqf>
<dd class="note">This is an example note. It is true and verifiable, and contains a little code snippet.
doubles the scale factor of an object, not the volume. In the case of a cube this would be the length of an edge.<br>If you want to multiply the volume, raise the ''scale'' to the power of 1/3.<br>
<code>[[if]] ([[_this]] == anExample) [[then]] { [[hint]] "Leave it here for others to read"; };</code></dd>
<sqf>
-->
// Example with 1x1x1 m^3 helper objects
<!-- END Note Section -->
// vectorAdds elevate the cubes so they touch the ground after scaling.
</dl>
_cube1 = createSimpleObject ["Land_VR_Shape_01_cube_1m_F", getPosASL player vectorAdd [1,3,0.5]];
_cube2 = createSimpleObject ["Land_VR_Shape_01_cube_1m_F", getPosASL player vectorAdd [3,1,0.5]];
_cube3 = createSimpleObject ["Land_VR_Shape_01_cube_1m_F", getPosASL player vectorAdd [1.35,1.35,0.13]];


<h3 style="display:none">Bottom Section</h3>
// Double the side length. V=2^3=8
<!-- Non-automatic appropriate categories go here, e.g
_cube1 setObjectScale 2;
[[Category:Scripting Commands {{arma3}}|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
// Octuple(8x) the volume. V=(8^(1/3))^3=8
-->
_cube2 setObjectScale 8^(1/3);
 
// Double the volume. V=(2^(1/3))^3=2
_cube3 setObjectScale 2^(1/3);
</sqf>
}}

Latest revision as of 10:38, 6 May 2024

Hover & click on the images for description

Description

Description:
Scales an attached object or a Simple Object's model - see Example 3 for various configurations' examples.
Problems:
The Arma 3 LOD limits still apply, meaning walkable surfaces can only be (~70?)m in size, and collision in general will only work up to (?)m from object center. This command works on all objects in Eden Editor or scenario preview, but it will not save and will reset when objects get moved. Eden Editor support is only intended for artists.
Setting the scale of non-simple objects, such as vehicles with players/AI in them, static objects (simulation = "house" in config), etc. might be possible, but not officially supported. You may encounter issues.
Changing the direction of the object (e.g. using setDir, setVectorDir, etc.) will reset the object back to its original size (probably because the engine normalises the directions, thus the scale in the transformation matrix becomes 1), so those commands should be run before resizing the object.
Groups:
Object Manipulation

Syntax

Syntax:
object setObjectScale scale
Parameters:
object: Object - must be either an attached object or Simple Object - see Example 3
scale: Number - in range 0.0001..65504, relative to the object model's normal scale
Return Value:
Nothing

Examples

Example 1:
_vehicle attachTo [player, [0,0,0]]; _vehicle setObjectScale 0.1;
Example 2:
// select an object in Eden Editor and execute the following code in the Debug Console. When moving the object, the effect is reset! private _object = get3DENSelected "Object" select 0; _object setObjectScale 0.1;
Example 3:
// multiple MP-compatible options // global simple object private _globalSimpleObject = createSimpleObject ["C_Offroad_01_F", getPosASL player, false]; _globalSimpleObject setObjectScale 0.1; // once is enough as long as it is not moved // local normal object private _localNormalObject = "C_Offroad_01_F" createVehicleLocal getPosATL player; _localNormalObject attachTo [player, [0, 2, 1.5]]; // normal object must be attached _localNormalObject setObjectScale 0.1; // once is enough as long as it is not moved // local simple object private _localSimpleObject = createSimpleObject ["C_Offroad_01_F", getPosASL player, true]; _localSimpleObject setObjectScale 0.1; // once is enough as long as it is not moved
Example 4:
// a not-so-great EachFrame workaround for a non-attached object // a normal object that is not attached must be scaled each frame // make sure the object is LOCAL in order to not saturate the network! private _localNormalObject = "C_Offroad_01_F" createVehicleLocal getPosATL player; // the object is not attached to anything addMissionEventHandler [ "EachFrame", { _thisArgs params ["_obj", "_scale"]; _obj setObjectScale _scale; }, [_localNormalObject, 0.1] ];
Example 5:
// only do the following in single player; // NEVER do such EachFrame in multiplayer!! // the performance will be terrible, the network will be saturated, the scaling may desync and not be perfect private _globalNormalObject = "C_Offroad_01_F" createVehicle getPosATL player; addMissionEventHandler [ "EachFrame", { _thisArgs params ["_obj", "_scale"]; _obj setObjectScale _scale; }, [_globalNormalObject, 0.1] ];

Additional Information

See also:
getObjectScale createVehicleLocalcreateSimpleObject BIS_fnc_createSimpleObject Multiplayer Scripting

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
P1ker1 - c
Posted on Jan 04, 2022 - 22:17 (UTC)
Note that
_obj setObjectScale 2;
doubles the scale factor of an object, not the volume. In the case of a cube this would be the length of an edge.
If you want to multiply the volume, raise the scale to the power of 1/3.
// Example with 1x1x1 m^3 helper objects // vectorAdds elevate the cubes so they touch the ground after scaling. _cube1 = createSimpleObject ["Land_VR_Shape_01_cube_1m_F", getPosASL player vectorAdd [1,3,0.5]]; _cube2 = createSimpleObject ["Land_VR_Shape_01_cube_1m_F", getPosASL player vectorAdd [3,1,0.5]]; _cube3 = createSimpleObject ["Land_VR_Shape_01_cube_1m_F", getPosASL player vectorAdd [1.35,1.35,0.13]]; // Double the side length. V=2^3=8 _cube1 setObjectScale 2; // Octuple(8x) the volume. V=(8^(1/3))^3=8 _cube2 setObjectScale 8^(1/3); // Double the volume. V=(2^(1/3))^3=2 _cube3 setObjectScale 2^(1/3);