Exec Directive
"#exec" directives execute console commands at compile time. Every "#exec" directive can be executed in UnrealEd's console bar. (without the "#exec") Currently in the newer engine builds, they are the only method of importing vertex meshes (think .3ds). They are also useful for keeping content closely coupled with the code that uses it (textures/sounds), or for referenced seperate content packages for organizational purposes.
Look for lines in Editor.log that start with "Cmd:" to find out about more possibly interesing exec directives.
See UnrealEd Console for more information on this fun stuff!
See Exec Directive (UT) for UT Import commands.
snip from the scale page:
When importing a mesh into the engine with an exec directive, you can specify a rotation for the mesh during import ('# EXEC MESH ORIGIN MESH=Blablabla YAW=..PITCH=..YAW=...) . In this case the rotation unit is a byte: a full circle is 255.
Textures
Import
Textures may also be imported upon compilation of a class or series of classes into a .u package. This is done using the #exec preprocessing directive.
Syntax:
#exec TEXTURE IMPORT NAME=NameForTextureToImportAs FILE=PATH\TO\SomeTexture.pcx GROUP=SomeGroup MIPS=OFF FLAGS=2 PALETTE=SomeTexPalette LODSET=2
- NAME
- Name the texture is imported as.
- FILE
- Path to the texture being imported. Paths are local to the root of the package directory.
- GROUP
- (optional) Name of the group the texture is classified under (used in, for example, the UEd Texture browser.)
- MIPS
- (optional) OFF or ON. Generate MipMaps.
- FLAGS
- (optional) Numerical value. Assigns the texture rendering style. Valid styles are:
- PALETTE
- (optional) Color palette to use if not default.
- LODSET
- (optional) Numerical value. Level of detail. Homologous to the LODSet Texture property in UEd. Affects texture clarity as dictated by the user's settings.
- 0: no detail settings applied.
- 1: LODSET_World – affected by user's World Texture Detail setting.
- 2: LODSET_Skin (or LODSET_PlayerSkin for (UT2003) ) – affected by user's Skin Detail setting.
- 3: (UT2003) LODSET_WeaponSkin – used for weapon textures
- 4: (UT2003) LODSET_Terrain – used for Terrain textures
- 5: (UT2003) LODSET_Interface – used for menu items like HUD and Player Portraits
- 6: (UT2003) LODSET_RenderMap – used for shaders
- 7: (UT2003) LODSET_LightMap – used for light maps
- ALPHA
- (UT2003) (optional) Binary value. Defines whether a texture is imported as a Texture with an Alpha Channel
- UCLAMPMODE
- (UT2003) (optional) can be CLAMP or WRAP, WRAP is default, so you don't have to add it then. I'm not totaly sure what is does, but it's needed for projector textures, and for team symbols.
- VCLAMPMODE
- (UT2003) (optional) see UCLAMPMODE.
(There are probably more import tags, but these are all I'm immediately aware of, and most likely all one will need to know.)
Context:
class SomeClass extends SomeActor; #exec TEXTURE IMPORT NAME=SomeTex1 FILE=Textures\SomeTexture.pcx GROUP=Skins FLAGS=2 #exec TEXTURE IMPORT NAME=SomeTex2 FILE=Textures\AnotherTexture.pcx GROUP=Skins FLAGS=2 #exec TEXTURE IMPORT NAME=SomeTex3 FILE=Textures\StillAnotherTexture.pcx GROUP=Skins FLAGS=2
Imported textures are addressed as PackageName.Texturename, and available via UnrealEd after PackageName is loaded in the Actor browser.
See also Texture Import And Export
Compressing (UT2003)
#exec TEXTURE COMPRESS NAME=Package.TextureName FORMAT=DXT?
DJPaul: To compress a texture to a format. Replace "DXT?" with a compresssion type: i.e. DXT1, DXT3, or DXT5.
Kirin: Default is RGBA8 for non-DDS files (eg. TGA) and DXT? for DDS files depending on what was imported. You can use the DXT Tools for Photoshop from http://developer.nvidia.com/view.asp?IO=ps_texture_compression_plugin to export a DDS texture from Photoshop. non-nVidia users: Don't it worry! It'll work if you don't have an nvidia card. I have a Radeon 9700 and the preview function hasn't bailed on me yet.
Kirin: WOW! That's a lot added in UT2003. Just added a bunch of discovered LODSET variables
smattbac Package Reference. It seems that if you only reference to an object in a package in the defaultproperties, you don't have to load the file (is this true for all engine builds?), but it might be good practice to load it anyway.
Packages
Loading Other Packages
You can use the OBJ LOAD parameters to load a specific file at compile time, so that you can reference objects in that package at compile time. For example, say you want to store a bunch of textures in a seperate .utx so that you don't necessarily have to re-compile the package everytime you want to update/change/add/remove textures, you could do something like:
#exec OBJ LOAD FILE="..\Textures\MyTextures.utx" var Texture SomeTexture; defaultproperties { SomeTexture=Texture'MyTextures.SomeCoolTexture_A' }
You can use OBJ LOAD to load any sort of Unreal package, be it for textures, sounds, animations, or even other script packages. Useful sometimes for bypassing annoying dependency issues as well (although you should probably just design your code not to have these in the first place).
PACKAGE specifies the package which the referenced FILE is compiled into. Setting it equal to the package in which the calling class resides will compile the loaded package into the compiled package. For example, with a texture package called MyTextures.utx and a script MyScript.uc in package MyPackage:
#exec OBJ LOAD FILE="..\Textures\MyTextures.utx" PACKAGE=MyPackage var Texture SomeTexture; defaultproperties { SomeTexture=Texture'MyPackage.SomeCoolTexture_A' }
SomeCoolTexture can then be referenced through MyPackage instead of MyTextures, eliminating the need for a separate texture package when MyPackage is distributed.
Oh yes, here's a little something I learned the hard way...if you want to EXEC OBJ LOAD files, make certain they have different names (i.e., it doesn't like having MyModWeapons.utx and MyModWeapons.uax). Simple work-around is to just name them like MyModWeaponsSkins.utx and MyModWeaponsSounds.uax. Sigh. Maybe I'm just an idiot, but it took me 10 minutes to figure that out. Hopefully this will save someone else that trouble.
Static Meshes
Import
You can import static meshes to be compiled in your .u file. You can import Lightwave (.lwo) and the .ase files exported from the ActorX Utility.
Lightwave (*.lwo files)
#exec STATICMESH IMPORT NAME=GrenadeMesh FILE=Models\assaultgrenade.lwo GROUP=EnemyWeapons
ActorX Exported (*.ase files)
#exec NEW STATICMESH NAME=AnotherGrenadeMesh FILE=Models\assaultgrenade2.ase GROUP=TeamWeapons
- NAME
- Name the static mesh is imported as.
- FILE
- Path to the static mesh being imported. Paths are local to the root of the package directory.
- GROUP
- (optional) Name of the group the static mesh is classified under (used in, for example, the UEd static mesh browser.)
- PACKAGE
- (optional) I'm not sure about this one. It is the name of the package you want to import the static mesh into. Not much use for this in compiling a .u file. However, you may be able to use it to create a batch compiler to compile and save out several packages at once? Like I said I'm not sure.
Daid303: There seems to be another parameter called "COLLISION" it's used alot in the resource UC files in UT2003, but I have no idea what it does.
Oh, wait if you say "COLLISION=0" then all the Materials have EnableCollision to false. Any idea what that does?
Skeletal Meshes
Import
You can import .PSK files obtained from the ActorX utility, that are placed in the /models folder of your package directory.
#exec MESH MODELIMPORT MESH=Weapon_1st MODELFILE=models\WeaponModel.PSK LODSTYLE=10
- MESH
- Name that the mesh is imported as.
- MODELFILE
- Path to the mesh being imported. Paths are local to the root of the package directory.
- GROUP
- (optional) Name of the group that the mesh is classified under.
- LODSTYLE
- not sure - I use 10 for weapons fine.
Position, Rotation and Scale
#exec MESH ORIGIN MESH=Weapon_1st X=0 Y=0 Z=0 YAW=0 PITCH=0 ROLL=0
#exec MESHMAP SCALE MESHMAP=Weapon_1st X=1.0 Y=1.0 Z=1.0
Assign Animations and Textures
#exec MESH DEFAULTANIM MESH=Weapon_1st ANIM=WeaponAnim
#exec MESHMAP SETTEXTURE MESHMAP=Weapon_1st NUM=0 TEXTURE=WeaponTex
- NUM
- Material number the texture is assigned to on the mesh.
Animations
Import
You can import .PSA files obtained from the ActorX utility, that are placed in the /models folder of your package directory.
#exec ANIM IMPORT ANIM=WeaponAnim ANIMFILE=models\WeaponAnim.PSA COMPRESS=1 MAXKEYS=999999 IMPORTSEQS=1
- ANIM
- Name that the animations are imported as.
- ANIMFILE
- Path to the animations being imported. Paths are local to the root of the package directory.
- GROUP
- (optional) Name of the group that the mesh is classified under.
- COMPRESS
- Compresses the animations. 1 is normal, uncompressed, lower numbers are more compressed.
- MAXKEYS
- not sure
- IMPORTSEQS
- not sure
Fonts
Importing True Type Fonts
Importing fonts involves using the NEW command with a factory class, the Aa TrueTypeFontFactory.
Example:
#exec NEW TRUETYPEFONTFACTORY NAME=ZoomStatsFontLarge FONTNAME="OCR A Extended" HEIGHT=24 ANTIALIAS=1 DROPSHADOWX=1 DROPSHADOWY=1 CHARS=".0123456789x"
See TrueTypeFontFactory for more information.
Refactor Me - This needs Splitting into UT and UT2003 Imports