Browse Source

Engine: Add ability to set camera zoom-level via scene JSON

master
Riyyi 2 years ago
parent
commit
f47babe5cf
  1. 9
      src/inferno/scene/scene.cpp

9
src/inferno/scene/scene.cpp

@ -54,11 +54,13 @@ void Scene::initialize()
auto& cameraJson = sceneJson.at("camera"); auto& cameraJson = sceneJson.at("camera");
uint32_t camera = loadEntity(cameraJson); uint32_t camera = loadEntity(cameraJson);
auto cameraType = CameraType::Perspective; auto& cameraComponent = addComponent<CameraComponent>(camera);
if (cameraJson.exists("type") && cameraJson.at("type").get<std::string>() == "orthographic") { if (cameraJson.exists("type") && cameraJson.at("type").get<std::string>() == "orthographic") {
cameraType = CameraType::Orthographic; cameraComponent.type = CameraType::Orthographic;
}
if (cameraJson.exists("zoom-level") && cameraJson.at("zoom-level").type() == ruc::Json::Type::Number) {
cameraComponent.zoomLevel = cameraJson.at("zoom-level").asDouble();
} }
addComponent<CameraComponent>(camera, cameraType);
if (cameraJson.exists("script")) { if (cameraJson.exists("script")) {
auto& cameraScript = cameraJson.at("script"); auto& cameraScript = cameraJson.at("script");
@ -67,6 +69,7 @@ void Scene::initialize()
addComponent<LuaScriptComponent>(camera, cameraScript.at("name").get<std::string>()); addComponent<LuaScriptComponent>(camera, cameraScript.at("name").get<std::string>());
} }
else { else {
// TODO: Allow usage of custom camera classes
addComponent<NativeScriptComponent>(camera).bind<CameraController>(); addComponent<NativeScriptComponent>(camera).bind<CameraController>();
} }
} }

Loading…
Cancel
Save