AntonioND / nitro-engine

3D engine for the Nintendo DS
150 stars 10 forks source link

Md2 to nea animation issues #9

Closed summerscorcher closed 1 year ago

summerscorcher commented 2 years ago

Hi, I'm having an issue with (What I presume to be) the md2_to_nea exporter.

I've got a rigged 3D model created in Maya and exported to .md2 using MilkShape 3D. Inside both Ms3d and it's accompanying md2 model viewer I can see it exported perfectly fine, animated, etc. But when I convert it into a nea bin and load it into the game, there seems to be a couple of things that can happen; 1) All frames are working perfectly 2) A portion of the animation is working perfectly, then it distorts/scales down to 0 instantly at around halfway 3) Only the first frame is visible, though clearly distorted, and all other frames are blank.

The examples I've encountered have all occurred by scrapping and starting my animation from scratch in MilkShape, a different result being achieved each time. I've tried modifying the nea exporter to print values such as frame->scale and frame->translate, and in my findings, on the broken model scale/translate was set to 0.000 at some point through the animation, where on the working model they were all unique values. I'm not sure if this is relevant to the problem, but figured I'd mention it anyway.

Do you have a specific workflow/programs to use to ensure compatibility with the exporter, or is there other special care that needs to be taken with it?

AntonioND commented 2 years ago

Thanks for the bug report!

If you could provide a test model I could take a look at the problem, this will be hard to debug otherwise.

I remember I used blender and a MD2 exporter back when I used NE, if that helps.

summerscorcher commented 2 years ago

Thank you for being willing to take a look! ^^ I've attached three models.

Both Wave.md2 files are completely broken for me when I convert it to nea, but the MilkShape version has one frame visible (Maya export is completely invisible when rendered in the engine). I should note the Wave model lacks normals on some sides, so you might have to render it without backface culling. The Boat.md2 should be fully functional.

Models.zip

(Also, woops, accidentally closed/reopened the issue hahah)

AntonioND commented 2 years ago

Thanks for the models. I won't be able to take a look at them for a few days, I'll try to check them on Monday!

AntonioND commented 2 years ago

@summerscorcher I can't reproduce your problem, the conversion happens correctly for me.

I've uploaded my test project. It's a modified version of the animated mode example. You can switch between models by pressing L or R. I don't have the textures, so I've done what I can.

test.zip

I think this may be an issue related to the converter. Can you tell me the characteristics of your development machine? OS? Compiler you are using md2_to_nea? CPU architecture (are you using an M1)?

I've even included my build of md2_to_nea in case you're on Linux.

summerscorcher commented 2 years ago

Hi, thanks for having a look! Yeah, the animations look exactly as expected in your provided test project.

My machine runs Windows 10, using mingw-w64-x86_64-toolchain (cc). CPU is Intel 64-bit architecture. I'm also running the make through MSYS2.

AntonioND commented 2 years ago

I think I know what the cause may be. Can you try with a 32-bit compiler? I suspect that I may have to refactor the converters because they are hitting undefined behaviour, or some compiler-defined behaviour.

summerscorcher commented 2 years ago

So I've installed mingw-i686 and tried to compile the converter using the x86 version of MSYS2, but sadly the results are the same as before when I try to convert an .md2 file with it.

AntonioND commented 2 years ago

I've pushed a few commits to the repository. The biggest change is that now I explicitly use stdint.h instead of hoping that the compiler uses the ones I expect. Can you build md2_to_nea now and try again?

summerscorcher commented 2 years ago

Same results once more unfortunately. I've built it with both the 32 and 64-bit versions of the compiler to be sure, but yeah :S. Is there anything else I can do on my side to help debug it?

AntonioND commented 2 years ago

Can you send me your broken models? The files after the conversion. I'd like to compare them to mine.

summerscorcher commented 2 years ago

Sorry about the delay, here's the two wave models converted to nea; Models_bin.zip

AntonioND commented 2 years ago

The differences are pretty significant, I was hoping to see a small diff. :( Can you tell me the exact commands you used to convert your models?

summerscorcher commented 2 years ago

Hmm, what a strange issue :S Of course, here's the command I usually use;

.\md2_to_nea.exe Wave.md2 wave_nea.bin

Here's also the log that comes with it, if it's of any help;

PS C:\devkitPro\nitro-engine\tools\md2_to_nea> .\md2_to_nea.exe Wave.md2 wave_nea.bin
md2_to_nea v2.1

Copyright (c) 2008-2011, 2019 Antonio Nino Diaz

Scale:     1.000000
Translate: 0.000000, 0.000000, 0.000000

Loading MD2 model...

MD2 Information:

  Number of frames: 30
  Texture size: 256x256
Creating lists of commands...

Creating NEA file...

Number of vertices: 8 - Each frame: 30
Number of normals: 7
Number of texture coordinates: 13
Number of frames: 30

Size of a frame: 180

NEA file size: 5574 bytes

Ready!
AntonioND commented 2 years ago

I'm really confused, to be honest. Can you send me the compiled converter you've used? md2_to_nea.exe? Basically, send me a test project. Something with a sample model that is broken, your converter, and a prebuilt model. You can use the sample one I sent a few messages ago as base.

summerscorcher commented 2 years ago

No problem, here's the small test project based off the one you posted before, featuring the "broken" md2, the exe converter, and the broken model compiled into a bin. (Same controls as your test project, just with only the bird and then the broken model). If I missed something let me know and I'll send it.

test.zip

AntonioND commented 2 years ago

Hi! Sorry for the silence of the last few days. I gave up with the bug. Yesterday I decided to rewrite the converters, and hopefully they will become more reliable that way. I've started with the one for static models (now I expect users to use OBJ models, not MD2): https://github.com/AntonioND/nitro-engine/commit/3114d3b204b972ccddf8f996d9447746b01d698c

I'll get started with the animated model conversion tomorrow, but that will take a longer time to implement.

summerscorcher commented 2 years ago

Hey again, no worries about that! We all have our lives going on in the background of course ^^. But that's wonderful, being able to use OBJ for static models would be amazing. Hopefully the animated converter would be able to use a more modern format as well. Regardless, thank you for all your work on this so far!

AntonioND commented 1 year ago

NEA support has just been removed in https://github.com/AntonioND/nitro-engine/commit/937c1ed1cf49717a3be047f928477cf104211196. I've replaced it by my new and shiny DSMA library: https://github.com/AntonioND/dsma-library This means MD2 models are no longer supported, only MD5 and OBJ models are supported officially.

I've had to modify a few functions related to animation, but everything else should be the same. Check this example to see how to use the new system: https://github.com/AntonioND/nitro-engine/tree/aa022b2a28e6017a9865917e01fc1d458908cf09/examples/loading/filesystem_animated_model_bmp

So I'm closing this issue once and for all. 😃

I will release a new version of Nitro Engine later today, but I intend to do a huge cleanup afterwards, and there will probably be a few small breaks (it will mostly be related to how the library handles things internally).

AntonioND commented 1 year ago

Okay, it has taken a week more than I expected, but version 0.8.0, that I've just released, has all the new changes, along many usability improvements. Feel free to give feedback!

summerscorcher commented 1 year ago

That's awesome, glad to see the new version! Unfortunately I've been wrapped up in other projects as of late, so I haven't been able to do NDS development. Also still looking for working plugins for Maya to export to .md5 with no luck so far, so I'm still on the lookout there. Regardless, I'll be sure to get back to you when I use it in the future!