public void GenerateEdgeMesh(Action <Mesh> onGenerateMesh) { if (lastPaintIndex == -1) { Debug.LogError("lastPaintIndex == -1"); return; } SafetyAreaEightNeighbourHelper.EightNeighbours(lastPaintIndex, (index) => { return(colors[index] == Color.red); }, (edgeIndices) => { float planeHeight = groundHeightStep.GetPlaneHeight(); Mesh edgeMesh = SafetyAreaVertexHelper.GenerateEdgeMesh(mesh, edgeIndices, planeHeight + 5f, planeHeight); onGenerateMesh?.Invoke(edgeMesh); }); }
public void Init() { if (groundHeightStep == null) { groundHeightStep = SafetyAreaManager.Instance.GetStep <GroundHeightStep>(SafetyAreaStepEnum.GroundHeight); } MeshFilter meshFilter = this.gameObject.AddComponent <MeshFilter>(); meshFilter.mesh = SafetyAreaVertexHelper.GeneratePlaneMesh(); mesh = meshFilter.mesh; MeshRenderer meshRenderer = this.gameObject.AddComponent <MeshRenderer>(); meshRenderer.material = Resources.Load <Material>("Material/SafetyPlaneMat"); MeshCollider meshCollider = this.gameObject.AddComponent <MeshCollider>(); meshCollider.sharedMesh = mesh; ClearMeshColor(); }
public void FillNearest(PointerEventData pointerEventData) { if (currentPointerEventData == null) { Debug.LogError("currentPointerEventData == null"); return; } Vector3 raycastPosition = pointerEventData.pointerCurrentRaycast.worldPosition; Vector3 pointerLocalPosition = transform.InverseTransformPoint(raycastPosition); List <int> effectIndices = SafetyAreaVertexHelper.CaculateEffectVerticeIndices(pointerLocalPosition); for (int i = 0; i < effectIndices.Count; i++) { int index = effectIndices[i]; colors[index] = Color.red; lastPaintIndex = index; } mesh.colors = colors; }
void Start() { if (stationaryAreaStep == null) { stationaryAreaStep = SafetyAreaManager.Instance.GetStep <StationaryAreaStep>(SafetyAreaStepEnum.StationaryArea); } if (groundHeightStep == null) { groundHeightStep = SafetyAreaManager.Instance.GetStep <GroundHeightStep>(SafetyAreaStepEnum.GroundHeight); } if (headTransform == null) { headTransform = SvrManager.Instance.head; } float groundHeight = groundHeightStep.GetPlaneHeight(); MeshFilter meshFilter = this.gameObject.AddComponent <MeshFilter>(); meshRenderer = this.gameObject.AddComponent <MeshRenderer>(); meshRenderer.material = Resources.Load <Material>("Material/SafetyEdgeMat"); meshFilter.mesh = SafetyAreaVertexHelper.GenerateCylinderMesh(new Vector3(0, groundHeight, 0), groundHeight + 5, groundHeight); }