Importing a Car into ANVEL
pfunkyfize last edited by pfunkyfize
Before I begin this walkthrough of importing new objects for ANVEL and tackling some common problems, I want to let readers know of the steps I will be demonstrating that are found in the following wikis:
- Importing a New Object - https://wiki.anvelsim.com/index.php/Importing_New_Object_Mesh
- The Object Editor - https://wiki.anvelsim.com/index.php/Object_Editor
- The Package Manager - https://wiki.anvelsim.com/index.php/Package_Manager (optional for now but necessary if you want to share your assets later)
The above wiki pages will lead ANVEL object authors through the process of creating and loading 3D assets into ANVEL in a logical order. Although the concrete pipe in the Importing a New Object wiki is a simple cylindrical asset created in-house, a more common source of 3D art assets is Turbosquid or other similar repositories, and these assets may have some issues that need correcting before they will import correctly.
The support request from this user was about importing an asset (The free Mitsubishi Lancer EVO on Turbosquid) that was crashing the Ogre mesh converter and the textures weren't sticking to the object. I was able to get the Lancer into ANVEL with the main textures intact and I'll go through the steps on how I fixed the issues. I'll be using DAZ Studio, Blender, Notepad++ text editor and Ogre Meshy. They're all free tools found on the web.
The basic overview of the importing steps:
Step 1- Procure or create the asset to be imported
Step 2 - Export the asset into a Wavefront OBJ file (with accompanying .mtl file)
Step 3 - Convert the newly exported OBJ into an Ogre .mesh file (with accompanying .material file)
Step 4 - Bundle all the new .mesh,.material and texture files into a single one level directory in the userData area of ANVEL
Step 5 - Check newly converted .mesh file inside Ogre Meshy
Step 6 - Create the new asset inside of ANVEL with the Object Editor
Step 1. This is where the 'artistry' happens, you should make your 3d asset in a modeler you are comfortable with. This example uses DAZ Studio for checking out object surfaces and Blender for heavy lifting 3d manipulation and triangulating 4 edged to N-Gon mesh. Generally speaking, you don't need expensive modeling software to make 3D items for ANVEL. Mesh is mesh no matter if it's made in Maya or Blender...
Since the Lancer from Turbosquid looked fundamentally sound once loaded in DAZ Studio, there wasn't much to change structurally. However, this is where I saw the discrepancy causing the main car texture map to not stick to the model. The texture was clearly not showing up on the car so I had to find the correct surface to apply the car texture. In DAZ Studio, I went to the surface controls and modified the opacity value of each surface so that the surface would turn invisible one at a time. When I found the surface that made the car body turn invisible I knew I had found the right surface. This method is the sure fire way of determining the surface if the surface names weren't named approprioately like 'carbody','driversidewindow' or 'windshield'. These surface were labeled 'default_12467' or 'Material_992' and other non-indicative labels. Once I found the correct surface I applied the appropriate vehicle texture to it then exported this new OBJ on top of the faulty one. This issue would have taken longer to find if I were manually editing the text OBJ file.
Step 2. DAZ Studio gave me a way to visually see the exact surface I was editing instead of guessing the material on a flat text file. Since I made a change to the object by applying the vehicle's texture, I needed to save the change by exporting the entire car and overwriting the old OBJ file for this new one. Since I was editing my work in DAZ, the base unit of measurement is the centimeter so when I exported the OBJ, I made sure to export it to 10% so it will have a ballpark scaling inside ANVEL. See the Object Editor wiki for useful exporting options. Before Ogre converts the OBJ and its MTL file, I checked the MTL file for long paths and removed them in a text editor leaving just the file name for the required texture map name.
Common causes for Ogre to fail conversions or even crash when the .OBJ is converted to .mesh is having a mix of quad faces and triangulated faces together on the same model. Depending on what 3d modeler is used to make the model, there could be a mix of triangulated faces and quads/N-gons. Ogre requires all triangle geometry. If the object being converted is a simple primitive type, Ogre seems to triangulate them easily if the faces are all quads and the triangulation step in Blender can be skipped. I opened the Lancer inside Blender and saw that it had a mix of quads and triangle polygons so I triangulated the entire OBJ by selecting all the appropriate objects in the Blender Object hierarchy for the Lancer, going into edit mode then do a CTRL-T which executes the triangulating program inside Blender. Since I made another change to the geometry of the OBJ file, I re-exported these new changes on top of the previous OBJ file. Also, I re-exported again so I checked the accompanying MTL file for full paths and they came back. I removed these full paths again leaving just the bare file names and saved the MTL file.
Step 3. At this point I opened ANVEL and ran the Ogre mesh conversion using the new Lancer OBJ and the conversion completed successfully without crashing.
Step 4. I bundled the newly made .mesh and .material files, together with the appropriate texture files and placed them in a directory inside the userAssets area of ANVEL (%LOCALAPPDATA%\Anvel\UserAssets on Windows or /usr/ANVEL/bin/common on Linux).
Now is also a good time to make an icon for your asset then place it in your new asset's folder. A good size is a 24x24 png screenshot of your model.
For now, the UserAssets directory is not specified as a resource directory inside of ANVEL's AnvelInit.xml file so the UserAssets area needs to be included in that file. Think of it like a PATH variable in an operating system. The asset directory you store your new assets in must reside in those directories or an entry for it must be added. See the 'Ingest the New Item into ANVEL' section inside this wiki -https://wiki.anvelsim.com/index.php/Importing_New_Object_Mesh#Ingest_the_New_Item_into_ANVEL for my example inside the AnvelInit.xml file.
Step 5. Open the Ogre Meshy application (Check the wiki for where you can get the free .mesh viewer) and check out the new .mesh file to make sure the geometry is well formed and the texture isn't distorted.
If you see discrepancies and/or distorted mesh it's back to Step 1 to fix it then run through the steps again until it passes visual inspection inside Ogre Meshy.
Step 6. The mesh inside Ogre Meshy looked good from all angles so I began the Object editor steps inside the the Object Editor wiki - https://wiki.anvelsim.com/index.php/Object_Editor. I jumped down to the 'Create a New Object' section inside the wiki and followed the steps to create and ingest the Lancer into ANVEL. This is the result.
Although the Lancer is huge in relation to the environment, this is an easy fix which can be tackled in one of three ways- assigning appropriate scaling parameters in the properties tab, manually rescale the vehicle to desired size with the scaling widget or open the object in a 3D modeler and re-export the model to something like 1% since we used 10% earlier then repeat steps 3-6. Since the scaling is all that is needed you don't need to retriangulate the mesh or reassign the main vehicle texture back on to the Lancer. For all intents and purposes, the Mitsubishi lancer from Turbosquid is successfully imported into ANVEL and it serves as a good proof-of-concept example.
I will tackle rescaling so the Lancer doesn't seem out of place with it's gigantic size. I go back into DAZ Studio and import the latest OBJ file then re-export it this time at 1%. ANVEL uses the meter standard as its base measuring unit so creating new models for that unit is easy if you're building a model from scratch. Since we're using a model that has been made in a different modeling software then we have to make some educated guesses to how we should scale it. That's why I will export at 1% since the original was exported down to 10% and it looked huge. Once I completed the export, I went on with steps 3-6 again (because we do not need to reassign textures or triangulate the OBJ mesh anymore in steps 1 and 2) and I am liking this last result a lot better:
I hope this walk-through helped and I'll be posting more examples and assets later.