// colormap.wdl to defined different flora at levelstart on the terrain // by lolek august 2004 // www.lolek.net bmap* mycolormap; entity* myterrain; // B G R var GREEN_cv[3] = 000,255,000; //tree01 var BLUE_cv[3] = 255,000,200; //tree02 var terrain_ver[3] = 0,0,0; //world pos of terrain vertex 1 var create_pos[3]; //create flora on this position var colormap_line; //pixel lines by your colormap bitmap var colormap_column; //pixel columnes by your colormap bitmap var format; //bitmap format by your colormap bitmap var pixel; //pixelcolor by your colormap bitmap var pix_alpha; //pixel alpha 0 var rgb_vec[3]; //red,green,blue vector var flora_temp[3]; //hold flora position if trace var flora_pos[3]; //flora create position string tree01_mdl=; string tree02_mdl=; //contain the terrainscale in WED put the scale into terrain properties SKILL1 //contain the scale from colormap bitmap size to original terrainsize into colormap properties SKILL2 DEFINE TERRAIN_SCALE,skill1; DEFINE COLORMAP_SCALE,skill2; // uses: TERRAIN_SCALE, COLORMAP_SCALE action terrain_floramap //give this action to terrain in WED { myterrain = my; myterrain.TERRAIN_SCALE = my.skill1*2; myterrain.COLORMAP_SCALE = my.skill2*2; ent_vertex(terrain_ver,1); //get vertex 1 pos from WED } action colormap_pointer //give this action to colormap bitmap in WED { mycolormap = bmap_for_entity(my,0); } function set_flora() { my.pan = random(360); vec_set (flora_temp,my.x); flora_temp.z -= 4000; trace_mode = ignore_me + ignore_sprites + ignore_models + use_box; my.z -=trace(my.pos,flora_temp); } function read_colormap() //start this function after level_load { while(mycolormap==NULL){wait(1);} while(colormap_line < bmap_height(mycolormap)){ while(colormap_column < bmap_width(mycolormap)){ format = bmap_lock(mycolormap,0); pixel = pixel_for_bmap(mycolormap,colormap_column,colormap_line); pixel_to_vec(rgb_vec,pix_alpha,format,pixel); // store pixel color in temp bmap_unlock(mycolormap); colormap_column += 1; if(rgb_vec.red==GREEN_cv.red&&rgb_vec.green==GREEN_cv.green&&rgb_vec.blue==GREEN_cv.blue){ create_pos.x=terrain_ver.x+(colormap_column*myterrain.TERRAIN_SCALE)+(myterrain.TERRAIN_SCALE/2)+myterrain.COLORMAP_SCALE; create_pos.y=terrain_ver.y-(colormap_line*myterrain.TERRAIN_SCALE) -(myterrain.TERRAIN_SCALE/2)-myterrain.COLORMAP_SCALE; create_pos.z=terrain_ver.z+2000; ent_create(tree01_mdl,create_pos.x,set_flora); } if(rgb_vec.red==BLUE_cv.red&&rgb_vec.green==BLUE_cv.green&&rgb_vec.blue==BLUE_cv.blue) { create_pos.x=terrain_ver.x+(colormap_column*myterrain.TERRAIN_SCALE)+(myterrain.TERRAIN_SCALE/2)+myterrain.COLORMAP_SCALE; create_pos.y=terrain_ver.y-(colormap_line*myterrain.TERRAIN_SCALE) -(myterrain.TERRAIN_SCALE/2)-myterrain.COLORMAP_SCALE; create_pos.z=terrain_ver.z+2000; ent_create(tree02_mdl,create_pos,set_flora); } } colormap_column = 0; colormap_line += 1; } } on_f read_colormap();