UFO: Alien Invasion
Loading...
Searching...
No Matches
ufomodel.cpp File Reference

Starting point for model tool. More...

Include dependency graph for ufomodel.cpp:

Go to the source code of this file.

Data Structures

struct  modelConfig_t

Macros

#define QGL_EXTERN
#define VERSION   "0.2"

Typedefs

typedef void(*) modelWorker_t(const byte *bufbuf, const char *fileName, int bufSize, void *userData)

Enumerations

enum  ufoModelAction_t {
  ACTION_NONE , ACTION_MDX , ACTION_SKINEDIT , ACTION_SKINNUM ,
  ACTION_CHECK , ACTION_INFO , ACTION_SKINFIX , ACTION_GLCMDSREMOVE
}

Functions

static void Exit (int exitCode) __attribute__((__noreturn__))
void Com_Printf (const char *format,...)
void Com_DPrintf (int level, const char *fmt,...)
image_t * R_LoadImageData (const char *name, const byte *pic, int width, int height, imagetype_t type)
 Creates a new image from RGBA data. Stores it in the gltextures array and also uploads it.
image_t * R_FindImage (const char *pname, imagetype_t type)
 Finds or loads the given image.
void Com_Error (int code, const char *fmt,...)
static model_t * LoadModel (const char *name)
 Loads in a model for the given name.
static void WriteToFile (const model_t *mod, const mAliasMesh_t *mesh, const char *fileName)
static int PrecalcNormalsAndTangents (const char *filenamefilename)
static void PrecalcNormalsAndTangentsBatch (const char *pattern)
static void Usage (void)
static void UM_DefaultParameter (void)
static void UM_Parameter (int argc, char **argv)
 Parameter parsing.
static void ModelWorker (modelWorker_t worker, const char *fileName, void *userData)
 The caller has to ensure that the model is from the expected format.
static void MD2SkinFix (const byte *bufbuf, const char *fileName, int bufSize, void *userData)
static void MD2Check (const byte *bufbuf, const char *fileName, int bufSize, void *userData)
static void MD2Visitor (modelWorker_t worker, void *userData)
static void ModelCheck (void)
static void SkinFix (void)
static void GLCmdsRemove (void)
void R_ReallocateStateArrays (int sizesize)
 Reallocate arrays of GL primitives if needed.
void R_ReallocateTexunitArray (gltexunit_t *texunit, int sizesize)
 Reallocate texcoord array of the specified texunit, if needed.
int main (int argc, char **argv)

Variables

rstate_t r_state
image_t * r_noTexture
static modelConfig_t config
memPool_t * com_genericPool
memPool_t * com_fileSysPool
memPool_t * vid_modelPool
memPool_t * vid_lightPool
memPool_t * vid_imagePool

Detailed Description

Starting point for model tool.

Definition in file ufomodel.cpp.

Macro Definition Documentation

◆ QGL_EXTERN

#define QGL_EXTERN

Definition at line 32 of file ufomodel.cpp.

◆ VERSION

#define VERSION   "0.2"

Definition at line 44 of file ufomodel.cpp.

Typedef Documentation

◆ modelWorker_t

typedef void(*) modelWorker_t(const byte *buf, const char *fileName, int bufSize, void *userData)

Definition at line 395 of file ufomodel.cpp.

Enumeration Type Documentation

◆ ufoModelAction_t

Enumerator
ACTION_NONE 
ACTION_MDX 
ACTION_SKINEDIT 
ACTION_SKINNUM 
ACTION_CHECK 
ACTION_INFO 
ACTION_SKINFIX 
ACTION_GLCMDSREMOVE 

Definition at line 49 of file ufomodel.cpp.

Function Documentation

◆ Com_DPrintf()

void Com_DPrintf ( int level,
const char * fmt,
... )

Definition at line 99 of file ufomodel.cpp.

References Com_DPrintf(), Com_Printf(), config, level, Q_vsnprintf(), and mapConfig_t::verbose.

