Get Mesh component starts to workgit add .!
This commit is contained in:
parent
8529fb1a66
commit
5581dfa8ad
@ -31,6 +31,14 @@ namespace Deer {
|
|||||||
return MeshManager::getModel(meshId);
|
return MeshManager::getModel(meshId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline Path& getMeshName() {
|
||||||
|
return MeshManager::getModelName(meshId);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool hasMesh() {
|
||||||
|
return meshId != 0;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool isActive() {
|
inline bool isActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,10 @@ namespace Deer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace MeshManager {
|
namespace MeshManager {
|
||||||
uint16_t loadModel(const MeshData&);
|
uint16_t loadModel(const Path&);
|
||||||
|
uint16_t loadModel(const MeshData&, const Path&);
|
||||||
VertexArray& getModel(uint16_t model_id);
|
VertexArray& getModel(uint16_t model_id);
|
||||||
|
Path& getModelName(uint16_t model_id);
|
||||||
|
|
||||||
void unloadAllModels();
|
void unloadAllModels();
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
namespace Deer {
|
namespace Deer {
|
||||||
void DataStore::loadModel(MeshData& meshData, const Path& name) {
|
void DataStore::loadModel(MeshData& meshData, const Path& name) {
|
||||||
Path realName;
|
Path realName;
|
||||||
realName = Path(DEER_MESH_PATH) / (name.string() + ".dmesh");
|
realName = Path(DEER_MESH_PATH) / (name.string() + DEER_MESH_EXTENSION);
|
||||||
|
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint8_t* data = DataStore::readFile(realName, &size);
|
uint8_t* data = DataStore::readFile(realName, &size);
|
||||||
@ -28,7 +28,7 @@ namespace Deer {
|
|||||||
|
|
||||||
void DataStore::saveModel(const MeshData& meshData, const Path& name) {
|
void DataStore::saveModel(const MeshData& meshData, const Path& name) {
|
||||||
Path realName;
|
Path realName;
|
||||||
realName = Path(DEER_MESH_PATH) / (name.string() + ".dmesh");
|
realName = Path(DEER_MESH_PATH) / (name.string() + DEER_MESH_EXTENSION);
|
||||||
|
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
{
|
{
|
||||||
|
@ -3,30 +3,57 @@
|
|||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace MeshManager {
|
namespace MeshManager {
|
||||||
|
struct MeshManagerContainer {
|
||||||
|
Path mesh_name;
|
||||||
|
VertexArray* mesh_data = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
size_t minModelId = 0;
|
size_t minModelId = 0;
|
||||||
VertexArray* meshes[SCENE_MAX_MESH_COUNT]{};
|
MeshManagerContainer meshes[SCENE_MAX_MESH_COUNT]{};
|
||||||
|
std::unordered_map<Path, size_t> mesh_name_id;
|
||||||
|
|
||||||
VertexArray* loadModelToGPU(const MeshData& data);
|
VertexArray* loadModelToGPU(const MeshData& data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshManager::unloadAllModels() {
|
void MeshManager::unloadAllModels() {
|
||||||
for (uint16_t i = 0; i < minModelId; i++) {
|
for (uint16_t i = 1; i < minModelId; i++) {
|
||||||
delete meshes[i];
|
delete meshes[i].mesh_data;
|
||||||
meshes[i] = nullptr;
|
meshes[i].mesh_data = nullptr;
|
||||||
|
}
|
||||||
|
mesh_name_id.clear();
|
||||||
|
|
||||||
|
mesh_name_id["NULL"] = 0;
|
||||||
|
meshes[0].mesh_data = nullptr;
|
||||||
|
meshes[0].mesh_name = "NULL";
|
||||||
|
minModelId = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
minModelId = 0;
|
uint16_t MeshManager::loadModel(const Path& name) {
|
||||||
|
if (mesh_name_id.contains(name))
|
||||||
|
return mesh_name_id[name];
|
||||||
|
|
||||||
|
MeshData meshData;
|
||||||
|
DataStore::loadModel(meshData, name);
|
||||||
|
|
||||||
|
return loadModel(meshData, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t MeshManager::loadModel(const MeshData& meshData) {
|
uint16_t MeshManager::loadModel(const MeshData& meshData, const Path& name) {
|
||||||
if (minModelId >= SCENE_MAX_MESH_COUNT) {
|
if (minModelId >= SCENE_MAX_MESH_COUNT) {
|
||||||
DEER_CORE_ERROR("Max model loaded into a scene");
|
DEER_CORE_ERROR("Max model loaded into a scene");
|
||||||
return -1;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh_name_id.contains(name)) {
|
||||||
|
DEER_CORE_ERROR("Mesh with name {0} already exists", name.string().c_str());
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t modelId = minModelId;
|
uint16_t modelId = minModelId;
|
||||||
minModelId++;
|
minModelId++;
|
||||||
|
|
||||||
meshes[modelId] = loadModelToGPU(meshData);
|
meshes[modelId].mesh_data = loadModelToGPU(meshData);
|
||||||
|
meshes[modelId].mesh_name = name;
|
||||||
|
|
||||||
return modelId;
|
return modelId;
|
||||||
}
|
}
|
||||||
@ -34,7 +61,13 @@ namespace Deer {
|
|||||||
VertexArray& MeshManager::getModel(uint16_t model_id) {
|
VertexArray& MeshManager::getModel(uint16_t model_id) {
|
||||||
DEER_CORE_ASSERT(model_id >= 0 && model_id < minModelId, "Invalid model id, id is not loaded");
|
DEER_CORE_ASSERT(model_id >= 0 && model_id < minModelId, "Invalid model id, id is not loaded");
|
||||||
|
|
||||||
return *meshes[model_id];
|
return *meshes[model_id].mesh_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Path& MeshManager::getModelName(uint16_t model_id) {
|
||||||
|
DEER_CORE_ASSERT(model_id >= 0 && model_id < minModelId, "Invalid model id, id is not loaded");
|
||||||
|
|
||||||
|
return meshes[model_id].mesh_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexArray* MeshManager::loadModelToGPU(const MeshData& data) {
|
VertexArray* MeshManager::loadModelToGPU(const MeshData& data) {
|
||||||
|
@ -66,7 +66,7 @@ namespace Deer {
|
|||||||
ShaderData shaderData;
|
ShaderData shaderData;
|
||||||
DataStore::loadShader(shaderData, "shader");
|
DataStore::loadShader(shaderData, "shader");
|
||||||
|
|
||||||
renderComponent.setMesh(MeshManager::loadModel(meshData));
|
renderComponent.setMesh(MeshManager::loadModel(meshData, "SIMPLE MESH"));
|
||||||
shaderComponent.setShader(ShaderManager::loadShader(shaderData));
|
shaderComponent.setShader(ShaderManager::loadShader(shaderData));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -46,6 +46,11 @@ namespace Deer {
|
|||||||
bool isDescendantOf(EntityStruct parent);
|
bool isDescendantOf(EntityStruct parent);
|
||||||
bool opEquals(const EntityStruct& other);
|
bool opEquals(const EntityStruct& other);
|
||||||
|
|
||||||
|
//COMPONENTS
|
||||||
|
EntityStruct getMeshComponent();
|
||||||
|
bool hasMeshComponent();
|
||||||
|
void removeMeshComponent();
|
||||||
|
|
||||||
// This function can be adapted to get a specific transform since the data is the same
|
// This function can be adapted to get a specific transform since the data is the same
|
||||||
EntityStruct getSelf();
|
EntityStruct getSelf();
|
||||||
};
|
};
|
||||||
@ -65,6 +70,17 @@ namespace Deer {
|
|||||||
void setRotation(glm::vec3);
|
void setRotation(glm::vec3);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MeshComponentStruct : EntityStruct {
|
||||||
|
bool check_self();
|
||||||
|
|
||||||
|
bool isActive();
|
||||||
|
bool hasMesh();
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
std::string getMesh();
|
||||||
|
void setMesh(std::string&);
|
||||||
|
};
|
||||||
|
|
||||||
EntityStruct getRoot();
|
EntityStruct getRoot();
|
||||||
void constructEntityStruct(int id, void* memory);
|
void constructEntityStruct(int id, void* memory);
|
||||||
void copyEntityStruct(int id, void* memory);
|
void copyEntityStruct(int id, void* memory);
|
||||||
|
@ -6,7 +6,8 @@ namespace Deer {
|
|||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
enum ResourceType : uint32_t {
|
enum ResourceType : uint32_t {
|
||||||
NOTHING = 0,
|
NOTHING = 0,
|
||||||
MESH = 1
|
MESH = 1,
|
||||||
|
SHADER = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns the count of meshes in the dir relative to the mesh root dir
|
// Returns the count of meshes in the dir relative to the mesh root dir
|
||||||
@ -23,6 +24,7 @@ namespace Deer {
|
|||||||
// Returns the name of the subDir in the dir relative to the mesh root dir
|
// Returns the name of the subDir in the dir relative to the mesh root dir
|
||||||
std::string getDirNameById(ResourceType, std::string& dir, int i);
|
std::string getDirNameById(ResourceType, std::string& dir, int i);
|
||||||
|
|
||||||
|
// INTERNAL
|
||||||
const char* getResourcePath(ResourceType);
|
const char* getResourcePath(ResourceType);
|
||||||
const char* getResourceExtension(ResourceType);
|
const char* getResourceExtension(ResourceType);
|
||||||
const char* getResourceName(ResourceType);
|
const char* getResourceName(ResourceType);
|
||||||
|
@ -137,5 +137,99 @@ namespace Deer {
|
|||||||
return EntityStruct(newEnt.getId());
|
return EntityStruct(newEnt.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityStruct EntityStruct::getMeshComponent() {
|
||||||
|
Entity& self = GET_ENTITY(entityId);
|
||||||
|
|
||||||
|
if (!self.hasComponent<MeshComponent>()) {
|
||||||
|
self.addComponent<MeshComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EntityStruct::hasMeshComponent() {
|
||||||
|
Entity& self = GET_ENTITY(entityId);
|
||||||
|
|
||||||
|
return self.hasComponent<MeshComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EntityStruct::removeMeshComponent() {
|
||||||
|
Entity& self = GET_ENTITY(entityId);
|
||||||
|
|
||||||
|
if (self.hasComponent<MeshComponent>()) {
|
||||||
|
self.removeComponent<MeshComponent>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MeshComponentStruct::isActive() {
|
||||||
|
Entity& self = GET_ENTITY(entityId);
|
||||||
|
|
||||||
|
if (!self.hasComponent<MeshComponent>()) {
|
||||||
|
DEER_UI_ENGINE_ERROR("Entity {0} has no component Mesh Component", entityId);
|
||||||
|
|
||||||
|
if (currentDockPanelExecution)
|
||||||
|
currentDockPanelExecution->invalidate();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.getComponent<MeshComponent>().isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MeshComponentStruct::hasMesh() {
|
||||||
|
Entity& self = GET_ENTITY(entityId);
|
||||||
|
|
||||||
|
if (!self.hasComponent<MeshComponent>()) {
|
||||||
|
DEER_UI_ENGINE_ERROR("Entity {0} has no component Mesh Component", entityId);
|
||||||
|
|
||||||
|
if (currentDockPanelExecution)
|
||||||
|
currentDockPanelExecution->invalidate();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.getComponent<MeshComponent>().hasMesh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MeshComponentStruct::clear() {
|
||||||
|
Entity& self = GET_ENTITY(entityId);
|
||||||
|
|
||||||
|
if (!self.hasComponent<MeshComponent>()) {
|
||||||
|
DEER_UI_ENGINE_ERROR("Entity {0} has no component Mesh Component", entityId);
|
||||||
|
|
||||||
|
if (currentDockPanelExecution)
|
||||||
|
currentDockPanelExecution->invalidate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.removeComponent<MeshComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string MeshComponentStruct::getMesh() {
|
||||||
|
Entity& self = GET_ENTITY(entityId);
|
||||||
|
|
||||||
|
if (!self.hasComponent<MeshComponent>()) {
|
||||||
|
DEER_UI_ENGINE_ERROR("Entity {0} has no component Mesh Component", entityId);
|
||||||
|
|
||||||
|
if (currentDockPanelExecution)
|
||||||
|
currentDockPanelExecution->invalidate();
|
||||||
|
return "NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.getComponent<MeshComponent>().getMeshName();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MeshComponentStruct::setMesh(std::string& name) {
|
||||||
|
Entity& self = GET_ENTITY(entityId);
|
||||||
|
|
||||||
|
if (!self.hasComponent<MeshComponent>()) {
|
||||||
|
DEER_UI_ENGINE_ERROR("Entity {0} has no component Mesh Component", entityId);
|
||||||
|
|
||||||
|
if (currentDockPanelExecution)
|
||||||
|
currentDockPanelExecution->invalidate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t meshId = MeshManager::loadModel(name);
|
||||||
|
self.getComponent<MeshComponent>().setMesh(meshId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,6 +25,8 @@ namespace Deer {
|
|||||||
AS_CHECK(scriptEngine->RegisterObjectType("TransformComponent", sizeof(EntityStruct),
|
AS_CHECK(scriptEngine->RegisterObjectType("TransformComponent", sizeof(EntityStruct),
|
||||||
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityStruct>() | asOBJ_APP_CLASS_ALLINTS));
|
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityStruct>() | asOBJ_APP_CLASS_ALLINTS));
|
||||||
|
|
||||||
|
AS_CHECK(scriptEngine->RegisterObjectType("MeshComponent", sizeof(EntityStruct),
|
||||||
|
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityStruct>() | asOBJ_APP_CLASS_ALLINTS));
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerEntityFunctions() {
|
void registerEntityFunctions() {
|
||||||
@ -120,6 +122,28 @@ namespace Deer {
|
|||||||
asCALL_THISCALL
|
asCALL_THISCALL
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
||||||
|
"Entity",
|
||||||
|
"MeshComponent getMeshComponent()",
|
||||||
|
asMETHOD(EntityStruct, getMeshComponent),
|
||||||
|
asCALL_THISCALL
|
||||||
|
));
|
||||||
|
|
||||||
|
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
||||||
|
"Entity",
|
||||||
|
"bool hasMeshComponent()",
|
||||||
|
asMETHOD(EntityStruct, hasMeshComponent),
|
||||||
|
asCALL_THISCALL
|
||||||
|
));
|
||||||
|
|
||||||
|
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
||||||
|
"Entity",
|
||||||
|
"void removeMeshComponent()",
|
||||||
|
asMETHOD(EntityStruct, removeMeshComponent),
|
||||||
|
asCALL_THISCALL
|
||||||
|
));
|
||||||
|
|
||||||
AS_CHECK(scriptEngine->RegisterGlobalFunction(
|
AS_CHECK(scriptEngine->RegisterGlobalFunction(
|
||||||
"Entity getRoot()",
|
"Entity getRoot()",
|
||||||
asFUNCTION(getRoot),
|
asFUNCTION(getRoot),
|
||||||
@ -141,6 +165,7 @@ namespace Deer {
|
|||||||
asCALL_THISCALL
|
asCALL_THISCALL
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
// TRANSFORM COMPONENT
|
// TRANSFORM COMPONENT
|
||||||
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
||||||
"TransformComponent",
|
"TransformComponent",
|
||||||
@ -183,6 +208,41 @@ namespace Deer {
|
|||||||
asMETHOD(TransformComponentStruct, setRotation),
|
asMETHOD(TransformComponentStruct, setRotation),
|
||||||
asCALL_THISCALL
|
asCALL_THISCALL
|
||||||
));
|
));
|
||||||
|
|
||||||
|
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
||||||
|
"MeshComponent",
|
||||||
|
"bool get_isActive() const property",
|
||||||
|
asMETHOD(MeshComponentStruct, isActive),
|
||||||
|
asCALL_THISCALL
|
||||||
|
));
|
||||||
|
|
||||||
|
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
||||||
|
"MeshComponent",
|
||||||
|
"bool get_hasMesh() const property",
|
||||||
|
asMETHOD(MeshComponentStruct, hasMesh),
|
||||||
|
asCALL_THISCALL
|
||||||
|
));
|
||||||
|
|
||||||
|
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
||||||
|
"MeshComponent",
|
||||||
|
"void clear()",
|
||||||
|
asMETHOD(MeshComponentStruct, clear),
|
||||||
|
asCALL_THISCALL
|
||||||
|
));
|
||||||
|
|
||||||
|
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
||||||
|
"MeshComponent",
|
||||||
|
"string getMesh()",
|
||||||
|
asMETHOD(MeshComponentStruct, getMesh),
|
||||||
|
asCALL_THISCALL
|
||||||
|
));
|
||||||
|
|
||||||
|
AS_CHECK(scriptEngine->RegisterObjectMethod(
|
||||||
|
"MeshComponent",
|
||||||
|
"void setMesh(string&in)",
|
||||||
|
asMETHOD(MeshComponentStruct, setMesh),
|
||||||
|
asCALL_THISCALL
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerTransformComponent() {
|
void registerTransformComponent() {
|
@ -15,6 +15,9 @@ namespace Deer {
|
|||||||
|
|
||||||
case ResourceType::MESH :
|
case ResourceType::MESH :
|
||||||
return DEER_MESH_PATH;
|
return DEER_MESH_PATH;
|
||||||
|
|
||||||
|
case ResourceType::SHADER :
|
||||||
|
return DEER_SHADER_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -27,7 +30,10 @@ namespace Deer {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
case ResourceType::MESH :
|
case ResourceType::MESH :
|
||||||
return ".dmesh";
|
return DEER_MESH_EXTENSION;
|
||||||
|
|
||||||
|
case ResourceType::SHADER :
|
||||||
|
return DEER_SHADER_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -41,6 +47,9 @@ namespace Deer {
|
|||||||
|
|
||||||
case ResourceType::MESH :
|
case ResourceType::MESH :
|
||||||
return "Mesh";
|
return "Mesh";
|
||||||
|
|
||||||
|
case ResourceType::SHADER :
|
||||||
|
return "Shader";
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
@ -11,6 +11,7 @@ namespace Deer {
|
|||||||
void registerResourceTypeEnum() {
|
void registerResourceTypeEnum() {
|
||||||
AS_RET_CHECK(scriptEngine->RegisterEnum("ResourceType"));
|
AS_RET_CHECK(scriptEngine->RegisterEnum("ResourceType"));
|
||||||
AS_CHECK(scriptEngine->RegisterEnumValue("ResourceType", "Mesh", (int)ResourceType::MESH));
|
AS_CHECK(scriptEngine->RegisterEnumValue("ResourceType", "Mesh", (int)ResourceType::MESH));
|
||||||
|
AS_CHECK(scriptEngine->RegisterEnumValue("ResourceType", "Shader", (int)ResourceType::SHADER));
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerEditorEngineStructs() {
|
void registerEditorEngineStructs() {
|
||||||
|
@ -11,3 +11,12 @@ void renderTransformComponent(any@ data) {
|
|||||||
transform.scale = magicSlider3("Scale", scale, 0.1);
|
transform.scale = magicSlider3("Scale", scale, 0.1);
|
||||||
transform.rotation = magicSlider3("Rotation", rotation, 0.1);
|
transform.rotation = magicSlider3("Rotation", rotation, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void renderMeshComponent(any@ data) {
|
||||||
|
Entity entity;
|
||||||
|
data.retrieve(entity);
|
||||||
|
|
||||||
|
MeshComponent meshComponent = entity.getMeshComponent();
|
||||||
|
|
||||||
|
text(meshComponent.getMesh());
|
||||||
|
}
|
@ -28,7 +28,10 @@ class PropertiesPannel : DockPanel {
|
|||||||
space();
|
space();
|
||||||
|
|
||||||
componentNode("Transform Component", any(entity), renderTransformComponent);
|
componentNode("Transform Component", any(entity), renderTransformComponent);
|
||||||
componentNode("Transform Component 2", any(entity), renderTransformComponent);
|
|
||||||
|
if (entity.hasMeshComponent()) {
|
||||||
|
componentNode("Mesh Component", any(entity), renderMeshComponent);
|
||||||
|
}
|
||||||
|
|
||||||
space();
|
space();
|
||||||
|
|
||||||
|
41
roe/editor/shader_explorer.as
Normal file
41
roe/editor/shader_explorer.as
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
class ShaderExplorer : DockPanel {
|
||||||
|
string currentPath = "";
|
||||||
|
|
||||||
|
void onRender() {
|
||||||
|
setupAutomaticColumns(128);
|
||||||
|
|
||||||
|
// To avoid problems we will cache the current path
|
||||||
|
const string cache_currentPath = currentPath;
|
||||||
|
if (cache_currentPath != "") {
|
||||||
|
drawIconCentered("folder", 64);
|
||||||
|
if (isItemClicked(0) and isMouseDoubleClicked(0)) {
|
||||||
|
currentPath = "";
|
||||||
|
}
|
||||||
|
textCenter(cache_currentPath + "/..");
|
||||||
|
nextColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourceType resourceType = ResourceType::Shader;
|
||||||
|
int dirCount = getDirCount(resourceType, cache_currentPath);
|
||||||
|
for (int i = 0; i < dirCount; i++) {
|
||||||
|
drawIconCentered("folder", 64);
|
||||||
|
|
||||||
|
if (isItemClicked(0) and isMouseDoubleClicked(0)) {
|
||||||
|
print(getDirPathById(resourceType, cache_currentPath, i));
|
||||||
|
currentPath = getDirPathById(resourceType, cache_currentPath, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
textCenter(getDirNameById(resourceType, cache_currentPath, i));
|
||||||
|
nextColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
int meshCount = getResourceCount(resourceType, cache_currentPath);
|
||||||
|
for (int i = 0; i < meshCount; i++) {
|
||||||
|
drawIconCentered("file", 64);
|
||||||
|
|
||||||
|
textCenter(getResourceNameById(resourceType, cache_currentPath, i));
|
||||||
|
nextColumn();
|
||||||
|
}
|
||||||
|
endColumns();
|
||||||
|
}
|
||||||
|
}
|
@ -90,6 +90,12 @@ Size=338,429
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,1
|
DockId=0x00000004,1
|
||||||
|
|
||||||
|
[Window][ShaderExplorer]
|
||||||
|
Pos=0,500
|
||||||
|
Size=1280,220
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000008,1
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y
|
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y
|
||||||
DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,474 Split=Y
|
DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,474 Split=Y
|
||||||
@ -97,7 +103,7 @@ DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y
|
|||||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=878,338 Split=X Selected=0x13926F0B
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=878,338 Split=X Selected=0x13926F0B
|
||||||
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=256,446 Selected=0xE45B9F93
|
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=256,446 Selected=0xE45B9F93
|
||||||
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=620,446 CentralNode=1 Selected=0x13926F0B
|
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=620,446 CentralNode=1 Selected=0x13926F0B
|
||||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=400,338 Selected=0x2A2C795E
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=400,338 Selected=0xA35A27E3
|
||||||
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702
|
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702
|
||||||
DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,220 Selected=0xD962995A
|
DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,220 Selected=0xD962995A
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user