]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.h
prvm_edict: Minor edit to string
[xonotic/darkplaces.git] / model_shared.h
index 0b377c2c18f79745437ad7cee9aca9f54074ad9a..38469a560dea575a83d3700d43d6817f36639239 100644 (file)
@@ -409,7 +409,7 @@ typedef enum dptransparentsort_category_e
        TRANSPARENTSORT_HUD,
 }dptransparentsortcategory_t;
 
-typedef struct q3shaderinfo_s
+typedef struct shader_s
 {
        char name[Q3PATHLENGTH];
 #define Q3SHADERINFO_COMPARE_START surfaceparms
@@ -469,7 +469,7 @@ typedef struct q3shaderinfo_s
        float rtlightambient;
 #define Q3SHADERINFO_COMPARE_END rtlightambient
 }
-q3shaderinfo_t;
+shader_t;
 
 typedef struct texture_shaderpass_s
 {
@@ -487,9 +487,10 @@ texture_shaderpass_t;
 
 typedef struct texture_s
 {
-       // q1bsp
        // name
-       //char name[16];
+       char name[64];
+
+       // q1bsp
        // size
        unsigned int width, height;
        // SURF_ flags
@@ -572,7 +573,8 @@ typedef struct texture_s
        // MATERIALFLAG_MODELLIGHT uses these parameters
        float render_modellight_ambient[3];
        float render_modellight_diffuse[3];
-       float render_modellight_lightdir[3];
+       float render_modellight_lightdir_world[3];
+       float render_modellight_lightdir_local[3];
        float render_modellight_specular[3];
        // lightmap rendering (not MATERIALFLAG_MODELLIGHT)
        float render_lightmap_ambient[3];
@@ -590,7 +592,6 @@ typedef struct texture_s
        int customblendfunc[2];
 
        // q3bsp
-       char name[64];
        int surfaceflags;
        int supercontents;
 
@@ -631,6 +632,11 @@ typedef struct texture_s
 
        // diffuse and ambient
        float rtlightambient;
+
+       // used by Mod_Mesh_GetTexture for drawflag and materialflag overrides, to disambiguate the same texture with different hints
+       int mesh_drawflag;
+       int mesh_defaulttexflags;
+       int mesh_defaultmaterialflags;
 }
  texture_t;
 
@@ -682,10 +688,6 @@ typedef struct msurface_s
        struct q3deffect_s *effect; // q3bsp
        // mesh information for collisions (only used by q3bsp curves)
        int num_firstcollisiontriangle;
-       int *deprecatedq3data_collisionelement3i; // q3bsp
-       float *deprecatedq3data_collisionvertex3f; // q3bsp
-       float *deprecatedq3data_collisionbbox6f; // collision optimization - contains combined bboxes of every data_collisionstride triangles
-       float *deprecatedq3data_bbox6f; // collision optimization - contains combined bboxes of every data_collisionstride triangles
 
        // surfaces own ranges of vertices and triangles in the model->surfmesh
        int num_triangles; // number of triangles
@@ -696,10 +698,6 @@ typedef struct msurface_s
        // mesh information for collisions (only used by q3bsp curves)
        int num_collisiontriangles; // q3bsp
        int num_collisionvertices; // q3bsp
-       int deprecatedq3num_collisionbboxstride;
-       int deprecatedq3num_bboxstride;
-       // FIXME: collisionmarkframe should be kept in a separate array
-       int deprecatedq3collisionmarkframe; // q3bsp // don't collide twice in one trace
 
        // used by Mod_Mesh_Finalize when building sortedmodelsurfaces
        qboolean included;
@@ -878,12 +876,6 @@ typedef struct model_brushq1_s
 }
 model_brushq1_t;
 
