Ejemplo n.º 1
0
 public AttachmentPoint(AttachmentPoint other)
 {
     this.name = other.name;
     this.parentBone = other.parentBone;
     this.orientation = other.orientation;
     this.position = other.position;
 }
Ejemplo n.º 2
0
 public AttachmentPoint(AttachmentPoint other)
 {
     this.name        = other.name;
     this.parentBone  = other.parentBone;
     this.orientation = other.orientation;
     this.position    = other.position;
 }
Ejemplo n.º 3
0
        /// <summary>
        ///		Overriden to copy/clone the bones of the master skeleton.
        /// </summary>
        protected override void LoadImpl()
        {
            nextAutoHandle         = skeleton.nextAutoHandle;
            nextTagPointAutoHandle = 0;

            this.blendMode = skeleton.BlendMode;

            // copy bones starting at the roots
            for (int i = 0; i < skeleton.RootBoneCount; i++)
            {
                Bone rootBone = skeleton.GetRootBone(i);
                CloneBoneAndChildren(rootBone, null);
                rootBone.Update(true, false);
            }

            SetBindingPose();

            // Clone the attachment points
            for (int i = 0; i < skeleton.AttachmentPoints.Count; i++)
            {
                AttachmentPoint ap         = skeleton.AttachmentPoints[i];
                Bone            parentBone = this.GetBone(ap.ParentBone);
                this.CreateAttachmentPoint(ap.Name, parentBone.Handle, ap.Orientation, ap.Position);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   TODO: should this replace an existing attachment point with the same name?
        /// </summary>
        /// <param name="name"></param>
        /// <param name="parentHandle"></param>
        /// <param name="rotation"></param>
        /// <param name="translation"></param>
        /// <returns></returns>
        public virtual AttachmentPoint CreateAttachmentPoint(string name, ushort parentHandle, Quaternion rotation,
                                                             Vector3 translation)
        {
            var parentBone = this.boneList[parentHandle];
            var ap         = new AttachmentPoint(name, parentBone.Name, rotation, translation);

            this.attachmentPoints.Add(ap);
            return(ap);
        }
Ejemplo n.º 5
0
		protected void WriteAttachmentPoint( BinaryWriter writer, AttachmentPoint ap, Bone bone )
		{
			long start_offset = writer.Seek( 0, SeekOrigin.Current );
			WriteChunk( writer, SkeletonChunkID.AttachmentPoint, 0 );

			WriteString( writer, ap.Name );
			WriteUShort( writer, bone.Handle );
			WriteVector3( writer, ap.Position );
			WriteQuat( writer, ap.Orientation );

			long end_offset = writer.Seek( 0, SeekOrigin.Current );
			writer.Seek( (int)start_offset, SeekOrigin.Begin );
			WriteChunk( writer, SkeletonChunkID.AttachmentPoint, (int)( end_offset - start_offset ) );
			writer.Seek( (int)end_offset, SeekOrigin.Begin );
		}
        /// <summary>
        ///   Inform the name manager about an object node for which the name
        ///   should be displayed.
        /// </summary>
        /// <param name="oid">the object id of the node (used as the key for lookups)</param>
        /// <param name="objNode">the object node whose name should be displayed</param>
        public void AddNode(long oid, ObjectNode objNode)
        {
            NameNode widgetNode = new NameNode(oid);
            Node attachNode = null;
            WidgetSceneObject attachObj = new WidgetSceneObject();
            attachObj.WidgetNode = widgetNode;
            AttachmentPoint ap = objNode.GetAttachmentPoint("name-disabled");
            if (ap == null) {
                // Default to a bit larger than the height of the bounding box
                float objectHeight = objNode.Entity.BoundingBox.Size.y * 1.02f;
                ap = new AttachmentPoint("name-disabled", null, Quaternion.Identity, Vector3.UnitY * objectHeight);
            }
            attachNode = objNode.AttachLocalObject(ap, attachObj);
            if (attachNode == null) {
                widgetNode.NodeVisible = true;
                widgetNode.Node = objNode.SceneNode;
            } else {
                // The node visible will be set by the attachObj
                widgetNode.Node = attachNode;
            }

            // FIXME
            //widgetNode.Widget.Text = objNode.Name;
            //widgetNode.Widget.Font = font;
            window.AddChild(widgetNode.Widget);
            widgetNode.Widget.Initialize();
            widgetNode.SetFont(font);
            widgetNode.SetText(objNode.Name);
            lock (nameDictionary) {
                nameDictionary[oid] = widgetNode;
            }
        }
Ejemplo n.º 7
0
		/// <summary>
		///   TODO: should this replace an existing attachment point with the same name?
		/// </summary>
		/// <param name="name"></param>
		/// <param name="parentHandle"></param>
		/// <param name="rotation"></param>
		/// <param name="translation"></param>
		/// <returns></returns>
		public virtual AttachmentPoint CreateAttachmentPoint( string name, ushort parentHandle, Quaternion rotation,
		                                                      Vector3 translation )
		{
			var parentBone = this.boneList[ parentHandle ];
			var ap = new AttachmentPoint( name, parentBone.Name, rotation, translation );
			this.attachmentPoints.Add( ap );
			return ap;
		}
Ejemplo n.º 8
0
        private void SetupShieldAttachment()
        {
            // TODO - Hack to set up fake attachment points;
            AttachmentPoint socket = new AttachmentPoint();

            switch (this.Entity.Mesh.Skeleton.Name) {
                case "human_male.skeleton":
                    socket.boneName = "LeftForeArm";
                    socket.offsetOrientation = Quaternion.FromAngleAxis((float)Math.PI / 2, new Vector3(1, 0, 0));
                    socket.offsetPosition = new Vector3(220, 50, 0);
                    break;
                case "human_female.skeleton":
                    socket.boneName = "L_Wrist_BIND_jjj";
                    socket.offsetOrientation = Quaternion.FromAngleAxis((float)Math.PI, new Vector3(0, 0, 1))
                        * Quaternion.FromAngleAxis((float)Math.PI / 2, new Vector3(1, 0, 0));
                    socket.offsetPosition = new Vector3(65, 20, 0);
                    break;
                default:
                    Logger.Log(0, "EntityName: {0}", this.Entity.Mesh.Skeleton.Name);
                    socket.boneName = "Left_Wrist_BIND_jjj";
                    socket.offsetOrientation = Quaternion.FromAngleAxis((float)Math.PI, new Vector3(0, 0, 1))
                        * Quaternion.FromAngleAxis((float)Math.PI / 2, new Vector3(1, 0, 0));
                    socket.offsetPosition = new Vector3(65, 35, 0);
                    break;
            }

            if (!this.Entity.Mesh.Skeleton.ContainsBone(socket.boneName))
                return;

            attachmentPoints["shield"] = socket;
        }
 protected void SetupSocket(AttachmentPoint attachPoint, bool selected)
 {
     if (attachPoint == null)
         return;
     string sceneObjName = "_attachMesh_" + attachPoint.Name;
     MovableObject sceneObj = CreateAxisLines(selected);
     sceneObj.Name = sceneObjName;
     sceneManager.AddMovableObject(sceneObj);
     Node attachNode = null;
     if (attachPoint.ParentBone != null) {
         attachNode = loadedModel.AttachObjectToBone(attachPoint.ParentBone, sceneObj, attachPoint.Orientation, attachPoint.Position);
     } else {
         string attachNodeName = string.Format("_attachmentAxis.{0}", attachPoint.Name);
         SceneNode sceneNode = sceneManager.CreateSceneNode(attachNodeName);
         sceneNode.Orientation = attachPoint.Orientation;
         sceneNode.Position = attachPoint.Position;
         helperNode.AddChild(sceneNode);
         sceneNode.AttachObject(sceneObj);
         attachNode = sceneNode;
     }
     attachedNodes.Add(attachNode);
 }
Ejemplo n.º 10
0
 public Node AttachObject(AttachmentPoint attachPoint, long objectId,  MovableObject sceneObj, Quaternion orientation, Vector3 offset)
 {
     Node attachNode;
     Quaternion derivedOrientation = attachPoint.Orientation * orientation;
     Vector3 derivedOffset = (attachPoint.Orientation * offset) + attachPoint.Position;
     if (attachPoint.ParentBone != null) {
         attachNode = this.Entity.AttachObjectToBone(attachPoint.ParentBone, sceneObj, derivedOrientation, derivedOffset);
     } else {
         string attachNodeName = string.Format("attachment.{0}.{1}", attachPoint.Name, objectId);
         SceneNode attachedSceneNode = sceneNode.Creator.CreateSceneNode(attachNodeName);
         attachedSceneNode.Orientation = derivedOrientation;
         attachedSceneNode.Position = derivedOffset;
         sceneNode.AddChild(attachedSceneNode);
         attachedSceneNode.AttachObject(sceneObj);
         attachNode = attachedSceneNode;
     }
     attachments[objectId] = attachNode;
     attachedObjects[objectId] = sceneObj;
     return attachNode;
 }
Ejemplo n.º 11
0
 public Node AttachObject(AttachmentPoint attachPoint, long objectId, MovableObject sceneObj)
 {
     return AttachObject(attachPoint, objectId, sceneObj, Quaternion.Identity, Vector3.Zero);
 }
Ejemplo n.º 12
0
 public Node AttachObject(string slotName, long objectId, MovableObject sceneObj, Quaternion orientation, Vector3 offset)
 {
     log.InfoFormat("Attaching to {0} on {1}", slotName, this.Name);
     AttachmentPoint socket = null;
     if (attachmentPoints.ContainsKey(slotName))
         socket = attachmentPoints[slotName];
     else
         socket = new AttachmentPoint(slotName, null, Quaternion.Identity, Vector3.Zero);
     return AttachObject(socket, objectId, sceneObj, orientation, offset);
 }
Ejemplo n.º 13
0
 /// <summary>
 ///   Creates a node for use in future attachments (based on the attachPoint structure)
 /// </summary>
 /// <param name="attachPoint"></param>
 /// <param name="objectId"></param>
 /// <returns></returns>
 public Node AttachNode(AttachmentPoint attachPoint, long objectId)
 {
     Node attachNode;
     if (attachPoint.ParentBone != null) {
         attachNode = this.Entity.AttachNodeToBone(attachPoint.ParentBone, attachPoint.Orientation,
                                                   attachPoint.Position);
     } else {
         SceneNode attachedSceneNode = sceneNode.Creator.CreateSceneNode();
         attachedSceneNode.Orientation = attachPoint.Orientation;
         attachedSceneNode.Position = attachPoint.Position;
         sceneNode.AddChild(attachedSceneNode);
         attachNode = attachedSceneNode;
     }
     attachments[objectId] = attachNode;
     // attachedObjects[objectId] = sceneObj;
     return attachNode;
 }
Ejemplo n.º 14
0
 public Node AttachNode(string slotName, long objectId)
 {
     log.InfoFormat("Attaching to {0} on {1}", slotName, this.Name);
     AttachmentPoint socket = null;
     if (attachmentPoints.ContainsKey(slotName))
         socket = attachmentPoints[slotName];
     else
         socket = new AttachmentPoint(slotName, null, Quaternion.Identity, Vector3.Zero);
     return AttachNode(socket, objectId);
 }
Ejemplo n.º 15
0
 public Node AttachLocalObject(AttachmentPoint attachPoint, MovableObject sceneObj)
 {
     long objectId = worldManager.GetLocalOid();
     localAttachments[objectId.ToString()] = objectId;
     return AttachObject(attachPoint, objectId, sceneObj);
 }
Ejemplo n.º 16
0
		/// <summary>
		///   TODO: should this replace an existing attachment point with the same name?
		/// </summary>
		/// <param name="name"></param>
		/// <param name="rotation"></param>
		/// <param name="translation"></param>
		/// <returns></returns>
		public virtual AttachmentPoint CreateAttachmentPoint( string name, Quaternion rotation, Vector3 translation )
		{
			var ap = new AttachmentPoint( name, null, rotation, translation );
			this._attachmentPoints.Add( ap );
			return ap;
		}
Ejemplo n.º 17
0
        private void SetupNameAttachment()
        {
            AttachmentPoint socket = new AttachmentPoint();

            switch (this.Entity.Mesh.Skeleton.Name) {
                case "human_male.skeleton":
                    socket.boneName = "Head";
                    break;
                case "human_female.skeleton":
                default:
                    socket.boneName = "Head_BIND_jjj";
                    break;
            }

            if (!this.Entity.Mesh.Skeleton.ContainsBone(socket.boneName))
                return;

            attachmentPoints["name"] = socket;
        }
Ejemplo n.º 18
0
 protected void CleanupSocket(AttachmentPoint attachPoint)
 {
     if (attachPoint == null)
         return;
     string sceneObjName = "_attachMesh_" + attachPoint.Name;
     CleanupAttachedObject(sceneObjName);
 }
Ejemplo n.º 19
0
        private void SetupPrimaryWeaponAttachment()
        {
            // TODO - Hack to set up fake attachment points;
            AttachmentPoint socket = new AttachmentPoint();

            switch (this.Entity.Mesh.Skeleton.Name) {
                case "orc.skeleton":
                    socket.boneName = "Right_Wrist_BIND_jjj";
                    socket.offsetOrientation = Quaternion.FromAngleAxis((float)Math.PI / 2, new Vector3(1, 0, 0));
                    socket.offsetPosition = new Vector3(170, 60, 0);
                    break;
                case "girl.skeleton":
                    socket.boneName = "Right_Wrist_BIND_jjj";
                    socket.offsetOrientation = Quaternion.FromAngleAxis((float)Math.PI / 2, new Vector3(1, 0, 0));
                    socket.offsetPosition = new Vector3(65, 20, 0);
                    break;
                case "hero.skeleton":
                    socket.boneName = "Right_Wrist_BIND_jjj";
                    socket.offsetOrientation = Quaternion.FromAngleAxis((float)Math.PI / 2, new Vector3(1, 0, 0));
                    socket.offsetPosition = new Vector3(65, 35, 0);
                    break;
                case "human_male.skeleton":
                    socket.boneName = "RightHand";
                    socket.offsetOrientation = Quaternion.FromAngleAxis((float)Math.PI, new Vector3(0, 0, 1))
                        * Quaternion.FromAngleAxis((float)Math.PI / 2, new Vector3(1, 0, 0));
                    socket.offsetPosition = new Vector3(-75, -20, 0);
                    break;
                case "human_female.skeleton":
                    socket.boneName = "R_Wrist_BIND_jjj";
                    socket.offsetOrientation = Quaternion.FromAngleAxis((float)Math.PI / 2, new Vector3(1, 0, 0));
                    socket.offsetPosition = new Vector3(65, 20, 0);
                    break;
                default:
                    Logger.Log(0, "EntityName: {0}", this.Entity.Mesh.Skeleton.Name);
                    socket.boneName = "Right_Wrist_BIND_jjj";
                    socket.offsetOrientation = Quaternion.FromAngleAxis((float)Math.PI / 2, new Vector3(1, 0, 0));
                    socket.offsetPosition = new Vector3(65, 35, 0);
                    break;
            }

            if (!this.Entity.Mesh.Skeleton.ContainsBone(socket.boneName))
                return;

            attachmentPoints["primaryWeapon"] = socket;
        }
Ejemplo n.º 20
0
		protected void WriteAttachmentPoint( BinaryWriter writer, AttachmentPoint ap )
		{
			var start_offset = writer.Seek( 0, SeekOrigin.Current );
			WriteChunk( writer, MeshChunkID.AttachmentPoint, 0 );

			WriteString( writer, ap.Name );
			WriteVector3( writer, ap.Position );
			WriteQuat( writer, ap.Orientation );

			var end_offset = writer.Seek( 0, SeekOrigin.Current );
			writer.Seek( (int)start_offset, SeekOrigin.Begin );
			WriteChunk( writer, MeshChunkID.AttachmentPoint, (int)( end_offset - start_offset ) );
			writer.Seek( (int)end_offset, SeekOrigin.Begin );
		}
Ejemplo n.º 21
0
        private void SetupQuestAvailableAttachment()
        {
            AttachmentPoint socket = new AttachmentPoint();

            switch (this.Entity.Mesh.Skeleton.Name) {
                case "human_male.skeleton":
                    socket.offsetPosition = new Vector3(0, 350, 0);
                    socket.boneName = "Head";
                    break;
                case "human_female.skeleton":
                    socket.offsetOrientation = Quaternion.FromAngleAxis(-1 * (float)Math.PI / 2, Vector3.UnitZ);
                    socket.offsetPosition = new Vector3(300, 0, 0);
                    socket.boneName = "Head_BIND_jjj";
                    break;
                default:
                    socket.offsetOrientation = Quaternion.FromAngleAxis(-1 * (float)Math.PI / 2, Vector3.UnitZ);
                    socket.offsetPosition = new Vector3(500, 0, 0);
                    socket.boneName = "Head_BIND_jjj";
                    break;
            }

            if (!this.Entity.Mesh.Skeleton.ContainsBone(socket.boneName))
                return;

            attachmentPoints["questavailable"] = socket;
        }