s&box docs

public sealed class Sandbox.Model : Sandbox.Resource

A model.

Broader workflow and conceptual references connected to this API.

Methods

Showing 29 methods

public System.Collections.Generic.Dictionary`2<Sandbox.BoneCollection.Bone,Sandbox.GameObject> CreateBoneObjects(Sandbox.GameObject root)

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

public string GetAnimationName(int animationIndex)

Returns name of an animation at given animation index.

Parameters

  • animationIndex: Animation index to get name of, starting at 0.

Returns

Name of the animation.

Exceptions

ExceptionCondition
ArgumentOutOfRangeExceptionThrown when given index exceeds range of [0,AnimationCount-1]

public string GetAttachmentName(int index)Obsolete

Returns name of an attachment at given index.

Obsolete: This API member is obsolete.

Parameters

  • index: Index of the attachment to look up, starting at 0.

Returns

The name of the attachment at given index.

Exceptions

ExceptionCondition
ArgumentOutOfRangeExceptionThrown when given index exceeds range of [0,AttachmentCount-1]

public int GetBaseVertex(int drawcall)

public string GetBoneName(int boneIndex)

Returns name of a bone at given bone index.

Parameters

  • boneIndex: Bone index to get name of, starting at 0.

Returns

Name of the bone.

Exceptions

ExceptionCondition
ArgumentOutOfRangeExceptionThrown when given index exceeds range of [0,BoneCount-1]

public int GetBoneParent(int boneIndex)

Returns the id of given bone's parent bone.

Parameters

  • boneIndex: The bone to look up parent of.

Returns

The id of the parent bone, or -1 if given bone has no parent.

Exceptions

ExceptionCondition
ArgumentOutOfRangeExceptionThrown when given index exceeds range of [0,BoneCount-1]

public System.Collections.Generic.Dictionary`2<string,string[]> GetBreakCommands()

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

public T GetData()

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

public int GetIndexCount(int drawcall)

public int GetIndexStart(int drawcall)

public uint[] GetIndices()

Experimental!

public int GetMaterialGroupIndex(string groupIndex)

Retrieves the index of a material group given its name.

Parameters

  • groupIndex: The name of the material group.

Returns

The index of the material group, or a negative value if the group does not exist.

public string GetMaterialGroupName(int groupIndex)

Returns name of a material group at given group index.

Parameters

  • groupIndex: Group index to get name of, starting at 0.

Returns

Name of the group.

Exceptions

ExceptionCondition
ArgumentOutOfRangeExceptionThrown when given index exceeds range of [0,MaterialGroupCount-1]

public string GetMorphName(int morph)

Returns name of a morph controller at given index.

Parameters

  • morph: Morph controller index to get name of, starting at 0.

Returns

Name of the morph controller at given index.

Exceptions

ExceptionCondition
ArgumentOutOfRangeExceptionThrown when given index exceeds range of [0,MorphCount-1]

public Sandbox.Vertex[] GetVertices()

Experimental!

public float GetVisemeMorph(string viseme, int morph)

Get morph weight for viseme.

public bool HasData()

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

public static Sandbox.Model Load(string filename)

Load a model by file path.

Parameters

  • filename: The file path to load as a model.

Returns

The loaded model, or null

public static System.Threading.Tasks.Task`1<Sandbox.Model> LoadAsync(string filename)

Load a model by file path.

Parameters

  • filename: The file path to load as a model.

Returns

The loaded model, or null

public byte[] SaveToVmdl()

public System.Threading.Tasks.Task`1<byte[]> SaveToVmdlAsync()

Properties

Showing 32 properties

public int Sandbox.Model.AnimationCount { get; set; }

Number of animations this model has.

public System.Collections.Generic.IReadOnlyList`1<string> Sandbox.Model.AnimationNames { get; set; }

public Sandbox.AnimationGraph Sandbox.Model.AnimGraph { get; set; }

Get the animgraph this model uses.

public int Sandbox.Model.AttachmentCount { get; set; }Obsolete

Returns amount of attachment points this model has.

Obsolete: This API member is obsolete.

public int Sandbox.Model.BodyGroupCount { get; set; }Obsolete

Obsolete: Use Parts

public System.Collections.Generic.IEnumerable`1<Sandbox.Model.BodyPart> Sandbox.Model.BodyParts { get; set; }Obsolete

Obsolete: Use Parts

public int Sandbox.Model.BoneCount { get; set; }

Number of bones this model has.

public BBox Sandbox.Model.Bounds { get; set; }

Total bounds of all the meshes.

public static Sandbox.ModelBuilder Sandbox.Model.Builder { get; set; }

Returns a static `Sandbox.ModelBuilder` instance, allowing for runtime model creation.

public static Sandbox.Model Sandbox.Model.Cube { get; set; }

A cube model

public ulong Sandbox.Model.DefaultBodyGroupMask { get; set; }Obsolete

Obsolete: Use Parts

public static Sandbox.Model Sandbox.Model.Error { get; set; }

An error model

public bool Sandbox.Model.IsError { get; set; }

Whether this model is an error model or invalid or not.

public bool Sandbox.Model.IsProcedural { get; set; }

Whether this model is procedural, i.e. it was created at runtime via `Sandbox.ModelBuilder.Create`.

public virtual bool Sandbox.Model.IsValid { get; set; }

public int Sandbox.Model.MaterialGroupCount { get; set; }

Number of material groups this model has.

