⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oxnewtonbsp.pas

📁 Newton Game Dynamic 1.52 Delphi下基于GLScene的OpenGL游戏开发控件。功能非常强大和易于使用。 Advanced physics engine for re
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{.$DEFINE OXNEWTON} // currently do nothing
unit oxNewtonBSP;
{ Newton Game Dynamics SDK License Version 1.55
  Copyright 2003-2006 Newton Game Dynamics. All rights reserved.

  LIMITED WARRANTY
  This software is provided "as-is", without any express or implied warranty.
  In no event shall the author be held liable for any damages arising from the use of this software.
  This is a contract. By accepting the Newton Game Dynamics SDK (the SOFTWARE),
  you (either an individual or a single entity, the LICENSEE) accept the terms and conditions of this licensing agreement.

  If the LICENSEE does not accept the terms and conditions, then LICENSEE must not accept the SOFTWARE.
  If at a later time the LICENSEE decides not to continue licensing the SOFTWARE under these terms and
  conditions, then the LICENSEE must delete permanently all files constituting the SOFTWARE.

  LICENSE AGREEMENT
  Newton Game Dynamics Limited grants to the LICENSEE and the LICENSEE hereby accepts a perpetual
  nontransferable and nonexclusive license to use and distribute the SOFTWARE, for any purpose.
  In addition, the following conditions apply:

  1) The LICENSEE may not use the SOFTWARE to reverse engineer the computer algorithm used by the SOFTWARE.
  2) The origin of the SOFTWARE must not be misrepresented; If the LICENSEE uses the SOFTWARE to distribute
     a product, the LICENSEE must not claim that He or She wrote the original SOFTWARE.
  3) The LICENSEE agrees to credit the use of the Newton Game Dynamics in any program information,
     including credit screens, "About" dialogs, program notes or instructions and shrink-wrapped packaging.
  4) The LICENSEE may not redistribute the SOFTWARE, except as part of a compiled software program that is
     not itself a physics library.
  5) The LICENSEE agrees to notify www.newtondynamics.com of any products, commercial, shareware or free
     that incorporate the Newton Game Dynamics technology.

  Julio Jerez and Alain Suero
  http://www.newtondynamics.com }

// next license part...

