Version 4 (modified by Pureon, 12 years ago) ( diff )

--

0 A.D. basic 3D implementation guide


In this guide we will be using Blender to create the 3D model, GIMP for textures, and Notepad++ for basic coding. All three of these programs are free and opensource, although other programs may be used to achieve similar results. You must also have an Alpha release of 0 A.D. installed on your computer. (SVN versions can be used too)

To keep things simple, we are going to create a simple textured crate/box object.


Actor file setup


Lets begin by creating an 'actor' xml file that will link our 3D model with the texture file and crucially make them visible in Atlas (0 A.D.'s Map/Scenario Editor).

  • STEP 1 - Navigate to the 'mods' folder in the game's installation directory: binaries\data\mods
  • STEP 2 - In the mods folder you will have a 'public.zip' file that needs to be extracted into a folder also called 'public' within the 'mods' folder.
  • STEP 3 - Once the public zip is extracted, navigate to the following folder: binaries\data\mods\public\art\actors\props\special\eyecandy
  • STEP 4 - Make a duplicate of the actor file called 'crate_a.xml' and call it 'crate_test.xml'
  • STEP 5 - Open the 'crate_test.xml' file in Notepad ++ (or any code editor). You will see this:
    http://i173.photobucket.com/albums/w73/purepics/0AD/actoropen.gif
    (Ignore the colored highlighted areas in this screenshot, that happens by default in Notepad++)
  • STEP 6 - We need to change the file locations for 'mesh' and 'texture' to these:
    <mesh>props/wrld_crate_test.dae</mesh>
    <texture>props/crate_test.png</texture>

    The code should now look like this:
    http://i173.photobucket.com/albums/w73/purepics/0AD/actorchanged.gif
  • STEP 7 - Save the file (as 'crate_test.xml') and close Notepad ++


Texture creation


Here we will create a basic texture file so that we can skin it onto our model later.

  • STEP 1 - First thing we need to do is find a texture we can use for 0 A.D. Remember our textures are released as CC-BY-SA, so the texture you use must be compatible with this license if you are planning for it to be released officially with the game. One of the websites we use to source textures is burningwell.org which is an online library of public domain images. Searching burningwell.org for the keyword 'wood' I found this texture, which will work well for this quick example.
  • STEP 2 - Download the texture and open it in Gimp.

  • STEP 3 - Most of our texture files are square ( see here for more info ), so first we're going to crop the texture to make it square.

Open the texture file in Gimp by going to File > Open... and then selecting the image downloaded from burningwell.org. Once opened the editing window should look like this:
http://i173.photobucket.com/albums/w73/purepics/0AD/textureopened.gif

  • STEP 4 - Now we are going to resize the texture so that it is 128x128 pixels. To do this, go to Image > Scale Image and change the Height value to 128 pixels. Make sure the Height and Width dimensions are locked (this changes the width value to 171px) like in the image below:

http://i173.photobucket.com/albums/w73/purepics/0AD/texturescale.gif
Select 'Scale' button to perform the scale

  • STEP 5 - We're now going to edit the canvas to make the texture 128x128. Go to Image > Canvas Size... and there change the Width to 128px. The Offset can also be set similar to how I've done it below: http://i173.photobucket.com/albums/w73/purepics/0AD/texturecanvas.gif

Select 'Resize' button to perform the resize to 128x128

  • STEP 6 - Now we're going to save a PNG file called 'crate_test.png'. Go to File > Export... and select the 'PNG image (*.png)' fileformat in the dropdown. Make the Name 'crate_test.png' and then select 'Export' to save the file. Make a note of where you saved the file for the next step.
  • STEP 7 - Move the PNG file to the following location: binaries\data\mods\public\art\textures\skins\props


3D modeling


Here we will go through the basic requirements of creating a textured (UV Mapped) model and exporting it as a Collada DAE format 3D file

  • STEP 1 - Open Blender (the latest version of Blender is always recommended)
  • STEP 2 - We're going to use the cube that appears by default in Blenders 3D View window

http://i173.photobucket.com/albums/w73/purepics/0AD/blenderstart.gif

The first thing we're therefore going to do is change from 'Object Mode' to 'Edit Mode'

http://i173.photobucket.com/albums/w73/purepics/0AD/blendereditmode.gif

  • STEP 3 - Once in edit mode go to Mesh > UV Unwrap... > Unwrap

http://i173.photobucket.com/albums/w73/purepics/0AD/blenderuvunwrap.gif

  • STEP 4 - Surprisingly that's all we need to do in this very simple example. So now we can export the 3D model file by going back into 'Object Mode', selecting the cube, and going to File > Export > COLLADA (.dae)

http://i173.photobucket.com/albums/w73/purepics/0AD/blenderexport.gif

  • STEP 5 - In the export window that opens up, select 'Export only selected'
    http://i173.photobucket.com/albums/w73/purepics/0AD/blenderselectedonly.gif

  • STEP 6 - Change the filename to wrld_crate_test.dae and then click 'Export COLLADA'
    http://i173.photobucket.com/albums/w73/purepics/0AD/blendersave.gif

  • STEP 7 - Move the DAE file to the following location: binaries\data\mods\public\art\meshes\props


Viewing model in Atlas


After saving the actor file, creating the texture, and exporting the 3D model, we can now open 0 A.D.'s Atlas Editor to view the crate in-game

  • STEP 1 - Run 0 A.D. and in the menu select Tools & Options > Scenario Editor
    http://i173.photobucket.com/albums/w73/purepics/0AD/scenarioeditor.gif
  • STEP 2 - Select the 'Object' tab
    http://i173.photobucket.com/albums/w73/purepics/0AD/atlasobject.gif

  • STEP 3 - Select Actors(All) in the dropdown to view actor objects instead of entities (that require additional templating)
    http://i173.photobucket.com/albums/w73/purepics/0AD/atlasactorsallt.gif

  • STEP 4 - In the Filter field type 'crate_test' to find the actor file we created earlier
    http://i173.photobucket.com/albums/w73/purepics/0AD/atlasfilter.gif

  • STEP 5 - Select the actor file in the list, and then click on 'Switch to Actor Viewer' to view the object in 'Actor Viewer'
    http://i173.photobucket.com/albums/w73/purepics/0AD/atlasactorviewer.gif

  • STEP 6 - The finished object should look like this in Actor Viewer:
    http://i173.photobucket.com/albums/w73/purepics/0AD/atlasfinal.gif

Attachments (16)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.