summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3ec5eb1)
raw | patch | inline | side by side (parent: 3ec5eb1)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 30 Jun 2022 11:03:13 +0000 (14:03 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 08:53:33 +0000 (11:53 +0300) |
index 1e9078e9320d52117e1b73aaf15371d3eaf7b22d..9c6dd4cb2aa53ab0a9086994dbf64ac00093d420 100644 (file)
back: Boolean; (* back animation normalization *)
end;
+
function g_Anim_GetTotalFrames (const a: TAnimInfo): LongWord;
function g_Anim_GetTotalTime (const a: TAnimInfo): LongWord;
function g_Anim_GetCountByTime (const a: TAnimInfo; time: LongWord): LongInt;
procedure g_Anim_GetFrameByTime (const a: TAnimInfo; time: LongWord; out count, frame: LongInt);
procedure g_Anim_GetState (const anim: TAnimInfo; time: LongWord; out state: TAnimState);
+ procedure g_Anim_GetFrameFromState (const s: TAnimState; backanim: Boolean; out frame: LongInt);
+
implementation
uses Math, utils, xstreams;
state.mPlayed := count >= 1;
end;
+ procedure g_Anim_GetFrameFromState (const s: TAnimState; backanim: Boolean; out frame: LongInt);
+ var total: LongInt;
+ begin
+ ASSERT(s.length > 0);
+ frame := s.CurrentFrame mod s.length;
+ if backanim then
+ begin
+ total := (s.length + 1) div 2;
+ if frame >= total then
+ frame := s.length - frame - 1;
+ end;
+ end;
+
end.
index fbdae7e4ee8e09cdfd307dc29365d7b322f88149..b8b90210de603771695a9b76e8f2b1328207f9e6 100644 (file)
procedure r_Draw_TextureRepeat (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
procedure r_Draw_TextureRepeatRotate (img: TGLTexture; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
- procedure r_Draw_MultiTextureRepeat (m: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
- procedure r_Draw_MultiTextureRepeatRotate (m: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
+ procedure r_Draw_MultiTextureRepeat (m: TGLMultiTexture; const anim: TAnimState; backanim: Boolean; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
+ procedure r_Draw_MultiTextureRepeatRotate (m: TGLMultiTexture; const anim: TAnimState; backanim: Boolean; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
procedure r_Draw_Filter (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
procedure r_Draw_FillRect (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
r_Draw_TextureRepeat(img, x, y, w, h, flip, r, g, b, a, blend);
end;
- procedure r_Draw_MultiTextureRepeat (m: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
- var img: TGLTexture; cur, total, i: Integer;
+ procedure r_Draw_MultiTextureRepeat (m: TGLMultiTexture; const anim: TAnimState; backanim: Boolean; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean);
+ var img: TGLTexture; frame: LongInt;
begin
ASSERT(anim.IsValid());
if m = nil then
r_Draw_TextureRepeat(nil, x, y, w, h, flip, NTR, NTG, NTB, NTB, blend)
else
begin
- if m.BackAnim then
- begin
- total := m.count * 2 - 1;
- cur := anim.CurrentFrame mod total;
- if cur < m.count then i := cur else i := total - cur - 1;
- end
- else
- i := anim.CurrentFrame mod m.count;
- img := m.GetTexture(i);
+ g_Anim_GetFrameFromState(anim, backanim, frame);
+ ASSERT(frame >= 0);
+ ASSERT(frame < m.count);
+ img := m.GetTexture(frame);
r_Draw_TextureRepeat(img, x, y, w, h, flip, r, g, b, a, blend);
end
end;
- procedure r_Draw_MultiTextureRepeatRotate (m: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
+ procedure r_Draw_MultiTextureRepeatRotate (m: TGLMultiTexture; const anim: TAnimState; backanim: Boolean; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
begin
ASSERT(w >= 0);
ASSERT(h >= 0);
glTranslatef(x + rx, y + ry, 0);
glRotatef(angle, 0, 0, 1);
glTranslatef(-(x + rx), -(y + ry), 0);
- r_Draw_MultiTextureRepeat(m, anim, x, y, w, h, flip, r, g, b, a, blend);
+ r_Draw_MultiTextureRepeat(m, anim, backanim, x, y, w, h, flip, r, g, b, a, blend);
glPopMatrix;
end
else
- r_Draw_MultiTextureRepeat(m, anim, x, y, w, h, flip, r, g, b, a, blend);
+ r_Draw_MultiTextureRepeat(m, anim, backanim, x, y, w, h, flip, r, g, b, a, blend);
end;
procedure r_Draw_Filter (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
index 786bd5409728417dc9f342797999f857a85f94b7..87379696680a2cf7d33bd88b5ea097f0891c72b7 100644 (file)
Models[i].anim[d, a].base := nil;
Models[i].anim[d, a].mask := nil;
if m.anim[d, a].resource <> '' then
- Models[i].anim[d, a].base := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].resource, 64, 64, m.anim[d, a].frames, m.anim[d, a].back, true);
+ Models[i].anim[d, a].base := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].resource, 64, 64, m.anim[d, a].frames, true);
if m.anim[d, a].mask <> '' then
- Models[i].anim[d, a].mask := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].mask, 64, 64, m.anim[d, a].frames, m.anim[d, a].back, true);
+ Models[i].anim[d, a].mask := r_Textures_LoadMultiFromFileAndInfo(prefix + m.anim[d, a].mask, 64, 64, m.anim[d, a].frames, true);
end
end;
{$IFDEF ENABLE_GIBS}
w,
h,
count,
- False,
False
);
end
ItemAnim[i].w,
ItemAnim[i].h,
ItemAnim[i].anim.frames,
- ItemAnim[i].anim.back,
false
);
Items[i].frame := 0;
for j := 0 to ANIM_LAST do
for d := TDirection.D_LEFT to TDirection.D_RIGHT do
r_Map_LoadMonsterAnim(i, j, d);
- VileFire := r_Textures_LoadMultiFromFileAndInfo(GameWAD + ':TEXTURES/FIRE', 64, 128, VileFireAnim.frames, VileFireAnim.back);
+ VileFire := r_Textures_LoadMultiFromFileAndInfo(GameWAD + ':TEXTURES/FIRE', 64, 128, VileFireAnim.frames);
// --------- player models --------- //
if PlayerModelsArray <> nil then
begin
{$IFDEF ENABLE_GFX}
for i := 1 to R_GFX_LAST do
if GFXAnim[i].anim.frames > 0 then
- GFXTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + GFXAnim[i].name, GFXAnim[i].w, GFXAnim[i].h, GFXAnim[i].anim.frames, GFXAnim[i].anim.back);
+ GFXTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + GFXAnim[i].name, GFXAnim[i].w, GFXAnim[i].h, GFXAnim[i].anim.frames);
{$ENDIF}
// --------- shots --------- //
for i := 0 to WEAPON_LAST do
if ShotAnim[i].anim.frames > 0 then
- ShotTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + ShotAnim[i].name, ShotAnim[i].w, ShotAnim[i].h, ShotAnim[i].anim.frames, ShotAnim[i].anim.back);
+ ShotTextures[i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/' + ShotAnim[i].name, ShotAnim[i].w, ShotAnim[i].h, ShotAnim[i].anim.frames);
// --------- flags --------- //
FlagTextures[FLAG_NONE] := nil;
- FlagTextures[FLAG_RED] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGRED', 64, 64, 5, false);
- FlagTextures[FLAG_BLUE] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGBLUE', 64, 64, 5, false);
- // FlagTextures[FLAG_DOM] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGDOM', 64, 64, 8, false);
+ FlagTextures[FLAG_RED] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGRED', 64, 64, 5);
+ FlagTextures[FLAG_BLUE] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGBLUE', 64, 64, 5);
+ // FlagTextures[FLAG_DOM] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':TEXTURES/FLAGDOM', 64, 64, 8);
// --------- shells --------- //
{$IFDEF ENABLE_SHELLS}
for i := 0 to SHELL_LAST do
for b := false to true do
begin
for i := 0 to 2 do
- PunchTextures[b, i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':WEAPONS/' + PunchName[b] + WeapPos[i], 64, 64, PunchAnim.frames, PunchAnim.back);
+ PunchTextures[b, i] := r_Textures_LoadMultiFromFileAndInfo(GameWad + ':WEAPONS/' + PunchName[b] + WeapPos[i], 64, 64, PunchAnim.frames);
end;
// --------- other --------- //
InvulPenta := r_Textures_LoadFromFile(GameWad + ':TEXTURES/PENTA');
mon.obj.Lerp(gLerpFactor, fX, fY);
if r_Map_GetMonsterTexture(m, a, d, t, dx, dy, flip) then
- r_Draw_MultiTextureRepeat(t, mon.DirAnim[a, d], fX + dx, fY + dy, t.width, t.height, flip, 255, 255, 255, 255, false);
+ r_Draw_MultiTextureRepeat(t, mon.DirAnim[a, d], false, fX + dx, fY + dy, t.width, t.height, flip, 255, 255, 255, 255, false);
// TODO draw g_debug_frames
end;
end;
procedure r_Map_DrawPlayerModel (pm: TPlayerModel; x, y: Integer; alpha: Byte);
- var a, pos, act, xx, yy, angle: Integer; d: TDirection; flip: Boolean; t: TGLMultiTexture; tex: TGLTexture; c: TRGB;
+ var a, pos, act, xx, yy, angle: Integer; d: TDirection; flip, back: Boolean; t: TGLMultiTexture; tex: TGLTexture; c: TRGB;
begin
a := pm.CurrentAnimation;
d := pm.Direction;
if r_Map_GetPlayerModelTex(pm.id, a, d, flip) then
begin
t := Models[pm.id].anim[d, a].base;
- r_Draw_MultiTextureRepeat(t, pm.AnimState, x, y, t.width, t.height, flip, 255, 255, 255, alpha, false);
+ back := PlayerModelsArray[pm.id].anim[d, a].back;
+ r_Draw_MultiTextureRepeat(t, pm.AnimState, back, x, y, t.width, t.height, flip, 255, 255, 255, alpha, false);
t := Models[pm.id].anim[d, a].mask;
if t <> nil then
begin
c := pm.Color;
- r_Draw_MultiTextureRepeat(t, pm.AnimState, x, y, t.width, t.height, flip, c.r, c.g, c.b, alpha, false);
+ r_Draw_MultiTextureRepeat(t, pm.AnimState, back, x, y, t.width, t.height, flip, c.r, c.g, c.b, alpha, false);
end;
end;
end;
index 062f76bdcebe373f1ecc231c88ba127b7724d476..1f3f23885eaef05e98ac9303c6f89459a6e1b4b9 100644 (file)
TGLMultiTexture = class
private
mTexture: array of TGLTexture;
- mBackanim: Boolean;
public
destructor Destroy; override;
property width: Integer read GetWidth;
property height: Integer read GetHeight;
property count: Integer read GetCount;
- property backAnim: Boolean read mBackanim; (* this property must be located at TAnimState? *)
end;
TGLTextureArray = array of TGLTexture;
function r_Textures_LoadFromFile (const filename: AnsiString; log: Boolean = True): TGLTexture;
function r_Textures_LoadMultiFromFile (const filename: AnsiString; log: Boolean = True): TGLMultiTexture;
- function r_Textures_LoadMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; backanim: Boolean; log: Boolean = True): TGLMultiTexture;
+ function r_Textures_LoadMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; log: Boolean = True): TGLMultiTexture;
function r_Textures_LoadMultiTextFromFile (const filename: AnsiString; var txt: TAnimTextInfo; log: Boolean = True): TGLMultiTexture;
function r_Textures_LoadStreamFromFile (const filename: AnsiString; w, h, count, cw: Integer; st: TGLTextureArray; rs: TRectArray; log: Boolean = True): Boolean;
end
end;
- function r_Textures_LoadMultiFromImageAndInfo (var img: TImageData; w, h, c: Integer; b: Boolean): TGLMultiTexture;
+ function r_Textures_LoadMultiFromImageAndInfo (var img: TImageData; w, h, c: Integer): TGLMultiTexture;
var t: TImageData; a: array of TGLTexture; i: Integer; m: TGLMultiTexture;
begin
ASSERT(w >= 0);
end;
m := TGLMultiTexture.Create();
m.mTexture := a;
- m.mBackanim := b;
ASSERT(m.mTexture <> nil);
result := m;
end;
- function r_Textures_LoadMultiFromDataAndInfo (data: Pointer; size: LongInt; w, h, c: Integer; b: Boolean): TGLMultiTexture;
+ function r_Textures_LoadMultiFromDataAndInfo (data: Pointer; size: LongInt; w, h, c: Integer): TGLMultiTexture;
var img: TImageData;
begin
ASSERT(w > 0);
try
if LoadImageFromMemory(data, size, img) then
if r_Textures_FixImageData(img) then
- result := r_Textures_LoadMultiFromImageAndInfo(img, w, h, c, b)
+ result := r_Textures_LoadMultiFromImageAndInfo(img, w, h, c)
except
end;
FreeImage(img);
try
if LoadImageFromMemory(data, size, img) then
if r_Textures_FixImageData(img) then
- result := r_Textures_LoadMultiFromImageAndInfo(img, txt.w, txt.h, txt.anim.frames, txt.anim.back);
+ result := r_Textures_LoadMultiFromImageAndInfo(img, txt.w, txt.h, txt.anim.frames);
finally
FreeMem(data);
end;
m := TGLMultiTexture.Create();
SetLength(m.mTexture, 1);
m.mTexture[0] := t;
- m.mBackanim := false;
txt.name := '';
txt.w := m.width;
txt.h := m.height;
result := r_Textures_LoadMultiTextFromFile(filename, txt, log);
end;
- function r_Textures_LoadMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; backanim: Boolean; log: Boolean = True): TGLMultiTexture;
+ function r_Textures_LoadMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; log: Boolean = True): TGLMultiTexture;
var wad: TWADFile; wadName, resName: AnsiString; data: Pointer; size: Integer;
begin
ASSERT(w > 0);
resName := g_ExtractFilePathName(filename);
if wad.GetResource(resName, data, size, log) then
begin
- result := r_Textures_LoadMultiFromDataAndInfo(data, size, w, h, count, backanim);
+ result := r_Textures_LoadMultiFromDataAndInfo(data, size, w, h, count);
FreeMem(data);
end;
wad.Free