diff options
author | Teravus Ovares | 2008-09-06 07:52:41 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-09-06 07:52:41 +0000 |
commit | 7d89e122930be39e84a6d174548fa2d12ac0484a (patch) | |
tree | e5aa5752f988a9aba2a969f49e5e208985eda80c /OpenSim/Region/Physics/Meshing | |
parent | * minor: speculatively try a change to bamboo.build to see if this generates ... (diff) | |
download | opensim-SC_OLD-7d89e122930be39e84a6d174548fa2d12ac0484a.zip opensim-SC_OLD-7d89e122930be39e84a6d174548fa2d12ac0484a.tar.gz opensim-SC_OLD-7d89e122930be39e84a6d174548fa2d12ac0484a.tar.bz2 opensim-SC_OLD-7d89e122930be39e84a6d174548fa2d12ac0484a.tar.xz |
* This is the fabled LibOMV update with all of the libOMV types from JHurliman
* This is a HUGE OMG update and will definitely have unknown side effects.. so this is really only for the strong hearted at this point. Regular people should let the dust settle.
* This has been tested to work with most basic functions. However.. make sure you back up 'everything' before using this. It's that big!
* Essentially we're back at square 1 in the testing phase.. so lets identify things that broke.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/Extruder.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Meshing/HelperTypes.cs | 110 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Meshing/PrimMesher.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Meshing/SculptMesh.cs | 7 |
5 files changed, 41 insertions, 103 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs index a47b6ae..1fc65e3 100644 --- a/OpenSim/Region/Physics/Meshing/Extruder.cs +++ b/OpenSim/Region/Physics/Meshing/Extruder.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | //#define SPAM | 27 | //#define SPAM |
28 | 28 | ||
29 | using OpenMetaverse; | ||
29 | using OpenSim.Region.Physics.Manager; | 30 | using OpenSim.Region.Physics.Manager; |
30 | 31 | ||
31 | namespace OpenSim.Region.Physics.Meshing | 32 | namespace OpenSim.Region.Physics.Meshing |
@@ -72,9 +73,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
72 | { | 73 | { |
73 | Mesh result = new Mesh(); | 74 | Mesh result = new Mesh(); |
74 | 75 | ||
75 | // Quaternion tt = new Quaternion(); | ||
76 | // Vertex v2 = new Vertex(0, 0, 0); | ||
77 | |||
78 | Mesh newLayer; | 76 | Mesh newLayer; |
79 | Mesh lastLayer = null; | 77 | Mesh lastLayer = null; |
80 | 78 | ||
@@ -163,7 +161,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
163 | 161 | ||
164 | // apply twist rotation to the profile layer and position the layer in the prim | 162 | // apply twist rotation to the profile layer and position the layer in the prim |
165 | 163 | ||
166 | Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), twist); | 164 | Quaternion profileRot = Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), twist); |
167 | foreach (Vertex v in newLayer.vertices) | 165 | foreach (Vertex v in newLayer.vertices) |
168 | { | 166 | { |
169 | if (v != null) | 167 | if (v != null) |
@@ -259,9 +257,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
259 | { | 257 | { |
260 | Mesh result = new Mesh(); | 258 | Mesh result = new Mesh(); |
261 | 259 | ||
262 | // Quaternion tt = new Quaternion(); | ||
263 | // Vertex v2 = new Vertex(0, 0, 0); | ||
264 | |||
265 | Mesh newLayer; | 260 | Mesh newLayer; |
266 | Mesh lastLayer = null; | 261 | Mesh lastLayer = null; |
267 | 262 | ||
@@ -377,7 +372,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
377 | // next apply twist rotation to the profile layer | 372 | // next apply twist rotation to the profile layer |
378 | if (twistTotal != 0.0f || twistBot != 0.0f) | 373 | if (twistTotal != 0.0f || twistBot != 0.0f) |
379 | { | 374 | { |
380 | Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), twist); | 375 | Quaternion profileRot = new Quaternion(new Vector3(0.0f, 0.0f, 1.0f), twist); |
381 | foreach (Vertex v in newLayer.vertices) | 376 | foreach (Vertex v in newLayer.vertices) |
382 | { | 377 | { |
383 | if (v != null) | 378 | if (v != null) |
@@ -392,7 +387,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
392 | 387 | ||
393 | // now orient the rotation of the profile layer relative to it's position on the path | 388 | // now orient the rotation of the profile layer relative to it's position on the path |
394 | // adding pushY to the angle used to generate the quat appears to approximate the viewer | 389 | // adding pushY to the angle used to generate the quat appears to approximate the viewer |
395 | Quaternion layerRot = new Quaternion(new Vertex(1.0f, 0.0f, 0.0f), (float)angle + pushY * 0.9f); | 390 | Quaternion layerRot = Quaternion.CreateFromAxisAngle(new Vector3(1.0f, 0.0f, 0.0f), (float)angle + pushY * 0.9f); |
396 | foreach (Vertex v in newLayer.vertices) | 391 | foreach (Vertex v in newLayer.vertices) |
397 | { | 392 | { |
398 | if (v != null) | 393 | if (v != null) |
diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs index 2cb8d04..7491782 100644 --- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs +++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs | |||
@@ -29,70 +29,10 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; | 30 | using System.Diagnostics; |
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using OpenMetaverse; | ||
32 | using OpenSim.Region.Physics.Manager; | 33 | using OpenSim.Region.Physics.Manager; |
33 | using OpenSim.Region.Physics.Meshing; | 34 | using OpenSim.Region.Physics.Meshing; |
34 | 35 | ||
35 | public class Quaternion | ||
36 | { | ||
37 | public float x = 0; | ||
38 | public float y = 0; | ||
39 | public float z = 0; | ||
40 | public float w = 1; | ||
41 | |||
42 | public Quaternion() | ||
43 | { | ||
44 | |||
45 | } | ||
46 | public Quaternion(float x1, float y1, float z1, float w1) | ||
47 | { | ||
48 | x = x1; y = y1; z = z1; w = w1; | ||
49 | } | ||
50 | public Quaternion(Vertex axis, float angle) | ||
51 | { | ||
52 | // using (* 0.5) instead of (/2) | ||
53 | w = (float)Math.Cos(angle * 0.5f); | ||
54 | float sin = (float)Math.Sin(angle * 0.5f); | ||
55 | //x = axis.X * (float)Math.Sin(angle * 0.5f); | ||
56 | //y = axis.Y * (float)Math.Sin(angle * 0.5f); | ||
57 | //z = axis.Z * (float)Math.Sin(angle * 0.5f); | ||
58 | x = axis.X * sin; | ||
59 | y = axis.Y * sin; | ||
60 | z = axis.Z * sin; | ||
61 | normalize(); | ||
62 | } | ||
63 | public static Quaternion operator *(Quaternion a, Quaternion b) | ||
64 | { | ||
65 | Quaternion c = new Quaternion(); | ||
66 | c.x = a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y; | ||
67 | c.y = a.w * b.y + a.y * b.w + a.z * b.x - a.x * b.z; | ||
68 | c.z = a.w * b.z + a.z * b.w + a.x * b.y - a.y * b.x; | ||
69 | c.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z; | ||
70 | return c; | ||
71 | } | ||
72 | |||
73 | public void normalize() | ||
74 | { | ||
75 | //float mag = length(); | ||
76 | |||
77 | //w /= mag; | ||
78 | //x /= mag; | ||
79 | //y /= mag; | ||
80 | //z /= mag; | ||
81 | float iMag = 1.0f / length(); | ||
82 | |||
83 | w *= iMag; | ||
84 | x *= iMag; | ||
85 | y *= iMag; | ||
86 | z *= iMag; | ||
87 | } | ||
88 | public float length() | ||
89 | { | ||
90 | return (float)Math.Sqrt(w * w + x * x + y * y + z * z); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | |||
95 | |||
96 | public class Vertex : PhysicsVector, IComparable<Vertex> | 36 | public class Vertex : PhysicsVector, IComparable<Vertex> |
97 | { | 37 | { |
98 | public Vertex(float x, float y, float z) | 38 | public Vertex(float x, float y, float z) |
@@ -129,34 +69,34 @@ public class Vertex : PhysicsVector, IComparable<Vertex> | |||
129 | 69 | ||
130 | Vertex v2 = new Vertex(0f, 0f, 0f); | 70 | Vertex v2 = new Vertex(0f, 0f, 0f); |
131 | 71 | ||
132 | v2.X = q.w * q.w * v.X + | 72 | v2.X = q.W * q.W * v.X + |
133 | 2f * q.y * q.w * v.Z - | 73 | 2f * q.Y * q.W * v.Z - |
134 | 2f * q.z * q.w * v.Y + | 74 | 2f * q.Z * q.W * v.Y + |
135 | q.x * q.x * v.X + | 75 | q.X * q.X * v.X + |
136 | 2f * q.y * q.x * v.Y + | 76 | 2f * q.Y * q.X * v.Y + |
137 | 2f * q.z * q.x * v.Z - | 77 | 2f * q.Z * q.X * v.Z - |
138 | q.z * q.z * v.X - | 78 | q.Z * q.Z * v.X - |
139 | q.y * q.y * v.X; | 79 | q.Y * q.Y * v.X; |
140 | 80 | ||
141 | v2.Y = | 81 | v2.Y = |
142 | 2f * q.x * q.y * v.X + | 82 | 2f * q.X * q.Y * v.X + |
143 | q.y * q.y * v.Y + | 83 | q.Y * q.Y * v.Y + |
144 | 2f * q.z * q.y * v.Z + | 84 | 2f * q.Z * q.Y * v.Z + |
145 | 2f * q.w * q.z * v.X - | 85 | 2f * q.W * q.Z * v.X - |
146 | q.z * q.z * v.Y + | 86 | q.Z * q.Z * v.Y + |
147 | q.w * q.w * v.Y - | 87 | q.W * q.W * v.Y - |
148 | 2f * q.x * q.w * v.Z - | 88 | 2f * q.X * q.W * v.Z - |
149 | q.x * q.x * v.Y; | 89 | q.X * q.X * v.Y; |
150 | 90 | ||
151 | v2.Z = | 91 | v2.Z = |
152 | 2f * q.x * q.z * v.X + | 92 | 2f * q.X * q.Z * v.X + |
153 | 2f * q.y * q.z * v.Y + | 93 | 2f * q.Y * q.Z * v.Y + |
154 | q.z * q.z * v.Z - | 94 | q.Z * q.Z * v.Z - |
155 | 2f * q.w * q.y * v.X - | 95 | 2f * q.W * q.Y * v.X - |
156 | q.y * q.y * v.Z + | 96 | q.Y * q.Y * v.Z + |
157 | 2f * q.w * q.x * v.Y - | 97 | 2f * q.W * q.X * v.Y - |
158 | q.x * q.x * v.Z + | 98 | q.X * q.X * v.Z + |
159 | q.w * q.w * v.Z; | 99 | q.W * q.W * v.Z; |
160 | 100 | ||
161 | return v2; | 101 | return v2; |
162 | } | 102 | } |
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index ecde92a..f955c52 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs | |||
@@ -30,6 +30,7 @@ using System; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Region.Physics.Manager; | 32 | using OpenSim.Region.Physics.Manager; |
33 | using OpenMetaverse; | ||
33 | 34 | ||
34 | namespace OpenSim.Region.Physics.Meshing | 35 | namespace OpenSim.Region.Physics.Meshing |
35 | { | 36 | { |
@@ -1559,7 +1560,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
1559 | 1560 | ||
1560 | if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) | 1561 | if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) |
1561 | { | 1562 | { |
1562 | Quaternion zFlip = new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), (float)Math.PI); | 1563 | Quaternion zFlip = Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), (float)Math.PI); |
1563 | Vertex vTmp = new Vertex(0.0f, 0.0f, 0.0f); | 1564 | Vertex vTmp = new Vertex(0.0f, 0.0f, 0.0f); |
1564 | foreach (Vertex v in cuttedHull.getVertices()) | 1565 | foreach (Vertex v in cuttedHull.getVertices()) |
1565 | if (v != null) | 1566 | if (v != null) |
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index 86bdabc..08b2d10 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using OpenSim.Region.Physics.Manager; | 31 | using OpenSim.Region.Physics.Manager; |
32 | using OpenMetaverse; | ||
32 | 33 | ||
33 | namespace OpenSim.Region.Physics.Meshing | 34 | namespace OpenSim.Region.Physics.Meshing |
34 | { | 35 | { |
@@ -783,7 +784,7 @@ angles24 = [ | |||
783 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides); | 784 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides); |
784 | 785 | ||
785 | if (initialProfileRot != 0.0f) | 786 | if (initialProfileRot != 0.0f) |
786 | profile.AddRot(new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), initialProfileRot)); | 787 | profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot)); |
787 | 788 | ||
788 | bool done = false; | 789 | bool done = false; |
789 | while (!done) | 790 | while (!done) |
@@ -807,7 +808,7 @@ angles24 = [ | |||
807 | 808 | ||
808 | float twist = twistBegin + twistTotal * percentOfPath; | 809 | float twist = twistBegin + twistTotal * percentOfPath; |
809 | if (twist != 0.0f) | 810 | if (twist != 0.0f) |
810 | newLayer.AddRot(new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), twist)); | 811 | newLayer.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), twist)); |
811 | 812 | ||
812 | newLayer.AddPos(xOffset, yOffset, zOffset); | 813 | newLayer.AddPos(xOffset, yOffset, zOffset); |
813 | 814 | ||
@@ -948,7 +949,7 @@ angles24 = [ | |||
948 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides); | 949 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides); |
949 | 950 | ||
950 | if (initialProfileRot != 0.0f) | 951 | if (initialProfileRot != 0.0f) |
951 | profile.AddRot(new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), initialProfileRot)); | 952 | profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot)); |
952 | 953 | ||
953 | bool done = false; | 954 | bool done = false; |
954 | while (!done) // loop through the length of the path and add the layers | 955 | while (!done) // loop through the length of the path and add the layers |
@@ -991,12 +992,12 @@ angles24 = [ | |||
991 | 992 | ||
992 | // next apply twist rotation to the profile layer | 993 | // next apply twist rotation to the profile layer |
993 | if (twistTotal != 0.0f || twistBegin != 0.0f) | 994 | if (twistTotal != 0.0f || twistBegin != 0.0f) |
994 | newLayer.AddRot(new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), twist)); | 995 | newLayer.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), twist)); |
995 | 996 | ||
996 | // now orient the rotation of the profile layer relative to it's position on the path | 997 | // now orient the rotation of the profile layer relative to it's position on the path |
997 | // adding taperY to the angle used to generate the quat appears to approximate the viewer | 998 | // adding taperY to the angle used to generate the quat appears to approximate the viewer |
998 | //newLayer.AddRot(new Quaternion(new Vertex(1.0f, 0.0f, 0.0f), angle + this.topShearY * 0.9f)); | 999 | //newLayer.AddRot(new Quaternion(new Vertex(1.0f, 0.0f, 0.0f), angle + this.topShearY * 0.9f)); |
999 | newLayer.AddRot(new Quaternion(new Vertex(1.0f, 0.0f, 0.0f), angle + this.topShearY)); | 1000 | newLayer.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(1.0f, 0.0f, 0.0f), angle + this.topShearY)); |
1000 | newLayer.AddPos(xOffset, yOffset, zOffset); | 1001 | newLayer.AddPos(xOffset, yOffset, zOffset); |
1001 | 1002 | ||
1002 | if (angle == startAngle) | 1003 | if (angle == startAngle) |
diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index 360b2f7..707c0e3 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs | |||
@@ -30,14 +30,14 @@ using System.Collections.Generic; | |||
30 | using System.Drawing; | 30 | using System.Drawing; |
31 | using System.Drawing.Imaging; | 31 | using System.Drawing.Imaging; |
32 | using System.Text; | 32 | using System.Text; |
33 | using OpenJPEGNet; | 33 | using OpenMetaverse.Imaging; |
34 | using Image = System.Drawing.Image; | ||
35 | 34 | ||
36 | namespace OpenSim.Region.Physics.Meshing | 35 | namespace OpenSim.Region.Physics.Meshing |
37 | { | 36 | { |
38 | // This functionality based on the XNA SculptPreview by John Hurliman. | 37 | // This functionality based on the XNA SculptPreview by John Hurliman. |
39 | public class SculptMesh : Mesh | 38 | public class SculptMesh : Mesh |
40 | { | 39 | { |
40 | ManagedImage managedImage; | ||
41 | Image idata = null; | 41 | Image idata = null; |
42 | Bitmap bLOD = null; | 42 | Bitmap bLOD = null; |
43 | Bitmap bBitmap = null; | 43 | Bitmap bBitmap = null; |
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
55 | 55 | ||
56 | try | 56 | try |
57 | { | 57 | { |
58 | idata = OpenJPEG.DecodeToImage(jpegData); | 58 | OpenJPEG.DecodeToImage(jpegData, out managedImage, out idata); |
59 | //int i = 0; | 59 | //int i = 0; |
60 | //i = i / i; | 60 | //i = i / i; |
61 | } | 61 | } |
@@ -64,6 +64,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
64 | System.Console.WriteLine("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed!"); | 64 | System.Console.WriteLine("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed!"); |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | |||
67 | if (idata != null) | 68 | if (idata != null) |
68 | { | 69 | { |
69 | bBitmap = new Bitmap(idata); | 70 | bBitmap = new Bitmap(idata); |