Changing the archive in some light billBoards breaks positioning/scale

Discuss modding questions and implementation details.
Post Reply
User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Changing the archive in some light billBoards breaks positioning/scale

Post by Ralzar »

I am working on my Torch Taker mod where you are now able to turn on/off billBoards for lights in dungeons like torches, campfires, lanters etc.

Code: Select all

DaggerfallBillboard lightBillboard = lightObj.GetComponent<DaggerfallBillboard>();
if (lightBillboard != null)
    lightBillboard.SetMaterial(540, lightBillboard.Summary.Record);
This worked completely fine out of the box.
torch.png
torch.png (77.1 KiB) Viewed 500 times

Until I ran into candles. Where apparently something happens to them to increase their scale and possibly their positioning.
candle.png
candle.png (41.73 KiB) Viewed 500 times
Inspecting the objects I see no obvious differences in their settings that are not also there for the other objects I do this with. But as you can see below the new candle sprite is halfway out of its frame?
candleObjs.png
candleObjs.png (28.37 KiB) Viewed 500 times
I have checked my replacement sprite and it is the same size as the original: 15x21

Anyone have any ideas about what is causing this? Maybe DFU does some kind of scale adjustment when creating the candle billBoards that gets reversed when you switch out the archive number?

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Changing the archive in some light billBoards breaks positioning/scale

Post by BadLuckBurt »

I have done some more debugging and found the following:

The sprite for 210_4-0 is 15x21 pixels when exported from Daggerfall Imaging and so is Ralzar's replacement image 540_4-0.

I dumped the size and scale values for both images as DFU loads them in and there's something funky going on in the scale department that I can not explain:

Code: Select all

Image: 540_4-0:

Archive - record : 540_4-0 | GetBillboardMesh size: (15.0000, 21.0000) 
Archive - record : 540_4-0 | GetBillboardMesh scale: (1.0000, 1.0000) 
Sprite size: (0.3750, 0.5250) 

----------------------------------------------------------------------------------------------------------

Image: 210_4-0

Archive - record : 210_4-0 | GetBillboardMesh size: (15.0000, 21.0000) 
Archive - record : 210_4-0 | GetBillboardMesh scale: (-128.0000, -128.0000) 
Sprite size: (0.2000, 0.2750) 
Image 540_4-0 gets loaded through TextureReplacement.GetStaticBillboardMaterial and returns with that sprite size which is correct, 15 * 0.025 = 0.375 and 21 * 0.025 = 0.525

Image 210_4-0 gets loaded through MaterialReader.GetMaterialAtlas and for some reason, it's scale is returned as (-128.0, -128.0).

The code below calculates what I show as Sprite size:

Code: Select all

            // Apply scale
            Vector2 finalSize;
            int xChange = (int)(size.x * (scale.x / BlocksFile.ScaleDivisor));
            int yChange = (int)(size.y * (scale.y / BlocksFile.ScaleDivisor));
            finalSize.x = (size.x + xChange);
            finalSize.y = (size.y + yChange);
With the scale being 1, xChange and yChange end up as 0 because the fraction is just really tiny.

But, naturally, with the scale being -128, you end up substracting half the width and half the height, shrinking the sprite down. Is this intended behaviour?

================================================================

So, I did one more test by hardcoding xChange and yChange to 0 for record 4 of archive 210 and 540. The candle behaves like it should, it doesn't grow or shrink, just gets extinguished and relit.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

Post Reply