public SceneObjectGroup GetRezReadySceneObject(TaskInventoryItem item)
        {
            AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());

            if (null == rezAsset)
            {
                m_log.WarnFormat(
                    "[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}",
                    item.AssetID, item.Name, m_part.Name);
                return(null);
            }

            string           xmlData = Utils.BytesToString(rezAsset.Data);
            SceneObjectGroup group   = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);

            group.ResetIDs();

            SceneObjectPart rootPart = group.GetChildPart(group.UUID);

            // Since renaming the item in the inventory does not affect the name stored
            // in the serialization, transfer the correct name from the inventory to the
            // object itself before we rez.
            rootPart.Name        = item.Name;
            rootPart.Description = item.Description;

            SceneObjectPart[] partList = group.Parts;

            group.SetGroup(m_part.GroupID, null);

            if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
            {
                if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
                {
                    foreach (SceneObjectPart part in partList)
                    {
                        part.EveryoneMask  = item.EveryonePermissions;
                        part.NextOwnerMask = item.NextPermissions;
                    }

                    group.ApplyNextOwnerPermissions();
                }
            }

            foreach (SceneObjectPart part in partList)
            {
                if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
                {
                    part.LastOwnerID = part.OwnerID;
                    part.OwnerID     = item.OwnerID;
                    part.Inventory.ChangeInventoryOwner(item.OwnerID);
                }

                part.EveryoneMask  = item.EveryonePermissions;
                part.NextOwnerMask = item.NextPermissions;
            }

            rootPart.TrimPermissions();

            return(group);
        }
예제 #2
0
        /// <summary>
        /// Handle the update of an object's user group.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="groupID"></param>
        /// <param name="objectLocalID"></param>
        /// <param name="Garbage"></param>
        private void HandleObjectGroupUpdate(
            IClientAPI remoteClient, UUID groupID, uint objectLocalID, UUID Garbage)
        {
            if (m_groupsModule == null)
            {
                return;
            }

            // XXX: Might be better to get rid of this special casing and have GetMembershipData return something
            // reasonable for a UUID.Zero group.
            if (groupID != UUID.Zero)
            {
                GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, remoteClient.AgentId);

                if (gmd == null)
                {
//                    m_log.WarnFormat(
//                        "[GROUPS]: User {0} is not a member of group {1} so they can't update {2} to this group",
//                        remoteClient.Name, GroupID, objectLocalID);

                    return;
                }
            }

            SceneObjectGroup so = ((Scene)remoteClient.Scene).GetGroupByPrim(objectLocalID);

            if (so != null)
            {
                if (so.OwnerID == remoteClient.AgentId)
                {
                    so.SetGroup(groupID, remoteClient);
                    EventManager.TriggerParcelPrimCountTainted();
                }
            }
        }
예제 #3
0
파일: Scene.cs 프로젝트: CCIR/opensim
        public virtual SceneObjectGroup AddNewPrim(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            //m_log.DebugFormat(
            //    "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);

            SceneObjectGroup sceneObject = null;
            
            // If an entity creator has been registered for this prim type then use that
            if (m_entityCreators.ContainsKey((PCode)shape.PCode))
            {
                sceneObject = m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape);
            }
            else
            {
                // Otherwise, use this default creation code;
                sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
                AddNewSceneObject(sceneObject, true);
                sceneObject.SetGroup(groupID, null);
            }

            if (UserManagementModule != null)
                sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);

            sceneObject.ScheduleGroupForFullUpdate();

            return sceneObject;
        }
예제 #4
0
        /// <summary>
        /// Create a New SceneObjectGroup/Part by raycasting
        /// </summary>
        /// <param name="ownerID"></param>
        /// <param name="groupID"></param>
        /// <param name="RayEnd"></param>
        /// <param name="rot"></param>
        /// <param name="shape"></param>
        /// <param name="bypassRaycast"></param>
        /// <param name="RayStart"></param>
        /// <param name="RayTargetID"></param>
        /// <param name="RayEndIsIntersection"></param>
        public virtual ISceneEntity AddNewPrim(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            //m_log.DebugFormat(
            //    "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);

            SceneObjectGroup sceneObject = new SceneObjectGroup (ownerID, pos, rot, shape, m_DefaultObjectName, m_parentScene);

            // If an entity creator has been registered for this prim type then use that
            if (m_entityCreators.ContainsKey((PCode)shape.PCode))
            {
                sceneObject = (SceneObjectGroup)m_entityCreators[(PCode)shape.PCode].CreateEntity (sceneObject, ownerID, groupID, pos, rot, shape);
            }
            else
            {
                // Otherwise, use this default creation code;
                
                sceneObject.SetGroup(groupID, null);
                AddPrimToScene(sceneObject);
                sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.FullUpdate);
            }


            return sceneObject;
        }
