sbsbakingparameters module

Module sbsbakingparameters aims to provide useful functions to read and modify the baking parameters of a Scene resource.
The baking parameters are saved as an encoded string in the .sbs file, this is why a specific module is required for them.
class pysbs.sbsbakers.sbsbakingparameters.BakingParameters(aBakers=None, aSubMeshColors=None, aSubMeshSelections=None)

Bases: object

Class that contains information on the Baking Parameters of a Scene resource

Members:
addBaker(aIdentifier)

Add a BakingConverter of the given kind

Parameters:

aIdentifier (BakerEnum) – Identifier of the converter to create

Returns:

The created BakingConverter object

Raise:

SBSImpossibleActionError

addHighDefinitionMeshFromFile(aAbsFilePath)

Add the given absolute path to the list of High Definition Meshes for a ‘From Mesh’ converter. This modifies the parameter MESH__HIGH_DEF_MESHES of this converter.

Parameters:

aAbsFilePath (str) – The absolute path to the resource

Returns:

True if success, False otherwise

Raise:

SBSImpossibleActionError

addHighDefinitionMeshFromResource(aResource)

Add the given resource in the list of High Definition Meshes for a ‘From Mesh’ converter. The resource must be already included in the package. This modifies the parameter MESH__HIGH_DEF_MESHES of this converter.

Parameters:

aResource (SBSResource) – The resource to reference

Returns:

True if success, False otherwise

Raise:

SBSImpossibleActionError

computeUniqueIdentifier(aIdentifier, aSuffixId=0)

Check if the given identifier is already used and generate a unique identifier if necessary

Parameters:
  • aIdentifier (str) – Identifier to check

  • aSuffixId (int) – Suffix ID

Returns:

A unique identifier, which is either the given one or a new one with a suffix: identifier [id]

fromSBSTree(aSBSTree)

Get the content of the given SBSTree to set the Baking Parameters

Parameters:

aSBSTree (SBSTree) – The tree of options ot baking parameters from

Returns:

True if success

getBaker(aBaker)

Get the BakingConverter object with the given identifier (ex: ‘Ambient Occlusion’)

Parameters:

aBaker (BakerEnum or str) – Identifier of the baker

Returns:

The BakingConverter with this identifier if found, None otherwise

getNbBakers()

Get the number of BakingConverter defined

Returns:

The number of BakingConverter as an integer

getParameter(aParameter)

Get the global parameter with the given identifier

Parameters:

aParameter (ConverterParamEnum or str) – Identifier of the parameter to get

Returns:

The parameter as a QtVariant if found, None otherwise

getParameterValue(aParameter)

Get the value of the parameter with the given identifier

Parameters:

aParameter (ConverterParamEnum or str) – Identifier of the parameter to get

Returns:

The parameter value in the type of the parameter if found, None otherwise

getSubMeshColor(aEntityId, aSubMeshId)

Get the SubMeshColor corresponding to the given (entityId, subMeshId)

Returns:

The SubMeshColor object if found, None otherwise

getSubMeshColorHexa(aEntityId, aSubMeshId)

Get the hexadecimal color of the SubMeshColor corresponding to the given (entityId, subMeshId)

Parameters:
  • aEntityId (int) – Index of the entity that contains the submesh (start to 1)

  • aSubMeshId (int) – Index of the submesh part (start to 0)

Returns:

The hexadecimal color as a string if it exists, None otherwise

getSubMeshSelection(aEntityId, aSubMeshId)

Get the SubMeshSelection corresponding to the given (entityId, subMeshId)

Returns:

The SubMeshSelection object if found, None otherwise

isSubMeshSelected(aEntityId, aSubMeshId)

Check if the given (entityId, subMeshId) is selected

Parameters:
  • aEntityId (int) – Index of the entity that contains the submesh (start to 1)

  • aSubMeshId (int) – Index of the submesh part (start to 0)

Returns:

True if the given submesh index is selected, False otherwise

moveDownBaker(aBaker)

Move down the given baker in the bakers list

Parameters:

aBaker (BakingConverter or BakerEnum or str) – Baker to move down in the bakers list

Raise:

SBSImpossibleActionError

moveUpBaker(aBaker)

Move up the given baker in the bakers list

Parameters:

aBaker (BakingConverter or BakerEnum or str) – Baker to move up in the bakers list

Raise:

SBSImpossibleActionError

removeBaker(aBaker)

Remove the given baker

Parameters:

aBaker (BakingConverter or BakerEnum or str) – Baker to remove, as an object or an identifier

Returns:

True if success, False otherwise

Raise:

SBSImpossibleActionError

selectBaker(aBaker, aSelected=True)

Select the given baker

Parameters:
  • aBaker (BakingConverter or BakerEnum or str) – Baker to select, as an object or an identifier

  • aSelected (bool) – True to select the baker, False to deselect it

Raise:

SBSImpossibleActionError

setFileParameterValueFromPath(aParameter, aAbsPath)

Set the file path value of the given parameter as the relative path of the given resource. Only parameters ‘MESH__CAGE_FILE’, ‘MESH__SKEW_MAP’, ‘NORMAL_MAP’, ‘TEXTURE_FILE’, ‘DIRECTION_FILE’ can be set by this function. An exception will be raised if the parameter is not appropriate.

Parameters:
  • aParameter (ConverterParamEnum or str) – Identifier of the parameter to set

  • aAbsPath (str) – The absolute path to the file resource

Returns:

True if success, False otherwise

Raise:

SBSImpossibleActionError

setFileParameterValueFromResource(aParameter, aResource)

Set the file path value of the given parameter as the relative path of the given resource. Only parameters ‘MESH__CAGE_FILE’, ‘NORMAL_MAP’, ‘TEXTURE_FILE’, ‘DIRECTION_FILE’ can be set by this function. An exception will be raised if the resource is invalid or if the parameter is not appropriate.

Parameters:
Returns:

True if success, False otherwise

Raise:

SBSImpossibleActionError

setParameterValue(aParameter, aParamValue)

Set the value of the given global parameter

Parameters:
  • aParameter (BakingGlobalParam) – The parameter to set

  • aParamValue (any type) – The value to set

Raise:

SBSImpossibleActionError

setSubMeshColorHexa(aEntityId, aSubMeshId, aColor)

Set the given color to the SubMesh part of the given Id

Parameters:
  • aEntityId (int) – Index of the entity that contains the submesh (start to 1)

  • aSubMeshId (int) – Index of the submesh part (start to 0)

  • aColor (str) – The hexadecimal color

Returns:

Nothing

Raise:

SBSImpossibleActionError

setSubMeshSelection(aEntityId, aSubMeshId, aSelected)

Set the given color to the SubMesh part of the given Id

Parameters:
  • aEntityId (int) – Index of the entity that contains the submesh (start to 1)

  • aSubMeshId (int) – Index of the submesh part (start to 0)

  • aSelected (bool) – True to select the SubMesh part, False to deselect it

toSBSOptionList()

Convert the object structure of the BakingParameters into a tree of SBSOptions, as it is saved in the .sbs file

Returns:

A list of SBSOptions object with the content of the BakingParameters