diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 212 |
1 files changed, 202 insertions, 10 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 95713e9..d3bb0bc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -1,10 +1,39 @@ | |||
1 | using System; | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
2 | using System.Collections; | 29 | using System.Collections; |
3 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
4 | using System.IO; | 31 | using System.IO; |
5 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text; | ||
6 | 34 | ||
7 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenMetaverse.StructuredData; | ||
8 | using Nini.Config; | 37 | using Nini.Config; |
9 | using log4net; | 38 | using log4net; |
10 | 39 | ||
@@ -12,11 +41,14 @@ using OpenSim.Framework; | |||
12 | using OpenSim.Framework.Capabilities; | 41 | using OpenSim.Framework.Capabilities; |
13 | using OpenSim.Region.Framework; | 42 | using OpenSim.Region.Framework; |
14 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
15 | using OpenSim.Framework.Servers; | 45 | using OpenSim.Framework.Servers; |
16 | using OpenSim.Framework.Servers.HttpServer; | 46 | using OpenSim.Framework.Servers.HttpServer; |
17 | using OpenSim.Services.Interfaces; | 47 | using OpenSim.Services.Interfaces; |
18 | 48 | ||
19 | using Caps = OpenSim.Framework.Capabilities.Caps; | 49 | using Caps = OpenSim.Framework.Capabilities.Caps; |
50 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
51 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
20 | 52 | ||
21 | namespace OpenSim.Region.ClientStack.Linden | 53 | namespace OpenSim.Region.ClientStack.Linden |
22 | { | 54 | { |
@@ -79,7 +111,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
79 | 111 | ||
80 | private bool m_persistBakedTextures = false; | 112 | private bool m_persistBakedTextures = false; |
81 | private IAssetService m_assetService; | 113 | private IAssetService m_assetService; |
82 | private bool m_dumpAssetsToFile; | 114 | private bool m_dumpAssetsToFile = false; |
83 | private string m_regionName; | 115 | private string m_regionName; |
84 | 116 | ||
85 | public BunchOfCaps(Scene scene, Caps caps) | 117 | public BunchOfCaps(Scene scene, Caps caps) |
@@ -439,7 +471,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
439 | } | 471 | } |
440 | 472 | ||
441 | /// <summary> | 473 | /// <summary> |
442 | /// | 474 | /// Convert raw uploaded data into the appropriate asset and item. |
443 | /// </summary> | 475 | /// </summary> |
444 | /// <param name="assetID"></param> | 476 | /// <param name="assetID"></param> |
445 | /// <param name="inventoryItem"></param> | 477 | /// <param name="inventoryItem"></param> |
@@ -448,6 +480,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
448 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | 480 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, |
449 | string assetType) | 481 | string assetType) |
450 | { | 482 | { |
483 | m_log.DebugFormat( | ||
484 | "Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", | ||
485 | assetID, inventoryItem, inventoryType, assetType); | ||
486 | |||
451 | sbyte assType = 0; | 487 | sbyte assType = 0; |
452 | sbyte inType = 0; | 488 | sbyte inType = 0; |
453 | 489 | ||
@@ -474,6 +510,160 @@ namespace OpenSim.Region.ClientStack.Linden | |||
474 | break; | 510 | break; |
475 | } | 511 | } |
476 | } | 512 | } |
513 | else if (inventoryType == "object") | ||
514 | { | ||
515 | inType = (sbyte)InventoryType.Object; | ||
516 | assType = (sbyte)AssetType.Object; | ||
517 | |||
518 | List<Vector3> positions = new List<Vector3>(); | ||
519 | List<Quaternion> rotations = new List<Quaternion>(); | ||
520 | OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); | ||
521 | OSDArray instance_list = (OSDArray)request["instance_list"]; | ||
522 | OSDArray mesh_list = (OSDArray)request["mesh_list"]; | ||
523 | OSDArray texture_list = (OSDArray)request["texture_list"]; | ||
524 | SceneObjectGroup grp = null; | ||
525 | |||
526 | List<UUID> textures = new List<UUID>(); | ||
527 | for (int i = 0; i < texture_list.Count; i++) | ||
528 | { | ||
529 | AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, ""); | ||
530 | textureAsset.Data = texture_list[i].AsBinary(); | ||
531 | m_assetService.Store(textureAsset); | ||
532 | textures.Add(textureAsset.FullID); | ||
533 | } | ||
534 | |||
535 | for (int i = 0; i < mesh_list.Count; i++) | ||
536 | { | ||
537 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); | ||
538 | |||
539 | Primitive.TextureEntry textureEntry | ||
540 | = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); | ||
541 | OSDMap inner_instance_list = (OSDMap)instance_list[i]; | ||
542 | |||
543 | OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; | ||
544 | for (uint face = 0; face < face_list.Count; face++) | ||
545 | { | ||
546 | OSDMap faceMap = (OSDMap)face_list[(int)face]; | ||
547 | Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face); | ||
548 | if(faceMap.ContainsKey("fullbright")) | ||
549 | f.Fullbright = faceMap["fullbright"].AsBoolean(); | ||
550 | if (faceMap.ContainsKey ("diffuse_color")) | ||
551 | f.RGBA = faceMap["diffuse_color"].AsColor4(); | ||
552 | |||
553 | int textureNum = faceMap["image"].AsInteger(); | ||
554 | float imagerot = faceMap["imagerot"].AsInteger(); | ||
555 | float offsets = (float)faceMap["offsets"].AsReal(); | ||
556 | float offsett = (float)faceMap["offsett"].AsReal(); | ||
557 | float scales = (float)faceMap["scales"].AsReal(); | ||
558 | float scalet = (float)faceMap["scalet"].AsReal(); | ||
559 | |||
560 | if(imagerot != 0) | ||
561 | f.Rotation = imagerot; | ||
562 | |||
563 | if(offsets != 0) | ||
564 | f.OffsetU = offsets; | ||
565 | |||
566 | if (offsett != 0) | ||
567 | f.OffsetV = offsett; | ||
568 | |||
569 | if (scales != 0) | ||
570 | f.RepeatU = scales; | ||
571 | |||
572 | if (scalet != 0) | ||
573 | f.RepeatV = scalet; | ||
574 | |||
575 | if (textures.Count > textureNum) | ||
576 | f.TextureID = textures[textureNum]; | ||
577 | else | ||
578 | f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE; | ||
579 | |||
580 | textureEntry.FaceTextures[face] = f; | ||
581 | } | ||
582 | |||
583 | pbs.TextureEntry = textureEntry.GetBytes(); | ||
584 | |||
585 | AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); | ||
586 | meshAsset.Data = mesh_list[i].AsBinary(); | ||
587 | m_assetService.Store(meshAsset); | ||
588 | |||
589 | pbs.SculptEntry = true; | ||
590 | pbs.SculptTexture = meshAsset.FullID; | ||
591 | pbs.SculptType = (byte)SculptType.Mesh; | ||
592 | pbs.SculptData = meshAsset.Data; | ||
593 | |||
594 | Vector3 position = inner_instance_list["position"].AsVector3(); | ||
595 | Vector3 scale = inner_instance_list["scale"].AsVector3(); | ||
596 | Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); | ||
597 | |||
598 | // no longer used - begin ------------------------ | ||
599 | // int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); | ||
600 | // int material = inner_instance_list["material"].AsInteger(); | ||
601 | // int mesh = inner_instance_list["mesh"].AsInteger(); | ||
602 | |||
603 | // OSDMap permissions = (OSDMap)inner_instance_list["permissions"]; | ||
604 | // int base_mask = permissions["base_mask"].AsInteger(); | ||
605 | // int everyone_mask = permissions["everyone_mask"].AsInteger(); | ||
606 | // UUID creator_id = permissions["creator_id"].AsUUID(); | ||
607 | // UUID group_id = permissions["group_id"].AsUUID(); | ||
608 | // int group_mask = permissions["group_mask"].AsInteger(); | ||
609 | // bool is_owner_group = permissions["is_owner_group"].AsBoolean(); | ||
610 | // UUID last_owner_id = permissions["last_owner_id"].AsUUID(); | ||
611 | // int next_owner_mask = permissions["next_owner_mask"].AsInteger(); | ||
612 | // UUID owner_id = permissions["owner_id"].AsUUID(); | ||
613 | // int owner_mask = permissions["owner_mask"].AsInteger(); | ||
614 | // no longer used - end ------------------------ | ||
615 | |||
616 | UUID owner_id = m_HostCapsObj.AgentID; | ||
617 | |||
618 | SceneObjectPart prim | ||
619 | = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); | ||
620 | |||
621 | prim.Scale = scale; | ||
622 | prim.OffsetPosition = position; | ||
623 | rotations.Add(rotation); | ||
624 | positions.Add(position); | ||
625 | prim.UUID = UUID.Random(); | ||
626 | prim.CreatorID = owner_id; | ||
627 | prim.OwnerID = owner_id; | ||
628 | prim.GroupID = UUID.Zero; | ||
629 | prim.LastOwnerID = prim.OwnerID; | ||
630 | prim.CreationDate = Util.UnixTimeSinceEpoch(); | ||
631 | prim.Name = assetName; | ||
632 | prim.Description = ""; | ||
633 | |||
634 | // prim.BaseMask = (uint)base_mask; | ||
635 | // prim.EveryoneMask = (uint)everyone_mask; | ||
636 | // prim.GroupMask = (uint)group_mask; | ||
637 | // prim.NextOwnerMask = (uint)next_owner_mask; | ||
638 | // prim.OwnerMask = (uint)owner_mask; | ||
639 | |||
640 | if (grp == null) | ||
641 | grp = new SceneObjectGroup(prim); | ||
642 | else | ||
643 | grp.AddPart(prim); | ||
644 | } | ||
645 | |||
646 | // Fix first link number | ||
647 | if (grp.Parts.Length > 1) | ||
648 | grp.RootPart.LinkNum++; | ||
649 | |||
650 | Vector3 rootPos = positions[0]; | ||
651 | grp.AbsolutePosition = rootPos; | ||
652 | for (int i = 0; i < positions.Count; i++) | ||
653 | { | ||
654 | Vector3 offset = positions[i] - rootPos; | ||
655 | grp.Parts[i].OffsetPosition = offset; | ||
656 | } | ||
657 | |||
658 | for (int i = 0; i < rotations.Count; i++) | ||
659 | { | ||
660 | if (i != 0) | ||
661 | grp.Parts[i].RotationOffset = rotations[i]; | ||
662 | } | ||
663 | |||
664 | grp.UpdateGroupRotationR(rotations[0]); | ||
665 | data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); | ||
666 | } | ||
477 | 667 | ||
478 | AssetBase asset; | 668 | AssetBase asset; |
479 | asset = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString()); | 669 | asset = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString()); |
@@ -506,8 +696,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
506 | } | 696 | } |
507 | } | 697 | } |
508 | 698 | ||
509 | |||
510 | |||
511 | /// <summary> | 699 | /// <summary> |
512 | /// | 700 | /// |
513 | /// </summary> | 701 | /// </summary> |
@@ -632,7 +820,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
632 | } | 820 | } |
633 | 821 | ||
634 | /// <summary> | 822 | /// <summary> |
635 | /// | 823 | /// Handle raw asset upload data via the capability. |
636 | /// </summary> | 824 | /// </summary> |
637 | /// <param name="data"></param> | 825 | /// <param name="data"></param> |
638 | /// <param name="path"></param> | 826 | /// <param name="path"></param> |
@@ -670,6 +858,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
670 | 858 | ||
671 | return res; | 859 | return res; |
672 | } | 860 | } |
861 | |||
673 | ///Left this in and commented in case there are unforseen issues | 862 | ///Left this in and commented in case there are unforseen issues |
674 | //private void SaveAssetToFile(string filename, byte[] data) | 863 | //private void SaveAssetToFile(string filename, byte[] data) |
675 | //{ | 864 | //{ |
@@ -679,6 +868,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
679 | // bw.Close(); | 868 | // bw.Close(); |
680 | // fs.Close(); | 869 | // fs.Close(); |
681 | //} | 870 | //} |
871 | |||
682 | private static void SaveAssetToFile(string filename, byte[] data) | 872 | private static void SaveAssetToFile(string filename, byte[] data) |
683 | { | 873 | { |
684 | string assetPath = "UserAssets"; | 874 | string assetPath = "UserAssets"; |
@@ -719,7 +909,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
719 | } | 909 | } |
720 | 910 | ||
721 | /// <summary> | 911 | /// <summary> |
722 | /// | 912 | /// Handle raw uploaded asset data. |
723 | /// </summary> | 913 | /// </summary> |
724 | /// <param name="data"></param> | 914 | /// <param name="data"></param> |
725 | /// <param name="path"></param> | 915 | /// <param name="path"></param> |
@@ -752,6 +942,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
752 | 942 | ||
753 | return res; | 943 | return res; |
754 | } | 944 | } |
945 | |||
755 | ///Left this in and commented in case there are unforseen issues | 946 | ///Left this in and commented in case there are unforseen issues |
756 | //private void SaveAssetToFile(string filename, byte[] data) | 947 | //private void SaveAssetToFile(string filename, byte[] data) |
757 | //{ | 948 | //{ |
@@ -761,6 +952,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
761 | // bw.Close(); | 952 | // bw.Close(); |
762 | // fs.Close(); | 953 | // fs.Close(); |
763 | //} | 954 | //} |
955 | |||
764 | private static void SaveAssetToFile(string filename, byte[] data) | 956 | private static void SaveAssetToFile(string filename, byte[] data) |
765 | { | 957 | { |
766 | string assetPath = "UserAssets"; | 958 | string assetPath = "UserAssets"; |
@@ -839,7 +1031,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
839 | uploadComplete.new_asset = inventoryItemID; | 1031 | uploadComplete.new_asset = inventoryItemID; |
840 | uploadComplete.compiled = errors.Count > 0 ? false : true; | 1032 | uploadComplete.compiled = errors.Count > 0 ? false : true; |
841 | uploadComplete.state = "complete"; | 1033 | uploadComplete.state = "complete"; |
842 | uploadComplete.errors = new OSDArray(); | 1034 | uploadComplete.errors = new OpenSim.Framework.Capabilities.OSDArray(); |
843 | uploadComplete.errors.Array = errors; | 1035 | uploadComplete.errors.Array = errors; |
844 | 1036 | ||
845 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | 1037 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); |
@@ -905,7 +1097,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
905 | } | 1097 | } |
906 | 1098 | ||
907 | /// <summary> | 1099 | /// <summary> |
908 | /// | 1100 | /// Handle raw uploaded baked texture data. |
909 | /// </summary> | 1101 | /// </summary> |
910 | /// <param name="data"></param> | 1102 | /// <param name="data"></param> |
911 | /// <param name="path"></param> | 1103 | /// <param name="path"></param> |
@@ -935,4 +1127,4 @@ namespace OpenSim.Region.ClientStack.Linden | |||
935 | } | 1127 | } |
936 | } | 1128 | } |
937 | 1129 | ||
938 | } | 1130 | } \ No newline at end of file |