This article relates to the game "Dota 2". Click here for more information.
This article relates to the workshop tools for "Dota 2". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

Attachments

From Valve Developer Community
Jump to: navigation, search
简体中文

Attachments are parented to a joints, and are defined by an offset and a rotation. In game they can be used for particle emission, and item attachment points among other uses. Attachments are stored in an attachment list, and can have multiple parents (influences).

Display

  • To toggle attachment display go Display > Attachments.
  • To toggle attachment name display go to Display >Attachment Names.

Create

  • Right click on a joint item in the outliner, and select Add Attachment.
  • Use the Model > Attachments menu items.

Edit

  • When an attachment is selected via the viewport or an outliner item the gizmo becomes available. Use the gizmo to translate and rotate the attachment.
  • When selected the editable properties of an attachment are accessible via the property editor.

Data Structures

The vmdl attachment data looks like this:

CVattachmentListReference[] m_pAttachmentLists = 
[
	CVattachmentListReference
	{
		CVattachmentList* m_pObject = &CVattachmentList_0
		string m_sFileName = ""
	}
]

m_pAttachmentLists

A list of CVattachmentListReference elements

CVattachmentListReference

A reference to an internal or external CVattachmentList:

Attribute Friendly Name Description Type Default Value
m_pObject pointer to the internal CVattachmentList CVattachmentList*
m_sFileName content relative path to the external CVattachmentList string

A CVattachmentList set list looks like this:

CVattachmentList CVattachmentList_0
{
	string m_name = ""
	CVattachment[] m_attachments = 
	[
		CVattachment
		{
			string m_name = "test"
			CVattachmentInfluence[] m_influences = 
			[
				CVattachmentInfluence
				{
					string m_influenceName = "spine1"
					float(3) m_vTranslationOffset = ( 0.000000, 0.000000, 0.000000 )
					float(3) m_vRotationOffset = ( 0.000000, 0.000000, 0.000000 )
					float m_flWeight = 1.000000
					bool m_bRoot = false
				}
			]
		}
	]
}

CVattachmentList

Attribute Friendly Name Description Type Default Value
m_name Name The name of the attachment list string
m_attachments Attachments List of CVattachment elements CVattachment[]
Note:When it is made external, a CVattachmentList is saved as a ".attach" file.

CVattachment

The data description of the attachment

Attribute Friendly Name Description Type Default Value
m_name Name The name of the attachment list string
m_influences Influences List of CVattachmentInfluence elements CVattachmentInfluence[]

CVattachmentInfluence

The data description of the influence

Attribute Friendly Name Description Type Default Value
m_influenceName Influence Name The name of the influence string
m_vTranslationOffset Translation Translation offset from the influnce float(3) ( 0.000000, 0.000000, 0.000000 )
m_vRotationOffset Rotation Rotation offset from the influnce float(3) ( 0.000000, 0.000000, 0.000000 )
m_flWeight Weight Weight of the influence float 1.0
m_bRoot Is Root Is the root of the model bool true
Note:Changing the influence weight only matters if there are more than one influence.
Tip:Use "Is Root" when adding an attachment to a model that has not joints.