#author("2022-10-18T10:06:51+00:00","default:admin","admin")
*''3D Characters'' [#r8bb1e0c]
We will use Blender, a 3D production software that is easy to obtain.
The detailed usage of Blender is omitted here.
#contents

**''Blender Preferences'' [#s1ba1bd8]
First, change the Blender environment to one suitable for Bakin.

&size(16){''About the Scene Units''};
Please make sure that the scene units are set as follows.
If the settings are different, the model will not be properly sized for FBX export.
#ref(ENシーンの単位.png)
#br

&size(16){''About FBX Export''};
To specify FBX export settings appropriate to Bakin's specifications, specify the following.
#ref(ENFBXエクスポート.png)
#br

&size(16){''How to Set Motions''};
There are two ways to set up motions.
!) Importing a model and motions as a single file
2) Importing a model and motions as separate fbx files

''1) Importing a Model and Motions as a Single File''
Select all bones with character models and motions and escport them together to create a single fbx file with a model and motions.
When an fbx file is loaded in Bakin, a model is generated and the built-in motion is loaded by selecting that model in Motion Management.

''2) Importing a Model and Motions as Separate fbx Files''
A model and bones, bones with motions of the same structure, if exported separately, will be exported as separate fbx files.
The bone structure on the model side and the bone structure on the motion side must be the same.
Load each fbx file in Bakin and specify the "fbx you want to use for the model" and "fbx you want to use for the motion" respectively.


