s
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: c45fd57ba0de798408ed6dd6a8353703
|
guid: cdc05b7235085b54c80ff09c008ac6ad
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public abstract class ModuleAgent : MonoBehaviour {
|
|
||||||
protected abstract void Awake();
|
|
||||||
|
|
||||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: f6fbfbc1731723a4babd9d4ee59ded5b
|
guid: eda56199f140e8e41bde06c79efd4b8e
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 算法:中心角度排序法
|
||||||
|
/// 依据:???
|
||||||
|
/// </summary>
|
||||||
|
public class AlgorithmEdge : ModuleAlgorithm<DataPlate> {
|
||||||
|
/// <summary> 算法:中心角度排序法 </summary>
|
||||||
|
public AlgorithmEdge() { }
|
||||||
|
|
||||||
|
public class EdgeAngle {
|
||||||
|
public float angle;
|
||||||
|
public Vector3 position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Compute(DataPlate data) {
|
||||||
|
//List<Vector2> edgePoints = data.edgePoints;
|
||||||
|
////计算多边形中心点
|
||||||
|
//float x = edgePoints.Average((v3) => v3.x);
|
||||||
|
//float y = edgePoints.Average((v3) => v3.y);
|
||||||
|
//Vector2 center = new Vector2(x, y);
|
||||||
|
////计算所有点的夹角
|
||||||
|
//Vector3 direction = edgePoints[0] - center;
|
||||||
|
//List<EdgeAngle> angleList = new List<EdgeAngle>();
|
||||||
|
//for (int i = 0; i < edgePoints.Count; i++) {
|
||||||
|
// Vector3 normal = edgePoints[i] - center;
|
||||||
|
// EdgeAngle edgeAngle = new EdgeAngle();
|
||||||
|
// edgeAngle.angle = Angle(direction, normal);
|
||||||
|
// edgeAngle.position = normal;
|
||||||
|
// angleList.Add(edgeAngle);
|
||||||
|
//}
|
||||||
|
//data.centerOffset = center;
|
||||||
|
////排序
|
||||||
|
//angleList.Sort((x, y) => x.angle.CompareTo(y.angle));
|
||||||
|
////把排序好的边缘点重新添加
|
||||||
|
//data.edgePoints = new List<Vector2>();
|
||||||
|
//for (int i = 0; i < angleList.Count; i++) {
|
||||||
|
// data.edgePoints.Add(angleList[i].position);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 计算两点夹角
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction">0度点位置</param>
|
||||||
|
/// <param name="position">目标点</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private float Angle(Vector3 direction, Vector3 position) {
|
||||||
|
float angle = Vector2.SignedAngle(direction, position);
|
||||||
|
return angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Awake() {
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: bf6ce1cc457f25f4fa864d359bc95e18
|
guid: d17cdf61cce7657489b657640646a786
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计算位置到边上最近的点
|
||||||
|
/// </summary>
|
||||||
|
public class AlgorithmSidePoint : ModuleAlgorithm<DataIntersect> {
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.AlgorithmSidePoint = this;
|
||||||
|
|
||||||
|
public override void Compute(DataIntersect data) {
|
||||||
|
Vector3 position = data.position - data.side.plate.designPosition;
|
||||||
|
for (int i = 0; i < data.side.lines.Length; i++) {
|
||||||
|
DataLine line = data.side.lines[i];
|
||||||
|
if (!Compute(line, position, out Vector3 intersectPoint)) { continue; }
|
||||||
|
data.isIntersect = true;
|
||||||
|
data.intersectPoint = intersectPoint + data.side.plate.designPosition;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 查询匹配的边 </summary>
|
||||||
|
private bool Compute(DataLine line, Vector3 position, out Vector3 intersectPoint) {
|
||||||
|
return ProjectDistance(line.a, line.b, position, out intersectPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 向量投影法
|
||||||
|
/// 计算点c到线段ab最近的点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="a"></param>
|
||||||
|
/// <param name="b"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
/// <returns>如果不在线段上返回 false</returns>
|
||||||
|
public static bool ProjectDistance(Vector3 a, Vector3 b, Vector3 c, out Vector3 intersectPoint) {
|
||||||
|
Vector3 ab = b - a;
|
||||||
|
Vector3 ac = c - a;
|
||||||
|
Vector3 p = Vector3.Project(ac, ab.normalized);
|
||||||
|
intersectPoint = p + a;
|
||||||
|
if (ab.normalized != p.normalized) { return false; }
|
||||||
|
if (ab.magnitude < p.magnitude) { return false; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 7922d1530e2c0f94f9ef1bdff77aa89b
|
guid: a76476370cd578b489a2b37297d054f9
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 散列点生成简单多边形算法
|
||||||
|
/// </summary>
|
||||||
|
public class AlgorithmSimplePolygon : ModuleAlgorithm<DataPlate> {
|
||||||
|
private UnitAlgorithm<DataPlate> AlgorithmSideSubdivision = new UnitAlgorithmBezier();
|
||||||
|
private UnitAlgorithm<DataPlate> AlgorithmTriangle = new UnitAlgorithmEarCutting();
|
||||||
|
private UnitAlgorithm<DataPlate> AlgorithmMergeTriangle = new UnitAlgorithmMergeTriangle();
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.AlgorithmSimplePolygon = this;
|
||||||
|
|
||||||
|
public override void Compute(DataPlate data) {
|
||||||
|
//遍历计算边(DataSide)上的细分点(positions)和线(lines)
|
||||||
|
AlgorithmSideSubdivision.Compute(data);
|
||||||
|
//计算三角面
|
||||||
|
AlgorithmTriangle.Compute(data);
|
||||||
|
//三角面列表转换网格
|
||||||
|
AlgorithmMergeTriangle.Compute(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 细分多边形算法
|
||||||
|
/// </summary>
|
||||||
|
public class AlgorithmSubdivisionPolygon : ModuleAlgorithm<DataPlate> {
|
||||||
|
private UnitAlgorithm<DataPlate> AlgorithmSideSubdivision = new UnitAlgorithmBezier();
|
||||||
|
private UnitAlgorithm<DataPlate> AlgorithmBorder = new UnitAlgorithmBorder();
|
||||||
|
private UnitAlgorithm<DataPlate> AlgorithmVertex = new UnitAlgorithmVertex();
|
||||||
|
private UnitAlgorithm<DataPlate> AlgorithmTriangle = new UnitAlgorithmRhombus();
|
||||||
|
private UnitAlgorithm<DataPlate> AlgorithmMergeTriangle = new UnitAlgorithmMergeTriangle();
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.AlgorithmSubdivisionPolygon = this;
|
||||||
|
|
||||||
|
public override void Compute(DataPlate data) {
|
||||||
|
//遍历计算边(DataSide)上的细分点(positions)和线(lines)
|
||||||
|
Chronoscope("遍历计算边(DataSide)上的细分点(positions)和线(lines)消耗时间:", () => AlgorithmSideSubdivision.Compute(data));
|
||||||
|
//计算多边形边界
|
||||||
|
Chronoscope("计算多边形边界消耗时间:", () => AlgorithmBorder.Compute(data));
|
||||||
|
//计算顶点
|
||||||
|
Chronoscope("计算顶点消耗时间:", () => AlgorithmVertex.Compute(data));
|
||||||
|
//计算三角面
|
||||||
|
Chronoscope("计算三角面消耗时间:", () => AlgorithmTriangle.Compute(data));
|
||||||
|
//三角面列表转换网格
|
||||||
|
Chronoscope("三角面列表转换网格消耗时间:", () => AlgorithmMergeTriangle.Compute(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 是否启用计时器 </summary>
|
||||||
|
private readonly bool isEnableTimer = true;
|
||||||
|
/// <summary> 计时器 </summary>
|
||||||
|
private void Chronoscope(string content, Action action) {
|
||||||
|
if (!isEnableTimer) { action?.Invoke(); return; }
|
||||||
|
float time = Time.realtimeSinceStartup;
|
||||||
|
action?.Invoke();
|
||||||
|
float consumed = Time.realtimeSinceStartup - time;
|
||||||
|
Debug.Log($"{content}{consumed * 1000}");
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: eaecf945c01ab084aaa6cdb6ebcd7e0f
|
guid: 2414983cb247d574fad8f47f71c42fdb
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缝合边算法模块
|
||||||
|
/// </summary>
|
||||||
|
public class AlgorithmSutureSide : ModuleAlgorithm<DataSutureSide> {
|
||||||
|
public class VertexPosition : IComparable<VertexPosition> {
|
||||||
|
public Vector3 designPosition;
|
||||||
|
public Vector3 bakingPosition;
|
||||||
|
public float distance;
|
||||||
|
public int CompareTo(VertexPosition other) {
|
||||||
|
return other.distance >= distance ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.AlgorithmSutureSide = this;
|
||||||
|
|
||||||
|
public override void Compute(DataSutureSide data) {
|
||||||
|
//List<VertexPosition> vertexPositions = VertexPositions(data);
|
||||||
|
data.designPositions = VertexToDesignPositions(data).ToArray();
|
||||||
|
data.bakingPositions = VertexToBakingPositions(data).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<VertexPosition> VertexPositions(DataSutureSide sutureSide) {
|
||||||
|
List<VertexPosition> vertexPositions = new List<VertexPosition>();
|
||||||
|
for (int i = 0; i < sutureSide.Vertices.Length; i++) {
|
||||||
|
Vector3 design = sutureSide.Vertices[i].design;
|
||||||
|
Quaternion quaternion = Quaternion.Euler(sutureSide.PlateBakingEulerAngles);
|
||||||
|
Vector3 baking = quaternion * sutureSide.Vertices[i].design;
|
||||||
|
VertexPosition vertexPosition = new VertexPosition();
|
||||||
|
vertexPosition.designPosition = design + sutureSide.PlateDesignPosition;
|
||||||
|
vertexPosition.bakingPosition = baking + sutureSide.PlateBakingPosition;
|
||||||
|
vertexPosition.distance = Vector3.Distance(design, sutureSide.side.aPoint.position);
|
||||||
|
vertexPositions.Add(vertexPosition);
|
||||||
|
}
|
||||||
|
//按距离从小到大排序
|
||||||
|
vertexPositions.Sort();
|
||||||
|
//是否颠倒
|
||||||
|
if (sutureSide.isReversal) { vertexPositions.Reverse(); }
|
||||||
|
return vertexPositions;
|
||||||
|
}
|
||||||
|
private List<Vector3> VertexToDesignPositions(DataSutureSide data) {
|
||||||
|
//转换列表
|
||||||
|
List<Vector3> positions = new List<Vector3>();
|
||||||
|
for (int i = 0; i < data.Vertices.Length; i++) {
|
||||||
|
Vector3 position = data.Vertices[i].design + data.PlateDesignPosition;
|
||||||
|
positions.Add(position);
|
||||||
|
}
|
||||||
|
if (data.isReversal) { positions.Reverse(); }
|
||||||
|
return positions;
|
||||||
|
}
|
||||||
|
private List<Vector3> VertexToBakingPositions(DataSutureSide data) {
|
||||||
|
//转换列表
|
||||||
|
List<Vector3> positions = new List<Vector3>();
|
||||||
|
for (int i = 0; i < data.Vertices.Length; i++) {
|
||||||
|
Quaternion quaternion = Quaternion.Euler(data.PlateBakingEulerAngles);
|
||||||
|
Vector3 baking = quaternion * data.Vertices[i].design;
|
||||||
|
Vector3 position = baking + data.PlateBakingPosition;
|
||||||
|
positions.Add(position);
|
||||||
|
}
|
||||||
|
if (data.isReversal) { positions.Reverse(); }
|
||||||
|
return positions;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: d4ba0921b8d30f548ba33b96c76f2c48
|
guid: 2883f9190b57bdc41a4458a5c9e16f53
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
-8
@@ -15,11 +15,3 @@ public abstract class ModuleAlgorithm<Data> : MonoBehaviour {
|
|||||||
/// <summary> 执行算法 </summary>
|
/// <summary> 执行算法 </summary>
|
||||||
public abstract void Compute(Data data);
|
public abstract void Compute(Data data);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 单个算法函数
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="Data"></typeparam>
|
|
||||||
public abstract class ModuleAlgorithmFunction<Data> {
|
|
||||||
/// <summary> 执行算法 </summary>
|
|
||||||
public abstract void Compute(Data data);
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: f504da41bfc887044b129dc255e092c2
|
guid: 485602713f4e17344b5dc7f627ed1a81
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轮廓渲染资源模块
|
||||||
|
/// </summary>
|
||||||
|
public class AssetsOutline : ModuleAssets<Transform> {
|
||||||
|
public UniversalRendererData rendererData;
|
||||||
|
private OutlineRendererFeature rendererFeature;
|
||||||
|
|
||||||
|
public override int Count => rendererFeature.settings.RenderObjs.Count;
|
||||||
|
public override List<Transform> Datas => rendererFeature.settings.RenderObjs;
|
||||||
|
|
||||||
|
protected override void Awake() {
|
||||||
|
ModuleCore.AssetsOutline = this;
|
||||||
|
rendererFeature = rendererData.rendererFeatures.OfType<OutlineRendererFeature>().FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Add(Transform data) {
|
||||||
|
if (Datas.Contains(data)) { return; }
|
||||||
|
Datas.Add(data);
|
||||||
|
}
|
||||||
|
public override void Remove(Transform data) {
|
||||||
|
if (!Datas.Contains(data)) { return; }
|
||||||
|
Datas.Remove(data);
|
||||||
|
}
|
||||||
|
public override Transform Find(int index) {
|
||||||
|
return Datas.LoopIndex(index);
|
||||||
|
}
|
||||||
|
public override void ForEach(Action<Transform> action) {
|
||||||
|
Datas.ForEach(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fe3a6923b67b64741aab806825b12c16
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+5
-1
@@ -3,6 +3,9 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 板片管理模块
|
||||||
|
/// </summary>
|
||||||
public class AssetsPlate : ModuleAssets<DataPlate> {
|
public class AssetsPlate : ModuleAssets<DataPlate> {
|
||||||
private List<DataPlate> dataPlates = new List<DataPlate>();
|
private List<DataPlate> dataPlates = new List<DataPlate>();
|
||||||
|
|
||||||
@@ -18,7 +21,8 @@ public class AssetsPlate : ModuleAssets<DataPlate> {
|
|||||||
if (dataPlates.Contains(data)) { return; }
|
if (dataPlates.Contains(data)) { return; }
|
||||||
dataPlates.Add(data);
|
dataPlates.Add(data);
|
||||||
//初始化参数
|
//初始化参数
|
||||||
data.position = ViewCameraDesign.position;
|
data.designPosition = ViewCameraDesign.CameraPosition;
|
||||||
|
data.bakingPosition = ViewCameraDesign.CameraPosition;
|
||||||
//生成可视化内容
|
//生成可视化内容
|
||||||
data.UpdateVisual();
|
data.UpdateVisual();
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 321aee0b32d39984085ac96e402e9c0b
|
guid: 8198c73995924524d985c3beb338f033
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 3aff7fb266b16b642b5658e558c0c924
|
guid: f005f421868c2084baf399dc6a42a60b
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 插入点(DataInsertPoint) 转换 点(DataPoint)
|
||||||
|
/// </summary>
|
||||||
|
public class BuilderInsertPointToPoint : ModuleBuilder<DataInsertPoint, DataPoint> {
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.InsertPointToPoint = this;
|
||||||
|
|
||||||
|
public override DataPoint To(DataInsertPoint insertPoint) {
|
||||||
|
DataPlate plate = insertPoint.plate;
|
||||||
|
Vector3 position = insertPoint.position;
|
||||||
|
//创建新的点
|
||||||
|
DataPoint point = new DataPoint(insertPoint.plate);
|
||||||
|
point.position = position;
|
||||||
|
//改变关联的边B点,重置贝塞尔曲线
|
||||||
|
insertPoint.side.bPoint = point;
|
||||||
|
insertPoint.side.OneRankBezier();
|
||||||
|
//创建新的边
|
||||||
|
DataSide side = CreateDataSide(plate, point, insertPoint.bPoint);
|
||||||
|
//插入边
|
||||||
|
int sideIndex = plate.sides.IndexOf(insertPoint.side);
|
||||||
|
plate.sides.Insert(sideIndex + 1, side);
|
||||||
|
//插入点
|
||||||
|
int pointIndex = plate.points.IndexOf(insertPoint.aPoint);
|
||||||
|
plate.points.Insert(pointIndex + 1, point);
|
||||||
|
//更新数据
|
||||||
|
plate.UpdateVisual();
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataSide CreateDataSide(DataPlate plate, DataPoint a, DataPoint b) {
|
||||||
|
DataSide side = new DataSide(plate);
|
||||||
|
side.aPoint = a;
|
||||||
|
side.bPoint = b;
|
||||||
|
side.OneRankBezier();
|
||||||
|
return side;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 板片预设数据(DataPlatePresets) 转换 板片数据(DataPlate)
|
||||||
|
/// </summary>
|
||||||
|
public class BuilderPlatePresetsToPlate : ModuleBuilder<DataPlatePresets, DataPlate> {
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.PlatePresetsToPlate = this;
|
||||||
|
|
||||||
|
public override DataPlate To(DataPlatePresets origin) {
|
||||||
|
DataPlate dataPlate = new DataPlate();
|
||||||
|
dataPlate.points = ToDataPoint(dataPlate, origin.designPoints);
|
||||||
|
dataPlate.sides = ToDataSide(dataPlate, dataPlate.points);
|
||||||
|
return dataPlate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DataPoint> ToDataPoint(DataPlate dataPlate, List<Vector3> list) {
|
||||||
|
List<DataPoint> points = new List<DataPoint>();
|
||||||
|
for (int i = 0; i < list.Count; i++) {
|
||||||
|
DataPoint point = new DataPoint(dataPlate);
|
||||||
|
point.position = list[i];
|
||||||
|
points.Add(point);
|
||||||
|
}
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
private List<DataSide> ToDataSide(DataPlate dataPlate, List<DataPoint> list) {
|
||||||
|
List<DataSide> sides = new List<DataSide>();
|
||||||
|
for (int i = 0; i < list.Count; i++) {
|
||||||
|
DataSide side = new DataSide(dataPlate);
|
||||||
|
side.aPoint = list.LoopIndex(i + 0);
|
||||||
|
side.bPoint = list.LoopIndex(i + 1);
|
||||||
|
side.OneRankBezier();
|
||||||
|
sides.Add(side);
|
||||||
|
}
|
||||||
|
return sides;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,10 +10,12 @@ using MuHua;
|
|||||||
public class ModuleCore : Module<ModuleCore> {
|
public class ModuleCore : Module<ModuleCore> {
|
||||||
|
|
||||||
#region 资产模块
|
#region 资产模块
|
||||||
/// <summary> 板片资产 </summary>
|
/// <summary> 板片资源管理模块 </summary>
|
||||||
public ModuleAssets<DataPlate> AssetsPlate;
|
public ModuleAssets<DataPlate> AssetsPlate;
|
||||||
/// <summary> 预设板片资产 </summary>
|
/// <summary> 预设板片资产 </summary>
|
||||||
public ModuleAssets<DataPlatePresets> AssetsPlatePresets;
|
public ModuleAssets<DataPlatePresets> AssetsPlatePresets;
|
||||||
|
/// <summary> 轮廓渲染资源模块 </summary>
|
||||||
|
public ModuleAssets<Transform> AssetsOutline;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 页面模块
|
#region 页面模块
|
||||||
@@ -32,50 +34,62 @@ public class ModuleCore : Module<ModuleCore> {
|
|||||||
public ModuleViewCamera ViewCameraBaking;
|
public ModuleViewCamera ViewCameraBaking;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 广播模块
|
|
||||||
/// <summary> 广播板片数据模块 </summary>
|
|
||||||
public ModuleSending<DataPlate> SendingPlate;
|
|
||||||
/// <summary> 广播板片数据点模块 </summary>
|
|
||||||
public ModuleSending<DataPoint> SendingPoint;
|
|
||||||
/// <summary> 广播查询数据模块 </summary>
|
|
||||||
public ModuleSending<DataFindPoint> SendingFindPoint;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 输入模块
|
#region 输入模块
|
||||||
/// <summary> 设计UI输入模块 </summary>
|
/// <summary> 设计UI输入模块 </summary>
|
||||||
public ModuleUIInput<UIInputDesignUnit> UIInputDesign;
|
public ModuleUIInput<UnitMouseInput> UIInputDesign;
|
||||||
|
/// <summary> 烘焙UI输入模块 </summary>
|
||||||
|
public ModuleUIInput<UnitMouseInput> UIInputBaking;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 转换模块
|
#region 转换模块
|
||||||
/// <summary> 预设板片转换板片 </summary>
|
/// <summary> 板片预设数据(DataPlatePresets) 转换 板片数据(DataPlate) </summary>
|
||||||
public ModuleBuilder<DataPlatePresets, DataPlate> PlatePresetsToPlate;
|
public ModuleBuilder<DataPlatePresets, DataPlate> PlatePresetsToPlate;
|
||||||
/// <summary> 插入点数据转换板片上的点 </summary>
|
/// <summary> 板片数据(DataPlate) 转换 多边形数据(DataPolygon) </summary>
|
||||||
|
public ModuleBuilder<DataPlate, DataPolygon> PlateToPolygon;
|
||||||
|
/// <summary> 插入点(DataInsertPoint) 转换 点(DataPoint) </summary>
|
||||||
public ModuleBuilder<DataInsertPoint, DataPoint> InsertPointToPoint;
|
public ModuleBuilder<DataInsertPoint, DataPoint> InsertPointToPoint;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 可视模块
|
#region 可视模块
|
||||||
/// <summary> 板片可视化内容生成模块 </summary>
|
/// <summary> 设计可视化内容生成模块 </summary>
|
||||||
public ModuleVisual<DataPlate> VisualPlate;
|
public ModuleVisual<DataPlate> VisualDesign;
|
||||||
/// <summary> 点可视化内容生成模块 </summary>
|
/// <summary> 烘焙可视化内容生成模块 </summary>
|
||||||
public ModuleVisual<DataPoint> VisualPoint;
|
public ModuleVisual<DataPlate> VisualBaking;
|
||||||
/// <summary> 多边形可视化内容生成模块 </summary>
|
/// <summary> 连接可视化内容生成模块 </summary>
|
||||||
public ModuleVisual<DataPolygon> VisualPolygon;
|
public ModuleVisual<DataConnector> VisualConnector;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 查询模块
|
||||||
|
/// <summary> 查询点模块 </summary>
|
||||||
|
public ModuleFind<DataPoint> FindPoint;
|
||||||
|
/// <summary> 查询边模块 </summary>
|
||||||
|
public ModuleFind<DataSide> FindSide;
|
||||||
|
/// <summary> 查询贝塞尔点模块 </summary>
|
||||||
|
public ModuleFind<DataBezier> FindBezier;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 算法模块
|
#region 算法模块
|
||||||
|
/// <summary> 计算位置到边上最近的点 </summary>
|
||||||
|
public ModuleAlgorithm<DataIntersect> AlgorithmSidePoint;
|
||||||
|
/// <summary> 简单多边形算法模块 </summary>
|
||||||
|
public ModuleAlgorithm<DataPlate> AlgorithmSimplePolygon;
|
||||||
|
/// <summary> 细分多边形算法模块 </summary>
|
||||||
|
public ModuleAlgorithm<DataPlate> AlgorithmSubdivisionPolygon;
|
||||||
|
/// <summary> 缝合边算法模块 </summary>
|
||||||
|
public ModuleAlgorithm<DataSutureSide> AlgorithmSutureSide;
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary> 查询点算法模块 </summary>
|
#region 事件定义
|
||||||
public ModuleAlgorithm<DataFindPoint> AlgorithmFindPoint;
|
/// <summary> 标记数据Event </summary>
|
||||||
/// <summary> 查询贝塞尔点算法模块 </summary>
|
public event Action<DataMark> OnMark;
|
||||||
public ModuleAlgorithm<DataFindBezier> AlgorithmFindBezier;
|
/// <summary> 移动烘焙视图的板片Event </summary>
|
||||||
|
public event Action<DataPlate> OnBakingMobilePlate;
|
||||||
/// <summary> 插入点算法模块 </summary>
|
#endregion
|
||||||
public ModuleAlgorithm<DataInsertPoint> AlgorithmInsertPoint;
|
|
||||||
|
|
||||||
/// <summary> 多边形算法模块 </summary>
|
|
||||||
public ModuleAlgorithm<DataPlate> AlgorithmPolygon;
|
|
||||||
///// <summary> 边缘排序算法模块 </summary>
|
|
||||||
//public ModuleAlgorithm<DataPlate> EdgeSort = new AlgorithmEdge();
|
|
||||||
|
|
||||||
|
#region 事件触发
|
||||||
|
/// <summary> 触发标记数据Event </summary>
|
||||||
|
public void Mark(DataMark data) => OnMark?.Invoke(data);
|
||||||
|
/// <summary> 触发移动烘焙视图的板片Event </summary>
|
||||||
|
public void BakingMobilePlate(DataPlate data) => OnBakingMobilePlate?.Invoke(data);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 152682a505646cc41a3bb70493adf97d
|
guid: d0d7dc4e6e513e34abe150338292b7d9
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询贝塞尔点
|
||||||
|
/// </summary>
|
||||||
|
public class FindBezier : ModuleFind<DataBezier> {
|
||||||
|
public readonly float FindRange = 0.02f;
|
||||||
|
/// <summary> 板片资产 </summary>
|
||||||
|
public ModuleAssets<DataPlate> AssetsPlate => ModuleCore.AssetsPlate;
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.FindBezier = this;
|
||||||
|
|
||||||
|
public override bool Find(Vector3 position, out DataBezier bezier) {
|
||||||
|
List<DataPlate> plates = AssetsPlate.Datas;
|
||||||
|
for (int i = 0; i < plates.Count; i++) {
|
||||||
|
Vector3 localPosition = position - plates[i].designPosition;
|
||||||
|
bezier = Find(plates[i], localPosition);
|
||||||
|
if (bezier != null) { return true; }
|
||||||
|
}
|
||||||
|
bezier = null; return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 查询匹配的边 </summary>
|
||||||
|
private DataBezier Find(DataPlate plate, Vector3 localPosition) {
|
||||||
|
for (int i = 0; i < plate.sides.Count; i++) {
|
||||||
|
DataBezier bezier = Find(plate.sides[i], localPosition);
|
||||||
|
if (bezier != null) { return bezier; }
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <summary> 查询匹配的边 </summary>
|
||||||
|
private DataBezier Find(DataSide side, Vector3 localPosition) {
|
||||||
|
if (side.bezier == Bezier.一阶) { return null; }
|
||||||
|
float aDis = Vector3.Distance(side.aBezier, localPosition);
|
||||||
|
if (aDis < FindRange) { return new DataBezier() { isA = true, side = side }; }
|
||||||
|
float bDis = Vector3.Distance(side.bBezier, localPosition);
|
||||||
|
if (bDis < FindRange) { return new DataBezier() { isA = false, side = side }; }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5ea40ae623c1a974fa852f60e22f5a37
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找点
|
||||||
|
/// </summary>
|
||||||
|
public class FindPoint : ModuleFind<DataPoint> {
|
||||||
|
public readonly float FindRange = 0.01f;
|
||||||
|
/// <summary> 板片资产 </summary>
|
||||||
|
public ModuleAssets<DataPlate> AssetsPlate => ModuleCore.AssetsPlate;
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.FindPoint = this;
|
||||||
|
|
||||||
|
public override bool Find(Vector3 position, out DataPoint point) {
|
||||||
|
List<DataPlate> plates = AssetsPlate.Datas;
|
||||||
|
for (int i = 0; i < plates.Count; i++) {
|
||||||
|
Vector3 localPosition = position - plates[i].designPosition;
|
||||||
|
point = Find(plates[i], localPosition);
|
||||||
|
if (point != null) { return true; }
|
||||||
|
}
|
||||||
|
point = null; return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 查询匹配的点 </summary>
|
||||||
|
private DataPoint Find(DataPlate plate, Vector3 localPosition) {
|
||||||
|
List<DataPoint> points = plate.points;
|
||||||
|
for (int i = 0; i < points.Count; i++) {
|
||||||
|
float distance = Vector3.Distance(points[i].position, localPosition);
|
||||||
|
if (distance > FindRange) { continue; }
|
||||||
|
return points[i];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1da1d6857fa49af4dbe4dd67998f54f1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找边
|
||||||
|
/// </summary>
|
||||||
|
public class FindSide : ModuleFind<DataSide> {
|
||||||
|
public readonly float FindRange = 0.01f;
|
||||||
|
/// <summary> 板片资产 </summary>
|
||||||
|
public ModuleAssets<DataPlate> AssetsPlate => ModuleCore.AssetsPlate;
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.FindSide = this;
|
||||||
|
|
||||||
|
public override bool Find(Vector3 position, out DataSide side) {
|
||||||
|
List<DataPlate> plates = AssetsPlate.Datas;
|
||||||
|
for (int i = 0; i < plates.Count; i++) {
|
||||||
|
Vector3 localPosition = position - plates[i].designPosition;
|
||||||
|
side = Find(plates[i], localPosition);
|
||||||
|
if (side != null) { return true; }
|
||||||
|
}
|
||||||
|
side = null; return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 查询匹配的边 </summary>
|
||||||
|
private DataSide Find(DataPlate plate, Vector3 localPosition) {
|
||||||
|
for (int i = 0; i < plate.sides.Count; i++) {
|
||||||
|
DataSide side = Find(plate.sides[i], localPosition);
|
||||||
|
if (side != null) { return side; }
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <summary> 查询匹配的边 </summary>
|
||||||
|
private DataSide Find(DataSide side, Vector3 localPosition) {
|
||||||
|
for (int i = 0; i < side.lines.Length; i++) {
|
||||||
|
Vector3 a = side.lines[i].a;
|
||||||
|
Vector3 b = side.lines[i].b;
|
||||||
|
float distance = ProjectDistance(a, b, localPosition);
|
||||||
|
//Debug.Log($"{a} , {b} , {localPosition}");
|
||||||
|
if (distance < FindRange) { return side; }
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 向量投影法
|
||||||
|
/// 计算点c到线段ab最近的点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="a"></param>
|
||||||
|
/// <param name="b"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
/// <returns>如果不在线段上返回 float.MaxValue</returns>
|
||||||
|
public static float ProjectDistance(Vector3 a, Vector3 b, Vector3 c) {
|
||||||
|
Vector3 ab = b - a;
|
||||||
|
Vector3 ac = c - a;
|
||||||
|
Vector3 p = Vector3.Project(ac, ab);
|
||||||
|
if (ab.normalized != p.normalized) { return float.MaxValue; }
|
||||||
|
if (ab.magnitude < p.magnitude) { return float.MaxValue; }
|
||||||
|
return Vector3.Distance(c, p + a);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f9b522b1c221a4643b94ce865ac8ecaa
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -3,14 +3,14 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成可视化内容模块
|
/// 查找模块
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ModuleVisual<Data> : MonoBehaviour {
|
public abstract class ModuleFind<Data> : MonoBehaviour {
|
||||||
/// <summary> 必须要初始化 </summary>
|
/// <summary> 必须要初始化 </summary>
|
||||||
protected abstract void Awake();
|
protected abstract void Awake();
|
||||||
/// <summary> 核心模块 </summary>
|
/// <summary> 核心模块 </summary>
|
||||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||||
|
|
||||||
/// <summary> 更新可视化 </summary>
|
/// <summary> 查询 </summary>
|
||||||
public abstract void UpdateVisual(Data data);
|
public abstract bool Find(Vector3 position, out Data data);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b7a6d69ae9d8c86438ea713a619b8afe
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 25f8d980388c4434381edd852a47ff9a
|
guid: 930f92d77ec6d97418874f1951013093
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public abstract class ModuleScene : MonoBehaviour {
|
|
||||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
|
||||||
protected virtual void Awake() {
|
|
||||||
//if (ModuleCore.ModuleScene != null) { Destroy(gameObject); return; }
|
|
||||||
//ModuleCore.ModuleScene = this;
|
|
||||||
//DontDestroyOnLoad(gameObject);
|
|
||||||
}
|
|
||||||
public virtual void LoadSceneAsync(string scene) {
|
|
||||||
StartCoroutine(ILoadSceneAsync(scene));
|
|
||||||
}
|
|
||||||
public abstract IEnumerator ILoadSceneAsync(string scene);
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 发送模块 广播数据
|
|
||||||
/// </summary>
|
|
||||||
public abstract class ModuleSending<T> : MonoBehaviour {
|
|
||||||
/// <summary> 必须要初始化 </summary>
|
|
||||||
protected abstract void Awake();
|
|
||||||
/// <summary> 核心模块 </summary>
|
|
||||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
|
||||||
|
|
||||||
/// <summary> 当前输入单元 </summary>
|
|
||||||
public abstract T Current { get; }
|
|
||||||
/// <summary> 改变输入单元时触发 </summary>
|
|
||||||
public abstract event Action<T> OnChange;
|
|
||||||
/// <summary> 改变输入单元 </summary>
|
|
||||||
public abstract void Change(T obj);
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: c55842ff76486fd458f30d05c0a5d2fa
|
guid: db1ffe2c1120fec4c9509e838aebb89c
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 烘焙输入模块
|
||||||
|
/// </summary>
|
||||||
|
public class UIInputBaking : ModuleUIInput<UnitMouseInput> {
|
||||||
|
private bool isDownMouseLeft;
|
||||||
|
private bool isDownMouseRight;
|
||||||
|
private UnitMouseInput leftInputUnit;
|
||||||
|
private UnitMouseInput rightInputUnit;
|
||||||
|
|
||||||
|
/// <summary> 设计视图相机模块 </summary>
|
||||||
|
protected ModuleViewCamera ViewCamera => ModuleCore.ViewCameraBaking;
|
||||||
|
|
||||||
|
public override UnitMouseInput Current => leftInputUnit;
|
||||||
|
public override event Action<UnitMouseInput> OnChangeInput;
|
||||||
|
public override void ChangeInput(UnitMouseInput input) {
|
||||||
|
leftInputUnit = input;
|
||||||
|
OnChangeInput?.Invoke(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Awake() {
|
||||||
|
ModuleCore.UIInputBaking = this;
|
||||||
|
rightInputUnit = new BakingRotate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Binding(VisualElement element) {
|
||||||
|
element.RegisterCallback<MouseDownEvent>(MouseDown);
|
||||||
|
element.RegisterCallback<MouseMoveEvent>(MouseMove);
|
||||||
|
element.RegisterCallback<MouseUpEvent>(MouseRelease);
|
||||||
|
element.RegisterCallback<MouseOutEvent>(MouseRelease);
|
||||||
|
element.RegisterCallback<WheelEvent>(ScrollWheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MouseDown(MouseDownEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, 0);
|
||||||
|
if (evt.button == 0) { leftInputUnit.MouseDown(data); isDownMouseLeft = true; }
|
||||||
|
if (evt.button == 1) { rightInputUnit.MouseDown(data); isDownMouseRight = true; }
|
||||||
|
}
|
||||||
|
private void MouseMove(MouseMoveEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, 0);
|
||||||
|
if (isDownMouseLeft) { leftInputUnit.MouseDrag(data); }
|
||||||
|
if (isDownMouseRight) { rightInputUnit.MouseDrag(data); }
|
||||||
|
if (evt.button == 0) { leftInputUnit.MouseMove(data); }
|
||||||
|
if (evt.button == 1) { rightInputUnit.MouseMove(data); }
|
||||||
|
}
|
||||||
|
private void MouseRelease(MouseUpEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, 0);
|
||||||
|
leftInputUnit.MouseRelease(data); isDownMouseLeft = false;
|
||||||
|
rightInputUnit.MouseRelease(data); isDownMouseRight = false;
|
||||||
|
}
|
||||||
|
private void MouseRelease(MouseOutEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, 0);
|
||||||
|
leftInputUnit.MouseRelease(data); isDownMouseLeft = false;
|
||||||
|
rightInputUnit.MouseRelease(data); isDownMouseRight = false;
|
||||||
|
}
|
||||||
|
private void ScrollWheel(WheelEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, evt.delta.y);
|
||||||
|
float size = ViewCamera.Scale + data.ScrollWheel;
|
||||||
|
size = Mathf.Clamp(size, -10f, -1f);
|
||||||
|
ViewCamera.Scale = Mathf.Lerp(ViewCamera.Scale, size, Time.deltaTime * 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataMouseInput CreateData(Vector2 localMousePosition, float scrollWheel) {
|
||||||
|
DataMouseInput data = new DataMouseInput();
|
||||||
|
data.ScrollWheel = scrollWheel;
|
||||||
|
data.ViewPosition = ViewCamera.ScreenToViewPosition(localMousePosition);
|
||||||
|
data.WorldPosition = ViewCamera.ScreenToWorldPosition(localMousePosition);
|
||||||
|
data.ScreenPosition = localMousePosition;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2f4e648fd2afac64eb1a2a9fa2f82246
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计输入模块
|
||||||
|
/// </summary>
|
||||||
|
public class UIInputDesign : ModuleUIInput<UnitMouseInput> {
|
||||||
|
private bool isDownMouseLeft;
|
||||||
|
private bool isDownMouseRight;
|
||||||
|
private UnitMouseInput leftInputUnit;
|
||||||
|
private UnitMouseInput rightInputUnit;
|
||||||
|
|
||||||
|
/// <summary> 设计视图相机模块 </summary>
|
||||||
|
protected ModuleViewCamera ViewCamera => ModuleCore.ViewCameraDesign;
|
||||||
|
|
||||||
|
public override UnitMouseInput Current => leftInputUnit;
|
||||||
|
public override event Action<UnitMouseInput> OnChangeInput;
|
||||||
|
public override void ChangeInput(UnitMouseInput input) {
|
||||||
|
leftInputUnit = input;
|
||||||
|
OnChangeInput?.Invoke(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Awake() {
|
||||||
|
ModuleCore.UIInputDesign = this;
|
||||||
|
rightInputUnit = new DesignMobile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Binding(VisualElement element) {
|
||||||
|
element.RegisterCallback<MouseDownEvent>(MouseDown);
|
||||||
|
element.RegisterCallback<MouseMoveEvent>(MouseMove);
|
||||||
|
element.RegisterCallback<MouseUpEvent>(MouseRelease);
|
||||||
|
element.RegisterCallback<MouseOutEvent>(MouseRelease);
|
||||||
|
element.RegisterCallback<WheelEvent>(ScrollWheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MouseDown(MouseDownEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, 0);
|
||||||
|
if (evt.button == 0) { leftInputUnit.MouseDown(data); isDownMouseLeft = true; }
|
||||||
|
if (evt.button == 1) { rightInputUnit.MouseDown(data); isDownMouseRight = true; }
|
||||||
|
}
|
||||||
|
private void MouseMove(MouseMoveEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, 0);
|
||||||
|
if (isDownMouseLeft) { leftInputUnit.MouseDrag(data); }
|
||||||
|
if (isDownMouseRight) { rightInputUnit.MouseDrag(data); }
|
||||||
|
leftInputUnit.MouseMove(data);
|
||||||
|
rightInputUnit.MouseMove(data);
|
||||||
|
}
|
||||||
|
private void MouseRelease(MouseUpEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, 0);
|
||||||
|
leftInputUnit.MouseRelease(data); isDownMouseLeft = false;
|
||||||
|
rightInputUnit.MouseRelease(data); isDownMouseRight = false;
|
||||||
|
}
|
||||||
|
private void MouseRelease(MouseOutEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, 0);
|
||||||
|
leftInputUnit.MouseRelease(data); isDownMouseLeft = false;
|
||||||
|
rightInputUnit.MouseRelease(data); isDownMouseRight = false;
|
||||||
|
}
|
||||||
|
private void ScrollWheel(WheelEvent evt) {
|
||||||
|
DataMouseInput data = CreateData(evt.localMousePosition, evt.delta.y);
|
||||||
|
float size = ViewCamera.Scale + data.ScrollWheel;
|
||||||
|
size = Mathf.Clamp(size, 0.1f, 4);
|
||||||
|
ViewCamera.Scale = Mathf.Lerp(ViewCamera.Scale, size, Time.deltaTime * 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataMouseInput CreateData(Vector2 localMousePosition, float scrollWheel) {
|
||||||
|
DataMouseInput data = new DataMouseInput();
|
||||||
|
data.ScrollWheel = scrollWheel;
|
||||||
|
data.ViewPosition = ViewCamera.ScreenToViewPosition(localMousePosition);
|
||||||
|
data.WorldPosition = ViewCamera.ScreenToWorldPosition(localMousePosition);
|
||||||
|
data.ScreenPosition = localMousePosition;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: be53272c8efb1d74e9e1ebb4aca3c814
|
guid: aea30e84af7b7ad4ab623d28e7668fcb
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
public class UIPageGarmentSewing : ModuleUIPage {
|
||||||
|
private TopMenu topMenu;
|
||||||
|
private VisualElement TopMenuElement => Q<VisualElement>("TopMenu");
|
||||||
|
protected override void Awake() => ModuleCore.CurrentPage = this;
|
||||||
|
|
||||||
|
private void Start() {
|
||||||
|
topMenu = new TopMenu(TopMenuElement);
|
||||||
|
topMenu.ClickTopMenu1 = () => { };
|
||||||
|
topMenu.ClickTopMenu2 = () => { ModuleCore.PresetsPlateWindow.Open(null); };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d436e806ac6755d4fb29cdb0f7208615
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
public abstract class ModuleUIPanel<Data> : MonoBehaviour {
|
|
||||||
public ModuleUIPage ModuleUIPage;
|
|
||||||
public VisualTreeAsset ModuleUIPanelAsset;
|
|
||||||
|
|
||||||
protected VisualElement element;
|
|
||||||
protected readonly string defaultStyleClass = "module-ui-panel";
|
|
||||||
|
|
||||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
|
||||||
|
|
||||||
/// <summary> MonoBehaviour Awake </summary>
|
|
||||||
public abstract void Awake();
|
|
||||||
/// <summary> 打开模块,并且传进参数 </summary>
|
|
||||||
public abstract void Open(Data data);
|
|
||||||
/// <summary> 关闭模块 </summary>
|
|
||||||
public abstract void Close();
|
|
||||||
|
|
||||||
protected void InitElement(bool hide = true) {
|
|
||||||
element = ModuleUIPanelAsset.Instantiate();
|
|
||||||
ModuleUIPage.Add(element);
|
|
||||||
element.AddToClassList(defaultStyleClass);
|
|
||||||
element.style.display = hide ? DisplayStyle.None : DisplayStyle.Flex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 3b65f36076867594bbc3bd06880b8497
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: ada184a497ebf2c429faa290f243c729
|
guid: 9083014378a5c3e4caaddd160ff79450
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
public class UIWindowPresetsPlate : ModuleUIWindow<Action> {
|
||||||
|
public VisualTreeAsset PresetsPlateUnitAsset;
|
||||||
|
private UIPresetsPlate presetsPlate;
|
||||||
|
private VisualElement element => ModuleUIPage.Q<VisualElement>("PresetsPlate");
|
||||||
|
|
||||||
|
/// <summary> 资源模块 </summary>
|
||||||
|
private ModuleAssets<DataPlate> AssetsPlate => ModuleCore.AssetsPlate;
|
||||||
|
/// <summary> 预设资源模块 </summary>
|
||||||
|
private ModuleAssets<DataPlatePresets> AssetsPlatePresets => ModuleCore.AssetsPlatePresets;
|
||||||
|
/// <summary> 转换模块 </summary>
|
||||||
|
private ModuleBuilder<DataPlatePresets, DataPlate> PlatePresetsToPlate => ModuleCore.PlatePresetsToPlate;
|
||||||
|
|
||||||
|
public override void Awake() {
|
||||||
|
ModuleCore.PresetsPlateWindow = this;
|
||||||
|
presetsPlate = new UIPresetsPlate(element);
|
||||||
|
|
||||||
|
presetsPlate.ClickClose = Close;
|
||||||
|
}
|
||||||
|
public override void Open(Action data) {
|
||||||
|
element.style.display = DisplayStyle.Flex;
|
||||||
|
presetsPlate.Clear();
|
||||||
|
AssetsPlatePresets.ForEach(Create);
|
||||||
|
}
|
||||||
|
public override void Close() {
|
||||||
|
presetsPlate.Clear();
|
||||||
|
element.style.display = DisplayStyle.None;
|
||||||
|
}
|
||||||
|
private void Create(DataPlatePresets data) {
|
||||||
|
VisualElement temp = PresetsPlateUnitAsset.Instantiate();
|
||||||
|
UIPresetsPlateUnit unit = new UIPresetsPlateUnit(temp, data);
|
||||||
|
unit.Click = () => { CreateTemplate(data); };
|
||||||
|
presetsPlate.Add(unit);
|
||||||
|
}
|
||||||
|
private void CreateTemplate(DataPlatePresets data) {
|
||||||
|
DataPlate dataPlate = PlatePresetsToPlate.To(data);
|
||||||
|
AssetsPlate.Add(dataPlate);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a930d912222858846a23606c170a59d8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public abstract class ModuleVideo : MonoBehaviour {
|
|
||||||
protected virtual ModuleCore Core => ModuleCore.I;
|
|
||||||
protected virtual void Awake() => Core.FunctionRegister(this);
|
|
||||||
|
|
||||||
/// <summary> 视频播放状态 </summary>
|
|
||||||
public virtual bool isPlaying => IsPlaying();
|
|
||||||
/// <summary> 从0开始的视频计数,x = 当前索引,y = 最大索引 </summary>
|
|
||||||
public virtual Vector2Int videoCount => VideoCount();
|
|
||||||
/// <summary> 视频渲染纹理 </summary>
|
|
||||||
public virtual RenderTexture renderTexture => RenderTexture();
|
|
||||||
/// <summary> 当前视频播放时间 </summary>
|
|
||||||
public virtual double time => Time();
|
|
||||||
/// <summary> 最大视频播放时间 </summary>
|
|
||||||
public virtual double maxTime => MaxTime();
|
|
||||||
/// <summary> 当前播放帧 </summary>
|
|
||||||
public virtual long frame { get => GetFrame(); set => SetFrame(value); }
|
|
||||||
/// <summary> 最大播放帧 </summary>
|
|
||||||
public virtual ulong frameCount => FrameCount();
|
|
||||||
|
|
||||||
/// <summary> 视频播放状态 </summary>
|
|
||||||
protected abstract bool IsPlaying();
|
|
||||||
/// <summary> 从0开始的视频计数,x = 当前索引,y = 最大索引 </summary>
|
|
||||||
protected abstract Vector2Int VideoCount();
|
|
||||||
/// <summary> 视频渲染纹理 </summary>
|
|
||||||
protected abstract RenderTexture RenderTexture();
|
|
||||||
/// <summary> 当前视频播放时间 </summary>
|
|
||||||
protected abstract double Time();
|
|
||||||
/// <summary> 最大视频播放时间 </summary>
|
|
||||||
protected abstract double MaxTime();
|
|
||||||
/// <summary> get当前播放帧 </summary>
|
|
||||||
protected abstract long GetFrame();
|
|
||||||
/// <summary> set当前播放帧 </summary>
|
|
||||||
protected abstract void SetFrame(long value);
|
|
||||||
/// <summary> 最大播放帧 </summary>
|
|
||||||
protected abstract ulong FrameCount();
|
|
||||||
|
|
||||||
/// <summary> 播放视频 </summary>
|
|
||||||
public abstract void Play();
|
|
||||||
/// <summary> 暂停视频 </summary>
|
|
||||||
public abstract void Pause();
|
|
||||||
/// <summary> 停止视频 </summary>
|
|
||||||
public abstract void Stop();
|
|
||||||
/// <summary> 根据索引播放视频 </summary>
|
|
||||||
public abstract void SetIndex(int value);
|
|
||||||
/// <summary> 根据累加的索引播放视频 </summary>
|
|
||||||
public abstract void AddIndex(int value);
|
|
||||||
|
|
||||||
/// <summary> 设置视频数据 </summary>
|
|
||||||
public abstract void SetValue(DataVideo value);
|
|
||||||
/// <summary> 设置视频数据列表 </summary>
|
|
||||||
public abstract void SetValue(List<DataVideo> list);
|
|
||||||
|
|
||||||
/// <summary> 设置视频数据,并且播放 </summary>
|
|
||||||
public virtual void Play(DataVideo value) { SetValue(value); Play(); }
|
|
||||||
/// <summary> 设置视频数据列表,并且第一个播放index位置的视频数据 </summary>
|
|
||||||
public virtual void Play(List<DataVideo> list, int index = 0) { SetValue(list); SetIndex(index); }
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 13d44cd5aaa7e9d4380cd6f8d1af21f1
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 视图相机,把内容渲染到渲染纹理上
|
|
||||||
/// </summary>
|
|
||||||
public abstract class ModuleViewCamera : MonoBehaviour {
|
|
||||||
/// <summary> 必须要初始化 </summary>
|
|
||||||
protected abstract void Awake();
|
|
||||||
/// <summary> 核心模块 </summary>
|
|
||||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
|
||||||
|
|
||||||
/// <summary> 视图位置 </summary>
|
|
||||||
public abstract Vector3 position { get; set; }
|
|
||||||
/// <summary> 视图旋转 </summary>
|
|
||||||
public abstract Vector3 eulerAngles { get; set; }
|
|
||||||
/// <summary> 视图缩放 </summary>
|
|
||||||
public abstract float scale { get; set; }
|
|
||||||
/// <summary> 渲染纹理 </summary>
|
|
||||||
public abstract RenderTexture RenderTexture { get; }
|
|
||||||
|
|
||||||
/// <summary> 更新渲染纹理 </summary>
|
|
||||||
public abstract void UpdateRenderTexture(int x, int y);
|
|
||||||
/// <summary> 屏幕坐标转换视图坐标(0-1) </summary>
|
|
||||||
public abstract Vector3 ScreenToViewPosition(Vector3 screenPosition);
|
|
||||||
/// <summary> 屏幕坐标转换世界坐标 </summary>
|
|
||||||
public abstract Vector3 ScreenToWorldPosition(Vector3 screenPosition);
|
|
||||||
/// <summary> 视图坐标(0-1)转换屏幕坐标 </summary>
|
|
||||||
public abstract Vector3 ViewToScreenPosition(Vector3 screenPosition);
|
|
||||||
/// <summary> 视图坐标(0-1)转换世界坐标 </summary>
|
|
||||||
public abstract Vector3 ViewToWorldPosition(Vector3 screenPosition);
|
|
||||||
/// <summary> 世界坐标转换屏幕坐标 </summary>
|
|
||||||
public abstract Vector3 WorldToScreenPosition(Vector3 screenPosition);
|
|
||||||
/// <summary> 世界坐标转换视图坐标(0-1) </summary>
|
|
||||||
public abstract Vector3 WorldToViewPosition(Vector3 screenPosition);
|
|
||||||
}
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 23fd5b1b4a536aa47a60881556c8e716
|
guid: 8c1f6f992590ee740829401bdf9c7486
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 视图相机,把内容渲染到渲染纹理上
|
||||||
|
/// </summary>
|
||||||
|
public abstract class ModuleViewCamera : MonoBehaviour {
|
||||||
|
/// <summary> 默认图层遮罩 </summary>
|
||||||
|
public static readonly LayerMask DefaultLayerMask = ~(1 << 0) | 1 << 0;
|
||||||
|
/// <summary> 必须要初始化 </summary>
|
||||||
|
protected abstract void Awake();
|
||||||
|
/// <summary> 核心模块 </summary>
|
||||||
|
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||||
|
|
||||||
|
/// <summary> 视图位置 </summary>
|
||||||
|
public abstract Vector3 Position { get; set; }
|
||||||
|
/// <summary> 视图旋转 </summary>
|
||||||
|
public abstract Vector3 EulerAngles { get; set; }
|
||||||
|
/// <summary> 视图缩放 </summary>
|
||||||
|
public abstract float Scale { get; set; }
|
||||||
|
/// <summary> 视图绿轴 </summary>
|
||||||
|
public abstract Vector3 Up { get; }
|
||||||
|
/// <summary> 视图红轴 </summary>
|
||||||
|
public abstract Vector3 Right { get; }
|
||||||
|
/// <summary> 视图蓝轴 </summary>
|
||||||
|
public abstract Vector3 Forward { get; }
|
||||||
|
/// <summary> 当前相机位置 </summary>
|
||||||
|
public abstract Vector3 CameraPosition { get; }
|
||||||
|
/// <summary> 渲染纹理 </summary>
|
||||||
|
public abstract RenderTexture RenderTexture { get; }
|
||||||
|
|
||||||
|
/// <summary> 更新渲染纹理 </summary>
|
||||||
|
public abstract void UpdateRenderTexture(int x, int y);
|
||||||
|
/// <summary> 屏幕坐标转换视图坐标(0-1) </summary>
|
||||||
|
public abstract Vector3 ScreenToViewPosition(Vector3 screenPosition);
|
||||||
|
/// <summary> 屏幕坐标转换世界坐标 </summary>
|
||||||
|
public abstract Vector3 ScreenToWorldPosition(Vector3 screenPosition);
|
||||||
|
/// <summary> 视图坐标(0-1)转换屏幕坐标 </summary>
|
||||||
|
//public abstract Vector3 ViewToScreenPosition(Vector3 screenPosition);
|
||||||
|
///// <summary> 视图坐标(0-1)转换世界坐标 </summary>
|
||||||
|
//public abstract Vector3 ViewToWorldPosition(Vector3 screenPosition);
|
||||||
|
///// <summary> 世界坐标转换屏幕坐标 </summary>
|
||||||
|
//public abstract Vector3 WorldToScreenPosition(Vector3 screenPosition);
|
||||||
|
///// <summary> 世界坐标转换视图坐标(0-1) </summary>
|
||||||
|
//public abstract Vector3 WorldToViewPosition(Vector3 screenPosition);
|
||||||
|
|
||||||
|
/// <summary> 屏幕坐标获取世界对象 </summary>
|
||||||
|
public abstract bool ScreenToWorldObject<T>(Vector3 screenPosition, out T value) where T : Object;
|
||||||
|
/// <summary> 屏幕坐标获取世界对象 </summary>
|
||||||
|
public abstract bool ScreenToWorldObject<T>(Vector3 screenPosition, out T value, LayerMask planeLayerMask) where T : Object;
|
||||||
|
/// <summary> 屏幕坐标获取世界对象的父对象 </summary>
|
||||||
|
public abstract bool ScreenToWorldObjectParent<T>(Vector3 screenPosition, out T value) where T : Object;
|
||||||
|
/// <summary> 屏幕坐标获取世界对象的父对象 </summary>
|
||||||
|
public abstract bool ScreenToWorldObjectParent<T>(Vector3 screenPosition, out T value, LayerMask planeLayerMask) where T : Object;
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ViewCameraBaking : ModuleViewCamera {
|
||||||
|
public readonly Vector3 CameraOffset = new Vector3(0, 0, -1.5f);
|
||||||
|
public Camera viewCamera;
|
||||||
|
public Transform viewOrigin;
|
||||||
|
public Transform viewSpace;
|
||||||
|
private RaycastHit hitInfo;
|
||||||
|
private RenderTexture renderTexture;
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.ViewCameraBaking = this;
|
||||||
|
|
||||||
|
public override Vector3 Position {
|
||||||
|
get => viewOrigin.localPosition;
|
||||||
|
set => viewOrigin.localPosition = value;
|
||||||
|
}
|
||||||
|
public override Vector3 EulerAngles {
|
||||||
|
get => viewOrigin.eulerAngles;
|
||||||
|
set => viewOrigin.eulerAngles = value;
|
||||||
|
}
|
||||||
|
public override float Scale {
|
||||||
|
get => viewCamera.transform.localPosition.z;
|
||||||
|
set => viewCamera.transform.localPosition = new Vector3(0, 0, value);
|
||||||
|
}
|
||||||
|
public override Vector3 Up {
|
||||||
|
get => viewOrigin.up;
|
||||||
|
}
|
||||||
|
public override Vector3 Right {
|
||||||
|
get => viewOrigin.right;
|
||||||
|
}
|
||||||
|
public override Vector3 Forward {
|
||||||
|
get => viewOrigin.forward;
|
||||||
|
}
|
||||||
|
public override Vector3 CameraPosition {
|
||||||
|
get => viewOrigin.localPosition;
|
||||||
|
}
|
||||||
|
public override RenderTexture RenderTexture {
|
||||||
|
get => renderTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateRenderTexture(int x, int y) {
|
||||||
|
renderTexture = new RenderTexture(x, y, 0);
|
||||||
|
viewCamera.targetTexture = renderTexture;
|
||||||
|
}
|
||||||
|
public override Vector3 ScreenToViewPosition(Vector3 screenPosition) {
|
||||||
|
float x = screenPosition.x / viewCamera.pixelWidth;
|
||||||
|
float y = 1 - screenPosition.y / viewCamera.pixelHeight;
|
||||||
|
Vector3 viewPosition = new Vector3(x, y);
|
||||||
|
return viewPosition;
|
||||||
|
}
|
||||||
|
public override Vector3 ScreenToWorldPosition(Vector3 screenPosition) {
|
||||||
|
Vector3 viewPosition = ScreenToViewPosition(screenPosition);
|
||||||
|
float aspectRatio = (float)viewCamera.pixelWidth / viewCamera.pixelHeight;
|
||||||
|
Vector3 ratio = viewPosition - new Vector3(0.5f, 0.5f);
|
||||||
|
return new Vector3(ratio.x * aspectRatio, ratio.y) * Scale + viewOrigin.position;
|
||||||
|
}
|
||||||
|
//public override Vector3 ViewToScreenPosition(Vector3 screenPosition) {
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
//}
|
||||||
|
//public override Vector3 ViewToWorldPosition(Vector3 screenPosition) {
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
//}
|
||||||
|
//public override Vector3 WorldToScreenPosition(Vector3 screenPosition) {
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
//}
|
||||||
|
//public override Vector3 WorldToViewPosition(Vector3 screenPosition) {
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
//}
|
||||||
|
|
||||||
|
public override bool ScreenToWorldObject<T>(Vector3 screenPosition, out T value) {
|
||||||
|
return ScreenToWorldObject(screenPosition, out value, DefaultLayerMask);
|
||||||
|
}
|
||||||
|
public override bool ScreenToWorldObject<T>(Vector3 screenPosition, out T value, LayerMask planeLayerMask) {
|
||||||
|
Vector3 viewPosition = ScreenToViewPosition(screenPosition);
|
||||||
|
Ray ray = viewCamera.ViewportPointToRay(viewPosition);
|
||||||
|
Physics.Raycast(ray, out hitInfo, 200, planeLayerMask);
|
||||||
|
value = hitInfo.transform?.GetComponent<T>();
|
||||||
|
return value != null;
|
||||||
|
}
|
||||||
|
public override bool ScreenToWorldObjectParent<T>(Vector3 screenPosition, out T value) {
|
||||||
|
return ScreenToWorldObjectParent(screenPosition, out value, DefaultLayerMask);
|
||||||
|
}
|
||||||
|
public override bool ScreenToWorldObjectParent<T>(Vector3 screenPosition, out T value, LayerMask planeLayerMask) {
|
||||||
|
Vector3 viewPosition = ScreenToViewPosition(screenPosition);
|
||||||
|
Ray ray = viewCamera.ViewportPointToRay(viewPosition);
|
||||||
|
Physics.Raycast(ray, out hitInfo, 200, planeLayerMask);
|
||||||
|
value = hitInfo.transform?.GetComponentInParent<T>();
|
||||||
|
return value != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ViewCameraDesign : ModuleViewCamera {
|
||||||
|
public Camera viewCamera;
|
||||||
|
public Transform viewSpace;
|
||||||
|
private RaycastHit hitInfo;
|
||||||
|
private RenderTexture renderTexture;
|
||||||
|
private readonly Vector3 CameraOffset = new Vector3(0, 0, -1.5f);
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.ViewCameraDesign = this;
|
||||||
|
|
||||||
|
public override Vector3 Position {
|
||||||
|
get => viewCamera.transform.localPosition - CameraOffset;
|
||||||
|
set => viewCamera.transform.localPosition = value + CameraOffset;
|
||||||
|
}
|
||||||
|
public override Vector3 EulerAngles {
|
||||||
|
get => viewCamera.transform.eulerAngles;
|
||||||
|
set => viewCamera.transform.eulerAngles = value;
|
||||||
|
}
|
||||||
|
public override float Scale {
|
||||||
|
get => viewCamera.orthographicSize;
|
||||||
|
set => viewCamera.orthographicSize = value;
|
||||||
|
}
|
||||||
|
public override Vector3 Up {
|
||||||
|
get => viewCamera.transform.up;
|
||||||
|
}
|
||||||
|
public override Vector3 Right {
|
||||||
|
get => viewCamera.transform.right;
|
||||||
|
}
|
||||||
|
public override Vector3 Forward {
|
||||||
|
get => viewCamera.transform.forward;
|
||||||
|
}
|
||||||
|
public override Vector3 CameraPosition {
|
||||||
|
get => viewCamera.transform.localPosition - CameraOffset;
|
||||||
|
}
|
||||||
|
public override RenderTexture RenderTexture {
|
||||||
|
get => renderTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateRenderTexture(int x, int y) {
|
||||||
|
renderTexture = new RenderTexture(x, y, 0);
|
||||||
|
viewCamera.targetTexture = renderTexture;
|
||||||
|
}
|
||||||
|
public override Vector3 ScreenToViewPosition(Vector3 screenPosition) {
|
||||||
|
float x = screenPosition.x / viewCamera.pixelWidth;
|
||||||
|
float y = 1 - screenPosition.y / viewCamera.pixelHeight;
|
||||||
|
Vector3 mouseRatio = new Vector3(x - 0.5f, y - 0.5f);
|
||||||
|
float aspectRatio = (float)viewCamera.pixelWidth / viewCamera.pixelHeight;
|
||||||
|
return new Vector3(mouseRatio.x * aspectRatio, mouseRatio.y) * 2;
|
||||||
|
}
|
||||||
|
public override Vector3 ScreenToWorldPosition(Vector3 screenPosition) {
|
||||||
|
return ScreenToViewPosition(screenPosition) * Scale + Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool ScreenToWorldObject<T>(Vector3 screenPosition, out T value) {
|
||||||
|
return ScreenToWorldObject(screenPosition, out value, DefaultLayerMask);
|
||||||
|
}
|
||||||
|
public override bool ScreenToWorldObject<T>(Vector3 screenPosition, out T value, LayerMask planeLayerMask) {
|
||||||
|
Vector3 viewPosition = ScreenToViewPosition(screenPosition);
|
||||||
|
Vector3 worldPosition = viewPosition * Scale + viewCamera.transform.position;
|
||||||
|
Ray ray = new Ray(worldPosition, viewCamera.transform.forward);
|
||||||
|
Physics.Raycast(ray, out hitInfo, 200, planeLayerMask);
|
||||||
|
value = hitInfo.transform?.GetComponent<T>();
|
||||||
|
return value != null;
|
||||||
|
}
|
||||||
|
public override bool ScreenToWorldObjectParent<T>(Vector3 screenPosition, out T value) {
|
||||||
|
return ScreenToWorldObjectParent(screenPosition, out value, DefaultLayerMask);
|
||||||
|
}
|
||||||
|
public override bool ScreenToWorldObjectParent<T>(Vector3 screenPosition, out T value, LayerMask planeLayerMask) {
|
||||||
|
Vector3 viewPosition = ScreenToViewPosition(screenPosition);
|
||||||
|
Vector3 worldPosition = viewPosition * Scale + viewCamera.transform.position;
|
||||||
|
Ray ray = new Ray(worldPosition, viewCamera.transform.forward);
|
||||||
|
Physics.Raycast(ray, out hitInfo, 200, planeLayerMask);
|
||||||
|
value = hitInfo.transform?.GetComponentInParent<T>();
|
||||||
|
return value != null;
|
||||||
|
}
|
||||||
|
//public override Vector3 ViewToScreenPosition(Vector3 screenPosition) {
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
//}
|
||||||
|
//public override Vector3 ViewToWorldPosition(Vector3 screenPosition) {
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
//}
|
||||||
|
//public override Vector3 WorldToScreenPosition(Vector3 screenPosition) {
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
//}
|
||||||
|
//public override Vector3 WorldToViewPosition(Vector3 screenPosition) {
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
//}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 147f3f6086f4a504ba7edb9ae6282915
|
guid: 6f8f76170dafc9549adcb43c6b78e751
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成可视化内容模块
|
||||||
|
/// </summary>
|
||||||
|
public abstract class ModuleVisual<Data> : MonoBehaviour {
|
||||||
|
/// <summary> 必须要初始化 </summary>
|
||||||
|
protected abstract void Awake();
|
||||||
|
/// <summary> 核心模块 </summary>
|
||||||
|
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||||
|
|
||||||
|
/// <summary> 更新可视化内容 </summary>
|
||||||
|
public abstract void UpdateVisual(Data data);
|
||||||
|
/// <summary> 释放可视化内容 </summary>
|
||||||
|
public abstract void ReleaseVisual(Data data);
|
||||||
|
|
||||||
|
/// <summary> 创建可视化内容 </summary>
|
||||||
|
public void Create<T>(ref T value, Transform original, Transform parent) {
|
||||||
|
if (value != null) { return; }
|
||||||
|
Transform temp = CreateTransform(original, parent);
|
||||||
|
value = temp.GetComponent<T>();
|
||||||
|
}
|
||||||
|
public Transform CreateTransform(Transform original, Transform parent) {
|
||||||
|
Transform temp = Instantiate(original, parent);
|
||||||
|
temp.gameObject.SetActive(true);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class VisualBaking : ModuleVisual<DataPlate> {
|
||||||
|
public Transform viewSpace;
|
||||||
|
public Transform platePrefab;//板片
|
||||||
|
public Transform suturePrefab;//缝合
|
||||||
|
public Transform sutureSidePrefab;//缝合边
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.VisualBaking = this;
|
||||||
|
|
||||||
|
public override void UpdateVisual(DataPlate plate) {
|
||||||
|
//更新板片
|
||||||
|
Create(ref plate.baking, platePrefab, viewSpace);
|
||||||
|
plate.baking.UpdateVisual(plate);
|
||||||
|
//子数据父对象
|
||||||
|
Transform parent = plate.design.transform;
|
||||||
|
//更新线段
|
||||||
|
plate.sides.ForEach(obj => UpdateVisual(obj, parent));
|
||||||
|
}
|
||||||
|
public override void ReleaseVisual(DataPlate data) {
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateVisual(DataSide side, Transform parent) {
|
||||||
|
//Create(ref side.design, sidePrefab, parent);
|
||||||
|
//side.design.UpdateVisual(side);
|
||||||
|
//更新缝合线
|
||||||
|
if (side.suture == null) { return; }
|
||||||
|
//side.suture.Update();
|
||||||
|
UpdateVisual(side.suture, viewSpace);
|
||||||
|
}
|
||||||
|
/// <summary> 更新缝合数据 </summary>
|
||||||
|
private void UpdateVisual(DataSuture suture, Transform parent) {
|
||||||
|
Create(ref suture.baking, suturePrefab, parent);
|
||||||
|
UpdateVisual(suture.a, suture.baking.transform);
|
||||||
|
UpdateVisual(suture.b, suture.baking.transform);
|
||||||
|
suture.baking.UpdateVisual(suture);
|
||||||
|
}
|
||||||
|
/// <summary> 更新缝合边 </summary>
|
||||||
|
private void UpdateVisual(DataSutureSide sutureSide, Transform parent) {
|
||||||
|
Create(ref sutureSide.baking, sutureSidePrefab, parent);
|
||||||
|
sutureSide.baking.UpdateVisual(sutureSide);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 545b7804867d268448f7089215e20f39
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 连接可视化模块
|
||||||
|
/// </summary>
|
||||||
|
public class VisualConnector : ModuleVisual<DataConnector> {
|
||||||
|
public Transform viewSpace;
|
||||||
|
public Transform connectorPrefab;//板片
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.VisualConnector = this;
|
||||||
|
|
||||||
|
public override void UpdateVisual(DataConnector data) {
|
||||||
|
//更新板片
|
||||||
|
Create(ref data.visual, connectorPrefab, viewSpace);
|
||||||
|
data.visual.UpdateVisual(data);
|
||||||
|
}
|
||||||
|
public override void ReleaseVisual(DataConnector data) {
|
||||||
|
if (data.visual != null) {
|
||||||
|
Destroy(data.visual.gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ea4effe5ac0300348b249f05af7bf201
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 版片可视化模块
|
||||||
|
/// </summary>
|
||||||
|
public class VisualDesign : ModuleVisual<DataPlate> {
|
||||||
|
public Transform viewSpace;
|
||||||
|
public Transform platePrefab;//板片
|
||||||
|
public Transform pointPrefab;//点
|
||||||
|
public Transform sidePrefab;//边
|
||||||
|
public Transform suturePrefab;//缝合
|
||||||
|
public Transform sutureSidePrefab;//缝合边
|
||||||
|
|
||||||
|
protected override void Awake() => ModuleCore.VisualDesign = this;
|
||||||
|
|
||||||
|
public override void UpdateVisual(DataPlate plate) {
|
||||||
|
//更新板片
|
||||||
|
Create(ref plate.design, platePrefab, viewSpace);
|
||||||
|
plate.design.UpdateVisual(plate);
|
||||||
|
//子数据父对象
|
||||||
|
Transform parent = plate.design.transform;
|
||||||
|
//更新点
|
||||||
|
plate.points.ForEach(obj => UpdateVisual(obj, parent));
|
||||||
|
//更新线段
|
||||||
|
plate.sides.ForEach(obj => UpdateVisual(obj, parent));
|
||||||
|
}
|
||||||
|
public override void ReleaseVisual(DataPlate data) {
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateVisual(DataPoint point, Transform parent) {
|
||||||
|
Create(ref point.visual, pointPrefab, parent);
|
||||||
|
point.visual.UpdateVisual(point);
|
||||||
|
}
|
||||||
|
private void UpdateVisual(DataSide side, Transform parent) {
|
||||||
|
Create(ref side.design, sidePrefab, parent);
|
||||||
|
side.design.UpdateVisual(side);
|
||||||
|
//更新缝合线
|
||||||
|
if (side.suture == null) { return; }
|
||||||
|
side.suture.Update();
|
||||||
|
UpdateVisual(side.suture, viewSpace);
|
||||||
|
}
|
||||||
|
/// <summary> 更新缝合数据 </summary>
|
||||||
|
private void UpdateVisual(DataSuture suture, Transform parent) {
|
||||||
|
Create(ref suture.design, suturePrefab, parent);
|
||||||
|
UpdateVisual(suture.a, suture.design.transform);
|
||||||
|
UpdateVisual(suture.b, suture.design.transform);
|
||||||
|
suture.design.UpdateVisual(suture);
|
||||||
|
}
|
||||||
|
/// <summary> 更新缝合边 </summary>
|
||||||
|
private void UpdateVisual(DataSutureSide sutureSide, Transform parent) {
|
||||||
|
Create(ref sutureSide.design, sutureSidePrefab, parent);
|
||||||
|
sutureSide.design.UpdateVisual(sutureSide);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 58ff5a6890e46a84ba577fc1e0c0d99b
|
guid: 2857d590c8aa00b41850f9d7eb170b60
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class DataBezier {
|
||||||
|
/// <summary> 是否是a </summary>
|
||||||
|
public bool isA;
|
||||||
|
/// <summary> 关联的边 </summary>
|
||||||
|
public DataSide side;
|
||||||
|
/// <summary> 位置 </summary>
|
||||||
|
public Vector3 position => isA ? side.aBezier : side.bBezier;
|
||||||
|
|
||||||
|
public void SetBezierPosition(Vector3 value) {
|
||||||
|
if (isA) { side.SetBezierPositionA(value); }
|
||||||
|
else { side.SetBezierPositionB(value); }
|
||||||
|
side.plate.UpdateVisual();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 72061d1b84a6a8b41978089a92f87ccb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary> 2D边界数据 </summary>
|
||||||
|
public class DataBorder {
|
||||||
|
public readonly float minX = 0;
|
||||||
|
public readonly float maxX = 0;
|
||||||
|
public readonly float minY = 0;
|
||||||
|
public readonly float maxY = 0;
|
||||||
|
/// <summary> 2D边界数据 </summary>
|
||||||
|
public DataBorder(float minX, float maxX, float minY, float maxY) {
|
||||||
|
this.minX = minX; this.maxX = maxX;
|
||||||
|
this.minY = minY; this.maxY = maxY;
|
||||||
|
}
|
||||||
|
/// <summary> 边界宽 </summary>
|
||||||
|
public float Wide => maxX - minX;
|
||||||
|
/// <summary> 边界高 </summary>
|
||||||
|
public float High => maxY - minY;
|
||||||
|
/// <summary> 最小点 </summary>
|
||||||
|
public Vector3 MinPoint => new Vector3(minX, minY, 0);
|
||||||
|
/// <summary> 最大点 </summary>
|
||||||
|
public Vector3 MaxPoint => new Vector3(maxX, maxY, 0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 402c90a27e984c3448d7d1aec8ea3e78
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class DataConnector {
|
||||||
|
|
||||||
|
#region 核心数据
|
||||||
|
public Vector3 aPoint;
|
||||||
|
public Vector3 bPoint;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 可视化数据
|
||||||
|
/// <summary> 可视化对象 </summary>
|
||||||
|
public PrefabConnector visual;
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2aa5648d6f9298f4ab08f95a6cf4927a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class DataFindBezier {
|
|
||||||
|
|
||||||
/// <summary> 有效的点 </summary>
|
|
||||||
public bool IsValid => plate != null && point != null;
|
|
||||||
|
|
||||||
#region 输入
|
|
||||||
/// <summary> 位置 (需要和点同一个坐标系) </summary>
|
|
||||||
public Vector3 position;
|
|
||||||
/// <summary> 板片数据 </summary>
|
|
||||||
public List<DataPlate> datas;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 输出
|
|
||||||
/// <summary> 是前点(-) </summary>
|
|
||||||
public bool isFront;
|
|
||||||
/// <summary> 查询到的板片 </summary>
|
|
||||||
public DataPlate plate;
|
|
||||||
/// <summary> 查询到的点 </summary>
|
|
||||||
public DataPoint point;
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 538ffda5b096d9d4cb1916697828a300
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class DataFindPoint {
|
|
||||||
|
|
||||||
/// <summary> 有效的板片 </summary>
|
|
||||||
public bool IsValidPlate => plate != null;
|
|
||||||
/// <summary> 有效的点 </summary>
|
|
||||||
public bool IsValidPoint => point != null;
|
|
||||||
|
|
||||||
#region 输入
|
|
||||||
/// <summary> 位置 (需要和点同一个坐标系) </summary>
|
|
||||||
public Vector3 position;
|
|
||||||
/// <summary> 板片数据 </summary>
|
|
||||||
public List<DataPlate> datas;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 输出
|
|
||||||
/// <summary> 查询到的板片 </summary>
|
|
||||||
public DataPlate plate;
|
|
||||||
/// <summary> 查询到的点 </summary>
|
|
||||||
public DataPoint point;
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e7f89410b01930c418b1df0a10a9f4cc
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -3,24 +3,14 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class DataInsertPoint {
|
public class DataInsertPoint {
|
||||||
|
|
||||||
/// <summary> 有效的</summary>
|
|
||||||
public bool IsValid => plate != null && aPoint != null && bPoint != null;
|
|
||||||
|
|
||||||
#region 输入
|
|
||||||
/// <summary> 位置 (需要和点同一个坐标系) </summary>
|
/// <summary> 位置 (需要和点同一个坐标系) </summary>
|
||||||
public Vector3 position;
|
public Vector3 position;
|
||||||
/// <summary> 板片数据 </summary>
|
|
||||||
public List<DataPlate> datas;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 输出
|
|
||||||
/// <summary> 执行操作的板片 </summary>
|
/// <summary> 执行操作的板片 </summary>
|
||||||
public DataPlate plate;
|
public DataPlate plate;
|
||||||
/// <summary> A点 </summary>
|
/// <summary> A点 </summary>
|
||||||
public DataPoint aPoint;
|
public DataPoint aPoint;
|
||||||
/// <summary> B点 </summary>
|
/// <summary> B点 </summary>
|
||||||
public DataPoint bPoint;
|
public DataPoint bPoint;
|
||||||
#endregion
|
/// <summary> 关联的线段 </summary>
|
||||||
|
public DataSide side;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary> 交点信息 </summary>
|
||||||
|
public class DataIntersect {
|
||||||
|
public readonly DataSide side;
|
||||||
|
public readonly Vector3 position;
|
||||||
|
/// <summary> 交点信息 </summary>
|
||||||
|
public DataIntersect(DataSide side, Vector3 position) {
|
||||||
|
this.side = side;
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
/// <summary> 是否相交 </summary>
|
||||||
|
public bool isIntersect;
|
||||||
|
/// <summary> 交点 </summary>
|
||||||
|
public Vector3 intersectPoint;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a8a4a29bf6f0fa14294e815ac39c81ad
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标记数据
|
||||||
|
/// </summary>
|
||||||
|
public class DataMark {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 61c3a2815406bfa4190a319d431b8fc5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user