index be268e299d7d87f7e8aaef28d64b9b3a2a90c40b..612644fce1527f96799429ada9fa976fe0dba7d8 100644 (file)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation, version 3 of the License ONLY.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
uses
{$IFDEF USE_MEMPOOL}mempool,{$ENDIF}
- MAPDEF, g_textures, g_basic, g_weapons, e_graphics, utils;
+ MAPDEF, g_textures, g_basic, g_weapons, e_graphics, utils, g_gfx,
+ ImagingTypes, Imaging, ImagingUtility;
const
A_STAND = 0;
HaveWeapon: Boolean;
end;
+ TModelBlood = record
+ R, G, B, Kind: Byte;
+ end;
+
TModelSound = record
ID: DWORD;
Level: Byte;
FName: String;
FDirection: TDirection;
FColor: TRGB;
+ FBlood: TModelBlood;
FCurrentAnimation: Byte;
FAnim: Array [TDirection.D_LEFT..TDirection.D_RIGHT] of Array [A_STAND..A_LAST] of TAnimation;
FMaskAnim: Array [TDirection.D_LEFT..TDirection.D_RIGHT] of Array [A_STAND..A_LAST] of TAnimation;
public
property Color: TRGB read FColor write FColor;
+ property Blood: TModelBlood read FBlood;
end;
procedure g_PlayerModel_LoadData();
function g_PlayerModel_Load(FileName: String): Boolean;
function g_PlayerModel_GetNames(): SSArray;
function g_PlayerModel_GetInfo(ModelName: String): TModelInfo;
+function g_PlayerModel_GetBlood(ModelName: String): TModelBlood;
function g_PlayerModel_Get(ModelName: String): TPlayerModel;
function g_PlayerModel_GetAnim(ModelName: String; Anim: Byte; var _Anim, _Mask: TAnimation): Boolean;
function g_PlayerModel_GetGibs(ModelName: String; var Gibs: TGibsArray): Boolean;
implementation
uses
+ {$INCLUDE ../nogl/noGLuses.inc}
g_main, g_sound, g_console, SysUtils, g_player, CONFIG,
- GL, GLExt, e_sound, g_options, g_map, Math, e_log, wadreader;
+ e_sound, g_options, g_map, Math, e_log, wadreader;
type
TPlayerModelInfo = record
PainSounds: TModelSoundArray;
DieSounds: TModelSoundArray;
SlopSound: Byte;
+ Blood: TModelBlood;
end;
const
end;
end;
+function g_PlayerModel_CalcGibSize (pData: Pointer; dataSize, x, y, w, h: Integer): TRectWH;
+ var i, j: Integer; done: Boolean; img: TImageData;
+
+ function IsVoid (i, j: Integer): Boolean;
+ begin
+ result := Byte((PByte(img.bits) + (y+j)*img.width*4 + (x+i)*4 + 3)^) = 0
+ end;
+
+begin
+ InitImage(img);
+ assert(LoadImageFromMemory(pData, dataSize, img));
+
+ (* trace x from right to left *)
+ done := false; i := 0;
+ while not done and (i < w) do
+ begin
+ j := 0;
+ while (j < h) and IsVoid(i, j) do inc(j);
+ done := (j < h) and (IsVoid(i, j) = false);
+ result.x := i;
+ inc(i);
+ end;
+
+ (* trace y from up to down *)
+ done := false; j := 0;
+ while not done and (j < h) do
+ begin
+ i := 0;
+ while (i < w) and IsVoid(i, j) do inc(i);
+ done := (i < w) and (IsVoid(i, j) = false);
+ result.y := j;
+ inc(j);
+ end;
+
+ (* trace x from right to left *)
+ done := false; i := w - 1;
+ while not done and (i >= 0) do
+ begin
+ j := 0;
+ while (j < h) and IsVoid(i, j) do inc(j);
+ done := (j < h) and (IsVoid(i, j) = false);
+ result.width := i - result.x + 1;
+ dec(i);
+ end;
+
+ (* trace y from down to up *)
+ done := false; j := h - 1;
+ while not done and (j >= 0) do
+ begin
+ i := 0;
+ while (i < w) and IsVoid(i, j) do inc(i);
+ done := (i < w) and (IsVoid(i, j) = false);
+ result.height := j - result.y + 1;
+ dec(j);
+ end;
+
+ FreeImage(img);
+end;
+
function g_PlayerModel_Load(FileName: string): Boolean;
var
ID: DWORD;
Description := config.ReadStr('Model', 'description', '');
end;
+ with PlayerModelsArray[ID] do
+ begin
+ Blood.R := MAX(0, MIN(255, config.ReadInt('Blood', 'R', 150)));
+ Blood.G := MAX(0, MIN(255, config.ReadInt('Blood', 'G', 0)));
+ Blood.B := MAX(0, MIN(255, config.ReadInt('Blood', 'B', 0)));
+ case config.ReadStr('Blood', 'Kind', 'NORMAL') of
+ 'NORMAL': Blood.Kind := BLOOD_NORMAL;
+ 'SPARKS': Blood.Kind := BLOOD_CSPARKS;
+ 'COMBINE': Blood.Kind := BLOOD_COMBINE;
+ else
+ Blood.Kind := BLOOD_NORMAL
+ end
+ end;
+
for b := A_STAND to A_LAST do
begin
aname := s+'_RIGHTANIM'+IntToStr(b);
if e_CreateTextureMemEx(pData, lenpd, Gibs[a].ID, a*32, 0, 32, 32) and
e_CreateTextureMemEx(pData2, lenpd2, Gibs[a].MaskID, a*32, 0, 32, 32) then
begin
- Gibs[a].Rect := e_GetTextureSize2(Gibs[a].ID);
+ //Gibs[a].Rect := e_GetTextureSize2(Gibs[a].ID);
+ Gibs[a].Rect := g_PlayerModel_CalcGibSize(pData, lenpd, a*32, 0, 32, 32);
with Gibs[a].Rect do
if Height > 3 then Height := Height-1-Random(2);
Gibs[a].OnlyOne := config.ReadInt('Gibs', 'once', -1) = a+1;
with PlayerModelsArray[a] do
begin
Result.FName := Info.Name;
+ Result.FBlood := Blood;
for b := A_STAND to A_LAST do
begin
end;
end;
+function g_PlayerModel_GetBlood(ModelName: string): TModelBlood;
+var
+ a: Integer;
+begin
+ Result.R := 150;
+ Result.G := 0;
+ Result.B := 0;
+ Result.Kind := BLOOD_NORMAL;
+ if PlayerModelsArray = nil then Exit;
+
+ for a := 0 to High(PlayerModelsArray) do
+ if PlayerModelsArray[a].Info.Name = ModelName then
+ begin
+ Result := PlayerModelsArray[a].Blood;
+ Break;
+ end;
+end;
+
procedure g_PlayerModel_FreeData();
var
i: DWORD;