◆ Com_Error()

void Com_Error ( int code,
const char * fmt,
... )
Note
Both client and server can use this, and it will do the appropriate things.

Definition at line 172 of file ufomodel.cpp.

References Com_Error(), Exit(), and Q_vsnprintf().

◆ Com_Printf()

void Com_Printf ( const char * format,
... )

Definition at line 87 of file ufomodel.cpp.

References Com_Printf(), format(), and Q_vsnprintf().

◆ Exit()

void Exit ( int exitCode)
static

Definition at line 80 of file ufomodel.cpp.

References Exit(), and Mem_Shutdown().

Referenced by Com_Error(), Exit(), main(), and UM_Parameter().

◆ GLCmdsRemove()

void GLCmdsRemove ( void )
static

Definition at line 556 of file ufomodel.cpp.

References Com_Printf(), GLCmdsRemove(), MD2GLCmdsRemove(), MD2Visitor(), and UFO_SIZE_T.

Referenced by GLCmdsRemove(), and main().

◆ LoadModel()

model_t * LoadModel ( const char * name)
static

Loads in a model for the given name.

Parameters
[in]nameFilename relative to base dir and with extension (models/model.md2)

Definition at line 189 of file ufomodel.cpp.

References Com_Error(), Com_Printf(), ERR_FATAL, FS_FreeFile(), FS_LoadFile(), IDALIASHEADER, IDMD3HEADER, LittleLong, LoadModel(), Mem_PoolAllocType, model_t::name, name, Q_strcasecmp, Q_strncpyz(), R_LoadObjModel(), R_ModLoadAliasMD2Model(), R_ModLoadAliasMD3Model(), and vid_modelPool.

Referenced by LoadModel(), and PrecalcNormalsAndTangents().

◆ main()

◆ MD2Check()

void MD2Check ( const byte * buf,
const char * fileName,
int bufSize,
void * userData )
static

◆ MD2SkinFix()

◆ MD2Visitor()

void MD2Visitor ( modelWorker_t worker,
void * userData )
static

◆ ModelCheck()

void ModelCheck ( void )
static

Definition at line 546 of file ufomodel.cpp.

References MD2Check(), MD2Visitor(), and ModelCheck().

Referenced by main(), and ModelCheck().

◆ ModelWorker()

void ModelWorker ( modelWorker_t worker,
const char * fileName,
void * userData )
static

The caller has to ensure that the model is from the expected format.

Parameters
workerThe worker callback
fileNameThe file name of the model to load
userDataUser data that is passed to the worker function

Definition at line 403 of file ufomodel.cpp.

References Com_Error(), ERR_DROP, ERR_FATAL, FS_FreeFile(), FS_LoadFile(), IDALIASHEADER, IDBSPHEADER, IDMD3HEADER, LittleLong, ModelWorker(), and Q_strcasecmp.

Referenced by main(), MD2Visitor(), and ModelWorker().

◆ PrecalcNormalsAndTangents()

int PrecalcNormalsAndTangents ( const char * filename)
static

◆ PrecalcNormalsAndTangentsBatch()

void PrecalcNormalsAndTangentsBatch ( const char * pattern)
static

◆ R_FindImage()

image_t * R_FindImage ( const char * pname,
imagetype_t type )

Finds or loads the given image.

See also
R_RegisterImage
Parameters
[in]pnameImage name Path relative to the game dir (e.g. textures/tex_common/nodraw)
[in]typeThe type of the image. This has influence on image filters and texture parameters when uploading the image data
Note
the image name has to be at least 5 chars long
See also
R_LoadTGA
R_LoadJPG
R_LoadPNG
Todo
should also check the mipmapping

Definition at line 140 of file ufomodel.cpp.

References Com_Error(), Com_Printf(), Com_StripExtension(), ERR_FATAL, Img_LoadImage(), MAX_QPATH, R_FindImage(), R_LoadImageData(), r_noTexture, and type.

