Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when selecting individual voxels then trying to recombine, no alpha model. #12

Open
Discipol opened this issue Oct 4, 2017 · 11 comments

Comments

@Discipol
Copy link

Discipol commented Oct 4, 2017

Steps to reproduce:
Get latest unity build.
Install this repo.
Load the knight model, without alpha model.
Select the individual voxel option, reimport.
Select the voxels that form the axe, or another voxel set. Try to merge them.
An error pops up here: alphaMax.voxels is null and you try to access it:

int alpha = alphaMask == null ? (byte)0 : alphaMask.voxels[ x, y, z ];

Fixing it like this:

int alpha = alphaMask == null || alphaMask.voxels == null ? (byte)0 : alphaMask.voxels[ x, y, z ];

Creates this error :S help

NullReferenceException: Object reference not set to an instance of an object
(wrapper managed-to-managed) object:ElementAddr_3_1 (object,int,int,int)
MVImporter.GenerateFaces (.MVVoxelChunk voxelChunk, .MVVoxelChunk alphaMask) (at Assets/MagicaVoxel/Scripts/MVImporter.cs:420)
MVVoxModelVoxelInspector.CombineVoxels (.MVVoxModelVoxel[] voxels) (at Assets/MagicaVoxel/Scripts/Editor/MVVoxModelVoxelInspector.cs:43)
MVVoxModelVoxelInspector.OnInspectorGUI () (at Assets/MagicaVoxel/Scripts/Editor/MVVoxModelVoxelInspector.cs:20)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1240)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

@barraudf
Copy link
Contributor

barraudf commented Oct 4, 2017

Did you pull #11 ? I think I got this error fixed. Let me know if you still have it!

@Discipol
Copy link
Author

Discipol commented Oct 4, 2017

@barraudf I downloaded the repo. There's only the master. I assumed I got up to including the last commit :S

@barraudf
Copy link
Contributor

barraudf commented Oct 4, 2017 via email

@Discipol
Copy link
Author

Discipol commented Oct 4, 2017

@barraudf I didn't push it, only tried to fix it locally, but then other things started throwing errors :S I don't want to mess things up as I JUST found this repo, just shared how far I got.

@barraudf
Copy link
Contributor

barraudf commented Oct 4, 2017 via email

@Discipol
Copy link
Author

Discipol commented Oct 4, 2017

@barraudf MVImporter.cs > 457 > int alpha = alphaMask == null ? (byte)0 : alphaMask.voxels[ x, y, z ];

Yeah I don't see the point of that either :D There are also some problems with the shaders / meshes. Some of the faces are reversed, so I can see through some cube faces :S

@barraudf
Copy link
Contributor

barraudf commented Oct 5, 2017

This is not what the file actually looks like : https://github.com/darkfall/MagicaVoxelUnity/blob/master/Assets/MagicaVoxel/Scripts/MVImporter.cs

It was updated 10 days ago, and no longer contains any "(byte)0". My guess is your working copy is outdated. You should try to revert and pull.

@Discipol
Copy link
Author

Discipol commented Oct 5, 2017

@barraudf Downloading it gives me that old version, I am git-ing now and its the latest one.
Also, error:

if(alphaMask == null && alphaMask.voxels != null)

Should be alphaMask != null :D

@Discipol
Copy link
Author

Discipol commented Oct 5, 2017

@barraudf The unitypackage and the source files are different, that's why I was getting outdated stuff, I was using the package :S what's happening here?

@barraudf
Copy link
Contributor

barraudf commented Oct 5, 2017

This repository is not much active anymore, I guess the unitypackage is not updated after each Pull Request, you'd better stick with git source code.

What I did back in time was to make my own magicka voxel importer in the end. MVImporter.cs contains all the code to read a vox file (the vox file format has been updated recently and now include a MATT chunk with all the Material data, which MagicaVoxelUnity doesn't handle) and how to build a model from the voxel data.

Good catch on alphaMask != null, I'll change it (or you can if you wish, that's what open source is about :))

@Discipol
Copy link
Author

Discipol commented Oct 5, 2017

@barraudf I want to mate but deadlines tell me I can't. At least, not at the moment. I will need some of this code to transform VOX into a format I will need, so I will say my warmest thanks to you and other contributors 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants