public sealed class Sandbox.Model : Sandbox.Resource
A model.
Related Guides
Broader workflow and conceptual references connected to this API.
If you want a specific file/asset type to have a custom Thumbnail/Inspector Preview, you can simply create an AssetPreview. An AssetPreview initializes a SceneWorld and SceneCamera, rendering the Camera to the Preview output, so all you need to do is populate it and/or position the Camera to your liking.
There is a large selection of Assets (Textures, Models, Sounds, ect) available to use on sbox.game, and you can use them without needing to think about downloading the files/mounting the content/ect.
A Component is added to a GameObject to provide functionality. This functionality can vary wildly.
The mount system is extensible - anyone can write a mount to add support for a new game or engine and contribute it to s&box via pull request. A mount detects a game's install directory via Steam, scans its files, and converts assets into s&box compatible assets, all at runtime.
You can define your own custom asset types as GameResources. They give you a nice inspector window and they're hotloaded in-game, which means you can whip things up pretty quickly if you're using them.
GPU instancing is an optimization where multiple instances of the same model with the same material can be drawn in a single draw call. This is a big optimization when rendering things that appear many times in a scene such as foliage.
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
| Exception | Condition |
|---|---|
ArgumentOutOfRangeException | Thrown 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
| Exception | Condition |
|---|---|
ArgumentOutOfRangeException | Thrown 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
| Exception | Condition |
|---|---|
ArgumentOutOfRangeException | Thrown 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
| Exception | Condition |
|---|---|
ArgumentOutOfRangeException | Thrown 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
| Exception | Condition |
|---|---|
ArgumentOutOfRangeException | Thrown 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
| Exception | Condition |
|---|---|
ArgumentOutOfRangeException | Thrown 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()
No results match this filter.
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 Sandbox.ModelAttachments Sandbox.Model.Attachments { get; set; }
Access to bones of this model.
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 Sandbox.BoneCollection Sandbox.Model.Bones { get; set; }
Access to bones of this model.
public static Sandbox.ModelBuilder Sandbox.Model.Builder { get; set; }
Returns a static `Sandbox.ModelBuilder` instance, allowing for runtime model creation.
public Sandbox.Model.CommonData Sandbox.Model.Data { get; set; }
public ulong Sandbox.Model.DefaultBodyGroupMask { get; set; }Obsolete
Obsolete: Use Parts
public Sandbox.HitboxSet Sandbox.Model.HitboxSet { get; set; }
Access to default hitbox set of this 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 Sandbox.PhysicsGroupDescription Sandbox.Model.Physics { get; set; }
public Sandbox.Engine.Utility.RayTrace.MeshTraceRequest Sandbox.Model.Trace { get; set; }
Trace against the triangles in this mesh
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.Model |