*** empty log message ***

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@926 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2007-04-05 22:16:15 +00:00
parent 890c0d8503
commit 220bcccd58
7 changed files with 45 additions and 14 deletions
+1
View File
@@ -275,6 +275,7 @@ int main(int argc, char **argv)
log("models");
preload_playermodels();
preload_hudguns();
preload_entmodels();
execute("start_game");
+3 -3
View File
@@ -196,10 +196,10 @@ struct md2 : vertmodel
}
}
void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float rad, float yaw, model *vwepmdl)
void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, model *vwepmdl)
{
parts[0]->rendershadow(anim, varseed, speed, basetime, o, rad, yaw);
if(vwepmdl) ((md2 *)vwepmdl)->parts[0]->rendershadow(anim, varseed, speed, basetime, o, rad, yaw);
parts[0]->rendershadow(anim, varseed, speed, basetime, o, yaw);
if(vwepmdl) ((md2 *)vwepmdl)->parts[0]->rendershadow(anim, varseed, speed, basetime, o, yaw);
}
bool load()
+6
View File
@@ -167,6 +167,12 @@ struct md3 : vertmodel
glPopMatrix();
}
void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, model *vwepmdl)
{
if(parts.length()>1) return;
parts[0]->rendershadow(anim, varseed, speed, basetime, o, yaw);
}
bool load()
{
if(loaded) return true;
+2 -1
View File
@@ -37,7 +37,8 @@ struct model
virtual int type() = 0;
virtual void genshadows(float height, float rad) {}
virtual void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float rad, float yaw, model *vwepmdl = NULL) {}
virtual void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, model *vwepmdl = NULL) {}
virtual bool hasshadows() { return false; }
};
struct mapmodelinfo { int rad, h, zoff; string name; model *m; };
+1
View File
@@ -250,6 +250,7 @@ extern int findanim(const char *name);
extern void loadskin(const char *dir, const char *altdir, Texture *&skin, model *m);
extern model *loadmodel(const char *name, int i = -1);
extern void preload_playermodels();
extern void preload_entmodels();
extern void preload_hudguns();
extern void preload_mapmodels();
extern void renderclients();
+18 -4
View File
@@ -115,15 +115,13 @@ void rendermodel(char *mdl, int anim, int tex, float rad, float x, float y, floa
light.y = s->g/ll+of;
light.z = s->b/ll+of;
if(dynshadow && d && (anim&ANIM_INDEX)!=ANIM_LYING_DEAD)
if(dynshadow && m->hasshadows() && (!d || (anim&ANIM_INDEX)!=ANIM_LYING_DEAD))
{
vec center(x, z, s->floor);
if(s->type==FHF) center.z -= s->vdelta/4.0f;
float radius = 4.0f;
radius *= 1.0f + min(1.0f, max(0.0f, 0.5f*(y - d->eyeheight - center.z)/(d->aboveeye + d->eyeheight)));
center.z += 0.1f;
glColor4f(1, 1, 1, dynshadow/100.0f);
m->rendershadow(anim, varseed, speed, basetime, center, radius, yaw, vwep);
m->rendershadow(anim, varseed, speed, basetime, center, yaw, vwep);
}
}
@@ -173,6 +171,22 @@ void preload_playermodels()
}
}
void preload_entmodels()
{
extern char *entmdlnames[];
loopi(I_AKIMBO-I_CLIPS+1)
{
model *mdl = loadmodel(entmdlnames[i]);
if(dynshadow && mdl) mdl->genshadows(8.0f, 2.0f);
}
static char *bouncemdlnames[] = { "misc/gib01", "misc/gib02", "misc/gib03", "weapons/grenade/static" };
loopi(sizeof(bouncemdlnames)/sizeof(bouncemdlnames[0]))
{
model *mdl = loadmodel(bouncemdlnames[i]);
if(dynshadow && mdl) mdl->genshadows(8.0f, 2.0f);
}
}
void preload_mapmodels()
{
int xs, ys;
+14 -6
View File
@@ -149,7 +149,7 @@ struct vertmodel : model
if(index>=tristrip::RESTART) continue;
}
tcvert &tc = tcverts[index];
if(!(as.anim&ANIM_NOSKIN)) glTexCoord2f(tc.u, tc.v);
if(isstat || !(as.anim&ANIM_NOSKIN)) glTexCoord2f(tc.u, tc.v);
glVertex3fv(&dynbuf[tc.index].x);
}
glEnd();
@@ -191,8 +191,9 @@ struct vertmodel : model
tag *tags;
int numtags;
GLuint *shadows;
float shadowrad;
part() : loaded(false), anims(NULL), links(NULL), tags(NULL), numtags(0), shadows(NULL) {}
part() : loaded(false), anims(NULL), links(NULL), tags(NULL), numtags(0), shadows(NULL), shadowrad(0) {}
virtual ~part()
{
meshes.deletecontentsp();
@@ -407,6 +408,7 @@ struct vertmodel : model
{
if(shadows) return;
shadowrad = rad;
shadows = new GLuint[numframes];
glGenTextures(numframes, shadows);
@@ -436,7 +438,7 @@ struct vertmodel : model
glViewport(0, 0, scr_w, scr_h);
}
void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float rad, float yaw)
void rendershadow(int anim, int varseed, float speed, int basetime, const vec &o, float yaw)
{
if(!shadows) return;
animstate as;
@@ -452,8 +454,8 @@ struct vertmodel : model
yaw *= RAD;
float c = cosf(yaw), s = sinf(yaw);
float x1 = -rad, x2 = +rad;
float y1 = -rad, y2 = +rad;
float x1 = -shadowrad, x2 = shadowrad;
float y1 = -shadowrad, y2 = shadowrad;
glBegin(GL_POLYGON);
glTexCoord2f(0, 1); glVertex3f(x1*c - y1*s + o.x, o.z, y1*c + x1*s + o.y);
@@ -499,7 +501,13 @@ struct vertmodel : model
void genshadows(float height, float rad)
{
loopv(parts) parts[i]->genshadows(height, rad);
if(parts.length()>1) return;
parts[0]->genshadows(height, rad);
}
bool hasshadows()
{
return parts.length()==1 && parts[0]->shadows;
}
};