Jump to content

[LE] Scaling actors - need a second pair of eyes (or neurons...)


Hoamaii

Recommended Posts

Hey guys,

 

I need to rescale 2 actors to the same size to play a custom animation (not a furniture, and not a paired anim - just a regular sequence).

 

For the moment, I'm rescaling both to a similar base scale of 1.0 with the following code:

float fREalScale
float fRealScalingFactor
float fAnimScaleM
float fAnimeScaleF

Function ScaleActor(actor akActor)
	fRealScale = akActor.GetScale()			
	; getScale() returns the base scale value - like console GetScale >> 1.0 (with base 1.03) - SetScale(s) sets a multiplier of Base Value, not a value.
	fRealScalingFactor = (1.0 / fRealScale)
	akActor.SetScale(fRealScalingFactor)
	If fAnimScaleM != 1.0 && akActor == ActorMale
		ActorMale.SetScale(fRealScalingFactor * fAnimScaleM )
	EndIf
	If fAnimScaleF != 1.0 && akActor == ActorFemale
		ActorFemale.SetScale(fRealScalingFactor * fAnimScaleF )
	EndIf
EndFunction

That works fine and does the job - but when both actors are 1.05 or 1.07, it makes them shrink in a very visible "jump" in game (same thing when 2 actors are 0.95 or less, they suddenly grow and it's not nice.

 

So I thought I'd try applying another factor to the multiplier, calculated on the average scaling factor of both actors (basically, 50% of their added base scales), and I tried this:

Function ScaleActors()
	float fRealScaleMale = actorMale.GetScale()	
	float fRealScaleFem = actorFemale.GetScale()
	float fAvgScale = ((fRealScaleMale + fRealScaleFem) * 0.5)
	Debug.MessageBox("Male scale " + fRealScaleMale + " FemScale " + fRealScaleFem + "  = AvgScale " + fAvgScale)
	float fMaleScalingFactor = (1.0 / fRealScaleMale)
	float fFemScalingFactor = (1.0 / fRealScaleFem)
	If fAnimScaleM != 1.0
		ActorMale.SetScale((fMaleScalingFactor * fAvgScale) * fAnimScaleM)
	Else 
		ActorMale.SetScale(fMaleScalingFactor * fAvgScale)
	EndIf
	If fAnimScaleF != 1.0
		ActorFemale.SetScale((fFemScalingFactor * fAvgScale) *  fAnimScaleF)
	Else
		ActorFemale.SetScale(fFemScalingFactor * fAvgScale)
	EndIf
EndFunction

That compiles fine and I get no log error. BUT it doesnt' work at all in game. Even though console command tells me that the new scale mutliplier has been properly applied, actors do not display that new scale in game.

 

For instance, an initially "1.00 with a base of 1.00" actor paired with a taller one (say 1.00 with a base of 1.05) may show a "1.02 with a base of 1.02" in console command, but on screen the RefID really looks like a 0.97 or 0.95 - visually, they shrink instead of getting taller.

 

I know floats are not very accurate and you can only scale actors with a precision of 0.01, but what I don't get is why the actor displays one thing and the console tells me another. Unless of course I'm failing to see some obvious mistake in my code which may mislead the console?..

 

Any idea?

 

Many thanks in advance!

 

 

Link to comment
Share on other sites

  • 3 weeks later...

FIXED:

Mhm... doesn't look like many of you guys have been working with scales lately :no:

But in case somebody encounters the same issue sometime, here's what I found and how I solved it:

Turns out both functions work fine, the issue was not with the scaling functions, but in the same script I was using "SetVehicle" on both actors, that's what freaks up rescaling functions.

I stumbled on a post by Migal130 commenting that "SetVehicle' changes the scale of actors - as far as I could visually tell in my tests, it apparently rescales actors to "1.0 with Base 1.0", fairly similar to what the furniture "RaceToScale" keyword does.

The trouble is that "setVehicle" does change actors' scales without affecting their height or scale values in game, thus causing "GetScale" (in scripts or in Console Commands) to return wrong values, which of course completely messed up the rest of my scaling functions. In order to fix that, one needs to always call "akActor.SetScale(1.0)" after SetVehicle to restore the actor to its CK modded values. Once that's done, my code works just as intended.

Another potential issue is that furniture use can also mess up actors' custom scales, causing them to not regain their custom scales on exit. Again, calling "SetScale(1.0) before modifying their scales, either in scripts or with console, is also needed.

And finally, I also learnt that, while modded scales added in the CK (whether directly on the actor or in races) or set with SetScale in Papyrus cause no issue at all, some other mods which rescale actors outside the scope of the CK like RaceMenu, NiOverride's functions, HDT High Heels or some custom skeletons can also falsify "GetScale" returns, thus preventing any rescaling function to work properly. As far as I know, there's no solution to fix that at the moment. Of course, RaceMenu only messes up scale if you used it to set an actor's height or scale. Personally I do use RaceMenu but I was fortunate enough as to change player or NPCs scales or height directly in the CK rather than in RaceMenu - and that's apparently the only way to avoid any further scaling issues when using that mod.

Here's the link to Migal130's post: https://forums.nexusmods.com/index.php?/topic/5150755-flower-girls-se-x/page-7

 

PS. There's actually a faster way to rescale two actors to the average scale of both than the codeI it posted up here:

Function ScaleActor(actor AkActor)
	float fRealScaleMale = actorMale.GetScale()	
	float fRealScaleFem = actorFemale.GetScale()
	float fAvgScale = ((fRealScaleMale + fRealScaleFem) * 0.5)
	If akActor == ActorMale
		akActor.SetScale(fAvgScale/fRealScaleMale)
	ElseIf akActor == ActorFemale
		akActor.SetScale(fAvgScale/fRealScaleFem)
	EndIf
EndFunction
  • Like 1
Link to comment
Share on other sites

  • 5 years later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...