Nor-s / Anim

3D animation editor (with ai mocap, mixamorig)
Other
188 stars 12 forks source link

animation was not fully correct #5

Closed lucasjinreal closed 2 years ago

lucasjinreal commented 2 years ago
image image

the bones seems opposite, all fbx are same behavior.

and this was:

image

default zombies also seems oppsited:

image
lucasjinreal commented 2 years ago
image
Nor-s commented 2 years ago

Wow...it's really hard to deal with model files.

If you built it yourself

What compiler did you use?

And I forgot to update the README.md. Did you ever use --recursive when cloning?

Here's what I just built from the main branch.... with gcc10.3.0 x86_64-w64-mingw32 (windows11)

image

I will build and test it in various environments. Thanks for the issue!

lucasjinreal commented 2 years ago

@Nor-s I am on macOS with clang 11.3.

which assimp version did u using? I using assimp updated to this commit: abfb26ab6f2b350d604ad1e653250c998579c41f

the only differences between you and me should be assimp, since I am not using your submodule commit id, I can not pull it due to poor network speed in China behind GFW, so I just cloned it with master branch.

Can u try update to master assimp master branch? it should have some bias between our two sides.

Nor-s commented 2 years ago

This also seems to be a flag issue!

I tested it with the assimp (abfb26ab6f2b350d604ad1e653250c998579c41f) on Mac OS with clang12 and it was normal.

However

I was able to reproduce the error by setting the assimp's flags as follows:

        AssimpAnimation(const char *animation_path)
        {
            type = AnimationType::Assimp;
            Assimp::Importer importer;
            unsigned int assimp_read_flag =
                aiProcess_SortByPType |
                aiProcess_ConvertToLeftHanded |
                aiProcess_ValidateDataStructure |
                aiProcess_LimitBoneWeights;
스크린샷 2022-06-06 오전 12 04 23 스크린샷 2022-06-06 오전 12 04 12

Try adding it to AssimpAnimation aiProcess_ConvertToLeftHanded | I'm not sure why the results are different depending on the environment,, but if you use that flag in code, it might work.

lucasjinreal commented 2 years ago

@Nor-s I didn't change the code, should be same as yours. let me have a try, if your code same as mine, I maybe should using aiProcess_ConvertToRightHanded to inverse it again, which is really strange.

lucasjinreal commented 2 years ago

@Nor-s Hi, I am uncomment that flag (it was just comment out when clone), not it looks lack some mesh:

image image

the flags:

 Assimp::Importer import;
        unsigned int assimp_read_flag = aiProcess_Triangulate |
                                        aiProcess_SortByPType |
                                        aiProcess_GenUVCoords |
                                        aiProcess_OptimizeMeshes |
                                        aiProcess_ValidateDataStructure |
                                        aiProcess_ConvertToLeftHanded |
                                        // aiProcess_FlipUVs |
                                        aiProcess_GenNormals |
                                        aiProcess_CalcTangentSpace;
        assimp_read_flag |= aiProcess_LimitBoneWeights;
        assimp_read_flag |= aiProcess_JoinIdenticalVertices;
        assimp_read_flag |= aiProcess_FlipWindingOrder;
        import.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);
Nor-s commented 2 years ago

@jinfagang You need to modify the AssimpAnimation class.

not model.cpp

lucasjinreal commented 2 years ago

@Nor-s thanks for the info, will try it later. But I have a question, doesn't fbx animation baked in? Why there should another reading process for the animation?

Nor-s commented 2 years ago

@jinfagang

There was no other reason. The reference I saw when I was learning the skeleton was just such a structure.

In my opinion, this structure has the advantage of being easy to implement. It also makes the animation model independent. Therefore, if you register an animation, you can use it in all models. (As long as the models have the same binding pose structure. Note that some Mixamo models have different binding poses.)

But I think it would be better to put them together.

So, in the future, I'm going to have an import manager and create a system that combines the two processes and manages resources.

lucasjinreal commented 2 years ago

@Nor-s thanks, after your explaination, i now though depart them from each other could be better. SO that animations with BVH and model with FBX can be work out of box.

Will catch u up with this project!

BTW, I found I can not using the camera (touchpad in mac) can not freely turn around the model, is it normal?

lucasjinreal commented 2 years ago

I tried edit animation class, but the result still not right:

image

and the texture seems not right as well.

