Giter VIP home page Giter VIP logo

filetovoxcore's Introduction

FileToVoxCore

FileToVoxCore is a library that allows you to read and write MagicaVoxel (.vox) file easily

Nuget

filetovoxcore's People

Contributors

benmclean avatar zarbuz avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

filetovoxcore's Issues

Iterate through filled voxels only?

Currently, I have my app using FileToVoxCore inside a constructor like this:

public VoxFileModel(FileToVoxCore.Vox.VoxModel model, int frame = 0)
{
	Palette = new uint[256];
	uint[] palette = model.Palette.Take(Palette.Length).Select(Color).ToArray();
	System.Array.Copy(
		sourceArray: palette,
		sourceIndex: 0,
		destinationArray: Palette,
		destinationIndex: 1,
		length: Math.Min(palette.Length, Palette.Length) - 1);
	FileToVoxCore.Vox.VoxelData voxelData = model.VoxelFrames[frame];
	SizeX = (ushort)(voxelData.VoxelsWide - 1);
	SizeY = (ushort)(voxelData.VoxelsTall - 1);
	SizeZ = (ushort)(voxelData.VoxelsDeep - 1);
	for (ushort x = 0; x < SizeX; x++)
		for (ushort y = 0; y < SizeY; y++)
			for (ushort z = 0; z < SizeZ; z++)
				if (voxelData.GetSafe(x, y, z) is byte voxel && voxel != 0)
					this[x, y, z] = voxel;
}

But those nested for loops at the end are very inefficient. It is doing an exhaustive search of the 3D space, which wastes CPU on models that are mostly empty space.

It would be better to expose an iterator which returns all the filled voxels without having to check all the empty ones. And I mean in a way that increases efficiency, not just an iterator that checks all the empty spaces behind the scenes.

Rotation bug on .vox write

FileToVoxCore seems to rotate models unexpectedly when writing.

I first mentioned this to Zarbuz on the MagicaVoxel Discord on 2023-10-15 and he asked me to make a reproduction of the bug.

I have created a unit test that minimally reproduces the issue here: https://github.com/BenMcLean/FileToVoxCore/blob/062939c5876cef1e9285713ee8829974720d00c2/FileToVoxCoreTest/UnitTest1.cs

Take any asymmetrical model (so you can see which way it is facing) as your Input.vox and run the unit test. Your Output.vox will be rotated.

Seems .ply to .vox are not fully supported

Hello,

I have this .ply file that I use for my study project. I lost its original file but I found your tool, hoping to solve my problem.
When I've open the generated file I didn't saw any voxels. So I tried to investigate and I found the line that cause this issue :
https://github.com/Zarbuz/FileToVoxCore/blob/735133e150d36052a758fdc92ab2374b7940a9c6/Schematics/Schematic.cs#LL333

The cast to ushort when x, y, or z are negative numbers, falsify everything.

Here is the file that cause the problem. I've just change the extension to .txt to be able to upload it, but it's a .ply file originaly.
bomb.txt

I don't have currently more time to fix it, but I just wanted to let you know what I've found,

License?

Could you please specify the license for this?

I would suggest MIT like the other dependencies in my project use.

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.