예제 #1
0
        /// <summary>
        /// 指定スクリーン座標に指定ボーンがあるか。
        /// </summary>
        /// <param name="x">スクリーンX座標</param>
        /// <param name="y">スクリーンY座標</param>
        /// <param name="bone">ボーン</param>
        /// <returns>ボーンを見つけたか</returns>
        public bool FindBoneOnScreenPoint(float x, float y, TMONode bone)
        {
            float   collisionTime;
            Vector3 collisionPoint;

            return(FindBoneOnScreenPoint(x, y, bone, out collisionPoint, out collisionTime));
        }
예제 #2
0
 private Matrix[] ClipBoneMatrices(TSOSubMesh sub_mesh, TMOFile tmo)
 {
     Matrix[] clipped_boneMatrices = new Matrix[sub_mesh.maxPalettes];
     for (int numPalettes = 0; numPalettes < sub_mesh.maxPalettes; numPalettes++)
     {
         TSONode tso_node = sub_mesh.GetBone(numPalettes);
         TMONode tmo_node = tmo.FindNodeByName(tso_node.Name);
         clipped_boneMatrices[numPalettes] = tso_node.OffsetMatrix * tmo_node.combined_matrix;
     }
     return(clipped_boneMatrices);
 }
예제 #3
0
        /// <summary>
        /// ワールド座標系での回転を得る
        /// </summary>
        public static Quaternion GetWorldRotation(this TDCG.TMONode node)
        {
            TMONode    n = node;
            Quaternion q = Quaternion.Identity;

            while (n != null)
            {
                q.Multiply(n.Rotation);
                n = n.parent;
            }
            return(q);
        }
예제 #4
0
        /// <summary>
        /// 指定スクリーン座標に指定ボーンがあるか。
        /// </summary>
        /// <param name="x">スクリーンX座標</param>
        /// <param name="y">スクリーンY座標</param>
        /// <param name="bone">ボーン</param>
        /// <param name="collisionPoint"></param>
        /// <param name="collisionTime"></param>
        /// <returns>ボーンを見つけたか</returns>
        public bool FindBoneOnScreenPoint(float x, float y, TMONode bone, out Vector3 collisionPoint, out float collisionTime)
        {
            collisionTime  = 0.0f;
            collisionPoint = Vector3.Zero;

            Figure fig;

            if (figures.TryGetFigure(out fig))
            {
                Matrix m = bone.combined_matrix;

                float   sphereRadius   = 1.25f;
                Vector3 sphereCenter   = new Vector3(m.M41, m.M42, m.M43);
                Vector3 rayStart       = ScreenToLocal(x, y, 0.0f);
                Vector3 rayEnd         = ScreenToLocal(x, y, 1.0f);
                Vector3 rayOrientation = rayEnd - rayStart;

                return(DetectSphereRayCollision(sphereRadius, ref sphereCenter, ref rayStart, ref rayOrientation, out collisionPoint, out collisionTime));
            }
            return(false);
        }