Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added shiny reaction and shiny factor
  • Loading branch information
skyjake committed Dec 30, 2004
1 parent d2bec03 commit 88d0810
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
6 changes: 6 additions & 0 deletions doomsday/Doc/ChangeLog.txt
Expand Up @@ -4,6 +4,12 @@
Legend: + added, - fixed, * improved/changed


Version 1.8.5
-------------
+ Model -> Sub -> Shiny reaction: how much shiny textures react to angle
changes


Version 1.8.4
-------------
* shiny texture coordinates are calculated using a simplified algorithm
Expand Down
1 change: 1 addition & 0 deletions doomsday/Include/def_data.h
Expand Up @@ -151,6 +151,7 @@ extern "C" {
ded_string_t shinyskin;
float shiny;
float shinycolor[3];
float shinyreact;
} ded_submodel_t;

typedef struct {
Expand Down
1 change: 1 addition & 0 deletions doomsday/Include/rend_model.h
Expand Up @@ -30,6 +30,7 @@ extern int mirrorHudModels;
extern int modelShinyMultitex;
extern float rend_model_lod;

void Rend_ModelRegister(void);
void Rend_RenderModel(vissprite_t * spr);

#endif
1 change: 1 addition & 0 deletions doomsday/Src/def_data.c
Expand Up @@ -165,6 +165,7 @@ int DED_AddModel(ded_t * ded, char *spr)
{
md->sub[i].shinycolor[0] = md->sub[i].shinycolor[1] =
md->sub[i].shinycolor[2] = 1;
md->sub[i].shinyreact = 1.0f;
}
return md - ded->models;
}
Expand Down
1 change: 1 addition & 0 deletions doomsday/Src/def_read.c
Expand Up @@ -954,6 +954,7 @@ int DED_ReadData(ded_t *ded, char *buffer, const char *sourceFile)
RV_STR("Shiny skin", mdl->sub[sub].shinyskin)
RV_FLT("Shiny", mdl->sub[sub].shiny)
RV_VEC("Shiny color", mdl->sub[sub].shinycolor, 3)
RV_FLT("Shiny reaction", mdl->sub[sub].shinyreact)
RV_END
CHECKSC;
}
Expand Down
1 change: 1 addition & 0 deletions doomsday/Src/rend_main.c
Expand Up @@ -88,6 +88,7 @@ void Rend_Register(void)
C_VAR_BYTE("rend-tex-anim-smooth", &smoothTexAnim, 0, 0, 1,
"1=Enable interpolated texture animation.");

Rend_ModelRegister();
Rend_RadioRegister();
}

Expand Down
21 changes: 15 additions & 6 deletions doomsday/Src/rend_model.c
Expand Up @@ -82,6 +82,7 @@ int modelLight = 4;
int frameInter = true;
int mirrorHudModels = false;
int modelShinyMultitex = true;
float modelShinyFactor = 1.0f;
int model_tri_count;
float rend_model_lod = 256;

Expand Down Expand Up @@ -115,6 +116,12 @@ static char *vertexUsage;

// CODE --------------------------------------------------------------------

void Rend_ModelRegister(void)
{
C_VAR_FLOAT("rend-model-shiny-strength", &modelShinyFactor, 0, 0, 10,
"General strength of model shininess effects.");
}

static float __inline qatan2(float y, float x)
{
float ang = BANG2RAD(bamsAtan2(y * 512, x * 512));
Expand Down Expand Up @@ -441,7 +448,7 @@ void Mod_FixedVertexColors(int count, gl_color_t * colors, float *color)
*/
void Mod_ShinyCoords(int count, gl_texcoord_t* coords, gl_vertex_t* normals,
float normYaw, float normPitch, float shinyAng,
float shinyPnt)
float shinyPnt, float reactSpeed)
{
int i;
float u, v;
Expand All @@ -458,10 +465,11 @@ void Mod_ShinyCoords(int count, gl_texcoord_t* coords, gl_vertex_t* normals,

// Rotate the normal vector so that it approximates the
// model's orientation compared to the viewer.
M_RotateVector(rotatedNormal, (shinyPnt + normYaw) * 360,
(shinyAng + normPitch - .5f) * 180);
M_RotateVector(rotatedNormal,
(shinyPnt + normYaw) * 360 * reactSpeed,
(shinyAng + normPitch - .5f) * 180 * reactSpeed);

u = (rotatedNormal[VX] + 1);
u = rotatedNormal[VX] + 1;
v = rotatedNormal[VZ];

coords->st[0] = u;
Expand Down Expand Up @@ -793,7 +801,7 @@ void Mod_RenderSubModel(vissprite_t * spr, int number)
}

// Calculate shiny coordinates.
shininess = mf->def->sub[number].shiny;
shininess = mf->def->sub[number].shiny * modelShinyFactor;
if(shininess < 0)
shininess = 0;
if(shininess > 1)
Expand Down Expand Up @@ -844,7 +852,8 @@ void Mod_RenderSubModel(vissprite_t * spr, int number)
}

Mod_ShinyCoords(numVerts, modelTexCoords, modelNormals, normYaw,
normPitch, shinyAng, shinyPnt);
normPitch, shinyAng, shinyPnt,
mf->def->sub[number].shinyreact);

// Shiny color.
if(subFlags & MFF_SHINY_LIT)
Expand Down

0 comments on commit 88d0810

Please sign in to comment.