// ===============================================================
 public void Objects_AttachmentUpdate(Object sender, OMV.PrimEventArgs args)
 {
     if (QueueTilOnline(args.Simulator, CommActionCode.OnAttachmentUpdate, sender, args)) return;
     lock (m_opLock) {
     LLRegionContext rcontext = FindRegion(args.Simulator);
     if (!ParentExists(rcontext, args.Prim.ParentID)) {
         // if this requires a parent and the parent isn't here yet, queue this operation til later
         rcontext.RequestLocalID(args.Prim.ParentID);
         QueueTilLater(args.Simulator, CommActionCode.OnObjectUpdated, sender, args);
         return;
     }
     this.m_statObjAttachmentUpdate++;
     m_log.Log(LogLevel.DUPDATEDETAIL, "OnNewAttachment: id={0}, lid={1}", args.Prim.ID.ToString(), args.Prim.LocalID);
     try {
         // if new or not, assume everything about this entity has changed
         UpdateCodes updateFlags = UpdateCodes.FullUpdate;
         IEntity ent;
         if (rcontext.TryGetCreateEntityLocalID(args.Prim.LocalID, out ent, delegate() {
                     IEntity newEnt = new LLEntityPhysical(rcontext.AssetContext,
                                     rcontext, args.Simulator.Handle, args.Prim.LocalID, args.Prim);
                     updateFlags |= UpdateCodes.New;
                     LLAttachment att = new LLAttachment();
                     newEnt.RegisterInterface<LLAttachment>(att);
                     string attachmentID = null;
                     if (args.Prim.NameValues != null) {
                         foreach (OMV.NameValue nv in args.Prim.NameValues) {
                             m_log.Log(LogLevel.DCOMMDETAIL, "AttachmentUpdate: ent={0}, {1}->{2}", newEnt.Name, nv.Name, nv.Value);
                             if (nv.Name == "AttachItemID") {
                                 attachmentID = nv.Value.ToString();
                                 break;
                             }
                         }
                     }
                     att.AttachmentID = attachmentID;
                     att.AttachmentPoint = args.Prim.PrimData.AttachmentPoint;
                     return newEnt;
                 }) ) {
         }
         else {
             m_log.Log(LogLevel.DBADERROR, "FAILED CREATION OF NEW ATTACHMENT");
         }
         ent.Update(updateFlags);
     }
     catch (Exception e) {
         m_log.Log(LogLevel.DBADERROR, "FAILED CREATION OF NEW ATTACHMENT: " + e.ToString());
     }
     }
     return;
 }
        private void CalcAttachmentPoint(LLAttachment atch, out OMV.Vector3 pos, out OMV.Quaternion rot)
        {
            OMV.Vector3 posRet = OMV.Vector3.Zero;
            OMV.Quaternion rotRet = OMV.Quaternion.Identity;

            switch (atch.AttachmentPoint) {
            case OMV.AttachmentPoint.Default:
            case OMV.AttachmentPoint.Chest:
            case OMV.AttachmentPoint.Skull:
            case OMV.AttachmentPoint.LeftShoulder:
            case OMV.AttachmentPoint.RightShoulder:
            case OMV.AttachmentPoint.LeftHand:
            case OMV.AttachmentPoint.RightHand:
            case OMV.AttachmentPoint.LeftFoot:
            case OMV.AttachmentPoint.RightFoot:
            case OMV.AttachmentPoint.Spine:
            case OMV.AttachmentPoint.Pelvis:
            case OMV.AttachmentPoint.Mouth:
            case OMV.AttachmentPoint.Chin:
            case OMV.AttachmentPoint.LeftEar:
            case OMV.AttachmentPoint.RightEar:
            case OMV.AttachmentPoint.LeftEyeball:
            case OMV.AttachmentPoint.RightEyeball:
            case OMV.AttachmentPoint.Nose:
            case OMV.AttachmentPoint.RightUpperArm:
            case OMV.AttachmentPoint.RightForearm:
            case OMV.AttachmentPoint.LeftUpperArm:
            case OMV.AttachmentPoint.LeftForearm:
            case OMV.AttachmentPoint.RightHip:
            case OMV.AttachmentPoint.RightUpperLeg:
            case OMV.AttachmentPoint.RightLowerLeg:
            case OMV.AttachmentPoint.LeftHip:
            case OMV.AttachmentPoint.LeftUpperLeg:
            case OMV.AttachmentPoint.LeftLowerLeg:
            case OMV.AttachmentPoint.Stomach:
            case OMV.AttachmentPoint.LeftPec:
            case OMV.AttachmentPoint.RightPec:
            case OMV.AttachmentPoint.HUDCenter2:
            case OMV.AttachmentPoint.HUDTopRight:
            case OMV.AttachmentPoint.HUDTop:
            case OMV.AttachmentPoint.HUDTopLeft:
            case OMV.AttachmentPoint.HUDCenter:
            case OMV.AttachmentPoint.HUDBottomLeft:
            case OMV.AttachmentPoint.HUDBottom:
            case OMV.AttachmentPoint.HUDBottomRight:
                break;
            default:
                break;
            }
            pos = posRet;
            rot = rotRet;
        }