diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/TriangleIndexVertexArray.cs | 272 |
1 files changed, 136 insertions, 136 deletions
diff --git a/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/TriangleIndexVertexArray.cs b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/TriangleIndexVertexArray.cs index 6d0d7b5..52c08ed 100644 --- a/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/TriangleIndexVertexArray.cs +++ b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/TriangleIndexVertexArray.cs | |||
@@ -1,136 +1,136 @@ | |||
1 | /* | 1 | /* |
2 | Bullet for XNA Copyright (c) 2003-2007 Vsevolod Klementjev http://www.codeplex.com/xnadevru | 2 | Bullet for XNA Copyright (c) 2003-2007 Vsevolod Klementjev http://www.codeplex.com/xnadevru |
3 | Bullet original C++ version Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com | 3 | Bullet original C++ version Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com |
4 | 4 | ||
5 | This software is provided 'as-is', without any express or implied | 5 | This software is provided 'as-is', without any express or implied |
6 | warranty. In no event will the authors be held liable for any damages | 6 | warranty. In no event will the authors be held liable for any damages |
7 | arising from the use of this software. | 7 | arising from the use of this software. |
8 | 8 | ||
9 | Permission is granted to anyone to use this software for any purpose, | 9 | Permission is granted to anyone to use this software for any purpose, |
10 | including commercial applications, and to alter it and redistribute it | 10 | including commercial applications, and to alter it and redistribute it |
11 | freely, subject to the following restrictions: | 11 | freely, subject to the following restrictions: |
12 | 12 | ||
13 | 1. The origin of this software must not be misrepresented; you must not | 13 | 1. The origin of this software must not be misrepresented; you must not |
14 | claim that you wrote the original software. If you use this software | 14 | claim that you wrote the original software. If you use this software |
15 | in a product, an acknowledgment in the product documentation would be | 15 | in a product, an acknowledgment in the product documentation would be |
16 | appreciated but is not required. | 16 | appreciated but is not required. |
17 | 2. Altered source versions must be plainly marked as such, and must not be | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
18 | misrepresented as being the original software. | 18 | misrepresented as being the original software. |
19 | 3. This notice may not be removed or altered from any source distribution. | 19 | 3. This notice may not be removed or altered from any source distribution. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | using System; | 22 | using System; |
23 | using System.Collections.Generic; | 23 | using System.Collections.Generic; |
24 | using System.Text; | 24 | using System.Text; |
25 | using MonoXnaCompactMaths; | 25 | using MonoXnaCompactMaths; |
26 | 26 | ||
27 | namespace XnaDevRu.BulletX | 27 | namespace XnaDevRu.BulletX |
28 | { | 28 | { |
29 | /// <summary> | 29 | /// <summary> |
30 | /// IndexedMesh indexes into existing vertex and index arrays, in a similar way OpenGL glDrawElements | 30 | /// IndexedMesh indexes into existing vertex and index arrays, in a similar way OpenGL glDrawElements |
31 | /// instead of the number of indices, we pass the number of triangles | 31 | /// instead of the number of indices, we pass the number of triangles |
32 | /// </summary> | 32 | /// </summary> |
33 | public struct IndexedMesh | 33 | public struct IndexedMesh |
34 | { | 34 | { |
35 | private int _numTriangles; | 35 | private int _numTriangles; |
36 | private int[] _triangleIndexBase; | 36 | private int[] _triangleIndexBase; |
37 | private int _triangleIndexStride; | 37 | private int _triangleIndexStride; |
38 | private int _numVertices; | 38 | private int _numVertices; |
39 | private Vector3[] _vertexBase; | 39 | private Vector3[] _vertexBase; |
40 | private int _vertexStride; | 40 | private int _vertexStride; |
41 | 41 | ||
42 | public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) | 42 | public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) |
43 | { | 43 | { |
44 | _numTriangles = numTriangleIndices; | 44 | _numTriangles = numTriangleIndices; |
45 | _triangleIndexBase = triangleIndexBase; | 45 | _triangleIndexBase = triangleIndexBase; |
46 | _triangleIndexStride = triangleIndexStride; | 46 | _triangleIndexStride = triangleIndexStride; |
47 | _vertexBase = vertexBase; | 47 | _vertexBase = vertexBase; |
48 | _numVertices = numVertices; | 48 | _numVertices = numVertices; |
49 | _vertexStride = vertexStride; | 49 | _vertexStride = vertexStride; |
50 | } | 50 | } |
51 | 51 | ||
52 | public IndexedMesh(int[] triangleIndexBase, Vector3[] vertexBase) | 52 | public IndexedMesh(int[] triangleIndexBase, Vector3[] vertexBase) |
53 | { | 53 | { |
54 | _numTriangles = triangleIndexBase.Length; | 54 | _numTriangles = triangleIndexBase.Length; |
55 | _triangleIndexBase = triangleIndexBase; | 55 | _triangleIndexBase = triangleIndexBase; |
56 | _triangleIndexStride = 32; | 56 | _triangleIndexStride = 32; |
57 | _vertexBase = vertexBase; | 57 | _vertexBase = vertexBase; |
58 | _numVertices = vertexBase.Length; | 58 | _numVertices = vertexBase.Length; |
59 | _vertexStride = 24; | 59 | _vertexStride = 24; |
60 | } | 60 | } |
61 | 61 | ||
62 | public int TriangleCount { get { return _numTriangles; } set { _numTriangles = value; } } | 62 | public int TriangleCount { get { return _numTriangles; } set { _numTriangles = value; } } |
63 | public int[] TriangleIndexBase { get { return _triangleIndexBase; } set { _triangleIndexBase = value; } } | 63 | public int[] TriangleIndexBase { get { return _triangleIndexBase; } set { _triangleIndexBase = value; } } |
64 | public int TriangleIndexStride { get { return _triangleIndexStride; } set { _triangleIndexStride = value; } } | 64 | public int TriangleIndexStride { get { return _triangleIndexStride; } set { _triangleIndexStride = value; } } |
65 | public int VertexCount { get { return _numVertices; } set { _numVertices = value; } } | 65 | public int VertexCount { get { return _numVertices; } set { _numVertices = value; } } |
66 | public Vector3[] VertexBase { get { return _vertexBase; } set { _vertexBase = value; } } | 66 | public Vector3[] VertexBase { get { return _vertexBase; } set { _vertexBase = value; } } |
67 | public int VertexStride { get { return _vertexStride; } set { _vertexStride = value; } } | 67 | public int VertexStride { get { return _vertexStride; } set { _vertexStride = value; } } |
68 | } | 68 | } |
69 | 69 | ||
70 | /// <summary> | 70 | /// <summary> |
71 | /// TriangleIndexVertexArray allows to use multiple meshes, by indexing into existing triangle/index arrays. | 71 | /// TriangleIndexVertexArray allows to use multiple meshes, by indexing into existing triangle/index arrays. |
72 | /// Additional meshes can be added using addIndexedMesh | 72 | /// Additional meshes can be added using addIndexedMesh |
73 | /// </summary> | 73 | /// </summary> |
74 | public class TriangleIndexVertexArray : StridingMeshInterface | 74 | public class TriangleIndexVertexArray : StridingMeshInterface |
75 | { | 75 | { |
76 | List<IndexedMesh> _indexedMeshes = new List<IndexedMesh>(); | 76 | List<IndexedMesh> _indexedMeshes = new List<IndexedMesh>(); |
77 | 77 | ||
78 | public TriangleIndexVertexArray() { } | 78 | public TriangleIndexVertexArray() { } |
79 | 79 | ||
80 | public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) | 80 | public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) |
81 | { | 81 | { |
82 | IndexedMesh mesh = new IndexedMesh(); | 82 | IndexedMesh mesh = new IndexedMesh(); |
83 | mesh.TriangleCount = numTriangleIndices; | 83 | mesh.TriangleCount = numTriangleIndices; |
84 | mesh.TriangleIndexBase = triangleIndexBase; | 84 | mesh.TriangleIndexBase = triangleIndexBase; |
85 | mesh.TriangleIndexStride = triangleIndexStride; | 85 | mesh.TriangleIndexStride = triangleIndexStride; |
86 | mesh.VertexBase = vertexBase; | 86 | mesh.VertexBase = vertexBase; |
87 | mesh.VertexCount = numVertices; | 87 | mesh.VertexCount = numVertices; |
88 | mesh.VertexStride = vertexStride; | 88 | mesh.VertexStride = vertexStride; |
89 | 89 | ||
90 | AddIndexedMesh(mesh); | 90 | AddIndexedMesh(mesh); |
91 | } | 91 | } |
92 | 92 | ||
93 | public TriangleIndexVertexArray(int[] triangleIndexBase, Vector3[] vertexBase) | 93 | public TriangleIndexVertexArray(int[] triangleIndexBase, Vector3[] vertexBase) |
94 | : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) { } | 94 | : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) { } |
95 | 95 | ||
96 | public void AddIndexedMesh(IndexedMesh indexedMesh) | 96 | public void AddIndexedMesh(IndexedMesh indexedMesh) |
97 | { | 97 | { |
98 | _indexedMeshes.Add(indexedMesh); | 98 | _indexedMeshes.Add(indexedMesh); |
99 | } | 99 | } |
100 | 100 | ||
101 | public override void GetLockedVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) | 101 | public override void GetLockedVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) |
102 | { | 102 | { |
103 | throw new Exception("The method or operation is not implemented."); | 103 | throw new Exception("The method or operation is not implemented."); |
104 | } | 104 | } |
105 | 105 | ||
106 | public override void GetLockedReadOnlyVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) | 106 | public override void GetLockedReadOnlyVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) |
107 | { | 107 | { |
108 | throw new Exception("The method or operation is not implemented."); | 108 | throw new Exception("The method or operation is not implemented."); |
109 | } | 109 | } |
110 | 110 | ||
111 | public override void UnLockVertexBase(int subpart) | 111 | public override void UnLockVertexBase(int subpart) |
112 | { | 112 | { |
113 | throw new Exception("The method or operation is not implemented."); | 113 | throw new Exception("The method or operation is not implemented."); |
114 | } | 114 | } |
115 | 115 | ||
116 | public override void UnLockReadOnlyVertexBase(int subpart) | 116 | public override void UnLockReadOnlyVertexBase(int subpart) |
117 | { | 117 | { |
118 | throw new Exception("The method or operation is not implemented."); | 118 | throw new Exception("The method or operation is not implemented."); |
119 | } | 119 | } |
120 | 120 | ||
121 | public override int SubPartsCount() | 121 | public override int SubPartsCount() |
122 | { | 122 | { |
123 | return _indexedMeshes.Count; | 123 | return _indexedMeshes.Count; |
124 | } | 124 | } |
125 | 125 | ||
126 | public override void PreallocateVertices(int numverts) | 126 | public override void PreallocateVertices(int numverts) |
127 | { | 127 | { |
128 | throw new Exception("The method or operation is not implemented."); | 128 | throw new Exception("The method or operation is not implemented."); |
129 | } | 129 | } |
130 | 130 | ||
131 | public override void PreallocateIndices(int numindices) | 131 | public override void PreallocateIndices(int numindices) |
132 | { | 132 | { |
133 | throw new Exception("The method or operation is not implemented."); | 133 | throw new Exception("The method or operation is not implemented."); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | } | 136 | } |