Commit 8d45f017 authored by Moritz's avatar Moritz

added classes to visualize vector data of point clouds and grids with gizmos

parent 8379ec59
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Testing {
public class Array3DVisualizer : MonoBehaviour {
public float GridSpacing = 1f;
public float DirectionScaleFactor = 1f;
private Vector3[,,] _grid = default;
private Vector3 _gridsize = default;
public void Visualize(Vector3[,,] grid) {
_grid = grid;
int x, y, z;
x = _grid.GetLength(0);
y = _grid.GetLength(1);
z = _grid.GetLength(2);
_gridsize = new Vector3(x, y, z);
}
private void OnDrawGizmos() {
if (_grid == default)
return;
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[x, y, z] == null) {
Debug.Log("What what?"); //should at least be zero vector
continue;
}
if (_grid[x, y, z] != Vector3.zero) {
Vector3 coordinates = new Vector3(x, y, z);
Gizmos.DrawLine(coordinates * GridSpacing, coordinates * GridSpacing + _grid[x, y, z] * DirectionScaleFactor);
}
}
}
}
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: e70d6477a6c8bd34a97d713eead5ee4a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Testing {
public class PointCloudVisualizer : MonoBehaviour {
public float spacingFactor = 100;
List<Teamproject.PCachePoint> _points = default;
public void Visualize(List<Teamproject.PCachePoint> points) {
_points = points;
Debug.Log("<color=red> PointCloudVisualizer: " + _points.Count + " points to visualize </color>");
}
private void OnDrawGizmos() {
if (_points != default)
foreach (Teamproject.PCachePoint p in _points) {
Gizmos.DrawLine(p.Position * spacingFactor, p.Position * spacingFactor + p.Direction);
}
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 93253b0e5016af54d9a4ff911b7df713
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment