/// <summary> /// Draws the current VoxelGrid state with mesh voxels /// </summary> void DrawState() { for (int x = 0; x < _gridSize.x; x++) { for (int y = 0; y < _gridSize.y; y++) { for (int z = 0; z < _gridSize.z; z++) { if (_grid.Voxels[x, y, z].IsOccupied) { for (int i = 0; i < 6; i++) { var voxel = _grid.Voxels[x, y, z]; if (voxel.Part.Type == PartType.Configurable) { PP_Drawing.DrawConfigurable(_grid.Voxels[x, y, z].Center + new Vector3(0, (i + 1) * _voxelSize, 0), _grid.VoxelSize, Color.black); } else { PP_Drawing.DrawCube(_grid.Voxels[x, y, z].Center + new Vector3(0, (i + 1) * _voxelSize, 0), _grid.VoxelSize, 1); } } } if (_grid.Voxels[x, y, z].IsActive) { PP_Drawing.DrawCube(_grid.Voxels[x, y, z].Center, _grid.VoxelSize, 0); } } } } }
void DrawVoxelList(List <Voxel> input) { foreach (var voxel in input) { PP_Drawing.DrawCube(voxel.Center + new Vector3(0, 0.5f, 0), _grid.VoxelSize, 0.25f); } }
/// <summary> /// Draws the current VoxelGrid state with mesh voxels /// </summary> protected override void DrawState() { for (int x = 0; x < _gridSize.x; x++) { for (int y = 0; y < _gridSize.y; y++) { for (int z = 0; z < _gridSize.z; z++) { Vector3 index = new Vector3(x + 0.5f, y + 0.5f, z + 0.5f) * _voxelSize; //Vector3 index = new Vector3(x , y , z) * _voxelSize; if (MainGrid.Voxels[x, y, z].IsOccupied) { for (int i = 0; i < 8; i++) { var voxel = MainGrid.Voxels[x, y, z]; if (voxel.Part.Type == PartType.Configurable) { //PP_Drawing.DrawConfigurable(transform.position + _grid.Voxels[x, y, z].Center + new Vector3(0, (i + 1) * _voxelSize, 0), _grid.VoxelSize, 1); PP_Drawing.DrawConfigurable(transform.position + index + new Vector3(0, (i + 1) * _voxelSize, 0), MainGrid.VoxelSize, Color.black); } else { //PP_Drawing.DrawCube(transform.position + _grid.Voxels[x, y, z].Center + new Vector3(0, (i + 1) * _voxelSize, 0), _grid.VoxelSize, 1); PP_Drawing.DrawCube(transform.position + index + new Vector3(0, (i + 1) * _voxelSize, 0), MainGrid.VoxelSize, 1); } } } } } } }
void DrawWalkable() { foreach (var voxel in _usedWalkables) { PP_Drawing.DrawCube(voxel.Center, _grid.VoxelSize, 0.25f); } }
protected virtual void DrawCompletedSpace() { foreach (var index in _completedIndices) { Vector3 realIndex = new Vector3(index.x + 0.5f, index.y + 1.5f, index.z + 0.5f) * _voxelSize; PP_Drawing.DrawCube(transform.position + realIndex, MainGrid.VoxelSize, _completedColor); } _showCompleted = false; _completedIndices = null; }
/// <summary> /// Visual aid to show which ConfigurablePart is being controlled now /// </summary> protected virtual void DrawActiveComponent() { var unfrozenParts = _existingParts.OfType <ConfigurablePart>().Where(p => p.CPAgent.Frozen == false); foreach (var up in unfrozenParts) { var pos = transform.position + (new Vector3(up.Center.x + 0.5f, up.Center.y + 0.5f, up.Center.z + 0.5f) * _voxelSize); PP_Drawing.DrawCube(pos + new Vector3(0, 4f, 0), 0.25f, 0f); } }
void DrawOrigins() { foreach (var origins in _origins) { foreach (var voxel in origins) { PP_Drawing.DrawCube(voxel.Center + new Vector3(0, 7 * _voxelSize, 0), _grid.VoxelSize, 1); } } }
/// <summary> /// Draws a box in the pivot point of the voxel configurable part /// </summary> protected virtual void DrawPartPivot() { foreach (var part in _existingParts) { float x = part.ReferenceIndex.x * _voxelSize; float y = part.ReferenceIndex.y * _voxelSize; float z = part.ReferenceIndex.z * _voxelSize; Vector3 origin = new Vector3(x, y + 7 * _voxelSize, z); PP_Drawing.DrawCube(origin, _voxelSize * 1.1f, 0.2f); } }