mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 14:21:10 +02:00
Take 0
This commit is contained in:
parent
799a3cae55
commit
d9e326258f
1 changed files with 64 additions and 2 deletions
|
@ -11,14 +11,76 @@
|
||||||
#ifndef hifi_model_Asset_h
|
#ifndef hifi_model_Asset_h
|
||||||
#define hifi_model_Asset_h
|
#define hifi_model_Asset_h
|
||||||
|
|
||||||
#include <bitset>
|
#include <memory>
|
||||||
#include <map>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Material.h"
|
||||||
|
#include "Geometry.h"
|
||||||
|
|
||||||
namespace model {
|
namespace model {
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class Table {
|
||||||
|
public:
|
||||||
|
typedef std::vector< T > Vector;
|
||||||
|
typedef int ID;
|
||||||
|
|
||||||
|
const ID INVALID_ID = 0;
|
||||||
|
|
||||||
|
enum Version {
|
||||||
|
DRAFT = 0,
|
||||||
|
FINAL,
|
||||||
|
NUM_VERSIONS,
|
||||||
|
};
|
||||||
|
|
||||||
|
Table() {
|
||||||
|
for (auto e : _elements) {
|
||||||
|
e.resize(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~Table() {}
|
||||||
|
|
||||||
|
ID add(Version v, const T& element) {
|
||||||
|
switch (v) {
|
||||||
|
case DRAFT: {
|
||||||
|
_elements[DRAFT].push_back(element);
|
||||||
|
return ID(-(_elements[DRAFT].size() - 1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FINAL: {
|
||||||
|
_elements[FINAL].push_back(element);
|
||||||
|
return ID(_elements[FINAL].size() - 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return INVALID_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Vector _elements[NUM_VERSIONS];
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef Table< MaterialPointer > MaterialTable;
|
||||||
|
typedef Table< MeshPointer > MeshTable;
|
||||||
|
|
||||||
class Asset {
|
class Asset {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
Asset();
|
||||||
|
~Asset();
|
||||||
|
|
||||||
|
MeshTable& editMeshes() { return _meshes; }
|
||||||
|
const MeshTable& getMeshes() const { return _meshes; }
|
||||||
|
|
||||||
|
MaterialTable& editMaterials() { return _materials; }
|
||||||
|
const MaterialTable& getMaterials() const { return _materials; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
MeshTable _meshes;
|
||||||
|
MaterialTable _materials;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr< Asset > AssetPointer;
|
typedef std::shared_ptr< Asset > AssetPointer;
|
||||||
|
|
Loading…
Reference in a new issue