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
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
XMeshThe 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
MeshThe 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
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
VertexCount
The numbers of vertexes in this model
public int VertexCount { get; }
Property Value
Methods
Box(Engine, XMaterial, float, float, float)
Creates a model of a box.
public static Model Box(Engine engine, XMaterial material, float width = 5, float height = 5, float depth = 5)
Parameters
engine
EngineThe Engine to use for rendering.
material
XMaterialThe material used to render the surface of the model.
width
floatThe width of the box
height
floatThe height of the box
depth
floatThe depth of the box
Returns
Cylinder(Engine, XMaterial, float, float, float)
Creates a model of a cylinder with spherical mapping.
public static Model Cylinder(Engine engine, XMaterial material, float radiusBottom = 1, float radiusTop = 1, float length = 10)
Parameters
engine
EngineThe Engine to use for rendering.
material
XMaterialThe material used to render the surface of the model.
radiusBottom
floatThe radius of the cylinder at the lower end (negative Z).
radiusTop
floatThe radius of the cylinder at the upper end (positive Z).
length
floatThe length of the cylinder.
Returns
Cylinder(Engine, XMaterial, float, float, float, int, int)
Creates a model of a cylinder with spherical mapping.
public static Model Cylinder(Engine engine, XMaterial material, float radiusBottom, float radiusTop, float length, int slices, int stacks)
Parameters
engine
EngineThe Engine to use for rendering.
material
XMaterialThe material used to render the surface of the model.
radiusBottom
floatThe radius of the cylinder at the lower end (negative Z).
radiusTop
floatThe radius of the cylinder at the upper end (positive Z).
length
floatThe length of the cylinder.
slices
intThe number of vertical slices to divide the cylinder in.
stacks
intThe number of horizontal stacks to divide the cylinder in.
Returns
Disc(Engine, XMaterial, float, float, float)
Creates a model of a textured round disc with a hole in the middle.
public static Model Disc(Engine engine, XMaterial material, float radiusInner = 5, float radiusOuter = 7, float height = 1)
Parameters
engine
EngineThe Engine to use for rendering.
material
XMaterialThe material used to render the surface of the model; must be IsTextured.
radiusInner
floatThe radius of the inner circle of the ring.
radiusOuter
floatThe radius of the outer circle of the ring.
height
floatThe height of the ring.
Returns
Exceptions
- NotSupportedException
The
material
is not textured.
Disc(Engine, XMaterial, float, float, float, int)
Creates a model of a textured round disc with a hole in the middle.
public static Model Disc(Engine engine, XMaterial material, float radiusInner, float radiusOuter, float height, int segments)
Parameters
engine
EngineThe Engine to use for rendering.
material
XMaterialThe material used to render the surface of the model; must be IsTextured.
radiusInner
floatThe radius of the inner circle of the ring.
radiusOuter
floatThe radius of the outer circle of the ring.
height
floatThe height of the ring.
segments
intThe number of segments the ring shall consist of.
Returns
Exceptions
- NotSupportedException
The
material
is not textured.
Intersects(Ray, out float)
Determine whether this PositionableRenderable is intersected by a ray.
public override bool Intersects(Ray ray, out float distance)
Parameters
ray
RayA ray in world space along which to check for intersections.
distance
floatReturns the distance along the
ray
at which the intersection took place.
Returns
- bool
true
if this PositionableRenderable was intersected by theray
.
- See Also
OnDispose()
Hook that is called when the object needs to dispose its internal resources.
protected override void OnDispose()
Quad(Engine, XMaterial, float, float)
Creates a model of a textured 2D quad.
public static Model Quad(Engine engine, XMaterial material, float width = 5, float height = 5)
Parameters
engine
EngineThe Engine to use for rendering.
material
XMaterialThe material used to render the surface of the model; must be IsTextured.
width
floatThe width of the quad.
height
floatThe height of the quad.
Returns
Exceptions
- NotSupportedException
The
material
is not textured.
RenderSubset(int, Camera, LightSource[])
protected void RenderSubset(int i, Camera camera, LightSource[] lights)
Parameters
i
intcamera
Cameralights
LightSource[]
SetTexture(ITextureProvider)
Sets the first diffuse texture of the first material.
public void SetTexture(ITextureProvider texture)
Parameters
texture
ITextureProviderThe texture to set;
null
for no texture.
Sphere(Engine, XMaterial, float, int, int)
Creates a model of a sphere with spherical mapping.
public static Model Sphere(Engine engine, XMaterial material, float radius = 10, int slices = 20, int stacks = 20)
Parameters
engine
EngineThe Engine to use for rendering.
material
XMaterialThe material used to render the surface of the model.
radius
floatThe radius of the sphere.
slices
intThe number of vertical slices to divide the sphere into.
stacks
intThe number of horizontal stacks to divide the sphere into.