Advanced Zooming with GTest
This tutorial is made by Jan H. Simon.
This is my first tutorial and it's based on the "Zoom Field Of View" Tutorial by
Vexator!
I'm german so don't get worried about my english!
It's all about making different Zoom-Levels. In my example "Near" and "Far".
I used it with an isometric view, but you can use it for 1st or 3d Person Cam as
you want!
And all the changes are made in Client.C!
First, we'll add a few variables at the top of client.c right after:
static int32 CurAvg;
// added
float ZoomMultiplikator = 1.0;
geBoolean FirstTime = GE_TRUE;
geBoolean ZoomMode = GE_FALSE;
geBoolean Stop = GE_TRUE;
// end added
Now in the SetupCamere function still in client.c ( I wrote the whole block so
just overwrite your fuction code with mine! ):
//=====================================================================================
// SetupCamera
//=====================================================================================
static void SetupCamera(geCamera *Camera, geRect *Rect, geXForm3d *XForm)
{
geCamera_SetWorldSpaceXForm(Camera, XForm);
geCamera_SetAttributes(Camera, 2.0f*ZoomMultiplikator, Rect);
}
and then in the Client_SendMove function:
// Do misc move actions
if (NewKeyDown(KeyLut[VK_RBUTTON], hWnd))
ButtonBits |= HOST_BUTTON_JUMP;
if (IsKeyDown(KeyLut[VK_LBUTTON], hWnd))
{
ButtonBits |= HOST_BUTTON_FIRE;
}
// added
if (IsKeyDown(KeyLut[VK_MBUTTON], hWnd))
{
if (Stop)
{
ZoomMode = !ZoomMode;
if (ZoomMode)
{
ZoomMultiplikator = 2.5; // Zoom camera in
if (FirstTime)
{
PlaySound ("wav/zoom_on.wav", NULL, SND_ASYNC);
FirstTime = GE_FALSE;
}
}
if (!ZoomMode)
{
FirstTime =
GE_TRUE;
ZoomMultiplikator = 1.0;
PlaySound ("wav/zoom_off.wav",
NULL, SND_ASYNC);
}
Stop = GE_FALSE;
}
}
else
Stop = GE_TRUE;
// end added
if (IsKeyDown('1', hWnd))
{
Client->CurrentWeapon = 0;
}
Now just save the code, add a sound at "Genesis3d11/wav/zoom_on.wav" and one in
the same place called "zoom_off.wav", compile the code and ready!
I hope it works but I think that it is VERY easy, too!
If you have any requests, ideas or alternatives ... mail me @
datenfunk@t-online.de!
Jan H. Simon