diff options
author | UbitUmarov | 2017-04-25 14:21:01 +0100 |
---|---|---|
committer | UbitUmarov | 2017-04-25 14:21:01 +0100 |
commit | 7c5376f224743358a7640477fedfd9de5b27b48d (patch) | |
tree | a4a1a4ed2046b5b7f953a0158a18f3b702e63cd5 | |
parent | cosmetics on mesh upload encoding of number of faces on pbs shape. Use opensi... (diff) | |
download | opensim-SC_OLD-7c5376f224743358a7640477fedfd9de5b27b48d.zip opensim-SC_OLD-7c5376f224743358a7640477fedfd9de5b27b48d.tar.gz opensim-SC_OLD-7c5376f224743358a7640477fedfd9de5b27b48d.tar.bz2 opensim-SC_OLD-7c5376f224743358a7640477fedfd9de5b27b48d.tar.xz |
move mesh pbs creation code out of mesh upload code into to PrimitiveBaseShape.cs
-rw-r--r-- | OpenSim/Framework/PrimitiveBaseShape.cs | 64 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 85 |
2 files changed, 78 insertions, 71 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 29985d2..a830551 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs | |||
@@ -328,6 +328,70 @@ namespace OpenSim.Framework | |||
328 | return shape; | 328 | return shape; |
329 | } | 329 | } |
330 | 330 | ||
331 | public static PrimitiveBaseShape CreateMesh(int numberOfFaces, UUID meshAssetID) | ||
332 | { | ||
333 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | ||
334 | |||
335 | shape._pathScaleX = 100; | ||
336 | shape._pathScaleY = 100; | ||
337 | |||
338 | if(numberOfFaces <= 0) // oops ? | ||
339 | numberOfFaces = 1; | ||
340 | |||
341 | switch(numberOfFaces) | ||
342 | { | ||
343 | case 1: // torus | ||
344 | shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; | ||
345 | shape.PathCurve = (byte)Extrusion.Curve1; | ||
346 | break; | ||
347 | |||
348 | case 2: // torus with hollow (a sl viewer whould see 4 faces on a hollow sphere) | ||
349 | shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; | ||
350 | shape.PathCurve = (byte)Extrusion.Curve1; | ||
351 | shape.ProfileHollow = 1; | ||
352 | break; | ||
353 | |||
354 | case 3: // cylinder | ||
355 | shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; | ||
356 | shape.PathCurve = (byte)Extrusion.Straight; | ||
357 | break; | ||
358 | |||
359 | case 4: // cylinder with hollow | ||
360 | shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; | ||
361 | shape.PathCurve = (byte)Extrusion.Straight; | ||
362 | shape.ProfileHollow = 1; | ||
363 | break; | ||
364 | |||
365 | case 5: // prism | ||
366 | shape.ProfileCurve = (byte)ProfileShape.EquilateralTriangle | (byte)HollowShape.Triangle; | ||
367 | shape.PathCurve = (byte)Extrusion.Straight; | ||
368 | break; | ||
369 | |||
370 | case 6: // box | ||
371 | shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle; | ||
372 | shape.PathCurve = (byte)Extrusion.Straight; | ||
373 | break; | ||
374 | |||
375 | case 7: // box with hollow | ||
376 | shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle; | ||
377 | shape.PathCurve = (byte)Extrusion.Straight; | ||
378 | shape.ProfileHollow = 1; | ||
379 | break; | ||
380 | |||
381 | default: // 8 faces box with cut | ||
382 | shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle; | ||
383 | shape.PathCurve = (byte)Extrusion.Straight; | ||
384 | shape.ProfileBegin = 1; | ||
385 | break; | ||
386 | } | ||
387 | |||
388 | shape.SculptEntry = true; | ||
389 | shape.SculptType = (byte)OpenMetaverse.SculptType.Mesh; | ||
390 | shape.SculptTexture = meshAssetID; | ||
391 | |||
392 | return shape; | ||
393 | } | ||
394 | |||
331 | public void SetScale(float side) | 395 | public void SetScale(float side) |
332 | { | 396 | { |
333 | _scale = new Vector3(side, side, side); | 397 | _scale = new Vector3(side, side, side); |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 4a5a8e7..e1b9e08 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -946,17 +946,26 @@ namespace OpenSim.Region.ClientStack.Linden | |||
946 | continue; | 946 | continue; |
947 | } | 947 | } |
948 | 948 | ||
949 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); | 949 | OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; |
950 | |||
951 | PrimitiveBaseShape pbs = null; | ||
952 | if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ... | ||
953 | { | ||
954 | int meshindx = inner_instance_list["mesh"].AsInteger(); | ||
955 | if (meshAssets.Count > meshindx) | ||
956 | pbs = PrimitiveBaseShape.CreateMesh(face_list.Count, meshAssets[meshindx]); | ||
957 | } | ||
958 | if(pbs == null) // fallback | ||
959 | pbs = PrimitiveBaseShape.CreateBox(); | ||
950 | 960 | ||
951 | Primitive.TextureEntry textureEntry | 961 | Primitive.TextureEntry textureEntry |
952 | = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); | 962 | = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); |
953 | 963 | ||
954 | |||
955 | OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; | ||
956 | for (uint face = 0; face < face_list.Count; face++) | 964 | for (uint face = 0; face < face_list.Count; face++) |
957 | { | 965 | { |
958 | OSDMap faceMap = (OSDMap)face_list[(int)face]; | 966 | OSDMap faceMap = (OSDMap)face_list[(int)face]; |
959 | Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face); | 967 | |
968 | Primitive.TextureEntryFace f = textureEntry.CreateFace(face); //clone the default | ||
960 | if (faceMap.ContainsKey("fullbright")) | 969 | if (faceMap.ContainsKey("fullbright")) |
961 | f.Fullbright = faceMap["fullbright"].AsBoolean(); | 970 | f.Fullbright = faceMap["fullbright"].AsBoolean(); |
962 | if (faceMap.ContainsKey("diffuse_color")) | 971 | if (faceMap.ContainsKey("diffuse_color")) |
@@ -986,77 +995,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
986 | 995 | ||
987 | if (textures.Count > textureNum) | 996 | if (textures.Count > textureNum) |
988 | f.TextureID = textures[textureNum]; | 997 | f.TextureID = textures[textureNum]; |
989 | else | 998 | |
990 | f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE; | ||
991 | |||
992 | textureEntry.FaceTextures[face] = f; | 999 | textureEntry.FaceTextures[face] = f; |
993 | } | 1000 | } |
994 | |||
995 | pbs.TextureEntry = textureEntry.GetBytes(); | 1001 | pbs.TextureEntry = textureEntry.GetBytes(); |
996 | 1002 | ||
997 | if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ... | ||
998 | { | ||
999 | int meshindx = inner_instance_list["mesh"].AsInteger(); | ||
1000 | if (meshAssets.Count > meshindx) | ||
1001 | { | ||
1002 | pbs.SculptEntry = true; | ||
1003 | pbs.SculptType = (byte)SculptType.Mesh; | ||
1004 | pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction | ||
1005 | // data will be requested from asset on rez (i hope) | ||
1006 | } | ||
1007 | } | ||
1008 | |||
1009 | // faces number to pbs shape for viewers LOD | ||
1010 | // now extended to full faces equivalent | ||
1011 | int nfaces = face_list.Count; | ||
1012 | switch(nfaces) | ||
1013 | { | ||
1014 | case 0: // low oops case | ||
1015 | case 1: // torus | ||
1016 | pbs.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; | ||
1017 | pbs.PathCurve = (byte)Extrusion.Curve1; | ||
1018 | break; | ||
1019 | |||
1020 | case 2: // torus with hollow (a sl viewer whould see 4 faces on a hollow sphere) | ||
1021 | pbs.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; | ||
1022 | pbs.PathCurve = (byte)Extrusion.Curve1; | ||
1023 | pbs.ProfileHollow = 1; | ||
1024 | break; | ||
1025 | |||
1026 | case 3: // cylinder | ||
1027 | pbs.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; | ||
1028 | pbs.PathCurve = (byte)Extrusion.Straight; | ||
1029 | break; | ||
1030 | |||
1031 | case 4: // cylinder with hollow | ||
1032 | pbs.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; | ||
1033 | pbs.PathCurve = (byte)Extrusion.Straight; | ||
1034 | pbs.ProfileHollow = 1; | ||
1035 | break; | ||
1036 | |||
1037 | case 5: // prism | ||
1038 | pbs.ProfileCurve = (byte)ProfileShape.EquilateralTriangle | (byte)HollowShape.Triangle; | ||
1039 | pbs.PathCurve = (byte)Extrusion.Straight; | ||
1040 | break; | ||
1041 | |||
1042 | case 6: // box | ||
1043 | pbs.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle; | ||
1044 | pbs.PathCurve = (byte)Extrusion.Straight; | ||
1045 | break; | ||
1046 | |||
1047 | case 7: // box with hollow | ||
1048 | pbs.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle; | ||
1049 | pbs.PathCurve = (byte)Extrusion.Straight; | ||
1050 | pbs.ProfileHollow = 1; | ||
1051 | break; | ||
1052 | |||
1053 | default: // 8 faces box with cut | ||
1054 | pbs.ProfileCurve = (byte)ProfileCurve.Square | (byte)HollowShape.Triangle; | ||
1055 | pbs.PathCurve = (byte)Extrusion.Straight; | ||
1056 | pbs.ProfileBegin = 1; | ||
1057 | break; | ||
1058 | } | ||
1059 | |||
1060 | Vector3 position = inner_instance_list["position"].AsVector3(); | 1003 | Vector3 position = inner_instance_list["position"].AsVector3(); |
1061 | Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); | 1004 | Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); |
1062 | 1005 | ||