Attachment Maker Tutorial.pdf

(491 KB) Pobierz
Tools for Asset Repair by PEV Image by Alberte Zato
AttachmentMaker a new tool from PEV
A way to quickly and accurately add attachments to any asset.
Introduction.
should identify with this layout.
I think I have created a really simple tool that will make
adding attachments a snap. Users will need to be able to
read an engineering drawing, and be able to visualise a
3d object from the three basic views. Other than that
virtually no drafting skills are needed.
Some Trainz users wish to add attachment points to
existing assets for their own use or, with permission of the
original creator, make some additions to his asset for
sharing with others.
A well proven way to add attachments involves making a
another mesh in GMax/3dsMax or Blender with what ever
attachments are needed along with an invisible object to
allow the mesh to export out of the modelling program.
This method is a bit hit or miss because there is no way to
get the original model into the modelling program so that
the attachments can be positioned relative to the shape of
the parent object.
Using Attachment Maker.
Installation.
The program is available for free download from my
PEVSoft Download page.
Attachments are easily added to meshes directly, but
again no visual reference is provided to know where to
place the attachments. And of course Auran's policy of
not allowing users to mess with their meshes also needs
to be adhered to. Auran's TrainzMeshImporter is
specifically written to allow meshes from a variety of
sources to be safely imported into the game, and in this
case it provides the necessary conversion between the
attachment data and an IM mesh for Trainz.
http://www.members.optusnet.com.au/~villaump/pevsoft.htm
Run the installer and the program will be loaded on to the
Program Files area of your C: drive, along with a desktop
icon and an entry in the PEVSoft folder of your All
Programs menu.
Auran's TrainzMeshImporter.exe is included in the setup
program. It may require a further download from MicroSoft
(See below)
GMax and other modelling programs provide neat multiple
views of an object in wire frame mode that allow
attachments to be positioned within a model. It seemed
logical that if we could directly make a multi view display
of a mesh we could add attachments quickly and
accurately.
Note that the beta and first release versions of this
program have some errors in the attachment rotation
mathematics that have now been resolved.
So I set to work to make a program that gives front, side,
and top views in wire frame mode, with all views
zoomable and moveable.
The resulting Attachment Maker program provides views
that are linked so that the relationship between them
always maintains third angle projection; meaning the
details are always aligned view to view. You will
understand the significance of this once you start to use
the program.
The views are the standard third angle projection, with the
plan (top) view being above the front view, and the side
view to the right. Those of you with drafting experience
© Peter Villaume (PEV) 2010 1
893872398.007.png
Opening a File
The purpose of this program is to add attachments to an
existing asset. Say for example you want to add safety
valve and whistle attachments to a small steam loco for
visual steam outlets.
Firstly use Content manager to open the loco asset for
editing and find the main body mesh. Then launch
Attachment Maker and open the body mesh using the File
Open menu.
Left Click in any view and the attachment tripod will follow
the cursor when you drag it. Positioning as you can see
takes moments.
Note the loco body is in three views. Top left is plan (top)
view, lower left is front view, and lower right is the side
view.
Use the mouse wheel to zoom in or out. Note that all
views zoom at the same rate (on purpose) Zooming is
also possible by using the cursor Up/Down keys with the
shift key. The mouse cursor must be on the drawing for
the key zoom or pan.
Press on the mouse wheel and drag the mouse to move a
view to look closely at some portion. Note that the views
move together to maintain a view of a particular point in
the drawing.(again on purpose.. quick and simple is the
objective here) Panning can also be done by selecting a
view (with the mouse or touch pad) and pressing the
cursor keys with the Ctrl key.
Window size can be changed by dragging the edges of
the window.
In the case of our steam loco example, move the
attachment to the top of the whistle, and rotate as
necessary to have the Y axis of the tripod pointing in the
direction of steam flow. In this case rotating about the X
axis will make the Y axis of the attachment tripod point
upwards.
Adding an Attachment Point
To add an attachment point ensure you have an axis
origin visible in at least one view. The origin is where the
dark yellow axis lines cross.
Press the "Add Attach" button in the panel on the upper
right side of the window. A yellow attachment tripod will
appear at the origin, (in all views).
To rotate the attachment you can use the up/down
buttons next to the rotation axis box, or enter a number in
the box.
© Peter Villaume (PEV) 2010 2
893872398.008.png 893872398.009.png 893872398.010.png
In the "Selected Attachment" panel with the "Add Attach"
button, there are edit boxes to change the attachment
name, its position, and its rotation.
To edit an attachment, you can select by Right Clicking on
the Selected Attachment panel. A list of attachments will
be presented and you can chose one by name.
When you press the "Add Attach" button the the new
attachment is always called "a.New". In our example,
change the name to "a.whistle" in the name box on the
Selected Attachment panel.
When you are happy that you have the attachment
correctly located and named, Right Click on the drawing
and the attachment will be locked, and deselected. It
changes colour from yellow to green when deselected as
in GMax.
Click on an attachment and press the "Accept" button to
select. "Cancel" turns off the selection window.
Remember that the selected attachment is yellow on the
drawing.
Repeat the process above to add more attachments. (The
safety valve attachments in our example)
© Peter Villaume (PEV) 2010 3
893872398.001.png 893872398.002.png 893872398.003.png 893872398.004.png
You can also change selection with the up/down buttons
next to the name box. (Please note at this stage in
program development I don't have attachment selection
by mouse click working)
Select the "attach_mesh.im" and the attachments will be
reloaded and displayed on the drawing.
Additions, deletions, and edits are easily done once the
appropriate attachments are selected.
A selected attachment can be deleted by pressing the
"Delete" button.
Making the Attachment Mesh
Putting the Attachment Mesh into Trainz
When you have placed your new attachments the results
are saved in the form of a mesh named "attach_mesh.im".
The name can be changed, if you so desire, in the Save
file dialogue.
To make the attachments work in Trainz an attachments
mesh reference must be added to the mesh table in the
config.txt file for the asset. The following example adds
attachments to a single mesh object.(mesh table only
shown here)
To save the mesh click on the "Save Att Mesh" item in the
"File" menu.
mesh-table {
default {
mesh "steam_loco.im"
auto-create1
}
attachments {
mesh "attach_mesh.im"
auto-create1
}
}
Because the two meshes share the same origin, (the
second having been built around the first) no other data is
needed.
The above assumes that "steam_loco.im" and the
"attach_mesh.im" file are in the same folder as the
config.txt file. (the asset root folder). The program help
shows an example where the meshes are in a sub-folder
of the asset. See the Content Creators' Guide for your
Trainz version for advice on asset folder layout.
The attachments should now behave as if they are part of
the default mesh.
Your new attachment data is converted to a mesh by
TrainzMeshImporter. The mesh has a single plane
surface 20mm square invisible from above, but visible
from below.(just to test its validity) The mesh requires no
textures.
Please be aware that the program overwrites any existing
"attach_mesh.im" file when saving the data.
If you have added passenger, load, or smoke attachments
and so on further additions will be needed to the config.txt
file. Again, refer to your Content Creator's Guide.
Editing an Attachment Mesh
TrainzMeshImporter
If you are unhappy with your attachment mesh or wish to
add more attachments, you can edit the mesh by first
loading the parent mesh using the "File" "Open" menu as
above. Then click on the "Open Att Mesh" item in the
"File" menu.
As part of the attachment mesh generation process,
Attachment Maker creates a file in XML format which is
then converted to an IM by Auran's TrainzMeshImporter
program. Auran's policy of having their own software
make all game content is thus maintained.
The Attachment Maker program will not operate if the
TrainzMeshImporter.exe is not in the Attachment Maker
application folder. A notice to this effect is displayed for a
few seconds before the program closes.
TrainzMeshImporter is included in the Attachment Maker
installation package and is latest version as of 17 April
2010.
TrainzMeshImporter requires some Microsoft C++ 2005
SP1 runtime files, and if these are not present the TMI will
not run, or may freeze. The Attachment Maker will fail to
produce an output mesh in this instance.
© Peter Villaume (PEV) 2010 4
893872398.005.png 893872398.006.png
attach_mesh.im and there is an attachment rotation where
the Y axis rotation is + or - 90deg. The mathematics to
convert a rotation matrix to axis angles has a divide by
zero occurrence under these conditions. The program will
zero the X axis angle and make the Y axis 90deg,
hopefully leaving any Z axis rotation as it stands.
The files can be downloaded as a package from
http://www.microsoft.com/downloads/details.aspx?
familyid=200B2FD9-AE1A-4A14-984D-
389C36F85647&displaylang=en
To test that TrainzMeshImporter is working open a DOS
window in the Attachment Maker application folder.
The problem is called "Gimball Lock" because the same
mathematics is used in gyro guidance systems and gyros
are mounted on gimballs. (the rings with bearings that
allow x,y,z rotation of one object relative to another.)
To open a DOS window, create a file named
"DOSWin.bat" in the Attachment Maker application folder.
The file should contain the following two lines:-
It's best to avoid Y=90deg or Y=-90deg. However it will
still work, the conversion from angles to matrix works fine.
It's the reloading of such data back into this program that
will give the message. Fortunately rotation around the Y
axis is rare in Trainz because the Y axis is used as a
direction pointer, so rotations about the X and Z axes are
used to have the Y axis pointing in the desired direction.
See the CCGTC for advice on orienting smoke
attachments as an example of this.
@echo off
cmd.exe /k
When you run this batch macro a DOS window will be
opened. Type "trainzmeshimporter.exe" in the window.
The TMI will display its help page if all is working
correctly.
FootNotes:
2. The Attachment Maker program, can handle 256
attachments in one mesh. This is the same limit as the
Trainz game itself imposes.
1. In the program help there is a reference to an error
message "Gimball Lock. Cannot resolve angles."
This message will only occur if reloading an
© Peter Villaume (PEV) 2010 5
Zgłoś jeśli naruszono regulamin