{**
    This part is added by Dave Gravel in repect with the author condition...
    Thanks for this code...
    //
    Hash Library

    Original Author:     Ciaran McCreesh <keesh@users.sf.net>
    Copyright:           Copyright (c) 2002 Ciaran McCreesh
    Date:                20020621
    Purpose:             A collection of hash components for Delphi. These are
                         similar to arrays, but the index is a string. A hashing
                         algorithm is used to provide extremely fast searching.

    Generic Moan:        This would be a lot easier if Delphi had template
                         classes. If anyone at Borland / Inprise / whatever
                         you're calling yourselves this week reads this, let me
                         know how much I have to bribe you.
    License:
      This library is Copyright (c) 2002 Ciaran McCreesh.
      Permission is granted to anyone to use this software for any purpose on
      any computer system, and to redistribute it freely, subject to the
      following restrictions:

      1. This software 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.

      2. The origin of this software must not be misrepresented.

      3. Altered versions must be plainly marked as such, and must not be
         misrepresented as being the original software.

    Documentation:
      Please see:
        * http://www.opensourcepan.co.uk/libraries/hashes/
        * http://www.undu.com/articles/020604.html

    Other notes:
      This unit provides three hashes, TIntegerHash, TStringHash and
      TObjectHash. If you want a more precise kind (eg TComponentHash), it's
      easiest to descend from THash and copy the TObjectHash code. Note that
      TObjectHash is slightly different from TIntegerHash and TStringHash
      because it has to free items -- it cannot just overwrite them.

    Internal data representation:
      Each hash object has an array (potentially dynamically sized, but this
      isn't used yet) of 'buckets' (dynamic arrays). Each bucket is mapped
      to a series of hash values (we take the high order bits of the value
      calculated), so that every possible hash value refers to exactly one
      bucket. This reduces the amount of searching that has to be done to
      find an item, so it's much faster than linear or B-Tree storage.

      Each bucket contains a series of integers. These are indexes into an
      items array, which for type reasons is maintained by the descendant
      classes. These are recycled when the hash detects that it is becoming
      inefficient.
}
{
   The Unofficial Newsletter of Delphi Users - Issue #8 - October 10th, 1995
   Delphi QSort Source Code
}
{
   oxNewton v1.48 GLScene Component simple demo write by Dave Gravel
   http://www.dave.serveusers.com
   This demo is only build to test my oxNewton Component.
}
interface
uses
     // Windows
     Forms, Windows, Classes, Messages, SysUtils, Graphics, Controls, ExtCtrls,
     Dialogs, StdCtrls,
     // GLScene
     GLScene, GLMisc, GLObjects, VectorLists,
     PersistentClasses, OpenGL1x, GLMesh, GLState, XCollection,
     GLGeomObjects, XOpenGL, VectorTypes, GLCrossPlatform,
     TGA, JPEG, GLTexture, fmod, fmodtypes,
     fmodpresets, fmoderrors, fmoddyn,
     // Newton
     NewtonImport, oxNewtonManager, oxNewtonUtils;
{******************************************************************************}
 // [09/05/07]: TOXNewtonStaBSP last change by Dave Gravel.
{******************************************************************************}
const
  // here i using ox tag only to make sure this unit don't make conflic with others...
  oxM_PI                   = 3.1415926535897932384626433832795;
  oxM_TWO_PI               = 6.283185307179586476925286766559;
  oxM_180_PI               = 57.295779513082320876798154814105;
  oxM_PI_180               = 0.017453292519943295769236907684886;
  oxc_HashInitialItemShift = 7;
  oxc_HashCompactR         = 2;
  oxc_HashCompactM         = 100;
  oxFACE_POLYGON           = 1;
  oxFACE_PATCH             = 2;
  oxFACE_MESH              = 3;
  oxFACE_BILLBOARD         = 4;
  oxQ3_FRONT               = 0;
  oxQ3_BACK                = 1;
  oxFIRST_OBJECT_ID        = 3;
  oxRIGHT	           = 0;
  oxLEFT	           = 1;
  oxBOTTOM                 = 2;
  oxTOP  	           = 3;
  oxBACK                   = 4;
  oxFRONT	           = 5;
  oxA                      = 0;
  oxB                      = 1;
  oxC                      = 2;
  oxD                      = 3;
  oxDIST_EPSILON           = 1/32;
  oxRad                    = Pi / 180.0;
  oxSKY_SEQGS: integer     = 180;
  oxCONTENTS_SOLID         = 1;
  oxCONTENTS_WINDOW        = 2;
  oxCONTENTS_AUX           = 4;
  oxCONTENTS_LAVA          = 8;
  oxCONTENTS_SLIME         = 16;
  oxCONTENTS_WATER         = 32;
  oxCONTENTS_FOG           = 64;
  oxLAST_VISIBLE_CONTENTS  = 64;
  oxCONTENTS_AREAPORTAL    = $8000;
  oxCONTENTS_PLAYERCLIP    = $10000;
  oxCONTENTS_MONSTERCLIP   = $20000;
  oxCONTENTS_TELEPORTER    = $40000;
  oxCONTENTS_JUMPPAD       = $80000;
  oxCONTENTS_CLUSTERPORTAL = $100000;
  oxCONTENTS_DONOTENTER    = $200000;
  oxCONTENTS_BOTCLIP       = $400000;
  oxCONTENTS_MOVER         = $800000;
  oxCONTENTS_ORIGIN        = $1000000;
  oxCONTENTS_BODY          = $2000000;
  oxCONTENTS_DEADMONSTER   = $4000000;
  oxCONTENTS_DETAIL        = $8000000;
  oxCONTENTS_STRUCTURAL    = $10000000;
  oxCONTENTS_TRANSLUCENT   = $20000000;
  oxCONTENTS_LADDER        = $20000000;
  oxCONTENTS_NODROP        = $80000000;
  oxSURF_NODAMAGE	   = $1;
  oxSURF_SLICK	           = $2;
  oxSURF_SKY		   = $4;
  oxSURF_LADDER	           = $8;
  oxSURF_NOIMPACT	   = $10;
  oxSURF_NOMARKS	   = $20;
  oxSURF_FLESH	           = $40;
  oxSURF_NODRAW	           = $80;
  oxSURF_HINT		   = $100;
  oxSURF_SKIP		   = $200;
  oxSURF_NOLIGHTMAP	   = $400;
  oxSURF_POINTLIGHT        = $800;
  oxSURF_METALSTEPS	   = $1000;
  oxSURF_NOSTEPS	   = $2000;
  oxSURF_NONSOLID	   = $4000;
  oxSURF_LIGHTFILTER	   = $8000;
  oxSURF_ALPHASHADOW	   = $10000;
  oxSURF_NODLIGHT	   = $20000;                                                               
  oxSURF_DUST		   = $40000;
  oxMASK_PLAYERSOLID       = ( oxCONTENTS_SOLID + oxCONTENTS_PLAYERCLIP + oxCONTENTS_WINDOW + oxCONTENTS_BODY );
  oxMASK_PLAYERNOSOLID     = ( oxCONTENTS_LAVA + oxCONTENTS_SLIME + oxCONTENTS_WATER );

var skyboxId: integer = -1;
type enSortKey = ( SS_BAD = 0, SS_PORTAL = 1, SS_ENVIRONMENT = 2, SS_OPAQUE = 3,
                   SS_DECAL = 4, SS_SEE_THROUGH = 5, SS_BANNER = 6, SS_FOG = 7,
                   SS_UNDERWATER = 8, SS_BLEND0 = 9, SS_BLEND1 = 10, SS_BLEND2 = 11,
                   SS_BLEND3 = 12, SS_BLEND6 = 13, SS_STENCIL_SHADOW = 14, SS_ALMOST_NEAREST = 15,
                   SS_NEAREST = 16 );
type ENTCGEN = ( TCGEN_BAD = 0, TCGEN_IDENTITY = 1, TCGEN_LIGHTMAP = 2, TCGEN_TEXTURE = 3, TCGEN_ENVIRONMENT_MAPPED = 4, TCGEN_FOG = 5, TCGEN_VECTOR = 6 );
type ENRGBGEN = ( RGBGEN_IDENTITYLIGHTNING = 0, RGBGEN_IDENTITY = 1, RGBGEN_WAVE = 2, RGBGEN_ENTITY = 3, RGBGEN_ONEMINUSENTITY = 4,
                  RGBGEN_VERTEX = 5, RGBGEN_ONEMINUSVERTEX = 6, RGBGEN_LIGHTNINGDIFFUSE = 7, RGBGEN_FOG = 8 );
type ENTCMOD = ( TCMOD_UNUSED = 0, TCMOD_ROTATE = 1, TCMOD_SCALE = 2, TCMOD_SCROLL = 3, TCMOD_STRETCH = 4, TCMOD_TRANSFORM = 5, TCMOD_TURB = 6 );
type ENWAVE = ( GF_NONE = 0, GF_SIN = 1, GF_SQUARE = 2, GF_TRIANGLE = 3, GF_SAWTOOTH = 4, GF_INVERSE_SAWTOOTH = 5, GF_NOISE = 6 );
type ENDEFORMTYPE = ( DEFORMVERTEXES_NONE = 0,
                      DEFORMVERTEXES_WAVE = 1,
                      DEFORMVERTEXES_NORMAL= 2,
                      DEFORMVERTEXES_BULGE = 3,
                      DEFORMVERTEXES_MOVE = 4,
                      DEFORMVERTEXES_AUTOSPRITE	= 5,
                      DEFORMVERTEXES_AUTOSPRITE2 = 6 );
{******************************************************************************}
 // [09/05/07]: TOXNewtonStaBSP last change by Dave Gravel.
{******************************************************************************}
type
  EHashError = class( Exception );
  EHashErrorClass = class of EHashError;
  EHashFindError = class( EHashError );
  EHashIterateError = class( EHashError );
  EHashInvalidKeyError = class( EHashError );
{******************************************************************************}
 // [09/05/07]: TOXNewtonStaBSP last change by Dave Gravel.
{******************************************************************************}
  THashRecord = record
    Hash: Cardinal;
    ItemIndex: integer;
    Key: string;
  end;
{******************************************************************************}
 // [09/05/07]: TOXNewtonStaBSP last change by Dave Gravel.
{******************************************************************************}
  THashIterator = record
    ck, cx: integer;
  end;
{******************************************************************************}
 // [09/05/07]: TOXNewtonStaBSP last change by Dave Gravel.
{******************************************************************************}
  THash = class
    protected
      f_Keys: array of array of THashRecord;
      f_CurrentItemShift: integer;
      f_CurrentItemCount: integer;
      f_CurrentItemMask: integer;
      f_CurrentItemMaxIdx: integer;
      f_SpareItems: array of integer;
      f_NextAllowed: boolean;
      f_CurrentKey: string;
      f_AllowCompact: boolean;
      f_CurrentIterator: THashIterator;
      procedure FUpdateMasks;
      procedure FUpdateBuckets;
      function FFindKey( const Key: string; var k, x: integer ): boolean;
      procedure FSetOrAddKey( const Key: string; ItemIndex: integer );
      procedure FDeleteIndex( i: integer ); virtual; abstract;
      function FGetItemCount: integer;
      function FAllocItemIndex: integer;
      procedure FMoveIndex( oldIndex, newIndex: integer ); virtual; abstract;
      procedure FTrimIndexes( count: integer ); virtual; abstract;
      procedure FClearItems; virtual; abstract;
      function FIndexMax: integer; virtual; abstract;
      procedure FAutoCompact;
    public
      constructor Create; reintroduce; virtual;
      function Exists( const Key: string ): boolean;
      procedure Rename( const Key, NewName: string );
      procedure Delete( const Key: string );
      procedure Restart;
      function Next: boolean;
      function Previous: boolean;
      function CurrentKey: string;
      property ItemCount: integer read FGetItemCount;
      procedure Compact;
      procedure Clear;
      property AllowCompact: boolean read f_AllowCompact write f_AllowCompact;
      property CurrentIterator: THashIterator read f_CurrentIterator write f_CurrentIterator;
      function NewIterator: THashIterator;
    end;
{******************************************************************************}
 // [09/05/07]: TOXNewtonStaBSP last change by Dave Gravel.
{******************************************************************************}
    TStringHash = class( THash )
      protected
        f_Items: array of string;
        procedure FDeleteIndex( i: integer ); override;
        function FGetItem( const Key: string ): string;
        procedure FSetItem( const Key, Value: string );
        procedure FMoveIndex( oldIndex, newIndex: integer ); override;
        procedure FTrimIndexes( count: integer ); override;
        procedure FClearItems; override;
        function FIndexMax: integer; override;
      public
        property Items[const Key: string]: string read FGetItem write FSetItem; default;
    end;
{******************************************************************************}
 // [09/05/07]: TOXNewtonStaBSP last change by Dave Gravel.
{******************************************************************************}
    TIntegerHash = class( THash )
      protected
        f_Items: array of integer;
        procedure FDeleteIndex( i: integer ); override;
        function FGetItem( const Key: string ): integer;
        procedure FSetItem( const Key: string; Value: integer );
        procedure FMoveIndex( oldIndex, newIndex: integer ); override;
        procedure FTrimIndexes( count: integer ); override;
        procedure FClearItems; override;
        function FIndexMax: integer; override;
      public
        property Items[const Key: string]: integer read FGetItem write FSetItem; default;
    end;
{******************************************************************************}
 // [09/05/07]: TOXNewtonStaBSP last change by Dave Gravel.
{******************************************************************************}
    TObjectHash = class( THash )
      protected
        f_Items: array of TObject;
        procedure FDeleteIndex( i: integer ); override;
        function FGetItem( const Key: string ): TObject;
        procedure FSetItem( const Key: string; Value: TObject );
        procedure FMoveIndex( oldIndex, newIndex: integer ); override;
        procedure FTrimIndexes( count: integer ); override;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -