aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletXPlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletXPlugin')
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs322
1 files changed, 161 insertions, 161 deletions
diff --git a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs
index fb30296..4f63687 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs
@@ -1,161 +1,161 @@
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/* 22/*
23 23
24 This file contains a class TriangleIndexVertexArray. I tried using the class with the same name 24 This file contains a class TriangleIndexVertexArray. I tried using the class with the same name
25 from the BulletX implementation and found it unusable for the purpose of using triangle meshes 25 from the BulletX implementation and found it unusable for the purpose of using triangle meshes
26 within BulletX as the implementation was painfully incomplete. 26 within BulletX as the implementation was painfully incomplete.
27 The attempt to derive from the original class failed as viable members were hidden. 27 The attempt to derive from the original class failed as viable members were hidden.
28 Fiddling around with BulletX itself was not my intention. 28 Fiddling around with BulletX itself was not my intention.
29 So I copied the class to the BulletX-plugin and modified it. 29 So I copied the class to the BulletX-plugin and modified it.
30 If you want to fiddle around with it it's up to you to move all this to BulletX. 30 If you want to fiddle around with it it's up to you to move all this to BulletX.
31 If someone someday implements the missing functionality in BulletX, feel free to remove this class. 31 If someone someday implements the missing functionality in BulletX, feel free to remove this class.
32 It's just an ugly hack. 32 It's just an ugly hack.
33 33
34 */ 34 */
35using System; 35using System;
36using System.Collections.Generic; 36using System.Collections.Generic;
37using System.Text; 37using System.Text;
38using MonoXnaCompactMaths; 38using MonoXnaCompactMaths;
39 39
40namespace OpenSim.Region.Physics.BulletXPlugin 40namespace OpenSim.Region.Physics.BulletXPlugin
41{ 41{
42 /// <summary> 42 /// <summary>
43 /// IndexedMesh indexes into existing vertex and index arrays, in a similar way OpenGL glDrawElements 43 /// IndexedMesh indexes into existing vertex and index arrays, in a similar way OpenGL glDrawElements
44 /// instead of the number of indices, we pass the number of triangles 44 /// instead of the number of indices, we pass the number of triangles
45 /// </summary> 45 /// </summary>
46 public struct IndexedMesh 46 public struct IndexedMesh
47 { 47 {
48 private int _numTriangles; 48 private int _numTriangles;
49 private int[] _triangleIndexBase; 49 private int[] _triangleIndexBase;
50 private int _triangleIndexStride; 50 private int _triangleIndexStride;
51 private int _numVertices; 51 private int _numVertices;
52 private Vector3[] _vertexBase; 52 private Vector3[] _vertexBase;
53 private int _vertexStride; 53 private int _vertexStride;
54 54
55 public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) 55 public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride)
56 { 56 {
57 _numTriangles = numTriangleIndices; 57 _numTriangles = numTriangleIndices;
58 _triangleIndexBase = triangleIndexBase; 58 _triangleIndexBase = triangleIndexBase;
59 _triangleIndexStride = triangleIndexStride; 59 _triangleIndexStride = triangleIndexStride;
60 _vertexBase = vertexBase; 60 _vertexBase = vertexBase;
61 _numVertices = numVertices; 61 _numVertices = numVertices;
62 _vertexStride = vertexStride; 62 _vertexStride = vertexStride;
63 } 63 }
64 64
65 public IndexedMesh(int[] triangleIndexBase, Vector3[] vertexBase) 65 public IndexedMesh(int[] triangleIndexBase, Vector3[] vertexBase)
66 { 66 {
67 _numTriangles = triangleIndexBase.Length; 67 _numTriangles = triangleIndexBase.Length;
68 _triangleIndexBase = triangleIndexBase; 68 _triangleIndexBase = triangleIndexBase;
69 _triangleIndexStride = 32; 69 _triangleIndexStride = 32;
70 _vertexBase = vertexBase; 70 _vertexBase = vertexBase;
71 _numVertices = vertexBase.Length; 71 _numVertices = vertexBase.Length;
72 _vertexStride = 24; 72 _vertexStride = 24;
73 } 73 }
74 74
75 public int TriangleCount { get { return _numTriangles; } set { _numTriangles = value; } } 75 public int TriangleCount { get { return _numTriangles; } set { _numTriangles = value; } }
76 public int[] TriangleIndexBase { get { return _triangleIndexBase; } set { _triangleIndexBase = value; } } 76 public int[] TriangleIndexBase { get { return _triangleIndexBase; } set { _triangleIndexBase = value; } }
77 public int TriangleIndexStride { get { return _triangleIndexStride; } set { _triangleIndexStride = value; } } 77 public int TriangleIndexStride { get { return _triangleIndexStride; } set { _triangleIndexStride = value; } }
78 public int VertexCount { get { return _numVertices; } set { _numVertices = value; } } 78 public int VertexCount { get { return _numVertices; } set { _numVertices = value; } }
79 public Vector3[] VertexBase { get { return _vertexBase; } set { _vertexBase = value; } } 79 public Vector3[] VertexBase { get { return _vertexBase; } set { _vertexBase = value; } }
80 public int VertexStride { get { return _vertexStride; } set { _vertexStride = value; } } 80 public int VertexStride { get { return _vertexStride; } set { _vertexStride = value; } }
81 } 81 }
82 82
83 /// <summary> 83 /// <summary>
84 /// TriangleIndexVertexArray allows to use multiple meshes, by indexing into existing triangle/index arrays. 84 /// TriangleIndexVertexArray allows to use multiple meshes, by indexing into existing triangle/index arrays.
85 /// Additional meshes can be added using addIndexedMesh 85 /// Additional meshes can be added using addIndexedMesh
86 /// </summary> 86 /// </summary>
87 public class TriangleIndexVertexArray : XnaDevRu.BulletX.StridingMeshInterface 87 public class TriangleIndexVertexArray : XnaDevRu.BulletX.StridingMeshInterface
88 { 88 {
89 List<IndexedMesh> _indexedMeshes = new List<IndexedMesh>(); 89 List<IndexedMesh> _indexedMeshes = new List<IndexedMesh>();
90 90
91 public TriangleIndexVertexArray() { } 91 public TriangleIndexVertexArray() { }
92 92
93 public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) 93 public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride)
94 { 94 {
95 IndexedMesh mesh = new IndexedMesh(); 95 IndexedMesh mesh = new IndexedMesh();
96 mesh.TriangleCount = numTriangleIndices; 96 mesh.TriangleCount = numTriangleIndices;
97 mesh.TriangleIndexBase = triangleIndexBase; 97 mesh.TriangleIndexBase = triangleIndexBase;
98 mesh.TriangleIndexStride = triangleIndexStride; 98 mesh.TriangleIndexStride = triangleIndexStride;
99 mesh.VertexBase = vertexBase; 99 mesh.VertexBase = vertexBase;
100 mesh.VertexCount = numVertices; 100 mesh.VertexCount = numVertices;
101 mesh.VertexStride = vertexStride; 101 mesh.VertexStride = vertexStride;
102 102
103 AddIndexedMesh(mesh); 103 AddIndexedMesh(mesh);
104 } 104 }
105 105
106 public TriangleIndexVertexArray(int[] triangleIndexBase, Vector3[] vertexBase) 106 public TriangleIndexVertexArray(int[] triangleIndexBase, Vector3[] vertexBase)
107 : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) { } 107 : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) { }
108 108
109 public void AddIndexedMesh(IndexedMesh indexedMesh) 109 public void AddIndexedMesh(IndexedMesh indexedMesh)
110 { 110 {
111 _indexedMeshes.Add(indexedMesh); 111 _indexedMeshes.Add(indexedMesh);
112 } 112 }
113 113
114 public override void GetLockedVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) 114 public override void GetLockedVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart)
115 { 115 {
116 throw new Exception("The method or operation is not implemented."); 116 throw new Exception("The method or operation is not implemented.");
117 } 117 }
118 118
119 public override void GetLockedReadOnlyVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) 119 public override void GetLockedReadOnlyVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart)
120 { 120 {
121 IndexedMesh m = _indexedMeshes[0]; 121 IndexedMesh m = _indexedMeshes[0];
122 Vector3[] vertexBase = m.VertexBase; 122 Vector3[] vertexBase = m.VertexBase;
123 verts = new List<Vector3>(); 123 verts = new List<Vector3>();
124 foreach (Vector3 v in vertexBase) 124 foreach (Vector3 v in vertexBase)
125 { 125 {
126 verts.Add(v); 126 verts.Add(v);
127 } 127 }
128 int[] indexBase = m.TriangleIndexBase; 128 int[] indexBase = m.TriangleIndexBase;
129 indicies = new List<int>(); 129 indicies = new List<int>();
130 foreach (int i in indexBase) 130 foreach (int i in indexBase)
131 { 131 {
132 indicies.Add(i); 132 indicies.Add(i);
133 } 133 }
134 numfaces = vertexBase.GetLength(0); 134 numfaces = vertexBase.GetLength(0);
135 } 135 }
136 136
137 public override void UnLockVertexBase(int subpart) 137 public override void UnLockVertexBase(int subpart)
138 { 138 {
139 throw new Exception("The method or operation is not implemented."); 139 throw new Exception("The method or operation is not implemented.");
140 } 140 }
141 141
142 public override void UnLockReadOnlyVertexBase(int subpart) 142 public override void UnLockReadOnlyVertexBase(int subpart)
143 { 143 {
144 } 144 }
145 145
146 public override int SubPartsCount() 146 public override int SubPartsCount()
147 { 147 {
148 return _indexedMeshes.Count; 148 return _indexedMeshes.Count;
149 } 149 }
150 150
151 public override void PreallocateVertices(int numverts) 151 public override void PreallocateVertices(int numverts)
152 { 152 {
153 throw new Exception("The method or operation is not implemented."); 153 throw new Exception("The method or operation is not implemented.");
154 } 154 }
155 155
156 public override void PreallocateIndices(int numindices) 156 public override void PreallocateIndices(int numindices)
157 { 157 {
158 throw new Exception("The method or operation is not implemented."); 158 throw new Exception("The method or operation is not implemented.");
159 } 159 }
160 } 160 }
161} 161}