experimental: add per-slot mapmodel scale factors
4th parameter of the "mapmodel" command is now a scale factor between 0.25 and 4.0. Values outside that range (like the dummy zero from old map config files) are interpreted as 1.0 Scaling does not affect the clipping, which has to be adjusted manually. DOCREF mapmodel editmapmodelslot
This commit is contained in:
@@ -78,7 +78,7 @@ void rendermapmodels()
|
||||
{
|
||||
mapmodelinfo &mmi = getmminfo(e.attr2);
|
||||
if(!&mmi) continue;
|
||||
rendermodel(mmi.name, ANIM_MAPMODEL|ANIM_LOOP, e.attr4, 0, vec(e.x, e.y, S(e.x, e.y)->floor + mmi.zoff + float(e.attr3) / ENTSCALE5), e.attr6, float(e.attr1) / ENTSCALE10, float(e.attr5) / ENTSCALE10, 10.0f);
|
||||
rendermodel(mmi.name, ANIM_MAPMODEL|ANIM_LOOP, e.attr4, 0, vec(e.x, e.y, S(e.x, e.y)->floor + mmi.zoff + float(e.attr3) / ENTSCALE5), e.attr6, float(e.attr1) / ENTSCALE10, float(e.attr5) / ENTSCALE10, 10.0f, 0, NULL, NULL, mmi.scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ struct model
|
||||
virtual void endrender() {}
|
||||
};
|
||||
|
||||
struct mapmodelinfo { int rad, h, zoff; string name; model *m; };
|
||||
struct mapmodelinfo { int rad, h, zoff; float scale; string name; model *m; };
|
||||
|
||||
enum { MMA_KEYWORDS = 0, MMA_DESC, MMA_DEFAULTPARAMS, MMA_USAGE, MMA_AUTHOR, MMA_LICENSE, MMA_DISTRIBUTION, MMA_VERSION, MMA_NUM };
|
||||
|
||||
|
||||
@@ -109,16 +109,19 @@ vector<mapmodelinfo> mapmodels;
|
||||
const char *mmpath = "mapmodels/";
|
||||
const char *mmshortname(const char *name) { return !strncmp(name, mmpath, strlen(mmpath)) ? name + strlen(mmpath) : name; }
|
||||
|
||||
void mapmodel(int *rad, int *h, int *zoff, char *snap, char *name)
|
||||
void mapmodel(int *rad, int *h, int *zoff, char *scale, char *name)
|
||||
{
|
||||
if(*snap && *name) // ignore "mapmodel" commands with insufficient parameters
|
||||
if(*scale && *name) // ignore "mapmodel" commands with insufficient parameters
|
||||
{
|
||||
intret(mapmodels.length());
|
||||
mapmodelinfo &mmi = mapmodels.add();
|
||||
mmi.rad = *rad;
|
||||
mmi.h = *h;
|
||||
mmi.zoff = *zoff;
|
||||
mmi.scale = atof(scale);
|
||||
if(mmi.scale < 0.25f || mmi.scale > 4.0f) mmi.scale = 1.0f;
|
||||
mmi.m = NULL;
|
||||
|
||||
filtertext(name, name, FTXT__MEDIAFILEPATH);
|
||||
formatstring(mmi.name)("%s%s", mmpath, name);
|
||||
mapmodelchanged = 1;
|
||||
@@ -182,24 +185,27 @@ void deletemapmodelslot(int *n, char *opt) // delete mapmodel slot - only if unu
|
||||
}
|
||||
COMMAND(deletemapmodelslot, "is");
|
||||
|
||||
void editmapmodelslot(int *n, char *rad, char *h, char *zoff, char *snap, char *name) // edit slot parameters != ""
|
||||
void editmapmodelslot(int *n, char *rad, char *h, char *zoff, char *scale, char *name) // edit slot parameters != ""
|
||||
{
|
||||
string res = "";
|
||||
if(!noteditmode("editmapmodelslot") && !multiplayer(true) && mapmodels.inrange(*n))
|
||||
{
|
||||
mapmodelinfo &mmi = mapmodels[*n];
|
||||
if(*rad || *h || *zoff || *snap || *name)
|
||||
if(*rad || *h || *zoff || *scale || *name)
|
||||
{ // change attributes
|
||||
if(*rad) mmi.rad = strtol(rad, NULL, 0);
|
||||
if(*h) mmi.h = strtol(h, NULL, 0);
|
||||
if(*zoff) mmi.zoff = strtol(zoff, NULL, 0);
|
||||
float s = atof(scale);
|
||||
if(s < 0.25f || s > 4.0f) s = 1.0f;
|
||||
if(*scale) mmi.scale = s;
|
||||
mmi.m = NULL;
|
||||
if(*name) formatstring(mmi.name)("%s%s", mmpath, name);
|
||||
unsavededits++;
|
||||
mapmodelchanged = 1;
|
||||
hdr.flags |= MHF_AUTOMAPCONFIG; // requires automapcfg
|
||||
}
|
||||
formatstring(res)("%d %d %d 0 \"%s\"", mmi.rad, mmi.h, mmi.zoff, mmshortname(mmi.name)); // give back all current attributes
|
||||
formatstring(res)("%d %d %d %s \"%s\"", mmi.rad, mmi.h, mmi.zoff, floatstr(mmi.scale, true), mmshortname(mmi.name)); // give back all current attributes
|
||||
}
|
||||
result(res);
|
||||
}
|
||||
@@ -606,7 +612,7 @@ void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, fl
|
||||
|
||||
if(rad >= 0)
|
||||
{
|
||||
if(!rad) rad = m->radius;
|
||||
if(!rad) rad = m->radius * scale;
|
||||
if(isoccluded(camera1->o.x, camera1->o.y, o.x-rad, o.y-rad, rad*2)) return;
|
||||
}
|
||||
|
||||
|
||||
@@ -427,7 +427,7 @@ void getcurrentmapconfig(vector<char> &f, bool onlysounds)
|
||||
{
|
||||
mapmodelinfo &mmi = getmminfo(i);
|
||||
if(!&mmi) break;
|
||||
cvecprintf(f, "mapmodel %d %d %d 0 \"%s\"\n", mmi.rad, mmi.h, mmi.zoff, mmshortname(mmi.name));
|
||||
cvecprintf(f, "mapmodel %d %d %d %s \"%s\"\n", mmi.rad, mmi.h, mmi.zoff, mmi.scale == 1.0f ? "0" : floatstr(mmi.scale, true), mmshortname(mmi.name));
|
||||
}
|
||||
cvecprintf(f, "\ntexturereset\n");
|
||||
loopi(256)
|
||||
|
||||
Reference in New Issue
Block a user