tommyettinger / spotvox

Renders MagicaVoxel .vox files to pixel art. Successor to IsoVoxel.
Apache License 2.0
39 stars 0 forks source link

java.lang.ArrayIndexOutOfBoundsException for vox file made up of multiple models #1

Closed JelleBouma closed 2 years ago

JelleBouma commented 2 years ago

error.zip

Exception in thread "HeadlessApplication" java.lang.ArrayIndexOutOfBoundsException: Index 228 out of bounds for length 228
        at com.github.tommyettinger.Renderer.drawSplats(Renderer.java:428)
        at com.github.tommyettinger.SpotVox.create(SpotVox.java:59)
        at com.badlogic.gdx.backends.headless.HeadlessApplication.mainLoop(HeadlessApplication.java:108)
        at com.badlogic.gdx.backends.headless.HeadlessApplication$1.run(HeadlessApplication.java:93)
        at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:704)
        at com.oracle.svm.core.windows.WindowsPlatformThreads.osThreadStartRoutine(WindowsPlatformThreads.java:143)

It seems to run into an error because it will try to get voxels beyond the height of the model, error does not appear when I delete all models except one in the file. I included my vox file where I run into the error. I didnt use any optional run parameters.

tommyettinger commented 2 years ago

Taking a look now.

tommyettinger commented 2 years ago

There is/was definitely a bug; even simple multi-part models weren't parsed correctly. I probably confused one of my newer repos, like Isonomicon, with SpotVox. Today I copied in and adapted the relevant code from Isonomicon to parse multi-part models; this seems to mostly work, but I'm not sure the positions are correct:

error_angle2

error_angle4

It also runs out of memory if it tries to render the large model at 4x scale, which I can't do much about.

JelleBouma commented 2 years ago

Oh you made 3 of these programs? lol Yeah those positions are off, if you open it in magicavoxel you can see what it should look like. Do you recommend I try Isonomicon instead?

tommyettinger commented 2 years ago

No, Isonomicon is also partly broken for renders this large, but I only just now got this fixed in SpotVox. I'll push a release in a bit.

error_angle2

Lighting works, positions are correct as far as I can tell, rotation works. There aren't any materials here, which I was surprised to find would crash Isonomicon but not SpotVox, and has since been fixed in Isonomicon. Materials could be used, though, if you wanted to make the metal reflective in places. You might want to try setting the x and y offsets for the whole model to 0 (select all sub-models, position, x=0, y=0), since that would center the rotation a little better; it is currently rotating around some other point, and the size of the blank space is much larger, because the model effectively starts at a position greater than 100 on x and y.

tommyettinger commented 2 years ago

0.0.3 is released! Please let me know if it works for you as well.

JelleBouma commented 2 years ago

Hi it works, thanks a lot! I got excited when you said material support but it doesn't support transparency ("glass material" in Magicavoxel) does it? I am melting its face so blood with transparency would be perfect. Anyways I am really glad to at least have a way to render voxel files automatically as opposed to having to render all my frames manually with Magicavoxel.

tommyettinger commented 2 years ago

Glad to hear it works!

SpotVox does not currently support transparency; it would be really tricky to get it working with the way this works... I'm about to release 0.0.4, which fixes an issue when multi-part models have negative x or y positions (and reduces how much wasted whitespace there is at the edges of the render).

Because this works now, I will close the issue. If there are similar problems and this issue isn't fully finished, please comment and I can reopen, or if there is a different type of issue/request you can open a new issue.

andreaszdw commented 1 year ago

Hello,

I got this error:

C:\Users\agraetz\AppData\Documents\Downloads\spotvox-windows-x64-0-0-6>spotvox -r=32 heavyTank1.vox
Exception in thread "main" java.lang.NoClassDefFoundError: Ljava/lang/IndexOutOfBoundsException;
        at com.oracle.svm.jni.functions.JNIFunctions.FindClass(JNIFunctions.java:348)
        at java.io.FileInputStream.readBytes(FileInputStream.java)
        at java.io.FileInputStream.read(FileInputStream.java:276)
        at com.github.tommyettinger.LittleEndianDataInputStream.read(LittleEndianDataInputStream.java:89)
        at com.github.tommyettinger.io.VoxIOExtended.readVox(VoxIOExtended.java:230)
        at com.github.tommyettinger.headless.HeadlessLauncher.call(HeadlessLauncher.java:58)
        at com.github.tommyettinger.headless.HeadlessLauncher.call(HeadlessLauncher.java:19)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at com.github.tommyettinger.headless.HeadlessLauncher.main(HeadlessLauncher.java:46)

C:\Users\agraetz\AppData\Documents\Downloads\spotvox-windows-x64-0-0-6>

If I use the copter.vox which is delieverd with the executable it works, but if I load copter.vox in magicavoxel and save it again, it doesn't work. Do you have a hint for me?

Best regards

Andreas