From 484ef1988b5a4e0e1966bdaacbeb9b8cc92555cf Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 21 Apr 2016 17:40:26 -1000 Subject: [PATCH] Add camera loader --- Runtime/Camera/CCameraManager.hpp | 6 ++++++ Runtime/World/ScriptLoader.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/Runtime/Camera/CCameraManager.hpp b/Runtime/Camera/CCameraManager.hpp index d4d433ed4..8a7c0244e 100644 --- a/Runtime/Camera/CCameraManager.hpp +++ b/Runtime/Camera/CCameraManager.hpp @@ -41,6 +41,12 @@ class CCameraManager public: CCameraManager(TUniqueId curCameraId); + static float DefaultAspect() {return 1.42f;} + static float DefaultFarPlane() {return 750.0f;} + static float DefaultNearPlane() {return 0.2f;} + static float DefaultFirstPersonFOV() {return 55.0f;} + static float DefaultThirdPersonFOV() {return 60.0f;} + void SetSpecialCameras(CFirstPersonCamera& fp, CBallCamera& ball) { x7c_fpCamera = &fp; diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 466fec8c1..970302074 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -25,6 +25,7 @@ #include "CScriptSound.hpp" #include "CScriptGenerator.hpp" #include "CScriptGrapplePoint.hpp" +#include "Camera/CCinematicCamera.hpp" #include "CSimplePool.hpp" #include "Collision/CCollidableOBBTreeGroup.hpp" #include "Editor/ProjectResourceFactoryMP1.hpp" @@ -730,6 +731,33 @@ CEntity* ScriptLoader::LoadDock(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadCamera(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { + if (!EnsurePropertyCount(propCount, 14, "Camera")) + return nullptr; + + SActorHead head = LoadActorHead(in, mgr); + + bool b1 = in.readBool(); + float f1 = in.readFloatBig(); + bool b2 = in.readBool(); + bool b3 = in.readBool(); + bool b4 = in.readBool(); + bool b5 = in.readBool(); + bool b6 = in.readBool(); + bool b7 = in.readBool(); + bool b8 = in.readBool(); + float f2 = in.readFloatBig(); + bool b9 = in.readBool(); + + bool b10 = false; + if (propCount > 14) + b10 = in.readBool(); + + u32 flags = b2 | b3 << 1 | b4 << 2 | b5 << 3 | b6 << 4 | b7 << 5 | b8 << 6 | b9 << 8; + + return new CCinematicCamera(mgr.AllocateUniqueId(), head.x0_name, info, + head.x10_transform, b1, f1, f2 / CCameraManager::DefaultAspect(), + CCameraManager::DefaultNearPlane(), CCameraManager::DefaultFarPlane(), + CCameraManager::DefaultAspect(), flags); } CEntity* ScriptLoader::LoadCameraWaypoint(CStateManager& mgr, CInputStream& in,