Astra Unity 2.6.6
Astra Unity Plugin
Astra.Asset.MorphableItem Class Reference

Morphables are items which contain data to allow a scaled change to a rig or mesh that they are attached to (including the character skin mesh). They range from basic things like adjusting an ear shape to something that alters the entire appearance of the AvatarItem, such as a zombie transformation. This class provides the ability to adjust the morphable. Typically, you adjust a MorphableItem using the AvatarItem.MorphableManager.DriveMorph function, which cascades the changes appropriately to other items attached to the AvatarItem. More...

Inheritance diagram for Astra.Asset.MorphableItem:

Classes

class  InjectJob
 Creates sub components to various other game objects for controlling blendshapes, bones, and decals More...
 
class  MuscleRange
 Values to adjust the mechanim default muscle parameters More...
 

Public Member Functions

bool PairedMeshExists (MeshItem[] meshItems=null, AvatarItem ai=null)
 Whether the paired mesh id is attached to this AvatarItem More...
 
bool PairedTagExists ()
 Whether there is an item that this Morphable is paired with currently attached to the AvatarItem
 
void SetProjectionDirty ()
 Indicates that we need to project again
 
void Freeze ()
 When frozen, ensures we don't keep syncing this morphable
 
void Thaw ()
 Allows the morphable to be synced again
 
ApiJobNoResult Remove (bool syncRig=true, bool destroy=false, int parentJobId=Job.kNoParentJobId)
 Provides the cleanest and fastest way to remove the morph More...
 
ApiJobNoResult RefreshComponents (int parentJobId=Job.kNoParentJobId)
 Call this anytime anything changes regarding the node structure of the gameObject This rescans for things like MeshItems, so there is a cost here Do not call this to update the values, call this only for hierarchy changes, use Sync instead More...
 
ApiJobNoResult Sync (bool refresh=false, int parentJobId=Job.kNoParentJobId)
 Updates the values for blendshapes and bones Only updates if it's marked as dirty or forced More...
 
InjectJob Inject (int parentJobId=Job.kNoParentJobId)
 Drives other components on this AvatarItem with this MorphableItem such as blendshapes, bones, and decals More...
 
- Public Member Functions inherited from Astra.Asset.ItemBase
virtual CompoundItem FindParentCompound ()
 Find the parent CompoundItem which this Item is attached to, if it exists, otherwise null
 
virtual AvatarItem FindAvatarItem ()
 Returns the AvatarItem this item is attached to (if found, note may return null)
 
virtual RigItem FindRigItem ()
 Finds the current RigItem associated on this Avatar Hierarchy More...
 

Public Attributes

MorphableItemData SourceData
 A copy of the "Source" data in unity format, this is basically a PrimitiveMorphable but in a nice serializable native format
 
SerializableDictionarySMorphableItemChildData ChildData = new SerializableDictionarySMorphableItemChildData()
 Tracks our morph datas keyed on guid of mesh item and value is the source or projected morph data
 
string SourceMeshId
 This is the origin mesh id for which the base morph was created for, this is almost always the figure mesh id
 
string SourceMaskId = null
 If not null will use a mask when doing projection, this is typically used for things like preventing ears from affecting projection
 
string PairedMeshId
 If this is a "mesh to mesh" morphable this pairing will be the other mesh that triggers this one to happen eg: if you have a hat and hair and the hat trips a distortion of the hair, this morph will be on the hair and the hat's mesh id will be this value
 
SerializableDictionarySMeshItem meshItems = new SerializableDictionarySMeshItem()
 Tracks out mesh items we want to listen to, key is the guid of the meshItem
 
SerializableDictionarySI blendshapeIndexes = new SerializableDictionarySI()
 key is the mesh guid, value is the blendshape slot
 
SerializableDictionarySDecalItem decalItems = new SerializableDictionarySDecalItem()
 tracks our decals, the key is the guid of the MeshItem.AstraGuid
 
MuscleRange[] muscleRanges
 Custom muscle value overrides for this Morphable
 
RigTarget rigTarget
 Where should the bones be when driven to 100%
 
bool ignoreEyeProjection = false
 If true, means that when we go to project this morph we should
 
bool ignoreMouthPartProjection = false
 If true, this morph won't affect PartItems like teeth, tongue, etc
 
