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 3D.
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 outward, z-axis right-hand coordinate system, and Cocos Creator 3D is x-axis right, y-axis, z-axis right-hand coordinate system, so rotation is required to make the axes consistent.
The following uses Blender 2.8 as an example to introduce the model import process. First we create a model in Blender.
In Blender's FBX export options documentation, we choose up as y up and forward as -z forward.
Imported into Cocos Creator 3D, you can see that the nodes are rotated by -90 on the x-axis in order to combine the axis with Cocos Creator 3D. The axes are aligned.
If you don't want this 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.
You can see that the rotation data is gone in Cocos Creator 3D.
Exporting glTF
Please read ther 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 you want some objects to face the player (using the LookAt()
method), you need to consider the initial orientation of the model. Here are two methods to adjust the initial orientation of the model.
- In Cocos Creator 3D, the -z-axis is used as the forward direction, while in Blender, the forward direction is +y-axis, so 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 3D, the -z-axis will be used as the front direction.
- If you do not want to change the orientation in the DCC tool, you can 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: