duanxianpi / QtLive2d

Qt-based Live2d widget
MIT License
20 stars 7 forks source link

Some model. cannot be opened. #3

Closed sucv closed 1 year ago

sucv commented 1 year ago

Several models from the official collections (https://www.live2d.com/en/download/sample-data/) cannot be opened. Such as Niziiro Mao, and Haru (not the receptionist version, the normal one down there).

I always received such kinds of errors.

00:07:03: Starting /media/sf_VB_shared/build-QtLive2d-Desktop_Qt_6_4_2_GCC_64bit-Debug/src/Sample/Sample...
START
[CSM][I]Live2D Cubism Core version: 04.02.0003 (67239939)

[CSM][I]CubismFramework::StartUp() is complete.

[CSM][I]CubismFramework::Initialize() is complete.

[APP]model index: 0
[APP]load model setting: Haru2.model3.json
[APP]create buffer: Resources/Haru2/Haru2.model3.json 
file open error
00:07:04: /media/sf_VB_shared/build-QtLive2d-Desktop_Qt_6_4_2_GCC_64bit-Debug/src/Sample/Sample crashed.

And when I run the code using debug, in CubismJson.cpp, the line 107 _root = ParseValue(reinterpret_cast<const csmChar*>(buffer), size, 0, &endPos); , which called the line 369 csmChar c = static_cast<csmChar>(buffer[i] & 0xFF); caused this.

I validated all the JSON files in those model folders, they are all valid. It would be greatly appreciated if you could find the reason. Thanks.

duanxianpi commented 1 year ago

Could you double check the location of the new models? When you are adding new model, please make sure the models are in the build directory build-QtLive2d-Desktop_Qt_6_4_2_GCC_64bit-Debug/src/Sample/Resources as well. When Qt Creator build the project, it will copy Resources folder from src to the build directory. But if you don't rebuild it, it won't help you copy.

Please let me know if that works.

sucv commented 1 year ago

Thanks for your prompt response!

Confirmed. I always use clean before building. Now I also tried manually deleting the entire built folder.

I added haru2 in LAppDefine.cpp. This haru is the normal one in the official collections. After the building, I can see the model in both the F:\VB_shared\build-QtLive2d-Desktop_Qt_6_4_2_GCC_64bit-Debug\src\Sample\Resources\haru2 and F:\VB_shared\QtLive2d_new\src\Sample\Resources\haru2. But it crashed without opening the window.

duanxianpi commented 1 year ago

Hi sucv, just tried on my own to add a haru to the application. Everything is fine. Here is a document for adding the model to Sample. Step 1: Add the model to Resources folder, make sure the model folder has following structure.

└───Haru2
    │   ...
    │   Haru2.model3.json
    │   ...
    ├───expressions
    │
    ├───Haru.2048
    │
    ├───motions
    │
    └───sounds

We use haru2 as example, since we already have a model called haru, the new model will called haru2.

Step 2: Modify LAppDefine.cpp, add addition line called haru2 in the ModelDir variable.

    const csmChar* ModelDir[] = {
        "miku_sample_t04",
        "Haru",
        "Hiyori",
        "Mark",
        "Natori",
        "Rice",
        "Haru2"
    };

When we try to load model Haru2, firstly, LAppDefine.cpp will try to find a folder called Haru2 under the Resources folder. Then it will try to find a Haru2.model3.json file where store all information about a Live2d model under Haru2 folder. So, the most important thing will be make sure LAppDefine.cpp can find the *.model3.json.

From the log u provide to me, I think there is 2 possibility,

  1. The model3.json file is not directly under model folder
  2. There folder and model is named Haru2 but there isn't exist a Haru2.model3.json.

Please let me know if the above information is helpful for you. And feel free to ask me if u have any other questions.

image

sucv commented 1 year ago

Oh my, I named the model folder haru2, but I didn't also change the json name to haru2.model3.json.

Thanks again for your help!

duanxianpi commented 1 year ago

no worries.