4 using System.Collections;
5 using System.Collections.Generic;
6 using System.Collections.Specialized;
7 using SiliconStudio.Core;
8 using SiliconStudio.Core.Collections;
9 using SiliconStudio.Core.Mathematics;
10 using SiliconStudio.Core.ReferenceCounting;
11 using SiliconStudio.Core.Serialization.Converters;
12 using SiliconStudio.Paradox.Graphics;
16 namespace SiliconStudio.
Paradox.Effects
25 private readonly List<Mesh> meshes =
new List<Mesh>();
26 private IList<Model> children;
36 public IList<Model> Children
38 get {
return children; }
39 set { children = value; }
49 public List<Mesh> Meshes
51 get {
return meshes; }
97 IEnumerator IEnumerable.GetEnumerator()
99 throw new NotImplementedException();
104 var vertices = geometryMesh.Vertices;
108 for (
int i = 0; i < vertices.Length; i++)
109 BoundingBox.
Merge(ref boundingBox, ref vertices[i].Position, out boundingBox);
116 var vertices = geometryMesh.Vertices;
120 for (
int i = 0; i < vertices.Length; i++)
121 BoundingBox.
Merge(ref boundingBox, ref vertices[i].Position, out boundingBox);
130 var vertices = geometryMesh.Vertices;
131 var indices = geometryMesh.Indices;
133 if (indices.Length < 0xFFFF)
135 var indicesShort =
new ushort[indices.Length];
136 for (
int i = 0; i < indicesShort.Length; i++)
138 indicesShort[i] = (ushort)indices[i];
140 meshDraw.IndexBuffer =
new IndexBufferBinding(
Buffer.Index.
New(graphicsDevice, indicesShort).RecreateWith(indicesShort),
false, indices.Length);
146 throw new InvalidOperationException(
"Cannot generate more than 65535 indices on feature level HW <= 9.3");
149 meshDraw.IndexBuffer =
new IndexBufferBinding(
Buffer.Index.
New(graphicsDevice, indices).RecreateWith(indices),
true, indices.Length);
152 meshDraw.VertexBuffers =
new[] {
new VertexBufferBinding(
Buffer.Vertex.
New(graphicsDevice, vertices).RecreateWith(vertices), layout, vertices.Length) };
154 meshDraw.DrawCount = indices.Length;
155 meshDraw.PrimitiveType = PrimitiveType.TriangleList;
158 mesh.Parameters.Set(RenderingParameters.RenderLayer, RenderLayers.RenderLayerAll);
172 var result =
new Model();
173 if (Children != null)
175 result.Children =
new List<Model>();
176 foreach (var child
in Children)
178 result.Children.Add(child.Instantiate());
182 foreach (var mesh
in Meshes)
184 var meshCopy =
new Mesh(mesh);
185 meshCopy.Parameters = meshCopy.Parameters.Clone();
186 result.Meshes.Add(meshCopy);
189 result.Hierarchy = Hierarchy;
200 case NotifyCollectionChangedAction.Add:
201 if (child.parent != null)
202 throw new InvalidOperationException(
"Model already have a parent.");
205 case NotifyCollectionChangedAction.Remove:
206 if (child.parent !=
this)
207 throw new InvalidOperationException(
"Model doesn't have expected parent.");
static readonly VertexDeclaration Layout
The vertex layout of this struct.
Represents an axis-aligned bounding box in three dimensional space.
The layout of a vertex buffer with a set of VertexElement.
Model Instantiate()
Create a clone with its own ParameterCollection. It allows reuse of a single Model for multiple Model...
static Model FromGeometricMeshData(GraphicsDevice graphicsDevice, GeometricMeshData< VertexPositionNormalTexture > geometryMesh, string effectName="Default")
Describes hiderarchical nodes in a flattened array.
static readonly VertexDeclaration Layout
The vertex layout of this struct.
Base class for converters to/from a data type.
Describes a custom vertex format structure that contains position, color and 10 texture coordinates i...
Describes a custom vertex format structure that contains position, normal and texture information...
void Add(Mesh mesh)
Adds the specified mesh (for collection initializers).
All-in-One Buffer class linked SharpDX.Direct3D11.Buffer.
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
static Model FromGeometricMeshData(GraphicsDevice graphicsDevice, GeometricMeshData< VertexPositionNormalTangentMultiTexture > geometryMesh, string effectName="Default")
static Buffer New(GraphicsDevice device, BufferDescription description, PixelFormat viewFormat=PixelFormat.None)
Creates a new Buffer instance.
void Add(Model model)
Adds the specified model view (for collection initializers).
object Item
Gets the added or removed item (if dictionary, value only).
NotifyCollectionChangedAction Action
Gets the type of action performed. Allowed values are NotifyCollectionChangedAction.Add and NotifyCollectionChangedAction.Remove.
SiliconStudio.Paradox.Graphics.Buffer Buffer
GraphicsProfile
Identifies the set of supported devices for the demo based on device capabilities.
The base interface for all the vertex data structure.
Collection of Mesh, each one usually being a different LOD of the same Model. The effect system will ...
static void Merge(ref BoundingBox value1, ref Vector3 value2, out BoundingBox result)
Constructs a SiliconStudio.Core.Mathematics.BoundingBox that is as large enough to contains the bound...
Binding structure that specifies a vertex buffer and other per-vertex parameters (such as offset and ...