载入中...
搜索中...
未找到
SceneInternal.h
浏览该文件的文档.
1#pragma once
2
3// Internal helpers shared between scene/Scene.cpp and scene/SceneNodes.cpp.
4//
5// Extracted verbatim from Scene.cpp when the node methods were split out.
6// Anonymous namespace: each translation unit gets its own internal copy,
7// exactly like the original single file.
8
9#include "common/Export.h"
11#include "scene/SceneHost.h"
12
13#include <glm/glm.hpp>
14#include <glm/gtc/quaternion.hpp>
15
16#include <string>
17
18namespace ssq {
19class Class;
20}
21
22namespace eve::scene {
23
31
32namespace {
33
40int linkKindFromString(const std::string &kind) { return findLinkKind(kind.c_str()); }
41
43int syncModeFromString(const std::string &mode) {
44 return mode == "body" ? 1 : 0;
45}
46
48glm::quat nodeQuaternion(const SceneNode &n) {
50 return glm::angleAxis(n.yaw, glm::vec3(0.f, 1.f, 0.f)) *
52 glm::angleAxis(n.pitch, glm::vec3(1.f, 0.f, 0.f)) *
54 glm::angleAxis(n.roll, glm::vec3(0.f, 0.f, 1.f));
55}
56
65void decomposeWorld(const glm::mat4 &w, glm::vec3 &pos, glm::vec3 &euler,
66 glm::vec3 &scale) {
67 pos = glm::vec3(w[3]);
69 glm::vec3 c0(w[0]), c1(w[1]), c2(w[2]);
70 scale = glm::vec3(glm::length(c0), glm::length(c1), glm::length(c2));
71 if (scale.x > 1e-8f) c0 /= scale.x;
72 if (scale.y > 1e-8f) c1 /= scale.y;
73 if (scale.z > 1e-8f) c2 /= scale.z;
75 glm::mat3 rot(c0, c1, c2);
76 eve::eulerYxzFromMatrix(glm::mat4(rot), euler.x, euler.y, euler.z);
77}
78
79} // namespace
80} // namespace eve::scene
float w
Definition AnimClip.cpp:738
HSQOBJECT cls
Definition ECS.cpp:39
#define EVENGINE_API_PLATFORM
Definition Export.h:107
glm::vec3 n
Definition Grass.cpp:63
std::array< float, 3 > scale
std::string kind
EVENGINE_API_PLATFORM void exposeScriptLinkBindings(ssq::Class &cls)
Register eve.Scene's script-link surface.
int findLinkKind(const char *kind)
Finds link kind.
void eulerYxzFromMatrix(const glm::mat< 4, 4, T, glm::defaultp > &m, T &yaw, T &pitch, T &roll)
Yaw/pitch/roll for the engine's transform order T * Ry * Rx * Rz * S.
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
Definition ECS.h:21