diff options
author | Justin Clark-Casey (justincc) | 2011-06-24 21:54:01 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-06-24 21:54:01 +0100 |
commit | 1a0a9d229013ff7abba17ccd95159ca7d4b47e9f (patch) | |
tree | 933ebbc203ae94f80f722cc74504dc3f22533ff9 /OpenSim | |
parent | minor: method documentation (diff) | |
download | opensim-SC_OLD-1a0a9d229013ff7abba17ccd95159ca7d4b47e9f.zip opensim-SC_OLD-1a0a9d229013ff7abba17ccd95159ca7d4b47e9f.tar.gz opensim-SC_OLD-1a0a9d229013ff7abba17ccd95159ca7d4b47e9f.tar.bz2 opensim-SC_OLD-1a0a9d229013ff7abba17ccd95159ca7d4b47e9f.tar.xz |
Implement the latest mesh mechanism so that rezzing the uploaded mesh now works again.
Many thanks to the aurora project for pioneering this.
This code is almost certainly not bug free, but it does at least appear to handle simple meshes (except when the viewer crashes - but it is beta!).
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 192 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 9 |
2 files changed, 195 insertions, 6 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index d52ebda..6786ac5 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) |
@@ -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()); |
@@ -841,7 +1027,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
841 | uploadComplete.new_asset = inventoryItemID; | 1027 | uploadComplete.new_asset = inventoryItemID; |
842 | uploadComplete.compiled = errors.Count > 0 ? false : true; | 1028 | uploadComplete.compiled = errors.Count > 0 ? false : true; |
843 | uploadComplete.state = "complete"; | 1029 | uploadComplete.state = "complete"; |
844 | uploadComplete.errors = new OSDArray(); | 1030 | uploadComplete.errors = new OpenSim.Framework.Capabilities.OSDArray(); |
845 | uploadComplete.errors.Array = errors; | 1031 | uploadComplete.errors.Array = errors; |
846 | 1032 | ||
847 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | 1033 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c6d8c73..f3879f0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -800,7 +800,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
800 | actor.Orientation = GetWorldRotation(); | 800 | actor.Orientation = GetWorldRotation(); |
801 | 801 | ||
802 | // Tell the physics engines that this prim changed. | 802 | // Tell the physics engines that this prim changed. |
803 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 803 | if (m_parentGroup.Scene != null) |
804 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | ||
804 | } | 805 | } |
805 | } | 806 | } |
806 | } | 807 | } |
@@ -1085,11 +1086,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1085 | 1086 | ||
1086 | public Vector3 AbsolutePosition | 1087 | public Vector3 AbsolutePosition |
1087 | { | 1088 | { |
1088 | get { | 1089 | get |
1090 | { | ||
1089 | if (IsAttachment) | 1091 | if (IsAttachment) |
1090 | return GroupPosition; | 1092 | return GroupPosition; |
1091 | 1093 | ||
1092 | return m_offsetPosition + m_groupPosition; } | 1094 | return m_offsetPosition + m_groupPosition; |
1095 | } | ||
1093 | } | 1096 | } |
1094 | 1097 | ||
1095 | public SceneObjectGroup ParentGroup | 1098 | public SceneObjectGroup ParentGroup |