navi homePPSaboutscreenshotsdownloaddevelopmentforum

Opened 17 years ago

Closed 15 years ago

#17 closed defect (fixed)

Height Map Terrain

Reported by: bensch Owned by: bottac
Priority: minor Milestone: 0.3.5_playability orx-v0
Component: Importer Version:
Keywords: Cc:
Referenced By: References:


A HeightMapTerrain is a class, that reads in a grey-scale image. Black is low terrain, White is high. Like this it should be very easy possible, to create good looking landscapes.
The process is called displacement and can also be applied to other bodies than flat surfaces. ⇒ Ideas?

  • The class must be able to
    • read in a texture as an SDL_surface.
      bool Material::loadImage(char* imageName, GLuint* texture)
        char* imgNameWithPath = searchTextureInPaths(imageName);
        if (imgNameWithPath)
            SDL_Surface* map;
            Image* pImage = new Image;
      	  PRINTF(1)("IMG_Load: %s\n", IMG_GetError());
      	  return false;
            pImage->height = map->h;
            pImage->width  = map->w;
            pImage->data   = (GLubyte*)map->pixels;
            if( !IMG_isPNG(SDL_RWFromFile(imgNameWithPath, "rb")) && !IMG_isJPG(SDL_RWFromFile(imgNameWithPath, "rb")))
      	for (int i=0;i<map->h * map->w *3;i+=3)
      	    GLuint temp = pImage->data[i];
      	    pImage->data[i] = pImage->data[i+2];
      	    pImage->data[i+2] = temp;
            this->applyItToAHitghtMap (pImage, texture);
            PRINTF(1)("Image not Found: %s\n", imgNameWithPath);
            return false;
    • then it should apply what it learnt to the heightMap (use the struct given below to pass info)
        struct Image
          int rowSpan;    //!< The count of the rows this Image has.
          GLuint width;   //!< The width of the Image.
          GLuint height;  //!< The height of the Image.
          GLuint bpp;     //!< BitsPerPixel
          GLuint type;    //!< Type of the Image.
          GLubyte *data;  //!< The Image Data comes here! DANGER: uncompressed data. Delete it!
    • Then Transform the mesh, pack it into (multipe) display lists, and give it back to orxonox.
  • Look out!
    • Loading will heappen at levelstart, so it can use some time.
    • During the Game-runtime there may be no delay.
    Look, that your algorithm covers this.

Change History (5)

comment:1 Changed 17 years ago by bensch

  • Owner changed from bensch to nico

comment:2 Changed 16 years ago by bensch

  • Milestone changed from 0.2.3-pre-alpha to feature-taks

comment:3 Changed 16 years ago by bottac

  • Owner changed from nico to bottac
  • Status changed from new to assigned

comment:4 Changed 16 years ago by patrick

  • Milestone changed from feature-taks to 0.3.5_playability

comment:5 Changed 15 years ago by bensch

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.