At the moment the mapmakers can't create green maps, cause trees are read from the texturemap instead of the metal map. This is really anoying for the mapmakers.
So to the coders, please fix the mapconv so the trees and the grass is read from the metalmap, it would be really helpfull .....
NOiZE
MAPCONV
Moderator: Moderators
Gah
I tried... Spent most of the day trying to get it to compile (friggin had to manually make it ignore LIBC.lib)
Thought I got it right, but after I loaded my map and hit enter to begin... It ate my compooter... Like 5 mins to bring up taskmgr :)
anyhow this is what I tried:
That's what my FeatureCreator.cpp looked like... rest was from the src zip.
Note:One thing thats confused the crap out of me is originally it was But 'a' is undeclared at that point, and definitely was undeclared at that point in the original FeatureCreator.cpp... And not there was no formatting in the ""s for an int there.
So I have no idea whut I done to it by removing the a, heh.
Maybe someone better than I (not saying much) can pick this up and in 30s turn out a working version....
Thought I got it right, but after I loaded my map and hit enter to begin... It ate my compooter... Like 5 mins to bring up taskmgr :)
anyhow this is what I tried:
Code: Select all
#include "StdAfx.h"
#include ".\featurecreator.h"
#define NUM_TREE_TYPES 16
#define treetop 215
extern float* heightmap;
CFeatureCreator::CFeatureCreator(void)
{
}
CFeatureCreator::~CFeatureCreator(void)
{
}
void CFeatureCreator::WriteToFile(ofstream* file)
{
//write vegetation map
file->write((char*)vegMap,xsize/4*ysize/4);
delete[] vegMap;
//write features
MapFeatureHeader fh;
fh.numFeatures=(int)features.size();
fh.numFeatureType=NUM_TREE_TYPES+1;
printf("Writing %i features\n",fh.numFeatures);
file->write((char*)&fh,sizeof(fh));
for(int a=0;a<NUM_TREE_TYPES;++a){
char c[100];
sprintf(c,"TreeType%i",a);
file->write(c,(int)strlen(c)+1);
}
char c[100];
sprintf(c,"GeoVent");
file->write(c,(int)strlen(c)+1);
for(vector<MapFeatureStruct>::iterator fi=features.begin();fi!=features.end();++fi){
file->write((char*)&*fi,sizeof(MapFeatureStruct));
}
}
void CFeatureCreator::CreateFeatures(CBitmap* bm, int startx, int starty,std::string metalfile)
{
printf("Creating features\n");
xsize=bm->xsize/8;
ysize=bm->ysize/8;
int mapx=xsize+1;
//geovents
CBitmap vent("geovent.bmp");
CBitmap metal(metalfile); //use the green channel for geos
// moved tree n Grassdefs
vegMap=new unsigned char[xsize/4*ysize/4];
memset(vegMap,0,xsize/4*ysize/4);
unsigned char* map=new unsigned char[ysize*xsize];
for(int y=0;y<metal.ysize;++y){
for(int x=0;x<metal.xsize;++x){
unsigned char c=metal.mem[(y*metal.xsize+x)*4+1];
if(c>127){
int bx=x*xsize/metal.xsize;
int by=y*ysize/metal.ysize;
for(int tries=0;tries<1000;++tries){
int x=bx+rand()*(40)/RAND_MAX-20;
int y=by+rand()*(40)/RAND_MAX-20;
if(x<5)
x=5;
if(x>xsize-5)
x=xsize-5;
if(y<5)
y=5;
if(y>ysize-5)
y=ysize-5;
float h=heightmap[y*mapx+x];
if(h<5)
continue;
bool good=true;
for(int y2=y-3;y2<=y+3;++y2){
for(int x2=x-3;x2<=x+3;++x2){
if(fabs(h-heightmap[(y2)*mapx+x2])>3)
good=false;
}
}
if(good){
if(c=255){
MapFeatureStruct ffs;
ffs.featureType=NUM_TREE_TYPES;
ffs.relativeSize=1;
ffs.rotation=0;
ffs.xpos=(float)x*8+4;
ffs.ypos=0;
ffs.zpos=(float)y*8+4;
features.push_back(ffs);
for(int y2=0;y2<vent.ysize;++y2){
for(int x2=0;x2<vent.xsize;++x2){
if(vent.mem[(y2*vent.xsize+x2)*4+0]!=255 || vent.mem[(y2*vent.xsize+x2)*4+2]!=255){
bm->mem[((y*8+y2-vent.ysize/2)*bm->xsize+x*8+x2-vent.xsize/2)*4+0]=vent.mem[(y2*vent.xsize+x2)*4+0];
bm->mem[((y*8+y2-vent.ysize/2)*bm->xsize+x*8+x2-vent.xsize/2)*4+1]=vent.mem[(y2*vent.xsize+x2)*4+1];
bm->mem[((y*8+y2-vent.ysize/2)*bm->xsize+x*8+x2-vent.xsize/2)*4+2]=vent.mem[(y2*vent.xsize+x2)*4+2];
}
}
}
break;
}
//trees metalmap green 200-216
if(c>199 && c<=treetop){
int t_type=(c-200);
map[y*xsize+x]=1;
MapFeatureStruct ffs;
ffs.featureType=t_type;
ffs.relativeSize=0.8f+float(rand())/RAND_MAX*0.4f;
ffs.rotation=0;
ffs.xpos=(float)startx+x*8+4;
ffs.ypos=0;
ffs.zpos=(float)starty+y*8+4;
features.push_back(ffs);
}
//Grass metalmap green 128 & not under water
if(c=128 && heightmap[(y*4+2)*mapx+x*4+2]>2){
vegMap[y*xsize/4+x]=1;
}
}
}
}
}
}
}
That's what my FeatureCreator.cpp looked like... rest was from the src zip.
Note:One thing thats confused the crap out of me is
Code: Select all
sprintf(c,"GeoVent");
Code: Select all
sprintf(c,"GeoVent",a);
So I have no idea whut I done to it by removing the a, heh.
Maybe someone better than I (not saying much) can pick this up and in 30s turn out a working version....
- [K.B.] Napalm Cobra
- Posts: 1222
- Joined: 16 Aug 2004, 06:15