Closed TedGriggs closed 1 year ago
Hi! Just following up on this issue. If you're not interested in reproducing this with the code I provided, can you point to an example of where you set a material (via setMaterial() not setTexture()) on a 3D mesh and have it animate properly.
Thanks!
The material seems incorrect for draw 3d mesh
What does that mean? Can you point me to a material for a 3d mesh that uses a shader that is "correct" and animates?
To create your own material for your objects look pls these shaders as reference:
axmol-dir\cocos2d\core\renderer\shaders\3D_positionNormalTexture.vert
axmol-dir\cocos2d\core\renderer\shaders\3D_colorNormalTexture.frag
or
axmol-dir\cocos2d\tests\cpp-tests\Resources\Shaders3D\3d_position_skin_tex.vert (no normal attribute)
axmol-dir\cocos2d\tests\cpp-tests\Resources\Shaders3D\3d_color_tex.frag
or other combinations.
Okay, I see what I need to do now. The getPosition() in the vertex shader was the key. Thanks!
When you setMaterial() on a 3D mesh, its rendering is tweaked and animations do not work.
We've modified the basic HelloWorldScene to demonstrate.
It loads a model "orc.c3t" (from the ccptests), gives it a plain texture, ("Yellow.png" - a 16x16 solid yellow image which just colors the orc entirely yellow), and starts an animation. This draws and animates the orc correctly.
It also loads a second "orc.c3t" model and gives it a simple material, "orc.material", that uses the most minimal shader you can do (just paint every pixel white, see "orc.vert" and "orc.frag"). It does not draw the orc correctly and it does not animate.
Using setPosition(), setRotation(), and setScale(), you can move the second orc around. It seems like no transforms are being applied to the meshes, bones, or whatever make up the second orc.
I bundled everything into a zip file. issue.zip
Maybe there is a misunderstanding on how materials are supposed to work. In any case, hopefully someone is still working on this engine that can take a look!