UE1 - UT How to dynamically scale 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 know that you can do something like this to change the scale of a mesh:

Code:
#exec meshmap scale meshmap=myMesh x=0.5 y=.05 z=0.1

However, I would like to do it later, like in PreBeginPlay(). Is this possible?
 

gopostal

Active Member
Jan 19, 2006
848
47
28
Drawscale can affect other things too. A lot depends on what you are scaling up/down.
If you dynamically alter something like scripted pawn you get a corresponding increase in health. Set drawscale to 2.0 and your monster will now have 2X its default health. It also affects collision. If the beginning collision of the actor was oversized to start, it will become correspondingly oversize (in scale). This is why some of the big monsters in MH seem to have a magical barrier around them. The mappers set drawscale way up to 4X or so but didn't bother to check collision size.

The obverse it true too. If you scale things down you will lose health in addition to the reduction in the collision box. If you are scaling objects and not monsters/players then you need to closely look at their boxes to ensure they don't render half in the floor or even delete completely for violating the BSP barrier.

A lot depends on what you are going to scale around with. You are welcome to chat me privately if you'd rather not openly discuss a project. I've spent a lot of time screwing around with this and you are welcome to see how it was addressed in the MH2 mod, specifically the strongermonster class.
 

Helen

Member
Jan 23, 2010
48
0
6
I wish to scale the mesh with different values for x, y, and z. I want to do it in PreBeginPlay (or anywhere in code) so that I can have one class, spawn many instances of it, and be able to dynamically give each instance different scaling. Does anyone know how to do this, thanks.
 

meowcat

take a chance
Jun 7, 2001
803
3
18
You can't adjust the three drawscale axes independently at runtime in the Unreal 1 engine, that capability only showed up later in the unreal Engine versions (such as the version on which UT2k4 runs).
 

gopostal

Active Member
Jan 19, 2006
848
47
28
You ought to be able to get around this though (depending on what you wanted to do) by using several meshes scaled to different ratios and rotated around the origin. It could get messy texturing them if you need specific skins that aren't generic but for something like random snowflakes or a cupboard full of tribbles, that's certainly doable.

So meow, a mesh is pretty much locked in Uengine1? That makes sense since a lot of the values that adjust with drawscale are done inside the engine (you won't find code for collision or health adjustment for instance). Without a way to address the axes independently there is no reason to have it otherwise.

I do remember coding in 2k4 there were a lot more vars for this. I just didn't understand them.
 

MrLoathsome

New Member
Apr 1, 2010
100
0
0
I did something like that in my monster size randomizer mutator.
Here are the 2 primary functions in that.
Perhaps something in there will help you:
Code:
function bool CheckCollision(Actor A, float DSM, vector newLoc)  // Credit to Feralidragon for this function
{
local bool isColliding;
local float CRadius, CHeight;

   CRadius = A.CollisionRadius;
   CHeight = A.CollisionHeight;
   A.SetCollisionSize(A.CollisionRadius * DSM, A.CollisionHeight * DSM);
   isColliding = !A.SetLocation(newLoc);
   A.SetCollisionSize(CRadius, CHeight);
   if (bDebugMode)
   {
       if (isColliding)
          log("RMS: Can NOT grow = "$A$"  DrawScaleMult = "$DSM);
       else
          log("RMS: Can grow = "$A$"  DrawScaleMult = "$DSM);
   }
   return isColliding;
}

function CheckReSize(Actor Other)
{
	local float F;
	local Vector V;

	F = FMax(MinMSize, (FRand()*MaxMSize));
	V = Other.Location;
	if (F > 1.0)
	{
		While ( (F > MinMSize) && (CheckCollision(Other, F, V)) ) 
			{ F = FMax(MinMSize, F - ScaleDown); if (bDebugMode) { log("RMS: Scaledown -> "$F); } }
	}
	Other.DrawScale = Other.DrawScale * F;
	Other.Mass = Other.Mass * F;
	if (ScriptedPawn(Other).Shadow != None)
		{ ScriptedPawn(Other).Shadow.DrawScale = ScriptedPawn(Other).Shadow.DrawScale * F; }
	ScriptedPawn(Other).Health = FClamp(ScriptedPawn(Other).Health * F, MinMHealth, MaxMHealth);
	Other.SetCollisionSize((Other.CollisionRadius * F), (Other.CollisionHeight * F));
	if ((bDebugMode) && (Other.DrawScale != Other.default.DrawScale))
		{ log("RMS: Pawn size randomized.... "$Other$" DrawScale = "$Other.DrawScale$" Health = "$Pawn(Other).Health); }
	if ((bDebugMode) && (Other.DrawScale == Other.default.DrawScale))
		{ log("RMS: Pawn size NOT randomized.... "$Other$" DrawScale = "$Other.DrawScale); }
}
 

Helen

Member
Jan 23, 2010
48
0
6
Thanks for the help. In the end I just subclassed twice, each with their own #exec statements so I could scale x, y, and z differently.