Changeset 8
- Timestamp:
- 30.1.2006 15:20:35 (3 years ago)
- Location:
- SoTerrain
- Files:
-
- 3 added
- 9 modified
-
SoTerrain.kateproject (modified) (2 diffs)
-
TODO (modified) (1 diff)
-
include/geomipmapping/SbGeoMipmapPrimitives.h (added)
-
include/geomipmapping/SoSimpleGeoMipmapTerrain.h (modified) (1 diff)
-
include/profiler/PrProfiler.h (modified) (2 diffs)
-
include/roam/SoSimpleROAMTerrain.h (modified) (1 diff)
-
makefile (modified) (2 diffs)
-
src/SoSimpleGeoMipmapTerrainTest.cpp (added)
-
src/SoSimpleROAMTerrainTest.cpp (modified) (3 diffs)
-
src/geomipmapping/SbGeoMipmapPrimitives.cpp (added)
-
src/geomipmapping/SoSimpleGeoMipmapTerrain.cpp (modified) (1 diff)
-
src/profiler/PrProfiler.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
SoTerrain/SoTerrain.kateproject
r6 r8 5 5 [Dir include/geomipmapping] 6 6 Dirs= 7 Files=SoSimpleGeoMipmapTerrain.h 7 Files=SoSimpleGeoMipmapTerrain.h/SbGeoMipmapPrimitives.h 8 8 9 9 [Dir include/profiler] … … 21 21 [Dir src] 22 22 Dirs=profiler/roam/geomipmapping 23 Files= main.cpp23 Files=SoSimpleGeoMipmapTerrainTest.cpp/SoSimpleROAMTerrainTest.cpp 24 24 25 25 [Dir src/geomipmapping] 26 26 Dirs= 27 Files=SoSimpleGeoMipmapTerrain.cpp 27 Files=SoSimpleGeoMipmapTerrain.cpp/SbGeoMipmapPrimitives.cpp 28 28 29 29 [Dir src/profiler] -
SoTerrain/TODO
r1 r8 1 1. Vypocet normal pro smooth shading.2 - priorita: nizka3 4 2. Generovani triangle-stripu.5 - priorita: nizka6 7 3. Inteligentnejsi vypocet bounding-boxu.8 - priorita: detail9 10 4. Geomorphing11 - priorita: nizka12 13 5. Zjednoduseni odvracenych stran kopcu14 - priorita: stredni15 16 17 memprof18 oprofile19 leaktracer -
SoTerrain/include/geomipmapping/SoSimpleGeoMipmapTerrain.h
r6 r8 29 29 /////////////////////////////////////////////////////////////////////////////// 30 30 31 // OpenInventor includy 32 #include <Inventor/fields/SoSFBool.h> 33 #include <Inventor/fields/SoSFInt32.h> 34 #include <Inventor/nodes/SoShape.h> 35 #include <Inventor/elements/SoCoordinateElement.h> 36 #include <Inventor/elements/SoTextureCoordinateElement.h> 37 #include <Inventor/elements/SoViewVolumeElement.h> 38 #include <Inventor/actions/SoGLRenderAction.h> 39 40 // lokalni includy 41 #include <geomipmapping/SbGeoMipmapPrimitives.h> 42 #include <profiler/PrProfiler.h> 43 #include <debug.h> 44 45 class SoSimpleGeoMipmapTerrain : public SoShape 46 { 47 SO_NODE_HEADER(SoSimpleGeoMipmapTerrain); 48 public: 49 /* Metody */ 50 static void initClass(); 51 SoSimpleGeoMipmapTerrain(); 52 /* Pole. */ 53 SoSFInt32 mapSize; 54 SoSFInt32 tileSize; 55 SoSFInt32 pixelError; 56 SoSFBool frustrumCulling; 57 SoSFBool freeze; 58 protected: 59 /* Metody */ 60 virtual void generatePrimitives(SoAction * action); 61 virtual void computeBBox(SoAction * action, SbBox3f & box, 62 SbVec3f & center); 63 inline bool isInViewVolume(SbGeoMipmapTile * tile); 64 inline float computePriority(SbGeoMipmapTile * tile); 65 /* Datove polozky. */ 66 const SoCoordinateElement * coords; 67 const SoTextureCoordinateElement * texture_coords; 68 const SbViewVolume * view_volume; 69 /* Konstanty. */ 70 static const int DEFAULT_PIXEL_ERROR = 20; 71 private: 72 /* Metody */ 73 virtual ~SoSimpleGeoMipmapTerrain(); 74 }; 75 31 76 #endif -
SoTerrain/include/profiler/PrProfiler.h
r6 r8 29 29 /////////////////////////////////////////////////////////////////////////////// 30 30 31 #ifdef PROFILE 32 31 33 #include <cstdlib> 32 34 #include <vector> 33 35 #include <fstream> 34 #include <time.h> 36 #ifdef __GNUC__ 37 #include <sys/time.h> 38 #else 39 #include <time.h> 40 #endif 35 41 36 42 #include <iostream> … … 120 126 /* Makra pro snadnejsi pouzivani PrProfiler. Jsou funkcni pouze tehdy, je-li 121 127 definovana promenna preprocesoru PROFILE. */ 122 #ifdef PROFILE 123 /** Urci zacatek profilovani. 124 Zacatek profilovani algoritmu s nazvem \p name. */ 125 #define PR_START_PROFILE(name)\126 static int name##_id = PrProfiler::getAlgId(#name); \127 PrProfiler::startProfile(name##_id) 128 /** Urci zacatek profilovani (objektova verze). 129 Zacatek profilovani algoritmu s nazvem \p name patriciho objektu \p object. */ 130 #define PR_START_OBJ_PROFILE(name, object)\131 static int name##_id = PrProfiler::getAlgId(#name); \132 PrProfiler::startProfile(name##_id, object) 133 /** Urci konec profilovani. 134 Konec profilovani algoritmu s nazvem \p name. */ 135 #define PR_STOP_PROFILE(name) PrProfiler::stopProfile(name##_id) 136 /** Urci konec profilovani (objektova verze). 137 Konec profilovani algoritmu s nazvem \p name patriciho objektu \p object. */ 138 #define PR_STOP_OBJ_PROFILE(name, object) \139 PrProfiler::stopProfile(name##_id, object) 140 /** Inicializace profileru. 141 Incializace celeho profileru, je nutno zavolat pred jeho pouzitim, 142 nelepe na zacatku programu. */ 143 #define PR_INIT_PROFILER() PrProfiler::initProfiler() 144 /** Tisk vysledku profilovani. 145 Vytiskne vysledky profilovani na konec souboru \p filename ve formatu 146 definovanem v PrProfiler::printResults(). */ 147 #define PR_PRINT_RESULTS(filename) PrProfiler::printResults(filename) 128 /** Urci zacatek profilovani. 129 Zacatek profilovani algoritmu s nazvem \p name. */ 130 #define PR_START_PROFILE(name) \ 131 static int name##_id = PrProfiler::getAlgId(#name); \ 132 PrProfiler::startProfile(name##_id) 133 /** Urci zacatek profilovani (objektova verze). 134 Zacatek profilovani algoritmu s nazvem \p name patriciho objektu \p object. */ 135 #define PR_START_OBJ_PROFILE(name, object) \ 136 static int name##_id = PrProfiler::getAlgId(#name); \ 137 PrProfiler::startProfile(name##_id, object) 138 /** Urci konec profilovani. 139 Konec profilovani algoritmu s nazvem \p name. */ 140 #define PR_STOP_PROFILE(name) PrProfiler::stopProfile(name##_id) 141 /** Urci konec profilovani (objektova verze). 142 Konec profilovani algoritmu s nazvem \p name patriciho objektu \p object. */ 143 #define PR_STOP_OBJ_PROFILE(name, object) \ 144 PrProfiler::stopProfile(name##_id, object) 145 /** Inicializace profileru. 146 Incializace celeho profileru, je nutno zavolat pred jeho pouzitim, 147 nelepe na zacatku programu. */ 148 #define PR_INIT_PROFILER() PrProfiler::initProfiler() 149 /** Tisk vysledku profilovani. 150 Vytiskne vysledky profilovani na konec souboru \p filename ve formatu 151 definovanem v PrProfiler::printResults(). */ 152 #define PR_PRINT_RESULTS(filename) PrProfiler::printResults(filename) 153 148 154 #else 149 #define PR_START_PROFILE(name) 150 #define PR_START_OBJ_PROFILE(name, object) 151 #define PR_STOP_PROFILE(name) 152 #define PR_STOP_OBJ_PROFILE(name, object) 153 #define PR_INIT_PROFILER() 154 #define PR_PRINT_RESULTS(filename) 155 156 struct PrResult {}; 157 class PrProfiler {}; 158 159 #define PR_START_PROFILE(name) 160 #define PR_START_OBJ_PROFILE(name, object) 161 #define PR_STOP_PROFILE(name) 162 #define PR_STOP_OBJ_PROFILE(name, object) 163 #define PR_INIT_PROFILER() 164 #define PR_PRINT_RESULTS(filename) 165 155 166 #endif 156 167 -
SoTerrain/include/roam/SoSimpleROAMTerrain.h
r6 r8 46 46 47 47 // lokalni includy 48 #include <roam/SbROAMPrimitives.h> 48 49 #include <roam/SbROAMSplitQueue.h> 49 50 #include <roam/SbROAMMergeQueue.h> -
SoTerrain/makefile
r6 r8 4 4 5 5 # Promenne specificke pro projekt 6 TARGET = ./SoSimpleROAMTerrainTest 6 ROAM_TARGET = ./SoSimpleROAMTerrainTest 7 GEO_TARGET = ./SoSimpleGeoMipmapTerrainTest 8 TARGETS = $(GEO_TARGET) $(ROAM_TARGET) 7 9 8 10 INC = ./include/ … … 11 13 DOC = ./doc/html/ 12 14 13 APP = $(OBJ)SoSimpleROAMTerrainTest.o 14 TER = $(OBJ)SoSimpleROAMTerrain.o 15 SQE = $(OBJ)SbROAMSplitQueue.o 16 MQE = $(OBJ)SbROAMMergeQueue.o 17 PRI = $(OBJ)SbROAMPrimitives.o 15 ROAM_APP = $(OBJ)SoSimpleROAMTerrainTest.o 16 ROAM_TER = $(OBJ)SoSimpleROAMTerrain.o 17 ROAM_SQ = $(OBJ)SbROAMSplitQueue.o 18 ROAM_MQ = $(OBJ)SbROAMMergeQueue.o 19 ROAM_PR = $(OBJ)SbROAMPrimitives.o 20 GEO_APP = $(OBJ)SoSimpleGeoMipmapTerrainTest.o 21 GEO_TER = $(OBJ)SoSimpleGeoMipmapTerrain.o 22 GEO_PR = $(OBJ)SbGeoMipmapPrimitives.o 18 23 PRF = $(OBJ)PrProfiler.o 19 24 20 OBJS = $(APP) $(TER) $(SQE) $(MQE) $(PRI) 25 ROAM_OBJS = $(ROAM_APP) $(ROAM_TER) $(ROAM_SQ) $(ROAM_MQ) $(ROAM_PR) 26 GEO_OBJS = $(GEO_APP) $(GEO_TER) $(GEO_PR) 27 OBJS = $(ROAM_OBJS) $(GEO_OBJS) $(PRF) 21 28 22 29 CXXFLAGS = -ansi -I`soqt-config --cppflags` -I./include/ -Wall 23 30 LDFLAGS = `soqt-config --libs --ldflags` `simage-config --ldflags --libs` 24 31 32 .PHONY : doc clean geo_run roam_run 33 .DEFAULT : all 34 25 35 # Cile prekladu 26 $(TARGET): CXXFLAGS += -O327 $(TARGET): LDFLAGS += -O328 $(TARGET) : $(OBJS)36 all : CXXFLAGS += -O3 37 all : LDFLAGS += -O3 38 all : $(TARGETS) 29 39 @echo "Version for release build." 30 @$(LD) $^ $(LDFLAGS) -o $(TARGET)31 40 32 41 debug : CXXFLAGS += -DDEBUG -ggdb -g3 33 42 debug : LDFLAGS += -DDEBUG -ggdb -g3 34 debug : $( OBJS)43 debug : $(TARGETS) 35 44 @echo "Version for debugging build." 36 @$(LD) $^ $(LDFLAGS) -o $(TARGET)37 45 38 46 profile : CXXFLAGS += -DPROFILE -O3 -pg -g 39 47 profile : LDFLAGS += -DPROFILE -O3 -pg -g 40 profile : $(OBJS) $(PRF) 48 profile : GEO_OBJS += $(PRF) 49 profile : ROAM_OBJS += $(PRF) 50 profile : $(TARGETS) 41 51 @echo "Version for profiling build." 42 @$(LD) $^ $(LDFLAGS) -o $(TARGET)43 52 44 clean : OBJS += $(PRF)45 53 clean : 46 54 @echo "Removing compiled files..." 47 @rm -f $(TARGET )55 @rm -f $(TARGETS) 48 56 @rm -f $(OBJS) 49 57 @rm -f -r $(DOC) 50 58 51 doc : :59 doc : 52 60 echo "Generating documentation..." 53 61 @doxygen doxyfile 54 62 55 release : $(TARGET ) doc63 release : $(TARGETS) doc 56 64 @echo "Making release tarball..." 57 @tar -cjf SoTerrain.tar.bz2 makefile doxyfile README TODO doc images include \ 58 src scripts SoTerrain.kateproject 65 @tar -cjf SoTerrain.tar.bz2 makefile doxyfile README TODO doc/html include \ 66 src scripts SoTerrain.kateproject SoTerrain.vcproj SoTerrain.sln \ 67 images/heightmaps/ps_height_1k.png images/textures/ps_texture_1k.png 59 68 60 r un : $(TARGET)69 roam_run : $(ROAM_TARGET) 61 70 @echo "Running test application..." 62 $( TARGET) images/heightmaps/ps_height_1k.png images/textures/ps_texture_1k.png71 $(ROAM_TARGET) images/heightmaps/ps_height_1k.png images/textures/ps_texture_1k.png 63 72 64 # Cile objektu 65 $(APP) : ./src/SoSimpleROAMTerrainTest.cpp 66 @echo "Building test application object..." 73 geo_run : $(GEO_TARGET) 74 @echo "Running test application..." 75 $(GEO_TARGET) images/heightmaps/ps_height_1k.png images/textures/ps_texture_1k.png 76 77 # Cil pro profiler 78 $(PRF) : $(SRC)profiler/PrProfiler.cpp 79 @echo "Building profiler object..." 67 80 @$(CXX) -c -o $@ $(CXXFLAGS) $^ 68 81 69 $(TER) : $(SRC)roam/SoSimpleROAMTerrain.cpp 82 # Cile pro ROAM 83 $(ROAM_TARGET) : $(ROAM_OBJS) $(PRF) 84 @echo "Linking ROAM test application..." 85 @$(LD) $^ $(LDFLAGS) -o $(ROAM_TARGET) 86 87 $(ROAM_APP) : ./src/SoSimpleROAMTerrainTest.cpp 88 @echo "Building ROAM test application object..." 89 @$(CXX) -c -o $@ $(CXXFLAGS) $^ 90 91 $(ROAM_TER) : $(SRC)roam/SoSimpleROAMTerrain.cpp 70 92 @echo "Building ROAM terrain object..." 71 93 @$(CXX) -c -o $@ $(CXXFLAGS) $^ 72 94 73 $( SQE) : $(SRC)roam/SbROAMSplitQueue.cpp95 $(ROAM_SQ) : $(SRC)roam/SbROAMSplitQueue.cpp 74 96 @echo "Building ROAM split queue object..." 75 97 @$(CXX) -c -o $@ $(CXXFLAGS) $^ 76 98 77 $( MQE) : $(SRC)roam/SbROAMMergeQueue.cpp99 $(ROAM_MQ) : $(SRC)roam/SbROAMMergeQueue.cpp 78 100 @echo "Building ROAM merge queue object..." 79 101 @$(CXX) -c -o $@ $(CXXFLAGS) $^ 80 102 81 $( PRI) : $(SRC)roam/SbROAMPrimitives.cpp103 $(ROAM_PR) : $(SRC)roam/SbROAMPrimitives.cpp 82 104 @echo "Building ROAM primitive objects..." 83 105 @$(CXX) -c -o $@ $(CXXFLAGS) $^ 84 106 85 $(PRF) : $(SRC)profiler/PrProfiler.cpp 86 @echo "Building profiler object..." 107 # Cile pro Geo Mip-Mapping 108 $(GEO_TARGET) : $(GEO_OBJS) $(PRF) 109 @echo "Linking Geo Mip-Mapping test application..." 110 @$(LD) $^ $(LDFLAGS) -o $(GEO_TARGET) 111 112 $(GEO_APP) : ./src/SoSimpleGeoMipmapTerrainTest.cpp 113 @echo "Building Geo Mip-Mapping test Application object..." 87 114 @$(CXX) -c -o $@ $(CXXFLAGS) $^ 115 116 $(GEO_TER) : $(SRC)geomipmapping/SoSimpleGeoMipmapTerrain.cpp 117 @echo "Building Geo Mip-Mapping terrain object..." 118 @$(CXX) -c -o $@ $(CXXFLAGS) $^ 119 120 $(GEO_PR) : $(SRC)geomipmapping/SbGeoMipmapPrimitives.cpp 121 @echo "Building Geo Mip-Mapping primitive objects..." 122 @$(CXX) -c -o $@ $(CXXFLAGS) $^ -
SoTerrain/src/SoSimpleROAMTerrainTest.cpp
r6 r8 25 25 #include <Inventor/sensors/SoTimerSensor.h> 26 26 27 #include <iostream> 28 #include <cmath> 27 29 #include <simage.h> 28 #include <cmath>29 30 30 31 #include <roam/SoSimpleROAMTerrain.h> … … 271 272 } 272 273 273 void profilerCallback()274 {275 PR_PRINT_RESULTS("profile.txt");276 }277 278 274 int main(int argc, char * argv[]) 279 275 { … … 293 289 { 294 290 std::cout << "Chybne zadane parametry programu!" << std::endl; 295 std::cout << "Pouziti: roamvyskova_mapa textura" << std::endl;291 std::cout << "Pouziti: SoSimpleROAMTerrainTest vyskova_mapa textura" << std::endl; 296 292 exit(0); 297 293 } -
SoTerrain/src/geomipmapping/SoSimpleGeoMipmapTerrain.cpp
r6 r8 26 26 /////////////////////////////////////////////////////////////////////////////// 27 27 28 #include <geomipmapping/SoSimpleGeoMipmapTerrain.h> 29 30 /****************************************************************************** 31 * SoSimpleGeoMipmapTerrain 32 ******************************************************************************* 33 * public 34 ******************************************************************************/ 35 36 SO_NODE_SOURCE(SoSimpleGeoMipmapTerrain) 37 38 void SoSimpleGeoMipmapTerrain::initClass() 39 { 40 /* Inicializace tridy. */ 41 SO_NODE_INIT_CLASS(SoSimpleGeoMipmapTerrain, SoShape, "Shape"); 42 SO_ENABLE(SoGLRenderAction, SoCoordinateElement); 43 SO_ENABLE(SoGLRenderAction, SoTextureCoordinateElement); 44 SO_ENABLE(SoGLRenderAction, SoViewVolumeElement); 45 } 46 47 SoSimpleGeoMipmapTerrain::SoSimpleGeoMipmapTerrain() 48 { 49 /* Inicializace tridy. */ 50 SO_NODE_CONSTRUCTOR(SoSimpleGeoMipmapTerrain); 51 52 /* Inicializace poli */ 53 SO_NODE_ADD_FIELD(mapSize, (0)); 54 SO_NODE_ADD_FIELD(tileSize, (0)); 55 SO_NODE_ADD_FIELD(pixelError, (DEFAULT_PIXEL_ERROR)); 56 SO_NODE_ADD_FIELD(frustrumCulling, (true)); 57 SO_NODE_ADD_FIELD(freeze, (false)); 58 } 59 60 /****************************************************************************** 61 * protected 62 ******************************************************************************/ 63 64 void SoSimpleGeoMipmapTerrain::generatePrimitives(SoAction * action) 65 { 66 static bool first_run = true; 67 if (first_run) 68 { 69 first_run = false; 70 } 71 72 if (!freeze.getValue()) 73 { 74 75 } 76 77 /* Vykresleni trojuhelniku. */ 78 beginShape(action, TRIANGLES); 79 80 endShape(); 81 } 82 83 void SoSimpleGeoMipmapTerrain::computeBBox(SoAction * action, SbBox3f & box, 84 SbVec3f & center) 85 { 86 /* Vypocet ohranicujiciho kvadru a jeho stredu. */ 87 float size = mapSize.getValue() - 1.0f; // >-< 88 center.setValue(size / 2.0f, size / 2.0f, size / 20.0f); 89 box.setBounds(0.0f, 0.0f, 0.0f, size, size, size / 10.0f); 90 } 91 92 /****************************************************************************** 93 * private 94 ******************************************************************************/ 95 96 SoSimpleGeoMipmapTerrain::~SoSimpleGeoMipmapTerrain() 97 { 98 99 } 100 101 inline bool SoSimpleGeoMipmapTerrain::isInViewVolume(SbGeoMipmapTile * tile) 102 { 103 return false; 104 } 105 106 inline float SoSimpleGeoMipmapTerrain::computePriority(SbGeoMipmapTile * tile) 107 { 108 return 0.0f; 109 } -
SoTerrain/src/profiler/PrProfiler.cpp
r6 r8 27 27 28 28 #include <profiler/PrProfiler.h> 29 30 #ifdef PROFILE 29 31 30 32 /* Cas potrebny na zjisteni frekvence procesoru. */ … … 194 196 { 195 197 // neni-li alg_id registrovano vraceni prazdneho retezce 196 if ((alg_id < 0) && (alg_id >= alg_names.size()))198 if ((alg_id < 0) && (alg_id >= static_cast<int>(alg_names.size()))) 197 199 { 198 200 return ""; … … 214 216 const PrResult & PrProfiler::getResult(long index) 215 217 { 216 if (index >= result_buffer.size()) // je-li prekrocena velikost bufferu 218 // je-li prekrocena velikost bufferu 219 if (index >= static_cast<int>(result_buffer.size())) 217 220 { 218 221 return NULL_RESULT; // chybna hodnota … … 262 265 PrTimeStamp PrProfiler::ticks_per_usec = 1; 263 266 PrTimeStamp PrProfiler::start_time_stamp = 0; 267 268 #endif
