UE1 - UT dynamically change the texture of a mesh

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Helen

Member
Jan 23, 2010
48
0
6
I would like to dynamically change the texture of a mesh. The mesh belongs to an Effects class. I know how to dynamically load a texture, however this following assignment doesn't have any effect ('self' being an instance of an Effects class):

Code:
self.Texture = Texture(DynamicLoadObject("Botpack.someTexture", class'Texture'));

Now I think I have to tell the self.Mesh to use this texture, but I can't find the syntax. Does anyone have any experience with this?

Thanks.
 

Shadow_knight

Carpe diem!
Jan 29, 2008
51
0
6
Prague
Well don't know how is it in Unreal1, but in UT2004 what you need to do, is to set up Skins[0] array - because there is the information which textures the mesh should use.
So one thing is to set a Mesh through:

Code:
defaultproperties {
Mesh=StaticMesh'MyMesh'
}

second thing is to set texture/s through skins array:

Code:
Skins[0]=Texture(DynamicLoadObject(MyPack.MyTex", class'Texture'));

The method where you change Skins array should be simulated, otherwise it won't work in net games.

Don't know how much this changed between UE1 and UE2, but maybe it helps.

sk
 

Feralidragon

UT n00b coder
Feb 25, 2008
182
0
16
The "Texture" property is only for Sprites and environment mapped Meshes.

For the rest of the meshes you have:
MultiSkins[] (from 0 to 7, the most used is MultiSkins[1], as MultiSkins[0] is quite special),
Skin (some meshes use this one, like the decoration sheet/panel).

Now that depends on the mesh, and how many "skins" it has.
Also you don't need the "self" keyword if you work with variables/properties from the actual actor the code is running in, so perhaps this will work with you instead:

Code:
MultiSkins[1] = Texture(DynamicLoadObject("Botpack.someTexture", class'Texture'));

UEngine2 is very different from UEngine1 regarding skins on models (different variables, unlimited multiskins (?), different mesh types, etc). I never wrote a single line of code in UEngine2 though...
 
Last edited:

Helen

Member
Jan 23, 2010
48
0
6
I did try assigning to the skins array, i set the first three slots to my texture to no effect.

The appearance I want to change is the color of the shockwave from a redeemer explosion. Right now it is just plain old white. I would like to get it to be another color.

Maybe we can't change it because it is a lodmesh rather than a StaticMesh?

So anyways, at the beginning of the ShockWave class, we have this:

Code:
#exec MESH IMPORT MESH=ShockWavem ANIVFILE=MODELS\SW_a.3D DATAFILE=MODELS\SW_d.3D X=0 Y=0 Z=0 
#exec MESH ORIGIN MESH=ShockWavem X=0 Y=0 Z=0 YAW=0 PITCH=64
#exec MESH SEQUENCE MESH=ShockWavem SEQ=All       STARTFRAME=0   NUMFRAMES=2
#exec MESH SEQUENCE MESH=ShockWavem SEQ=Explosion STARTFRAME=0   NUMFRAMES=2
#exec MESH SEQUENCE MESH=ShockWavem SEQ=Implode   STARTFRAME=0   NUMFRAMES=1
#exec TEXTURE IMPORT NAME=Shockt1 FILE=MODELS\shockw.PCX GROUP="Skins"
#exec MESHMAP SCALE MESHMAP=ShockWavem X=1.0 Y=1.0 Z=2.0 
#exec MESHMAP SETTEXTURE MESHMAP=ShockWavem NUM=1 TEXTURE=Shockt1

I decompiled botpack.u, and grabbed the shockw.PCX (which looks more brown that white??). I copied this pcx, then I edited the picture so that it was red, and renamed it to ShockRed.pcx (and put it in the correct directory).

Then I have my own inherited shock wave class, so at the top I did:

Code:
#exec texture IMPORT NAME=ShockRed FILE=TEXTURES\ShockRed.PCX
#exec MESHMAP SETTEXTURE MESHMAP=ShockWavem NUM=1 TEXTURE=ShockRed

but, sadly, this again didn't have any effect. :(
 

Feralidragon

UT n00b coder
Feb 25, 2008
182
0
16
Well, first off, that won't have any effect actually. The primary skin assignments take effect within the same class the mesh is imported only, afaik.

All you have to do is to import the texture itself only, and open that package in Ued to check if your texture is actually being imported or not.

Next, the import directives for the main class you got that from, tells that the assigned skin array is MultiSkins[1] (since it's applying the skin to NUM=1).

So now you either set the new texture in the code:
Code:
simulated function PostBeginPlay()
{
	MultiSkins[1] = SomeTexture;
	Super.PostBeginPlay();
}

Or in the default properties:
Code:
defaultproperties
{
	MultiSkins(1)=SomeTexture
}

Notice the difference between default properties and running code: in default properties you can't apply any space, nor ";" at the end of each variable assignment, plus array indexes are represented within "()" and not "[]".
In configuration (ini) files however, the array index is represented by "[]".


Another thing: I hope you're compiling your scripts "externally" and not within "Ued" itself. What I mean is: create .uc files instead (unreal classes) externally, then compile them into a new package using "ucc make" or "UMake", never use Ued itself to compile, for several reasons:
- Syntax highlighting only works when you "reselect" the script;
- Some scripts won't open due to a naming bug: if you open "Whatever" class, you won't be able to open the "What" class for example;
- The import directives won't work at all;
- You cannot change the package binaries anymore (delete classes for instance).
 

Helen

Member
Jan 23, 2010
48
0
6
I use WOTGreal to compile :)

So thankyou, your suggestions worked. At the top of the class I have this single line:

Code:
#exec texture IMPORT NAME=RedWave FILE=TEXTURES\RedWave.PCX

And in preBeginPlay() is simply:

Code:
	MultiSkins[1] = Texture(DynamicLoadObject("myMutator.RedWave", class'Texture'));

This is the best forum eva :2thumb: