aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs206
1 files changed, 197 insertions, 9 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 95713e9..6786ac5 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -1,10 +1,39 @@
1using 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
28using System;
2using System.Collections; 29using System.Collections;
3using System.Collections.Generic; 30using System.Collections.Generic;
4using System.IO; 31using System.IO;
5using System.Reflection; 32using System.Reflection;
33using System.Text;
6 34
7using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.StructuredData;
8using Nini.Config; 37using Nini.Config;
9using log4net; 38using log4net;
10 39
@@ -12,11 +41,14 @@ using OpenSim.Framework;
12using OpenSim.Framework.Capabilities; 41using OpenSim.Framework.Capabilities;
13using OpenSim.Region.Framework; 42using OpenSim.Region.Framework;
14using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization;
15using OpenSim.Framework.Servers; 45using OpenSim.Framework.Servers;
16using OpenSim.Framework.Servers.HttpServer; 46using OpenSim.Framework.Servers.HttpServer;
17using OpenSim.Services.Interfaces; 47using OpenSim.Services.Interfaces;
18 48
19using Caps = OpenSim.Framework.Capabilities.Caps; 49using Caps = OpenSim.Framework.Capabilities.Caps;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
20 52
21namespace OpenSim.Region.ClientStack.Linden 53namespace 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,156 @@ 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// int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger();
599// int material = inner_instance_list["material"].AsInteger();
600// int mesh = inner_instance_list["mesh"].AsInteger();
601
602 OSDMap permissions = (OSDMap)inner_instance_list["permissions"];
603 int base_mask = permissions["base_mask"].AsInteger();
604 int everyone_mask = permissions["everyone_mask"].AsInteger();
605 UUID creator_id = permissions["creator_id"].AsUUID();
606 UUID group_id = permissions["group_id"].AsUUID();
607 int group_mask = permissions["group_mask"].AsInteger();
608// bool is_owner_group = permissions["is_owner_group"].AsBoolean();
609// UUID last_owner_id = permissions["last_owner_id"].AsUUID();
610 int next_owner_mask = permissions["next_owner_mask"].AsInteger();
611 UUID owner_id = permissions["owner_id"].AsUUID();
612 int owner_mask = permissions["owner_mask"].AsInteger();
613
614 SceneObjectPart prim
615 = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero);
616
617 prim.Scale = scale;
618 prim.OffsetPosition = position;
619 rotations.Add(rotation);
620 positions.Add(position);
621 prim.UUID = UUID.Random();
622 prim.CreatorID = creator_id;
623 prim.OwnerID = owner_id;
624 prim.GroupID = group_id;
625 prim.LastOwnerID = prim.OwnerID;
626 prim.CreationDate = Util.UnixTimeSinceEpoch();
627 prim.Name = assetName;
628 prim.Description = "";
629
630 prim.BaseMask = (uint)base_mask;
631 prim.EveryoneMask = (uint)everyone_mask;
632 prim.GroupMask = (uint)group_mask;
633 prim.NextOwnerMask = (uint)next_owner_mask;
634 prim.OwnerMask = (uint)owner_mask;
635
636 if (grp == null)
637 grp = new SceneObjectGroup(prim);
638 else
639 grp.AddPart(prim);
640 }
641
642 // Fix first link number
643 if (grp.Parts.Length > 1)
644 grp.RootPart.LinkNum++;
645
646 Vector3 rootPos = positions[0];
647 grp.AbsolutePosition = rootPos;
648 for (int i = 0; i < positions.Count; i++)
649 {
650 Vector3 offset = positions[i] - rootPos;
651 grp.Parts[i].OffsetPosition = offset;
652 }
653
654 for (int i = 0; i < rotations.Count; i++)
655 {
656 if (i != 0)
657 grp.Parts[i].RotationOffset = rotations[i];
658 }
659
660 grp.UpdateGroupRotationR(rotations[0]);
661 data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp));
662 }
477 663
478 AssetBase asset; 664 AssetBase asset;
479 asset = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString()); 665 asset = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString());
@@ -506,8 +692,6 @@ namespace OpenSim.Region.ClientStack.Linden
506 } 692 }
507 } 693 }
508 694
509
510
511 /// <summary> 695 /// <summary>
512 /// 696 ///
513 /// </summary> 697 /// </summary>
@@ -632,7 +816,7 @@ namespace OpenSim.Region.ClientStack.Linden
632 } 816 }
633 817
634 /// <summary> 818 /// <summary>
635 /// 819 /// Handle raw asset upload data via the capability.
636 /// </summary> 820 /// </summary>
637 /// <param name="data"></param> 821 /// <param name="data"></param>
638 /// <param name="path"></param> 822 /// <param name="path"></param>
@@ -670,6 +854,7 @@ namespace OpenSim.Region.ClientStack.Linden
670 854
671 return res; 855 return res;
672 } 856 }
857
673 ///Left this in and commented in case there are unforseen issues 858 ///Left this in and commented in case there are unforseen issues
674 //private void SaveAssetToFile(string filename, byte[] data) 859 //private void SaveAssetToFile(string filename, byte[] data)
675 //{ 860 //{
@@ -679,6 +864,7 @@ namespace OpenSim.Region.ClientStack.Linden
679 // bw.Close(); 864 // bw.Close();
680 // fs.Close(); 865 // fs.Close();
681 //} 866 //}
867
682 private static void SaveAssetToFile(string filename, byte[] data) 868 private static void SaveAssetToFile(string filename, byte[] data)
683 { 869 {
684 string assetPath = "UserAssets"; 870 string assetPath = "UserAssets";
@@ -719,7 +905,7 @@ namespace OpenSim.Region.ClientStack.Linden
719 } 905 }
720 906
721 /// <summary> 907 /// <summary>
722 /// 908 /// Handle raw uploaded asset data.
723 /// </summary> 909 /// </summary>
724 /// <param name="data"></param> 910 /// <param name="data"></param>
725 /// <param name="path"></param> 911 /// <param name="path"></param>
@@ -752,6 +938,7 @@ namespace OpenSim.Region.ClientStack.Linden
752 938
753 return res; 939 return res;
754 } 940 }
941
755 ///Left this in and commented in case there are unforseen issues 942 ///Left this in and commented in case there are unforseen issues
756 //private void SaveAssetToFile(string filename, byte[] data) 943 //private void SaveAssetToFile(string filename, byte[] data)
757 //{ 944 //{
@@ -761,6 +948,7 @@ namespace OpenSim.Region.ClientStack.Linden
761 // bw.Close(); 948 // bw.Close();
762 // fs.Close(); 949 // fs.Close();
763 //} 950 //}
951
764 private static void SaveAssetToFile(string filename, byte[] data) 952 private static void SaveAssetToFile(string filename, byte[] data)
765 { 953 {
766 string assetPath = "UserAssets"; 954 string assetPath = "UserAssets";
@@ -839,7 +1027,7 @@ namespace OpenSim.Region.ClientStack.Linden
839 uploadComplete.new_asset = inventoryItemID; 1027 uploadComplete.new_asset = inventoryItemID;
840 uploadComplete.compiled = errors.Count > 0 ? false : true; 1028 uploadComplete.compiled = errors.Count > 0 ? false : true;
841 uploadComplete.state = "complete"; 1029 uploadComplete.state = "complete";
842 uploadComplete.errors = new OSDArray(); 1030 uploadComplete.errors = new OpenSim.Framework.Capabilities.OSDArray();
843 uploadComplete.errors.Array = errors; 1031 uploadComplete.errors.Array = errors;
844 1032
845 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); 1033 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
@@ -905,7 +1093,7 @@ namespace OpenSim.Region.ClientStack.Linden
905 } 1093 }
906 1094
907 /// <summary> 1095 /// <summary>
908 /// 1096 /// Handle raw uploaded baked texture data.
909 /// </summary> 1097 /// </summary>
910 /// <param name="data"></param> 1098 /// <param name="data"></param>
911 /// <param name="path"></param> 1099 /// <param name="path"></param>