Filetexturebase¶
This module is the base class for filepath texture map creation. Color grading may be added later.
This class is intended to be extended/overridden by each renderer or file texture type. Provides base functionality.
A texture node network will have these values
Texture file path
Color Space
Output Connection
2d texture properties
repeat UV
Offset UV
Rotate UV
Scale 3d (triplanar and 3d placement)
A texture can be stacked into a layer texture and mixed. (later)
See subClasses for use. For example mayafiletexture.py
- class FileTextureBase(masterNode=None, masterAttribute='', textureName='', textureNode=None, genAttrDict=None, scalar=False, autoCreate=True, create=False, ingest=False, message=True)¶
Bases:
object
Main class that manages a single filepath texture node network
- outputAttr = ''¶
- initName(textureName)¶
Builds the name of the node network if given or will use the default name sets self.textureNameVal
- connectedAttr()¶
Returns the opposite attribute connected to the masterNode.masterAttribute
- Return oppositeAttr:
the name of the connected attribute ie “outColor” will be empty string if none “”
- Rtype oppositeAttr:
str
- valid()¶
Checks if the main texture node exists, can be overridden for more checks
- Return valid:
True if the setup is valid
- Rtype valid:
bool
- exists()¶
Returns if the main texture node exists in the scene
- Return exists:
True if the texture node exists False if not
- Rtype exists:
bool
- ingest()¶
Should be overridden as will depend on the file texture type
- create(genAttrDict=None)¶
Should be overridden and then call to self.setFromDictSafe(genAttrDict)
- delete()¶
Should be overridden as will depend on the file texture type
- setFromDict(genAttrDict, apply=False)¶
Sets the normal network from the generic attribute (any renderer) dictionary.
See DEFAULT_VALUES for an example of a genAttrDict
- Parameters:
genAttrDict (dict) – A dictionary of values that can be applied to the texture network see DEFAULT_VALUES
apply – Apply the values to the node network after setting the class variables
- applyCurrentSettings()¶
Applies the current settings to the normal map’s texture network
- renderer()¶
Returns the current renderer as a string.
Should be overridden.
- Return renderer:
“Arnold”, “Maya” “Redshift” etc.
- Rtype renderer:
str
- textureType()¶
Returns the current texture type as a string.
Should be overridden.
- Return textureType:
The texture node type for example “file” (default maya fileTexture type)
- Rtype renderer:
str
- setName(name)¶
- name()¶
- setPath(path)¶
- path()¶
- setColorSpace(colorSpace)¶
- colorSpace()¶
- setPlaceType(placeType)¶
- placeType()¶
- setRepeatUV(repeatUV)¶
- repeatUV()¶
- setOffsetUV(offsetUV)¶
- offsetUV()¶
- setRotateUV(offsetUV)¶
- rotateUV()¶
- setScale3d(scale3d)¶
- scale3d()¶
Mayafiletexture¶
This module is the class for the default Maya texture “file” and “place2dTexture” nodes.
Color grading may be added later.
A texture node network can be modified with these values:
Texture file path
Color Space
Output Connection
2d texture properties
repeat UV
Offset UV
Rotate UV
Scale 3d (triplanar and 3d placement)
A texture can be stacked into a layer texture and mixed. (later)
Example use, building a texture on a shader “lambert”, attribute “color”
from zoo.libs.maya.cmds.textures.filetexturetypes import mayafiletexture
from zoo.libs.maya import zapi
shaderNode = zapi.nodeByName("lambert2")
# autoload or create a texture network at "lambert2.color"
txtrInst = mayafiletexture.MayaFileTexture(masterAttribute="color", masterNode=shaderNode,
textureName="colorTexture",
autoCreate=True, create=False, ingest=False)
txtrInst.setName("newColorTexture") # sets a new name of the texture network
txtrInst.setPath("c:/aPath/toMy/texture.jpg") # set the file texture path
txtrInst.setColorSpace("sRGB") # sets the incoming texture space
txtrInst.setRepeatUV((2.0, 2.0)) # sets the repeating texture U and V values.
txtrInst.rotateUV(45.0) # rotates the texture by 45 degrees
- class MayaFileTexture(masterNode=None, masterAttribute='', textureName='', textureNode=None, genAttrDict=None, scalar=False, autoCreate=True, create=False, ingest=False, message=True)¶
Bases:
FileTextureBase
Main class that manages a single filepath texture node network
- inputAttr = 'color'¶
- outputAttr = 'outColor'¶
- outputScalarAttr = 'outAlpha'¶
- textureNodeType = 'file'¶
- valid()¶
Checks if the two texture node exist:
self.textureNode self.place2dNode
- Return valid:
True if the setup is valid
- Rtype valid:
bool
- exists()¶
Returns if the main texture node exists in the scene
- Return exists:
True if the texture node exists False if not
- Rtype exists:
bool
- ingest()¶
Tries to ingest the file texture network of two nodes.
This method will check in order:
If self.masterNode and self.masterAttr are given: Will try to ingest from their connection If self.textureNode is given as a zapi node: Tries to ingest the place2dNode too If self.textureName is given as a string name: Ingests self.textureNode and self.place2dNode
If successful will register two zapi nodes:
self.textureNode self.place2dNode
- Return success:
Returns True if the file texture network was successfully ingested.
- Rtype success:
bool
- create(genAttrDict=None)¶
- Creates and potentially connects the texture node network and assigns the dict or default values if None:
self.textureNode = Main texture node “file” type
self.place2dNode = Place texture node “place2dTexture” type
- Connects the texture to:
self.masterNode (zapi node)
self.masterAttribute (str)
- Parameters:
genAttrDict (dict) – A dictionary of values that can be applied to the texture network see base.DEFAULT_VALUES
- delete()¶
Deletes the entire texture network, deletes all nodes
- renderer()¶
Returns the current renderer as a string.
Should be overridden.
- Return renderer:
“Arnold”, “Maya” “Redshift” etc.
- Rtype renderer:
str
- setName(name)¶
Renames the node network to the new name.
- Parameters:
name (str) – The new name of the texture network
- Return newName:
New name of the texture node
- Rtype newName:
str
- Return newPlace2dName:
New name of the texture node
- Rtype newPlace2dName:
str
- rename(name)¶
Documentation see self.setName()
- name()¶
Returns the name of the main texture node or “” if it doesn’t exist.
- Return name:
The name of the main texture node, or “” if it doesn’t exist
- Rtype name:
str
- setPath(path)¶
Sets the path of the texture image
- Parameters:
path (str) – The path on disk to the texture image
- path()¶
Gets the path on disk of the texture image
- Return path:
The path on disk to the texture image can be “” if nothing set
- Rtype path:
str
- setColorSpace(colorSpace)¶
Sets the color space of the main texture node as a string, must match Maya’s color space strings.
eg “sRGB”
- Parameters:
colorSpace (str) – The color space of the node, must match Maya’s color space strings.
- colorSpace()¶
Gets the color space of the main texture node as a string
eg “sRGB”
- Return colorSpace:
The color space of the main texture node as a string
- Rtype colorSpace:
str
- setPlaceType(placeType)¶
- placeType()¶
- setRepeatUV(repeatUV)¶
- repeatUV()¶
- setOffsetUV(offsetUV)¶
- offsetUV()¶
- setRotateUV(offsetUV)¶
- rotateUV()¶
- setScale3d(scale3d)¶
- scale3d()¶