◆ R_LoadImageData()

image_t * R_LoadImageData ( const char * name,
const byte * pic,
int width,
int height,
imagetype_t type )

Creates a new image from RGBA data. Stores it in the gltextures array and also uploads it.

Note
This is also used as an entry point for the generated r_noTexture
Parameters
[in]nameThe name of the newly created image
[in]picThe RGBA data of the image
[in]widthThe width of the image (power of two, please)
[in]heightThe height of the image (power of two, please)
[in]typeThe image type
See also
imagetype_t
Todo
Instead of this hack, unit tests' build should link to the dummy GL driver

Definition at line 113 of file ufomodel.cpp.

References Com_Error(), Com_Printf(), ERR_DROP, image_t::has_alpha, image_t::height, len, Mem_PoolAllocType, image_t::name, name, Q_strncpyz(), R_LoadImageData(), image_t::type, type, vid_imagePool, and image_t::width.

◆ R_ReallocateStateArrays()

void R_ReallocateStateArrays ( int size)

Reallocate arrays of GL primitives if needed.

Parameters
sizeThe new array size
Note
Also resets all non-default GL array bindings
See also
R_ReallocateTexunitArray

Definition at line 563 of file ufomodel.cpp.

References rstate_t::array_size, rstate_t::color_array, Mem_SafeReAlloc, rstate_t::next_normal_array, rstate_t::next_tangent_array, rstate_t::next_vertex_array_3d, rstate_t::normal_array, R_ReallocateStateArrays(), r_state, rstate_t::tangent_array, rstate_t::vertex_array_2d, and rstate_t::vertex_array_3d.

◆ R_ReallocateTexunitArray()

void R_ReallocateTexunitArray ( gltexunit_t * texunit,
int size )

Reallocate texcoord array of the specified texunit, if needed.

Parameters
texunitPointer to texunit (TODO: remove this comment as obvious and redundant)
sizeThe new array size
Note
Also resets active texunit
See also
R_ReallocateStateArrays

Definition at line 579 of file ufomodel.cpp.

References rstate_t::active_texunit, gltexunit_t::array_size, Mem_SafeReAlloc, R_ReallocateTexunitArray(), r_state, and gltexunit_t::texcoord_array.

◆ SkinFix()

void SkinFix ( void )
static

Definition at line 551 of file ufomodel.cpp.

References MD2SkinFix(), MD2Visitor(), and SkinFix().

Referenced by main(), and SkinFix().

◆ UM_DefaultParameter()

void UM_DefaultParameter ( void )
static

Definition at line 327 of file ufomodel.cpp.

References config, and UM_DefaultParameter().

Referenced by main(), and UM_DefaultParameter().

◆ UM_Parameter()

void UM_Parameter ( int argc,
char ** argv )
static

◆ Usage()

void Usage ( void )
static

Definition at line 310 of file ufomodel.cpp.

References Com_Printf(), and Usage().

◆ WriteToFile()

void WriteToFile ( const model_t * mod,
const mAliasMesh_t * mesh,
const char * fileName )
static

Variable Documentation

◆ com_fileSysPool

memPool_t* com_fileSysPool

Definition at line 73 of file ufomodel.cpp.

◆ com_genericPool

memPool_t* com_genericPool

Definition at line 72 of file ufomodel.cpp.

◆ config

modelConfig_t config
static

Definition at line 70 of file ufomodel.cpp.

◆ r_noTexture

◆ r_state

rstate_t r_state

Definition at line 46 of file ufomodel.cpp.

◆ vid_imagePool

memPool_t* vid_imagePool

Definition at line 76 of file ufomodel.cpp.

◆ vid_lightPool

memPool_t* vid_lightPool

lightmap - wiped with every new map

Definition at line 75 of file ufomodel.cpp.

◆ vid_modelPool

memPool_t* vid_modelPool

modeldata - wiped with every new map

Definition at line 74 of file ufomodel.cpp.