Exemple #1
0
        //public apGizmos.SelectResult Select__Bone_AnimClipMenu(Vector2 mousePosGL, Vector2 mousePosW, int btnIndex, apGizmos.SELECT_TYPE selectType)
        //{
        //	//AnimClip 편집시에 Bone을 선택할 수 있다.

        //	if(Editor.Select.AnimClip == null || Editor.Select.AnimClip._targetMeshGroup == null || Editor._boneGUIRenderMode != apEditor.BONE_RENDER_MODE.Render)
        //	{
        //		return null;
        //	}
        //	apMeshGroup meshGroup = Editor.Select.AnimClip._targetMeshGroup;

        //	//TODO : 마우스 클릭 체크

        //	if(Editor.Select.Bone != null)
        //	{
        //		//return 1;
        //		return apGizmos.SelectResult.Main.SetSingle(Editor.Select.Bone);
        //	}
        //	return null;
        //}



        public bool IsBoneClick(apBone bone, Vector2 mousePosW, Vector2 mousePosGL, apEditor.BONE_RENDER_MODE boneRenderMode)
        {
            if (!bone.IsGUIVisible)
            {
                return(false);
            }

            if (boneRenderMode == apEditor.BONE_RENDER_MODE.None)
            {
                return(false);
            }

            if (boneRenderMode == apEditor.BONE_RENDER_MODE.Render)
            {
                //뿔 모양의 Bone Shape를 클릭하는지 체크하자 (헬퍼가 아닐 경우)
                if (!bone._shapeHelper)
                {
                    if (apEditorUtil.IsPointInTri(mousePosW, bone._worldMatrix._pos, bone._shapePoint_Mid1, bone._shapePoint_End1))
                    {
                        return(true);
                    }

                    if (apEditorUtil.IsPointInTri(mousePosW, bone._worldMatrix._pos, bone._shapePoint_Mid2, bone._shapePoint_End2))
                    {
                        return(true);
                    }
                    if (bone._shapeTaper < 100)
                    {
                        if (apEditorUtil.IsPointInTri(mousePosW, bone._worldMatrix._pos, bone._shapePoint_End1, bone._shapePoint_End2))
                        {
                            return(true);
                        }
                    }
                }

                //가운데 원점도 체크
                //Size는 10
                Vector2 orgPos  = apGL.World2GL(bone._worldMatrix._pos);
                float   orgSize = apGL.Zoom * 10.0f;
                if ((orgPos - mousePosGL).sqrMagnitude < orgSize * orgSize)
                {
                    return(true);
                }
                //이전 코드
                //if ((bone._worldMatrix._pos - mousePosW).sqrMagnitude < 10 * 10)
                //{
                //	return true;
                //}
            }
            else
            {
                //End1 _ End2
                // |     |
                //Mid1  Mid2
                //    Pos
                //2. Outline 상태에서는 선을 체크해야한다.
                //1> 헬퍼가 아닌 경우 : 뿔 모양만 체크
                //2> 헬퍼인 경우 : 다이아몬드만 체크

                if (!bone._shapeHelper)
                {
                    Vector2 posGL_Org  = apGL.World2GL(bone._worldMatrix._pos);
                    Vector2 posGL_Mid1 = apGL.World2GL(bone._shapePoint_Mid1);
                    Vector2 posGL_Mid2 = apGL.World2GL(bone._shapePoint_Mid2);
                    Vector2 posGL_End1 = apGL.World2GL(bone._shapePoint_End1);
                    Vector2 posGL_End2 = apGL.World2GL(bone._shapePoint_End2);

                    if (IsPointInEdge(posGL_Org, posGL_Mid1, mousePosGL))
                    {
                        return(true);
                    }
                    if (IsPointInEdge(posGL_Org, posGL_Mid2, mousePosGL))
                    {
                        return(true);
                    }
                    if (IsPointInEdge(posGL_Mid1, posGL_End1, mousePosGL))
                    {
                        return(true);
                    }
                    if (IsPointInEdge(posGL_Mid2, posGL_End2, mousePosGL))
                    {
                        return(true);
                    }
                    if (bone._shapeTaper < 100)
                    {
                        if (IsPointInEdge(posGL_End1, posGL_End2, mousePosGL))
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    //가운데 원점 체크
                    //여기서는 적당히 체크하자
                    //Size는 10
                    Vector2 orgPos  = apGL.World2GL(bone._worldMatrix._pos);
                    float   orgSize = apGL.Zoom * 10.0f;
                    float   minDist = orgSize * 0.5f;
                    float   maxDist = orgSize * 1.1f;
                    float   dist    = (orgPos - mousePosGL).sqrMagnitude;
                    if (dist < maxDist * maxDist && dist > minDist * minDist)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        private apBone CheckBoneClick(apBone targetBone, Vector2 mousePosW, Vector2 mousePosGL, apEditor.BONE_RENDER_MODE boneRenderMode, int curBoneDepth)
        {
            apBone resultBone = null;
            apBone bone       = null;

            //Child가 먼저 렌더링되므로, 여기가 우선순위
            for (int i = 0; i < targetBone._childBones.Count; i++)
            {
                bone = CheckBoneClick(targetBone._childBones[i], mousePosW, mousePosGL, boneRenderMode, curBoneDepth);
                if (bone != null)
                {
                    if (bone._depth > curBoneDepth)                    //Depth 처리를 해야한다.
                    {
                        resultBone   = bone;
                        curBoneDepth = bone._depth;                        //처리된 Depth 갱신
                    }
                }
            }
            if (resultBone != null)
            {
                return(resultBone);
            }
            if (resultBone == null)
            {
                if (IsBoneClick(targetBone, mousePosW, mousePosGL, boneRenderMode))
                {
                    return(targetBone);
                }
            }
            return(null);
        }