Starting point for model tool. More...
#include "../../shared/ufotypes.h"
#include "../../common/mem.h"
#include "../../shared/shared.h"
#include "../../common/filesys.h"
#include "../../common/qfiles.h"
#include "../../shared/typedefs.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"
Go to the source code of this file.
Data Structures | |
struct | modelConfig_s |
Defines | |
#define | VERSION "0.2" |
Typedefs | |
typedef struct modelConfig_s | modelConfig_t |
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_CHECK, 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, 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 | MD2HeaderCheck (const dMD2Model_t *md2, const char *fileName, int bufSize) |
static void | MD2SkinEdit (const byte *buf, const char *fileName, int bufSize, void *userData) |
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 | MD2GLCmdsRemove (const byte *buf, const char *fileName, int bufSize, void *userData) |
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) |
int | main (int argc, char **argv) |
Variables | |
rstate_t | r_state |
image_t * | r_noTexture |
static modelConfig_t | config |
struct memPool_s * | com_genericPool |
struct memPool_s * | com_fileSysPool |
struct memPool_s * | vid_modelPool |
struct memPool_s * | vid_imagePool |
Starting point for model tool.
Definition in file ufomodel.c.
#define VERSION "0.2" |
Definition at line 39 of file ufomodel.c.
typedef struct modelConfig_s modelConfig_t |
typedef void(* modelWorker_t)(const byte *buf, const char *fileName, int bufSize, void *userData) |
Definition at line 423 of file ufomodel.c.
enum ufoModelAction_t |
Definition at line 44 of file ufomodel.c.
void Com_DPrintf | ( | int | level, | |
const char * | fmt, | |||
... | ||||
) |
Definition at line 91 of file ufomodel.c.
References Com_Printf(), Q_vsnprintf(), and modelConfig_s::verbose.
void Com_Error | ( | int | code, | |
const char * | fmt, | |||
... | ||||
) |
Definition at line 164 of file ufomodel.c.
References Exit(), and Q_vsnprintf().
void Com_Printf | ( | const char * | format, | |
... | ||||
) |
Definition at line 79 of file ufomodel.c.
References Q_vsnprintf().
static void Exit | ( | int | exitCode | ) | [static] |
Definition at line 72 of file ufomodel.c.
References Mem_Shutdown().
Referenced by Com_Error(), main(), and UM_Parameter().
static void GLCmdsRemove | ( | void | ) | [static] |
Definition at line 628 of file ufomodel.c.
References Com_Printf(), MD2GLCmdsRemove(), MD2Visitor(), and UFO_SIZE_T.
Referenced by main().
static model_t* LoadModel | ( | const char * | name | ) | [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 182 of file ufomodel.c.
References byte, Com_Error(), Com_Printf(), DPMHEADER, ERR_FATAL, FS_FreeFile(), FS_LoadFile(), IDALIASHEADER, IDMD3HEADER, LittleLong(), Mem_PoolAlloc, model_s::name, Q_strcasecmp, Q_strncpyz(), qfalse, R_LoadObjModel(), R_ModLoadAliasDPMModel(), R_ModLoadAliasMD2Model(), and R_ModLoadAliasMD3Model().
Referenced by PrecalcNormalsAndTangents().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 635 of file ufomodel.c.
References modelConfig_s::action, ACTION_CHECK, ACTION_GLCMDSREMOVE, ACTION_MDX, ACTION_NONE, ACTION_SKINEDIT, ACTION_SKINFIX, Com_Printf(), Exit(), modelConfig_s::fileName, FS_InitFilesystem(), GLCmdsRemove(), modelConfig_s::inputName, MD2SkinEdit(), Mem_CreatePool, Mem_Init(), Mem_PoolAlloc, Mem_Shutdown(), ModelCheck(), ModelWorker(), image_s::name, PrecalcNormalsAndTangents(), PrecalcNormalsAndTangentsBatch(), Q_strncpyz(), qfalse, SkinFix(), Swap_Init(), UM_DefaultParameter(), UM_Parameter(), Usage(), and VERSION.
static void MD2Check | ( | const byte * | buf, | |
const char * | fileName, | |||
int | bufSize, | |||
void * | userData | |||
) | [static] |
Definition at line 561 of file ufomodel.c.
References Com_GetExtension(), Com_Printf(), i, LittleLong(), MD2_MAX_SKINNAME, MD2HeaderCheck(), name, dMD2Model_t::num_skins, dMD2Model_t::ofs_skins, qfalse, qtrue, and R_AliasModelGetSkin().
Referenced by ModelCheck().
static void MD2GLCmdsRemove | ( | const byte * | buf, | |
const char * | fileName, | |||
int | bufSize, | |||
void * | userData | |||
) | [static] |
Definition at line 459 of file ufomodel.c.
References Com_Error(), Com_Printf(), ERR_DROP, FS_WriteFile(), LittleLong(), MD2HeaderCheck(), Mem_Dup, Mem_Free, dMD2Model_t::num_glcmds, dMD2Model_t::ofs_end, dMD2Model_t::ofs_frames, dMD2Model_t::ofs_glcmds, dMD2Model_t::ofs_skins, dMD2Model_t::ofs_st, dMD2Model_t::ofs_tris, and UFO_SIZE_T.
Referenced by GLCmdsRemove().
static void MD2HeaderCheck | ( | const dMD2Model_t * | md2, | |
const char * | fileName, | |||
int | bufSize | |||
) | [static] |
Definition at line 380 of file ufomodel.c.
References Com_Error(), ERR_DROP, LittleLong(), MD2_ALIAS_VERSION, MD2_MAX_SKINS, MD2_MAX_TRIANGLES, MD2_MAX_VERTS, dMD2Model_t::num_skins, dMD2Model_t::num_tris, dMD2Model_t::num_verts, dMD2Model_t::ofs_end, and dMD2Model_t::version.
Referenced by MD2Check(), MD2GLCmdsRemove(), MD2SkinEdit(), and MD2SkinFix().
static void MD2SkinEdit | ( | const byte * | buf, | |
const char * | fileName, | |||
int | bufSize, | |||
void * | userData | |||
) | [static] |
Definition at line 404 of file ufomodel.c.
References Com_Printf(), i, LittleLong(), MD2_MAX_SKINNAME, MD2HeaderCheck(), name, dMD2Model_t::num_skins, and dMD2Model_t::ofs_skins.
Referenced by main().
static void MD2SkinFix | ( | const byte * | buf, | |
const char * | fileName, | |||
int | bufSize, | |||
void * | userData | |||
) | [static] |
Definition at line 496 of file ufomodel.c.
References byte, 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, dMD2Model_t::ofs_skins, and R_AliasModelGetSkin().
Referenced by SkinFix().
static void MD2Visitor | ( | modelWorker_t | worker, | |
void * | userData | |||
) | [static] |
Definition at line 605 of file ufomodel.c.
References FS_BuildFileList(), FS_NextFileFromFileList(), and ModelWorker().
Referenced by GLCmdsRemove(), ModelCheck(), and SkinFix().
static void ModelCheck | ( | void | ) | [static] |
Definition at line 618 of file ufomodel.c.
References MD2Check(), and MD2Visitor().
Referenced by main().
static void ModelWorker | ( | modelWorker_t | worker, | |
const char * | fileName, | |||
void * | userData | |||
) | [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 431 of file ufomodel.c.
References byte, Com_Error(), DPMHEADER, ERR_DROP, ERR_FATAL, FS_FreeFile(), FS_LoadFile(), IDALIASHEADER, IDBSPHEADER, IDMD3HEADER, LittleLong(), and Q_strcasecmp.
Referenced by main(), and MD2Visitor().
static int PrecalcNormalsAndTangents | ( | const char * | filename | ) | [static] |
Definition at line 258 of file ufomodel.c.
References model_s::alias, Com_Error(), Com_Printf(), Com_StripExtension(), ERR_DROP, FS_CheckFile(), i, LoadModel(), MAX_QPATH, mAliasModel_s::meshes, mAliasModel_s::num_frames, mAliasModel_s::num_meshes, modelConfig_s::overwrite, Q_strcat(), R_ModCalcUniqueNormalsAndTangents(), modelConfig_s::smoothness, and WriteToFile().
Referenced by main(), and PrecalcNormalsAndTangentsBatch().
static void PrecalcNormalsAndTangentsBatch | ( | const char * | pattern | ) | [static] |
Definition at line 294 of file ufomodel.c.
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 132 of file ufomodel.c.
References Com_Error(), Com_Printf(), Com_StripExtension(), ERR_FATAL, image_s::glowmap, Img_LoadImage(), it_glowmap, it_normalmap, it_roughnessmap, it_specularmap, it_world, MAX_QPATH, image_s::name, image_s::normalmap, R_FindImage(), R_GetImage(), R_LoadImageData(), r_noTexture, image_s::roughnessmap, image_s::specularmap, image_s::type, and va().
image_t* R_LoadImageData | ( | const char * | name, | |
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 105 of file ufomodel.c.
References Com_Error(), Com_HashKey(), Com_Printf(), ERR_DROP, image_s::has_alpha, hash(), image_s::hashNext, image_s::hashPrev, image_s::height, i, len, MAX_GL_TEXTURES, MAX_IMAGEHASH, Mem_PoolAlloc, image_s::name, Q_strncpyz(), qfalse, R_BindTexture, R_GetImage(), r_numImages, R_UploadTexture(), image_s::texnum, image_s::type, and image_s::width.
static void SkinFix | ( | void | ) | [static] |
Definition at line 623 of file ufomodel.c.
References MD2SkinFix(), and MD2Visitor().
Referenced by main().
static void UM_DefaultParameter | ( | void | ) | [static] |
Definition at line 328 of file ufomodel.c.
References modelConfig_s::smoothness.
Referenced by main().
static void UM_Parameter | ( | int | argc, | |
char ** | argv | |||
) | [static] |
Parameter parsing.
Definition at line 336 of file ufomodel.c.
References modelConfig_s::action, ACTION_CHECK, ACTION_GLCMDSREMOVE, ACTION_MDX, ACTION_SKINEDIT, ACTION_SKINFIX, Com_Printf(), Exit(), modelConfig_s::fileName, i, modelConfig_s::inputName, modelConfig_s::overwrite, Q_strncpyz(), qtrue, modelConfig_s::smoothness, Usage(), and modelConfig_s::verbose.
Referenced by main().
static void Usage | ( | void | ) | [static] |
Definition at line 313 of file ufomodel.c.
References Com_Printf().
Referenced by main(), and UM_Parameter().
static void WriteToFile | ( | const model_t * | mod, | |
const mAliasMesh_t * | mesh, | |||
const char * | fileName | |||
) | [static] |
Definition at line 226 of file ufomodel.c.
References Com_Printf(), qFILE_s::f, f, FILE_WRITE, FS_CloseFile(), FS_OpenFile(), FS_Write(), i, IDMDXHEADER, mAliasMesh_s::indexes, LittleLong(), MDX_VERSION, mAliasMesh_s::num_tris, and mAliasMesh_s::num_verts.
Referenced by PrecalcNormalsAndTangents().
struct memPool_s* com_fileSysPool |
Definition at line 66 of file ufomodel.c.
struct memPool_s* com_genericPool |
Definition at line 65 of file ufomodel.c.
modelConfig_t config [static] |
Definition at line 63 of file ufomodel.c.
Definition at line 42 of file ufomodel.c.
Referenced by MAP_InitStartup(), R_Draw3DGlobe(), R_DrawFlatGeoscape(), R_DrawInitLocal(), R_FindImage(), R_InitImages(), R_InitMiscTexture(), R_LoadAnimImages(), R_LoadMaterials(), R_ParseStage(), R_RegisterImage(), R_SwitchModelMemPoolTag(), R_UploadData(), SCR_SetLoadingBackground(), and UI_LoadImage().
Definition at line 41 of file ufomodel.c.
struct memPool_s* vid_imagePool |
Definition at line 68 of file ufomodel.c.
struct memPool_s* vid_modelPool |
modeldata - wiped with every new map
Definition at line 67 of file ufomodel.c.