bool ignoreIndirectProjection = false
 If true, this morph won't affect any non-direct children, ie: FigureItem morph would apply to eyes, mouth, etc but not clothing
 
bool ignoreAllProjection = false
 If true, this morph won't affect any child meshes, it will only apply it's own MeshTarget (if set)
 
float projectionWeight = 1.0f
 When driving the projection blendshapes to dependent meshes this is the multipler used to feather the projected blendshape
 
List< string > CategoriesRegions = new List<string>()
 List of region tags attached to this morphable
 
bool IsRigCoupled = true
 If we drive a blendshape and we have bone translations, will the blendshape move even w/o the bones being moved (this is on by default)
 
bool HasRigTargets = false
 if true, this morphable moves bones
 
bool HasMeshTargets = false
 if true, this morphable moves vertices of the mesh target
 
bool HasMaterialTargets = false
 if true, this morphable has materials that get blended onto the target using decals
 
bool InjectedMeshTargets = false
 true if the morph has been installed into the smr
 
bool InjectedRig = false
 true if the RigItem has been fused with the MorphableItem
 
bool DriveVertices = true
 If true when injecting a blendshape the vertices data will be used
 
bool DriveNormals = true
 If true when injecting a blendshape the normals data will be used
 
bool DriveTangents = false
 If true when injecting a blendshape the tangents data will be used
 
bool allowProjection = true
 Set to false to disable any projection
 
bool Refresh = false
 Do we want to force a recalculation of projection data on the next frame?
 

Protected Member Functions

void Discover ()
 Finds all child nodes that match various targets (eg: MeshItem) and binds them to this MorphableItem.
 
void SyncBlendshapes ()
 
ApiJobNoResult SyncRig (RigItem.ImmediateSyncCallback callback=null, int parentJobId=Job.kNoParentJobId)
 
void SyncDecal (bool refresh=false)
 
bool NeedsInjection ()
 Let's us know if we need to inject a RigTarget, MeshTarget, or MaterialTarget More...
 
bool? InjectJobFunc (Job job)
 
bool NeedsProjection ()
 
int GetProjectionKey (string morphId, string sourceMeshId, string targetMeshId, string sourceMaskId)
 
Job Project (int parentJobId=Job.kNoParentJobId)
 Projects source mesh against ALL target meshes NOTE: There is both local cache in C#/Unity and C++ for these projections, see GetProjectionKey / _projected More...
 
void InjectBlendshapes ()
 Pushes the blendshape into all mesh items under this object This assumes you already have all morph data in the containers variable. This will block the thread while it performs this function.
 
void InjectRig ()
 
void InjectDecal ()
 Finds or Adds a DecalItem for this MorphableItem if necessary, only applies one if we have at least one MaterialTarget
 
- Protected Member Functions inherited from Astra.Asset.ItemBase
void TrackId (string id)
 
void UntrackIds ()
 

Protected Attributes

AvatarItem _avatarItem
 
System.Object _lock = new System.Object()
 
bool _dirty = false
 
bool _meshItemsDirty = false
 
bool _projectionDirty = false
 
float _value = 0f
 
float _savedValue = -1f
 
bool _removed = false
 
HashSet< int > _projected = new HashSet<int>()
 
- Protected Attributes inherited from Astra.Asset.ItemBase
List< string > _trackingIds = null
 

Properties

override McsSdk20.Primitives.AstraPrimitiveType PrimitiveType [get]
 
override McsSdk20.Primitives.SchematicType SchematicType [get]
 
bool IsPairedMorphable [get]
 Whether there is a Paired mesh id.
 
bool IsPairedTagMorphable [get]
 Whether this morphable is tagged to have attached items via the mesh to tag system
 
bool InjectedDecals [get]
 true if a DecalItem has been added for this morph
 
float Value [getset]
 Range 0->100, 0 being 0% and 100 being 100%, TODO: normalize to 0->1
 
- Properties inherited from Astra.Asset.ItemBase
virtual McsSdk20.Primitives.AstraPrimitiveType PrimitiveType [get]
 Retrieve the primitive type for this item
 
virtual McsSdk20.Primitives.SchematicType SchematicType [get]
 Retrieve the schematic type for this item
 
string AstraGuid [getset]
 Guid for this item to identify it in the Astra Service
 
string AstraName [getset]
 Display name for this item
 