-typedef struct model_brushq2_s
-{
-       int dummy; // MSVC can't handle an empty struct
-}
-model_brushq2_t;
-
 typedef struct model_brushq3_s
 {
        int num_models;
@@ -914,7 +906,7 @@ typedef struct model_brushq3_s
        rtexture_t **data_lightmaps;
        rtexture_t **data_deluxemaps;
 
-       // voxel light data with directional shading
+       // voxel light data with directional shading - data for cpu sampling of it...
        int num_lightgrid;
        q3dlightgrid_t *data_lightgrid;
        // size of each cell (may vary by map, typically 64 64 128)
@@ -927,6 +919,10 @@ typedef struct model_brushq3_s
        int num_lightgrid_isize[3];
        // transform modelspace coordinates to lightgrid index
        matrix4x4_t num_lightgrid_indexfromworld;
+       // parameters for fragment shader to sample the texture version of it:
+       int lightgridtexturesize[3]; // 3 layers tall (ambient, lightcolor, lightdir)
+       matrix4x4_t lightgridworldtotexturematrix;
+       rtexture_t *lightgridtexture;
 
        // true if this q3bsp file has been detected as using deluxemapping
        // (lightmap texture pairs, every odd one is never directly refernced,
@@ -1058,7 +1054,6 @@ typedef struct model_s
        model_sprite_t  sprite;
        model_brush_t   brush;
        model_brushq1_t brushq1;
-       model_brushq2_t brushq2;
        model_brushq3_t brushq3;
        // flags this model for offseting sounds to the model center (used by brush models)
        int soundfromcenter;
@@ -1066,6 +1061,8 @@ typedef struct model_s
        // if set, the model contains light information (lightmap, or vertexlight)
        qboolean lit;
        float lightmapscale;
+
+       qboolean nolerp;
 }
 dp_model_t;
 
@@ -1074,6 +1071,15 @@ dp_model_t;
 // model loading
 extern dp_model_t *loadmodel;
 extern unsigned char *mod_base;
+
+typedef struct modloader_s
+{
+       char *extension;
+       char *header;
+       size_t headersize; // The header might not be NULL terminated
+       void (*Load)(dp_model_t *, void *, void *);
+} modloader_t;
+
 // sky/water subdivision
 //extern cvar_t gl_subdivide_size;
 // texture fullbrights
@@ -1088,6 +1094,9 @@ extern cvar_t mod_q3shader_default_polygonfactor;
 extern cvar_t mod_q3shader_default_refractive_index;
 extern cvar_t mod_q3shader_force_addalpha;
 extern cvar_t mod_q3shader_force_terrain_alphaflag;
+extern cvar_t mod_q3bsp_lightgrid_texture;
+extern cvar_t mod_q3bsp_lightgrid_world_surfaces;
+extern cvar_t mod_q3bsp_lightgrid_bsp_surfaces;
 
 void Mod_Init (void);
 void Mod_Reload (void);
@@ -1127,7 +1136,7 @@ void Mod_CreateCollisionMesh(dp_model_t *mod);
 
 void Mod_FreeQ3Shaders(void);
 void Mod_LoadQ3Shaders(void);
-q3shaderinfo_t *Mod_LookupQ3Shader(const char *name);
+shader_t *Mod_LookupQ3Shader(const char *name);
 qboolean Mod_LoadTextureFromQ3Shader(mempool_t *mempool, const char *modelname, texture_t *texture, const char *name, qboolean warnmissing, qboolean fallback, int defaulttexflags, int defaultmaterialflags);
 texture_shaderpass_t *Mod_CreateShaderPass(mempool_t *mempool, skinframe_t *skinframe);
 texture_shaderpass_t *Mod_CreateShaderPassFromQ3ShaderLayer(mempool_t *mempool, const char *modelname, q3shaderinfo_layer_t *layer, int layerindex, int texflags, const char *texturename);
@@ -1195,22 +1204,22 @@ int Mod_Q2BSP_NativeContentsFromSuperContents(int supercontents);
 
 // a lot of model formats use the Q1BSP code, so here are the prototypes...
 struct entity_render_s;
