22 if (ImGui::CollapsingHeader(
"Position", ImGuiTreeNodeFlags_DefaultOpen)) {
30 if (ImGui::DragFloat3(
"Position", pos, 0.1f)) {
32 if (selectedEntity.scene) {
33 entt::registry* registry;
34 if (selectedEntity.isGlobal) {
35 registry = &selectedEntity.scene->getRegistry();
37 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
42 if (registry->valid(selectedEntity.entity)) {
43 auto* mutableComponent = registry->try_get<
PositionComponent>(selectedEntity.entity);
44 if (mutableComponent) {
45 mutableComponent->position.x = pos[0];
46 mutableComponent->position.y = pos[1];
47 mutableComponent->position.z = pos[2];
54 if (ImGui::Button(
"删除组件##PositionComponent")) {
55 g_editorGlobal.componentToDelete = entt::type_hash<PositionComponent>::value();
64 if (ImGui::CollapsingHeader(
"Rotation", ImGuiTreeNodeFlags_DefaultOpen)) {
67 static float rot[3] = {component->rotation.x, component->rotation.y, component->rotation.z};
68 rot[0] = component->rotation.x;
69 rot[1] = component->rotation.y;
70 rot[2] = component->rotation.z;
72 if (ImGui::DragFloat3(
"Rotation (degrees)", rot, 1.0f)) {
74 if (selectedEntity.scene) {
75 entt::registry* registry;
76 if (selectedEntity.isGlobal) {
77 registry = &selectedEntity.scene->getRegistry();
79 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
84 if (registry->valid(selectedEntity.entity)) {
85 auto* mutableComponent = registry->try_get<RotationComponent>(selectedEntity.entity);
86 if (mutableComponent) {
87 mutableComponent->rotation.x = rot[0];
88 mutableComponent->rotation.y = rot[1];
89 mutableComponent->rotation.z = rot[2];
96 if (ImGui::Button(
"删除组件##RotationComponent")) {
97 g_editorGlobal.componentToDelete = entt::type_hash<RotationComponent>::value();
106 if (ImGui::CollapsingHeader(
"Scale", ImGuiTreeNodeFlags_DefaultOpen)) {
109 static float scale[3] = {component->scale.x, component->scale.y, component->scale.z};
110 scale[0] = component->scale.x;
111 scale[1] = component->scale.y;
112 scale[2] = component->scale.z;
114 if (ImGui::DragFloat3(
"Scale", scale, 0.01f, 0.001f, 100.0f)) {
116 if (selectedEntity.scene) {
117 entt::registry* registry;
118 if (selectedEntity.isGlobal) {
119 registry = &selectedEntity.scene->getRegistry();
121 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
126 if (registry->valid(selectedEntity.entity)) {
127 auto* mutableComponent = registry->try_get<ScaleComponent>(selectedEntity.entity);
128 if (mutableComponent) {
129 mutableComponent->scale.x = scale[0];
130 mutableComponent->scale.y = scale[1];
131 mutableComponent->scale.z = scale[2];
138 if (ImGui::Button(
"删除组件##ScaleComponent")) {
139 g_editorGlobal.componentToDelete = entt::type_hash<ScaleComponent>::value();
211 if (ImGui::CollapsingHeader(
"CacheRotationMatrix", ImGuiTreeNodeFlags_DefaultOpen)) {
213 ImGui::Text(
"旋转矩阵 (缓存)");
214 ImGui::Text(
"[%.3f, %.3f, %.3f, %.3f]",
215 component->rotationMatrix.m[0], component->rotationMatrix.m[1],
216 component->rotationMatrix.m[2], component->rotationMatrix.m[3]);
217 ImGui::Text(
"[%.3f, %.3f, %.3f, %.3f]",
218 component->rotationMatrix.m[4], component->rotationMatrix.m[5],
219 component->rotationMatrix.m[6], component->rotationMatrix.m[7]);
220 ImGui::Text(
"[%.3f, %.3f, %.3f, %.3f]",
221 component->rotationMatrix.m[8], component->rotationMatrix.m[9],
222 component->rotationMatrix.m[10], component->rotationMatrix.m[11]);
223 ImGui::Text(
"[%.3f, %.3f, %.3f, %.3f]",
224 component->rotationMatrix.m[12], component->rotationMatrix.m[13],
225 component->rotationMatrix.m[14], component->rotationMatrix.m[15]);
242 if (ImGui::CollapsingHeader(
"Directional Light", ImGuiTreeNodeFlags_DefaultOpen)) {
245 static float direction[3] = {component->direction.x, component->direction.y, component->direction.z};
246 direction[0] = component->direction.x;
247 direction[1] = component->direction.y;
248 direction[2] = component->direction.z;
250 if (ImGui::DragFloat3(
"Direction", direction, 0.01f, -1.0f, 1.0f)) {
252 if (selectedEntity.scene) {
253 entt::registry* registry;
254 if (selectedEntity.isGlobal) {
255 registry = &selectedEntity.scene->getRegistry();
257 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
262 if (registry->valid(selectedEntity.entity)) {
263 auto* mutableComponent = registry->try_get<DirectionalLightComponent>(selectedEntity.entity);
264 if (mutableComponent) {
265 mutableComponent->direction.x = direction[0];
266 mutableComponent->direction.y = direction[1];
267 mutableComponent->direction.z = direction[2];
273 static float color[3] = {component->color.x, component->color.y, component->color.z};
274 color[0] = component->color.x;
275 color[1] = component->color.y;
276 color[2] = component->color.z;
278 if (ImGui::ColorEdit3(
"Color", color)) {
280 if (selectedEntity.scene) {
281 entt::registry* registry;
282 if (selectedEntity.isGlobal) {
283 registry = &selectedEntity.scene->getRegistry();
285 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
290 if (registry->valid(selectedEntity.entity)) {
291 auto* mutableComponent = registry->try_get<DirectionalLightComponent>(selectedEntity.entity);
292 if (mutableComponent) {
293 mutableComponent->color.x = color[0];
294 mutableComponent->color.y = color[1];
295 mutableComponent->color.z = color[2];
301 static float intensity = component->intensity;
302 intensity = component->intensity;
304 if (ImGui::SliderFloat(
"Intensity", &intensity, 0.0f, 5.0f)) {
306 if (selectedEntity.scene) {
307 entt::registry* registry;
308 if (selectedEntity.isGlobal) {
309 registry = &selectedEntity.scene->getRegistry();
311 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
316 if (registry->valid(selectedEntity.entity)) {
317 auto* mutableComponent = registry->try_get<DirectionalLightComponent>(selectedEntity.entity);
318 if (mutableComponent) {
319 mutableComponent->intensity = intensity;
325 static bool enabled = component->enabled;
326 enabled = component->enabled;
328 if (ImGui::Checkbox(
"Enabled", &enabled)) {
330 if (selectedEntity.scene) {
331 entt::registry* registry;
332 if (selectedEntity.isGlobal) {
333 registry = &selectedEntity.scene->getRegistry();
335 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
340 if (registry->valid(selectedEntity.entity)) {
341 auto* mutableComponent = registry->try_get<DirectionalLightComponent>(selectedEntity.entity);
342 if (mutableComponent) {
343 mutableComponent->enabled = enabled;
350 if (ImGui::Button(
"删除组件##DirectionalLightComponent")) {
351 g_editorGlobal.componentToDelete = entt::type_hash<DirectionalLightComponent>::value();
360 if (ImGui::CollapsingHeader(
"Diffuse Texture", ImGuiTreeNodeFlags_DefaultOpen)) {
362 ImGui::Text(
"模型UUID: %s", component->modelUuid.empty() ?
"未设置" : component->modelUuid.c_str());
363 ImGui::Text(
"纹理路径: %s", component->texturePath.empty() ?
"未设置" : component->texturePath.c_str());
364 ImGui::Text(
"纹理状态: %s", component->texture ?
"已加载" :
"未加载");
367 if (ImGui::Button(
"删除组件##DiffuseTextureComponent")) {
368 g_editorGlobal.componentToDelete = entt::type_hash<DiffuseTextureComponent>::value();
377 if (ImGui::CollapsingHeader(
"Normal Map", ImGuiTreeNodeFlags_DefaultOpen)) {
379 ImGui::Text(
"模型UUID: %s", component->modelUuid.empty() ?
"未设置" : component->modelUuid.c_str());
380 ImGui::Text(
"纹理路径: %s", component->texturePath.empty() ?
"未设置" : component->texturePath.c_str());
381 ImGui::Text(
"纹理状态: %s", component->texture ?
"已加载" :
"未加载");
384 if (ImGui::Button(
"删除组件##NormalMapComponent")) {
385 g_editorGlobal.componentToDelete = entt::type_hash<NormalMapComponent>::value();
394 if (ImGui::CollapsingHeader(
"Shininess", ImGuiTreeNodeFlags_DefaultOpen)) {
397 static float shininess = component->shininess;
398 shininess = component->shininess;
400 if (ImGui::DragFloat(
"Shininess", &shininess, 1.0f, 1.0f, 256.0f)) {
402 if (selectedEntity.scene) {
403 entt::registry* registry;
404 if (selectedEntity.isGlobal) {
405 registry = &selectedEntity.scene->getRegistry();
407 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
412 if (registry->valid(selectedEntity.entity)) {
413 auto* mutableComponent = registry->try_get<ShininessComponent>(selectedEntity.entity);
414 if (mutableComponent) {
415 mutableComponent->shininess = shininess;
422 if (ImGui::Button(
"删除组件##ShininessComponent")) {
423 g_editorGlobal.componentToDelete = entt::type_hash<ShininessComponent>::value();