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();
196 if (ImGui::CollapsingHeader(
"CacheRotationMatrix", ImGuiTreeNodeFlags_DefaultOpen)) {
198 ImGui::Text(
"旋转矩阵 (缓存)");
199 ImGui::Text(
"[%.3f, %.3f, %.3f, %.3f]",
200 component->rotationMatrix.m[0], component->rotationMatrix.m[1],
201 component->rotationMatrix.m[2], component->rotationMatrix.m[3]);
202 ImGui::Text(
"[%.3f, %.3f, %.3f, %.3f]",
203 component->rotationMatrix.m[4], component->rotationMatrix.m[5],
204 component->rotationMatrix.m[6], component->rotationMatrix.m[7]);
205 ImGui::Text(
"[%.3f, %.3f, %.3f, %.3f]",
206 component->rotationMatrix.m[8], component->rotationMatrix.m[9],
207 component->rotationMatrix.m[10], component->rotationMatrix.m[11]);
208 ImGui::Text(
"[%.3f, %.3f, %.3f, %.3f]",
209 component->rotationMatrix.m[12], component->rotationMatrix.m[13],
210 component->rotationMatrix.m[14], component->rotationMatrix.m[15]);
227 if (ImGui::CollapsingHeader(
"Directional Light", ImGuiTreeNodeFlags_DefaultOpen)) {
230 static float direction[3] = {component->direction.x, component->direction.y, component->direction.z};
231 direction[0] = component->direction.x;
232 direction[1] = component->direction.y;
233 direction[2] = component->direction.z;
235 if (ImGui::DragFloat3(
"Direction", direction, 0.01f, -1.0f, 1.0f)) {
237 if (selectedEntity.scene) {
238 entt::registry* registry;
239 if (selectedEntity.isGlobal) {
240 registry = &selectedEntity.scene->getRegistry();
242 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
247 if (registry->valid(selectedEntity.entity)) {
248 auto* mutableComponent = registry->try_get<DirectionalLightComponent>(selectedEntity.entity);
249 if (mutableComponent) {
250 mutableComponent->direction.x = direction[0];
251 mutableComponent->direction.y = direction[1];
252 mutableComponent->direction.z = direction[2];
258 static float color[3] = {component->color.x, component->color.y, component->color.z};
259 color[0] = component->color.x;
260 color[1] = component->color.y;
261 color[2] = component->color.z;
263 if (ImGui::ColorEdit3(
"Color", color)) {
265 if (selectedEntity.scene) {
266 entt::registry* registry;
267 if (selectedEntity.isGlobal) {
268 registry = &selectedEntity.scene->getRegistry();
270 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
275 if (registry->valid(selectedEntity.entity)) {
276 auto* mutableComponent = registry->try_get<DirectionalLightComponent>(selectedEntity.entity);
277 if (mutableComponent) {
278 mutableComponent->color.x = color[0];
279 mutableComponent->color.y = color[1];
280 mutableComponent->color.z = color[2];
286 static float intensity = component->intensity;
287 intensity = component->intensity;
289 if (ImGui::SliderFloat(
"Intensity", &intensity, 0.0f, 5.0f)) {
291 if (selectedEntity.scene) {
292 entt::registry* registry;
293 if (selectedEntity.isGlobal) {
294 registry = &selectedEntity.scene->getRegistry();
296 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
301 if (registry->valid(selectedEntity.entity)) {
302 auto* mutableComponent = registry->try_get<DirectionalLightComponent>(selectedEntity.entity);
303 if (mutableComponent) {
304 mutableComponent->intensity = intensity;
310 static bool enabled = component->enabled;
311 enabled = component->enabled;
313 if (ImGui::Checkbox(
"Enabled", &enabled)) {
315 if (selectedEntity.scene) {
316 entt::registry* registry;
317 if (selectedEntity.isGlobal) {
318 registry = &selectedEntity.scene->getRegistry();
320 SceneTrunk* trunk = selectedEntity.scene->getLoadedTrunk(selectedEntity.trunkName);
325 if (registry->valid(selectedEntity.entity)) {
326 auto* mutableComponent = registry->try_get<DirectionalLightComponent>(selectedEntity.entity);
327 if (mutableComponent) {
328 mutableComponent->enabled = enabled;
335 if (ImGui::Button(
"删除组件##DirectionalLightComponent")) {
336 g_editorGlobal.componentToDelete = entt::type_hash<DirectionalLightComponent>::value();
345 if (ImGui::CollapsingHeader(
"Diffuse Texture", ImGuiTreeNodeFlags_DefaultOpen)) {
347 ImGui::Text(
"模型UUID: %s", component->modelUuid.empty() ?
"未设置" : component->modelUuid.c_str());
348 ImGui::Text(
"纹理路径: %s", component->texturePath.empty() ?
"未设置" : component->texturePath.c_str());
349 ImGui::Text(
"纹理状态: %s", component->texture ?
"已加载" :
"未加载");
352 if (ImGui::Button(
"删除组件##DiffuseTextureComponent")) {
353 g_editorGlobal.componentToDelete = entt::type_hash<DiffuseTextureComponent>::value();