public System.Collections.Immutable.ImmutableArray`1<Sandbox.Material> Sandbox.Model.Materials { get; set; }

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

Returns

An ImmutableArray of Materials.

public int Sandbox.Model.MeshCount { get; set; }

Total number of meshes this model is made out of.

public int Sandbox.Model.MorphCount { get; set; }

Number of morph controllers this model has.

public Sandbox.ModelMorphs Sandbox.Model.Morphs { get; set; }

Access to bones of this model.

public string Sandbox.Model.Name { get; set; }

Name of the model, usually being its file path.

public Sandbox.ModelParts Sandbox.Model.Parts { get; set; }

Access to body parts of this model.

public BBox Sandbox.Model.PhysicsBounds { get; set; }

Total bounds of all the physics shapes.

public BBox Sandbox.Model.RenderBounds { get; set; }

Render view bounds.

Metadata

FieldValue
NamespaceSandbox
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.Model

On this page

Methodspublic System.Collections.Generic.Dictionary`2<Sandbox.BoneCollection.Bone,Sandbox.GameObject> CreateBoneObjects(Sandbox.GameObject root)public System.String GetAnimationName(System.Int32 animationIndex)public System.Nullable`1<Transform> GetAttachment(System.Int32 index)public System.Nullable`1<Transform> GetAttachment(System.String name)public System.String GetAttachmentName(System.Int32 index)public System.Int32 GetBaseVertex(System.Int32 drawcall)public System.String GetBoneName(System.Int32 boneIndex)public System.Int32 GetBoneParent(System.Int32 boneIndex)public Transform GetBoneTransform(System.Int32 boneIndex)public Transform GetBoneTransform(System.String bone)public System.Collections.Generic.Dictionary`2<System.String,System.String[]> GetBreakCommands()public T GetData()public System.Int32 GetIndexCount(System.Int32 drawcall)public System.Int32 GetIndexStart(System.Int32 drawcall)public System.UInt32[] GetIndices()public System.Int32 GetMaterialGroupIndex(System.String groupIndex)public System.String GetMaterialGroupName(System.Int32 groupIndex)public System.Collections.Generic.IEnumerable`1<Sandbox.Material> GetMaterials(System.Int32 groupIndex)public System.Collections.Generic.IEnumerable`1<Sandbox.Material> GetMaterials(System.String groupName)public System.String GetMorphName(System.Int32 morph)public Sandbox.Vertex[] GetVertices()public System.Single GetVisemeMorph(System.String viseme, System.Int32 morph)public System.Boolean HasData()public static Sandbox.Model Load(System.String filename)public static System.Threading.Tasks.Task`1<Sandbox.Model> LoadAsync(System.String filename)public System.Byte[] SaveToVmdl()public System.Threading.Tasks.Task`1<System.Byte[]> SaveToVmdlAsync()public System.Boolean TryGetData(System.Type t, System.Object data)public System.Boolean TryGetData(T data)Propertiespublic System.Int32 Sandbox.Model.AnimationCount { get; set; }public System.Collections.Generic.IReadOnlyList`1<System.String> Sandbox.Model.AnimationNames { get; set; }public Sandbox.AnimationGraph Sandbox.Model.AnimGraph { get; set; }public System.Int32 Sandbox.Model.AttachmentCount { get; set; }public Sandbox.ModelAttachments Sandbox.Model.Attachments { get; set; }public System.Int32 Sandbox.Model.BodyGroupCount { get; set; }public System.Collections.Generic.IEnumerable`1<Sandbox.Model.BodyPart> Sandbox.Model.BodyParts { get; set; }public System.Int32 Sandbox.Model.BoneCount { get; set; }public Sandbox.BoneCollection Sandbox.Model.Bones { get; set; }public BBox Sandbox.Model.Bounds { get; set; }public static Sandbox.ModelBuilder Sandbox.Model.Builder { get; set; }public static Sandbox.Model Sandbox.Model.Cube { get; set; }public Sandbox.Model.CommonData Sandbox.Model.Data { get; set; }public System.UInt64 Sandbox.Model.DefaultBodyGroupMask { get; set; }public static Sandbox.Model Sandbox.Model.Error { get; set; }public Sandbox.HitboxSet Sandbox.Model.HitboxSet { get; set; }public System.Boolean Sandbox.Model.IsError { get; set; }public System.Boolean Sandbox.Model.IsProcedural { get; set; }public virtual System.Boolean Sandbox.Model.IsValid { get; set; }public System.Int32 Sandbox.Model.MaterialGroupCount { get; set; }public System.Collections.Immutable.ImmutableArray`1<Sandbox.Material> Sandbox.Model.Materials { get; set; }public System.Int32 Sandbox.Model.MeshCount { get; set; }public System.Int32 Sandbox.Model.MorphCount { get; set; }public Sandbox.ModelMorphs Sandbox.Model.Morphs { get; set; }public System.String Sandbox.Model.Name { get; set; }public Sandbox.ModelParts Sandbox.Model.Parts { get; set; }public Sandbox.PhysicsGroupDescription Sandbox.Model.Physics { get; set; }public BBox Sandbox.Model.PhysicsBounds { get; set; }public static Sandbox.Model Sandbox.Model.Plane { get; set; }public BBox Sandbox.Model.RenderBounds { get; set; }public static Sandbox.Model Sandbox.Model.Sphere { get; set; }public Sandbox.Engine.Utility.RayTrace.MeshTraceRequest Sandbox.Model.Trace { get; set; }Metadata