本文整理匯總了C#中OpenSim.Region.Framework.Scenes.SceneObjectGroup.SetAttachmentPoint方法的典型用法代碼示例。如果您正苦於以下問題:C# SceneObjectGroup.SetAttachmentPoint方法的具體用法?C# SceneObjectGroup.SetAttachmentPoint怎麽用?C# SceneObjectGroup.SetAttachmentPoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenSim.Region.Framework.Scenes.SceneObjectGroup
的用法示例。
在下文中一共展示了SceneObjectGroup.SetAttachmentPoint方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AttachToAgent
/// <summary>
/// Attach this scene object to the given avatar.
/// </summary>
///
/// This isn't publicly available since attachments should always perform the corresponding inventory
/// operation (to show the attach in user inventory and update the asset with positional information).
///
/// <param name="sp"></param>
/// <param name="so"></param>
/// <param name="attachmentpoint"></param>
/// <param name="AttachOffset"></param>
/// <param name="silent"></param>
protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, int attachmentpoint, Vector3 AttachOffset, bool silent)
{
// don't attach attachments to child agents
if (avatar.IsChildAgent) return;
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
so.DetachFromBackup();
// Remove from database and parcel prim count
m_scene.DeleteFromStorage(so.UUID);
m_scene.EventManager.TriggerParcelPrimCountTainted();
so.RootPart.AttachedAvatar = avatar.UUID;
//Anakin Lohner bug #3839
SceneObjectPart[] parts = so.Parts;
for (int i = 0; i < parts.Length; i++)
parts[i].AttachedAvatar = avatar.UUID;
if (so.RootPart.PhysActor != null)
{
m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor);
so.RootPart.PhysActor = null;
}
so.AbsolutePosition = AttachOffset;
so.RootPart.AttachedPos = AttachOffset;
so.RootPart.IsAttachment = true;
so.RootPart.SetParentLocalId(avatar.LocalId);
so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
avatar.AddAttachment(so);
if (!silent)
{
// Killing it here will cause the client to deselect it
// It then reappears on the avatar, deselected
// through the full update below
//
if (so.IsSelected)
{
m_scene.SendKillObject(so.RootPart.LocalId);
}
so.IsSelected = false; // fudge....
so.ScheduleGroupForFullUpdate(PrimUpdateFlags.FullUpdate);
}
// In case it is later dropped again, don't let
// it get cleaned up
so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
so.HasGroupChanged = false;
}
示例2: UpdateAttachmentPosition
public void UpdateAttachmentPosition(IClientAPI client, SceneObjectGroup sog, Vector3 pos)
{
// If this is an attachment, then we need to save the modified
// object back into the avatar's inventory. First we save the
// attachment point information, then we update the relative
// positioning (which caused this method to get driven in the
// first place. Then we have to mark the object as NOT an
// attachment. This is necessary in order to correctly save
// and retrieve GroupPosition information for the attachment.
// Then we save the asset back into the appropriate inventory
// entry. Finally, we restore the object's attachment status.
byte attachmentPoint = (byte)sog.RootPart.AttachmentPoint;
sog.UpdateGroupPosition(pos, true);
sog.RootPart.IsAttachment = false;
sog.AbsolutePosition = sog.RootPart.AttachedPos;
UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID);
sog.SetAttachmentPoint(attachmentPoint);
}
示例3: AttachObject
public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, int AttachmentPt, bool silent)
{
Vector3 attachPos = group.AbsolutePosition;
if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
{
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
AttachmentPt &= 0x7f;
// If the attachment point isn't the same as the one previously used
// set it's offset position = 0 so that it appears on the attachment point
// and not in a weird location somewhere unknown.
if (AttachmentPt != 0 && AttachmentPt != (int)group.GetAttachmentPoint())
{
attachPos = Vector3.Zero;
}
// AttachmentPt 0 means the client chose to 'wear' the attachment.
/*if (AttachmentPt == 0)
{
// Check object for stored attachment point
AttachmentPt = (int)group.GetAttachmentPoint();
attachPos = group.GetAttachmentPos();
}*/
if (AttachmentPt == 0)
{
// Check object for older stored attachment point
AttachmentPt = group.RootPart.Shape.State;
//attachPos = group.AbsolutePosition;
}
// if we still didn't find a suitable attachment point.......
if (AttachmentPt == 0)
{
// Stick it on right hand with Zero Offset from the attachment point.
AttachmentPt = (int)AttachmentPoint.RightHand;
attachPos = Vector3.Zero;
}
group.SetAttachmentPoint((byte)AttachmentPt);
group.AbsolutePosition = attachPos;
// Remove any previous attachments
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
UUID itemID = UUID.Zero;
if (sp != null)
{
foreach (SceneObjectGroup grp in sp.GetAttachments(AttachmentPt))
{
itemID = grp.GetFromItemID();
if (itemID != UUID.Zero)
DetachSingleAttachmentToInv(itemID, remoteClient);
}
}
if (group.GetFromItemID() == UUID.Zero)
{
m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID);
}
else
{
itemID = group.GetFromItemID();
}
ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group);
AttachToAgent(sp, group, AttachmentPt, attachPos, silent);
}
else
{
remoteClient.SendAgentAlertMessage(
"You don't have sufficient permissions to attach this object", false);
return false;
}
return true;
}
示例4: FindAttachmentPoint
/// <summary>
/// Attach the object to the avatar
/// </summary>
/// <param name="remoteClient">The client that is having the attachment done</param>
/// <param name="localID">The localID (SceneObjectPart) that is being attached (for the attach script event)</param>
/// <param name="group">The group (SceneObjectGroup) that is being attached</param>
/// <param name="AttachmentPt">The point to where the attachment will go</param>
/// <param name="item">If this is not null, it saves a query in this method to the InventoryService
/// This is the Item that the object is in (if it is in one yet)</param>
protected void FindAttachmentPoint(IClientAPI remoteClient, uint localID, SceneObjectGroup group,
int AttachmentPt, InventoryItemBase item)
{
//Make sure that we arn't over the limit of attachments
SceneObjectGroup[] attachments = GetAttachmentsForAvatar(remoteClient.AgentId);
if (attachments.Length + 1 > m_maxNumberOfAttachments)
{
//Too many
remoteClient.SendAgentAlertMessage(
"You are wearing too many attachments. Take one off to attach this object", false);
return;
}
Vector3 attachPos = group.GetAttachmentPos();
if(!m_allowMultipleAttachments)
AttachmentPt &= 0x7f; //Disable it!
//Did the attachment change position or attachment point?
bool changedPositionPoint = false;
// If the attachment point isn't the same as the one previously used
// set it's offset position = 0 so that it appears on the attachment point
// and not in a weird location somewhere unknown.
//Simplier terms: the attachment point changed, set it to the default 0,0,0 location
if ((AttachmentPt & 0x7f) != 0 && (AttachmentPt & 0x7f) != (int)group.GetAttachmentPoint())
{
attachPos = Vector3.Zero;
changedPositionPoint = true;
}
else
{
// AttachmentPt 0 means the client chose to 'wear' the attachment.
if ((AttachmentPt & 0x7f) == 0)
{
// Check object for stored attachment point
AttachmentPt = (int)group.GetSavedAttachmentPoint();
attachPos = group.GetAttachmentPos();
}
//Check state afterwards... use the newer GetSavedAttachmentPoint and Pos above first
if ((AttachmentPt & 0x7f) == 0)
{
// Check object for older stored attachment point
AttachmentPt = group.RootPart.Shape.State;
//attachPos = group.AbsolutePosition;
}
// if we still didn't find a suitable attachment point, force it to the default
//This happens on the first time an avatar 'wears' an object
if ((AttachmentPt & 0x7f) == 0)
{
// Stick it on right hand with Zero Offset from the attachment point.
AttachmentPt = (int)AttachmentPoint.RightHand;
//Default location
attachPos = Vector3.Zero;
changedPositionPoint = true;
}
}
group.HasGroupChanged = changedPositionPoint;
//Update where we are put
group.SetAttachmentPoint((byte)AttachmentPt);
//Fix the position with the one we found
group.AbsolutePosition = attachPos;
// Remove any previous attachments
ScenePresence presence = m_scene.GetScenePresence(remoteClient.AgentId);
if (presence == null)
return;
UUID itemID = UUID.Zero;
//Check for multiple attachment bits
//If the numbers are the same, it wants to have the old attachment taken off
if ((AttachmentPt & 0x7f) == AttachmentPt)
{
foreach (SceneObjectGroup grp in attachments)
{
if (grp.GetAttachmentPoint() == (byte)AttachmentPt)
{
itemID = grp.GetFromItemID();
break;
}
}
if (itemID != UUID.Zero)
DetachSingleAttachmentToInventory(itemID, remoteClient);
}
itemID = group.GetFromItemID();
group.RootPart.AttachedAvatar = presence.UUID;
//Anakin Lohner bug #3839
//.........這裏部分代碼省略.........
示例5: UpdateAttachmentPosition
public void UpdateAttachmentPosition(SceneObjectGroup sog, Vector3 pos)
{
// First we save the
// attachment point information, then we update the relative
// positioning. Then we have to mark the object as NOT an
// attachment. This is necessary in order to correctly save
// and retrieve GroupPosition information for the attachment.
// Finally, we restore the object's attachment status.
byte attachmentPoint = sog.GetAttachmentPoint();
sog.UpdateGroupPosition(pos);
sog.RootPart.IsAttachment = false;
sog.AbsolutePosition = sog.RootPart.AttachedPos;
sog.SetAttachmentPoint(attachmentPoint);
sog.HasGroupChanged = true;
}
示例6: AttachToAgent
/// <summary>
/// Attach this scene object to the given avatar.
/// </summary>
///
/// This isn't publicly available since attachments should always perform the corresponding inventory
/// operation (to show the attach in user inventory and update the asset with positional information).
///
/// <param name="sp"></param>
/// <param name="so"></param>
/// <param name="attachmentpoint"></param>
/// <param name="AttachOffset"></param>
/// <param name="silent"></param>
protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, int attachmentpoint, Vector3 AttachOffset)
{
// don't attach attachments to child agents
if (avatar.IsChildAgent) return;
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
// Remove from database and parcel prim count
IBackupModule backup = so.Scene.RequestModuleInterface<IBackupModule>();
if (backup != null)
backup.DeleteFromStorage(so.UUID);
so.RootPart.AttachedAvatar = avatar.UUID;
//Anakin Lohner bug #3839
SceneObjectPart[] parts = so.Parts;
for (int i = 0; i < parts.Length; i++)
parts[i].AttachedAvatar = avatar.UUID;
if (so.RootPart.PhysActor != null)
{
m_scene.SceneGraph.PhysicsScene.RemovePrim(so.RootPart.PhysActor);
so.RootPart.PhysActor = null;
}
so.AbsolutePosition = AttachOffset;
so.RootPart.AttachedPos = AttachOffset;
so.RootPart.IsAttachment = true;
so.RootPart.SetParentLocalId(avatar.LocalId);
so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
avatar.AddAttachment(so);
// Killing it here will cause the client to deselect it
// It then reappears on the avatar, deselected
// through the full update below
//
if (so.IsSelected)
{
m_scene.ForEachClient(delegate(IClientAPI client)
{
client.SendKillObject(m_scene.RegionInfo.RegionHandle, new ISceneEntity[] { so.RootPart });
});
foreach (SceneObjectPart part in so.ChildrenList)
{
part.CreateSelected = true;
}
}
//NOTE: This MUST be here, otherwise we limit full updates during attachments when they are selected and it will block the first update.
// So until that is changed, this MUST stay. The client will instantly reselect it, so this value doesn't stay borked for long.
so.IsSelected = false;
so.ScheduleGroupUpdate(PrimUpdateFlags.FullUpdate);
// In case it is later dropped again, don't let
// it get cleaned up
so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
so.HasGroupChanged = false;
}