/usr/src/castle-game-engine-5.2.0/x3d/x3dloadinternalspine_simpletextureloader.inc is in castle-game-engine-src 5.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | {
Copyright 2014-2014 Michalis Kamburelis.
This file is part of "Castle Game Engine".
"Castle Game Engine" is free software; see the file COPYING.txt,
included in this distribution, for details about the copyright.
"Castle Game Engine" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------------
}
type
{ Texture nodes, indexed by attachment name. }
TImageTextureNodeMap = specialize TFPGMap<string, TImageTextureNode>;
{ Spine simple texture loader (without atlas).
Reads each region attachment as a single texture file,
from a filename 'images/' + AttachmentName + '.png'. }
TSimpleTextureLoader = class(TTextureLoader)
strict private
Nodes: TImageTextureNodeMap;
BaseUrl: string;
public
constructor Create(const ABaseUrl: string);
destructor Destroy; override;
function UseNode(const AttachmentName: string;
out TexCoord: TQuadTexCoord; out TexRect: TQuadTexRect): TImageTextureNode; override;
end;
constructor TSimpleTextureLoader.Create(const ABaseUrl: string);
begin
inherited Create;
BaseUrl := ABaseUrl;
Nodes := TImageTextureNodeMap.Create;
end;
destructor TSimpleTextureLoader.Destroy;
begin
FreeAndNil(Nodes);
inherited;
end;
function TSimpleTextureLoader.UseNode(const AttachmentName: string;
out TexCoord: TQuadTexCoord; out TexRect: TQuadTexRect): TImageTextureNode;
var
Index: Integer;
begin
Index := Nodes.IndexOf(AttachmentName);
if Index <> -1 then
Result := Nodes.Data[Index] else
begin
Result := TImageTextureNode.Create('SimpleTexture_' + ToX3DName(AttachmentName), BaseUrl);
Result.FdUrl.Items.Add('images/' + AttachmentName + '.png');
Result.RepeatS := false;
Result.RepeatT := false;
Nodes[AttachmentName] := Result;
end;
TexCoord[0] := Vector2Single(0, 0);
TexCoord[1] := Vector2Single(1, 0);
TexCoord[2] := Vector2Single(1, 1);
TexCoord[3] := Vector2Single(0, 1);
TexRect[0] := Vector2Single(0, 0);
TexRect[1] := Vector2Single(1, 1);
end;
|