Zooming

Started by Seventeen Uncles, Sat 08/11/2014 12:26:56

Previous topic - Next topic

Seventeen Uncles

Hi there, considered putting this in the beginners forum but i think its more suited for here.

basicly what im looking to do is zoom in on a character during a particular room transition, then once that interaction is over return back to the starting room with the character in the same place, i'm fairly certain i'll be able to manage scripting saving the x/y coords of the character to return to the same place etc, but what im having trouble with is finding a plugin or a way to control the camera viewport or zoom.

I did find a reference to a zoom plugin but its quite old and the link/documenation no longer works, so im not even sure if its what im after. If you have any recommendations on this, or if its even possible within AGS i'd really appreciate it.

for some background if ive not made my intention clear above, my playable character is a dog, and theres a tick that lives on his head that you can talk to whenever you want. What I want to happen is for the camera to zoom in on the dogs head, do the room transition to a room where you have a conversation, then when this ends return to the startng room and zoom back out, just so its clear to the player where the conversation is taking place.

Adeel

Tween Module might be what you're looking for. The demo also shows Roger zooming in and out.

Slasher

Hi Seventeen Uncles,

I am presently using the tween module to zoom in and pan backgrounds using characters as you cannot use tween to do this with objects.

Recommended.

Seventeen Uncles

Quote from: Adeel S. Ahmed on Sat 08/11/2014 13:48:55
Tween Module might be what you're looking for. The demo also shows Roger zooming in and out.

Quote from: slasher on Sat 08/11/2014 21:01:05
Hi Seventeen Uncles,

I am presently using the tween module to zoom in and pan backgrounds using characters as you cannot use tween to do this with objects.

Recommended.

Thanks guys i'll give it a look, thanks for taking the time to reply.

I'll post the results here later for any future searchers :D

Seventeen Uncles

the tween module doesnt do quite what im looking for, rather than just make a specific character scale in relation to the rest of the scene (so it looks like the character is growing) im more looking for a universal zoom so that the viewport itself seems to be moving towards the scene.

selmiak

If everything is in always in the same place when the zoom takes place (static conditions) it might be a (workintensive) option to manually do the zoom in a lot of frames, either pixel by pixel or within Photoshop/gimp with the scaling tools and save the frames.
If you have different starting conditions every time and want to do it by code you might want to try taking a screenshot and save it to a dynamic sprite and zoom this in with the tween module (or rather scale it up to fake a zoom). But learning about dynamic sprites is still on my to do list so I can only point in that direction and be semi-helpful.

Seventeen Uncles

Quote from: selmiak on Sun 09/11/2014 18:08:32
If everything is in always in the same place when the zoom takes place (static conditions) it might be a (workintensive) option to manually do the zoom in a lot of frames, either pixel by pixel or within Photoshop/gimp with the scaling tools and save the frames.
If you have different starting conditions every time and want to do it by code you might want to try taking a screenshot and save it to a dynamic sprite and zoom this in with the tween module (or rather scale it up to fake a zoom). But learning about dynamic sprites is still on my to do list so I can only point in that direction and be semi-helpful.

I think your second suggestion (taking a screenshot then tweening it) would be the winning option. Its a bit of a shame that the max scaling level is 200% as i'd like to scale in much closer than this. I think this is all a bit beyond my AGS scripting skill at the moment, perhaps i'll revisit it in the future.

thanks for your help everyone.

i think the way i'll do it for now is to create a room which is just a big object of my characters face that fills the screen, then tween scale into his forehead to the 'zoomed in' view of the tick on his skin.

Seventeen Uncles

heres what I ended up with (lots of placeholders but you get the idea)

HERE

Adeel

Looking good so far. This is what I had in my mind (more or less) when I suggested you to use Tween Module . :)

Black background would work better than dark background, imho. This will give a feeling that the pug's in deep thought and you won't have to worry about the close-up's background matching with the current room. I've seen some games using this effect.

Grim

You could always take another screenshot of that sprite zoomed to 200% , then switch to it and zoom again... But to be honest, looking at that video, it's actually pretty great already;) I'd go with that.

Snarky

Is 200% a limitation of the Tween module? The documentation doesn't say anything about it for DynamicSprite.Resize(). If so, you could always tween it yourself, and scale as much as you like.

Vincent

Quote from: Snarky on Mon 10/11/2014 11:52:13
you could always tween it yourself,


Code: ags

// Prompting by a legendary teacher

function Magnifying_Glass (int x1, int y1, int x2, int y2) 
{
   DynamicSprite*ds = DynamicSprite.CreateFromBackground(x1, y1, x2, y2);
   DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();

   int lens = 100, x, y, width, height;
   
   while (lens <= 200) // say for example the double size
    {   
       width = (ds.Width * lens) / 100;
       // height = (ds.Height * lens) / 100; // queer logic ?!

       x = x1 - (width - ds.Width) / 2;
       // y = y1 - (height - ds.Height) / 2; // queer logic ?!

       surface.DrawImage(x, y, ds.Graphic, width, height); // x, y, slot, transparency, width, height
       Wait(1);
       lens ++;
    }
       ds.Delete();
}

Crimson Wizard

#12
@Vincent, you forgot surface.Release() ;).
This must be called every time before Wait, otherwise it may work glitchy with Direct3D renderer.

Code: ags

    while (lens <= 200) // say for example the double size
    {  
       DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); 
       <do stuff>
       surface.Release();
       Wait(1);
       lens ++;
    }

Vincent

Quote from: Crimson Wizard on Mon 10/11/2014 13:30:16
Code: ags

    while (lens <= 200) // say for example the double size
    {  
       DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); // HERE
       <do stuff>
       surface.Release(); // HERE
       Wait(1);
       lens ++;
    }


It's amazing how the simplest things I forget anytime. :)
Thanks Crimson Wizard :)

Code: ags

// This can't be put where i did. 
// This is place it, WHILE, the sequence execution.
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); 
// And also, of course.
surface.Release();
// Before the waiting performance.

Snarky

Yes, something along those lines, although you should use a multiplicative time-scaling factor instead of an additive one. In other words, instead of lens++ each turn, you should do lens = lens * zoomFactor, with zoomFactor something like 1.1, or higher if you want a faster zoom. (In this case you need to work in floats, not ints, and do the rounding once you've calculated the new surface size.)

The reason for this is that as the canvas grows, one pixel is a smaller and smaller percentage of the whole thing, so it will feel as if the scaling is slowing down. If you use multiplication you'll get a steady zoom.

Vincent

Certainly.
If you need to perform such operations like this, doubtless, you must need float numbers.
Their are the best choice.

Code: ags

float zoom = 1. ; 
// lens = lens * zoomFactor (God bless you) 


Thanks Snarky for the suggestion, I'll keep it in mind.

Dualnames

You do all know there's a Zoom module?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk