diff --git a/config/scontext.cfg b/config/scontext.cfg index 9a1ab0b2..31782554 100644 --- a/config/scontext.cfg +++ b/config/scontext.cfg @@ -10,7 +10,7 @@ context_mdlcfg = 4 // mdl configs, same // set allowed commands for the map config context mapcfgidents = [ loadnotexture loadsky mapmodelreset mapmodel texturereset texture fog fogcolour mapsoundreset mapsound watercolour shadowyaw ] -mdlcfgidents = [ md2anim md2emit md2tag md3anim md3emit md3link md3load md3skin mdlalphatest mdlcachelimit mdlcullface mdlscale mdlshadowdist mdltrans mdltranslucent mdlvertexlight] +mdlcfgidents = [ md2anim md2emit md2tag md3anim md3emit md3link md3load md3skin mdlalphatest mdlalphablend mdlcachelimit mdlcullface mdlscale mdlshadowdist mdltrans mdltranslucent mdlvertexlight] loop i (listlen $mapcfgidents) [ scriptcontext $context_mapcfg (at $mapcfgidents $i) ] loop i (listlen $mdlcfgidents) [ scriptcontext $context_mdlcfg (at $mdlcfgidents $i) ] diff --git a/packages/models/mapmodels/toca/doors/1/md3.cfg b/packages/models/mapmodels/toca/doors/1/md3.cfg index 784ff0e5..0658cd88 100644 --- a/packages/models/mapmodels/toca/doors/1/md3.cfg +++ b/packages/models/mapmodels/toca/doors/1/md3.cfg @@ -10,3 +10,4 @@ mdlalphablend 1 mdltranslucent 100 //mdlalphatest 30 //mdlalphatexture 1 + diff --git a/source/src/model.h b/source/src/model.h index 033fef5f..db4b42cc 100644 --- a/source/src/model.h +++ b/source/src/model.h @@ -41,12 +41,13 @@ class dynent; struct model { - bool cullface, vertexlight; + bool cullface, vertexlight, alphablend; //ALX Alpha channel models float alphatest, translucency, scale, radius, shadowdist; 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() : 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() : cullface(true), vertexlight(false), alphablend(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; diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 7783d833..92985cb3 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -44,6 +44,13 @@ void mdlalphatest(int *alphatest) COMMAND(mdlalphatest, "i"); +void mdlalphablend(int *alphablend) //ALX Alpha channel models +{ + checkmdl; + loadingmodel->alphablend = *alphablend!=0; +} +COMMAND(mdlalphablend, "i"); + void mdlscale(int *percent) { checkmdl; @@ -219,7 +226,8 @@ void renderbatchedmodel(model *m, batchedmodel &b) m->setskin(b.tex); - if(b.anim&ANIM_TRANSLUCENT) + //if(b.anim&ANIM_TRANSLUCENT) + if(b.anim&ANIM_TRANSLUCENT || m->alphablend) //ALX Alpha channel models { 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); @@ -236,7 +244,8 @@ void renderbatchedmodel(model *m, batchedmodel &b) m->render(b.anim, b.varseed, b.speed, b.basetime, b.o, b.yaw, b.pitch, b.d, a, b.scale); - if(b.anim&ANIM_TRANSLUCENT) + //if(b.anim&ANIM_TRANSLUCENT) + if(b.anim&ANIM_TRANSLUCENT || m->alphablend) //ALX Alpha channel models { glDepthFunc(GL_LESS); glDisable(GL_BLEND); @@ -304,7 +313,8 @@ void endmodelbatches(bool flush) loopvj(b.batched) { batchedmodel &bm = b.batched[j]; - if(bm.anim&ANIM_TRANSLUCENT) + //if(bm.anim&ANIM_TRANSLUCENT) + if(bm.anim&ANIM_TRANSLUCENT || b.m->alphablend) //ALX Alpha channel models { translucentmodel &tm = translucent.add(); tm.m = b.m;