public void Set(NPVoxMeshOutput _meshOutput, NPVoxNormalProcessor _processor) { MeshOutput = _meshOutput; ViewedProcessor = _processor; PreviewObject = MeshOutput.Instatiate(); VoxToUnity = new NPVoxToUnity(MeshOutput.GetVoxModel(), MeshOutput.VoxelSize); MeshFilter mf = PreviewObject.GetComponent <MeshFilter>(); PreviewMesh = Mesh.Instantiate <Mesh>(mf.sharedMesh); mf.sharedMesh = PreviewMesh; PreviewObject.hideFlags = HideFlags.HideAndDontSave; PreviewObject.SetActive(false); IsValid = true; }
void OnDrawGizmos() { // if (Selection.activeGameObject != this.gameObject) // { // return; // } NPVoxMeshOutput MeshOutput = MeshFactory as NPVoxMeshOutput; if (MeshOutput) { NPVoxToUnity npVoxToUnity = MeshOutput.GetNPVoxToUnity(); NPVoxModel model = MeshOutput.GetVoxModel(); if (model) { foreach (NPVoxSocket socket in model.Sockets) { Vector3 anchorPos = npVoxToUnity.ToUnityPosition(socket.Anchor); Quaternion rotation = Quaternion.Euler(socket.EulerAngles); Vector3 anchorRight = npVoxToUnity.ToUnityDirection(rotation * Vector3.right); Vector3 anchorUp = npVoxToUnity.ToUnityDirection(rotation * Vector3.up); Vector3 anchorForward = npVoxToUnity.ToUnityDirection(rotation * Vector3.forward); Gizmos.color = new Color(0.5f, 1.0f, 0.1f, 0.75f); Gizmos.DrawCube(transform.position + anchorPos, Vector3.one * 0.4f); Gizmos.color = Color.red; Gizmos.DrawLine(transform.position + anchorPos, transform.position + anchorPos + anchorRight * 10.0f); Gizmos.color = Color.green; Gizmos.DrawLine(transform.position + anchorPos, transform.position + anchorPos + anchorUp * 10.0f); Gizmos.color = Color.blue; Gizmos.DrawLine(transform.position + anchorPos, transform.position + anchorPos + anchorForward * 10.0f); } } } }