scaling active objects, with Mode 7 Ex
Hello,
I am having an issue with getting active objects that are sprite-mapped to a Mode 7 surface to scale smoothly... I used "get on-screen width/height from X,Y,W,H" to get them to scale ok, but the scaling is really rough and doesn't look right. I am looking into using 3D Actives to move and scale the active objects around, but so far haven't been able to get the positions of the objects being moved by 3D Actives to stick to their sprite-mapped locations on the Mode 7 field. Does anyone have a tip on how to handle the weird scaling, or how to get 3D Actives to move an object around relative to the Mode 7 origin? Thanks!
-Joel
Re: scaling active objects, with Mode 7 Ex
Are you using smooth or fast scaling? (0 or 1 in the action)
Re: scaling active objects, with Mode 7 Ex
I am using "1" for higher-quality scaling, but honestly I don't really see any noticeable difference between the two modes. The sprite is scaling in giant leaps, so if I start as far away as possible (where I can still see the sprite) then move forward it will only change scale maybe 3 or 4 times before I run over it. I believe I have gotten some better results using an Active Picture Object, but for my game I need the sprites to animate... Thanks for the help Dynasoft!
Re: scaling active objects, with Mode 7 Ex
Can we see the formula you use for scaling in [code][/code] tags?
Re: scaling active objects, with Mode 7 Ex
Sorry, I don't really know what that means! Here are the events I am using for the sprite mapping, I hope this is what you were asking for.
Start of Frame - >
Torch : Set W to XScale("Torch")
Torch : Set H to YScale("Torch")
Always - >
Torch : Set X_MAP to GetMapXZ("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), ZPOS("TorchMARKER"))
Torch : Set Y_MAP to GetMapYZ("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), ZPOS("TorchMARKER"))
Torch : Set W_MAP to GetMapWidth("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), W("Torch"), H("Torch"))*0.2
Torch : Set W_MAP to GetMapWidth("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), W("Torch"), H("Torch"))*0.2
Torch : Set VISIBLE to GetMapVisible("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), W("Torch"), H("Torch"))
VISIBLE of Torch = 0
Torch: Make invisible
VISIBLE of Torch = 1
Torch: Reappear
Torch: Set X position to X_MAP("Torch")
Torch: Set Y position to Y_MAP("Torch")
Torch: Set X scale to W_MAP("Torch") (Quality=1)
Torch: Set Y scale to H_MAP("Torch") (Quality=1)
It occurred to me while looking around the forums that maybe the scaling calculation is using an integer where it should be getting a floating point value. I tried changing it around a bunch of different ways, but I still didn't see any visible difference in the sprite mapping. With 3D Actives the sprites scale so beautifully... I really hope I can achieve a similar result with Mode7Ex.
Re: scaling active objects, with Mode 7 Ex
Well, the problem is that you're passing the width/height in pixels to the scale. You have to divide them by the original size, e.g.
Torch : Set W to XScale("Torch")/32.0
Torch : Set H to YScale("Torch")/32.0
Re: scaling active objects, with Mode 7 Ex
Thanks Looki,
Could you please elaborate a bit on your suggestion? Dividing the XScale and YScale of the sprite by its original dimensions returns "1.0", yes? Would this not make the game think the sprite is only 1 pixel wide/high? The image I am trying to sprite map is 128 x 256; I tried dividing by those dimensions, but my sprites just disappeared! Could you explain specifically how dividing by the image dimension should affect the calculation? Thanks again for the help!
Re: scaling active objects, with Mode 7 Ex
Ahh, sorry for that. You have to multiply them to get the width/height.
You have to divide the width by the original width to get the X scale. :blush:
Re: scaling active objects, with Mode 7 Ex
All right, after some messing around I was able to get it to work. Thanks a million Looki!
Re: scaling active objects, with Mode 7 Ex
I have one follow up question, if I may... the sprites are scaling nicely now, but there is a pretty bad lag and intermittent crash of the runtime when the sprite is directly behind the camera. Here is what the sprite-mapping events look like now:
Start of Frame - >
Torch : Set W to XScale("Torch")*128
Torch : Set H to YScale("Torch")*256
Always - >
Torch : Set X_MAP to GetMapXZ("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), ZPOS("TorchMARKER"))
Torch : Set Y_MAP to GetMapYZ("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), ZPOS("TorchMARKER"))
Torch : Set W_MAP to GetMapWidth("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), W("Torch"), H("Torch"))*0.2
Torch : Set W_MAP to GetMapWidth("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), W("Torch"), H("Torch"))*0.2
Torch : Set VISIBLE to GetMapVisible("Mode7Ex", X("TorchMARKER"), Y("TorchMARKER"), W("Torch"), H("Torch"))
VISIBLE of Torch = 0
Torch: Make invisible
VISIBLE of Torch = 1
Torch: Reappear
Torch: Set X position to X_MAP("Torch")
Torch: Set Y position to Y_MAP("Torch")
Torch: Set X scale to W_MAP("Torch")/128 (Quality=0)
Torch: Set Y scale to H_MAP("Torch")/256 (Quality=0)
Maybe there is a problem with the GetMapVisible calculation? It seems to be hiding + showing the sprite properly... any help I could get would be appreciated. Thanks!
Re: scaling active objects, with Mode 7 Ex
Ok I was able to more or less fix the lag by creating a detector that follows the Mode7 origin, and only doing the sprite-mapping calculations when the sprite is not overlapping the detector. If anyone knows the cause of this issue or has another method of dealing with it, I would be interested to learn... but for now it looks like I got it. Thanks to all for the help!