creating a monster for ut2k4

Vertex Mesh Importing via UnrealScript


This page displays a list of the import commands for vertex meshes in UT2004. Most obsolete parameters have been left out. The order in which these commands are given is important but straightforward.I have presented them here in a correct order. It's important to remember that almost any errors made in the import code will be silently ignored by the compiler and the package will usually always compile. The compiler should log a warning if any none optional parameters are missing, although it usually wont tell you what is missing. But it will still compile. The warnings may look like this.
	ExecWarning: C:\UT2004\MyPackage\Classes\MyModel.uc(3) : ExecWarning, Bad MESH IMPORT
	ExecWarning: C:\UT2004\MyPackage\Classes\MyModel.uc(4) : ExecWarning, Bad MESH LODPARAMS
	ExecWarning: C:\UT2004\MyPackage\Classes\MyModel.uc(5) : ExecWarning, Bad MESH ORIGIN
	
To import the _d.3d (vertex mesh file) and _a.3d (vertex animation file) files they must be placed in a folder located inside your new package folder. This folder can be named anything, the most common name is "Models" in order to keep the file structure neat and consistant. You will need a .uc file contained within the "Classes" folder to contain the import code. You can extend any actor or object of your choice, and the name is not important either. This file is basically just a placeholder for the import code. Remember that in order to view the model in the mesh browser you might need to first load your package in the actor browser.

Example C:\UT2004\MyPackage\Models
	class MyModelImport extends Actor;

	//code goes here
	


You can download a .uc file I made that contains examples of all of the code featured on this page here Vertex Import Code. Although almost all the parameters are optional, I have put "No" if leaving the parameter out would create a broken or worthless command. The first step is to import the files and set some parameters that go with it.

#Exec MESH IMPORT Parameters:

MESH This specifies the name of the mesh. Optional: No
ANIVFILE This specifies the path to the animation file for import (_a.3d). Optional: No
DATAFILE This specifies the path to the mesh file for import (_d.3d). Optional: No
LODSTYLE A bit field with switches that changes the style of building for the level of detail collapse sequences.

1: Value curvature over length.
2: Protect the edges of doublesided polygons - like the CTF flags.
4: Try to respect texture seams more. Use this if there is too much 'stretching' going on.
8: Value length over curvature. Needed for unwelded, multi-element, or otherwise 'open' meshes like the new superhealth.
16: Translucent polygons will be collapsed less early in the LOD sequence. (Broken in the 224 code base.)
Optional: Yes
LODFRAME With this you can pick a frame, other than the default 0th frame to be sampled for generating the collapse sequence. Optional: Yes
LODNOTEX A boolean value. If set, causes texture coordinates to be ignored when importing. This improves performace. It's good for models that will only ever have 1 flat texture (constant colour such as red or blue). It's also good for those models that might only ever be seen in the far distance behind clouds or fog. Optional: Yes
LODOLD A boolean value. Maintain the original order of animation vertices as they are imported. If active, this means some internal reorganization will be done at load time, instead of compile time. Included to make differential patching of older content feasible. Optional: Yes
DOSMOOTH A boolean value. If 1 then the LOD level changes appear smoother. 0 results in more visible popping but increase in performance. Optional: Yes
REORDER Appears to be obsolete. Optional: Yes
	//Examples of minimum requirements and including optional settings

	#Exec MESH IMPORT MESH=MyMesh ANIVFILE=Models\MyMeshAnims_a.3d DATAFILE=Models\MyMesh_d.3d

	#Exec MESH IMPORT MESH=MyMesh ANIVFILE=Models\MyMeshAnims_a.3d DATAFILE=Models\MyMesh_d.3d LODSTYLE=8 LODFRAME=0 LODNOTEX=0 LODOLD=0 DOSMOOTH=1
	

The next step is to set any additional LOD settings that may be desired (optional).

#Exec MESH LODPARAMS parameters:

MESH This specifies the name of the mesh that we are setting LOD parameters for. Optional: No
STRENGTH LOD scaler. The default is 1.0. Tweak this setting higher for more aggressive LOD-culling, lower it if you see the mesh distort too early. Optional: Yes
MINVERTS The minimum number of vertices you want your mesh to always retain at the farthest distances. Maximum appears to be 887. Optional: Yes
MORPH Set it to 0.0 for no morphing, any other value up to 1.0 indicates the proportion of vertices that are allowed to contribute to the smooth morphing. More means less popping, but at the cost of more CPU time. Useful values are 0.25 - 0.4, the default is currently 0.3. Optional: Yes
ZDISP This specifies (in Unreal units) the distance at which the LOD culling kicks in. Optional: Yes
HYSTERESIS This value gives a range within which the level of detail will be 'sticky' and not change. Any reasonably small value ( like 0.01 ) will help eliminate potential flicker that would otherwise occur when a mesh happens to sit at the exact boundary of two LODs, distance-wise. Optional: Yes
	//Example including optional settings

	#Exec MESH LODPARAMS MESH=MyMesh STRENGTH=1 MINVERTS=10 MORPH=1 ZDISP=500 HYSTERESIS=0.2
	

Now it's time to set the origin and rotation of the mesh (optional). These are useful if errors were made in the 3d package that was used to create the model.

#Exec MESH ORIGIN parameters:

MESH This specifies the name of the mesh that we are setting the parameters for. Optional: No
X, Y, Z Here you can set the origin of the mesh. Optional: Yes
YAW,PITCH, ROLL Here you can set the rotation of the mesh. The rotation unit is a byte.

