Quick camo selection definition guide

From Bohemia Interactive Community
Jump to navigation Jump to search

Intention

This guide describes a process to easily create camo selections for models to allow reskinning even for a large amount of assets.

Scope

  1. This is not a beginners guide. Please refer to related information section at the end to learn the basics.
  2. This is not about creating textures.
  3. This is not about explaining tools usage.
  4. This is not explaining config basics.
  5. This does not (yet) include the definition of selections for materials.

What are camo selections

Camo selections are term to describe named selections to be used to apply different textures to a model. This can be done by either means of config or scripting.

Process

Get texture list

Requirement: You need the paid subscriber versions of mikero's tools. Namely dep3d.

DeP3d [-options..] AnyFolder | Anyfile[.p3d] | any list | "comma,separated,list"
Options
...
-FL[nn] list files (see readme)

Sample calls:

DeP3d.exe -P -FL p:\namespace\path\modelName.p3d
DeP3d.exe -P -FL p:\namespace\path\ >> TextureListForPath.txt

Alternatives:

  • Get the textures assigned to the model via ObjectBuilder or some other tool.
  • Use a hex/text editor and search for paa.

Update model

CreateNamedSelectionFromMapping.bat

cd /D "c:\Steam\SteamApps\common\Arma 3 Tools\ObjectBuilder\"

O2Script.exe -a O2Scripts\NamedSelectionCreate.bio2s p:\namespace\path\modelName.p3d selectionName namespace\path\textureName.paa

exit

NamedSelectionCreate.bio2s (create a text file, paste the following content, save as the said filename with bio2s as extension and move to the O2Scripts folder of ObjectBuilder)

#include "std\lodNames.inc"

_createNewSelection =
{
	private ["_obj","_selName","_sel"];

	_obj = _this select 0;
	_selName = _this select 1;
	_sel = _this select 2;

	if (_obj checkSelectionName _selName) then
	{
		//new selection already exists
		//ToDo: handle that if needed
	}
	else
	{
		_obj save _sel as _selName;
	};
};

_getTexOrMatName =
{
	private["_obj","_fi","_isMat"];
	_obj = _this@0;
	_fi = _this@1;
	_isMat = _this@2;

	if(_isMat)then
	{
		getMaterial (_obj face _x)
	}
	else
	{
		getTexture (_obj face _x)
	}
};

_getProxyFaces =
{
	private ["_obj","_faces","_face","_proxySel"];
	_obj = _this;

	_faces = [];
	{
		if (_x @ [0,6]=="proxy:") then
		{
			_proxySel = _obj loadSelection _x;
			_face = (getSelectedFaces _proxySel) @ 0;
			_faces set [count _faces,_face];
		};
	} forEach getSelections _obj;

	_faces
};

_faceIndicesByTexture =
{
	private["_obj","_texName","_texIsMat","_proxyFaces","_faceIndices"];
	_obj = _this@0;
	_texName = _this@1;
	_texIsMat = _this@2;

	_proxyFaces = _obj call _getProxyFaces;

	_faceIndices = [];
	_obj forEachFace [{[_obj,_x,_texIsMat] call _getTexOrMatName == _texName},
	{
		if(!(_x in _proxyFaces))then
		{
			_faceIndices set [count _faceIndices,_x];
		};
	}];

	_faceIndices
};

_selectByFaceIndices =
{
	private ["_obj","_faceIndices","_sel"];
	_obj = _this@0;
	_facesIndices = _this@1;

	_sel = newSelection _obj;
	_sel selectFaces _facesIndices;
	selectPointsFromFaces _sel
};

_selectionByTexture =
{
	private["_obj","_texName","_texIsMat","_faceIndices"];
	_obj = _this@0;
	_texName = _this@1;
	_texIsMat = _this@2;

	_faceIndices = [_obj,_texName,_texIsMat] call _faceIndicesByTexture;
	[_obj,_faceIndices] call _selectByFaceIndices
};

