Esempio n. 1
0
void renderclient(dynent *d, bool team, char *mdlname, bool hellpig, float scale)
{
    int n = 3;
    float speed = 100.0f;
    float mz = d->o.z-d->eyeheight+1.55f*scale;
    int basetime = -((int)d&0xFFF);
    if(d->state==CS_DEAD)
    {
        int r;
        if(hellpig) { n = 2; r = range[3]; } else { n = (int)d%3; r = range[n]; };
        basetime = d->lastaction;
        int t = lastmillis-d->lastaction;
        if(t<0 || t>20000) return;
        if(t>(r-1)*100) { n += 4; if(t>(r+10)*100) { t -= (r+10)*100; mz -= t*t/10000000000.0f*t; }; };
        if(mz<-1000) return;
        //mdl = (((int)d>>6)&1)+1;
        //mz = d->o.z-d->eyeheight+0.2f;
        //scale = 1.2f;
    }
    else if(d->state==CS_EDITING)                   { n = 16; }
    else if(d->state==CS_LAGGED)                    { n = 17; }
    else if(d->monsterstate==M_ATTACKING)           { n = 8;  }
    else if(d->monsterstate==M_PAIN)                { n = 10; } 
    else if((!d->move && !d->strafe) || !d->moving) { n = 12; } 
    else if(!d->onfloor && d->timeinair>100)        { n = 18; }
    else                                            { n = 14; speed = 1200/d->maxspeed*scale; if(hellpig) speed = 300/d->maxspeed;  }; 
    if(hellpig) { n++; scale *= 32; mz -= 1.9f; };
    rendermodel(mdlname, frame[n], range[n], 0, 1.5f, d->o.x, mz, d->o.y, d->yaw+90, d->pitch/2, team, scale, speed, 0, basetime);
};
Esempio n. 2
0
 int modelpreview(const char *name, int anim, float sizescale, bool overlaid)
 {
     autotab();
     if(sizescale==0) sizescale = 1;
     int size = (int)(sizescale*2*FONTH)-SHADOW;
     if(visible())
     {
         bool hit = ishit(size+SHADOW, size+SHADOW);
         float xs = size, ys = size, xi = curx, yi = cury;
         if(overlaid && hit && actionon)
         {
             hudnotextureshader->set();
             gle::colorf(0, 0, 0, 0.75f);
             rect_(xi+SHADOW, yi+SHADOW, xs, ys);
             hudshader->set();
         }
         int x1 = int(floor(screen->w*(xi*scale.x+origin.x))), y1 = int(floor(screen->h*(1 - ((yi+ys)*scale.y+origin.y)))),
             x2 = int(ceil(screen->w*((xi+xs)*scale.x+origin.x))), y2 = int(ceil(screen->h*(1 - (yi*scale.y+origin.y))));
         glDisable(GL_BLEND);
         modelpreview::start(x1, y1, x2-x1, y2-y1, overlaid);
         model *m = loadmodel(name);
         if(m)
         {
             entitylight light;
             light.color = vec(1, 1, 1);
             light.dir = vec(0, -1, 2).normalize();
             vec center, radius;
             m->boundbox(center, radius);
             float yaw;
             vec o = calcmodelpreviewpos(radius, yaw).sub(center);
             rendermodel(&light, name, anim, o, yaw, 0, 0, NULL, NULL, 0);
         }
         modelpreview::end();
         hudshader->set();
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glEnable(GL_BLEND);
         if(overlaid)
         {
             if(hit)
             {
                 hudnotextureshader->set();
                 glBlendFunc(GL_ZERO, GL_SRC_COLOR);
                 gle::colorf(1, 0.5f, 0.5f);
                 rect_(xi, yi, xs, ys);
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                 hudshader->set();
             }
             if(!overlaytex) overlaytex = textureload("data/guioverlay.png", 3);
             gle::color(light);
             glBindTexture(GL_TEXTURE_2D, overlaytex->id);
             rect_(xi, yi, xs, ys, 0);
         }
     }
     return layout(size+SHADOW, size+SHADOW);
 }
Esempio n. 3
0
 void renderent(entity &e)
 {
     /* FIXME: if the item list change, this hack will be messed */

     defformatstring(widn)("modmdlpickup%d", e.type-3);
     defformatstring(mdlname)("pickups/%s", identexists(widn)?getalias(widn):

     entmdlnames[e.type-I_CLIPS+(m_lss(gamemode, mutators) && e.type==I_GRENADE ? 5:0)]);

     float z = (float)(1+sinf(lastmillis/100.0f+e.x+e.y)/20), yaw = lastmillis/10.0f;
     rendermodel(mdlname, ANIM_MAPMODEL|(e.spawned ? 0 : ANIM_TRANSLUCENT)|ANIM_LOOP|ANIM_DYNALLOC, 0, 0, vec(e.x, e.y, z+S(e.x, e.y)->floor+e.attr1), yaw, 0);
 }