255 = 360 degrees (65536)
192 = 270 degrees (49152)
128 = 180 degrees (32768)
64 = 90 degrees (16384)
Optional: Yes
	//Example including optional settings

	#Exec MESH ORIGIN MESH=MyMesh X=10 Y=0 Z=50 YAW=0 PITCH=64 ROLL=192
	

If yu wish, you can change the bounding box which is created automatically for you to one that better fits the model (optional).

#Exec MESH BOUNDINGBOX parameters:

MESH The name of the mesh that has the bounding box we wish to change. Optional: No
XMIN, YMIN, ZMIN Change the lower limits of the box here. Optional: Yes
XMAX, YMAX, ZMAX Change the upper limits of the box here. Optional: Yes
	//Example including optional settings

	#Exec MESH BOUNDINGBOX MESH=MyMesh XMIN=-50.0 YMIN=-50.0 ZMIN=-50.0 XMAX=50.0 YMAX=50.0 ZMAX=50.0
	

Now we need to declare each animation.

#Exec MESH SEQUENCE parameters:

MESH The name of the mesh the sequence resides in, which we want to declare. Optional: No
SEQ The name of the sequence you wish to declare. Optional: No
STARTFRAME Each animation resides inside the _a.3d file one after the other. Put here the frame number at which the desired animation starts. Optional: No
NUMFRAMES Specify here how long the animation is (number of frames). Optional: No
RATE You can change how many frames per second the animation takes here. Optional: Yes
GROUP This assigns the sequence to a group. Optional: Yes
	//Examples including optional settings.

	#Exec MESH SEQUENCE MESH=MyMesh SEQ=All STARTFRAME=0 NUMFRAMES=32
	#Exec MESH SEQUENCE MESH=MyMesh SEQ=Bend STARTFRAME=0 NUMFRAMES=10
	#Exec MESH SEQUENCE MESH=MyMesh SEQ=Spherize STARTFRAME=11 NUMFRAMES=10 RATE=5 GROUP=MyGroup
	#Exec MESH SEQUENCE MESH=MyMesh SEQ=Taper STARTFRAME=22 NUMFRAMES=10

	

Now that the animation information "exists" you can create animation notifies. This must be placed after the #Exec MESH SEQUENCE commands.

#Exec MESH NOTIFY parameters:

MESH The name of the mesh the sequence resides in, which we wish to add a notify for. Optional: No
SEQ The name of the sequence we want to create a notify for. Optional: No
TIME This is where to place the notify. The range is 0 to 1. To find the correct value the math is:

Frame / TotalFrames

So if you wanted to place a notify on frame 1.58 (of a 26 frame total animation) you would put 0.06.
Optional: No
FUNCTION The name of the function that will be called for this notify. This function should exist within the actor that has this mesh when its drawtype is DT_Mesh. Optional: No
	//Example

	#Exec MESH NOTIFY MESH=MyMesh SEQ=Spherize TIME=0.5 FUNCTION=Pop

	
Finally, you can apply textures (or materials) to the mesh. But in order to do that something called a "meshmap" must be created. The meshmap can also be used to resize the mesh.

#Exec MESHMAP NEW parameters:

MESHMAP The name of the meshmap we are creating, this must be the same as the mesh we are creating it for. Optional: No
MESH The name of the mesh we are creating the meshmap for. Optional: No
	//Example

	#Exec MESHMAP NEW MESHMAP=MyMesh MESH=MyMesh
	
You can use the meshmap to change the scale of the mesh (optional but without it your mesh might be invisible because its drawscale would be 0!).

#Exec MESHMAP SCALE parameters:

MESHMAP The name of the meshmap we are creating, this must be the same as the mesh we are creating it for. Optional: No
X, Y, Z Changes the scale of the mesh (does the same as the MESH SCALE command). Optional: No
	//Example

	#Exec MESHMAP SCALE MESHMAP=MyMesh X=1 Y=1 Z=1
	
To set the textures use the SETTEXTURE command. The textures should exist at compile time.

#Exec MESHMAP SETTEXTURE parameters:

MESHMAP The name of the meshmap that was created for this model. Optional: No
NUM The position in the skin array where this texture should go. For example NUM=0 corresponds to Skins[0]. Optional: No
TEXTURE The name of the texture (or material) to apply to this skin slot. The texture should be referenced first, either by importing the texture into the package or by loading the package it resides in.

IMPORT TEXTURE (via UnrealScript)
LOADING TEXTURE (via UnrealScript)
Optional: No
TLOD Appears to be obsolete. Optional: Yes
	//Example including texture import
	#Exec TEXTURE IMPORT NAME=HeadTexture FILE=Images\MyHeadTexture.DDS GROUP=MyMeshTextures
	#Exec TEXTURE IMPORT NAME=BodyTexture FILE=Images\MyBodyTexture.DDS GROUP=MyMeshTextures
	#Exec TEXTURE IMPORT NAME=WeaponTexture FILE=Images\MyWeaponTexture.DDS GROUP=MyMeshTextures

	#Exec MESHMAP SETTEXTURE MESHMAP=MyMesh NUM=0 TEXTURE=HeadTexture
	#Exec MESHMAP SETTEXTURE MESHMAP=MyMesh NUM=1 TEXTURE=BodyTexture
	#Exec MESHMAP SETTEXTURE MESHMAP=MyMesh NUM=2 TEXTURE=WeaponTexture
	

TOP TIP - You only need to specify the texture name, not the package or group when assiging any type of material using the SETTEXTURE command.