Importing Models Exported from DCC Tools
Currently, most Digital Content Creation (DCC) tools (3DS Max, Maya, Blender) can export models in FBX and glTF formats. These formats, exported by these tools, can be well received in Cocos Creator 3.0.
Exporting FBX
Because the coordinate system of the DCC tool and the game engine’s coordinate system are not necessarily the same, some transformations are required when exporting a model to get the desired result in the engine. For example, Blender’s coordinate system is X-axis right, Y-axis inward, and Z-axis upward, while Cocos Creator 3.x’s coordinate system is X-axis right, Y-axis upward, and Z-axis outward, so the rotation needs to be adjusted to make the axes consistent.
The following uses Blender 2.8 as an example to introduce the model import process. First, create a model in Blender.
In Blender’s FBX Export Options documentation, choose Up as Y Up and Forward as -Z Forward.
Imported into Cocos Creator, notice that the nodes are rotated by -90 on the X-axis in order to combine the axis with Cocos Creator. The axes are aligned.
To use a different rotation value, Blender’s FBX export plugin provides an experimental function, Apply Transform, which can directly transform the rotation data into the model’s vertex data.
Notice that the rotation data is gone in Cocos Creator 3.x.
Exporting glTF
Please read the following documents:
- glTF also uses a right-handed coordinate system
Options for exporting glTF in Blender. It is relatively simple, as long as the +Y Up option is checked, there is no rotation value in the exported data.
Possible issues
During the game development process, the orientation of the model may be used. For example, if some objects should face the player (using the LookAt()
method), consider the initial orientation of the model. Here are two methods to adjust the initial orientation of the model.
- In Cocos Creator 3.x, the -Z-axis is used as the forward direction, while in Blender, the forward direction is +Y-axis, when making a model, the positive direction of the Y-axis should be used as the orientation of the object, and the derived transformation later, in Cocos Creator, the -Z-axis will be used as the front direction.
- To not change the orientation in the DCC tool, try adding a parent node to the imported model in the scene, and then rotate the model so that the initial orientation of the model is the -Z-axis. All subsequent rotation-related operations are based on the parent. A node is an operation object.
Artist’s production specifications
Reasonably formulating a sub-assets name under model assets (e.g mesh or material). Each modification of the sub-assets name will result in the loss of the place associated with the sub-assets in the project.
When a part of the model needs to be transparent and a part does not need to be transparent, it should be exported into two materials. If it is a material export that is prone to model penetration, you need to manually adjust the material.
External asset references, use relative path when exporting. Otherwise, under the cooperation of multiple people, the original asset path will not be recognized, resulting in the model’s built-in materials cannot obtain the texture correctly and appear yellow. Autodesk 3ds Max export local path is modified as follows: