Close This Window





This tutorial describes how to use Till 'rollin' Maginot's
3dz-txt importer/exporter for 3ds Max (maxscript).

The script can import and export txt files which can be
converted from and to 3dz files by Alessandro Borges
3dz-txt-converter 1.8.

3dz files are the main 3d geo files for European Air War (EAW),
a flight simulator created by Microprose.






1. Setup
2. Learning By Importing
3. Prepare For Export
4. Export

Appendix:
a) Bulkhead Elements
b) RS-Loops
c) The Geo Problem

Usefull Links






1 SETUP

First you need to know some basics on how to work with this tool:

a) how do I start the script?
b) how do I see the output console (called “Listener Window”)?

  • To start the tool simply drag'n drop the mgto_EAWtxtImportExport.ms file into the 3ds Max viewport.
    OR:
    In 3ds Max go to the "Utilitys" Tab (normally on the right side, small hammer symbol)
    Select "MAXScript" -> "Run Script" -> select the *.ms file.

  • You'll need the maxscript Listener Window to see all the script outputs, otherwise you maybe won't really know what's wrong if something does not work. To open the Listener Window click with the right mouse button on the white field in the lower left corner and click on "Open Listener Window"




2 LEARNING BY IMPORTING

At the first glance: For the beginning, a good way to understand the tool is to import an original model from EAW.

  • So start 3ds Max, start the script and open the listener window (if you haven't already).

  • Now click on "get url" and choose the model you want to import.
    I'll choose the ptempf.txt.
    NOTE: To get the txt file you have to convert the *.3dz with Alessandro Borges 3dz converter (1.8).

  • If you want the script to remove unused Vertices (Nodes) then check the "remove unused nodes" box. You can do this still afterwards, so if you're unsure keep it unchecked.

  • Now press "Import".

  • With some luck there will no error message pup up.
    That's because the script is just work-in-progress and I haven't tested it with
    every 3dz file yet. If you find a problem please be so kind an drop me a line on till.maginot.eu.
    NOTE: The script does not import lines or any piggyback elements yet!

  • If you now take a look at the Listener Window you see what happened during the import. If you importa default EAW model in most cases there will be a warning like "element xyz was not created as faces".
    This is because the way the geo works in EAW is not always compatible with 3ds Max.
    But we're not going to use the model anyway, we'll create our own.
    NOTE: You can find more info about the differences in 3d-data in the “The Geo Problem” Section.

Ok there's the model of the plane, but that's
not all:

The smaller green boxes are representing the [INSERT] Components.
In my case there is the plane itself (rootBone), left and right gear and the propeller.

The Stars, or in fact Point Objects, are representing the Hardpoints. The Z-axis is showing the normal vector while X- and Y-axis are building up the imaginary 3d-plane.



At the second glance : Now lets take a closer look at the imported stuff

[INSERT] Components

The green boxes are representing the [INSERT] part of the 3dz file.
They are like bones: You can assign Vertices(Nodes) to them and the game can
rotate these vertices around the centre of the Dummy (e.g. for the propeller to rotate).

To see what's going on first select the model. On the right side you should already see the Modifier Panel (otherwise click on the "Modify"-Icon).
You see the Line "Editable Mesh" and above "Skin".
The Skin-Modifier should already be selectedand below there is the Bone List with the Components-Dummy-Names listed.
If you expand the Skin-Modifier (click on the small “+” on the left side of "Skin") and click on "Envelope" you can see which vertices are assigned to which dummy. If you select another dummy in the Bone List you see the vertices assigned to this bone turn red in the viewport.

It's important that the first dummy in the list is always the "rootBone" and all other dummys follow in the order of their insertID's (0 first , then 1, 2, 3, ...) .
Remember this!

Very important is the naming of these dummys:
Insert_cod={codID}_num={numID}_{insertID}
If you have this line in the [INSERT] section of the 3dz:
;I000=_cod _num _y _z _x
I001= 2 2 -56 -19 -58

the dummy has to be named :
Insert_cod=2_num=2_1




Hardpoints

Hardpoints are represented by Point Objects in 3ds Max.
Like for thecomponent dummys the naming is veryimportant:
Hardpoint_index={hardpointCode}_{cutOrder}
The cutOrder number specifies in which order the script tries to use the hardpoints as cut poly. If all hardpoints can cut through the complete model the first cut will be made by the hardpoint with the number _01. If not, the hardpoint with the lowest cutOrder Number will be used.
NOTE: You have to number your hardpoints without any gabs.. so _01, _02, _04, _05 is not permitted

Again: the Z-axis is the normal vector of your hardpoint and X and Y are building up the 3d-plane


Textures

The model you've imported has already a Standard Material applied to it. To make things easier for exporting you can set the texture name (the one ending up in the [HEADER] section of the 3dz, the one the game will use to select the texture) independently from the texture file you use in 3ds Max while working on the model.
Simply name the “Diffuse Map” panel of the “Material Manager” like you want the texture to be named with the ending “.PCX”.






3 PEPARE FOR EXPORT

A) Set Element Types.
B) Set Action Codes.
C) Place and name Hardpoints.
D) Place and name INSERT-Dummys.
E) Add Bulkhead Elements.
F) Check for non coplanar polys.
G) Check Rendering Sequence.

  • A) You can define for each poly what kind of Element Type it should be, with Max's “Smoothing Group” value.
    Note: you can also create Hardpoints with it which are piggybacked to the poly you've created. The hardpoint will use the first Vertex (Node) of this Poly as centre point.
    2: Hardpoint piggybacked to single coloured poly.
    3: single coloured poly.
    4: multicoloured poly.
    5: textured poly.
    6: textured poly with alpha.
    15: bulkhead element.


  • B) You can add Action Codes to every Poly by the “Material ID” value. Combine the action code and the bool-value to a four digit number and assign it as material id to the poly
    e.g. “148 0” will be “1480”.
    Visit the EAW wiki for a complete list of action codes.

  • C) I assume you've already build your own model, unwrapped and textured it. Now place all Hardpoints you don't want to add per piggyback later on. Use the imported Point Objects or create new ones, important is only that you name them correctly.
    You can place them where ever you want, but they act like any other poly. The only difference is, that it's a poly where every vertex is on the same place. But the hardpoint can cut through the model like any other poly and there must be a working RS solution involving all hardpoints.

  • D) Create (INSERT) Dummys (or reuse the imported ones) and place them.
    You need at least one: the “rootBone” which is positioned at the centre of the 3d room (X=Y=Z=0).
    Remeber: the naming is strict!
    So NO “root-bone” or “rootbone” or “RootBone” orwhatever. If you're not sure take a look at the imported ones.
    You can rotate them but this will not help you because only their position will be exported.

  • E) At this point you have to prepare your model for export.
    This means: add Bulkhead Elements if necessary and if you haven't already done so and make sure they can cut through the whole model along the edges.
    There is one exception: The cut order of my script is the following
    1 - hardpoints (sorted by the cutOrder number).
    2 - polys with same normal value like main cut plane (if there are several of them check them like 3).
    3 - the poly with themosteven placement of polys above and below.
    So if you know the order of the cuts you can set the bulkheads accordingly.

  • F) Now we want to know if all polys are Coplanar, because that's important for the RS calculation.
    First select your model (not a modifier!) and go into the face or polygon editing mode. Then press the "select concave polys" button. The script will automatically select all non coplanar polys for you and now you just have to find a way to make them coplanar.
    In the moment you get the message that all polys are coplanar, you're ready to proceed.

  • G) To check the Rendering Sequence, simply select your model (and all hardpoints if you want to include them in the calculation), select a main cut plane (or keep “none”) and press the "check selection" button.
    The calculation can take some time depending on the complexity of the model. It can take up to 2 minutes and 3ds Max might stop responding after a few seconds. That's normal, just be patient. When the calculation stops you get an output in the “Listener Window”. If the script detects an RS-loop it will select all polys which are part of the loop. The script will only select one loop. If you have several loops, you have to fix one then check again, fix the next, check again, until you get a working RS.
    NOTE: You can find more infos about this in the RS-Loops section.

    NOTE: The main cut plane defines the preferred 3d-plane where the the script tries to cut through the model. Every poly using the same normal vector as the main cutplane will be preferable used as cut-plane in the RS calculation.
    If you have a (nearly) symmetrical model the mirror plane is the best choice because it will cut the model immediately into two similar halves.
    If you get an RS-Loop, choosing another main cut plane can solve the problem in some cases.



4 EXPORT


A) Add skin modifier
B) Set [HEADER] values
C) Export Options
D) Save Scene


  • A) Add the Skin-Modifier to your model and apply the Bones to it (make sure you add them in the right order: rootBone, .._0, .._1, .._2, .... Compare it with an imported model if you're unsure).
    Under the Skin-Modifier go to “Advanced Parameters” and set “Bone Affect Limit” to 1.
    Now assign the vertices to the corresponding dummys (Components).
    The rootBone represents_f = 0, Insert..._0 represents _f = 1, Insert..._1 represents _f= 2 and so on..





  • B) To set the [HEADER] values before exporting the model, expand the header rollout of the import/export script.

    • INI: Select the model of the plane and press the “calculate radius from mesh” button. To be on the save side add a small value to the INI value (e.g. +10) by hand.

    • TEXTURE: Press the “get texture from selection” button to read the material name of the selected object.

    • PREVIEW: You can set a preview image here. You can get the file name from any file on your hard disk by using the “get name from file” button.


  • C) You have the following options when you want to export a model:

    • “irreversible remove Bulkheads”: if
      this option isselected the exporterwill replace all Elements marked as bulkheads (smoothing group 15) with an empty element (e.g. E001 = 255)

    • “Normals Mode”: here you can choose if you want to export the normals as _d and _c values or as _D value. (you need to export as _d and _c values if you want to compile the *.txt back to a *.3dz).
      NOTE: If you want to polish the normals of your model a bit more, you can recalculate them with Will's 3dzAnalyzer. His _d values seems to be a bit better then mine. But that's no must-do.

    • “Render Sequence”: If you're sure the model allows a working RS you can calculate it on export.You should select the same “maincut plane” you've used to test the RS before


  • D) The export script will try to save your 3ds Max scene before the real export process starts. This is necessary because the exporter will change the scene and the stuff in there. After the export process the script will reload this saved scene again and you have the same conditions like before hitting the export button.
    But remember: if you don't save over your working file (e.g. when you use the on export saved scene only as backup) you have to reload YOUR working scene after exporting manually.