string AstraInstanceId [getset]
 Guid representing an instance of this item
 
- Properties inherited from Astra.Asset.IAstraBaseInterface
string AstraGuid [getset]
 
string AstraName [getset]
 
string AstraInstanceId [getset]
 

Detailed Description

Morphables are items which contain data to allow a scaled change to a rig or mesh that they are attached to (including the character skin mesh). They range from basic things like adjusting an ear shape to something that alters the entire appearance of the AvatarItem, such as a zombie transformation. This class provides the ability to adjust the morphable. Typically, you adjust a MorphableItem using the AvatarItem.MorphableManager.DriveMorph function, which cascades the changes appropriately to other items attached to the AvatarItem.

Member Function Documentation

◆ Inject()

InjectJob Astra.Asset.MorphableItem.Inject ( int  parentJobId = Job.kNoParentJobId)
inline

Drives other components on this AvatarItem with this MorphableItem such as blendshapes, bones, and decals

Parameters
parentJobIdJob that triggered this job for debugging purposes. Optional.
Returns

◆ NeedsInjection()

bool Astra.Asset.MorphableItem.NeedsInjection ( )
inlineprotected

Let's us know if we need to inject a RigTarget, MeshTarget, or MaterialTarget

Returns
True if we do, false otherwise

◆ NeedsProjection()

bool Astra.Asset.MorphableItem.NeedsProjection ( )
inlineprotected

Tells us if any of the tracked meshes needs to be projected

Returns
True if a meshItem is missing morph data and it needs to be calculated or fetched

◆ PairedMeshExists()

bool Astra.Asset.MorphableItem.PairedMeshExists ( MeshItem[]  meshItems = null,
AvatarItem  ai = null 
)
inline

Whether the paired mesh id is attached to this AvatarItem

Parameters
meshItemsOptional list of MeshItems to search for the paired mesh. If not used, uses the AvatarItem's MeshItems
aiOptional AvatarItem to search. If null, uses the AvatarItem this MorphableItem is attached to

◆ Project()

Job Astra.Asset.MorphableItem.Project ( int  parentJobId = Job.kNoParentJobId)
inlineprotected

Projects source mesh against ALL target meshes NOTE: There is both local cache in C#/Unity and C++ for these projections, see GetProjectionKey / _projected

Parameters
parentJobId
Returns
The job you can wait on until all data has been calculated

◆ RefreshComponents()

ApiJobNoResult Astra.Asset.MorphableItem.RefreshComponents ( int  parentJobId = Job.kNoParentJobId)
inline

Call this anytime anything changes regarding the node structure of the gameObject This rescans for things like MeshItems, so there is a cost here Do not call this to update the values, call this only for hierarchy changes, use Sync instead

Parameters
parentJobIdJob that triggered this job for debugging purposes. Optional.
Returns

◆ Remove()

ApiJobNoResult Astra.Asset.MorphableItem.Remove ( bool  syncRig = true,
bool  destroy = false,
int  parentJobId = Job.kNoParentJobId 
)
inline

Provides the cleanest and fastest way to remove the morph

Parameters
syncRigWhether the rig should be synced as part of this operation
destroyWhether the Morphable should be destroyed as part of this operation
parentJobIdId of the parent job, if it applies. Optional.

◆ Sync()

ApiJobNoResult Astra.Asset.MorphableItem.Sync ( bool  refresh = false,
int  parentJobId = Job.kNoParentJobId 
)
inline

Updates the values for blendshapes and bones Only updates if it's marked as dirty or forced

Parameters
refreshSet to true to force a sync
parentJobIdJob that triggered this job for debugging purposes. Optional.

◆ SyncBlendshapes()

void Astra.Asset.MorphableItem.SyncBlendshapes ( )
inlineprotected

Makes sure the blendshape has the right value

◆ SyncDecal()

void Astra.Asset.MorphableItem.SyncDecal ( bool  refresh = false)
inlineprotected

Keeps the decal value synced with the morph if there is one

◆ SyncRig()

ApiJobNoResult Astra.Asset.MorphableItem.SyncRig ( RigItem.ImmediateSyncCallback  callback = null,
int  parentJobId = Job.kNoParentJobId 
)
inlineprotected

Updates the rig bones so they match the morphs


The documentation for this class was generated from the following file: