CAST II Game Engine

   MAIN       FEATURES       SCREENSHOTS       FORUMS       MANUAL       DOWNLOADS       CONTACTS   
Units
Class Hierarchy
Classes, Interfaces and Objects
Types
Enumerations
Variables
Constants
Functions and Procedures
Identifiers

Unit BaseTypes

Description

Base types unit

(C) 2007 George "Mirage" Bakhtadze
The source code may be used under either MPL 1.1 or LGPL 2.1 license. See included license.txt file
Created: Apr 09, 2007
Unit contains most basic types

Functions and Procedures

Overview

procedure ColorTo4S(var Result: TColor4s; const Color: Longword); overload;
function ColorTo4S(const Color: Longword): TColor4s; overload;
function ColorTo4S(const Color: TColor): TColor4s; overload;
procedure ColorTo4S(var Result: TColor4s; const Color: TColor); overload;
function GetArea(AX1, AY1, AX2, AY2: Single): TArea;
function GetColor(const C: Longword): TColor; overload;
function GetColor(const R, G, B, A: Byte): TColor; overload;
function GetColor4S(const R, G, B, A: Single): TColor4s;
function GetRect(ALeft, ATop, ARight, ABottom: Integer): TRect;
function GetRectExpanded(const ARect: TRect; EX, EY: Integer): TRect;
function GetRectMoved(const ARect: TRect; MoveX, MoveY: Integer): TRect;
function GetRectOnImage(UV: TUV; AImageWidth, AImageHeight: Integer): TRect;
function GetRectScaled(const ARect: TRect; SX, SY: Single): TRect;
function GetRectWH(ALeft, ATop, AWidth, AHeight: Integer): TRect;
procedure Rect(ALeft, ATop, ARight, ABottom: Integer; out Result: TRect);
procedure RectExpand(const ARect: TRect; EX, EY: Integer; out Result: TRect);
procedure RectMove(const ARect: TRect; MoveX, MoveY: Integer; out Result: TRect);
procedure RectScale(const ARect: TRect; SX, SY: Single; out Result: TRect);
function TimeUnitToMs(const TimeStamp: TTimeUnit): Int64;

Description

procedure ColorTo4S(var Result: TColor4s; const Color: Longword); overload;

Converts a TColor to TColor4s

function ColorTo4S(const Color: Longword): TColor4s; overload;

Converts a TColor to TColor4s

function ColorTo4S(const Color: TColor): TColor4s; overload;

Converts a TColor to TColor4s

procedure ColorTo4S(var Result: TColor4s; const Color: TColor); overload;

Converts a TColor to TColor4s

function GetArea(AX1, AY1, AX2, AY2: Single): TArea;

 

function GetColor(const C: Longword): TColor; overload;

Returns TColor record

function GetColor(const R, G, B, A: Byte): TColor; overload;

Returns TColor record

function GetColor4S(const R, G, B, A: Single): TColor4s;

Returns TColor4s record

function GetRect(ALeft, ATop, ARight, ABottom: Integer): TRect;

Returns the specified by its bounds rectangle record

function GetRectExpanded(const ARect: TRect; EX, EY: Integer): TRect;

Returns source rectangle expanded by (EX, EY)

function GetRectMoved(const ARect: TRect; MoveX, MoveY: Integer): TRect;

Returns source rectangle moved by (MoveX, MoveY)

function GetRectOnImage(UV: TUV; AImageWidth, AImageHeight: Integer): TRect;

Returns the specified by UV coordinates on an image rectangle record

function GetRectScaled(const ARect: TRect; SX, SY: Single): TRect;

Returns source rectangle scaled by (SX, SY)

function GetRectWH(ALeft, ATop, AWidth, AHeight: Integer): TRect;

Returns the specified by width and height rectangle record

procedure Rect(ALeft, ATop, ARight, ABottom: Integer; out Result: TRect);

Fills the specified rectangle record and returns it in Result

procedure RectExpand(const ARect: TRect; EX, EY: Integer; out Result: TRect);

Returns in Result source rectangle expanded by (EX, EY)

procedure RectMove(const ARect: TRect; MoveX, MoveY: Integer; out Result: TRect);

Returns in Result source rectangle moved by (MoveX, MoveY)

procedure RectScale(const ARect: TRect; SX, SY: Single; out Result: TRect);

Returns in Result source rectangle scaled by (SX, SY)

function TimeUnitToMs(const TimeStamp: TTimeUnit): Int64;

Convert time unit to milliseconds

Types

Overview

