public void Move__MeshAutoGen(Vector2 curMouseGL, Vector2 curMousePosW, Vector2 deltaMoveW, int btnIndex, bool isFirstMove) { if (Editor.Select.SelectionType != apSelection.SELECTION_TYPE.Mesh || Editor.Select.Mesh == null || Editor.Select.Mesh.LinkedTextureData == null || Editor.Select.Mesh.LinkedTextureData._image == null || Editor._meshEditMode != apEditor.MESH_EDIT_MODE.MakeMesh || Editor._meshEditeMode_MakeMesh != apEditor.MESH_EDIT_MODE_MAKEMESH.AutoGenerate || !Editor.MeshGenerator.IsScanned) { return; } apMesh mesh = Editor.Select.Mesh; //Vector2 imageHalfOffset = new Vector2(mesh.LinkedTextureData._width * 0.5f, mesh.LinkedTextureData._height * 0.5f); List <apMeshGenMapper.ControlPoint> controlPoints = Editor.MeshGenerator.Mapper.ControlPoints; List <apMeshGenMapper.ControlPoint> selectedControlPoints = Editor.MeshGenerator._selectedControlPoints; apMeshGenMapper.ControlPoint curPoint = null; for (int i = 0; i < selectedControlPoints.Count; i++) { curPoint = selectedControlPoints[i]; curPoint._pos_Cur += deltaMoveW; } Editor.SetRepaint(); }
public apGizmos.TransformParam PivotReturn__MeshAutoGen() { if (Editor.Select.SelectionType != apSelection.SELECTION_TYPE.Mesh || Editor.Select.Mesh == null || Editor.Select.Mesh.LinkedTextureData == null || Editor.Select.Mesh.LinkedTextureData._image == null || Editor._meshEditMode != apEditor.MESH_EDIT_MODE.MakeMesh || Editor._meshEditeMode_MakeMesh != apEditor.MESH_EDIT_MODE_MAKEMESH.AutoGenerate || !Editor.MeshGenerator.IsScanned) { //Debug.LogError("Pivot Failed"); return(null); } List <apMeshGenMapper.ControlPoint> selectedControlPoints = Editor.MeshGenerator._selectedControlPoints; if (selectedControlPoints.Count == 0) { //Debug.LogError("Pivot Failed : Count 0"); return(null); } apMesh mesh = Editor.Select.Mesh; Vector2 imageHalfOffset = new Vector2(mesh.LinkedTextureData._width * 0.5f, mesh.LinkedTextureData._height * 0.5f); apMeshGenMapper.ControlPoint curPoint = null; Vector2 posW = Vector2.zero; if (selectedControlPoints.Count == 1) { curPoint = selectedControlPoints[0]; posW = curPoint._pos_Cur - (mesh._offsetPos + imageHalfOffset); return(apGizmos.TransformParam.Make(posW, 0.0f, Vector2.one, 0, Color.black, true, apMatrix3x3.identity, false, apGizmos.TRANSFORM_UI.TRS_NoDepth, Vector2.zero, 0.0f, Vector2.one)); } else { Vector2 centerPos = Vector2.zero; for (int i = 0; i < selectedControlPoints.Count; i++) { curPoint = selectedControlPoints[i]; posW = curPoint._pos_Cur - (mesh._offsetPos + imageHalfOffset); centerPos += posW; } centerPos /= selectedControlPoints.Count; //Debug.Log("Pivot : Multiple " + centerPos + " (" + selectedControlPoints.Count + ")"); return(apGizmos.TransformParam.Make(centerPos, 0.0f, Vector2.one, 0, Color.black, true, apMatrix3x3.identity, true, apGizmos.TRANSFORM_UI.TRS_NoDepth, Vector2.zero, 0.0f, Vector2.one)); } }
public void Scale__MeshAutoGen(Vector2 deltaScaleW, bool isFirstScale) { if (Editor.Select.SelectionType != apSelection.SELECTION_TYPE.Mesh || Editor.Select.Mesh == null || Editor.Select.Mesh.LinkedTextureData == null || Editor.Select.Mesh.LinkedTextureData._image == null || Editor._meshEditMode != apEditor.MESH_EDIT_MODE.MakeMesh || Editor._meshEditeMode_MakeMesh != apEditor.MESH_EDIT_MODE_MAKEMESH.AutoGenerate || !Editor.MeshGenerator.IsScanned) { return; } apMesh mesh = Editor.Select.Mesh; Vector2 imageHalfOffset = new Vector2(mesh.LinkedTextureData._width * 0.5f, mesh.LinkedTextureData._height * 0.5f); //List<apMeshGenMapper.ControlPoint> controlPoints = Editor.MeshGenerator.Mapper.ControlPoints; List <apMeshGenMapper.ControlPoint> selectedControlPoints = Editor.MeshGenerator._selectedControlPoints; if (selectedControlPoints.Count <= 1) { return; } apMeshGenMapper.ControlPoint curPoint = null; Vector2 posW = Vector2.zero; Vector2 centerPos = Vector2.zero; for (int i = 0; i < selectedControlPoints.Count; i++) { curPoint = selectedControlPoints[i]; posW = curPoint._pos_Cur - (mesh._offsetPos + imageHalfOffset); centerPos += posW; } centerPos /= selectedControlPoints.Count; Vector2 scale = new Vector2(1.0f + deltaScaleW.x, 1.0f + deltaScaleW.y); apMatrix3x3 matrix_Scale = apMatrix3x3.TRS(centerPos, 0, Vector2.one) * apMatrix3x3.TRS(Vector2.zero, 0, scale) * apMatrix3x3.TRS(-centerPos, 0, Vector2.one); for (int i = 0; i < selectedControlPoints.Count; i++) { curPoint = selectedControlPoints[i]; posW = curPoint._pos_Cur - (mesh._offsetPos + imageHalfOffset); posW = matrix_Scale.MultiplyPoint(posW); curPoint._pos_Cur = posW + (mesh._offsetPos + imageHalfOffset); } Editor.SetRepaint(); }
public apGizmos.SelectResult MultipleSelect__MeshAutoGen(Vector2 mousePosGL_Min, Vector2 mousePosGL_Max, Vector2 mousePosW_Min, Vector2 mousePosW_Max, apGizmos.SELECT_TYPE areaSelectType) { if (Editor.Select.SelectionType != apSelection.SELECTION_TYPE.Mesh || Editor.Select.Mesh == null || Editor.Select.Mesh.LinkedTextureData == null || Editor.Select.Mesh.LinkedTextureData._image == null || Editor._meshEditMode != apEditor.MESH_EDIT_MODE.MakeMesh || Editor._meshEditeMode_MakeMesh != apEditor.MESH_EDIT_MODE_MAKEMESH.AutoGenerate || !Editor.MeshGenerator.IsScanned) { return(null); } apMesh mesh = Editor.Select.Mesh; Vector2 imageHalfOffset = new Vector2(mesh.LinkedTextureData._width * 0.5f, mesh.LinkedTextureData._height * 0.5f); List <apMeshGenMapper.ControlPoint> controlPoints = Editor.MeshGenerator.Mapper.ControlPoints; List <apMeshGenMapper.ControlPoint> selectedControlPoints = Editor.MeshGenerator._selectedControlPoints; //if (!Editor.Controller.IsMouseInGUI(mousePosGL)) //{ // return apGizmos.SelectResult.Main.SetMultiple<apMeshGenMapper.ControlPoint>(selectedControlPoints); //} if (areaSelectType == apGizmos.SELECT_TYPE.New) { selectedControlPoints.Clear(); } apMeshGenMapper.ControlPoint curPoint = null; Vector2 posW = Vector2.zero; bool isAnyChanged = false; for (int iPoint = 0; iPoint < controlPoints.Count; iPoint++) { curPoint = controlPoints[iPoint]; posW = curPoint._pos_Cur - (mesh._offsetPos + imageHalfOffset); bool isSelectable = (mousePosW_Min.x < posW.x && posW.x < mousePosW_Max.x) && (mousePosW_Min.y < posW.y && posW.y < mousePosW_Max.y); if (isSelectable) { switch (areaSelectType) { case apGizmos.SELECT_TYPE.New: case apGizmos.SELECT_TYPE.Add: if (!selectedControlPoints.Contains(curPoint)) { selectedControlPoints.Add(curPoint); } break; case apGizmos.SELECT_TYPE.Subtract: if (selectedControlPoints.Contains(curPoint)) { selectedControlPoints.Remove(curPoint); } break; } isAnyChanged = true; } } if (isAnyChanged) { Editor.SetRepaint(); } else { if (areaSelectType == apGizmos.SELECT_TYPE.New) { selectedControlPoints.Clear(); Editor.SetRepaint(); } } return(apGizmos.SelectResult.Main.SetMultiple <apMeshGenMapper.ControlPoint>(selectedControlPoints)); }
// Select public apGizmos.SelectResult Select__MeshAutoGen(Vector2 mousePosGL, Vector2 mousePosW, int btnIndex, apGizmos.SELECT_TYPE selectType) { //Debug.Log("Select__MeshAutoGen : " + mousePosGL); if (Editor.Select.SelectionType != apSelection.SELECTION_TYPE.Mesh || Editor.Select.Mesh == null || Editor.Select.Mesh.LinkedTextureData == null || Editor.Select.Mesh.LinkedTextureData._image == null || Editor._meshEditMode != apEditor.MESH_EDIT_MODE.MakeMesh || Editor._meshEditeMode_MakeMesh != apEditor.MESH_EDIT_MODE_MAKEMESH.AutoGenerate || !Editor.MeshGenerator.IsScanned) { //Debug.LogError("Select__MeshAutoGen : Failed"); return(null); } apMesh mesh = Editor.Select.Mesh; Vector2 imageHalfOffset = new Vector2(mesh.LinkedTextureData._width * 0.5f, mesh.LinkedTextureData._height * 0.5f); List <apMeshGenMapper.ControlPoint> controlPoints = Editor.MeshGenerator.Mapper.ControlPoints; List <apMeshGenMapper.ControlPoint> selectedControlPoints = Editor.MeshGenerator._selectedControlPoints; if (!Editor.Controller.IsMouseInGUI(mousePosGL)) { //Debug.LogError("Select__MeshAutoGen : Mouse Over"); return(apGizmos.SelectResult.Main.SetMultiple <apMeshGenMapper.ControlPoint>(selectedControlPoints)); } apMeshGenMapper.ControlPoint curPoint = null; Vector2 posGL = Vector2.zero; bool isAnySelect_ControlPoint = false; for (int iPoint = 0; iPoint < controlPoints.Count; iPoint++) { curPoint = controlPoints[iPoint]; posGL = apGL.World2GL(curPoint._pos_Cur - (mesh._offsetPos + imageHalfOffset)); if (IsAutoGenMeshControlPointClickable(posGL, mousePosGL, 13)) { if (selectType == apGizmos.SELECT_TYPE.New) { selectedControlPoints.Clear(); selectedControlPoints.Add(curPoint); } else if (selectType == apGizmos.SELECT_TYPE.Add) { if (!selectedControlPoints.Contains(curPoint)) { selectedControlPoints.Add(curPoint); } } else //if (selectType == apGizmos.SELECT_TYPE.Subtract) { if (selectedControlPoints.Contains(curPoint)) { selectedControlPoints.Remove(curPoint); } } isAnySelect_ControlPoint = true; break; } } if (isAnySelect_ControlPoint) { //Debug.Log(">>> Select__MeshAutoGen : Is Any Selected"); Editor.SetRepaint(); } else { if (selectType == apGizmos.SELECT_TYPE.New) { selectedControlPoints.Clear(); //Debug.Log(">>> Select__MeshAutoGen : Unselected"); Editor.SetRepaint(); } } return(apGizmos.SelectResult.Main.SetMultiple <apMeshGenMapper.ControlPoint>(selectedControlPoints)); }