Skip to content

Instantly share code, notes, and snippets.

{
"id": "1592929254567-0",
"indexed_at_ms": 1592929254567,
"event": {
"method": "POST",
"path": "/",
"query": {},
"headers": {
"x-forwarded-for": "216.41.237.104",
"x-forwarded-proto": "https",
@TheFizz
TheFizz / UnityMagicaVoxelize.cs
Created June 4, 2020 02:57
This script will "voxelize" the existing MagicaVoxel model in Unity3D so you can "shatter" it in voxel cubes.
using System;
using System.Collections.Generic;
using UnityEngine;
public class Voxelizer : MonoBehaviour
{
public GameObject parent;
public GameObject voxel;
private float height, width;
1456974563
float segmentAngle;
segmentAngle = 360f / segments;
float partialSegmentAngle = segmentAngle / angleFraction;
float currentRotation = segmentAngle;
for (int i = 0; i < segments; i++)
{
Mesh mesh = new Mesh();
Vector3[] vertices = new Vector3[angleFraction + 2];