Int16 = SmallInt;
Int32 = Longint;
Int8 = ShortInt;
Nat16 = Word;
Nat32 = Longword;
Nat8 = Byte;
PAnsiStringArray = ^TAnsiStringArray;
PArea = ^TArea;
PByteBuffer = ^TByteBuffer;
PColor = ^TColor;
PDWordBuffer = ^TDWordBuffer;
PImageBuffer = ^TImageBuffer;
PPalette = ^TPalette;
PRect = ^TRect;
PRect3D = ^TRect3D;
PSingleBuffer = ^TSingleBuffer;
PSmallintBuffer = ^TSmallintBuffer;
PUV = ^TUV;
PVector2s = ^TVector2s;
PVector3s = ^TVector3s;
PWordBuffer = ^TWordBuffer;
TAnsiStringArray = array of AnsiString;
TArea = record X1, Y1, X2, Y2: Single; end;
TARGB = packed record B, G, R, A: Byte; end;
TARGBArray = array[0..$0FFFFFFF] of TARGB;
TARGBInt = packed record B, G, R, A: Integer; end;
TByteBuffer = array[0..$6FFFFFFF] of Byte;
TCharMap = ^TCharmapArray;
TCharmapArray = array[0..$FFFFFF] of TCharMapItem;
TCharMapItem = Longword;
TColor = packed record case Boolean of False: (C: Longword); True: (B, G, R, A: Byte); end;
TColor4s = packed record case Integer of 0: (R, G, B, A: Single;); 1: (RGB: TVector3s); 2: (RGBA: TVector4s); end;
TColorBuffer = array[0..$0FFFFFFF] of TColor;
TDelegate = procedure(Data: Pointer) of object;
TDWordBuffer = array[0..$0FFFFFFF] of Cardinal;
TFileName = string;
TFileSignature = array [0..3] of AnsiChar;
TImageBuffer = TColorBuffer;
TIndArray = array of Integer;
TMessageFlags = set of TMessageFlag;
TNameString = AnsiString;
TPalette = array[0..255] of TPaletteItem;
TPaletteItem = TARGB;
TPointerArray = array of Pointer;
TProgressDelegate = procedure(Progress: Single) of object;
TRect = packed record case Integer of 0:(Left, Top, Right, Bottom: Integer); 1:(X, Y, W, H: Integer); 2:(a1, a2, Width, Height: Integer); end;
TRect3D = packed record case Integer of 0:(Left, Top, Right, Bottom, Front, Back: Integer); 1:(X, Y, W, H: Integer); 2:(a1, a2, Width, Height: Integer); end;
TRGBArray = array[0..$0FFFFFFF] of packed record B, G, R: Byte; end;
TSet32 = set of 0..31;
TSGUID12 = string[12];
TShortMessage = string[127];
TShortName = string[31];
TSingleArray = array of Single;
TSingleBuffer = array[0..$0FFFFFFF] of Single;
TSmallintBuffer = array[0..$0FFFFFFF] of Smallint;
TStringArray = array of String;
TTimeUnit = Double;
TUV = packed record U, V, W, H: Single; end;
TUVArray = array[0..$FFFFFF] of TUV;
TUVMap = ^TUVArray;
TVector2s = packed record case Integer of 0: (X, Y: Single); 1: (V: array[0..1] of Single); end;
TVector3s = packed record case Integer of 0: (X, Y, Z: Single); 1: (V: array[0..2] of Single); end;
TVector4s = packed record case Integer of 0: (X, Y, Z, W: Single); 1: (V: array[0..3] of Single); 2: (xyz: TVector3s); end;
TWordBuffer = array[0..$0FFFFFFF] of Word;

Description

Int16 = SmallInt;

 

Int32 = Longint;

 

Int8 = ShortInt;

 

Nat16 = Word;

 

Nat32 = Longword;

Unsinged (natural)

Nat8 = Byte;

 

PAnsiStringArray = ^TAnsiStringArray;

 

PArea = ^TArea;

 

PByteBuffer = ^TByteBuffer;

 

PColor = ^TColor;

Pointer to 32-bit color

PDWordBuffer = ^TDWordBuffer;

 

PImageBuffer = ^TImageBuffer;

 

PPalette = ^TPalette;

 

PRect = ^TRect;

 

PRect3D = ^TRect3D;

 

PSingleBuffer = ^TSingleBuffer;

 

PSmallintBuffer = ^TSmallintBuffer;

 

PUV = ^TUV;

Pointer to TUV

PVector2s = ^TVector2s;

Pointer to a two-dimensional vector

PVector3s = ^TVector3s;

Pointer to a three-dimensional vector

PWordBuffer = ^TWordBuffer;

 

TAnsiStringArray = array of AnsiString;

 

TArea = record X1, Y1, X2, Y2: Single; end;

 

TARGB = packed record B, G, R, A: Byte; end;

 

TARGBArray = array[0..$0FFFFFFF] of TARGB;

 

TARGBInt = packed record B, G, R, A: Integer; end;

 

TByteBuffer = array[0..$6FFFFFFF] of Byte;

 

TCharMap = ^TCharmapArray;

 

TCharmapArray = array[0..$FFFFFF] of TCharMapItem;

 

TCharMapItem = Longword;

Character map

TColor = packed record case Boolean of False: (C: Longword); True: (B, G, R, A: Byte); end;

32-bit color

TColor4s = packed record case Integer of 0: (R, G, B, A: Single;); 1: (RGB: TVector3s); 2: (RGBA: TVector4s); end;

Color with floating-point components

TColorBuffer = array[0..$0FFFFFFF] of TColor;

 

TDelegate = procedure(Data: Pointer) of object;

