setObjectTexture: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|x([0-9])= *<code>([^<]*)<\/code>" to "|x$1= <sqf>$2</sqf>")
m (Text replacement - "<dd class="note">([^}]*)<code>([^<]*)<\/code>" to "<dd class="note">$1<sqf>$2</sqf>")
Line 68: Line 68:
Instead of bitmaps, procedural textures can be used.<br>
Instead of bitmaps, procedural textures can be used.<br>
The syntax for those is '''#(argb,8,8,3)color(R,G,B,A)''', where R,G,B stands for Red, Green, Blue, and A stands for Alpha, all values can be anything between 0 and 1 (including decimals). e.g.
The syntax for those is '''#(argb,8,8,3)color(R,G,B,A)''', where R,G,B stands for Red, Green, Blue, and A stands for Alpha, all values can be anything between 0 and 1 (including decimals). e.g.
<code>_obj setObjectTexture [0,'#(argb,8,8,3)color(0,1,0,1)']</code>
<sqf>_obj setObjectTexture [0,'#(argb,8,8,3)color(0,1,0,1)']</sqf>
would color myObj in flat green. See [[Procedural Textures]] for more details.
would color myObj in flat green. See [[Procedural Textures]] for more details.
<dd class="notedate">Posted on August 25, 2014 - 22:27 (EST)</dd>
<dd class="notedate">Posted on August 25, 2014 - 22:27 (EST)</dd>
Line 74: Line 74:
<dd class="note">
<dd class="note">
Also works with absolute path and .jpg files.
Also works with absolute path and .jpg files.
<code>_obj setObjectTexture [0, "C:\Folder\Folder\Texture.paa"];
<sqf>_obj setObjectTexture [0, "C:\Folder\Folder\Texture.paa"];
_obj setObjectTexture [0, "C:\Folder\Folder\Texture.jpg"];</code>
_obj setObjectTexture [0, "C:\Folder\Folder\Texture.jpg"];</sqf>
Texture can also be blank:
Texture can also be blank:
<code>_obj setObjectTexture [2,""];</code>
<code>_obj setObjectTexture [2,""];</code>
Line 85: Line 85:
<dd class="note">
<dd class="note">
It is also possible to apply texture to unit's backpack, as it also has hidden selection (unfortunately does not work for vests)
It is also possible to apply texture to unit's backpack, as it also has hidden selection (unfortunately does not work for vests)
<code>(backpackContainer player) setObjectTexture [0,'#(argb,8,8,3)color(0,0,0,1)']</code>
<sqf>(backpackContainer player) setObjectTexture [0,'#(argb,8,8,3)color(0,0,0,1)']</sqf>
Also keep in mind that player's custom texture is being reset when you open BIS Arsenal (even without changing any gear)
Also keep in mind that player's custom texture is being reset when you open BIS Arsenal (even without changing any gear)
</dd>
</dd>
Line 101: Line 101:
<dd class="note">
<dd class="note">
Sometimes it could be necessary to set default material on an object for the texture to take effect:
Sometimes it could be necessary to set default material on an object for the texture to take effect:
<code>_block = createVehicle ["Land_VR_Block_02_F", player getPos [20, getDir player], [], 0, "CAN_COLLIDE"];
<sqf>_block = createVehicle ["Land_VR_Block_02_F", player getPos [20, getDir player], [], 0, "CAN_COLLIDE"];
_block setObjectMaterial [0, "\a3\data_f\default.rvmat"];
_block setObjectMaterial [0, "\a3\data_f\default.rvmat"];
_block setObjectTexture [0, "#(rgb,8,8,3)color(1,0,0,1)"];</code>
_block setObjectTexture [0, "#(rgb,8,8,3)color(1,0,0,1)"];</sqf>
Courtesy of '''[[User:Larrow|Larrow]]'''
Courtesy of '''[[User:Larrow|Larrow]]'''
</dd>
</dd>


</dl>
</dl>

Revision as of 11:57, 13 May 2022

Hover & click on the images for description

Description

Description:
Applies given texture to object's selection. See Retexturing with setObjectTexture for a short tutorial.
  • Not all objects can be textured this way. To find out, run getObjectTextures command on an object. Empty array [] usually indicates it cannot be textured.
  • All textures must have resolution 2^x / 2^y (16x16, 16x32, 64x256, 512x512, ...). The largest texture size commonly supported by graphics cards and RV engine is 4096x4096
  • Supported formats: .pac, .paa, .jpg, .jpeg, .ogg, .ogv
Multiplayer:
See setObjectTextureGlobal
Groups:
Object Manipulation

Syntax

Syntax:
object setObjectTexture [selectionNumber, texture]
Parameters:
object: Object
selectionNumber: Number - Index of the selection. It is defined in the hiddenselection[]={} array in the vehicle's config (starting with 0).
texture: String - Path to texture
Return Value:
Nothing

Examples

Example 1:
_objectname setObjectTexture [0, "\pboname\texture.paa"]; _objectname setObjectTexture [1, "\pboname\texture2.paa"];
Example 2:
_obj setObjectTexture [0, "#(rgb,8,8,3)color(1,0,0,1)"];
Example 3:
_obj setObjectTexture [0, "#(argb,512,512,1)r2t(rendersurface,1.333)"];
Example 4:
When applying custom texture in Editor on vehicles that have randomization enabled (Arma 3 Assets), disable randomization first: this setVariable ["BIS_enableRandomization", false]; this setObjectTexture [0,"#(rgb,8,8,3)color(1,0,0,1)"];

Additional Information

See also:
getObjectTextures setObjectTextureGlobal setObjectMaterial getObjectMaterials setObjectMaterialGlobal forceFlagTexture

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
Posted on December 19, 2009 - 23:16
Lou Montana
Instead of bitmaps, procedural textures can be used.
The syntax for those is #(argb,8,8,3)color(R,G,B,A), where R,G,B stands for Red, Green, Blue, and A stands for Alpha, all values can be anything between 0 and 1 (including decimals). e.g.
_obj setObjectTexture [0,'#(argb,8,8,3)color(0,1,0,1)']
would color myObj in flat green. See Procedural Textures for more details.
Posted on August 25, 2014 - 22:27 (EST)
Benargee
Also works with absolute path and .jpg files.
_obj setObjectTexture [0, "C:\Folder\Folder\Texture.paa"]; _obj setObjectTexture [0, "C:\Folder\Folder\Texture.jpg"];
Texture can also be blank: _obj setObjectTexture [2,""]; This will make the texture selection invisible on certain units without an error message. In some cases this is a desirable effect
Posted on March 18, 2015 - 03:09 (UTC)
Longbow
It is also possible to apply texture to unit's backpack, as it also has hidden selection (unfortunately does not work for vests)
(backpackContainer player) setObjectTexture [0,'#(argb,8,8,3)color(0,0,0,1)']
Also keep in mind that player's custom texture is being reset when you open BIS Arsenal (even without changing any gear)
Posted on May 13, 2015 - 14:37 (UTC)
Moerderhoschi
You can also use the gameinternal skins: List of MH9 Skins _obj setObjectTexture [0, "\a3\air_f\heli_light_01\data\skins\heli_light_01_ext_digital_co.paa"];
Posted on October 24, 2016 - 12:09 (UTC)
Killzone Kid
Sometimes it could be necessary to set default material on an object for the texture to take effect:
_block = createVehicle ["Land_VR_Block_02_F", player getPos [20, getDir player], [], 0, "CAN_COLLIDE"]; _block setObjectMaterial [0, "\a3\data_f\default.rvmat"]; _block setObjectTexture [0, "#(rgb,8,8,3)color(1,0,0,1)"];
Courtesy of Larrow