diff options
author | Teravus Ovares | 2008-04-08 01:29:45 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-04-08 01:29:45 +0000 |
commit | d0f77841016291956ff3668b0d67d0a8a56d8f1e (patch) | |
tree | fa9e0c4737c45fb51bee574300e7cd96b68d854f /OpenSim/Region/Physics/Meshing | |
parent | Update svn properties. (diff) | |
download | opensim-SC_OLD-d0f77841016291956ff3668b0d67d0a8a56d8f1e.zip opensim-SC_OLD-d0f77841016291956ff3668b0d67d0a8a56d8f1e.tar.gz opensim-SC_OLD-d0f77841016291956ff3668b0d67d0a8a56d8f1e.tar.bz2 opensim-SC_OLD-d0f77841016291956ff3668b0d67d0a8a56d8f1e.tar.xz |
* Adds poor support for ellipsis in the Meshmerizer. This will get better.. notice the huge nasty facets! Regular spheres still work as they did.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 111 |
1 files changed, 110 insertions, 1 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 6fb4606..d668aa3 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs | |||
@@ -57,7 +57,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
57 | // Setting baseDir to a path will enable the dumping of raw files | 57 | // Setting baseDir to a path will enable the dumping of raw files |
58 | // raw files can be imported by blender so a visual inspection of the results can be done | 58 | // raw files can be imported by blender so a visual inspection of the results can be done |
59 | // const string baseDir = "rawFiles"; | 59 | // const string baseDir = "rawFiles"; |
60 | private const string baseDir = null; // "rawFiles"; | 60 | private const string baseDir = null; //"rawFiles"; |
61 | 61 | ||
62 | // TODO: unused | 62 | // TODO: unused |
63 | // private static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, | 63 | // private static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, |
@@ -204,6 +204,8 @@ namespace OpenSim.Region.Physics.Meshing | |||
204 | } | 204 | } |
205 | } | 205 | } |
206 | break; | 206 | break; |
207 | |||
208 | |||
207 | default: | 209 | default: |
208 | if (hshape == HollowShape.Same) | 210 | if (hshape == HollowShape.Same) |
209 | hshape= HollowShape.Square; | 211 | hshape= HollowShape.Square; |
@@ -986,6 +988,105 @@ namespace OpenSim.Region.Physics.Meshing | |||
986 | result.DumpRaw(baseDir, primName, "Z extruded"); | 988 | result.DumpRaw(baseDir, primName, "Z extruded"); |
987 | return result; | 989 | return result; |
988 | } | 990 | } |
991 | private static Mesh CreateSphereMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) | ||
992 | // Builds the z (+ and -) surfaces of a box shaped prim | ||
993 | { | ||
994 | UInt16 hollowFactor = primShape.ProfileHollow; | ||
995 | UInt16 profileBegin = primShape.ProfileBegin; | ||
996 | UInt16 profileEnd = primShape.ProfileEnd; | ||
997 | UInt16 taperX = primShape.PathScaleX; | ||
998 | UInt16 taperY = primShape.PathScaleY; | ||
999 | UInt16 pathShearX = primShape.PathShearX; | ||
1000 | UInt16 pathShearY = primShape.PathShearY; | ||
1001 | Mesh m = new Mesh(); | ||
1002 | float radius = 0.6f; | ||
1003 | float sq5 = (float) Math.Sqrt(5.0); | ||
1004 | float phi = (1 + sq5) * 0.5f; | ||
1005 | float rat = (float) Math.Sqrt(10f + (2f * sq5)) / (4f * phi); | ||
1006 | float a = (radius / rat) * 0.5f; | ||
1007 | float b = (radius / rat) / (2.0f * phi); | ||
1008 | |||
1009 | Vertex v1 = new Vertex(0f, b, -a); | ||
1010 | Vertex v2 = new Vertex(b, a, 0f); | ||
1011 | Vertex v3 = new Vertex(-b, a, 0f); | ||
1012 | Vertex v4 = new Vertex(0f, b, a); | ||
1013 | Vertex v5 = new Vertex(0f, -b, a); | ||
1014 | Vertex v6 = new Vertex(-a, 0f, b); | ||
1015 | Vertex v7 = new Vertex(0f, -b, -a); | ||
1016 | Vertex v8 = new Vertex(a, 0f, -b); | ||
1017 | Vertex v9 = new Vertex(a, 0f, b); | ||
1018 | Vertex v10 = new Vertex(-a, 0f, -b); | ||
1019 | Vertex v11 = new Vertex(b, -a, 0); | ||
1020 | Vertex v12 = new Vertex(-b, -a, 0); | ||
1021 | m.Add(v1); | ||
1022 | m.Add(v2); | ||
1023 | m.Add(v3); | ||
1024 | m.Add(v4); | ||
1025 | m.Add(v5); | ||
1026 | m.Add(v6); | ||
1027 | m.Add(v7); | ||
1028 | m.Add(v8); | ||
1029 | m.Add(v9); | ||
1030 | m.Add(v10); | ||
1031 | m.Add(v11); | ||
1032 | m.Add(v12); | ||
1033 | |||
1034 | Triangle t1 = new Triangle(v1, v2, v3); | ||
1035 | Triangle t2 = new Triangle(v4, v3, v2); | ||
1036 | Triangle t3 = new Triangle(v4, v5, v6); | ||
1037 | Triangle t4 = new Triangle(v4, v9, v5); | ||
1038 | Triangle t5 = new Triangle(v1, v7, v8); | ||
1039 | Triangle t6 = new Triangle(v1, v10, v7); | ||
1040 | Triangle t7 = new Triangle(v5, v11, v12); | ||
1041 | Triangle t8 = new Triangle(v7, v12, v11); | ||
1042 | Triangle t9 = new Triangle(v3, v6, v10); | ||
1043 | Triangle t10 = new Triangle(v12, v10, v6); | ||
1044 | Triangle t11 = new Triangle(v2, v8, v9); | ||
1045 | Triangle t12 = new Triangle(v11, v9, v8); | ||
1046 | Triangle t13 = new Triangle(v4, v6, v3); | ||
1047 | Triangle t14 = new Triangle(v4, v2, v9); | ||
1048 | Triangle t15 = new Triangle(v1, v3, v10); | ||
1049 | Triangle t16 = new Triangle(v1, v8, v2); | ||
1050 | Triangle t17 = new Triangle(v7, v10, v12); | ||
1051 | Triangle t18 = new Triangle(v7, v11, v8); | ||
1052 | Triangle t19 = new Triangle(v5, v12, v6); | ||
1053 | Triangle t20 = new Triangle(v5, v9, v11); | ||
1054 | m.Add(t1); | ||
1055 | m.Add(t2); | ||
1056 | m.Add(t3); | ||
1057 | m.Add(t4); | ||
1058 | m.Add(t5); | ||
1059 | m.Add(t6); | ||
1060 | m.Add(t7); | ||
1061 | m.Add(t8); | ||
1062 | m.Add(t9); | ||
1063 | m.Add(t10); | ||
1064 | m.Add(t11); | ||
1065 | m.Add(t12); | ||
1066 | m.Add(t13); | ||
1067 | m.Add(t14); | ||
1068 | m.Add(t15); | ||
1069 | m.Add(t16); | ||
1070 | m.Add(t17); | ||
1071 | m.Add(t18); | ||
1072 | m.Add(t19); | ||
1073 | m.Add(t20); | ||
1074 | |||
1075 | // strechy! | ||
1076 | foreach (Vertex v in m.vertices) | ||
1077 | { | ||
1078 | v.X *= size.X; | ||
1079 | v.Y *= size.Y; | ||
1080 | v.Z *= size.Z; | ||
1081 | } | ||
1082 | foreach (Triangle t in m.triangles) | ||
1083 | { | ||
1084 | t.invertNormal(); | ||
1085 | } | ||
1086 | m.DumpRaw(baseDir, primName, "Z extruded"); | ||
1087 | |||
1088 | return m; | ||
1089 | } | ||
989 | 1090 | ||
990 | public static void CalcNormals(Mesh mesh) | 1091 | public static void CalcNormals(Mesh mesh) |
991 | { | 1092 | { |
@@ -1065,6 +1166,14 @@ namespace OpenSim.Region.Physics.Meshing | |||
1065 | CalcNormals(mesh); | 1166 | CalcNormals(mesh); |
1066 | } | 1167 | } |
1067 | break; | 1168 | break; |
1169 | case ProfileShape.HalfCircle: | ||
1170 | if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
1171 | { | ||
1172 | mesh = CreateSphereMesh(primName, primShape, size); | ||
1173 | CalcNormals(mesh); | ||
1174 | } | ||
1175 | break; | ||
1176 | |||
1068 | case ProfileShape.EquilateralTriangle: | 1177 | case ProfileShape.EquilateralTriangle: |
1069 | mesh = CreatePrismMesh(primName, primShape, size); | 1178 | mesh = CreatePrismMesh(primName, primShape, size); |
1070 | CalcNormals(mesh); | 1179 | CalcNormals(mesh); |