models.cpp:

 unsigned int assimp_read_flag = aiProcess_Triangulate |
                                        aiProcess_SortByPType |
                                        aiProcess_GenUVCoords |
                                        aiProcess_OptimizeMeshes |
                                        aiProcess_ValidateDataStructure |
                                        // aiProcess_ConvertToLeftHanded |
                                        aiProcess_FlipUVs |
                                        aiProcess_GenNormals |
                                        aiProcess_CalcTangentSpace;
        assimp_read_flag |= aiProcess_LimitBoneWeights;
        assimp_read_flag |= aiProcess_JoinIdenticalVertices;
        assimp_read_flag |= aiProcess_FlipWindingOrder;
        import.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);

animation.cpp

  unsigned int assimp_read_flag =
                aiProcess_SortByPType |
                aiProcess_ValidateDataStructure |
                aiProcess_ConvertToLeftHanded |
                aiProcess_LimitBoneWeights;

            importer.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);

why it was so not right?

lucasjinreal commented 2 years ago
image

the mesh also cavity.

lucasjinreal commented 2 years ago

@Nor-s all right, now I reset all flags, except adding a ConvertToLeft hand in animation. now it looks like this:

屏幕录制2022-06-07 下午10 02 45

as you can see, the animation now looks a little bit normal, but still not right, the leg, are opossited I think. it was un natural.

why?

Nor-s commented 2 years ago

@jinfagang i dont know... sorry

But try setting this flag on model load as well. The reason it looks like this is probably because the coordinate system of the model nodes does not change. (It looks like the left and right are reversed because only the animation has changed)

Try the following: aiProcess_MakeLeftHanded | (model or animation)

(I found out later that the 'ConvertToLeft' option sets various things. So try MakeLeftHanded as well. instead CovertToLeft..)

//this is shortcut flag for Direct3D-based applications)
#define aiProcee_CovertToLeft aiProcess_MakeLeftHanded | aiProcess_FlipUVs | aiProcess_FlipWindingOrdel| 0 

If that doesn't work, check out the next project. These projects also looked fine to me for animation with assimp.

And I'm not sure about the camera rotation. It works fine on my macbook m1. (But moving the camera forward is slow, because I haven't set that part up for the mixamo model yet.)

I'm really sorry that I haven't been able to help again.

lucasjinreal commented 2 years ago

@Nor-s thanks, I will try aiProcess_MakeLeftHanded later.

why does the system platform will effect the animation loading way? it didn't make sense. Have u tried download some mixamo fbx model file and visualize?

Nor-s commented 2 years ago

i find model error but this model

But This model gave an error even when I run it on Blender. screenshot (14) screenshot (17)

screenshot (15)

And if the model texture has an alpha value, the model may not be visible.

Mixamo Load test

12323

화면 캡처 2022-06-08 130620 화면 캡처 2022-06-08 130634 화면 캡처 2022-06-08 130703 화면 캡처 2022-06-08 130719 화면 캡처 2022-06-08 130733 화면 캡처 2022-06-08 131032 화면 캡처 2022-06-08 131053

lucasjinreal commented 2 years ago

@Nor-s are u tested on macos? the only difference between you and me is system.

Nor-s commented 2 years ago

@jinfagang I really don't know why. It works fine on my macbook.

mac os test

image image

image

image

image

image

image

image

lucasjinreal commented 2 years ago

@Nor-s I am trying build pixe3d on a ubuntu, see if this platform is normal. I will clone a fresh repo to start.

Nor-s commented 2 years ago

@jinfagang Since I have never built in Ubuntu environment, I will also try it in wsl2 ubuntu environment.

Also, if you are using gcc12 assimp will not build so you may need to install a different version.

: assimp issue 4433

Nor-s commented 2 years ago

platform

wsl2 Ubuntu 20.04.4 LTS (Focal Fossa) gcc 9.4.0 x86_64-linux-gnu

install

sudo apt install wget
sudo apt install openssl
sudo apt install ninja-build
sudo apt-get install build-essential libgtk-3-dev
sudo apt-get install libxinerama-dev
sudo apt install libssl-dev

CMAKE 3.23.2

wget https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2.tar.gz
tar -xvf cmake-3.23.2.tar.gz
cd cmake-3.23.2
./bootstrap --prefix=/usr
make
sudo make install

Edit pixel3d/CMakeLists.txt

project(
  n-glcpp
  LANGUAGES CXX
  VERSION 0.0.5)
set(CMAKE_CXX_STANDARD 17)
if (UNIX AND NOT APPLE)
    set(CMAKE_MAKE_PROGRAM /usr/bin/ninja CACHE FILEPATH "")
endif()

Build

git clone --recursive https://github.com/Nor-s/Pixel3D.git
cd Pixel3D
mkdir build
cd build
cmake .. -G Ninja
ninja

image

However, the models have not been tested yet.