Table of Contents

Class Model

Namespace
OmegaEngine.Graphics.Renderables
Assembly
OmegaEngine.dll

A model (stored as a Direct3DX Mesh with one or more subsets). Handle

public class Model : PositionableRenderable, IDisposable, IPositionable
Inheritance
Model
Implements
Derived
Inherited Members
Extension Methods

Remarks

No custom SlimDX.Direct3D9.PrimitiveTypes. Use VertexGroup for that.

Constructors

Model(XMesh)

Creates a new model based upon a XMesh, using its internal material data if available.

public Model(XMesh mesh)

Parameters

mesh XMesh

The XMesh providing the mesh data.

Remarks

Calling Dispose() will not dispose the mesh. This is handled by the CacheManager.

Model(XMesh, params XMaterial[])

Creates a new model based upon a XMesh, using an external texture and a plain white material.

public Model(XMesh mesh, params XMaterial[] materials)

Parameters

mesh XMesh

The XMesh providing the mesh data.

materials XMaterial[]

The materials to use for rendering the model.

Remarks

Calling Dispose() will call ReleaseReference() on mesh and materials.

Model(Mesh, params XMaterial[])

Creates a new model based upon a custom mesh.

public Model(Mesh mesh, params XMaterial[] materials)

Parameters

mesh Mesh

The mesh to render. Normals should be calculated before-hand if they will be used (e.g. by SurfaceShaders).

materials XMaterial[]

The materials to use for rendering the model.

Remarks

Calling Dispose() will call Dispose() on mesh and ReleaseReference() on materials.

Fields

Materials

An array of materials used to render this mesh

public readonly XMaterial[] Materials

Field Value

XMaterial[]

Mesh

The mesh object to use for rendering; never null.

protected readonly Mesh Mesh

Field Value

Mesh

Properties

NumberSubsets

The numbers of subsets in this model

public int NumberSubsets { get; protected set; }

Property Value

int

VertexCount

The numbers of vertexes in this model

public int VertexCount { get; }

Property Value

int

Methods

Box(Engine, ITextureProvider?, float, float, float)

Creates a model of a textured box.

public static Model Box(Engine engine, ITextureProvider? texture = null, float width = 5, float height = 5, float depth = 5)

Parameters

engine Engine

The Engine to use for rendering.

texture ITextureProvider

The texture to place on the model; null for no texture.

width float

The width of the box

height float

The height of the box

depth float

The depth of the box

Returns

Model

Cylinder(Engine, ITextureProvider?, float, float, float)

Creates a model of a textured cylinder with spherical mapping.

public static Model Cylinder(Engine engine, ITextureProvider? texture = null, float radiusBottom = 1, float radiusTop = 1, float length = 10)

Parameters

engine Engine

The Engine to use for rendering.

texture ITextureProvider

The texture to place on the model; null for no texture.

radiusBottom float

The radius of the cylinder at the lower end (negative Z).

radiusTop float

The radius of the cylinder at the upper end (positive Z).

length float

The length of the cylinder.

Returns

Model

Cylinder(Engine, ITextureProvider?, float, float, float, int, int)

Creates a model of a textured sphere with spherical mapping.

public static Model Cylinder(Engine engine, ITextureProvider? texture, float radiusBottom, float radiusTop, float length, int slices, int stacks)

Parameters

engine Engine

The Engine to use for rendering.

texture ITextureProvider

The texture to place on the model; null for no texture.

radiusBottom float

The radius of the cylinder at the lower end (negative Z).

radiusTop float

The radius of the cylinder at the upper end (positive Z).

length float

The length of the cylinder.

slices int

The number of vertical slices to divide the cylinder in.

stacks int

The number of horizontal stacks to divide the cylinder in.

Returns

Model

Disc(Engine, ITextureProvider?, float, float, float)

Creates a model of a textured round disc with a hole in the middle.

public static Model Disc(Engine engine, ITextureProvider? texture = null, float radiusInner = 5, float radiusOuter = 7, float height = 1)

Parameters

engine Engine

The Engine to use for rendering.

texture ITextureProvider

The texture to place on the model; null for no texture.

radiusInner float

The radius of the inner circle of the ring.

radiusOuter float

The radius of the outer circle of the ring.

height float

The height of the ring.

Returns

Model

Disc(Engine, ITextureProvider, float, float, float, int)

Creates a model of a textured round disc with a hole in the middle.

public static Model Disc(Engine engine, ITextureProvider texture, float radiusInner, float radiusOuter, float height, int segments)

Parameters

engine Engine

The Engine to use for rendering.

texture ITextureProvider

The texture to place on the model; null for no texture.

radiusInner float

The radius of the inner circle of the ring.

radiusOuter float

The radius of the outer circle of the ring.

height float

The height of the ring.

segments int

The number of segments the ring shall consist of.

Returns

Model

Intersects(Ray, out float)

Determine whether this PositionableRenderable is intersected by a ray.

public override bool Intersects(Ray ray, out float distance)

Parameters

ray Ray

A ray in world space along which to check for intersections.

distance float

Returns the distance along the ray at which the intersection took place.

Returns

bool

true if this PositionableRenderable was intersected by the ray.

See Also

OnDispose()

Hook that is called when the object needs to dispose its internal resources.

protected override void OnDispose()

Quad(Engine, ITextureProvider?, float, float)

Creates a model of a textured 2D quad.

public static Model Quad(Engine engine, ITextureProvider? texture = null, float width = 5, float height = 5)

Parameters

engine Engine

The Engine to use for rendering.

texture ITextureProvider

The texture to place on the model; null for no texture.

width float

The width of the quad.

height float

The height of the quad.

Returns

Model

RenderSubset(int, Camera, LightSource[])

protected void RenderSubset(int i, Camera camera, LightSource[] lights)

Parameters

i int
camera Camera
lights LightSource[]

SetTexture(ITextureProvider)

Sets the first diffuse texture of the first material.

public void SetTexture(ITextureProvider texture)

Parameters

texture ITextureProvider

The texture to set; null for no texture.

Sphere(Engine, ITextureProvider?, float, int, int)

Creates a model of a textured sphere with spherical mapping.

public static Model Sphere(Engine engine, ITextureProvider? texture = null, float radius = 10, int slices = 20, int stacks = 20)

Parameters

engine Engine

The Engine to use for rendering.

texture ITextureProvider

The texture to place on the model; null for no texture.

radius float

The radius of the sphere.

slices int

The number of vertical slices to divide the sphere into.

stacks int

The number of horizontal stacks to divide the sphere into.

Returns

Model