void rpgobstacle::render(bool mainpass)
{
	rendermodel(&light, temp.mdl, ANIM_MAPMODEL|ANIM_LOOP, vec(o).sub(vec(0, 0, eyeheight)), yaw + 90, pitch, 0, MDL_SHADOW|MDL_CULL_DIST|MDL_CULL_OCCLUDED|MDL_LIGHT|MDL_DYNLIGHT, NULL, NULL, 0, 0, temp.alpha);
}
Esempio n. 5
0
void rpgobstacle::render()
{
	rendermodel(temp.mdl, ANIM_MAPMODEL|ANIM_LOOP, vec(o).sub(vec(0, 0, eyeheight)), yaw, pitch, roll, MDL_CULL_DIST|MDL_CULL_OCCLUDED, NULL, NULL, 0, 0, 1, temp.alpha);
}
Esempio n. 6
0
 int modelpreview(const char *name, int anim, float sizescale, bool overlaid)
 {
     autotab();
     if(sizescale==0) sizescale = 1;
     int size = (int)(sizescale*2*FONTH)-SHADOW;
     if(visible())
     {
         bool hit = ishit(size+SHADOW, size+SHADOW);
         float xs = size, ys = size, xi = curx, yi = cury;
         if(overlaid && hit && actionon)
         {
             glDisable(GL_TEXTURE_2D);
             notextureshader->set();
             glColor4f(0, 0, 0, 0.75f);
             rect_(xi+SHADOW, yi+SHADOW, xs, ys);
             glEnable(GL_TEXTURE_2D);
             defaultshader->set();
         }
         int x1 = int(floor(screenw*(xi*scale.x+origin.x))), y1 = int(floor(screenh*(1 - ((yi+ys)*scale.y+origin.y)))),
             x2 = int(ceil(screenw*((xi+xs)*scale.x+origin.x))), y2 = int(ceil(screenh*(1 - (yi*scale.y+origin.y))));
         glViewport(x1, y1, x2-x1, y2-y1);
         glScissor(x1, y1, x2-x1, y2-y1);
         glEnable(GL_SCISSOR_TEST);
         glDisable(GL_BLEND);
         modelpreview::start(overlaid);
         model *m = loadmodel(name);
         if(m)
         {
             entitylight light;
             light.color = vec(1, 1, 1);
             light.dir = vec(0, -1, 2).normalize();
             vec center, radius;
             m->boundbox(center, radius);
             float dist =  2.0f*max(radius.magnitude2(), 1.1f*radius.z),
                   yaw = fmod(lastmillis/10000.0f*360.0f, 360.0f);
             vec o(-center.x, dist - center.y, -0.1f*dist - center.z);
             rendermodel(&light, name, anim, o, yaw, 0, 0, NULL, NULL, 0);
         }
         modelpreview::end();
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glEnable(GL_BLEND);
         glDisable(GL_SCISSOR_TEST);
         glViewport(0, 0, screenw, screenh);
         if(overlaid)
         {
             if(hit)
             {
                 glDisable(GL_TEXTURE_2D);
                 notextureshader->set();
                 glBlendFunc(GL_ZERO, GL_SRC_COLOR);
                 glColor3f(1, 0.5f, 0.5f);
                 rect_(xi, yi, xs, ys);
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                 glEnable(GL_TEXTURE_2D);
                 defaultshader->set();
             }
             if(!overlaytex) {
                 string otname;
                 inexor::filesystem::appendmediadir(otname, "guioverlay.png", DIR_UI);
                 overlaytex = textureload(otname, 3);
             }
             glColor3fv(light.v);
             glBindTexture(GL_TEXTURE_2D, overlaytex->id);
             rect_(xi, yi, xs, ys, 0);
         }
     }
     return layout(size+SHADOW, size+SHADOW);
 }
Esempio n. 7
0
void rpgitem::render()
{
	vec4 col(colour, temp.alpha);
	rendermodel(temp.mdl, ANIM_MAPMODEL|ANIM_LOOP, vec(o).sub(vec(0, 0, eyeheight)), yaw, pitch, roll, MDL_CULL_DIST|MDL_CULL_OCCLUDED, NULL, NULL, 0, 0, getscale(), col);
}