Xonotic
anim.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define setanim(...)   anim_set(__VA_ARGS__)
 
#define updateanim(...)   anim_update(__VA_ARGS__)
 

Functions

void anim_set (entity e, vector anim, bool looping, bool override, bool restart)
 
void anim_update (entity e)
 Update e.frame based on its animstate relative to time. More...
 

Variables

float animstate_endtime
 
float animstate_framerate
 
bool animstate_looping
 whether to repeat More...
 
int animstate_numframes
 
bool animstate_override
 true for one cycle, then changed to false More...
 
int animstate_startframe
 
float animstate_starttime
 
float frame
 primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4) More...
 
float frame1time
 start time of framegroup animation More...
 
float frame2
 secondary framegroup animation (strength = lerpfrac) More...
 
float frame2time
 start time of framegroup animation More...
 
float frame3
 tertiary framegroup animation (strength = lerpfrac3) More...
 
float frame3time
 start time of framegroup animation More...
 
float frame4
 quaternary framegroup animation (strength = lerpfrac4) More...
 
float frame4time
 start time of framegroup animation More...
 
float lerpfrac
 strength of framegroup blend More...
 
float lerpfrac3
 strength of framegroup blend More...
 
float lerpfrac4
 strength of framegroup blend More...
 

Macro Definition Documentation

◆ setanim

#define setanim (   ...)    anim_set(__VA_ARGS__)

◆ updateanim

#define updateanim (   ...)    anim_update(__VA_ARGS__)

Definition at line 47 of file anim.qh.

Function Documentation

◆ anim_set()

void anim_set ( entity  e,
vector  anim,
bool  looping,
bool  override,
bool  restart 
)
Parameters
animx = startframe, y = numframes, z = framerate

Definition at line 6 of file anim.qc.

References BITXOR_ASSIGN, EF_RESTARTANIM_BIT, frametime, and time.

Referenced by viewmodel_draw(), and W_Model().

7 {
8  if (!anim) return; // no animation was given to us! We can't use this.
9 
10  if (anim.x == e.animstate_startframe)
11  {
12  if (anim.y == e.animstate_numframes)
13  {
14  if (anim.z == e.animstate_framerate)
15  {
16  if (!restart) return;
17  if (anim.y == 1) // ZYM animation
19  }
20  }
21  }
22  e.animstate_startframe = anim.x;
23  e.animstate_numframes = anim.y;
24  e.animstate_framerate = anim.z;
25  e.animstate_starttime = time - 0.1 * frametime; // shift it a little bit into the past to prevent float inaccuracy hiccups
26  e.animstate_endtime = e.animstate_starttime + e.animstate_numframes / e.animstate_framerate;
27  e.animstate_looping = looping;
28  e.animstate_override = override;
29  e.frame = e.animstate_startframe;
30  e.frame1time = time;
31 }
const int EF_RESTARTANIM_BIT
float frametime
Definition: csprogsdefs.qc:17
#define BITXOR_ASSIGN(a, b)
Definition: common.qh:107
float time
Definition: csprogsdefs.qc:16
+ Here is the caller graph for this function:

◆ anim_update()

void anim_update ( entity  e)

Update e.frame based on its animstate relative to time.

Definition at line 36 of file anim.qc.

References bound(), and time.

Referenced by viewmodel_draw().

37 {
38  if (time >= e.animstate_endtime)
39  {
40  if (e.animstate_looping)
41  {
42  e.animstate_starttime = e.animstate_endtime;
43  e.animstate_endtime = e.animstate_starttime + e.animstate_numframes / e.animstate_framerate;
44  }
45  e.animstate_override = false;
46  }
47  float frameofs = bound(0, (time - e.animstate_starttime) * e.animstate_framerate, e.animstate_numframes - 1);
48  e.frame = e.animstate_startframe + frameofs;
49 }
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ animstate_endtime

float animstate_endtime

◆ animstate_framerate

float animstate_framerate

Definition at line 36 of file anim.qh.

◆ animstate_looping

bool animstate_looping

whether to repeat

Definition at line 40 of file anim.qh.

Referenced by viewmodel_draw().

◆ animstate_numframes

int animstate_numframes

Definition at line 35 of file anim.qh.

◆ animstate_override

bool animstate_override

true for one cycle, then changed to false

Definition at line 42 of file anim.qh.

Referenced by PlayerDamage(), and viewmodel_draw().

◆ animstate_startframe

int animstate_startframe

Definition at line 34 of file anim.qh.

◆ animstate_starttime

float animstate_starttime

Definition at line 37 of file anim.qh.

Referenced by SUB_CalcMove_controller_think().

◆ frame

◆ frame1time

◆ frame2

◆ frame2time

◆ frame3

float frame3

tertiary framegroup animation (strength = lerpfrac3)

Definition at line 10 of file anim.qh.

Referenced by CSQCModel_InterpolateAnimation_2To4_PreNote(), CSQCPlayer_FallbackFrame_Apply(), CSQCPlayer_FallbackFrame_PostUpdate(), and CSQCPlayer_FallbackFrame_PreUpdate().

◆ frame3time

float frame3time

start time of framegroup animation

Definition at line 26 of file anim.qh.

Referenced by CSQCModel_InterpolateAnimation_2To4_Do(), CSQCModel_InterpolateAnimation_2To4_PreNote(), and CSQCPlayer_FallbackFrame_PostUpdate().

◆ frame4

float frame4

quaternary framegroup animation (strength = lerpfrac4)

Definition at line 12 of file anim.qh.

Referenced by CSQCModel_InterpolateAnimation_2To4_PreNote(), CSQCPlayer_FallbackFrame_Apply(), CSQCPlayer_FallbackFrame_PostUpdate(), and CSQCPlayer_FallbackFrame_PreUpdate().

◆ frame4time

float frame4time

start time of framegroup animation

Definition at line 28 of file anim.qh.

Referenced by CSQCModel_InterpolateAnimation_2To4_Do(), CSQCModel_InterpolateAnimation_2To4_PreNote(), and CSQCPlayer_FallbackFrame_PostUpdate().

◆ lerpfrac

◆ lerpfrac3

float lerpfrac3

strength of framegroup blend

Definition at line 17 of file anim.qh.

Referenced by CSQCModel_InterpolateAnimation_2To4_Do().

◆ lerpfrac4

float lerpfrac4

strength of framegroup blend

Definition at line 19 of file anim.qh.

Referenced by CSQCModel_Hook_PreDraw(), and CSQCModel_InterpolateAnimation_2To4_Do().