**''Advice on Making Your Own Models - Based on Preset Models -'' [#vc39f742]
&size(16){''Exporting a Model from Bakin''};
We will refer to the "Standard_A" character model in the 3D_Tutorial game file for this explanation.
(The DLC "3D_Tutorial" must be downloaded in advance.)
#ref(ENモデルのエクスポート.png)
Open the 3D_Tutorial game file, select the 3D character model under "Resources > Models > standard_A" and press the Export button.
Select any folder to export.
Next, select the "motion_A" folder in the model list and export this folder as well.
#ref(ENモーションA.png)
Once the data has been exported, launch Blender, select File > Import > FBX, and import with the following specifications
#ref(ENFBX.png)
This time, since the model and motions are handled as separate files, proceed with the motion setting method "2) Importing a Model and Motions as Separate fbx Files".
This method has the advantage that the same motion can be used for different character models with the same bone structure.

After importing the model into Blender, edit the polygon mesh and textures as needed to your liking.
#br

&size(16){''Preparation for Adding a Model''};
Prepare a folder for the assets you wish to add.
This folder is only used temporarily when adding a file, and the location of the file or the name of the folder does not matter.
The added model will be added as a separate file with the same file name under the res folder in the game file folder.

Put the model file (.fbx), texture files (.png), and a specifying file (.def) directly under the folder you have provided.
Example: If you put an asset (standard_A) in the [standard_A] folder
#ref(standard_A1.png)

When adding a model to Bakin, please add it with the standard_A.def generated when exporting in the same folder with it.
This file contains the material and texture linkage specifications.
If you change the material name or texture name, you will need to edit this. (It is possible to manually specify the material name in Bakin without editing.)
#ref(standard_A2.png)
#br

**''Advice on Making Your Own Models - Adding Your Own 3D Characters -'' [#y4fde169]
This section explains how to add your own 3D characters to Bakin.
There are two ways to add motion data, depending on how the motion data is handled.

''Separating a Model and Motions as Separate FBX Files''
Add a model file with polygons and skeleton structure, and motion files with skeleton structure and motion data separately.

The advantage of this method is that existing motions can be applied to different polygon shapes as long as they have the same skeletal structure.
(This method is used for the human characters in Bakin.)

The files required for addition are model (.fbx), texture (.png), and motion (.fbx) files.
The skeleton structure and name of the model and motion should be the same.
#ref(./自作のモデルを作る際のアドバイス1.png,80%)
#ref(./自作のモデルを作る際のアドバイス2.png,80%)
#br

''Combining a Model and Motions as a Single FBX File''
Add polygons, skeleton structure and motion data together as a single file.
If the model has multiple motions, load the corresponding file with the model and select the corresponding model in Motion Management.
The number of frames and loop settings can then be specified.
#ref(./自作のモデルを作る際のアドバイス3.png,80%)
#br


&size(16){''About Files Required for Addition''};
3D characters require model, texture, and motion data.
Creating these requires knowledge of 3D graphics and prescribed software.

The format and specifications of each file are as follows.

&size(14){''1. Model file (.fbx)''};
- File Format: FBX format.

- The recommended FBX version is FBX7.4 (FBX2014).
(Bakin's human characters were created using Blender 2.83)

- The FBX format supports both ASCII and binary formats.

- For versions earlier than FBX7.4 (FBX2014), you will be able to load the file by enabling the Optimization Options specification when adding the file to Bakin. (*The display may not be correct in some cases.)
For more information, please see the section on Adding Methods to Bakin below.

- The display will not be correct except for the triangular polygon.
Please perform triangular polygonal conversion in advance or specify the Optimization Option when you add the model to Bakin.
(Enabling the Optimization Option will automatically perform the triangular polygonalization.)

- The size of a single block of Bakin terrain is equivalent in Blender to the size of a primitive solid (dimension 1 m: scaling 0.5).
Bakin's standard character size is such that it fits for one block of terrain.

- Multiple materials can be specified for a single model, and the model's specified material can be changed on the Bakin side.

- The file names should be specified in half-width alphanumeric letters.

- The limit on the number of joints in a skeleton structure is limited to a maximum of 1365 per model.
However, this limit varies between a minimum of 341 and a maximum of 1365, depending on the machine spec, according to the OpenGL specification.
In addition, the maximum number of weight influences should be 4. (If the maximum of 4 is exceeded, 4 will be adopted with preference given to those with the highest weights.)

- For separate motion data, the bones of the character model are not animated, but export as a FBX file with only the polygon and skeleton structure.

- To combine motion data, specify multiple animations in this model file, and then export the model and baked animations together as a single FBX file.
The working unit for motion is 60 fps.

&size(14){''2. Textures (.bmp、.png)''};
- File Format: BMP or PNG format.

- The recommended pixel size for textures is a value called a power of 2, such as 64 x 64, 128 x 128, 256 x 256, or 512 x 512.  256 x 128, etc. can also be used.
Specifying a texture with a size other than a power of 2 may cause problems with the display.

- The file name of the texture is the one specified in the model's FBX.

- Alpha channel can be specified in BMP to create transparency.
PNGs can also be rendered transparently by specifying a transparent area.

- Bakin uses PBR (Physical Based Rendering) to achieve more realistic textures. When using PBR rendering, it is recommended that three textures be specified for each model, depending on the purpose of use.
#br
Albedo Map Texture: Texture that specifies the color of the model
Normal Map Texture: Texture that specifies the surface roughness of the model
Mask Map Texture: Texture that specifies R (luminance), G (roughness), B (metal), and A (specular intensity) for each RGBA channel, respectively
#br
By specifying these settings correctly, more realistic textures can be expressed.
#br
Also, even without a mask map, the specifications controlled by the mask map can be adjusted to some extent by the material properties.
#ref(ENマテリアルプロパティ.png)
- The file names should be specified in half-width alphanumeric letters.

- Example of Texture Files
Albedo Map Texture
#ref(追加に必要なファイル2.png)
Normal Map Texture
#ref(追加に必要なファイル3.png)
Mask Map Texture
#ref(追加に必要なファイル4.png)
#br

&size(14){''3. Motion Files (.fbx)''};
If the asset to be added is to be separate files for the model and motions, motion-only files will be required.
The supported FBX versions and formats are the same specifications as for the model file section.

- File Format: FBX format.

- Delete the polygon mesh in the motion files.

- The skeleton structure and name should be the same as in the model file.

- The working unit of motion is 60fps, the same as when it is put together.

- If there are multiple motions (actions) in one motion file, they are loaded as separate motions.

- Specify the start and end frames and export the FBX file with the baking process specified.

- The motion file names are flexible, but it may be easier to work with if you include a specific string, such as mot_Motionname(half-width alphanumeric letters).fbx.
Example: mot_walk.fbx, mot_wait.fbx, mot_run.fbx

- The default setting for motion is no loop regeneration.
If you wish to loop the animation, turn on the "Loop" specification for the motion in the Motion Properties.
#ref(ループ.png)
#br


&size(16){''Preparation for Adding a Model''};
+Prepare a folder for the asset files you wish to add.
This folder is only used temporarily for addition. Any file location or folder name is acceptable.
The added model will be added under the res folder in the game file folder.
#br
+Put the model file (.fbx) and texture file (.bmp or .png) directly under the folder you have prepared.
Example: If you put an asset (standard_A) in the [standard_A] folder
#ref(追加に必要なファイル6.png)
#br

**''Adding Methods to Bakin'' [#ece24823]
The process for adding a model and motions to Bakin is the same whether they are separate or combined.
#br
+Select [Resources] > [Models] > [Add Button] to open the [Asset Picker] window.
#ref(ENBAKIN への追加⽅法1.png)
#br
+Select the [Select from File].
#br
#ref(ENBAKIN への追加⽅法2.png)
#br
+Open the folder containing the model you wish to add and select the fbx file.
#br
+Check [Auto Optimization When Importing FBX File] if necessary.
Optimization automatically performs the following processes:
---Skin weight normalization
---Polygon triangulation
---Apply scale (scale option next to the optimization checkbox)
---For FBX formats earlier than FBX7.4, conversion to FBX7.4
(If the model file was not imported correctly, uncheck the box.
(If the model file was not imported correctly, uncheck the box.)
#br
+Press [Add and Exit].
#br
''Steps 1-5 can also be done by dragging and dropping fbx files into the model list.''
#br
+The character model is added to the Model List.
The location of the added file will be displayed in [Model Settings > Basic > Folder Name].
The textures are automatically created in the texture folder.
#ref(ENBAKIN への追加⽅法3.png)
#br
(Assets added by [Select from File] will be distinguished from the default system assets [reserved] and will be displayed with the model name in black).
#br
User assets are also saved in the game file when the game is saved.
The original files are not used as is.
#br
+Select the added character model and register it as a stamp using the Stamp button.
#ref(ENBAKIN への追加⽅法4.png)

''Adding Motions''
Continue with the motion fbx files, if available
Follow the same procedure as above to add a motion file as a model, and then select the added motion model in the motion menu.
#ref(ENBAKIN への追加⽅法5.png)

+Selecting a motion model registers the specification in the Motion List.
You can change the name of the motion specification to anything you like.
#br
#ref(ENBAKIN への追加⽅法6.png)
#br
+After specifying motion settings, return to the stamp and register the motion settings on the stamp of the character model.
#br
#ref(ENBAKIN への追加⽅法7.png)
#br
+Once you have registered the motion setting on the stamp, return to the motion menu and select the motion setting you wish to specify.
#br
#ref(BAKIN への追加⽅法8.png)
#br
+If there are more motions to be added, click the [+] Add button under [Motion Sets Settings > Motions] to add motion models.
#br
#ref(BAKIN への追加⽅法9.png)
#ref(ENBAKIN への追加⽅法10.png)
#br
The "Motion Name" of the Motions are tied to the behavior in the game, so by adding the following Motion Name, the motions will be automatically registered as in-game behaviors. 
(Please refer to the "Motion Name Correspondence Table" for details.)
wait: Waiting motion
battle_wait: Standby motion in battles
walk: Walking motion
run: Running motion
attack: Attack motion in battles
skill: Skill motion in battles
damage: Damage motion in battles
#br
Once you've specified the setup, cast settings, etc., then test play to see how it works!
#br
This completes the series of steps for adding a character model.


//**キャラシェーダ【cha_hair】について [#udc1069b]
//キャラシェーダを使用する場合、モデルに以下のマテリアルが含まれている必要があります。
//・分離してるマテリアルは顔パーツのみ?
//・顔マテリアルは1つ。その中に目や口のテクスチャが貼られる。
//モデルとしては顔matのみ
//目や口の位置はどうやって判断している?
//インポートしたモデルでも、それらしい位置に出た。
//これはdefの情報を読んでいる?読んでいるならインポート時に同じフォルダにあることが条件?

//体のマテリアルは1つでもよい

//重要なのは顔のマテリアルだけ

//・顔パーツの位置は、シェーダで定義しており、
//正面から投影する形で、目や口をキャラモデルに表示させている。

//マテリアルプロパティで「目の高さ:1」と設定すると、Bakin上の高さ1の位置に、目が表示される。
//※DCCツール側のモデルサイズが1の場合の話

Front page   New Page list Search Recent changes   Help   RSS of recent changes