예제 #5
0
파일: Scene.cs 프로젝트: Ideia-Boa/opensim
        public virtual SceneObjectGroup AddNewPrim(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            //m_log.DebugFormat(
            //    "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);

            // If an entity creator has been registered for this prim type then use that
            if (m_entityCreators.ContainsKey((PCode)shape.PCode))
                return m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape);

            // Otherwise, use this default creation code;
            SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
            AddNewSceneObject(sceneObject, true);
            sceneObject.SetGroup(groupID, null);

            return sceneObject;
        }
예제 #6
0
        public virtual SceneObjectGroup AddNewPrim(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            //m_log.DebugFormat(
            //    "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);

            SceneObjectGroup sceneObject = null;

            // If an entity creator has been registered for this prim type then use that
            if (m_entityCreators.ContainsKey((PCode)shape.PCode))
            {
                sceneObject = m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape);
            }
            else
            {
                // Otherwise, use this default creation code;
                sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
                AddNewSceneObject(sceneObject, true);
                sceneObject.SetGroup(groupID, null);

                if (AgentPreferencesService != null) // This will override the brave new full perm world!
                {
                    AgentPrefs prefs = AgentPreferencesService.GetAgentPreferences(ownerID);
                    // Only apply user selected prefs if the user set them
                    if (prefs != null && prefs.PermNextOwner != 0)
                    {
                        sceneObject.RootPart.GroupMask = (uint)prefs.PermGroup;
                        sceneObject.RootPart.EveryoneMask = (uint)prefs.PermEveryone;
                        sceneObject.RootPart.NextOwnerMask = (uint)prefs.PermNextOwner;
                    }
                }
            }

            if (UserManagementModule != null)
                sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);

            sceneObject.ScheduleGroupForFullUpdate();

            return sceneObject;
        }
예제 #7
0
        public virtual SceneObjectGroup RezPrim(SceneObjectPart sourcePart, SceneObjectPart newPart, int param, out string reason)
        {
            // Rez object
            Vector3 pos = newPart.AbsolutePosition;
            SceneObjectGroup group = new SceneObjectGroup(newPart);
            bool isTemp = (group.RootPart.GetEffectiveObjectFlags() & PrimFlags.TemporaryOnRez) != 0;

            ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
            if (parcel == null)
            {
                reason = "land";
                return null;
            }

            // Pass 0 for landImpact here so that it can be tested separately.
            if (!Permissions.CanRezObject(0, newPart.OwnerID, sourcePart.UUID, pos, isTemp))
            {
                reason = "permission";
                return null;
            }

            if (!CheckLandImpact(parcel, group.LandImpact, out reason))
            {
                return null;
            }

            // Check for grey goo fence
            if (!CheckGreyGoo(sourcePart, group))
            {
                reason = "fence";
                return null;
            }

            // Allowing the rez... update the last rez time and the new group fields
            sourcePart.StampLastRez();
            group.CurrentParcel = parcel;   // initialize _currentParcel (and auto-return)
            group.SetGeneration(group.RootPart.Generation); // now update the rest of the parts
            group.ResetIDs();

            //set the group's group before setting the object's position.
            //this will make sure that the group id is correct during the script
            //engine's group check
            group.SetGroup(sourcePart.ParentGroup.RootPart.GroupID, null);

            AddNewSceneObject(group, !isTemp);

            SceneObjectPart rootPart = group.GetChildPart(group.UUID);

            rootPart.TrimPermissions();

            if (group.RootPart.IsPrim)
            {
                group.ClearPartAttachmentData();
            }

            group.CreateScriptInstances(param, ScriptStartFlags.PostOnRez, DefaultScriptEngine, (int)ScriptStateSource.PrimData, null);
            rootPart.ScheduleFullUpdate(PrimUpdateFlags.ForcedFullUpdate);

            reason = "success";
            return rootPart.ParentGroup;
        }
예제 #8
0
        private SceneObjectGroup RezSingleObjectToWorld(IClientAPI remoteClient, UUID itemID, 
            SceneObjectGroup group, Vector3 RayEnd, Vector3 RayStart,
            UUID RayTargetID, byte BypassRayCast, byte bRayEndIsIntersection,
            bool RezSelected, bool attachment, Vector3 pos, string name,
            string description, IInventoryItem item, ItemPermissionBlock itemPermissions,
            int? startParam, UUID? newAvatarGroupId, UUID? rezzedByObjectUUID)
        {
            bool ownerChanged = false;  // record this for the CHANGED_OWNER changed event

            if (IsBadUserLoad(group))
            {
                if (remoteClient != null)
                    remoteClient.SendAgentAlertMessage("You are currently not allowed to rez objects in this region.", false);
                return null;   // already reported above
            }
            if (IsBlacklistedLoad(group))
            {
                if (remoteClient != null)
                    remoteClient.SendAgentAlertMessage("Cannot rez blacklisted object '" + group.Name + "'.", false);
                return null;   // already reported above
            }

            //set the group here so that positioning in world will enable/disable the
            //script correctly based on the group the use is currently in

            // Initialize the server weight (LI)
            group.RecalcPrimWeights();

            group.RezzedFromFolderId = item.Folder;
            //group.FromAssetId = item.AssetID; //not needed yet

            if (newAvatarGroupId.HasValue)
            {
                //set the object's land group
                group.SetGroup(newAvatarGroupId.Value, null);
            }

            if (attachment)
            {
                group.SetFromItemID(itemID);
            }
            else
            {
                group.RootPart.SetGroupPositionDirect(pos);

                if (RezSelected)
                {
                    //also tell the client there is a new object being rezzed
                    foreach (SceneObjectPart part in group.GetParts())
                    {
                        part.AddFlag(PrimFlags.CreateSelected);
                    }
                }
            }

            SceneObjectPart rootPart = group.GetChildPart(group.UUID);
            if (rootPart == null) {
                string what = "object ";
                if (attachment)
                    what = " attachment ";
                m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + what + " root part not found.");
                return null;
            }

            // Since renaming the item in the inventory does not affect the name stored
            // in the serialization, transfer the correct name from the inventory to the
            // object itself before we rez.
            rootPart.Name = name;
            rootPart.Description = description;

            var partList = group.GetParts();

            foreach (SceneObjectPart part in partList)
            {
                /// This fixes inconsistencies between this part and the root part.
                /// In the past, there was a bug in Link operations that did not force 
                /// these permissions on child prims when linking.
                part.SyncChildPermsWithRoot();
            }

            if (rootPart.OwnerID != item.Owner)
            {
                if (Permissions.PropagatePermissions())
                {
                    if ((itemPermissions.CurrentPermissions & ScenePermBits.SLAM) != 0)
                    {    // enforce slam bit, apply item perms to the group parts
                        foreach (SceneObjectPart part in partList)
                        {
                            part.EveryoneMask = item.EveryOnePermissions;
                            part.NextOwnerMask = item.NextPermissions;
                            part.GroupMask = 0; // DO NOT propagate here
                        }
                    }
                    group.ApplyNextOwnerPermissions();
                }
            }

            ownerChanged |= group.Rationalize(item.Owner, false);

            foreach (SceneObjectPart part in partList)
            {
                if (part.OwnerID != item.Owner)
                {
                    part.LastOwnerID = part.OwnerID;
                    part.OwnerID = item.Owner;
                    part.Inventory.ChangeInventoryOwner(item.Owner);
                    ownerChanged = true;
                }
                else if (((itemPermissions.CurrentPermissions & ScenePermBits.SLAM) != 0) && (!attachment)) // Slam!
                {
                    part.EveryoneMask = itemPermissions.EveryOnePermissions;
                    part.NextOwnerMask = itemPermissions.NextPermissions;

                    part.GroupMask = 0; // DO NOT propagate here
                }
            }

            rootPart.TrimPermissions();

            if (!attachment)
            {
                if (group.RootPart.IsPrim)
                {
                    group.ClearPartAttachmentData();
                }
            }

            if (this.AddObjectToSceneIfPermitted(group, remoteClient, pos, attachment, rezzedByObjectUUID))
            {
                if (ownerChanged)
                {
                    foreach (SceneObjectPart part in partList)
                        part.TriggerScriptChangedEvent(Changed.OWNER);
                }

                if (!attachment)
                {
                    // Fire on_rez
                    group.CreateScriptInstances(startParam, ScriptStartFlags.PostOnRez, DefaultScriptEngine, (int)ScriptStateSource.PrimData, null);

                    rootPart.ScheduleFullUpdate(PrimUpdateFlags.ForcedFullUpdate);
                }

            } 
            else 
            {
                // The viewer automatically removes no-copy items from inventory on a rez attempt.
                // Since this one did not rez, it's still in inventory so let's "put it back".
                if (remoteClient != null)
                {
                    InventoryItemBase ib = item as InventoryItemBase;

                    if (item != null)
                    {
                        //this is a folder item, not a task item. update the user
                        remoteClient.SendInventoryItemCreateUpdate(ib, 0);
                    }
                }
                return null;
            }

            return rootPart.ParentGroup;
        }
