diff options
Merge branch 'bigmerge' of ssh://3dhosting.de/var/git/careminster into bigmerge
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs | 197 |
1 files changed, 0 insertions, 197 deletions
diff --git a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs deleted file mode 100644 index 637cf6e..0000000 --- a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs +++ /dev/null | |||
@@ -1,197 +0,0 @@ | |||
1 | /* | ||
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 | ||
4 | |||
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 | ||
7 | arising from the use of this software. | ||
8 | |||
9 | Permission is granted to anyone to use this software for any purpose, | ||
10 | including commercial applications, and to alter it and redistribute it | ||
11 | freely, subject to the following restrictions: | ||
12 | |||
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 | ||
15 | in a product, an acknowledgment in the product documentation would be | ||
16 | appreciated but is not required. | ||
17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
18 | misrepresented as being the original software. | ||
19 | 3. This notice may not be removed or altered from any source distribution. | ||
20 | */ | ||
21 | |||
22 | /* | ||
23 | This file contains a class TriangleIndexVertexArray. I tried using the class with the same name | ||
24 | from the BulletX implementation and found it unusable for the purpose of using triangle meshes | ||
25 | within BulletX as the implementation was painfully incomplete. | ||
26 | The attempt to derive from the original class failed as viable members were hidden. | ||
27 | Fiddling around with BulletX itself was not my intention. | ||
28 | So I copied the class to the BulletX-plugin and modified it. | ||
29 | If you want to fiddle around with it it's up to you to move all this to BulletX. | ||
30 | If someone someday implements the missing functionality in BulletX, feel free to remove this class. | ||
31 | It's just an ugly hack. | ||
32 | */ | ||
33 | |||
34 | using System; | ||
35 | using System.Collections.Generic; | ||
36 | using MonoXnaCompactMaths; | ||
37 | using XnaDevRu.BulletX; | ||
38 | |||
39 | namespace OpenSim.Region.Physics.BulletXPlugin | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// IndexedMesh indexes into existing vertex and index arrays, in a similar way OpenGL glDrawElements | ||
43 | /// instead of the number of indices, we pass the number of triangles | ||
44 | /// </summary> | ||
45 | public struct IndexedMesh | ||
46 | { | ||
47 | private int _numTriangles; | ||
48 | private int[] _triangleIndexBase; | ||
49 | private int _triangleIndexStride; | ||
50 | private int _numVertices; | ||
51 | private Vector3[] _vertexBase; | ||
52 | private int _vertexStride; | ||
53 | |||
54 | public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, | ||
55 | Vector3[] vertexBase, int vertexStride) | ||
56 | { | ||
57 | _numTriangles = numTriangleIndices; | ||
58 | _triangleIndexBase = triangleIndexBase; | ||
59 | _triangleIndexStride = triangleIndexStride; | ||
60 | _vertexBase = vertexBase; | ||
61 | _numVertices = numVertices; | ||
62 | _vertexStride = vertexStride; | ||
63 | } | ||
64 | |||
65 | public IndexedMesh(int[] triangleIndexBase, Vector3[] vertexBase) | ||
66 | { | ||
67 | _numTriangles = triangleIndexBase.Length; | ||
68 | _triangleIndexBase = triangleIndexBase; | ||
69 | _triangleIndexStride = 32; | ||
70 | _vertexBase = vertexBase; | ||
71 | _numVertices = vertexBase.Length; | ||
72 | _vertexStride = 24; | ||
73 | } | ||
74 | |||
75 | public int TriangleCount | ||
76 | { | ||
77 | get { return _numTriangles; } | ||
78 | set { _numTriangles = value; } | ||
79 | } | ||
80 | |||
81 | public int[] TriangleIndexBase | ||
82 | { | ||
83 | get { return _triangleIndexBase; } | ||
84 | set { _triangleIndexBase = value; } | ||
85 | } | ||
86 | |||
87 | public int TriangleIndexStride | ||
88 | { | ||
89 | get { return _triangleIndexStride; } | ||
90 | set { _triangleIndexStride = value; } | ||
91 | } | ||
92 | |||
93 | public int VertexCount | ||
94 | { | ||
95 | get { return _numVertices; } | ||
96 | set { _numVertices = value; } | ||
97 | } | ||
98 | |||
99 | public Vector3[] VertexBase | ||
100 | { | ||
101 | get { return _vertexBase; } | ||
102 | set { _vertexBase = value; } | ||
103 | } | ||
104 | |||
105 | public int VertexStride | ||
106 | { | ||
107 | get { return _vertexStride; } | ||
108 | set { _vertexStride = value; } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
113 | /// TriangleIndexVertexArray allows to use multiple meshes, by indexing into existing triangle/index arrays. | ||
114 | /// Additional meshes can be added using addIndexedMesh | ||
115 | /// </summary> | ||
116 | public class TriangleIndexVertexArray : StridingMeshInterface | ||
117 | { | ||
118 | private List<IndexedMesh> _indexedMeshes = new List<IndexedMesh>(); | ||
119 | |||
120 | public TriangleIndexVertexArray() | ||
121 | { | ||
122 | } | ||
123 | |||
124 | public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, | ||
125 | int numVertices, Vector3[] vertexBase, int vertexStride) | ||
126 | { | ||
127 | IndexedMesh mesh = new IndexedMesh(); | ||
128 | mesh.TriangleCount = numTriangleIndices; | ||
129 | mesh.TriangleIndexBase = triangleIndexBase; | ||
130 | mesh.TriangleIndexStride = triangleIndexStride; | ||
131 | mesh.VertexBase = vertexBase; | ||
132 | mesh.VertexCount = numVertices; | ||
133 | mesh.VertexStride = vertexStride; | ||
134 | |||
135 | AddIndexedMesh(mesh); | ||
136 | } | ||
137 | |||
138 | public TriangleIndexVertexArray(int[] triangleIndexBase, Vector3[] vertexBase) | ||
139 | : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) | ||
140 | { | ||
141 | } | ||
142 | |||
143 | public void AddIndexedMesh(IndexedMesh indexedMesh) | ||
144 | { | ||
145 | _indexedMeshes.Add(indexedMesh); | ||
146 | } | ||
147 | |||
148 | public override void GetLockedVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, | ||
149 | int subpart) | ||
150 | { | ||
151 | throw new Exception("The method or operation is not implemented."); | ||
152 | } | ||
153 | |||
154 | public override void GetLockedReadOnlyVertexIndexBase(out List<Vector3> verts, out List<int> indicies, | ||
155 | out int numfaces, int subpart) | ||
156 | { | ||
157 | IndexedMesh m = _indexedMeshes[0]; | ||
158 | Vector3[] vertexBase = m.VertexBase; | ||
159 | verts = new List<Vector3>(); | ||
160 | foreach (Vector3 v in vertexBase) | ||
161 | { | ||
162 | verts.Add(v); | ||
163 | } | ||
164 | int[] indexBase = m.TriangleIndexBase; | ||
165 | indicies = new List<int>(); | ||
166 | foreach (int i in indexBase) | ||
167 | { | ||
168 | indicies.Add(i); | ||
169 | } | ||
170 | numfaces = vertexBase.GetLength(0); | ||
171 | } | ||
172 | |||
173 | public override void UnLockVertexBase(int subpart) | ||
174 | { | ||
175 | throw new Exception("The method or operation is not implemented."); | ||
176 | } | ||
177 | |||
178 | public override void UnLockReadOnlyVertexBase(int subpart) | ||
179 | { | ||
180 | } | ||
181 | |||
182 | public override int SubPartsCount() | ||
183 | { | ||
184 | return _indexedMeshes.Count; | ||
185 | } | ||
186 | |||
187 | public override void PreallocateVertices(int numverts) | ||
188 | { | ||
189 | throw new Exception("The method or operation is not implemented."); | ||
190 | } | ||
191 | |||
192 | public override void PreallocateIndices(int numindices) | ||
193 | { | ||
194 | throw new Exception("The method or operation is not implemented."); | ||
195 | } | ||
196 | } | ||
197 | } | ||