- Timestamp:
- 06/14/08 01:11:58 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/CHC_revisited
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.cpp
r2756 r2757 81 81 82 82 83 void BinaryLoader::LoadTextures(ifstream &str) 84 { 85 int numTextures; 86 str.read(reinterpret_cast<char *>(&numTextures), sizeof(int)); 87 88 for (int i = 0; i < numTextures; ++ i) 89 { 90 // texture 91 int texnameSize; 92 int id; 93 94 str.read(reinterpret_cast<char *>(&id), sizeof(int)); 95 str.read(reinterpret_cast<char *>(&texnameSize), sizeof(int)); 96 97 char *texname = new char[texnameSize]; 98 str.read(texname, sizeof(char) * texnameSize); 99 100 cout << "loading texture " << texname << " with len " << texnameSize << " id: " << id << endl; 101 102 Texture *tex = new Texture(texname); 103 104 mTextureTable[id] = tex; 105 } 106 } 107 108 83 109 //Appearance *BinaryLoader::LoadMaterial(igzstream &str) 84 110 Material *BinaryLoader::LoadMaterial(ifstream &str) … … 88 114 89 115 // texture 90 int texnameSize; 91 92 str.read(reinterpret_cast<char *>(&texnameSize), sizeof(int)); 93 94 if (texnameSize) 95 { 96 char *texname = new char[texnameSize]; 97 str.read(texname, sizeof(char) *texnameSize); 98 99 100 cout << "loading texture " << texname << " with len " << texnameSize << endl; 101 Texture *tex = new Texture(texname); 102 103 mat->SetTexture(tex); 104 } 105 else 106 cout << "no texture " << texnameSize << endl; 116 int texId; 117 118 str.read(reinterpret_cast<char *>(&texId), sizeof(int)); 119 //cout << "texid: " << texId << endl; 120 121 if (texId >= 0) 122 { 123 mat->SetTexture(mTextureTable[texId]); 124 } 107 125 108 126 // material … … 158 176 return NULL; 159 177 160 cout << "vertexcount: " << vertexCount << endl;178 //cout << "vertexcount: " << vertexCount << endl; 161 179 162 180 vertices = new Vector3[vertexCount]; … … 171 189 if (texCoordCount) 172 190 { 173 cout << "loading texcoords of size " << texCoordCount << endl;191 //cout << "loading texcoords of size " << texCoordCount << endl; 174 192 texcoords = new float[texCoordCount * 2]; 175 193 str.read(reinterpret_cast<char *>(texcoords), sizeof(float) * vertexCount * 2); … … 201 219 if (!istr.is_open()) 202 220 return false; 221 222 // load the texture table 223 LoadTextures(istr); 203 224 204 225 // #shapes -
GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.h
r2756 r2757 1 #ifndef _ BinaryLoader_H__2 #define _ BinaryLoader_H__1 #ifndef __BinaryLoader_H__ 2 #define __BinaryLoader_H__ 3 3 4 4 // note use forward declaration instead … … 6 6 #include <iostream> 7 7 #include <fstream> 8 #include <map> 9 8 10 #include "common.h" 9 11 … … 16 18 class Material; 17 19 class Geometry; 20 class Texture; 18 21 19 22 … … 26 29 protected: 27 30 31 void LoadTextures(std::ifstream &str); 32 28 33 SceneEntity *LoadSceneEntity(std::ifstream &str); 29 34 Material *LoadMaterial(std::ifstream &str); … … 34 39 Geometry *LoadGeometry(igzstream &str); 35 40 */ 41 42 std::map<int, Texture *> mTextureTable; 36 43 }; 37 44 -
GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp
r2756 r2757 146 146 BinaryLoader loader; 147 147 148 const string filename("house_test.dem");149 //const string filename("city.dem");148 //const string filename("house_test.dem"); 149 const string filename("city.dem"); 150 150 151 151 camera = new Camera(800, 600); … … 166 166 167 167 SetupProjection(800, 600, 60, sceneBox); 168 camera->LookAtBox(sceneBox);169 //camera->LookInBox(sceneBox);168 //camera->LookAtBox(sceneBox); 169 camera->LookInBox(sceneBox); 170 170 //camera->SetPosition(Vector3(0, 0, -3)); 171 171 //camera->SetDirection(Vector3(0, 0, 1));
Note: See TracChangeset
for help on using the changeset viewer.