2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
24 #include "../math/Matrix.h"
\r
25 #include "../math/Ray.h"
\r
28 #include "BaseMesh.h"
\r
30 #include "EffectDefault.h"
\r
31 #include "EffectInstance.h"
\r
32 #include "ExtendedMaterial.h"
\r
33 #include "GlyphMetricsFloat.h"
\r
34 #include "AttributeWeights.h"
\r
35 #include "WeldEpsilons.h"
\r
44 /// Provides an interface to manipulate mesh objects.
\r
46 /// <unmanaged>ID3DXMesh</unmanaged>
\r
47 public ref class Mesh : public BaseMesh
\r
49 COMOBJECT(ID3DXMesh, Mesh);
\r
52 array<int>^ adjacency;
\r
53 array<ExtendedMaterial>^ materials;
\r
54 array<EffectInstance>^ effects;
\r
57 static Mesh^ FromMemory_Internal( SlimDX::Direct3D9::Device^ device, const void* memory, DWORD size, MeshFlags flags );
\r
60 void SetAdjacency( DWORD *adjacency );
\r
63 Mesh( SlimDX::Direct3D9::Device^ device, int faceCount, int vertexCount, MeshFlags options, array<VertexElement>^ vertexDeclaration );
\r
64 Mesh( SlimDX::Direct3D9::Device^ device, int faceCount, int vertexCount, MeshFlags options, SlimDX::Direct3D9::VertexFormat fvf );
\r
67 static Mesh^ FromMemory( SlimDX::Direct3D9::Device^ device, array<System::Byte>^ memory, MeshFlags flags );
\r
68 static Mesh^ FromStream( SlimDX::Direct3D9::Device^ device, System::IO::Stream^ stream, MeshFlags flags );
\r
69 static Mesh^ FromFile( SlimDX::Direct3D9::Device^ device, System::String^ fileName, MeshFlags flags );
\r
70 static Mesh^ FromXFile( SlimDX::Direct3D9::Device^ device, XFileData^ xfile, MeshFlags flags );
\r
72 static Result ToXFile( Mesh^ mesh, System::String^ fileName, XFileFormat format, System::Runtime::InteropServices::CharSet charSet );
\r
73 static Result ToXFile( Mesh^ mesh, System::String^ fileName, XFileFormat format );
\r
75 static Mesh^ CreateBox( SlimDX::Direct3D9::Device^ device, float width, float height, float depth );
\r
76 static Mesh^ CreateCylinder( SlimDX::Direct3D9::Device^ device, float radius1, float radius2, float length, int slices, int stacks );
\r
77 static Mesh^ CreateSphere( SlimDX::Direct3D9::Device^ device, float radius, int slices, int stacks );
\r
78 static Mesh^ CreateTeapot( SlimDX::Direct3D9::Device^ device );
\r
79 static Mesh^ CreateTorus( SlimDX::Direct3D9::Device^ device, float innerRadius, float outerRadius, int sides, int rings );
\r
81 static Mesh^ CreateText( SlimDX::Direct3D9::Device^ device, System::Drawing::Font^ font, System::String^ text, float deviation, float extrusion, [Out] array<GlyphMetricsFloat>^% glyphMetrics );
\r
82 static Mesh^ CreateText( SlimDX::Direct3D9::Device^ device, System::Drawing::Font^ font, System::String^ text, float deviation, float extrusion );
\r
84 static Mesh^ Concatenate( SlimDX::Direct3D9::Device^ device, array<Mesh^>^ meshes, MeshFlags options, array<Matrix>^ geometryTransforms, array<Matrix>^ textureTransforms, array<VertexElement>^ vertexDeclaration );
\r
85 static Mesh^ Concatenate( SlimDX::Direct3D9::Device^ device, array<Mesh^>^ meshes, MeshFlags options, array<Matrix>^ geometryTransforms, array<Matrix>^ textureTransforms );
\r
86 static Mesh^ Concatenate( SlimDX::Direct3D9::Device^ device, array<Mesh^>^ meshes, MeshFlags options );
\r
88 static Mesh^ Simplify( Mesh^ mesh, array<AttributeWeights>^ attributeWeights, array<float>^ vertexWeights, int minimumValue, MeshSimplification options );
\r
89 static Mesh^ Simplify( Mesh^ mesh, array<AttributeWeights>^ attributeWeights, int minimumValue, MeshSimplification options );
\r
90 static Mesh^ Simplify( Mesh^ mesh, int minimumValue, MeshSimplification options );
\r
92 static Mesh^ TessellateNPatches( Mesh^ mesh, float segmentCount, bool quadraticInterpolation );
\r
94 void GenerateAdjacency( float epsilon ) new;
\r
96 System::String^ Validate();
\r
98 DataStream^ LockAttributeBuffer( LockFlags flags );
\r
99 Result UnlockAttributeBuffer();
\r
100 Result SetAttributeTable( array<AttributeRange>^ table );
\r
102 Result OptimizeInPlace( MeshOptimizeFlags flags, [Out] array<int>^% faceRemap, [Out] array<int>^% vertexRemap );
\r
103 Result OptimizeInPlace( MeshOptimizeFlags flags );
\r
105 Mesh^ Optimize( MeshOptimizeFlags flags, [Out] array<int>^% faceRemap, [Out] array<int>^% vertexRemap );
\r
106 Mesh^ Optimize( MeshOptimizeFlags flags );
\r
108 Mesh^ Clean( CleanType type, [Out] System::String^% errorsAndWarnings );
\r
109 Mesh^ Clean( CleanType type );
\r
111 Result ComputeNormals();
\r
112 Result ComputeTangent( int textureStage, int tangentIndex, int binormalIndex, bool wrap );
\r
113 Result ComputeTangentFrame( TangentOptions options );
\r
115 Mesh^ ComputeTangentFrame( int textureInSemantic, int textureInIndex, int partialOutSemanticU,
\r
116 int partialOutIndexU, int partialOutSemanticV, int partialOutIndexV, int normalOutSemantic,
\r
117 int normalOutIndex, TangentOptions options, float partialEdgeThreshold,
\r
118 float singularPointThreshold, float normalEdgeThreshold, [Out] array<int>^% vertexMapping );
\r
120 Mesh^ ComputeTangentFrame( int textureInSemantic, int textureInIndex, int partialOutSemanticU,
\r
121 int partialOutIndexU, int partialOutSemanticV, int partialOutIndexV, int normalOutSemantic,
\r
122 int normalOutIndex, TangentOptions options, float partialEdgeThreshold,
\r
123 float singularPointThreshold, float normalEdgeThreshold );
\r
125 Result TessellateRectanglePatch( SlimDX::Direct3D9::VertexBuffer^ vertexBuffer, array<float>^ segmentCounts,
\r
126 array<VertexElement>^ vertexDeclaration, RectanglePatchInfo rectanglePatchInfo );
\r
128 Result TessellateTrianglePatch( SlimDX::Direct3D9::VertexBuffer^ vertexBuffer, array<float>^ segmentCounts,
\r
129 array<VertexElement>^ vertexDeclaration, TrianglePatchInfo trianglePatchInfo );
\r
131 array<ExtendedMaterial>^ GetMaterials() { return materials; }
\r
132 void SetMaterials( array<ExtendedMaterial>^ value ) { materials = value; }
\r
134 array<EffectInstance>^ GetEffects() { return effects; }
\r
135 void SetEffects( array<EffectInstance>^ value ) { effects = value; }
\r
137 void SetAdjacency( array<int>^ adjacency ) { this->adjacency = adjacency; }
\r
138 array<int>^ GetAdjacency() { return adjacency; }
\r
140 Result WeldVertices( WeldFlags flags, WeldEpsilons epsilons, [Out] array<int>^% faceRemap, [Out] array<int>^% vertexRemap );
\r
141 Result WeldVertices( WeldFlags flags, [Out] array<int>^% faceRemap, [Out] array<int>^% vertexRemap );
\r
142 Result WeldVertices( WeldFlags flags, WeldEpsilons epsilons );
\r
143 Result WeldVertices( WeldFlags flags );
\r
145 property SkinInfo^ SkinInfo
\r
147 SlimDX::Direct3D9::SkinInfo^ get() { return skinInfo; }
\r
148 void set( SlimDX::Direct3D9::SkinInfo^ value ) { skinInfo = value; }
\r