-void R_Q1BSP_DrawAddWaterPlanes(struct entity_render_s *ent);
-void R_Q1BSP_DrawSky(struct entity_render_s *ent);
-void R_Q1BSP_Draw(struct entity_render_s *ent);
-void R_Q1BSP_DrawDepth(struct entity_render_s *ent);
-void R_Q1BSP_DrawDebug(struct entity_render_s *ent);
-void R_Q1BSP_DrawPrepass(struct entity_render_s *ent);
-void R_Q1BSP_GetLightInfo(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, unsigned char *outleafpvs, int *outnumleafspointer, int *outsurfacelist, unsigned char *outsurfacepvs, int *outnumsurfacespointer, unsigned char *outshadowtrispvs, unsigned char *outlighttrispvs, unsigned char *visitingleafpvs, int numfrustumplanes, const mplane_t *frustumplanes, qboolean noocclusion);
-void R_Q1BSP_CompileShadowMap(struct entity_render_s *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist);
-void R_Q1BSP_DrawShadowMap(int side, struct entity_render_s *ent, const vec3_t relativelightorigin, const vec3_t relativelightdirection, float lightradius, int modelnumsurfaces, const int *modelsurfacelist, const unsigned char *surfacesides, const vec3_t lightmins, const vec3_t lightmaxs);
-void R_Q1BSP_DrawLight(struct entity_render_s *ent, int numsurfaces, const int *surfacelist, const unsigned char *trispvs);
+void R_Mod_DrawAddWaterPlanes(struct entity_render_s *ent);
+void R_Mod_DrawSky(struct entity_render_s *ent);
+void R_Mod_Draw(struct entity_render_s *ent);
+void R_Mod_DrawDepth(struct entity_render_s *ent);
+void R_Mod_DrawDebug(struct entity_render_s *ent);
+void R_Mod_DrawPrepass(struct entity_render_s *ent);
+void R_Mod_GetLightInfo(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, unsigned char *outleafpvs, int *outnumleafspointer, int *outsurfacelist, unsigned char *outsurfacepvs, int *outnumsurfacespointer, unsigned char *outshadowtrispvs, unsigned char *outlighttrispvs, unsigned char *visitingleafpvs, int numfrustumplanes, const mplane_t *frustumplanes, qboolean noocclusion);
+void R_Mod_CompileShadowMap(struct entity_render_s *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist);
+void R_Mod_DrawShadowMap(int side, struct entity_render_s *ent, const vec3_t relativelightorigin, const vec3_t relativelightdirection, float lightradius, int modelnumsurfaces, const int *modelsurfacelist, const unsigned char *surfacesides, const vec3_t lightmins, const vec3_t lightmaxs);
+void R_Mod_DrawLight(struct entity_render_s *ent, int numsurfaces, const int *surfacelist, const unsigned char *trispvs);
 
 // dynamic mesh building (every frame) for debugging and other uses
 void Mod_Mesh_Create(dp_model_t *mod, const char *name);
 void Mod_Mesh_Destroy(dp_model_t *mod);
 void Mod_Mesh_Reset(dp_model_t *mod);
-texture_t *Mod_Mesh_GetTexture(dp_model_t *mod, const char *name, int defaultdrawflags, int defaulttexflags, int addmaterialflags);
+texture_t *Mod_Mesh_GetTexture(dp_model_t *mod, const char *name, int defaultdrawflags, int defaulttexflags, int defaultmaterialflags);
 msurface_t *Mod_Mesh_AddSurface(dp_model_t *mod, texture_t *tex, qboolean batchwithprevioussurface);
 int Mod_Mesh_IndexForVertex(dp_model_t *mod, msurface_t *surf, float x, float y, float z, float nx, float ny, float nz, float s, float t, float u, float v, float r, float g, float b, float a);
 void Mod_Mesh_AddTriangle(dp_model_t *mod, msurface_t *surf, int e0, int e1, int e2);
@@ -1242,6 +1251,9 @@ void Mod_Skeletal_FreeBuffers(void);
 void Mod_SpriteInit(void);
 
 // loaders
+void Mod_2PSB_Load(dp_model_t *mod, void *buffer, void *bufferend);
+void Mod_BSP2_Load(dp_model_t *mod, void *buffer, void *bufferend);
+void Mod_HLBSP_Load(dp_model_t *mod, void *buffer, void *bufferend);
 void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend);
 void Mod_IBSP_Load(dp_model_t *mod, void *buffer, void *bufferend);
 void Mod_MAP_Load(dp_model_t *mod, void *buffer, void *bufferend);