Coder Social home page Coder Social logo

unity-job-system-voxelizer's People

Contributors

thecyberbrick avatar

Stargazers

 avatar

Watchers

 avatar  avatar

unity-job-system-voxelizer's Issues

Grid contains filled parallelepiped instead of actual model shape

Hello!
I'm trying to voxelize a human tooth model with the next code and getting confusing result:

// mesh - mesh of my blender model, ~3000 vertices
// resolution - int3(59, 129, 50)
var vertices = new NativeArray<float3>(mesh.vertices.Select(v3 => new float3(v3.x, v3.y, v3.z)).ToArray(), Allocator.Persistent);
var normals = new NativeArray<float3>(mesh.normals.Select(v3 => new float3(v3.x, v3.y, v3.z)).ToArray(), Allocator.Persistent);
var grid = new NativeArray3D<Voxel.Voxel, LinearIndexer>(new LinearIndexer(), resolution.x + 1, resolution.y + 1, resolution.z + 1, Allocator.Persistent);
var properties = Voxel.Voxelizer.Voxelizer.VoxelizationProperties.SMOOTH;
var job = Voxel.Voxelizer.Voxelizer.Voxelize(vertices, normals, grid, 1, properties);
job.Handle.Complete();
vertices.Dispose();
normals.Dispose();

for (int x = 0; x < grid.Length(0); x++) {
  for (int y = 0; y < grid.Length(1); y++) {
    for (int z = 0; z < grid.Length(2); z++) {
      var voxel = grid[x, y, z];
      if (voxel.Data.IsVoxelSet) {
        var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
	cube.transform.position = new Vector3(x, y, z);
      }
    }
  }
}

grid.Dispose();
job.Dispose();

Result is a filled parallelepiped.
I tried both SMOOTH and FLAT configurations -- absolutely no difference.

Could you please provide readme with usage examples?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.