This is a tutorial showing how to work with custom 3D models for X-Rebirth. In these instructions, I am using 3DS Max 32-bit 2012. Those using Blender or other versions of Max may have slightly different procedures. Regardless of the 3D modeling program you are using, the basic import/export approach remain similar.
I had intended to write a 3d modeling tutorial ages ago as a companion to my X Rebirth - Modding Guide. Hopefully this tutorial will help inspire more people to create custom models for Rebirth.
Description:
Herein, I will outline a method for importing an existing object into 3DS Max, making changes to the mesh, and then exporting the new model so it can be used in the game. This tutorial is intended for 'beginners' who are not familiar with how to use the modeling tools we already have available for this game.
In this tutorial, we will drill a hole in an asteroid and put some guidance lights inside. For the sake of simplicity, my instructions will be brief. I will include details when I think they may be useful, but I will assume you know your way around your computer and that you have a working-knowledge of the 3D modeling program you are using.
Requirements:
- Extracted game files (refer to X Rebirth Tools)
- 3DS Max. I am using version: 2012 32-bit.
- Collada plug-in for 3DS Max. Download here.
- .xmf/.xac <-> .dae converter. Thread and download here.
- osr_tut_asteroid.rar (optional) mod extension example files used in this tutorial. Download here. You can extract these files for reference, but do NOT install this extension as long as you are working through the tutorial.
Step 1 (mission possible):
The first thing we'll do, is to verify if we can spawn an existing asteroid near our starting location. There are several ways this can be done. We will write some MD (Mission Director) code to do the job. Copy the following into the XML editor of your choice (I use Visual Studio Express):
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<mdscript name="Osr_tut_asteroid" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
<cues>
<cue name="OSR_InitAsteroidTut" instantiate="false">
<conditions>
<event_cue_signalled cue="md.Setup.GameStart" />
</conditions>
<actions>
<create_object macro="macro.env_ast_ore_l_05_macro" name="$Asteroid" zone="player.zone">
<position object="player.primaryship" x="-8000m" y="5000m" z="8000m"/>
<rotation yaw="-40deg"/>
</create_object>
<signal_cue cue="OSR_Locate_Asteroid"/>
</actions>
</cue>
<cue name="OSR_Locate_Asteroid">
<conditions>
<event_cue_signalled/>
</conditions>
<delay exact="1s"/>
<actions>
<find_object name="$MyAsteroid" class="class.asteroid" macro="macro.env_ast_osr_l_05_macro" space="player.sector"/>
<do_if value="$MyAsteroid">
<create_mission cue="OSR_Locate_Asteroid" name="'Asteroid'" description="'Fly to the custom asteroid'" difficulty="level.trivial" faction="faction.player" type="missiontype.flyto" abortable="true">
<objective action="objective.flyto" object="$MyAsteroid"/>
</create_mission>
<signal_cue_instantly cue="AsteroidMissionEnd" param="$MyAsteroid" check="false"/>
</do_if>
<do_else>
<show_help custom="'Something is wrong. The asteroid does NOT exist!'" force="true" duration="8s"/>
</do_else>
</actions>
</cue>
<cue name="AsteroidMissionEnd">
<conditions>
<event_cue_signalled/>
</conditions>
<actions>
<set_value name="$MyAsteroid" exact="event.param"/>
</actions>
<cues>
<cue name="Asteroid_Check_Distance" checkinterval="3s">
<conditions>
<check_value value="player.primaryship.distanceto.{$MyAsteroid}" max="3000m"/>
</conditions>
<actions>
<remove_mission cue="OSR_Locate_Asteroid" type="completed"/>
<cancel_cue cue="OSR_Locate_Asteroid"/>
</actions>
</cue>
</cues>
</cue>
</cues>
</mdscript>
- Run the game. You should see a Mission Guidance directing you to the asteroid. If this works, you are ready for the next step.
- Set the stage for working with the game files if you haven't already done so. This involves extracting all of the cat/dat files somewhere so you can work on them without disturbing the game installation. There are instructions how to do this in various places on the forum.
- Install the Collada plug-in for 3DS Max.
- Extract the XRConverters files to somewhere that you can access with a command-line
Before you go too far, it might be a good idea to make sure things are set up properly. After you know what you are doing, you may want to skip some of these steps (or do things completely differently).
First, we will duplicate an existing asteroid copied from our extraction location into our active X Rebirth installation. Some of these steps are general in nature and will acquaint you with several fundamental aspects of modding this game.
From your extracted game files, locate and copy the following files into your X-Rebirth Steam installation location:
- assets\environments\asteroids\env_ast_ore_l_05.xml
- assets\environments\asteroids\env_ast_ore_l_05_data (folder and contents)
- assets\environments\asteroids\macros\env_ast_ore_l_05_macro.xml
- index\macros.xml
- index\components.xml
- libraries\material_library.xml
- assets\fx\textures\gradient_red.dds
- assets\textures\environments\asteroids\asteroid_01_diff.dds
We are going to add some 'runway' lights to our custom asteroid. For this, we will use an existing part from the Arawn Carrier. Copy the following files into the assets\environments\asteroids\env_ast_ore_l_05_data folder that you created above (note they are going into a different folder than where they come from)
- assets\units\size_xl\units_size_xl_capital_destroyer_1_data\anim_poslights_front-collision.xmf
- assets\units\size_xl\units_size_xl_capital_destroyer_1_data\anim_poslights_front-lod0.xmf
At this point, the game won't be able to see our duplicated asteroid. We will need to make some changes. In most cases, we are simply changing 'ore' to 'osr (replace 'r' with 's') in the asteroid files.
Rename the following files:
- assets\environments\asteroids\env_ast_ore_l_05.xml to env_ast_osr_l_05.xml
- assets\environments\asteroids\env_ast_ore_l_05_data to env_ast_osr_l_05_data (folder)
- assets\environments\asteroids\macros\env_ast_ore_l_05_macro.xml to env_ast_osr_l_05_macro.xml
Change the extension for the following 2 files from .xml to .pck
- index\components.xml
- index\macros.xml
Code: Select all
<entry name="env_ast_osr_l_05" value="assets\environments\asteroids\env_ast_osr_l_05"/>
Code: Select all
<entry name="env_ast_osr_l_05_macro" value="assets\environments\asteroids\macros\env_ast_osr_l_05_macro"/>
Change:
Code: Select all
<create_object macro="macro.env_ast_ore_l_05_macro" name="$Asteroid" zone="player.zone">
Code: Select all
<create_object macro="macro.env_ast_osr_l_05_macro" name="$Asteroid" zone="player.zone">
Edit file assets\environments\asteroids\env_ast_osr_l_05 to match the following:
Code: Select all
?xml version="1.0"?>
<components>
<component name="env_ast_osr_l_05" class="asteroid">
<source geometry="extensions\osr_tut_asteroid\assets\environments\asteroids\env_ast_osr_l_05_data" />
<layers>
<layer>
<waypoints />
<lights />
</layer>
</layers>
<connections>
<connection name="container" tags="contents" value="0" optional="0" />
<connection name="position" tags="position" value="1" optional="1" />
<connection name="space" tags="asteroid">
<offset />
</connection>
<connection name="Connection01" tags="part ">
<offset>
<position x="-0.000000" y="0.000000" z="0.000000" />
</offset>
<parts>
<part name="part_main">
<lods>
<lod index="0">
<materials>
<material id="1" ref="asteroids.ast_ore_01" />
</materials>
</lod>
</lods>
<size>
<max x="315.181" y="249.642" z="508.852" />
<center x="-9.48499" y="0" z="7.358" />
</size>
</part>
<part name="anim_poslights_front">
<lods>
<lod index="0">
<materials>
<material id="1" ref="effects.gradient_red" />
</materials>
</lod>
</lods>
<size>
<max x="98.9863" y="98.8839" z="274.4" />
<center x="0.36657" y="-0.181473" z="6.10352e-005" />
</size>
<size_raw>
<max x="231.7066" y="130.807" z="558.0496" />
<center x="-11.5705" y="-41.12183" z="-6.103516E-05" />
</size_raw>
<uv_animations>
<uv_animation mapchannel="1">
<uv_property name="u_offset" controller="linear_float">
<key frame="0" value="0" />
<key frame="100" value="-1" />
</uv_property>
</uv_animation>
</uv_animations>
</part>
</parts>
</connection>
</connections>
</component>
</components>
Step 5 (import):
Now that we have proven our duplicated asteroid works in-game, it is time to import it into 3DS Max. Before we can do that, we have to convert the asteroid into DAE format so Max can work with it. For this, we use the .xmf/.xac <-> .dae converter tool created by arc_.
Locate the folder where you installed the XRConverter and create the following file in that directory
Code: Select all
rem This converts from XML to DAE
XRConvertersMain.exe importxmf "E:\Steam\steamapps\common\X Rebirth" "E:\Steam\steamapps\common\X Rebirth\assets\environments\asteroids\env_ast_osr_l_05.xml"
- Save the above as import.bat (in the converters directory)
- Run the .bat file preferably from a command-prompt so you can see the output.
- If successful, you should see a new file: assets\environments\asteroids\env_ast_osr_l_05.dae. This file has the DAE extension required for 3DS Max import.
- From within 3D Studio Max, import the file you just created using Autodesk Collada (*.DAE) format. Accept all the defaults, ignore any errors and adjust material path locations so that you can view the asteroid with its textures.
[ external image ]
Step 6 (clone the lights):
Let's take a look at the pieces we are dealing with:
[ external image ]
All those I've marked as 'Helper' are small boxes linked to the various meshes. You can trace this hierarchy by examining the Helper and mesh properties. I may go into this in greater detail in a subsequent tutorial.
For now, let's hide everything but the two anim_poslights_xx meshes (hide the Helper's as well). We are going to trim the lights so they better serve our purpose.
Delete polygons in the area circled in red for the following meshes: anim_poslights_frontXlod0XeffectsXgradient_red and anim_poslights_frontXcollision
[ external image ]
Clone three times and rotate the lights so they form a circle:
[ external image ]
Attach the three clones to the original, Adjust Pivot to 0,0,0, and Rest XForm. This will make sure the lights mesh stays oriented properly with respect to their linked Helper.
Step 6 (drill a hole):
Using the circle of lights as a reference, create a cylinder slightly bigger running through the asteroid. Use a Boolean Operation to cut a hole through the following meshes: part_mainXlod0XasteroidsXast_ore_01 and part_mainXcollision
[ external image ]
Reset Xform for the meshes we've performed Boolean operations on. The resulting view from the front shows the hole and the lights positioned toward the edge of the circle:
[ external image ]
Step 6 (export):
- Export (overwrite) to your assets\environments\asteroids\env_ast_osr_l_05.xml file using Autodesk Collada (*.DAE) format.
- Locate the folder where you installed the XRConverter and create the following file in that directory
Code: Select all
rem This coverts from DAE to XML
XRConvertersMain.exe exportxmf "E:\Steam\steamapps\common\X Rebirth" "E:\Steam\steamapps\common\X Rebirth\assets\environments\asteroids\env_ast_osr_l_05.dae"
- Run the .bat program you just created.
- The result should be new mesh files in folder env_ast_osr_l_05_data and a new env_ast_osr_l_05.xml file.
- Run the game and take a look at your new custom asteroid!
Step 8 (cleanup):
Now that you've created a new model for Rebirth, you probably don't want to leave the files in your game installation. I showed you how to do things this way, because it can be a good method for testing during development. In general, you may want to create mod extensions for things that you want to keep and/or distribute.
For your convenience, I created a mod extension containing the end-result of this tutorial. If you want to use the extension, make sure you remove the various files created in the game folders during this tutorial before running the extension. Another way, is to rename components.pck and macros.pck back to .xml. That way, the game will refer to the files in the extension instead of the ones in the game folders.
Step 9 (next steps):
The asteroid created in this tutorial could serve as a platform for further experiments and learning. Here are some possibilities:
- Create a shield around the asteroid so you could hide in it protected
- Create a landing platform for viewing. Connect a station interior
- Place weapons on the asteroid for defense
- Hide a custom jumpgate inside
- Turn the asteroid into a ship (mobile asteroid)
Next tutorial will explore getting a working custom ship into the game....
Thanks.