#ifndef TRANSFORM_COMPONENT_H #define TRANSFORM_COMPONENT_H #include #include #include class TransformComponent { public: TransformComponent(); ~TransformComponent(); glm::vec3 position; glm::vec3 rotation; // Euler angles (pitch, yaw, roll) in degrees. glm::vec3 scale; // Returns the world transform matrix. glm::mat4 GetMatrix() const; // Save this transform to a YAML node. YAML::Node Save() const { YAML::Node node; node["position"] = YAML::Node(); node["position"].push_back(position.x); node["position"].push_back(position.y); node["position"].push_back(position.z); node["rotation"] = YAML::Node(); node["rotation"].push_back(rotation.x); node["rotation"].push_back(rotation.y); node["rotation"].push_back(rotation.z); node["scale"] = YAML::Node(); node["scale"].push_back(scale.x); node["scale"].push_back(scale.y); node["scale"].push_back(scale.z); return node; } // Load this transform from a YAML node. void Load(const YAML::Node &node) { if (node["position"]) { position.x = node["position"][0].as(); position.y = node["position"][1].as(); position.z = node["position"][2].as(); } if (node["rotation"]) { rotation.x = node["rotation"][0].as(); rotation.y = node["rotation"][1].as(); rotation.z = node["rotation"][2].as(); } if (node["scale"]) { scale.x = node["scale"][0].as(); scale.y = node["scale"][1].as(); scale.z = node["scale"][2].as(); } } }; #endif // TRANSFORM_COMPONENT_H