[TUTORIAL] Working with custom 3D models

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

User avatar
Observe
Posts: 2793
Joined: Fri, 30. Dec 05, 18:47
xr

[TUTORIAL] Working with custom 3D models

Post by Observe » Wed, 14. Jan 15, 07:04

Image

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.
Procedure:

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>
Save this in your Rebirth game folder: md/osr_tut_asteroid.xml (create the md folder if it doesn't already exist).
  • Run the game. You should see a Mission Guidance directing you to the asteroid. If this works, you are ready for the next step.
Step 2 (set the stage):
  • 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
Step 3 (assemble the pieces):

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
Copy those files into your active game installation. In some cases you will have to create the directory structure because folders may not exist. Some of these files are needed for the conversion tools to work and others so that you can see the materials in your modeling program.

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
Step 4 (clone that roid):

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
Open those 3 files and likewise change any references for env_ast_ore to env_ast_osr within them.

Change the extension for the following 2 files from .xml to .pck
  • index\components.xml
  • index\macros.xml
Edit file index\components.pck by adding the following entry:

Code: Select all

  <entry name="env_ast_osr_l_05" value="assets\environments\asteroids\env_ast_osr_l_05"/>
Edit file index\macros.pck by adding the following entry:

Code: Select all

  <entry name="env_ast_osr_l_05_macro" value="assets\environments\asteroids\macros\env_ast_osr_l_05_macro"/>
Edit the md file you created (md\osr_tut_asteroid.xml) and change the macro reference so it spawns our custom asteroid.

Change:

Code: Select all

<create_object macro="macro.env_ast_ore_l_05_macro" name="$Asteroid" zone="player.zone">
to (ore to osr):

Code: Select all

<create_object macro="macro.env_ast_osr_l_05_macro" name="$Asteroid" zone="player.zone">
Run the game. The asteroid will look the same as before, but now it is referencing your new asteroid object that you will be working with.

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>
In the above, we have included a connection for the lights we will be adding and we've deleted all but the highest Level Of Detail (LOD) to make things simpler to understand.

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"
Note: Change the drive letter and/or path to match your Steam location.
  • 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.
This is what you should see:

Image

Step 6 (clone the lights):

Let's take a look at the pieces we are dealing with:

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

Image

Clone three times and rotate the lights so they form a circle:

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

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:

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"
Note: Change the drive letter and/or path to match your Steam location. Save the file as export.bat (in the converters directory)
  • 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.
Step 7 (verify in-game):
  • Run the game and take a look at your new custom asteroid!
Image

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)
That's it for now. Please let me know if I have made any serious omissions, mistakes, or if you know of better ways to do things than how I have described.

Next tutorial will explore getting a working custom ship into the game....

Thanks.
Last edited by Observe on Sat, 17. Jan 15, 21:06, edited 13 times in total.

User avatar
Observe
Posts: 2793
Joined: Fri, 30. Dec 05, 18:47
xr

Post by Observe » Wed, 14. Jan 15, 07:45

[Placeholder]

lubatomy
Posts: 214
Joined: Mon, 29. Dec 03, 16:22
x4

Post by lubatomy » Wed, 14. Jan 15, 15:23

since it was asked i put them here, here are the questions i have for now:

1 - I am using 3ds max 2015 which i assume is similar to what you are using. How do I go about fixing the materials to be looking at the correct ones for a model?

2 - I installed that plug in you suggested but it has the name "ColladaMax" something. the name you listed "Autodesk Collada (dae)" is the original FBX importer that was installed with 3ds Max. Can you port a screen shot that shows the import and export options?

