初始化项目
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BakingMobile : UnitMouseInput {
|
||||
/// <summary> 设计视图相机模块 </summary>
|
||||
public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraBaking;
|
||||
|
||||
private Vector3 mousePosition;
|
||||
private Vector3 originalPosition;
|
||||
|
||||
public override void MouseDown(DataMouseInput data) {
|
||||
mousePosition = data.ScreenPosition;
|
||||
originalPosition = ViewCamera.Position;
|
||||
}
|
||||
public override void MouseDrag(DataMouseInput data) {
|
||||
Vector3 original = ViewCamera.ScreenToWorldPosition(mousePosition);
|
||||
Vector3 current = data.WorldPosition;
|
||||
Vector3 offset = current - original;
|
||||
Vector3 up = ViewCamera.Up * offset.y;
|
||||
Vector3 right = ViewCamera.Right * offset.x;
|
||||
ViewCamera.Position = originalPosition + up + right;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e91048b6b41fcd488c55503ebfc3723
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,46 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BakingMobilePlate : UnitMouseInput {
|
||||
/// <summary> 安排点图层遮罩 </summary>
|
||||
private readonly LayerMask Arrange = LayerMaskTool.Arrange;
|
||||
/// <summary> 烘焙视图相机模块 </summary>
|
||||
public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraBaking;
|
||||
|
||||
private Vector3 mousePosition;
|
||||
private Vector3 originalPosition;
|
||||
private FixedArrange arrange;
|
||||
private ModulePrefab<DataPlate> platePrefab;
|
||||
|
||||
public override void MouseDown(DataMouseInput data) {
|
||||
if (!ViewCamera.ScreenToWorldObject(data.ScreenPosition, out platePrefab)) { return; }
|
||||
mousePosition = data.ScreenPosition;
|
||||
originalPosition = platePrefab.transform.localPosition;
|
||||
platePrefab.Value.dataBaking.position = originalPosition;
|
||||
ModuleCore.BakingMobilePlate(platePrefab.Value);
|
||||
}
|
||||
public override void MouseDrag(DataMouseInput data) {
|
||||
if (platePrefab == null) { return; }
|
||||
if (ViewCamera.ScreenToWorldObjectParent(data.ScreenPosition, out arrange, Arrange)) {
|
||||
platePrefab.Value.arrange = arrange;
|
||||
platePrefab.Value.dataBaking.position = arrange.transform.localPosition;
|
||||
platePrefab.Value.dataBaking.eulerAngles = arrange.transform.localEulerAngles;
|
||||
}
|
||||
else { Mobile(data.WorldPosition); }
|
||||
platePrefab.Value.UpdateVisual(false);
|
||||
}
|
||||
public override void MouseRelease(DataMouseInput data) {
|
||||
ModuleCore.BakingMobilePlate(null);
|
||||
}
|
||||
|
||||
private void Mobile(Vector3 worldPosition) {
|
||||
platePrefab.Value.arrange = null;
|
||||
Vector3 original = ViewCamera.ScreenToWorldPosition(mousePosition);
|
||||
Vector3 current = worldPosition;
|
||||
Vector3 offset = current - original;
|
||||
Vector3 up = ViewCamera.Up * offset.y;
|
||||
Vector3 right = ViewCamera.Right * offset.x;
|
||||
platePrefab.Value.dataBaking.position = originalPosition - up - right;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00b6b3cc18640204a8ad48985d53db48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BakingRotate : UnitMouseInput {
|
||||
/// <summary> 设计视图相机模块 </summary>
|
||||
public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraBaking;
|
||||
|
||||
private Vector3 mousePosition;
|
||||
private Vector3 originalEulerAngles;
|
||||
|
||||
public override void MouseDown(DataMouseInput data) {
|
||||
mousePosition = data.ViewPosition;
|
||||
originalEulerAngles = ViewCamera.EulerAngles;
|
||||
}
|
||||
public override void MouseDrag(DataMouseInput data) {
|
||||
float offsetX = data.ViewPosition.x - mousePosition.x;
|
||||
float offsetY = data.ViewPosition.y - mousePosition.y;
|
||||
ViewCamera.EulerAngles = originalEulerAngles + new Vector3(-offsetY, offsetX , 0) * 360;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49bda1134b4639f4cb22ffd3bb0499ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,7 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BakingSelect : UnitMouseInput {
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1b9618a80c54534ca23a5e71c9d9de0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DesignBezier : UnitMouseInput {
|
||||
/// <summary> 设计视图相机模块 </summary>
|
||||
public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraDesign;
|
||||
/// <summary> 查询点算法模块 </summary>
|
||||
public ModuleFind<DataPlateSide> FindSide => ModuleCore.FindSide;
|
||||
|
||||
public override void MouseDown(DataMouseInput data) {
|
||||
if (!FindSide.Find(data.WorldPosition, out DataPlateSide side)) { return; }
|
||||
if (side.bezier == Bezier.一阶) { side.TwoRankBezier(); side.plate.UpdateVisual(); return; }
|
||||
if (side.bezier == Bezier.二阶) { side.ThreeRankBezier(); side.plate.UpdateVisual(); return; }
|
||||
if (side.bezier == Bezier.三阶) { side.OneRankBezier(); side.plate.UpdateVisual(); return; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4c272ae3cc78a54c819d6b6194a75a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,35 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DesignInsert : UnitMouseInput {
|
||||
/// <summary> 查询边交点 </summary>
|
||||
public UnitFind<SideIntersectPoint> find = new FindSideIntersectPoint();
|
||||
|
||||
public override void MouseDown(DataMouseInput data) {
|
||||
if (!find.Find(data.WorldPosition, out SideIntersectPoint sip)) { return; }
|
||||
Insert(sip.side, sip.side.plate, sip.side.aPoint, sip.side.bPoint, sip.intersectPoint);
|
||||
}
|
||||
|
||||
private void Insert(DataPlateSide side, DataPlate plate, DataPlatePoint aPoint, DataPlatePoint bPoint, Vector3 position) {
|
||||
//创建新的点
|
||||
DataPlatePoint newPoint = new DataPlatePoint(plate);
|
||||
newPoint.position = position - plate.dataDesign.position;
|
||||
//改变关联的边B点,重置贝塞尔曲线
|
||||
side.bPoint = newPoint;
|
||||
side.OneRankBezier();
|
||||
//创建新的边
|
||||
DataPlateSide newSide = new DataPlateSide(plate);
|
||||
newSide.aPoint = newPoint;
|
||||
newSide.bPoint = bPoint;
|
||||
newSide.OneRankBezier();
|
||||
//插入边
|
||||
int sideIndex = plate.plateSides.IndexOf(side);
|
||||
plate.plateSides.Insert(sideIndex + 1, newSide);
|
||||
//插入点
|
||||
int pointIndex = plate.platePoints.IndexOf(aPoint);
|
||||
plate.platePoints.Insert(pointIndex + 1, newPoint);
|
||||
//更新数据
|
||||
plate.UpdateVisual();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6572c7ebab448a94d880fca85c728132
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,78 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DesignMobile : UnitMouseInput {
|
||||
/// <summary> 设计视图相机模块 </summary>
|
||||
public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraDesign;
|
||||
/// <summary> 查询贝塞尔点算法模块 </summary>
|
||||
public ModuleFind<DataBezier> FindBezier => ModuleCore.FindBezier;
|
||||
|
||||
private DataBezier bezier;
|
||||
private Vector3 mousePosition;
|
||||
private Vector3 originalPosition;
|
||||
private ModulePrefab<DataPlatePoint> prefabPoint;
|
||||
private ModulePrefab<DataPlate> prefabPlate;
|
||||
|
||||
public override void MouseDown(DataMouseInput data) {
|
||||
//判断是否选中贝塞尔点
|
||||
if (FindBezier.Find(data.WorldPosition, out bezier)) {
|
||||
RecordBezier(data.ScreenPosition); return;
|
||||
}
|
||||
//判断是否选中点
|
||||
if (ViewCamera.ScreenToWorldObjectParent(data.ScreenPosition, out prefabPoint)) {
|
||||
RecordPoint(data.ScreenPosition); return;
|
||||
}
|
||||
//判断是否选中板片
|
||||
if (ViewCamera.ScreenToWorldObjectParent(data.ScreenPosition,out prefabPlate)) {
|
||||
RecordPlate(data.ScreenPosition); return;
|
||||
}
|
||||
RecordCamera(data.ScreenPosition);
|
||||
}
|
||||
public override void MouseDrag(DataMouseInput data) {
|
||||
Vector3 original = ViewCamera.ScreenToWorldPosition(mousePosition);
|
||||
Vector3 current = data.WorldPosition;
|
||||
Vector3 offset = current - original;
|
||||
|
||||
if (bezier != null) { MobileBezier(offset); return; }
|
||||
if (prefabPoint != null) { MobilePoint(offset); return; }
|
||||
if (prefabPlate != null) { MobilePlate(offset); return; }
|
||||
MobileCamera(offset);
|
||||
}
|
||||
|
||||
//贝塞尔
|
||||
private void RecordBezier(Vector3 screenPosition) {
|
||||
mousePosition = screenPosition;
|
||||
originalPosition = bezier.position;
|
||||
}
|
||||
private void MobileBezier(Vector3 offset) {
|
||||
Vector3 position = originalPosition + offset;
|
||||
bezier.SetBezierPosition(position);
|
||||
}
|
||||
//点
|
||||
private void RecordPoint(Vector3 screenPosition) {
|
||||
mousePosition = screenPosition;
|
||||
originalPosition = prefabPoint.Value.position;
|
||||
}
|
||||
private void MobilePoint(Vector3 offset) {
|
||||
prefabPoint.Value.position = originalPosition + offset;
|
||||
prefabPoint.Value.plate.UpdateVisual();
|
||||
}
|
||||
//板片
|
||||
private void RecordPlate(Vector3 screenPosition) {
|
||||
mousePosition = screenPosition;
|
||||
originalPosition = prefabPlate.Value.dataDesign.position;
|
||||
}
|
||||
private void MobilePlate(Vector3 offset) {
|
||||
prefabPlate.Value.dataDesign.position = originalPosition + offset;
|
||||
prefabPlate.Value.UpdateVisual(false);
|
||||
}
|
||||
//相机
|
||||
private void RecordCamera(Vector3 screenPosition) {
|
||||
mousePosition = screenPosition;
|
||||
originalPosition = ViewCamera.Position;
|
||||
}
|
||||
private void MobileCamera(Vector3 offset) {
|
||||
ViewCamera.Position = originalPosition - offset;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d9fbc3106b97d147ac9164dc314865a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,57 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DesignSuture : UnitMouseInput {
|
||||
/// <summary> 查询边交点 </summary>
|
||||
public UnitFind<SideIntersectPoint> find = new FindSideIntersectPoint();
|
||||
/// <summary> 连接可视化内容生成模块 </summary>
|
||||
public ModuleVisual<DataConnector> VisualConnector => ModuleCore.VisualConnector;
|
||||
|
||||
private DataPlateSide aSide;
|
||||
private DataPlateSide bSide;
|
||||
private DataConnector connector;
|
||||
|
||||
public override void MouseDown(DataMouseInput data) {
|
||||
connector = new DataConnector();
|
||||
connector.aPoint = data.WorldPosition;
|
||||
if (!find.Find(data.WorldPosition, out SideIntersectPoint sip)) { return; }
|
||||
connector.aPoint = sip.intersectPoint;
|
||||
aSide = sip.side;
|
||||
}
|
||||
public override void MouseDrag(DataMouseInput data) {
|
||||
if (connector == null) { return; }
|
||||
connector.bPoint = data.WorldPosition;
|
||||
if (find.Find(data.WorldPosition, out SideIntersectPoint sip)) {
|
||||
connector.bPoint = sip.intersectPoint;
|
||||
bSide = sip.side;
|
||||
}
|
||||
else { connector.bPoint = data.WorldPosition; }
|
||||
VisualConnector.UpdateVisual(connector);
|
||||
}
|
||||
public override void MouseRelease(DataMouseInput data) {
|
||||
if (connector == null) { return; }
|
||||
VisualConnector.ReleaseVisual(connector);
|
||||
connector = null;
|
||||
|
||||
if (aSide == null || bSide == null || aSide == bSide) { return; }
|
||||
if (aSide.suture != null || bSide.suture != null) { return; }
|
||||
DataSuture suture = new DataSuture(aSide, bSide);
|
||||
aSide.suture = suture;
|
||||
bSide.suture = suture;
|
||||
aSide.plate.UpdateVisual();
|
||||
}
|
||||
|
||||
//private Vector3 GetPosition(DataMouseInput data) {
|
||||
// if (!FindSide.Find(data.WorldPosition, out bSide)) { return data.WorldPosition; }
|
||||
// if (aSide == bSide) { return data.WorldPosition; }
|
||||
// if (Intersect(bSide, data.WorldPosition, out Vector3 intersectPoint)) { return intersectPoint; }
|
||||
// else { return data.WorldPosition; }
|
||||
//}
|
||||
//private bool Intersect(DataSide side, Vector3 position, out Vector3 intersectPoint) {
|
||||
//DataIntersect intersect = new DataIntersect(side, position);
|
||||
//AlgorithmSidePoint.Compute(intersect);
|
||||
//intersectPoint = intersect.intersectPoint;
|
||||
//return intersect.isIntersect;
|
||||
//}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4da355235e26524388688f6bd6d5f43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DesignSutureReversal : UnitMouseInput {
|
||||
/// <summary> 设计视图相机模块 </summary>
|
||||
public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraDesign;
|
||||
/// <summary> 查询点算法模块 </summary>
|
||||
public ModuleFind<DataPlateSide> FindSide => ModuleCore.FindSide;
|
||||
|
||||
public override void MouseDown(DataMouseInput data) {
|
||||
if (!FindSide.Find(data.WorldPosition, out DataPlateSide side)) { return; }
|
||||
if (side.suture.a.plateSide == side) {
|
||||
side.suture.a.isReversal = !side.suture.a.isReversal;
|
||||
}
|
||||
if (side.suture.b.plateSide == side) {
|
||||
side.suture.b.isReversal = !side.suture.b.isReversal;
|
||||
}
|
||||
side.plate.UpdateVisual();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4360e81518739f24c842afc64b8e81b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,9 +2,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标输入单元
|
||||
/// </summary>
|
||||
public abstract class UnitMouseInput {
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
@@ -17,4 +14,6 @@ public abstract class UnitMouseInput {
|
||||
public virtual void MouseMove(DataMouseInput data) { }
|
||||
/// <summary> 释放鼠标 </summary>
|
||||
public virtual void MouseRelease(DataMouseInput data) { }
|
||||
/// <summary> 鼠标滚轮 </summary>
|
||||
public virtual void MouseScroll(DataMouseInput data) { }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e54a1981f15dce04b95e1b917c13cccd
|
||||
guid: d6cbde8dad4ff3f44bd5cc80c96fc3b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
Reference in New Issue
Block a user