|
UFO: Alien Invasion
|
Starting point for model tool. More...
#include "../../shared/ufotypes.h"#include "../../common/mem.h"#include "../../shared/shared.h"#include "../../common/filesys.h"#include "../../shared/typedefs.h"#include "../../client/renderer/r_gl.h"#include "../../client/renderer/r_material.h"#include "../../client/renderer/r_image.h"#include "../../client/renderer/r_model.h"#include "../../client/renderer/r_state.h"#include "../../shared/images.h"#include "../../common/common.h"#include "md2.h"#include <SDL_main.h>#include <cstddef>
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 *buf, 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 *filename) |
| 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 *buf, const char *fileName, int bufSize, void *userData) |
| static void | MD2Check (const byte *buf, 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 size) |
| Reallocate arrays of GL primitives if needed. | |
| void | R_ReallocateTexunitArray (gltexunit_t *texunit, int size) |
| 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 |
Starting point for model tool.
Definition in file ufomodel.cpp.
| #define QGL_EXTERN |
Definition at line 32 of file ufomodel.cpp.
| #define VERSION "0.2" |
Definition at line 44 of file ufomodel.cpp.
Definition at line 395 of file ufomodel.cpp.
| enum 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.
Definition at line 99 of file ufomodel.cpp.
References Com_Printf(), config, level, and Q_vsnprintf().
Definition at line 172 of file ufomodel.cpp.
References Exit(), and Q_vsnprintf().
Referenced by LoadModel(), ModelWorker(), PrecalcNormalsAndTangents(), R_FindImage(), and R_LoadImageData().
| void Com_Printf | ( | const char * | format, |
| ... ) |
Definition at line 87 of file ufomodel.cpp.
References format(), and Q_vsnprintf().
Referenced by Com_DPrintf(), GLCmdsRemove(), LoadModel(), main(), MD2Check(), MD2SkinFix(), PrecalcNormalsAndTangents(), PrecalcNormalsAndTangentsBatch(), R_FindImage(), R_LoadImageData(), UM_Parameter(), Usage(), and WriteToFile().
Definition at line 80 of file ufomodel.cpp.
References Mem_Shutdown().
Referenced by Com_Error(), main(), and UM_Parameter().
Definition at line 556 of file ufomodel.cpp.
References Com_Printf(), MD2GLCmdsRemove(), MD2Visitor(), and UFO_SIZE_T.
Referenced by main().
|
static |
Loads in a model for the given name.
| [in] | name | Filename 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, Mem_PoolAllocType, model_t::name, name, Q_strcasecmp, Q_strncpyz(), R_LoadObjModel(), R_ModLoadAliasMD2Model(), R_ModLoadAliasMD3Model(), and vid_modelPool.
Referenced by PrecalcNormalsAndTangents().
Definition at line 590 of file ufomodel.cpp.
References ACTION_CHECK, ACTION_GLCMDSREMOVE, ACTION_INFO, ACTION_MDX, ACTION_NONE, ACTION_SKINEDIT, ACTION_SKINFIX, ACTION_SKINNUM, com_fileSysPool, com_genericPool, Com_Printf(), config, Exit(), FS_InitFilesystem(), GLCmdsRemove(), MD2Info(), MD2SkinEdit(), MD2SkinNum(), Mem_CreatePool, Mem_Init(), Mem_PoolAllocType, Mem_Shutdown(), ModelCheck(), ModelWorker(), PrecalcNormalsAndTangents(), PrecalcNormalsAndTangentsBatch(), Q_strncpyz(), r_noTexture, SkinFix(), Swap_Init(), UM_DefaultParameter(), UM_Parameter(), Usage(), VERSION, vid_imagePool, and vid_modelPool.
Definition at line 492 of file ufomodel.cpp.
References bufSize, Com_GetExtension(), Com_Printf(), i, LittleLong, MD2_MAX_SKINNAME, MD2HeaderCheck(), name, dMD2Model_t::num_skins, dMD2Model_t::ofs_skins, R_AliasModelGetSkin(), and r_noTexture.
Referenced by ModelCheck().
Definition at line 430 of file ufomodel.cpp.
References bufSize, Com_GetExtension(), Com_Printf(), Com_SkipPath(), Com_sprintf(), Com_StripExtension(), FS_WriteFile(), i, LittleLong, MD2_MAX_SKINNAME, MD2HeaderCheck(), Mem_Dup, Mem_Free, name, dMD2Model_t::num_skins, OBJZERO, dMD2Model_t::ofs_skins, R_AliasModelGetSkin(), and r_noTexture.
Referenced by SkinFix().
|
static |
Definition at line 533 of file ufomodel.cpp.
References FS_BuildFileList(), FS_NextFileFromFileList(), and ModelWorker().
Referenced by GLCmdsRemove(), ModelCheck(), and SkinFix().
Definition at line 546 of file ufomodel.cpp.
References MD2Check(), and MD2Visitor().
Referenced by main().
|
static |
The caller has to ensure that the model is from the expected format.
| worker | The worker callback |
| fileName | The file name of the model to load |
| userData | User 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, and Q_strcasecmp.
Referenced by main(), and MD2Visitor().
|
static |
Definition at line 257 of file ufomodel.cpp.
References model_t::alias, Com_Error(), Com_Printf(), Com_StripExtension(), config, ERR_DROP, FS_CheckFile(), i, LoadModel(), MAX_QPATH, mAliasModel_t::meshes, mAliasModel_t::num_frames, mAliasModel_t::num_meshes, Q_strcat(), R_ModCalcUniqueNormalsAndTangents(), and WriteToFile().
Referenced by main(), and PrecalcNormalsAndTangentsBatch().
|
static |
Definition at line 291 of file ufomodel.cpp.
References Com_Printf(), FS_BuildFileList(), FS_NextFileFromFileList(), and PrecalcNormalsAndTangents().
Referenced by main().
| image_t * R_FindImage | ( | const char * | pname, |
| imagetype_t | type ) |
Finds or loads the given image.
| [in] | pname | Image name Path relative to the game dir (e.g. textures/tex_common/nodraw) |
| [in] | type | The type of the image. This has influence on image filters and texture parameters when uploading the image data |
Definition at line 140 of file ufomodel.cpp.
References Com_Error(), Com_Printf(), Com_StripExtension(), ERR_FATAL, Img_LoadImage(), MAX_QPATH, R_LoadImageData(), r_noTexture, and type.
| 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.
| [in] | name | The name of the newly created image |
| [in] | pic | The RGBA data of the image |
| [in] | width | The width of the image (power of two, please) |
| [in] | height | The height of the image (power of two, please) |
| [in] | type | The image type |
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(), image_t::type, type, vid_imagePool, and image_t::width.
Referenced by R_FindImage().
Reallocate arrays of GL primitives if needed.
| size | The new array size |
Definition at line 563 of file ufomodel.cpp.
References Mem_SafeReAlloc, and r_state.
| void R_ReallocateTexunitArray | ( | gltexunit_t * | texunit, |
| int | size ) |
Reallocate texcoord array of the specified texunit, if needed.
| texunit | Pointer to texunit (TODO: remove this comment as obvious and redundant) |
| size | The new array size |
Definition at line 579 of file ufomodel.cpp.
References gltexunit_t::array_size, Mem_SafeReAlloc, r_state, and gltexunit_t::texcoord_array.
Definition at line 551 of file ufomodel.cpp.
References MD2SkinFix(), and MD2Visitor().
Referenced by main().
Parameter parsing.
Definition at line 335 of file ufomodel.cpp.
References ACTION_CHECK, ACTION_GLCMDSREMOVE, ACTION_INFO, ACTION_MDX, ACTION_SKINEDIT, ACTION_SKINFIX, ACTION_SKINNUM, Com_Printf(), config, Exit(), i, Q_streq, Q_strncpyz(), and Usage().
Referenced by main().
Definition at line 310 of file ufomodel.cpp.
References Com_Printf().
Referenced by main(), and UM_Parameter().
|
static |
Definition at line 228 of file ufomodel.cpp.
References Com_Printf(), f, FILE_WRITE, FS_OpenFile(), FS_Write(), i, IDMDXHEADER, mAliasMesh_t::indexes, LittleLong, MDX_VERSION, mAliasMesh_t::num_tris, and mAliasMesh_t::num_verts.
Referenced by PrecalcNormalsAndTangents().
| memPool_t* com_fileSysPool |
Definition at line 73 of file ufomodel.cpp.
| memPool_t* com_genericPool |
Definition at line 72 of file ufomodel.cpp.
|
static |
Definition at line 70 of file ufomodel.cpp.
| image_t* r_noTexture |
Definition at line 47 of file ufomodel.cpp.
Referenced by main(), MD2Check(), MD2SkinFix(), R_Draw3DGlobe(), R_DrawFlatGeoscape(), R_DrawInitLocal(), R_FindImage(), R_FindPics(), R_InitImages(), R_InitMiscTexture(), R_LoadActorSkinsFromModel(), R_LoadAnimImages(), R_LoadMaterials(), R_ParseStage(), R_ReloadImageData(), R_SwitchModelMemPoolTag(), R_UploadData(), UI_LoadImage(), and UI_LoadWrappedImage().
| rstate_t r_state |
Definition at line 46 of file ufomodel.cpp.
| memPool_t* vid_imagePool |
Definition at line 76 of file ufomodel.cpp.
| memPool_t* vid_lightPool |
lightmap - wiped with every new map
Definition at line 75 of file ufomodel.cpp.
| memPool_t* vid_modelPool |
modeldata - wiped with every new map
Definition at line 74 of file ufomodel.cpp.