3 - I know your next tutorial is working with a custom ship, is that a completely new model to the game or just changing an existing model? I am trying to work with a completely new model (got it from killerog's test at getting the battlestar galactica in game).

User avatar
Observe
Posts: 2793
Joined: Fri, 30. Dec 05, 18:47
xr

Post by Observe » Wed, 14. Jan 15, 15:42

lubatomy wrote:1 - I am using 3ds max 2015 which i assume is similar to what you are using. How do I go about fixing the materials to be looking at the correct ones for a model?
Materials are specified in several places. In the case of this tutorial, you will see material references in file env_ast_osr_l_05.xml.

Code: Select all

<lod index="0">
         <materials>
		<material id="1" ref="asteroids.ast_ore_01" />
	</materials>
</lod>
However, the game doesn't actually use that information. Instead, it gets it from the .xmf mesh files themselves - which you can't easily read because they are in binary. Knowing the material is asteroids.ast_ore_01, you will find reference to that in libraries\material_library.xml. From there, you can see the associated image paths.
lubatomy wrote:2 - I installed that plug in you suggested but it has the name "ColladaMax" something. the name you listed "Autodesk Collada (dae)" is the original FBX importer that was installed with 3ds Max. Can you port a screen shot that shows the import and export options?
I'll post a screenshot later today if I have time.
lubatomy wrote:3 - I know your next tutorial is working with a custom ship, is that a completely new model to the game or just changing an existing model? I am trying to work with a completely new model (got it from killerog's test at getting the battlestar galactica in game).
Many of the principles are the same. Since this was an introductory tutorial, I kept things as simple as possible so people could make sure their setup is working.

The main difference in creating a new model from scratch, is making sure you have everything properly linked to parent objects and that your materials are referenced correctly. I strongly suggest starting as simple as possible and then working up to more complex projects.

Too often I have seen people dive into major projects before they have sorted out fundamental details. The result, is people can get lost, frustrated, and then give up. My next tutorial (no time estimate) will build on this one in a more advanced fashion.

Thanks

lubatomy
Posts: 214
Joined: Mon, 29. Dec 03, 16:22
x4

Post by lubatomy » Wed, 14. Jan 15, 15:48

Observe wrote:
lubatomy wrote:3 - I know your next tutorial is working with a custom ship, is that a completely new model to the game or just changing an existing model? I am trying to work with a completely new model (got it from killerog's test at getting the battlestar galactica in game).
Many of the principles are the same. Since this was an introductory tutorial, I kept things as simple as possible so people could make sure their setup is working.

The main difference in creating a new model from scratch, is making sure you have everything properly linked to parent objects and that your materials are referenced correctly. I strongly suggest starting as simple as possible and then working up to more complex projects.

Too often I have seen people dive into major projects before they have sorted out fundamental details. The result, is people can get lost, frustrated, and then give up. My next tutorial (no time estimate) will build on this one in a more advanced fashion.

Thanks
in this case i am lucky that killerog did most of the hard work. I have had the ship appear in game after some minor changes as it appears in game and textured and all that but it was pointing in the wrong direction. The bottom of the actual model was considered forward in game while the front of the actual model was considered the top in game.

Of course going back to the original data from killerog, the main body of the ship mo longer renders anymore but i know what i did that got it to render in the first place and can repeat those steps.

User avatar
Observe
Posts: 2793
Joined: Fri, 30. Dec 05, 18:47
xr

Post by Observe » Wed, 14. Jan 15, 16:02

lubatomy wrote:I have had the ship appear in game after some minor changes as it appears in game and textured and all that but it was pointing in the wrong direction. The bottom of the actual model was considered forward in game while the front of the actual model was considered the top in game.
It's easy to rotate objects. The main thing is to make sure that you reset the Pivot Points after rotation. If you don't do that, your model will always point in the wrong direction. Likewise, getting a Galactica model into the game is easy if all you want is a floating barge. Making Galactica a functional ship is fairly complex and something you may want to work up to with smaller projects. :wink:

lubatomy
Posts: 214
Joined: Mon, 29. Dec 03, 16:22
x4

Post by lubatomy » Wed, 14. Jan 15, 16:10

Observe wrote:
lubatomy wrote:I have had the ship appear in game after some minor changes as it appears in game and textured and all that but it was pointing in the wrong direction. The bottom of the actual model was considered forward in game while the front of the actual model was considered the top in game.
It's easy to rotate objects. The main thing is to make sure that you reset the Pivot Points after rotation. If you don't do that, your model will always point in the wrong direction. Likewise, getting a Galactica model into the game is easy if all you want is a floating barge. Making Galactica a functional ship is fairly complex and something you may want to work up to with smaller projects. :wink:
i actually think the other parts are the eay parts and getting the model in is the hard part. I already have it as a buildable ship. it has fuel storage. I have not gone and placed turrets or shields or jump drive yet but those wont be too hard once i am ready work on them. I learned most of that stuff when i played around with some of the XL transport ship models that egosoft had in the files but not used. obviously the hardest parts will be the mass traffic nav points but that will be the last thing i think about doing as the ship can be functional without that i believe.

lubatomy
Posts: 214
Joined: Mon, 29. Dec 03, 16:22
x4

Post by lubatomy » Wed, 14. Jan 15, 19:49

ok thanks to the hint above about making sure the pivot point was correct, I figured out how to get the model pointing the right direction in game.

next steps are:

1 - get the engines done as their own model in game and ready to use.

2 - start placing things like a player dock point, jump drive, shields, turrets, etc.

Ship being built in DeVries

Build finshed and ship moving out or build dock

antoniut
Posts: 197
Joined: Sat, 4. Oct 14, 13:07
xr

Post by antoniut » Wed, 14. Jan 15, 20:26

Congrats lubatomy! You got help finally and u are advancing :) It seems working with yisha's body is a good keep secret :D

User avatar
Observe
Posts: 2793
Joined: Fri, 30. Dec 05, 18:47
xr

Post by Observe » Fri, 16. Jan 15, 23:50

lubatomy wrote:I already have it as a buildable ship. it has fuel storage. I have not gone and placed turrets or shields or jump drive yet but those wont be too hard once i am ready work on them. I learned most of that stuff when i played around with some of the XL transport ship models that egosoft had in the files but not used. obviously the hardest parts will be the mass traffic nav points but that will be the last thing i think about doing as the ship can be functional without that i believe.
Sounds like you are well on your way! Make sure you let us know as you progress. :)

lubatomy
Posts: 214
Joined: Mon, 29. Dec 03, 16:22
x4

Post by lubatomy » Sat, 17. Jan 15, 03:23

yeap i will...

This weekend i am going to try and get the engines done the way they should be as well as start working on the surface elements like shields and turrets and dock point. Just a matter of finding good places for them.

User avatar
Earth Ultimatum IV.
Posts: 5136
Joined: Mon, 3. May 10, 14:39
x4

Post by Earth Ultimatum IV. » Sat, 17. Jan 15, 13:46

Now we just need someone who would change Skunk's model to a Katana, and create a cockpit and backroom interior that would fit.
Or the Normandy from ME series.

Or maybe a freighter.

lubatomy
Posts: 214
Joined: Mon, 29. Dec 03, 16:22
x4

Post by lubatomy » Sat, 17. Jan 15, 15:54

Well I have run into another snag.

In order to make the engines correctly, I wanted to import an existing engine to see how they linked everything and all that and the xac/xmf converter crashes out every time i try to import and engine (go from .xml with data directory to .dae so i can look at it in modeling software).

there is a lot more going on with the engines themselves like animations, specific glow effects, the exhaust connections. If i want to have an engine that looks unique then I need be able to try and replicate most of that. Unfortuately that has to be put on hold unless someone else can import one of the engine system props.

they are located at:

Code: Select all

..\assets\props\EngineSystems\

antoniut
Posts: 197
Joined: Sat, 4. Oct 14, 13:07
xr

Post by antoniut » Wed, 21. Jan 15, 22:25

The xmf dae converter is for 3ds max only?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13907
Joined: Sun, 20. Nov 05, 23:45
x4

Post by UniTrader » Wed, 21. Jan 15, 22:37

it should be for any programm which can handle dae/collada, so it should be many Moddeling programs because this File Format is open ;) (and is btw also based on xml :D)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Post Reply

Return to “X Rebirth - Scripts and Modding”