Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
0 views

diff

The document contains code changes related to zoom functionality in a rendering engine. Key updates include adjustments to zoom field of view variables, the introduction of a zoom state structure, and modifications to how zoom affects gun animations. The changes enhance the zoom feature by allowing for different animations based on the zoom state and incorporating iron sight functionality.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

diff

The document contains code changes related to zoom functionality in a rendering engine. Key updates include adjustments to zoom field of view variables, the introduction of a zoom state structure, and modifications to how zoom affects gun animations. The changes enhance the zoom feature by allowing for different animations based on the zoom state and incorporating iron sight functionality.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

diff --git a/engine/rendergl.cpp b/engine/rendergl.

cpp
index 0297cc1..95b0e6b 100644
--- a/engine/rendergl.cpp
+++ b/engine/rendergl.cpp
@@ -864,18 +864,36 @@ float curfov = 100, curavatarfov = 65, fovy, aspect;
int farplane;
VARP(zoominvel, 0, 250, 5000);
VARP(zoomoutvel, 0, 100, 5000);
-VARP(zoomfov, 10, 35, 60);
+VARP(zoomfov, 10, 35, 100);
VARP(fov, 10, 100, 150);
-VAR(avatarzoomfov, 10, 25, 60);
+VAR(avatarzoomfov, 10, 25, 100);
VAR(avatarfov, 10, 65, 150);
FVAR(avatardepth, 0, 0.5f, 1);
FVARNP(aspect, forceaspect, 0, 0, 1e3f);
+VARF(showironsight, 0, 0, 1, zoominfo.state = (zoominfo.state & 3) |
(showironsight << 2););

static int zoommillis = 0;


VARF(zoom, -1, 0, 1,
- if(zoom) zoommillis = totalmillis;
+ if(zoom) {
+ zoommillis = totalmillis;
+ zoominfo.startmillis = lastmillis;
+ }
);

+zoomstate zoominfo;
+
+void zoomstate::update() {
+ if(!zoom) { state = ZOOM_OFF | (state & USE_IRON_SIGHT); return; }
+ duration = zoom > 0 ? zoominvel : zoomoutvel;
+ if(duration > totalmillis - zoommillis)
+ {
+ // startmillis = zoommillis;
+ state = (zoom > 0 ? ZOOM_IN: ZOOM_OUT) | (state & USE_IRON_SIGHT);
+ return;
+ }
+ state = (zoom > 0 ? ZOOM_ON: ZOOM_OFF) | (state & USE_IRON_SIGHT);
+}
+
void disablezoom()
{
zoom = 0;
@@ -966,6 +984,7 @@ void recomputecamera()
{
game::setupcamera();
computezoom();
+ zoominfo.update();

bool shoulddetach = thirdperson > 1 || game::detachcamera();


if(!thirdperson && !shoulddetach)
diff --git a/fpsgame/render.cpp b/fpsgame/render.cpp
index 08e5014..2f97b75 100644
--- a/fpsgame/render.cpp
+++ b/fpsgame/render.cpp
@@ -345,15 +345,28 @@ namespace game
return;
}

+ // zoominfo.update();
int rtime = guns[d->gunselect].attackdelay;
if(d->lastaction && d->lastattackgun==d->gunselect && lastmillis-d-
>lastaction<rtime)
{
- drawhudmodel(d, ANIM_GUN_SHOOT|ANIM_SETSPEED, rtime/17.0f, d-
>lastaction);
- }
- else
+ if(zoominfo.state == (ZOOM_ON|USE_IRON_SIGHT)) {
+ drawhudmodel(d, ANIM_GUN_SHOOT_ZOOM|ANIM_SETSPEED, rtime/17.0f,
d->lastaction); }
+ else {
+ drawhudmodel(d, ANIM_GUN_SHOOT |ANIM_SETSPEED, rtime/17.0f,
d->lastaction); }
+ }
+ else if(zoominfo.state == (ZOOM_IN|USE_IRON_SIGHT)) {
+ drawhudmodel(d, ANIM_GUN_ZOOM_IN |ANIM_SETSPEED,
zoominfo.duration, zoominfo.startmillis);
+ }
+ else if(zoominfo.state == (ZOOM_OUT|USE_IRON_SIGHT)) {
+ drawhudmodel(d, ANIM_GUN_ZOOM_OUT|ANIM_SETSPEED,
zoominfo.duration, zoominfo.startmillis);
+ }
+ else
{
- drawhudmodel(d, ANIM_GUN_IDLE|ANIM_LOOP);
- }
+ if(zoominfo.state == (ZOOM_ON|USE_IRON_SIGHT)) {
+ drawhudmodel(d, ANIM_GUN_IDLE_ZOOM|ANIM_LOOP); }
+ else {
+ drawhudmodel(d, ANIM_GUN_IDLE |ANIM_LOOP); }
+ }
}

void renderavatar()
diff --git a/shared/ents.h b/shared/ents.h
index d7e7e05..1738ae7 100644
--- a/shared/ents.h
+++ b/shared/ents.h
@@ -110,7 +110,7 @@ enum
ANIM_PAIN,
ANIM_JUMP, ANIM_SINK, ANIM_SWIM,
ANIM_EDIT, ANIM_LAG, ANIM_TAUNT, ANIM_WIN, ANIM_LOSE,
- ANIM_GUN_IDLE, ANIM_GUN_SHOOT,
+ ANIM_GUN_IDLE, ANIM_GUN_SHOOT, ANIM_GUN_IDLE_ZOOM, ANIM_GUN_SHOOT_ZOOM,
ANIM_GUN_ZOOM_IN, ANIM_GUN_ZOOM_OUT,
ANIM_VWEP_IDLE, ANIM_VWEP_SHOOT, ANIM_SHIELD, ANIM_POWERUP,
ANIM_MAPMODEL, ANIM_TRIGGER,
NUMANIMS
@@ -125,7 +125,7 @@ static const char * const animnames[] =
"pain",
"jump", "sink", "swim",
"edit", "lag", "taunt", "win", "lose",
- "gun idle", "gun shoot",
+ "gun idle", "gun shoot", "gun idle zoom", "gun shoot zoom", "gun zoom in",
"gun zoom out",
"vwep idle", "vwep shoot", "shield", "powerup",
"mapmodel", "trigger"
};
diff --git a/shared/iengine.h b/shared/iengine.h
index 6e03b1f..9a6466a 100644
--- a/shared/iengine.h
+++ b/shared/iengine.h
@@ -266,6 +266,13 @@ extern void removetrackeddynlights(physent *owner = NULL);
extern physent *camera1;
extern vec worldpos, camdir, camright, camup;

+enum { ZOOM_OFF, ZOOM_ON, ZOOM_IN, ZOOM_OUT, USE_IRON_SIGHT };


+struct zoomstate {
+ int state, startmillis, duration;
+ void update();
+};
+
+extern zoomstate zoominfo;
extern void disablezoom();

extern vec calcavatarpos(const vec &pos, float dist);

You might also like