General method pointer

TDWordBuffer = array[0..$0FFFFFFF] of Cardinal;

 

TFileName = string;

 

TFileSignature = array [0..3] of AnsiChar;

File signature

TImageBuffer = TColorBuffer;

 

TIndArray = array of Integer;

 

TMessageFlags = set of TMessageFlag;

Message flag set

TNameString = AnsiString;

 

TPalette = array[0..255] of TPaletteItem;

Image palette for paletted graphics file formats

TPaletteItem = TARGB;

Palette color

TPointerArray = array of Pointer;

 

TProgressDelegate = procedure(Progress: Single) of object;

Method pointer used by time-consuming routines to report progess in range [0..1]

TRect = packed record case Integer of 0:(Left, Top, Right, Bottom: Integer); 1:(X, Y, W, H: Integer); 2:(a1, a2, Width, Height: Integer); end;

Last pixel convention: not include

TRect3D = packed record case Integer of 0:(Left, Top, Right, Bottom, Front, Back: Integer); 1:(X, Y, W, H: Integer); 2:(a1, a2, Width, Height: Integer); end;

 

TRGBArray = array[0..$0FFFFFFF] of packed record B, G, R: Byte; end;

 

TSet32 = set of 0..31;

32-bit set

TSGUID12 = string[12];

Globally unique identifier

TShortMessage = string[127];

 

TShortName = string[31];

 

TSingleArray = array of Single;

 

TSingleBuffer = array[0..$0FFFFFFF] of Single;

 

TSmallintBuffer = array[0..$0FFFFFFF] of Smallint;

 

TStringArray = array of String;

 

TTimeUnit = Double;

Type for time values

TUV = packed record U, V, W, H: Single; end;

Rectangular area within a bitmap (texture)

TUVArray = array[0..$FFFFFF] of TUV;

 

TUVMap = ^TUVArray;

 

TVector2s = packed record case Integer of 0: (X, Y: Single); 1: (V: array[0..1] of Single); end;

Two-dimensional vector

TVector3s = packed record case Integer of 0: (X, Y, Z: Single); 1: (V: array[0..2] of Single); end;

Three-dimensional vector

TVector4s = packed record case Integer of 0: (X, Y, Z, W: Single); 1: (V: array[0..3] of Single); 2: (xyz: TVector3s); end;

Four-dimensional (homogeneous) vector

TWordBuffer = array[0..$0FFFFFFF] of Word;

 

Enumerations

TMessageFlag
Message flag
 mfInvalidMessage has been handled or discarded. No need to handle it anymore.
 mfRecipientMessage has a recipient
 mfChildsMessage is a notification message from parent to immediate childs
 mfBroadcastMessage is a broadcasted message from some item down through hierarchy
 mfCoreMessage's destination is core handle
 mfAsyncMessage is asyncronous

Constants

Overview

BitsInByte = 8;
clBlack4s : TColor4s = (R: 0; G: 0; B: 0; A: 0);
clWhite4s : TColor4s = (R: 1; G: 1; B: 1; A: 1);
DefaultUV : TUV = (U: 0; V: 0; W: 1; H: 1);
DegToRad = pi/180;
epsilon = 0.0001;
MaxFloatValue = 3.4e+38;
MaxInt16 : Int16 = $7FFF;
MaxInt32 : Int32 = $7FFFFFFF;
MaxInt8 : Int8 = $7F;
MaxNat16 : Nat16 = $FFFF;
MaxNat32 : Nat32 = $FFFFFFFF;
MaxNat8 : Nat8 = $FF;
MaxPadeg = 6;
MinInt16 : Int16 = -$8000;
MinInt32 : Int32 = -$7FFFFFFF-1;
MinInt8 : Int8 = -$80;
NullSignature : TFileSignature = (#0, #0, #0, #0);
RadToDeg = 180/pi;

Description

BitsInByte = 8;

 

clBlack4s : TColor4s = (R: 0; G: 0; B: 0; A: 0);

Floating point color black

clWhite4s : TColor4s = (R: 1; G: 1; B: 1; A: 1);

Floating point color black

DefaultUV : TUV = (U: 0; V: 0; W: 1; H: 1);

Default area on image

DegToRad = pi/180;

 

epsilon = 0.0001;

 

MaxFloatValue = 3.4e+38;

 

MaxInt16 : Int16 = $7FFF;

-$80000000

MaxInt32 : Int32 = $7FFFFFFF;

Max and mins for signed

MaxInt8 : Int8 = $7F;

 

MaxNat16 : Nat16 = $FFFF;

 

MaxNat32 : Nat32 = $FFFFFFFF;

Max for unsigned

MaxNat8 : Nat8 = $FF;

 

MaxPadeg = 6;

 

MinInt16 : Int16 = -$8000;

 

MinInt32 : Int32 = -$7FFFFFFF-1;

 

MinInt8 : Int8 = -$80;

 

NullSignature : TFileSignature = (#0, #0, #0, #0);

 

RadToDeg = 180/pi;

 

Last modified: Jan 6, 2010
Copyright (C) 2006-2010, casteng.com