_createNewSelectionByTexture =
{
	private["_obj","_selName","_texName","_texIsMat","_sel"];

	_obj = _this select 0;
	_selName = _this select 1;
	_texName = _this select 2;
	_texIsMat = _this select 3;

	_sel = [_obj,_texName,_texIsMat] call _selectionByTexture;
	[_obj,_selName,_sel] call _createNewSelection;
};

_sourcePath = this@0;
_targetPath = _sourcePath;

if ((count this) == 2) then {_targetPath = this@1;};

_selectionName = this@1;
_textureName = this@2;

_p3d = newLODObject;
_p3d loadP3D _sourcePath;

_LODs = getObjects _p3d;
_resolutions = getResolutions _p3d;

console=openStandardIO;
console<<"_sourcePath: "<<_sourcePath<<eoln;
console<<"_selectionName: "<<_selectionName<<eoln;
console<<"_textureName: "<<_textureName<<eoln;

for "_i" from 0 to (count _p3d-1) do
{
	_currentLOD = _LODs @ _i;
	_currentResolution = _resolutions @ _i;

	if (IS_LOD_RESOLUTION(_currentResolution)) then
	{
		[_currentLOD,_selectionName,_textureName,false] call _createNewSelectionByTexture;
	};
};

save (_p3d as _targetPath);

Model.cfg

See also: ArmA: Howto Model Config - CfgModels explanations - sections

Config

See also: CfgVehicles_Config_Reference#hiddenSelections

IMPORTANT: Define the correct loading order via requiredAddons in the cfgPatches header to make sure your definition overwrites potential other definitions.

Create named selections overview

If a model already has named selections defined, you can use this batch script to list them/log them to file.

ListNamedSelectionsMapping.bat

// Adjust path
cd /D "c:\Steam\SteamApps\common\Arma 3 Tools\ObjectBuilder\"

O2Script.exe -a O2Scripts\NamedSelectionsOverview.bio2s p:\namespace\path\modelName.p3d >> NamedSelectionsOverview.txt

exit

Sample output:

_sourcePath: p:\namespace\path\modelName.p3d
_currentResolution: 1
_selectionName: name1
_textures: namespace\path\textureName4711.paa
_selectionName: name2
_textures: namespace\path\textureName4712.paa
...

NamedSelectionsOverview.bio2s (create a text file, paste the following content, save as the said filename with bio2s as extension and move to the O2Scripts folder of ObjectBuilder)

#include "std\lodNames.inc"

_createOverviewForCurrentLOD =
{
	private["_object"];

	_object = _this select 0;

	{
		private["_selectionName","_textures","_selection","_selectedFaces"];
		_selectionName = _x;

		_textures = [];
		_selection = _object loadSelection _selectionName;
		_selectedFaces = getSelectedFaces _selection;

		{
			private["_face","_texture"];
			_face = _x;

			_texture = getTexture (_object face _face);
			if (!(_texture in _textures)) then
			{

				_textures set [count _textures,_texture];
			};
		} forEach _selectedFaces;

		console<<"_selectionName: "<<_selectionName<<eoln;

		{
			private["_texture"];
			_texture = _x;
			if (_texture != "") then
			{
				console<<"_textures: "<<_texture<<eoln;
			};
		} forEach _textures;
	} forEach (getSelections _object);
};

_sourcePath = this@0;

_p3d = newLODObject;
_p3d loadP3D _sourcePath;

_LODs = getObjects _p3d;
_resolutions = getResolutions _p3d;

console=openStandardIO;

for "_i" from 0 to ((count _p3d) - 1) do
{
	_currentLOD = _LODs @ _i;
	_currentResolution = _resolutions @ _i;

	if (IS_LOD_RESOLUTION(_currentResolution)) then
	{
		console<<"_currentResolution: "<<str _currentResolution<<eoln;

		[_currentLOD] call _createOverviewForCurrentLOD;
	};
};

Related information

Videos

Text