コード例 #1
0
    XnaGeometry.Vector2 getFromBasis(
        XnaGeometry.Vector4 pt_in,
        XnaGeometry.Vector4 base_vec_u,
        XnaGeometry.Vector4 base_vec_v)
    {
        XnaGeometry.Vector2 basis = new XnaGeometry.Vector2(0, 0);
        basis.X = XnaGeometry.Vector4.Dot(pt_in, base_vec_u);
        basis.Y = XnaGeometry.Vector4.Dot(pt_in, base_vec_v);

        return(basis);
    }
コード例 #2
0
    public void poseCarryBones(MeshBone endeffector_bone)
    {
        int i = 0;

        foreach (var cur_bone in carry_bones)
        {
            var basis_pair = bones_basis[i];
            var tmp_vec    = endeffector_bone.getWorldEndPt() - endeffector_bone.getWorldStartPt();
            var base_vec_u = new XnaGeometry.Vector2(tmp_vec.X, tmp_vec.Y);
            base_vec_u.Normalize();

            var base_vec_v = new XnaGeometry.Vector2(0, 0);
            base_vec_v.X = -base_vec_u.Y;
            base_vec_v.Y = base_vec_u.X;

            var set_startpt = new XnaGeometry.Vector4(0, 0, 0, 1);
            var set_endpt   = new XnaGeometry.Vector4(0, 0, 0, 1);

            var calcVec = new XnaGeometry.Vector2(0, 0);
            calcVec = basis_pair.Item1.X * base_vec_u + basis_pair.Item1.Y * base_vec_v;

            set_startpt.X = calcVec.X;
            set_startpt.Y = calcVec.Y;
            set_startpt  += endeffector_bone.getWorldStartPt();
            set_startpt.W = 1;

            calcVec     = basis_pair.Item2.X * base_vec_u + basis_pair.Item2.Y * base_vec_v;
            set_endpt.X = calcVec.X;
            set_endpt.Y = calcVec.Y;
            set_endpt  += endeffector_bone.getWorldStartPt();
            set_endpt.W = 1;

            cur_bone.setWorldStartPt(set_startpt);
            cur_bone.setWorldEndPt(set_endpt);

            i++;
        }
    }
コード例 #3
0
        public string ProcessContactBone(XnaGeometry.Vector2 pt_in,
			                             float radius,
		                                 MeshBoneUtil.MeshBone bone_in)
        {
            string ret_name = "";
            XnaGeometry.Vector4 diff_vec = bone_in.getWorldEndPt() - bone_in.getWorldStartPt();

            XnaGeometry.Vector2 cur_vec = new XnaGeometry.Vector2(diff_vec.X, diff_vec.Y);
            float cur_length = (float)cur_vec.Length();

            XnaGeometry.Vector2 unit_vec = cur_vec;
            unit_vec.Normalize();

            XnaGeometry.Vector2 norm_vec = new XnaGeometry.Vector2(unit_vec.Y, unit_vec.X);

            XnaGeometry.Vector2 src_pt = new XnaGeometry.Vector2(bone_in.getWorldStartPt().X, bone_in.getWorldStartPt().Y);
            XnaGeometry.Vector2 rel_vec = pt_in - src_pt;
            float proj = (float)XnaGeometry.Vector2.Dot(rel_vec, unit_vec);

            if( (proj >= 0) && (proj <= cur_length))
            {
                float norm_proj = (float)XnaGeometry.Vector2.Dot(rel_vec, norm_vec);
                if(norm_proj <= radius)
                {
                    return bone_in.getKey();
                }
            }

            List<MeshBone> cur_children = bone_in.getChildren();
            foreach(MeshBone cur_child in cur_children)
            {
                ret_name = ProcessContactBone(pt_in, radius, cur_child);
                if(!(ret_name.Equals(""))) {
                    break;
                }
            }

            return ret_name;
        }
コード例 #4
0
        public CreatureUVSwapPacket(XnaGeometry.Vector2 local_offset_in,
						XnaGeometry.Vector2 global_offset_in,
						XnaGeometry.Vector2 scale_in,
						int tag_in)
        {
            local_offset = local_offset_in;
                global_offset = global_offset_in;
                scale = scale_in;
                tag = tag_in;
        }