63 lines
1.7 KiB
ActionScript
63 lines
1.7 KiB
ActionScript
class MeshComponentRender {
|
|
Entity entity;
|
|
MeshComponent meshComponent;
|
|
|
|
MeshComponentRender(Entity _entity) {
|
|
entity = _entity;
|
|
meshComponent = entity.getComponent<MeshComponent>();
|
|
}
|
|
|
|
void render() {
|
|
if (!entity.hasComponent<MeshComponent>())
|
|
return;
|
|
|
|
ImGui::title("Mesh Component");
|
|
ImGui::space(10, 10);
|
|
ImGui::text("Mesh : ");
|
|
ImGui::sameline();
|
|
if (meshComponent.hasMesh) {
|
|
ImGui::text(meshComponent.meshResource.name);
|
|
} else {
|
|
ImGui::text("Empty");
|
|
}
|
|
|
|
// Mesh icon
|
|
if (meshComponent.hasMesh) {
|
|
FrameBuffer frameBuffer = Previewer::getMeshPreview(meshComponent.meshResource);
|
|
ImGui::drawFrameBufferCentered(frameBuffer, 128, 128);
|
|
} else {
|
|
ImGui::drawIconCentered(StudioAPI::loadIcon("empty.png"), 128);
|
|
}
|
|
|
|
ImGui::dragDropTarget("MESH", ReciverFunction(this.setMesh));
|
|
|
|
ImGui::space(10, 10);
|
|
bool active = meshComponent.isActive;
|
|
if (meshComponent.get_hasMesh()) {
|
|
active = ImGui::checkbox("Active", active);
|
|
meshComponent.set_isActive(active);
|
|
} else {
|
|
ImGui::checkboxDisabled("Active", active);
|
|
}
|
|
|
|
ImGui::sameline();
|
|
|
|
if (ImGui::buttonEnd("Clear")) {
|
|
meshComponent.clear();
|
|
}
|
|
}
|
|
|
|
void setMesh(any@ meshData) {
|
|
GPUMesh mesh;
|
|
if (meshData.retrieve(mesh)) {
|
|
meshComponent.meshResource = mesh;
|
|
}
|
|
}
|
|
|
|
void remove() {
|
|
if (ImGui::menuItem("Remove")) {
|
|
entity.removeComponent<MeshComponent>();
|
|
}
|
|
}
|
|
}
|