Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Spezialkartenerstellung - automatisch?
#2
Das Karteformat stammt aus der Computersteinzeit. Es geht nicht viel simpler as so: (Das "Format" ist das PPM-Format.)

Code:
/**
* Calculates preview from height map
* @param filename name of heightfield file
* @author Hajo/prissi
*/
bool
welt_gui_t::update_from_heightfield(const char *filename)
{
    FILE *file = fopen(filename, "rb");
    if(file) {
        char buf [256];
        int w, h;
        
        read_line(buf, 255, file);
        if(buf[0]!='P'  ||  buf[1]!='6') {
            return false;
        }
        
        read_line(buf, 255, file);
        sscanf(buf, "%d %d", &w, &h);
    
        read_line(buf, 255, file);
        if(buf[0]!='2'  ||  buf[1]!='5'  ||  buf[2]!='5') {
            return false;
        }
        for(int y=0, y=0; y<h; y++) {
            // new line?
            for(int x=0; x<w; x++) {
                sint16 R = (unsigned char)fgetc(file);
                sint16 G = (unsigned char)fgetc(file);
                sint16 B = (unsigned char)fgetc(file);
                    
                karte[(y*w)+x] = reliefkarte_t::calc_hoehe_farbe( (((R*2+G*3+B)/4 - 224+16)&(sint16)0xFFF0), sets->gib_grundwasser() );
            }
        }
Zitieren


Nachrichten in diesem Thema
Spezialkartenerstellung - automatisch? - von Actroshasser - 03-08-2006, Thursday-11:29:11
[Kein Betreff] - von prissi - 03-08-2006, Thursday-12:01:18
[Kein Betreff] - von Wurzelgnom - 03-08-2006, Thursday-17:02:59
[Kein Betreff] - von HaJo4 - 04-05-2007, Friday-03:16:29
[Kein Betreff] - von Wurzelgnom - 04-05-2007, Friday-15:06:38
[Kein Betreff] - von HaJo4 - 04-05-2007, Friday-17:00:04
[Kein Betreff] - von Wurzelgnom - 04-05-2007, Friday-18:19:18

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste