public override void OnInspectorGUI() { VoxelSurface voxelSurface = (VoxelSurface)target; voxelSurface.size = EditorGUILayout.IntField("Size", voxelSurface.size); voxelSurface.drawGizmos = EditorGUILayout.Toggle("Draw Gizmos", voxelSurface.drawGizmos); if (voxelSurface.entityField != null) { EditorGUILayout.IntField("Number of Entities", voxelSurface.entityField.entities.Count); } if (voxelSurface.navMesh != null) { EditorGUILayout.IntField("NavMesh positions Count", voxelSurface.navMesh.positions.Count); EditorGUILayout.IntField("NavMesh connections Count", voxelSurface.navMesh.connections.Count); } else { EditorGUILayout.LabelField("No nav mesh"); } if (GUILayout.Button("Initialize")) { voxelSurface.Initialize(); } if (GUILayout.Button("Create Own Mesh")) { voxelSurface.CreateOwnMesh(); } }
public void UpdateDirty() { if (!dirty) { return; } dirty = false; ((HermiteDataGrid)grid).Save(TWDir.Test.CreateSubdirectory("DualContouring").CreateFile("InteractiveGrid.txt")); lastSurfaceExtractionTime = PerformanceHelper.Measure(() => { surfaceMesh = dcMeshBuilder.buildRawMesh(grid); }); if (meshElement != null) { meshElement.Delete(); } meshElement = surfaceRenderer.CreateSurface(grid, Matrix.Identity); meshElement.WorldMatrix = Matrix.Scaling(new Vector3(CellSize)); this.lines.ClearAllLines(); addHermiteVertices(grid, CellSize, this.lines); addQEFPoints(surfaceMesh, CellSize, this.lines); addHermiteNormals(grid, CellSize, this.lines); lines.AddBox(new BoundingBox(new Vector3(), grid.Dimensions.ToVector3() * cellSize), Color.Black); }
public void UpdateSurface(VoxelCustomRenderer customRenderer) { if (surface != null) { surface.Delete(); } surface = customRenderer.CreateSurface(Grid, Matrix.Scaling(new Vector3(BuilderConfiguration.VoxelSize)) * Matrix.Translation(ChunkCoord.ToVector3() * BuilderConfiguration.VoxelSize * BuilderConfiguration.ChunkNumVoxels)); SurfaceDirty = false; }
void OnSceneGUI() { VoxelSurface voxelSurface = target as VoxelSurface; FUtils.Elvis(voxelSurface.GetComponentInParent <GridArray>(), gridArray => { gridArray.Update(); if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (gridArray != null) { gridArray.Hit(hit.point); } } } }); }