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
meshXMeshThe XMesh providing the mesh data.
materialsXMaterial[]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
meshMeshThe mesh to render. Normals should be calculated before-hand if they will be used (e.g. by SurfaceShaders).
materialsXMaterial[]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
engineEngineThe Engine to use for rendering.
materialXMaterialThe material used to render the surface of the model.
widthfloatThe width of the box
heightfloatThe height of the box
depthfloatThe 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
engineEngineThe Engine to use for rendering.
materialXMaterialThe material used to render the surface of the model.
radiusBottomfloatThe radius of the cylinder at the lower end (negative Z).
radiusTopfloatThe radius of the cylinder at the upper end (positive Z).
lengthfloatThe 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
engineEngineThe Engine to use for rendering.
materialXMaterialThe material used to render the surface of the model.
radiusBottomfloatThe radius of the cylinder at the lower end (negative Z).
radiusTopfloatThe radius of the cylinder at the upper end (positive Z).
lengthfloatThe length of the cylinder.
slicesintThe number of vertical slices to divide the cylinder in.
stacksintThe 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
engineEngineThe Engine to use for rendering.
materialXMaterialThe material used to render the surface of the model; must be IsTextured.
radiusInnerfloatThe radius of the inner circle of the ring.
radiusOuterfloatThe radius of the outer circle of the ring.
heightfloatThe height of the ring.
Returns
Exceptions
- NotSupportedException
The
materialis 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
engineEngineThe Engine to use for rendering.
materialXMaterialThe material used to render the surface of the model; must be IsTextured.
radiusInnerfloatThe radius of the inner circle of the ring.
radiusOuterfloatThe radius of the outer circle of the ring.
heightfloatThe height of the ring.
segmentsintThe number of segments the ring shall consist of.
Returns
Exceptions
- NotSupportedException
The
materialis 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
rayRayA ray in world space along which to check for intersections.
distancefloatReturns the distance along the
rayat which the intersection took place.
Returns
- bool
trueif 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
engineEngineThe Engine to use for rendering.
materialXMaterialThe material used to render the surface of the model; must be IsTextured.
widthfloatThe width of the quad.
heightfloatThe height of the quad.
Returns
Exceptions
- NotSupportedException
The
materialis not textured.
RenderSubset(int, Camera, LightSource[])
protected void RenderSubset(int i, Camera camera, LightSource[] lights)
Parameters
iintcameraCameralightsLightSource[]
SetTexture(ITextureProvider)
Sets the first diffuse texture of the first material.
public void SetTexture(ITextureProvider texture)
Parameters
textureITextureProviderThe texture to set;
nullfor 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
engineEngineThe Engine to use for rendering.
materialXMaterialThe material used to render the surface of the model.
radiusfloatThe radius of the sphere.
slicesintThe number of vertical slices to divide the sphere into.
stacksintThe number of horizontal stacks to divide the sphere into.