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

📄 gl_model_h.pas

📁 雷神之锤2(Quake2)Delphi源码
💻 PAS
字号:
{----------------------------------------------------------------------------}
{                                                                            }
{ File(s): gl_model.h                                                        }
{                                                                            }
{ Initial conversion by : osamaao                                            }
{ Initial conversion on : 14-Jan-2002                                        }
{                                                                            }
{ This File contains part of convertion of Quake2 source to ObjectPascal.    }
{ More information about this project can be found at:                       }
{ http://www.sulaco.co.za/quake2/                                            }
{                                                                            }
{ Copyright (C) 1997-2001 Id Software, Inc.                                  }
{                                                                            }
{ 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 2             }
{ of the License, or (at your option) any later version.                     }
{                                                                            }
{ This program 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.                       }
{                                                                            }
{ See the GNU General Public License for more details.                       }
{                                                                            }
{----------------------------------------------------------------------------}
{ Updated on : 27/07/2002                                                    }
{ Updated by : Fabrizio Rossini  rossini.f@libero.it                         }
{ Added USES clause ,fixed some var declaration from Double to Single        }
{ Copied from GL_Local.pas the Image_s RECORD declaration to avoid circular  }
{ use of unit in delphi                                                      }
{----------------------------------------------------------------------------}
{ * Still dependent (to compile correctly) on:                               }
{ Q_Shared , QFiles                                                          }
{----------------------------------------------------------------------------}
{ * TODO:                                                                    }
{ none                                                                       }
{----------------------------------------------------------------------------}


(*/*

d*_t structures are on-disk representations
m*_t structures are in-memory

*/*)


{==============================================================================

BRUSH MODELS

==============================================================================}




unit gl_model_h;

interface
uses q_shared,QFiles ; // added by {FAB}

const
  SIDE_FRONT          = 0;
  SIDE_BACK           = 1;
  SIDE_ON             = 2;

  SURF_PLANEBACK      =	2;
  SURF_DRAWSKY	      =	4;
  SURF_DRAWTURB	      =	$10;
  SURF_DRAWBACKGROUND =	$40;
  SURF_UNDERWATER     =	$80;

  VERTEXSIZE          = 7;


//type

//  begin dummy

  //position = Integer;
  {
  Vec3_t   = Integer;
  Image_t  = Integer;
  Image_p  = Integer;
  cPlane_t = Integer;
  cPlane_p = Integer;
  dvis_p   = Integer;
  }
    const
  MAXLIGHTMAPS = 10; // comment this 3 lines when all conversion is done
  MAX_QPATH    = 10; //  is a dummy declarations only 
  MAX_MD2SKINS = 10; //
//  end dummy


type
////////////////////// copied from gl_local  // by {FAB}

imagetype_t = (it_skin, it_sprite, it_wall, it_pic, it_sky);

  image_s = record
    name  : array [0..MAX_QPATH-1] of char;  // game path, including extension
    type_ : imagetype_t;
    width, height,			     // source image
    upload_width, upload_height,             // after power of two and picmip
    registration_sequence        : integer;  // 0 = free

//	struct msurface_s	*texturechain;	// for sort-by-texture world drawing
//    texturechain : msurface_p;  // for sort-by-texture world drawing
   
    texturechain : Pointer {to msurface_p}; // changed by {FAB} 

    texnum : integer;						// gl texture binding
    sl, tl, sh, th : Single;   		     // 0,0 - 1,1 unless part of the scrap
    scrap,
    has_alpha,
    paletted  : qboolean;
  end;

  image_t = image_s;

  image_p = ^image_t;
//////////////////////////////////////// end of copy {FAB}


//
// in memory representation
//
// !!! if this is changed, it must be changed in asm_draw.h too !!!

  qBoolean = Boolean;
  
  mVertex_p = ^mVertex_t;
  mVertex_t = record
    //Vec3_t: Position;  // fixed by {FAB}
    Position :vec3_t;
  end;

  mModel_p = ^mModel_t;
  mModel_t = record
    Mins     : Vec3_t;
    Maxs     : Vec3_t;
    Origin   : Vec3_t;	        	// for sounds or lights
    Radius   : Single ;                 //was Double; changed by {FAB}
    HeadNode : Integer;
    VisLeafs : Integer;       		// not including the solid leaf 0
    FirstFace: Integer;
    NumFaces : Integer;
  end;


// !!! if this is changed, it must be changed in asm_draw.h too !!!
  mEdge_p = ^mEdge_t;
  mEdge_t = record
    V               : array[0..1] of Word;
    CachedEdgeOffset: Cardinal;
  end;


  mTexInfo_p = ^mtexInfo_s;
  mTexInfo_s = record
    Vecs     : array[0..1, 0..3] of Single; // was Double {FAB}
    Flags    : Integer;
    NumFrames: Integer;
    Next     : mTexInfo_p;			// animation chain
    Image    : Image_p;
  end;

  mTexInfo_t = mTexInfo_s;


  glPoly_p = ^glPoly_s;
  glPoly_s = record
    Next    : glPoly_p;
    Chain   : glPoly_p;
    NumVerts: Integer;
    Flags   : Integer;			// for SURF_UNDERWATER (not needed anymore?)
    Verts   : array[0..3, 0..VERTEXSIZE - 1] of Single;	// variable sized (xyz s1t1 s2t2)
  end;

  glpoly_t = glpoly_s;


  
  mSurface_p = ^mSurface_s;
  mSurface_s = record
    visFrame          : Integer;         // should be drawn when node is crossed
    Plane             : cPlane_p;
    Flags             : Integer;
    FirstEdge         : Integer;         // look up in model->surfedges[], negative numbers
    NumEdges          : Integer;         // are backwards edges
    TextureMins       : array[0..1] of SmallInt;
    Extents           : array[0..1] of	SmallInt;
    Light_s           : Integer;
    Light_t           : Integer;	// gl lightmap coordinates
    dLight_s          : Integer;
    dLight_t          : Integer;        // gl lightmap coordinates for dynamic lightmaps
    Polys             : glPoly_p;	// multiple if warped
    TextureChain      : mSurface_p;
    LightMapChain     : mSurface_p;
    TexInfo           : mtexinfo_p;
    // lighting info
    dLightFrame       : Integer;
    dLightBits        : Integer;
    LightMapTextureNum: Integer;

    Styles      : array [0..MAXLIGHTMAPS - 1] of Byte;
    Cached_Light: array [0..MAXLIGHTMAPS - 1] of Single;	// values currently used in lightmap
    Samples     : PByte;		// [numstyles*surfsize]
  end;

  mSurface_t = mSurface_s;


  mNode_p = ^mNode_s;
  mNode_s = record
    // common with leaf
    Contents    : Integer;		        // -1, to differentiate from leafs
    visFrame    : Integer;		        // node needs to be traversed if current
    MinMaxs     : array[0..5] of Single;	// for bounding box culling
    Parent      : mNode_p;
    // node specific
    Plane       : cPlane_p;
    Children    : array[0..1] of mNode_p;
    FirstSurface: Word;
    NumSurfaces : Word;
  end;

  mNode_t = mNode_s;


  mLeaf_p = ^mLeaf_s;
  mLeaf_s = record
    // common with node
    Contents        : Integer;	        	// wil be a negative contents number
    visFrame        : Integer;		        // node needs to be traversed if current
    MinMaxs         : array[0..5] of Single;	// for bounding box culling
    Parent          : mNode_p;
    // leaf specific
    Cluster         : Integer;
    Area            : Integer;
    FirstMarkSurface: ^mSurface_p;
    NumMarkSurfaces : Integer;
  end;

  mLeaf_t = mLeaf_s;

//
// Whole model
//

  modType_t = (mod_bad, mod_brush, mod_sprite, mod_alias);


  Model_p = ^Model_s;
  Model_s = record
    Name                 : array [0..MAX_QPATH-1] of char; //string[MAX_QPATH]; fixed by fab 
    Registration_Sequence: Integer;
    _Type                : modType_t;
    NumFrames            : Integer;
    Flags                : Integer;
    //
    // volume occupied by the model graphics
    //
    Mins, Maxs           : Vec3_t;
    Radius               :Single;
    //
    // solid volume for clipping
    //
    ClipBox              :qBoolean;
    ClipMins, ClipMaxs   : Vec3_t;
    //
    // brush model
    //
    FirstModelSurface    : Integer; 
    NumModelSurfaces     : Integer;
    LightMap             : Integer;		// only for submodels

    NumSubModels         : Integer;
    SubModels            : mmodel_p;

    NumPlanes            : Integer;
    Planes               : cPlane_p;

    NumLeafs             : Integer;		// number of visible leafs, not counting 0
    Leafs                : mLeaf_p;

    NumVertexes          : Integer;
    vertexes             : mVertex_p;

    NumEdges             : Integer;
    Edges                : medge_p;

    NumNodes             : Integer;
    FirstNode            : Integer;
    Nodes                : mNode_p;

    NumTexInfo           : Integer;
    TexInfo              : mTexInfo_p;

    NumSurfaces          : Integer;
    Surfaces             : mSurface_p;

    NumSurfEdges         : Integer;
    SurfEdges            : PInteger;

    NumMarkSurfaces      : Integer;
    MarkSurfaces         : ^msurface_p;

    vis                  : dvis_p;   // {FAB} declared in QFiles
    LightData            : PByte;

    // for alias models and skins
    Skins                : array[0..MAX_MD2SKINS - 1] of Image_p;
    ExtraDataSize        : Integer;
    ExtraData            : Pointer;
  end;

  Model_t = Model_s;

//============================================================================


(*  these are omitted declarationals.
void	Mod_Init (void);
void	Mod_ClearAll (void);
model_t *Mod_ForName (char *name, qboolean crash);
mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
byte	*Mod_ClusterPVS (int cluster, model_t *model);

void	Mod_Modellist_f (void);

void	*Hunk_Begin (int maxsize);
void	*Hunk_Alloc (int size);
int		Hunk_End (void);
void	Hunk_Free (void *base);

void	Mod_FreeAll (void);
void	Mod_Free (model_t *mod);
*)

implementation

end.

⌨️ 快捷键说明

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