Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

dispmap.h

Go to the documentation of this file.
00001 // dispmap.h
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #ifndef _DISPMAP_H_
00011 #define _DISPMAP_H_
00012 
00013 #include <string>
00014 #include <celmath/vecmath.h>
00015 
00016 
00017 typedef float (*DisplacementMapFunc)(float, float, void*);
00018 
00019 class DisplacementMap
00020 {
00021  public:
00022     DisplacementMap(int w, int h); 
00023     ~DisplacementMap();
00024     int getWidth() const { return width; };
00025     int getHeight() const { return height; };
00026     inline float getDisplacement(int x, int y) const;
00027     inline void setDisplacement(int x, int y, float d);
00028     void generate(DisplacementMapFunc func, void* info = NULL);
00029     void clear();
00030     
00031  private:
00032     int width;
00033     int height;
00034     float* disp;
00035 };
00036 
00037 // extern DisplacementMap* LoadDisplacementMap(std::string filename);
00038 
00039 
00040 float DisplacementMap::getDisplacement(int x, int y) const
00041 {
00042     return disp[y * width + x];
00043 }
00044 
00045 void DisplacementMap::setDisplacement(int x, int y, float d)
00046 {
00047     disp[y * width + x] = d;
00048 }
00049 
00050 #endif // _DISPMAP_H_

Generated on Sat Jan 14 22:30:27 2006 for Celestia by  doxygen 1.4.1