How to import a 3D model in the Redkit from a 3D software ? - JLouis-B/RedTools GitHub Wiki
Thanks to Nemomallo from CD Projekt forum for greatly improving and redesigning this tutorial!
Prepare your models
In the first place, you have to export your 3D models in a format supported by the converter. The list of the supported formats is the list of the formats supported by the Irrlicht engine or by the Assimp, you can find these list here and here (There's also 3D World Studio (.smf) and other formats because these lists aren't up to date).
About the textures of your model :
- Don't use capital letters in the name of the textures, it can cause problems
- For a normal map, set the same name than the diffuse map, but with a "_n" suffix. For the specular maps, use the "_s" suffix
- If the textures are not loaded correctly in the Redkit, you can (re)set the textures manually.
If you use more than one LOD, you should set each LOD at the same position in your 3D software and export each LOD in a separated file (one file per LOD). If you use a collision mesh, it works exactly like the LODs, set your collision mesh at the position of the object and export the collision mesh in a separated file.
In this example, I have made a 3D model in Blender (with 2 LOD), and I exported it in the .obj format, because it's a very simple format well supported by Blender and Irrlicht.
Usage of the converter
After this, I import these files in the converter. To do this :
- Start the converter
- Click on the "Select 3D models" button, and I load my LOD0 (the most detailed LOD) model.
- To add the LOD1 (less detailed), I go to Redkit tools/LOD/LOD/LOD1 to select the LOD1 layer, and I load the LOD1 model with the "Select 3D models" button.
- Now, I will set the size of my object. I go to Redkit tools/Size, and I set the size of the object. This will be the size of the object in the Redkit.
- To ensure that the model scale stays the same, copy the last three numbers of one the values and bring them behind the comma eg. 0.21774 meters is not the actual size of the church that is 21,774 meters high in the 3D program
- After this, select "RedEngine (.re)" in the format selector, set the name of your file, and click on the "Export" button.
Now you have your .re file.
Import in the Redkit
Open the Redkit, and import the textures before the .re file. Import your .re file (right click/import/mesh), and your model is ready in the Redkit.
Import custom collision
Often the basic collision creation Redkit provides is not enough, that’s why we now want to learn how to import custom collision. For importing complex collision, you need at least two 3D models LOD0 (as described above you can add also LOD1 and LOD2 to LOD0) and a collision model/mesh (coll_mesh). Importing custom collision needs additional steps. Follow all steps above until the usage of the converter. Now we have to do something different. The example files I use are church_outskirts (LOD0,LOD1,LOD2) and curch_outskirts_coll.
- Start the converter
- Click on the "Select 3D models" button, and load LOD0 (the most detailed LOD) model.
- To add the LOD1 (less detailed), go to Redkit tools/LOD/LOD1 to select the LOD1 layer, and I load the LOD1 model with the "Select 3D models" button.
- To add the LOD2 (even less detailed), go to Redkit tools/LOD/LOD2 to select the LOD2 layer, and load the LOD2 model with the "Select 3D models" button.
- Don’t add the Collision mesh LOD/Collision mesh must be empty!
- Set the size of the object. Go to Redkit tools/Size, and set the size of the object. This will be the size of the object in the Redkit.
- After this, select "RedEngine (.re)" in the format selector, set the name of your file, and click on the "Export" button.
Now you have the “yourname”.re file for example church_outskirts.re but we don’t import it into Redkit yet.
After that we create a second .re file, here are two ways to do this: Close the Converter and restart it.
Don’t close the converter and clear the LOD we used
- To clear the LODs go to Redkit tools/LOD/Clear all LODs. After that we have to set LOD0 as active LOD for importing meshes.
We want to import the file coll_mesh into the converter now
- Click on the "Select 3D models" button, and load the coll_mesh model as LOD0.
- Set the size of the object. Go to Redkit tools/Size, and set the size of the object.
It’s important that we set the size of the coll_mesh to the same xyz size as the LOD0(LOD1, LOD2) we used before, not bigger, not smaller! If the coll_mesh is not as big as the LODs it will be misplaced from the LODs and not fit.
- After this, select "RedEngine (.re)" in the format selector, use the name you used above for exporting LOD0(LOD1, LOD2) as yourname_coll and click on the "Export" button.
You have now a “yourname_coll”.re file like church_outskirts_coll.re and we can start importing those two files into Redkit. We import the first file (coll_mesh).
-
Open the Redkit, and import the textures (right click/import/textures) before the .re files
-
Import the file yourname_coll.re (right click/import/mesh)
-
A window pops up, change the name of the file from “yourname_coll” to “yourname” and click ok and ok again
-
Open the imported file “yourname” and go to Collision/Create exact collision
-
Turn on Show collision by clicking that button and check
-
Save your file and close it We import the second file (LOD0, LOD1, LOD2)
-
Import the file yourname.re (right click/import/mesh)
-
A window pops up, but now we just click ok twice (Explanation: The file that we imported first whose name we changed to “yourname” gets actualized by importing a file with the exact same name.)
-
Open the imported file “yourname” check the collision by clicking the button Show Collision
Check your Mesh
- If collision aligns to the mesh -> if not repeat process from the beginning and /or adjust your models in your 3D program if necessary
- Adjust textures if necessary and remove data if necessary -> Follow the procedure described below.
- Then Save
Problems and solutions (in the Mesh Editor/opened Mesh)
Material Tab
You see nothing -> mesh might be too small check size.
You see nothing or some parts are invisible -> Check List of materials if the instances are destroyed or not (picture instance underlined yellow)
- if destroyed click Create Instance and assign base material manually or click the Button Reassign
- if the Instance is already created go to tab Raport and follow procedure below
You see nothing or some parts are invisible -> Check normals of the model in 3D program
Your mesh has textures missing -> assign them manually or reassign them by clicking the button Reassign (picture: reassign underlined blue)
You see no collision -> Click Show collision if you still have problems go to Tools/ Swap collision triangles this changes the normals of the collision mesh and repeat from start until fixed
Still problems with collision mesh -> Check normals of the coll_mesh in 3D program and repeat from start until fixed
I can’t walk on the mesh -> Go to Tools/SwapCollisionTriangles
Stil problems with walking on it -> Check normals of the coll_mesh in 3D program and repeat from start until fixed
Raport Tab (see above)
Problems material “x” is not used! Click on Fix! this deletes the unused material (see picture)
After deleting unused materials all textures are wrong -> Save file and repeat steps above after: We import the second file
Properties Tab
Wrong sounds when walking or hitting mesh in level -> Change sound material
Other important entries to look at in the Properties Tab
- autoHideDistance distance -> after which mesh get hidden 0= infinte distance
- ShadowRenderingDistance -> how far shadows will be drawn when mesh in level and shadows added to mesh, override in level possible
LOD Tab
Adjust the distance when LOD switch only at PC, Xennon is for Xbox
(Explanation: If we imported a (coll_)mesh with an undefined material (not to a texture connected material) it will not create the instance, but the information is there and if you create the instance default textures will be assigned. After we import the file “yourname.re” all old mesh data but the collision got removed.
If we imported a (coll_)mesh with a defined material but the second import of the file “yourname” uses different materials than what was defined before the old material and data will also be removed.
The material that was used before contains no data and is unused, so we have to fix/delete it. This can lead to problems in the material list mesh and breaks it so you have to reimport “yourname.re” again to fix the list. -> follow below
But if we imported a (coll_)mesh with defined material and the second import uses that material the mesh data gets updated and the instance gets set back to the basic values ( loses extra information like detailmap or diffuse colour and LOD switch distances) with diffuse, normal and specular map assigned. - > Follow below
In both cases I advice to add extra information only after fixing unused materials.
Always be aware that, if you want to make changes related to the coll_mesh you will have to do the same import process again. Don't use reimport for importing the coll_mesh.re (in the mesh file window (Mesh editor), it will remove the collision data)!