Api Sandbox Model
class

Model

public sealed class Model : Resource

A model.

Properties

Name Type Description
AnimationCount Int32 Number of animations this model has.
AnimationNames IReadOnlyList<String>
AnimGraph AnimationGraph Get the animgraph this model uses.
Attachments ModelAttachments Access to bones of this model.
AttachmentCount Int32 Returns amount of attachment points this model has.
Parts ModelParts Access to body parts of this model.
BodyGroupCount Int32
DefaultBodyGroupMask UInt64
BodyParts IEnumerable<BodyPart>
Bounds BBox Total bounds of all the meshes.
PhysicsBounds BBox Total bounds of all the physics shapes.
RenderBounds BBox Render view bounds.
IsValid virtual Boolean
IsError Boolean Whether this model is an error model or invalid or not.
Name String Name of the model, usually being its file path.
IsProcedural Boolean Whether this model is procedural, i.e. it was created at runtime via Create.
MeshCount Int32 Total number of meshes this model is made out of.
Trace MeshTraceRequest Trace against the triangles in this mesh
Data CommonData
HitboxSet HitboxSet Access to default hitbox set of this model
MaterialGroupCount Int32 Number of material groups this model has.
Materials ImmutableArray<Material> Retrieves an enumerable collection of all Materials on the meshes. This is fast, and cached. The order of these items is the same order used in ModelRenderer.Materials etc
Morphs ModelMorphs Access to bones of this model.
MorphCount Int32 Number of morph controllers this model has.
Physics PhysicsGroupDescription
Bones BoneCollection Access to bones of this model.
BoneCount Int32 Number of bones this model has.
Builder static ModelBuilder Returns a static ModelBuilder instance, allowing for runtime model creation.
Cube static Model A cube model
Sphere static Model A sphere model
Plane static Model A plane model
Error static Model An error model

Methods

String GetAnimationName(Int32 animationIndex)

Returns name of an animation at given animation index.

animationIndex — Animation index to get name of, starting at 0.
returns — Name of the animation.
ArgumentOutOfRangeException — Thrown when given index exceeds range of [0,AnimationCount-1]
Transform? GetAttachment(String name)

Retrieves attachment transform based on given attachment name.

name — Name of the attachment to retrieve transform of.
returns — The attachment transform, or null if attachment by given name is not found.
Transform? GetAttachment(Int32 index)

Retrieves attachment transform based on given attachment index.

index — &gt;Index of the attachment to look up, starting at 0.
returns — The attachment transform.
ArgumentOutOfRangeException — Thrown when given index exceeds range of [0,AttachmentCount-1]
String GetAttachmentName(Int32 index)

Returns name of an attachment at given index.

index — Index of the attachment to look up, starting at 0.
returns — The name of the attachment at given index.
ArgumentOutOfRangeException — Thrown when given index exceeds range of [0,AttachmentCount-1]
Boolean TryGetData(T data)

Tries to extract data from model based on the given type's ModelDoc.GameDataAttribute.

data — The extracted data, or default on failure.
returns — true if data was extracted successfully, false otherwise.
Boolean TryGetData(Type t, Object data)

Tries to extract data from model based on the given type's ModelDoc.GameDataAttribute.

t — The class with ModelDoc.GameDataAttribute.
data — The extracted data, or default on failure.
returns — true if data was extracted successfully, false otherwise.
Boolean HasData()

Tests if this model has generic data based on given type's ModelDoc.GameDataAttribute. This will be faster than testing this via GetData]]>()

T GetData()

Extracts data from model based on the given type's ModelDoc.GameDataAttribute.

Dictionary<String, String[]> GetBreakCommands()

Internal function used to get a list of break commands the model has.

static Model Load(String filename)

Load a model by file path.

filename — The file path to load as a model.
returns — The loaded model, or null
static Task<Model> LoadAsync(String filename)

Load a model by file path.

filename — The file path to load as a model.
returns — The loaded model, or null
String GetMaterialGroupName(Int32 groupIndex)

Returns name of a material group at given group index.

groupIndex — Group index to get name of, starting at 0.
returns — Name of the group.
ArgumentOutOfRangeException — Thrown when given index exceeds range of [0,MaterialGroupCount-1]
Int32 GetMaterialGroupIndex(String groupIndex)

Retrieves the index of a material group given its name.

groupIndex — The name of the material group.
returns — The index of the material group, or a negative value if the group does not exist.
IEnumerable<Material> GetMaterials(Int32 groupIndex)

Retrieves an enumerable collection of Materials belonging to a specified group.

groupIndex — The index of the material group. Default value is 0.
returns — An IEnumerable of Materials in the specified group.
IEnumerable<Material> GetMaterials(String groupName)

Retrieves an enumerable collection of Materials belonging to a specified group.

groupName — The name of the material group.
returns — An IEnumerable of Materials in the specified group.
ArgumentException — Thrown when the provided group name does not exist.
String GetMorphName(Int32 morph)

Returns name of a morph controller at given index.

morph — Morph controller index to get name of, starting at 0.
returns — Name of the morph controller at given index.
ArgumentOutOfRangeException — Thrown when given index exceeds range of [0,MorphCount-1]
Single GetVisemeMorph(String viseme, Int32 morph)

Get morph weight for viseme.

Byte[] SaveToVmdl()
Task<Byte[]> SaveToVmdlAsync()
String GetBoneName(Int32 boneIndex)

Returns name of a bone at given bone index.

boneIndex — Bone index to get name of, starting at 0.
returns — Name of the bone.
ArgumentOutOfRangeException — Thrown when given index exceeds range of [0,BoneCount-1]
Int32 GetBoneParent(Int32 boneIndex)

Returns the id of given bone's parent bone.

boneIndex — The bone to look up parent of.
returns — The id of the parent bone, or -1 if given bone has no parent.
ArgumentOutOfRangeException — Thrown when given index exceeds range of [0,BoneCount-1]
Transform GetBoneTransform(Int32 boneIndex)

Returns transform of given bone at bind position.

ArgumentOutOfRangeException — Thrown when given index exceeds range of [0,BoneCount-1]
Transform GetBoneTransform(String bone)

Returns transform of given bone at bind position.

Dictionary<Bone, GameObject> CreateBoneObjects(GameObject root)

Creates a dictionary of bone names to game objects, where each game object is a bone object in the scene.

Vertex[] GetVertices()

Experimental!

UInt32[] GetIndices()

Experimental!

Int32 GetIndexCount(Int32 drawcall)
Int32 GetIndexStart(Int32 drawcall)
Int32 GetBaseVertex(Int32 drawcall)
Assembly: Sandbox.Engine Namespace: Sandbox Full Name: Sandbox.Model