Table of Contents

Class Geometry3D

Namespace
HelixToolkit.SharpDX
Assembly
HelixToolkit.SharpDX.dll
[Serializable]
[DataContract]
public abstract class Geometry3D : ObservableObject, INotifyPropertyChanged, IGUID
Inheritance
Geometry3D
Implements
Derived
Inherited Members

Constructors

Geometry3D()

Initializes a new instance of the Geometry3D class.

public Geometry3D()

Geometry3D(bool)

Initializes a new instance of the Geometry3D class.

public Geometry3D(bool isDynamic)

Parameters

isDynamic bool

if set to true [is dynamic].

Fields

DisableUpdateBound

The disable update bound, only used in AssignTo(Geometry3D)

protected bool DisableUpdateBound

Field Value

bool

TriangleBuffer

public const string TriangleBuffer = "TriangleBuffer"

Field Value

string

VertexBuffer

public const string VertexBuffer = "VertexBuffer"

Field Value

string

Properties

Bound

Geometry AABB

[IgnoreDataMember]
public BoundingBox Bound { get; set; }

Property Value

BoundingBox

BoundingSphere

Geometry Bounding Sphere

[IgnoreDataMember]
public BoundingSphere BoundingSphere { get; set; }

Property Value

BoundingSphere

Colors

Vertex Color

[DataMember]
public Color4Collection? Colors { get; set; }

Property Value

Color4Collection

GUID

Gets the unique identifier.

[DataMember]
public Guid GUID { get; set; }

Property Value

Guid

The unique identifier.

Indices

Indices, can be triangle list, line list, etc.

[DataMember]
public IntCollection? Indices { get; set; }

Property Value

IntCollection

IsDynamic

Gets or sets a value indicating whether this instance is dynamic. Must be set before passing to GeometryModel3D.

When set to true, the internal vertex/index buffer will be created using dynamic buffer.

Default is false, which is using immutable.

Dynamic buffer is useful if user streaming similar sizes of Vertices/Indices into this geometry, this will avoid unnecessary buffer creation and reuse the existing dynamic buffer if the max size less than the size of existing buffer.

public bool IsDynamic { get; set; }

Property Value

bool

true if this instance is dynamic; otherwise, false.

IsTransient

Gets a value indicating whether the geometry data are transient. Call SetAsTransient() to set this flag to true.

When this is true, geometry3D data will be cleared once being loaded into GPU.

This geometry3D can only be used by one Model3D in one Viewport. Must not be shared. Hit test is disabled as well.

Useful when loading a large geometry for view only and free up memory after geometry data being uploaded to GPU.

public bool IsTransient { get; }

Property Value

bool

true if this instance is transient; otherwise, false.

Octree

TO use Octree during hit test to improve hit performance, please call UpdateOctree after model created.

public IOctreeBasic? Octree { get; }

Property Value

IOctreeBasic

OctreeDirty

Gets or sets a value indicating whether [octree dirty], needs update.

public bool OctreeDirty { get; }

Property Value

bool

true if [octree dirty]; otherwise, false.

OctreeParameter

Gets or sets the octree parameter.

public OctreeBuildParameter OctreeParameter { get; }

Property Value

OctreeBuildParameter

The octree parameter.

Positions

Vertex Positions

[DataMember]
public Vector3Collection? Positions { get; set; }

Property Value

Vector3Collection

PreDefinedIndexCount

The pre defined index count. Used when IsDynamic = true.

The pre define index count allows user to initialize a dynamic buffer with a minimum pre-define size.

Example: If the index count increments from 0 to around 3000 during index array streaming, pre-define a size of 3000 for this geometry allows the dynamic buffer to be reused and avoid recreating dynamic buffer 3000 times.

public int PreDefinedIndexCount { get; set; }

Property Value

int

PreDefinedVertexCount

The pre defined vertex count. Only used when IsDynamic = true.

The pre define vertex count allows user to initialize a dynamic buffer with a minimum pre-define size.

Example: If the vertex count increments from 0 to around 3000 during vertex array streaming, pre-define a size of 3000 for this geometry allows the dynamic buffer to be reused and avoid recreating dynamic buffer 3000 times.

public int PreDefinedVertexCount { get; set; }

Property Value

int

Methods

AssignTo(Geometry3D)

Assigns internal properties to another geometry3D. This does not assign IsDynamic/PreDefinedIndexCount/PreDefinedVertexCount

Following properties are assigned: Positions, Indices, Colors, Bound, BoundingSphere, Octree, OctreeParameter

Override OnAssignTo(Geometry3D) to assign custom properties in child class

public void AssignTo(Geometry3D target)

Parameters

target Geometry3D

The target.

CanCreateOctree()

protected virtual bool CanCreateOctree()

Returns

bool

ClearAllGeometryData()

Clears all geometry data.

public void ClearAllGeometryData()

ClearOctree()

Set octree to null

public void ClearOctree()

CreateOctree(OctreeBuildParameter)

Override to create different octree in subclasses.

protected virtual IOctreeBasic? CreateOctree(OctreeBuildParameter parameter)

Parameters

parameter OctreeBuildParameter

Returns

IOctreeBasic

ManualSetOctree(IOctreeBasic)

Manuals the set octree.

public void ManualSetOctree(IOctreeBasic octree)

Parameters

octree IOctreeBasic

The octree.

OnAssignTo(Geometry3D)

protected virtual void OnAssignTo(Geometry3D target)

Parameters

target Geometry3D

OnClearAllGeometryData()

protected virtual void OnClearAllGeometryData()

SetAsTransient()

Sets this geometry as transient.

Once this is called, this geometry will be marked as IsTransient = true.

This function must be called before geometry is attached to a model for rendering. Or before the model is attached to a viewport for rendering.

A transient geometry is being used to save memory. All geometry data will be cleared once being uploaded into GPU. Should not be shared with multiple models.

A transient geometry does not support hit test.
public void SetAsTransient()

UpdateBounds()

Manually call this function to update AABB and Bounding Sphere

public virtual void UpdateBounds()

UpdateColors()

Call to manually update vertex color buffer.

This is useful if user want to reuse existing Colors object and update color value inside the list.

Make sure the Colors count equal to the Positions count

public void UpdateColors()

UpdateOctree(bool)

Create Octree for current model.

public void UpdateOctree(bool force = false)

Parameters

force bool

UpdateTriangles()

Call to manually update triangle buffer.

This is useful if user want to reuse existing Indices object and update index value inside the list.

public void UpdateTriangles()

UpdateVertices()

Call to manually update vertex buffer. Use with DisablePropertyChangedEvent

This is useful if user want to reuse existing Positions list and update vertex value inside the list.

Note: For performance purpose, this will not cause bounding box update. User must manually call UpdateBounds() to refresh geometry bounding box.

public void UpdateVertices()