[2795] | 1 | #include "ResourceManager.h"
|
---|
[2755] | 2 | #include "Matrix4x4.h"
|
---|
| 3 | #include "Geometry.h"
|
---|
[2756] | 4 | #include "SceneEntity.h"
|
---|
[2755] | 5 | #include "Material.h"
|
---|
[2756] | 6 | #include "Texture.h"
|
---|
[2795] | 7 | #include "gzstream.h"
|
---|
[2823] | 8 | #include "Vector3.h"
|
---|
[2840] | 9 | #include "Transform3.h"
|
---|
[2842] | 10 | #include "Shape.h"
|
---|
[2844] | 11 | #include "LODInfo.h"
|
---|
[3034] | 12 | #include "RenderState.h"
|
---|
| 13 | #include "ShaderProgram.h"
|
---|
[3057] | 14 | #include "ShaderManager.h"
|
---|
[2747] | 15 |
|
---|
| 16 |
|
---|
[3021] | 17 | #ifdef _CRT_SET
|
---|
| 18 | #define _CRTDBG_MAP_ALLOC
|
---|
| 19 | #include <stdlib.h>
|
---|
| 20 | #include <crtdbg.h>
|
---|
| 21 |
|
---|
| 22 | // redefine new operator
|
---|
| 23 | #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
---|
| 24 | #define new DEBUG_NEW
|
---|
| 25 | #endif
|
---|
| 26 |
|
---|
| 27 |
|
---|
[2747] | 28 | using namespace std;
|
---|
| 29 |
|
---|
| 30 |
|
---|
[2776] | 31 | namespace CHCDemoEngine
|
---|
[2755] | 32 | {
|
---|
[2747] | 33 |
|
---|
[3038] | 34 |
|
---|
[3037] | 35 | // only instance of the resource manager
|
---|
| 36 | ResourceManager *ResourceManager::sResourceManager = NULL;
|
---|
[2755] | 37 |
|
---|
[3038] | 38 |
|
---|
| 39 | ResourceManager::ResourceManager()
|
---|
| 40 | {
|
---|
[3127] | 41 | mUseNormalMapping = false;
|
---|
[3226] | 42 | mUseSpecialColors = false;
|
---|
[3038] | 43 | }
|
---|
| 44 |
|
---|
| 45 |
|
---|
[2795] | 46 | ResourceManager::~ResourceManager()
|
---|
[2781] | 47 | {
|
---|
[2795] | 48 | // delete all resources.
|
---|
| 49 | CLEAR_CONTAINER(mSceneEntities);
|
---|
| 50 | CLEAR_CONTAINER(mGeometry);
|
---|
| 51 | CLEAR_CONTAINER(mMaterials);
|
---|
| 52 | CLEAR_CONTAINER(mTextures);
|
---|
| 53 | CLEAR_CONTAINER(mTrafos);
|
---|
[2842] | 54 | CLEAR_CONTAINER(mShapes);
|
---|
[2781] | 55 | }
|
---|
| 56 |
|
---|
[2795] | 57 |
|
---|
[3052] | 58 | void ResourceManager::DelSingleton()
|
---|
| 59 | {
|
---|
| 60 | DEL_PTR(sResourceManager);
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 |
|
---|
[2795] | 64 | SceneEntity *ResourceManager::LoadSceneEntity(igzstream &str)
|
---|
[2747] | 65 | {
|
---|
[2764] | 66 | bool hasTrafo;
|
---|
| 67 | str.read(reinterpret_cast<char *>(&hasTrafo), sizeof(bool));
|
---|
| 68 |
|
---|
[2823] | 69 | SceneEntity *sceneGeom;
|
---|
[2957] | 70 | Transform3 *trafo;
|
---|
[2823] | 71 |
|
---|
[2764] | 72 | if (!hasTrafo)
|
---|
[3128] | 73 | {
|
---|
| 74 | trafo = new Transform3(); // identity
|
---|
[2764] | 75 | }
|
---|
| 76 | else
|
---|
| 77 | {
|
---|
[2957] | 78 | Matrix4x4 m;
|
---|
| 79 | str.read(reinterpret_cast<char *>(m.x), sizeof(Matrix4x4));
|
---|
| 80 | trafo = new Transform3(m);
|
---|
[2764] | 81 | }
|
---|
| 82 |
|
---|
[2840] | 83 | mTrafos.push_back(trafo);
|
---|
[2844] | 84 |
|
---|
[2839] | 85 | sceneGeom = new SceneEntity(trafo);
|
---|
[2825] | 86 |
|
---|
[2852] | 87 |
|
---|
[2844] | 88 | ///////////////
|
---|
[3048] | 89 | //-- load LOD levels
|
---|
[2842] | 90 |
|
---|
[2853] | 91 | // note: lods must be ordered from smallest distance to largest
|
---|
[2844] | 92 | int numLODs;
|
---|
| 93 | str.read(reinterpret_cast<char *>(&numLODs), sizeof(int));
|
---|
[2842] | 94 |
|
---|
[2844] | 95 | for (int i = 0; i < numLODs; ++ i)
|
---|
| 96 | {
|
---|
[3048] | 97 | // the distance until the next LOD level is used
|
---|
[2853] | 98 | float dist;
|
---|
| 99 | str.read(reinterpret_cast<char *>(&dist), sizeof(float));
|
---|
[2844] | 100 |
|
---|
| 101 | int numShapes;
|
---|
| 102 | str.read(reinterpret_cast<char *>(&numShapes), sizeof(int));
|
---|
| 103 |
|
---|
[3070] | 104 | //LODLevel *lodLevel = new LODLevel(dist);
|
---|
| 105 | LODLevel lodLevel(dist);
|
---|
[2844] | 106 |
|
---|
| 107 | for (int j = 0; j < numShapes; ++ j)
|
---|
| 108 | {
|
---|
| 109 | int shapeId;
|
---|
| 110 | str.read(reinterpret_cast<char *>(&shapeId), sizeof(int));
|
---|
| 111 |
|
---|
| 112 | Geometry *geom = mGeometryTable[shapeId];
|
---|
| 113 | Material *mat = mMaterialTable[shapeId];
|
---|
| 114 | // create shape
|
---|
[3071] | 115 | Shape *shape = new Shape(geom, mat);
|
---|
[3236] | 116 |
|
---|
[2844] | 117 | mShapes.push_back(shape);
|
---|
| 118 |
|
---|
| 119 | sceneGeom->AddShape(shape);
|
---|
[3070] | 120 | lodLevel.AddShape(shape);
|
---|
[2844] | 121 | }
|
---|
| 122 |
|
---|
[3070] | 123 | //mLODs.push_back(lodLevel);
|
---|
[2844] | 124 | sceneGeom->AddLODLevel(lodLevel);
|
---|
| 125 | }
|
---|
| 126 |
|
---|
[3057] | 127 |
|
---|
[3113] | 128 | static ShaderProgram *sTreeAnimationProgram =
|
---|
| 129 | ShaderManager::GetSingleton()->GetShaderProgram("treeAnimation");
|
---|
| 130 | static ShaderProgram *sTreeAnimationProgramMrt =
|
---|
| 131 | ShaderManager::GetSingleton()->GetShaderProgram("treeAnimationMrt");
|
---|
| 132 |
|
---|
| 133 |
|
---|
[3041] | 134 | ///////////
|
---|
[3047] | 135 | //-- hack: add tree animation (should be done per material script!)
|
---|
[3041] | 136 |
|
---|
[3050] | 137 | if (numLODs > 1)
|
---|
[3041] | 138 | {
|
---|
[3047] | 139 | ShapeContainer::iterator sstart, send;
|
---|
| 140 |
|
---|
| 141 | // only use shader for the first two lod levels (the non-billboards)
|
---|
| 142 | for (int i = 0; i < min(numLODs, 2); ++ i)
|
---|
| 143 | //for (int i = 0; i < numLODs; ++ i)
|
---|
[3041] | 144 | {
|
---|
| 145 | sceneGeom->GetLODLevel(i, sstart, send);
|
---|
| 146 |
|
---|
| 147 | for (ShapeContainer::iterator it = sstart; it != send; ++ it)
|
---|
| 148 | {
|
---|
| 149 | Shape *shape = *it;
|
---|
[3045] | 150 |
|
---|
[3041] | 151 | Material *mat = shape->GetMaterial();
|
---|
| 152 |
|
---|
[3045] | 153 | // add the vertex animation program
|
---|
[3050] | 154 | for (int i = 0; i < 3; ++ i)
|
---|
[3045] | 155 | {
|
---|
| 156 | Technique *tech = mat->GetTechnique(i);
|
---|
[3041] | 157 |
|
---|
[3045] | 158 | GPUProgramParameters *vtxParams = tech->GetVertexProgramParameters();
|
---|
[3041] | 159 |
|
---|
[3046] | 160 | if (i == 0)
|
---|
| 161 | {
|
---|
| 162 | tech->SetVertexProgram(sTreeAnimationProgram);
|
---|
| 163 | vtxParams->SetLightDirParam(5);
|
---|
| 164 | }
|
---|
| 165 | else
|
---|
| 166 | {
|
---|
| 167 | tech->SetVertexProgram(sTreeAnimationProgramMrt);
|
---|
[3115] | 168 | vtxParams->SetOldTimerParam(5);
|
---|
[3046] | 169 | }
|
---|
| 170 |
|
---|
| 171 | /// use a timer to simulate the moving of the tree in the wind
|
---|
[3045] | 172 | vtxParams->SetTimerParam(0);
|
---|
[3113] | 173 |
|
---|
[3045] | 174 | // wind direction
|
---|
| 175 | static Vector3 windDir = Normalize(Vector3(0.8f, 0.2f, 0.0f));
|
---|
| 176 | vtxParams->SetValue3f(1, windDir.x, windDir.y, windDir.z);
|
---|
| 177 | // amplitude
|
---|
| 178 | vtxParams->SetValue1f(2, 0.3f);
|
---|
| 179 |
|
---|
| 180 | AxisAlignedBox3 box = sceneGeom->GetBoundingBox();
|
---|
| 181 | vtxParams->SetValue2f(3, box.Min().z, box.Max().z);
|
---|
| 182 | // frequency
|
---|
| 183 | vtxParams->SetValue1f(4, 0.1f);
|
---|
| 184 | }
|
---|
[3041] | 185 | }
|
---|
| 186 | }
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[2755] | 189 | return sceneGeom;
|
---|
[2747] | 190 | }
|
---|
| 191 |
|
---|
| 192 |
|
---|
[3237] | 193 | int ResourceManager::LoadTextures(igzstream &str)
|
---|
[2757] | 194 | {
|
---|
| 195 | int numTextures;
|
---|
| 196 | str.read(reinterpret_cast<char *>(&numTextures), sizeof(int));
|
---|
[2961] | 197 |
|
---|
[2757] | 198 | for (int i = 0; i < numTextures; ++ i)
|
---|
| 199 | {
|
---|
[2961] | 200 | // load texture name
|
---|
[2757] | 201 | int texnameSize;
|
---|
| 202 | str.read(reinterpret_cast<char *>(&texnameSize), sizeof(int));
|
---|
| 203 |
|
---|
| 204 | char *texname = new char[texnameSize];
|
---|
| 205 | str.read(texname, sizeof(char) * texnameSize);
|
---|
| 206 |
|
---|
[2784] | 207 | Texture *tex = new Texture(model_path + texname);
|
---|
[2757] | 208 |
|
---|
[2846] | 209 | int boundS, boundT;
|
---|
| 210 |
|
---|
| 211 | str.read(reinterpret_cast<char *>(&boundS), sizeof(int));
|
---|
| 212 | str.read(reinterpret_cast<char *>(&boundT), sizeof(int));
|
---|
| 213 |
|
---|
| 214 | tex->SetBoundaryModeS(boundS);
|
---|
| 215 | tex->SetBoundaryModeT(boundT);
|
---|
| 216 |
|
---|
| 217 | tex->Create();
|
---|
| 218 |
|
---|
[2764] | 219 | mTextureTable[i] = tex;
|
---|
[2795] | 220 | mTextures.push_back(tex);
|
---|
[3021] | 221 |
|
---|
| 222 | delete [] texname;
|
---|
[2757] | 223 | }
|
---|
[2764] | 224 |
|
---|
[3237] | 225 | return numTextures;
|
---|
[2757] | 226 | }
|
---|
| 227 |
|
---|
[3237] | 228 | // todo: split up geometry and materials!!
|
---|
| 229 | int ResourceManager::LoadShapes(igzstream &str)
|
---|
[2764] | 230 | {
|
---|
| 231 | int numShapes;
|
---|
| 232 | str.read(reinterpret_cast<char *>(&numShapes), sizeof(int));
|
---|
| 233 |
|
---|
| 234 | for (int i = 0; i < numShapes; ++ i)
|
---|
| 235 | {
|
---|
| 236 | Geometry *geom = LoadGeometry(str);
|
---|
| 237 | Material *mat = LoadMaterial(str);
|
---|
| 238 |
|
---|
| 239 | mGeometryTable[i] = geom;
|
---|
[2842] | 240 | mMaterialTable[i] = mat;
|
---|
[2795] | 241 |
|
---|
| 242 | mGeometry.push_back(geom);
|
---|
| 243 | mMaterials.push_back(mat);
|
---|
[2764] | 244 | }
|
---|
| 245 |
|
---|
[3237] | 246 | return numShapes;
|
---|
[2764] | 247 | }
|
---|
| 248 |
|
---|
| 249 |
|
---|
[2795] | 250 | Material *ResourceManager::LoadMaterial(igzstream &str)
|
---|
[2747] | 251 | {
|
---|
[2756] | 252 | // default material
|
---|
[2755] | 253 | Material *mat = new Material();
|
---|
[2756] | 254 |
|
---|
[3042] | 255 | // set default fragment + vertex programs
|
---|
| 256 | Technique *tech = mat->GetDefaultTechnique();
|
---|
| 257 |
|
---|
[2747] | 258 | // texture
|
---|
[2757] | 259 | int texId;
|
---|
| 260 | str.read(reinterpret_cast<char *>(&texId), sizeof(int));
|
---|
[2747] | 261 |
|
---|
[2982] | 262 | if (texId >= 0)
|
---|
[3042] | 263 | tech->SetTexture(mTextureTable[texId]);
|
---|
[2764] | 264 |
|
---|
[3042] | 265 | str.read(reinterpret_cast<char *>(&tech->mAlphaTestEnabled), sizeof(bool));
|
---|
| 266 | str.read(reinterpret_cast<char *>(&tech->mCullFaceEnabled), sizeof(bool));
|
---|
[2844] | 267 |
|
---|
[3034] | 268 | // gl material
|
---|
| 269 | bool hasGlMaterial;
|
---|
| 270 | str.read(reinterpret_cast<char *>(&hasGlMaterial), sizeof(bool));
|
---|
[3042] | 271 |
|
---|
[3034] | 272 | if (hasGlMaterial)
|
---|
[2747] | 273 | {
|
---|
[2769] | 274 | // only write rgb part of the material
|
---|
[3042] | 275 | str.read(reinterpret_cast<char *>(&tech->mAmbientColor), sizeof(Vector3));
|
---|
| 276 | str.read(reinterpret_cast<char *>(&tech->mDiffuseColor), sizeof(Vector3));
|
---|
| 277 | str.read(reinterpret_cast<char *>(&tech->mEmmisiveColor), sizeof(Vector3));
|
---|
| 278 | str.read(reinterpret_cast<char *>(&tech->mSpecularColor), sizeof(Vector3));
|
---|
[2747] | 279 | }
|
---|
| 280 |
|
---|
[3226] | 281 | if (mUseSpecialColors)
|
---|
| 282 | {
|
---|
| 283 | tech->mAmbientColor.r = tech->mAmbientColor.g = tech->mAmbientColor.b = 0.2f;
|
---|
| 284 | tech->mDiffuseColor.r = 0.7f; tech->mDiffuseColor.g = 0.5f; tech->mDiffuseColor.b = 0.2f;
|
---|
| 285 | }
|
---|
[3045] | 286 |
|
---|
[3226] | 287 |
|
---|
[3045] | 288 | ///////////////
|
---|
| 289 | //-- add technique for deferred shading
|
---|
| 290 |
|
---|
[3057] | 291 | static ShaderProgram *sDefaultFragmentProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("defaultFragmentMrt");
|
---|
| 292 | static ShaderProgram *sDefaultFragmentTexProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("defaultFragmentTexMrt");
|
---|
| 293 | static ShaderProgram *sDefaultVertexProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("defaultVertexMrt");
|
---|
| 294 |
|
---|
[3144] | 295 | static ShaderProgram *sNormalMappingVertexProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("normalMappingVertexMrt");
|
---|
| 296 | static ShaderProgram *sNormalMappingFragmentProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("normalMappingFragmentMrt");
|
---|
[3127] | 297 |
|
---|
[3128] | 298 |
|
---|
[3045] | 299 | Technique *deferred = new Technique(*tech);
|
---|
| 300 |
|
---|
[3145] | 301 | if (mUseNormalMapping)
|
---|
| 302 | {
|
---|
[3146] | 303 | deferred->SetFragmentProgram(sNormalMappingFragmentProgramMrt);
|
---|
[3145] | 304 | deferred->SetVertexProgram(sNormalMappingVertexProgramMrt);
|
---|
| 305 | }
|
---|
[3034] | 306 | else
|
---|
[3145] | 307 | {
|
---|
| 308 | if (deferred->GetTexture())
|
---|
| 309 | deferred->SetFragmentProgram(sDefaultFragmentTexProgramMrt);
|
---|
| 310 | else
|
---|
| 311 | deferred->SetFragmentProgram(sDefaultFragmentProgramMrt);
|
---|
[3034] | 312 |
|
---|
[3145] | 313 | deferred->SetVertexProgram(sDefaultVertexProgramMrt);
|
---|
| 314 | }
|
---|
| 315 |
|
---|
[3126] | 316 | deferred->GetFragmentProgramParameters()->SetViewMatrixParam(0);
|
---|
[3145] | 317 |
|
---|
[3114] | 318 | deferred->GetVertexProgramParameters()->SetModelMatrixParam(1);
|
---|
| 319 | deferred->GetVertexProgramParameters()->SetOldModelMatrixParam(2);
|
---|
[3113] | 320 |
|
---|
[3050] | 321 | mat->AddTechnique(deferred);
|
---|
[3041] | 322 |
|
---|
[3048] | 323 |
|
---|
| 324 | ///////////
|
---|
| 325 | //-- add depth pass
|
---|
| 326 |
|
---|
| 327 | Technique *depthPass = new Technique(*tech);
|
---|
[3114] | 328 |
|
---|
[3048] | 329 | depthPass->SetColorWriteEnabled(false);
|
---|
| 330 | depthPass->SetLightingEnabled(false);
|
---|
| 331 | mat->AddTechnique(depthPass);
|
---|
[3045] | 332 |
|
---|
[2755] | 333 | return mat;
|
---|
[2747] | 334 | }
|
---|
| 335 |
|
---|
| 336 |
|
---|
[2795] | 337 | Geometry *ResourceManager::LoadGeometry(igzstream &str)
|
---|
[2747] | 338 | {
|
---|
[2756] | 339 | Vector3 *vertices;
|
---|
| 340 | Vector3 *normals;
|
---|
[2980] | 341 | Texcoord2 *texcoords;
|
---|
[2747] | 342 |
|
---|
| 343 |
|
---|
[2756] | 344 | //////////////
|
---|
| 345 | //-- read in vertices
|
---|
[2747] | 346 |
|
---|
[2756] | 347 | int vertexCount;
|
---|
| 348 | str.read(reinterpret_cast<char *>(&vertexCount), sizeof(int));
|
---|
[2747] | 349 |
|
---|
| 350 | // end of file reached
|
---|
[2961] | 351 | if (str.eof()) return NULL;
|
---|
[2747] | 352 |
|
---|
[2756] | 353 | vertices = new Vector3[vertexCount];
|
---|
| 354 | str.read(reinterpret_cast<char *>(vertices), sizeof(Vector3) * vertexCount);
|
---|
[2747] | 355 |
|
---|
[2756] | 356 | normals = new Vector3[vertexCount];
|
---|
| 357 | str.read(reinterpret_cast<char *>(normals), sizeof(Vector3) * vertexCount);
|
---|
[2747] | 358 |
|
---|
[3127] | 359 | Vector3 *tangents;
|
---|
| 360 |
|
---|
| 361 | if (mUseNormalMapping)
|
---|
| 362 | {
|
---|
| 363 | tangents = new Vector3[vertexCount];
|
---|
| 364 | str.read(reinterpret_cast<char *>(tangents), sizeof(Vector3) * vertexCount);
|
---|
| 365 | }
|
---|
| 366 | else
|
---|
| 367 | {
|
---|
| 368 | tangents = NULL;
|
---|
| 369 | }
|
---|
| 370 |
|
---|
[2756] | 371 | int texCoordCount;
|
---|
| 372 | str.read(reinterpret_cast<char *>(&texCoordCount), sizeof(int));
|
---|
[2747] | 373 |
|
---|
[3153] | 374 |
|
---|
[2756] | 375 | if (texCoordCount)
|
---|
[2747] | 376 | {
|
---|
[2980] | 377 | texcoords = new Texcoord2[texCoordCount];
|
---|
| 378 | str.read(reinterpret_cast<char *>(texcoords), sizeof(Texcoord2) * texCoordCount);
|
---|
[2747] | 379 | }
|
---|
[2756] | 380 | else
|
---|
[2811] | 381 | {
|
---|
[2756] | 382 | texcoords = NULL;
|
---|
[2811] | 383 | }
|
---|
[2747] | 384 |
|
---|
[3127] | 385 | const bool delGeometry = false;
|
---|
[3154] | 386 | return new Geometry(vertices, normals, texcoords, vertexCount, delGeometry, NULL);//tangents);
|
---|
[2747] | 387 | }
|
---|
| 388 |
|
---|
| 389 |
|
---|
[3237] | 390 | int ResourceManager::LoadSceneEntities(igzstream &str,
|
---|
| 391 | SceneEntityContainer &entities)
|
---|
[2747] | 392 | {
|
---|
[2764] | 393 | int entityCount;
|
---|
| 394 | str.read(reinterpret_cast<char *>(&entityCount), sizeof(int));
|
---|
| 395 |
|
---|
[2963] | 396 | entities.reserve(entityCount);
|
---|
[2764] | 397 |
|
---|
| 398 | for (int i = 0; i < entityCount; ++ i)
|
---|
| 399 | {
|
---|
| 400 | SceneEntity *ent = LoadSceneEntity(str);
|
---|
[2842] | 401 |
|
---|
[2963] | 402 | // return loaded entities
|
---|
| 403 | entities.push_back(ent);
|
---|
| 404 | // also store internally
|
---|
[2795] | 405 | mSceneEntities.push_back(ent);
|
---|
[2764] | 406 | }
|
---|
| 407 |
|
---|
[3237] | 408 | return entityCount;
|
---|
[2764] | 409 | }
|
---|
| 410 |
|
---|
| 411 |
|
---|
[3237] | 412 | int ResourceManager::Load(const std::string &filename,
|
---|
| 413 | SceneEntityContainer &entities)
|
---|
[2764] | 414 | {
|
---|
[2795] | 415 | igzstream istr(filename.c_str());
|
---|
[2747] | 416 |
|
---|
[2756] | 417 | if (!istr.is_open())
|
---|
[3237] | 418 | return 0;
|
---|
[2747] | 419 |
|
---|
[2764] | 420 | cout << "loading textures" << endl;
|
---|
| 421 |
|
---|
[2757] | 422 | // load the texture table
|
---|
[3237] | 423 | int numTextures = LoadTextures(istr);
|
---|
[2757] | 424 |
|
---|
[3237] | 425 | cout << "loaded " << numTextures << " textures" << endl;
|
---|
| 426 |
|
---|
[2764] | 427 | cout << "loading shapes (geometry + materials)" << endl;
|
---|
[2747] | 428 |
|
---|
[2764] | 429 | // load the shapees
|
---|
[3237] | 430 | int numShapes = LoadShapes(istr);
|
---|
[2762] | 431 |
|
---|
[3237] | 432 | cout << "loaded " << (int)mGeometryTable.size() << " shapes" << endl;
|
---|
| 433 |
|
---|
[2764] | 434 | cout << "loading scene entites" << endl;
|
---|
[2763] | 435 |
|
---|
[3237] | 436 | int numEntities = LoadSceneEntities(istr, entities);
|
---|
| 437 |
|
---|
| 438 | cout << "loaded " << numEntities << " scene entities" << endl;
|
---|
| 439 |
|
---|
[2756] | 440 | cout << "bin loading finished" << endl;
|
---|
[2747] | 441 |
|
---|
[3237] | 442 | // clean up temporary tables
|
---|
[2795] | 443 | mTextureTable.clear();
|
---|
| 444 | mGeometryTable.clear();
|
---|
| 445 | mMaterialTable.clear();
|
---|
| 446 |
|
---|
[3237] | 447 | return numEntities;
|
---|
[2747] | 448 | }
|
---|
| 449 |
|
---|
[3070] | 450 |
|
---|
| 451 | void ResourceManager::AddSceneEntity(SceneEntity *ent)
|
---|
| 452 | {
|
---|
| 453 | mSceneEntities.push_back(ent);
|
---|
[3036] | 454 | }
|
---|
| 455 |
|
---|
[3070] | 456 |
|
---|
| 457 | Transform3 *ResourceManager::CreateTransform(const Matrix4x4 &m)
|
---|
| 458 | {
|
---|
| 459 | Transform3 *t = new Transform3(m);
|
---|
| 460 |
|
---|
| 461 | mTrafos.push_back(t);
|
---|
| 462 | return t;
|
---|
| 463 | }
|
---|
| 464 |
|
---|
[3215] | 465 |
|
---|
| 466 |
|
---|
| 467 | Material *ResourceManager::CreateMaterial()
|
---|
| 468 | {
|
---|
| 469 | Material *mat = new Material();
|
---|
| 470 | mMaterials.push_back(mat);
|
---|
| 471 |
|
---|
| 472 | return mat;
|
---|
| 473 | }
|
---|
| 474 |
|
---|
[3070] | 475 | } |
---|