Class Scene
Represents a completely imported model or scene. Everything that was imported from the given file can be accessed from here. Once the scene is loaded from unmanaged memory, it resides solely in managed memory and Assimp's read only copy is released.
Implements
Inherited Members
Namespace: SharpAssimp
Assembly: SharpAssimp.dll
Syntax
public sealed class Scene : IMarshalable<Scene, AiScene>
Constructors
| Edit this page View SourceScene()
Constructs a new instance of the Scene class.
Declaration
public Scene()
Scene(string)
Constructs a new instance of the Scene class.
Declaration
public Scene(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name of the scene |
Properties
| Edit this page View SourceAnimationCount
Gets the number of animations in the scene.
Declaration
public int AnimationCount { get; }
Property Value
Type | Description |
---|---|
int |
Animations
Gets the animations in the scene, if any.
Declaration
public List<Animation> Animations { get; }
Property Value
Type | Description |
---|---|
List<Animation> |
CameraCount
Gets the number of cameras in the scene.
Declaration
public int CameraCount { get; }
Property Value
Type | Description |
---|---|
int |
Cameras
Gets the cameras in the scene, if any.
Declaration
public List<Camera> Cameras { get; }
Property Value
Type | Description |
---|---|
List<Camera> |
HasAnimations
Gets if the scene contains any animations.
Declaration
public bool HasAnimations { get; }
Property Value
Type | Description |
---|---|
bool |
HasCameras
Gets if the scene contains any cameras.
Declaration
public bool HasCameras { get; }
Property Value
Type | Description |
---|---|
bool |
HasLights
Gets if the scene contains any lights.
Declaration
public bool HasLights { get; }
Property Value
Type | Description |
---|---|
bool |
HasMaterials
Gets if the scene contains any materials. There should always be at least the default Assimp material if no materials were loaded.
Declaration
public bool HasMaterials { get; }
Property Value
Type | Description |
---|---|
bool |
HasMeshes
Gets if the scene contains meshes. Unless if no special scene flags are set this should always be true.
Declaration
public bool HasMeshes { get; }
Property Value
Type | Description |
---|---|
bool |
HasTextures
Gets if the scene contains embedded textures.
Declaration
public bool HasTextures { get; }
Property Value
Type | Description |
---|---|
bool |
LightCount
Gets the number of lights in the scene.
Declaration
public int LightCount { get; }
Property Value
Type | Description |
---|---|
int |
Lights
Gets the lights in the scene, if any.
Declaration
public List<Light> Lights { get; }
Property Value
Type | Description |
---|---|
List<Light> |
MaterialCount
Gets the number of materials in the scene. There should always be at least the default Assimp material if no materials were loaded.
Declaration
public int MaterialCount { get; }
Property Value
Type | Description |
---|---|
int |
Materials
Gets the materials in the scene.
Declaration
public List<Material> Materials { get; }
Property Value
Type | Description |
---|---|
List<Material> |
MeshCount
Gets the number of meshes in the scene.
Declaration
public int MeshCount { get; }
Property Value
Type | Description |
---|---|
int |
Meshes
Gets the meshes contained in the scene, if any.
Declaration
public List<Mesh> Meshes { get; }
Property Value
Type | Description |
---|---|
List<Mesh> |
Metadata
Gets the metadata of the scene. This data contains global metadata which belongs to the scene like unit-conversions, versions, vendors or other model-specific data. This can be used to store format-specific metadata as well.
Declaration
public Metadata Metadata { get; }
Property Value
Type | Description |
---|---|
Metadata |
Name
Gets or sets the name of the scene.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
RootNode
Gets or sets the root node of the scene graph. There will always be at least the root node if the import was successful and no special flags have been set. Presence of further nodes depends on the format and content of the imported file.
Declaration
public Node? RootNode { get; set; }
Property Value
Type | Description |
---|---|
Node |
SceneFlags
Gets or sets the state of the imported scene. By default no flags are set, but issues can arise if the flag is set to incomplete.
Declaration
public SceneFlags SceneFlags { get; set; }
Property Value
Type | Description |
---|---|
SceneFlags |
TextureCount
Gets the number of embedded textures in the scene.
Declaration
public int TextureCount { get; }
Property Value
Type | Description |
---|---|
int |
Textures
Gets the embedded textures in the scene, if any.
Declaration
public List<EmbeddedTexture?> Textures { get; }
Property Value
Type | Description |
---|---|
List<EmbeddedTexture> |
Methods
| Edit this page View SourceClear()
Clears the scene of all components.
Declaration
public void Clear()
FreeNative(nint, bool)
Frees unmanaged memory created by ToNative(nint, out Native).
Declaration
public static void FreeNative(nint nativeValue, bool freeNative)
Parameters
Type | Name | Description |
---|---|---|
nint | nativeValue | Native value to free |
bool | freeNative | True if the unmanaged memory should be freed, false otherwise. |
FreeUnmanagedScene(nint)
Frees unmanaged memory allocated -ONLY- in ToUnmanagedScene(Scene). To free an unmanaged scene allocated by the unmanaged Assimp library, call the appropiate ReleaseImport(nint) function.
Declaration
public static void FreeUnmanagedScene(nint scenePtr)
Parameters
Type | Name | Description |
---|---|---|
nint | scenePtr | Pointer to unmanaged scene data. |
FromUnmanagedScene(nint)
Marshals an unmanaged scene to managed memory. This does not free the unmanaged memory.
Declaration
public static Scene? FromUnmanagedScene(nint scenePtr)
Parameters
Type | Name | Description |
---|---|---|
nint | scenePtr | The unmanaged scene data |
Returns
Type | Description |
---|---|
Scene | The managed scene, or null if the pointer is NULL |
GetEmbeddedTexture(string)
Gets an embedded texture by a string. The string may be a texture ID in the format of "*1" or is the file name of the texture.
Declaration
public EmbeddedTexture? GetEmbeddedTexture(string fileName)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | Texture ID or original file name. |
Returns
Type | Description |
---|---|
EmbeddedTexture | Embedded texture or null if it could not be found. |
ToUnmanagedScene(Scene)
Marshals a managed scene to unmanaged memory. The unmanaged memory must be freed with a call to FreeUnmanagedScene(nint), the memory is owned by AssimpNet and cannot be freed by the native library.
Declaration
public static nint ToUnmanagedScene(Scene scene)
Parameters
Type | Name | Description |
---|---|---|
Scene | scene | Scene data |
Returns
Type | Description |
---|---|
nint | Unmanaged scene or NULL if the scene is null. |