コード例 #1
0
ファイル: rendermd2.cpp プロジェクト: bsegovia/cube-gles
void mapmodel(char *rad, char *h, char *zoff, char *snap, char *name)
{
  md2 *m = loadmodel(name);
  mapmodelinfo mmi = { atoi(rad), atoi(h), atoi(zoff), atoi(snap), m->loadname };
  m->mmi = mmi;
  mapmodels.add(m);
}
コード例 #2
0
ファイル: world.cpp プロジェクト: Kid-Matthew/lamiae
bool getentboundingbox(extentity &e, ivec &o, ivec &r)
{
    switch(e.type)
    {
        case ET_EMPTY:
            return false;
        case ET_MAPMODEL:
        {
            model *m = loadmodel(NULL, e.attr[1]);
            if(m)
            {
                vec center, radius;
                m->boundbox(center, radius);
                rotatebb(center, radius, e.attr[0]);

                o = e.o;
                o.add(center);
                r = radius;
                r.add(1);
                o.sub(r);
                r.mul(2);
                break;
            }
        }
        // invisible mapmodels use entselradius
        default:
            o = e.o;
            o.sub(entselradius);
            r.x = r.y = r.z = entselradius*2;
            break;
    }
    return true;
}
コード例 #3
0
ファイル: 3dgui.cpp プロジェクト: deathstar/sauerbraten
 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);
 }
コード例 #4
0
ファイル: rendermd2.cpp プロジェクト: bsegovia/cube-gles
void rendermodel(const char *mdl, int frame, int range, int tex,
                 float rad, float x, float y, float z,
                 float yaw, float pitch, bool teammate,
                 float scale, float speed, int snap, int basetime)
{
  md2 *m = loadmodel(mdl);

  if (world::isoccluded(player1->o.x, player1->o.y, x-rad, z-rad, rad*2))
    return;

  delayedload(m);

  int xs, ys;
  ogl::bindtexture(GL_TEXTURE_2D, tex ? ogl::lookuptex(tex, xs, ys) : FIRSTMDL+m->mdlnum);

  const int ix = (int)x;
  const int iy = (int)z;
  vec light(1.0f, 1.0f, 1.0f);

  if (!OUTBORD(ix, iy)) {
    sqr *s = S(ix,iy);
    const float ll = 256.0f; // 0.96f;
    const float of = 0.0f; // 0.1f;
    light.x = s->r/ll+of;
    light.y = s->g/ll+of;
    light.z = s->b/ll+of;
  }

  if (teammate) {
    light.x *= 0.6f;
    light.y *= 0.7f;
    light.z *= 1.2f;
  }

  m->render(light, frame, range, x, y, z, yaw, pitch, scale, speed, snap, basetime);
}
コード例 #5
0
ファイル: rendermodel.cpp プロジェクト: acidbarrel/Torment
void abovemodel(vec &o, const char *mdl)
{
    model *m = loadmodel(mdl);
    if(!m) return;
    o.z += m->above(0/*frame*/);
};
コード例 #6
0
ファイル: rendermodel.cpp プロジェクト: acidbarrel/Torment
void rendermodel(vec &color, vec &dir, const char *mdl, int anim, int varseed, int tex, float x, float y, float z, float yaw, float pitch, float speed, int basetime, dynent *d, int cull, const char *vwepmdl)
{
    model *m = loadmodel(mdl); 
    if(!m) return;
    if(cull)
    {
        vec center;
        float radius = m->boundsphere(0/*frame*/, center);   // FIXME
        center.add(vec(x, y, z));
        if((cull&MDL_CULL_DIST) && center.dist(camera1->o)/radius>maxmodelradiusdistance) return;
        if(cull&MDL_CULL_VFC)
        {
            if(refracting)
            {
                if(center.z+radius<refracting-waterfog || center.z-radius>=refracting) return;
            }
            else if(reflecting && center.z+radius<=reflecting) return;
            if((reflecting || refracting) && center.dist(camera1->o)-radius>reflectdist) return;
            if(isvisiblesphere(radius, center) >= VFC_FOGGED) return;
        };
        if((cull&MDL_CULL_OCCLUDED) && modeloccluded(center, radius)) return;
    };
    if(showboundingbox)
    {
        if(d) render3dbox(d->o, d->eyeheight, d->aboveeye, d->radius);
        else if((anim&ANIM_INDEX)!=ANIM_GUNSHOOT && (anim&ANIM_INDEX)!=ANIM_GUNIDLE)
        {
            vec center, radius;
            if(showboundingbox==1) m->collisionbox(0, center, radius);
            else m->boundbox(0, center, radius);
            rotatebb(center, radius, int(yaw));
            center.add(vec(x, y, z));
            render3dbox(center, radius.z, radius.z, radius.x, radius.y);
        };
    };

    if(d) lightreaching(d->o, color, dir);
    m->setskin(tex);  
    glColor3fv(color.v);
    m->setshader();
    if(renderpath!=R_FIXEDFUNCTION)
    {
        vec rdir(dir);
        rdir.rotate_around_z((-yaw-180.0f)*RAD);
        rdir.rotate_around_y(-pitch*RAD);
        glProgramEnvParameter4f_(GL_VERTEX_PROGRAM_ARB, 0, rdir.x, rdir.y, rdir.z, 0);

        vec camerapos = vec(player->o).sub(vec(x, y, z));
        camerapos.rotate_around_z((-yaw-180.0f)*RAD);
        camerapos.rotate_around_y(-pitch*RAD);
        glProgramEnvParameter4f_(GL_VERTEX_PROGRAM_ARB, 1, camerapos.x, camerapos.y, camerapos.z, 1);

        if(refracting) setfogplane(1, refracting - z);
    };

    model *vwep = NULL;
    if(vwepmdl)
    {
        vwep = loadmodel(vwepmdl);
        if(vwep->type()!=m->type()) vwep = NULL;
    };

    if(!m->cullface) glDisable(GL_CULL_FACE);
    m->render(anim, varseed, speed, basetime, x, y, z, yaw, pitch, d, vwep);
    if(!m->cullface) glEnable(GL_CULL_FACE);
};
コード例 #7
0
ファイル: 3dgui.cpp プロジェクト: Boom-Rang/inexor-code
 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);
 }