예제 #9
0
        public SceneObjectGroup CreateEntity(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            if (Array.IndexOf(creationCapabilities, (PCode)shape.PCode) < 0)
            {
                m_log.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name);
                return null;
            }

            SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape, m_scene);
            SceneObjectPart rootPart = sceneObject.GetChildPart(sceneObject.UUID);

            rootPart.AddFlag(PrimFlags.Phantom);
            if (rootPart.Shape.PCode != (byte)PCode.Grass)
            {
                // Tree size has to be adapted depending on its type
                switch ((Tree)rootPart.Shape.State)
                {
                    case Tree.Cypress1:
                    case Tree.Cypress2:
                    case Tree.Palm1:
                    case Tree.Palm2:
                    case Tree.WinterAspen:
                        rootPart.Scale = new Vector3(4, 4, 10);
                        break;
                    case Tree.WinterPine1:
                    case Tree.WinterPine2:
                        rootPart.Scale = new Vector3(4, 4, 20);
                        break;

                    case Tree.Dogwood:
                        rootPart.Scale = new Vector3(6.5f, 6.5f, 6.5f);
                        break;

                    // case... other tree types
                    // tree.Scale = new Vector3(?, ?, ?);
                    // break;

                    default:
                        rootPart.Scale = new Vector3(4, 4, 4);
                        break;
                }
            }

            m_scene.AddPrimToScene(sceneObject);
            sceneObject.ScheduleGroupForFullUpdate(PrimUpdateFlags.FullUpdate);
            sceneObject.SetGroup(groupID, null);

            return sceneObject;
        }
예제 #10
0
 public SceneObjectGroup CreateEntity(
     UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
 {
     if (Array.IndexOf(creationCapabilities, (PCode)shape.PCode) < 0)
     {
         m_log.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name);
         return null;
     }
     
     SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
     SceneObjectPart rootPart = sceneObject.GetChildPart(sceneObject.UUID);
     
     // if grass or tree, make phantom
     //rootPart.TrimPermissions();
     rootPart.AddFlag(PrimFlags.Phantom);
     if (rootPart.Shape.PCode != (byte)PCode.Grass)
         AdaptTree(ref shape);
     
     m_scene.AddNewSceneObject(sceneObject, true);
     sceneObject.SetGroup(groupID, null);
     
     return sceneObject;
 }
예제 #11
0
파일: Scene.cs 프로젝트: shangcheng/Aurora
        public virtual SceneObjectGroup AddNewPrim(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            //m_log.DebugFormat(
            //    "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);

            SceneObjectGroup sceneObject = null;
            
            // If an entity creator has been registered for this prim type then use that
            if (m_entityCreators.ContainsKey((PCode)shape.PCode))
            {
                sceneObject = m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape);
            }
            else
            {
                // Otherwise, use this default creation code;
                sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape, this);
                //This has to be set, otherwise it will break things like rezzing objects in an area where crossing is disabled, but rez isn't
                sceneObject.m_lastSignificantPosition = pos;

                AddNewSceneObject(sceneObject, true);
                sceneObject.SetGroup(groupID, null);
            }


            return sceneObject;
        }
예제 #12
0
        public SceneObjectGroup CreateEntity(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            if (Array.IndexOf(creationCapabilities, (PCode)shape.PCode) < 0)
            {
                m_log.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name);
                return null;
            }

            SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
            SceneObjectPart rootPart = sceneObject.GetPart(sceneObject.UUID);

            rootPart.AddFlag(PrimFlags.Phantom);

            m_scene.AddNewSceneObject(sceneObject, true);
            sceneObject.SetGroup(groupID, null);

            return sceneObject;
        }
예제 #13
0
        /// <summary>
        /// Create a New SceneObjectGroup/Part by raycasting
        /// </summary>
        /// <param name="ownerID"></param>
        /// <param name="groupID"></param>
        /// <param name="pos"></param>
        /// <param name="rot"></param>
        /// <param name="shape"></param>
        public virtual ISceneEntity AddNewPrim(
            UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
        {
            SceneObjectGroup sceneObject = new SceneObjectGroup (ownerID, pos, rot, shape, m_DefaultObjectName, m_parentScene);

            // If an entity creator has been registered for this prim type then use that
            if (m_entityCreators.ContainsKey((PCode)shape.PCode))
            {
                sceneObject = (SceneObjectGroup)m_entityCreators[(PCode)shape.PCode].CreateEntity (sceneObject, ownerID, groupID, pos, rot, shape);
            }
            else
            {
                // Otherwise, use this default creation code;
                sceneObject.SetGroup(groupID, ownerID, false);
                AddPrimToScene(sceneObject);
                sceneObject.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
            }


            return sceneObject;
        }