Model rotations, experimental

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7029 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Alejandro V. Garcia
2013-01-04 09:41:15 +00:00
parent d78ac41e3a
commit c5e656fc9e
4 changed files with 45 additions and 15 deletions
+7 -2
View File
@@ -177,10 +177,14 @@ struct md2 : vertmodel
}
};
void render(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, float pitch, dynent *d, modelattach *a, float scale)
void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a, float scale)
{
if(!loaded) return;
pitch += offsetpitch;
yaw += offsetyaw;
roll += offsetroll;
if(a) for(int i = 0; a[i].tag; i++)
{
if(a[i].pos) link(NULL, a[i].tag, a[i].pos);
@@ -206,6 +210,7 @@ struct md2 : vertmodel
matrixstack[0].translate(o);
matrixstack[0].rotate_around_z((yaw+180)*RAD);
matrixstack[0].rotate_around_y(-pitch*RAD);
matrixstack[0].rotate_around_x(roll*RAD);
if(anim&ANIM_MIRROR || scale!=1) matrixstack[0].scale(scale, anim&ANIM_MIRROR ? -scale : scale, scale);
parts[0]->render(anim, varseed, speed, basetime, d);
@@ -220,7 +225,7 @@ struct md2 : vertmodel
if(!m) continue;
m->parts[0]->index = parts.length()+i;
m->setskin();
m->render(anim, varseed, speed, basetime, o, yaw, pitch, d, NULL, scale);
m->render(anim, varseed, speed, basetime, o, roll, yaw, pitch, d, NULL, scale);
}
if(d) d->lastrendered = lastmillis;
+7 -2
View File
@@ -153,10 +153,14 @@ struct md3 : vertmodel
}
};
void render(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, float pitch, dynent *d, modelattach *a, float scale)
void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a, float scale)
{
if(!loaded) return;
pitch += offsetpitch;
yaw += offsetyaw;
roll += offsetroll;
if(a) for(int i = 0; a[i].tag; i++)
{
vertmodel *m = (vertmodel *)a[i].m;
@@ -177,6 +181,7 @@ struct md3 : vertmodel
shadowdir = vec(0, 1/SQRT2, -1/SQRT2);
shadowdir.rotate_around_z((-shadowyaw-yaw-180.0f)*RAD);
shadowdir.rotate_around_y(-pitch*RAD);
shadowdir.rotate_around_x(roll*RAD);
(shadowpos = shadowdir).mul(shadowdist);
}
@@ -189,6 +194,7 @@ struct md3 : vertmodel
matrixstack[0].translate(o);
matrixstack[0].rotate_around_z((yaw+180)*RAD);
matrixstack[0].rotate_around_y(-pitch*RAD);
matrixstack[0].rotate_around_x(roll*RAD);
if(anim&ANIM_MIRROR || scale!=1) matrixstack[0].scale(scale, anim&ANIM_MIRROR ? -scale : scale, scale);
parts[0]->render(anim, varseed, speed, basetime, d);
@@ -306,4 +312,3 @@ COMMAND(md3skin, "ss");
COMMAND(md3anim, "siif");
COMMAND(md3link, "iis");
COMMAND(md3emit, "siii");
+3 -4
View File
@@ -42,11 +42,11 @@ class dynent;
struct model
{
bool cullface, vertexlight;
float alphatest, translucency, scale, radius, shadowdist;
float alphatest, translucency, scale, radius, shadowdist, offsetroll, offsetyaw, offsetpitch;
vec translate;
int cachelimit, batch;
model() : cullface(true), vertexlight(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {}
model() : offsetroll(0), offsetyaw(0), offsetpitch(0), cullface(true), vertexlight(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {}
virtual ~model() {}
virtual bool load() = 0;
@@ -55,7 +55,7 @@ struct model
virtual void cleanup() = 0;
virtual void render(int anim, int varseed, float speed, int basetime, const vec &o, float yaw, float pitch, dynent *d, modelattach *a = NULL, float scale = 1.0f) = 0;
virtual void render(int anim, int varseed, float speed, int basetime, const vec &o, float roll, float yaw, float pitch, dynent *d, modelattach *a = NULL, float scale = 1.0f) = 0;
virtual void setskin(int tex = 0) = 0;
virtual void genshadows(float height, float rad) {}
@@ -67,4 +67,3 @@ struct model
};
struct mapmodelinfo { int rad, h, zoff; string name; model *m; };
+28 -7
View File
@@ -79,6 +79,27 @@ void mdlcachelimit(int *limit)
COMMAND(mdlcachelimit, "i");
void mdlroll(float *angle)
{
checkmdl;
loadingmodel->offsetroll = *angle;
}
COMMAND(mdlroll, "f");
void mdlyaw(float *angle)
{
checkmdl;
loadingmodel->offsetyaw = *angle;
}
COMMAND(mdlyaw, "f");
void mdlpitch(float *angle)
{
checkmdl;
loadingmodel->offsetpitch = *angle;
}
COMMAND(mdlpitch, "f");
vector<mapmodelinfo> mapmodels;
void mapmodel(int *rad, int *h, int *zoff, char *snap, char *name)
@@ -159,7 +180,7 @@ struct batchedmodel
{
vec o;
int anim, varseed, tex;
float yaw, pitch, speed;
float roll, yaw, pitch, speed;
int basetime;
playerent *d;
int attached;
@@ -205,7 +226,7 @@ void renderbatchedmodel(model *m, batchedmodel &b)
if(stenciling)
{
m->render(b.anim|ANIM_NOSKIN, b.varseed, b.speed, b.basetime, b.o, b.yaw, b.pitch, b.d, a, b.scale);
m->render(b.anim|ANIM_NOSKIN, b.varseed, b.speed, b.basetime, b.o, b.roll, b.yaw, b.pitch, b.d, a, b.scale);
return;
}
@@ -222,7 +243,7 @@ void renderbatchedmodel(model *m, batchedmodel &b)
if(b.anim&ANIM_TRANSLUCENT)
{
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
m->render(b.anim|ANIM_NOSKIN, b.varseed, b.speed, b.basetime, b.o, b.yaw, b.pitch, b.d, a, b.scale);
m->render(b.anim|ANIM_NOSKIN, b.varseed, b.speed, b.basetime, b.o, b.roll, b.yaw, b.pitch, b.d, a, b.scale);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthFunc(GL_LEQUAL);
@@ -234,7 +255,7 @@ void renderbatchedmodel(model *m, batchedmodel &b)
glColor4f(color[0], color[1], color[2], m->translucency);
}
m->render(b.anim, b.varseed, b.speed, b.basetime, b.o, b.yaw, b.pitch, b.d, a, b.scale);
m->render(b.anim, b.varseed, b.speed, b.basetime, b.o, b.roll, b.yaw, b.pitch, b.d, a, b.scale);
if(b.anim&ANIM_TRANSLUCENT)
{
@@ -406,7 +427,7 @@ void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, fl
if(stenciling)
{
m->startrender();
m->render(anim|ANIM_NOSKIN, varseed, speed, basetime, o, yaw, pitch, d, a, scale);
m->render(anim|ANIM_NOSKIN, varseed, speed, basetime, o, 0, yaw, pitch, d, a, scale);
m->endrender();
return;
}
@@ -445,7 +466,7 @@ void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, fl
if(anim&ANIM_TRANSLUCENT)
{
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
m->render(anim|ANIM_NOSKIN, varseed, speed, basetime, o, yaw, pitch, d, a, scale);
m->render(anim|ANIM_NOSKIN, varseed, speed, basetime, o, 0, yaw, pitch, d, a, scale);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthFunc(GL_LEQUAL);
@@ -457,7 +478,7 @@ void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, fl
glColor4f(color[0], color[1], color[2], m->translucency);
}
m->render(anim, varseed, speed, basetime, o, yaw, pitch, d, a, scale);
m->render(anim, varseed, speed, basetime, o, 0, yaw, pitch, d, a, scale);
if(anim&ANIM_TRANSLUCENT)
{