APPENDIX

a) Bulkhead Elements

Creating models for EAW is not like creating models for most other (modern) games around. In the days EAW was developed 3d video cards where rare. So EAW calculates the sorting of all polygons itself instead of giving this task to the video card. To speed this task (called "Render Sorting") up the developers precalculated the "Rendering Sequence" for every object and saved it in the 3dz file. The technique used is called Binary Space Partitioning (BSP). This is the [SEQUENCE] part in the 3dz.

But that's it for the moment with theory. The question is: what does this mean for you as modeler? In fact, a lot! You have to plan your model to be BSP-conform. And a simple way of making it BSP-conform is to use Bulkhead Elements. These elements (polys) should cut the mesh into smaller peaces and are normally not part of the model you planed to build because they are inside the model, they just eat up your poly limit. But it's hardly possible to build complex models without bulkhead elements.

When you're finished with your model, you can remove these elements/polys from the model on export by the script. This will keep the bulkheads in the Rendering Sequence but remove them as actual visual geometry. But remeber: they still need one of the 254 slots in the [ELEMENT] section of the 3dz, what represents your polylimit per 3dz file. So try to use only there bulkheads where it's really necessary.



b) RS-LOOPS

Loops in the rendering sequence are the main reason for all RS-problems. An RS-Loop occurs when for a given set of polys P it's impossible to find at least one poly which can separate all other polys of P into “above”,“below” and “same-plane”. This means for every poly within P there is at least one poly“in-between”. “in-between” means vertices of this poly are above AND below compared to the cut-poly.



c) The Geo Problem

There is a main difference between the way you can build 3d-models in 3ds Max and the kind of geometry EAW allows:
It's no problem for EAW to render a number n of the exact same poly. But because this is called “bad geometry” in todays 3d production, 3ds Max can not fullyhandle such geo. In fact only an Editable_Mesh allows basic usage of this kind of geo. So if you want to build bulkhead elements inside of your model you need an Editable_Mesh object. You wont have much luck with an Editable_Poly.

That's why this script needs your model as an Editable_Mesh if you want to make it export ready. Building the model as Editable_Poly in the first place is no problem though.
The whole geo problem is also the reason why you can't always import the original EAW models. The script will make changes to the geo when parts of the model in question will not work in 3ds Max. You normally end up with more Elements then the model had before.
But this only an import restriction. If your model does work in 3ds Max you will be able to export it.





Usefull Links


txt- 3dz converter
(Download from Wills Gunship page)

Sim HQ - main EAW editing Community

EAW wiki

3dz studio (Win) & Render Sequence Calculator

Understanding the Render Sequence

Will's Gunship Tools




Close This Window


Copyright 2009 Till Maginot. All rights reserved