From bacc98d4a695fb0dee06159194af0fdecef6206b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 26 Apr 2016 03:40:56 -0700 Subject: [PATCH] Initial CCollidableOBBTreeGroup imps --- DataSpec/DNAMP1/MREA.hpp | 2 +- Runtime/Collision/CCollidableAABox.cpp | 6 ++ Runtime/Collision/CCollidableAABox.hpp | 11 ++++ Runtime/Collision/CCollidableOBBTreeGroup.cpp | 6 ++ Runtime/Collision/CCollidableOBBTreeGroup.hpp | 4 +- Runtime/Collision/CCollisionEdge.cpp | 20 ++++++ Runtime/Collision/CCollisionEdge.hpp | 21 ++++++ Runtime/Collision/CMakeLists.txt | 2 + Runtime/Collision/COBBTree.cpp | 65 +++++++++++++++++++ Runtime/Collision/COBBTree.hpp | 58 +++++++++++++++++ Runtime/World/CMakeLists.txt | 1 + Runtime/World/CWorldLight.cpp | 46 +++++++++++++ Runtime/World/CWorldLight.hpp | 34 ++++++++++ hecl | 2 +- specter | 2 +- 15 files changed, 275 insertions(+), 5 deletions(-) create mode 100644 Runtime/Collision/CCollidableAABox.cpp create mode 100644 Runtime/Collision/CCollidableAABox.hpp create mode 100644 Runtime/Collision/CCollisionEdge.cpp create mode 100644 Runtime/Collision/CCollisionEdge.hpp create mode 100644 Runtime/Collision/COBBTree.cpp create mode 100644 Runtime/Collision/COBBTree.hpp create mode 100644 Runtime/World/CWorldLight.cpp create mode 100644 Runtime/World/CWorldLight.hpp diff --git a/DataSpec/DNAMP1/MREA.hpp b/DataSpec/DNAMP1/MREA.hpp index 09c188f8b..e9f840fc7 100644 --- a/DataSpec/DNAMP1/MREA.hpp +++ b/DataSpec/DNAMP1/MREA.hpp @@ -94,7 +94,7 @@ struct MREA Value q; Value spotCutoff; Value unk5; - Value unk6; + Value castShadows; Value unk7; Value falloff; Value unk9; diff --git a/Runtime/Collision/CCollidableAABox.cpp b/Runtime/Collision/CCollidableAABox.cpp new file mode 100644 index 000000000..ee048d470 --- /dev/null +++ b/Runtime/Collision/CCollidableAABox.cpp @@ -0,0 +1,6 @@ +#include "CCollidableAABox.hpp" + +CCollidableAABox::CCollidableAABox() +{ + +} diff --git a/Runtime/Collision/CCollidableAABox.hpp b/Runtime/Collision/CCollidableAABox.hpp new file mode 100644 index 000000000..b94c3d0c9 --- /dev/null +++ b/Runtime/Collision/CCollidableAABox.hpp @@ -0,0 +1,11 @@ +#ifndef CCOLLIDABLEAABOX_HPP +#define CCOLLIDABLEAABOX_HPP + + +class CCollidableAABox +{ +public: + CCollidableAABox(); +}; + +#endif // CCOLLIDABLEAABOX_HPP \ No newline at end of file diff --git a/Runtime/Collision/CCollidableOBBTreeGroup.cpp b/Runtime/Collision/CCollidableOBBTreeGroup.cpp index f272e9a22..8f2e76076 100644 --- a/Runtime/Collision/CCollidableOBBTreeGroup.cpp +++ b/Runtime/Collision/CCollidableOBBTreeGroup.cpp @@ -1,4 +1,5 @@ #include "CCollidableOBBTreeGroup.hpp" +#include "COBBTree.hpp" #include "CToken.hpp" namespace urde @@ -6,6 +7,11 @@ namespace urde CCollidableOBBTreeGroup::CCollidableOBBTreeGroup(CInputStream& in) { + u32 treeCount = in.readUint32Big(); + x0_trees.reserve(treeCount); + + for (u32 i = 0 ; i < treeCount ; i++) + x0_trees.push_back(in); } CFactoryFnReturn FCollidableOBBTreeGroupFactory(const SObjectTag &tag, CInputStream &in, diff --git a/Runtime/Collision/CCollidableOBBTreeGroup.hpp b/Runtime/Collision/CCollidableOBBTreeGroup.hpp index 26346be73..c1c934e64 100644 --- a/Runtime/Collision/CCollidableOBBTreeGroup.hpp +++ b/Runtime/Collision/CCollidableOBBTreeGroup.hpp @@ -3,12 +3,12 @@ #include "IOStreams.hpp" #include "CFactoryMgr.hpp" - namespace urde { - +class COBBTree; class CCollidableOBBTreeGroup { + std::vector x0_trees; public: CCollidableOBBTreeGroup(CInputStream& in); }; diff --git a/Runtime/Collision/CCollisionEdge.cpp b/Runtime/Collision/CCollisionEdge.cpp new file mode 100644 index 000000000..fa3d14521 --- /dev/null +++ b/Runtime/Collision/CCollisionEdge.cpp @@ -0,0 +1,20 @@ +#include "CCollisionEdge.hpp" + +namespace urde +{ +CCollisionEdge::CCollisionEdge(CInputStream& in) +{ + x0_index1 = in.readUint16Big(); + x2_index2 = in.readUint16Big(); +} + +u16 CCollisionEdge::GetVertIndex1() const +{ + return x0_index1; +} + +u16 CCollisionEdge::GetVertIndex2() const +{ + return x2_index2; +} +} diff --git a/Runtime/Collision/CCollisionEdge.hpp b/Runtime/Collision/CCollisionEdge.hpp new file mode 100644 index 000000000..ff5c94a97 --- /dev/null +++ b/Runtime/Collision/CCollisionEdge.hpp @@ -0,0 +1,21 @@ +#ifndef __URDE_CCOLLISIONEDGE_HPP__ +#define __URDE_CCOLLISIONEDGE_HPP__ + +#include "RetroTypes.hpp" + +namespace urde +{ +class CCollisionEdge +{ + u16 x0_index1 = -1; + u16 x2_index2 = -1; +public: + CCollisionEdge()=default; + CCollisionEdge(CInputStream&); + + u16 GetVertIndex1() const; + u16 GetVertIndex2() const; +}; +} + +#endif // __URDE_CCOLLISIONEDGE_HPP__ diff --git a/Runtime/Collision/CMakeLists.txt b/Runtime/Collision/CMakeLists.txt index 0c609d94d..f241968bd 100644 --- a/Runtime/Collision/CMakeLists.txt +++ b/Runtime/Collision/CMakeLists.txt @@ -1,6 +1,8 @@ set(COLLISION_SOURCES CGameCollision.hpp CGameCollision.cpp CCollisionInfo.hpp CCollisionInfo.cpp + CCollisionEdge.hpp CCollisionEdge.cpp + COBBTree.hpp COBBTree.cpp CCollidableOBBTree.hpp CCollidableOBBTree.cpp CCollidableOBBTreeGroup.hpp CCollidableOBBTreeGroup.cpp CMaterialList.hpp diff --git a/Runtime/Collision/COBBTree.cpp b/Runtime/Collision/COBBTree.cpp new file mode 100644 index 000000000..f135780a2 --- /dev/null +++ b/Runtime/Collision/COBBTree.cpp @@ -0,0 +1,65 @@ +#include "COBBTree.hpp" + + +namespace urde +{ +/* This is exactly what retro did >.< */ +u32 verify_deaf_babe(CInputStream& in) +{ + return in.readUint32Big(); +} + +/* This is exactly what retro did >.< */ +u32 verify_version(CInputStream& in) +{ + return in.readUint32Big(); +} + +COBBTree::COBBTree(const COBBTree::SIndexData&, const COBBTree::CNode*) +{ +} + +COBBTree::COBBTree(CInputStream& in) + : x0_magic(verify_deaf_babe(in)), + x4_version(verify_version(in)), + x8_memsize(in.readUint32()), + x18_indexData(in) +{ +} + +COBBTree::SIndexData::SIndexData(CInputStream& in) +{ + u32 count = in.readUint32Big(); + x0_.reserve(count); + for (u32 i = 0 ; i < count ; i++) + x0_.push_back(in.readUint32Big()); + + count = in.readUint32Big(); + for (u32 i = 0 ; i < count ; i++) + x10_.push_back(in.readUByte()); + count = in.readUint32Big(); + for (u32 i = 0 ; i < count ; i++) + x20_.push_back(in.readUByte()); + count = in.readUint32Big(); + for (u32 i = 0 ; i < count ; i++) + x30_.push_back(in.readUByte()); + + count = in.readUint32Big(); + for (u32 i = 0 ; i < count ; i++) + x40_.push_back(in); + + count = in.readUint32Big(); + for (u32 i = 0 ; i < count ; i++) + x50_.push_back(in.readUint16Big()); + + count = in.readUint32Big(); + for (u32 i = 0 ; i < count ; i++) + x60_.push_back(zeus::CVector3f::ReadBig(in)); +} + +COBBTree::CNode::CNode(CInputStream& in) +{ + x0_obb = zeus::COBBox::ReadBig(in); +} + +} diff --git a/Runtime/Collision/COBBTree.hpp b/Runtime/Collision/COBBTree.hpp new file mode 100644 index 000000000..a43d3c336 --- /dev/null +++ b/Runtime/Collision/COBBTree.hpp @@ -0,0 +1,58 @@ +#ifndef __URDE_COBBTREE_HPP__ +#define __URDE_COBBTREE_HPP__ +#include "RetroTypes.hpp" +#include "CCollisionEdge.hpp" +#include "zeus/CVector3f.hpp" +#include "zeus/COBBox.hpp" + +namespace urde +{ +class COBBTree +{ +public: + struct SIndexData + { + std::vector x0_; + std::vector x10_; + std::vector x20_; + std::vector x30_; + std::vector x40_; + std::vector x50_; + std::vector x60_; + SIndexData()=default; + SIndexData(CInputStream&); + }; + + class CNodeLeafData + { + }; + + class CNode + { + zeus::COBBox x0_obb; + bool x3c_ = false; + std::unique_ptr x40_; + std::unique_ptr x44_; + std::unique_ptr x48_; + public: + CNode() = default; + CNode(CInputStream&); + }; + +private: + + u32 x0_magic = 0; + u32 x4_version = 0; + u32 x8_memsize = 0; + /* CSimpleAllocator xc_ We're not using this but lets keep track*/ + SIndexData x18_indexData; + std::unique_ptr x88_root; +public: + + + COBBTree(const COBBTree::SIndexData&, const CNode*); + COBBTree(CInputStream&); +}; +} + +#endif // __URDE_COBBTREE_HPP__ diff --git a/Runtime/World/CMakeLists.txt b/Runtime/World/CMakeLists.txt index 38954a93f..0c9e14e95 100644 --- a/Runtime/World/CMakeLists.txt +++ b/Runtime/World/CMakeLists.txt @@ -1,5 +1,6 @@ set(WORLD_SOURCES CWorld.hpp CWorld.cpp + CWorldLight.hpp CWorldLight.cpp IGameArea.hpp IGameArea.cpp CGameArea.hpp CGameArea.cpp CAi.hpp CAi.cpp diff --git a/Runtime/World/CWorldLight.cpp b/Runtime/World/CWorldLight.cpp new file mode 100644 index 000000000..563627186 --- /dev/null +++ b/Runtime/World/CWorldLight.cpp @@ -0,0 +1,46 @@ +#include "CWorldLight.hpp" + +namespace urde +{ +CWorldLight::CWorldLight(CInputStream& in) + : x0_type(ELightType(in.readUint32Big())), + x4_color(zeus::CVector3f::ReadBig(in)), + x10_position(zeus::CVector3f::ReadBig(in)), + x1c_direction(zeus::CVector3f::ReadBig(in)), + x28_q(in.readFloatBig()), + x2c_cutoffAngle(in.readFloatBig()), + x34_castShadows(in.readBool()), + x38_(in.readFloatBig()), + x3c_falloff(EFalloffType(in.readUint32Big())), + x40_(in.readFloatBig()) +{ +} + +CLight CWorldLight::GetAsCGraphicsLight() const +{ + const float epsilon = 1.1920929e-7; + zeus::CVector3f tmpColor = x4_color; + zeus::CColor color(x4_color.x, x4_color.y, x4_color.z); + float tmp = x28_q; + if (epsilon < tmp) + tmp = 0.0000011920929f; +/* + if (x0_type == ELightType::Spot) + { + float f2 = tmpColor.x; + float f0 = tmpColor.y; + float f1 = tmpColor.z; + float f3 = f2 * tmp; + f2 = f0 * tmp; + f0 = 1.0f; + f1 *= tmp; + tmpColor.x = f3; + tmpColor.y = f2; + tmpColor.z = f1; + + if (f3 >= f0) + } +*/ +} + +} diff --git a/Runtime/World/CWorldLight.hpp b/Runtime/World/CWorldLight.hpp new file mode 100644 index 000000000..e4034ecec --- /dev/null +++ b/Runtime/World/CWorldLight.hpp @@ -0,0 +1,34 @@ +#ifndef CWORLDLIGHT_HPP +#define CWORLDLIGHT_HPP + +#include "Graphics/CLight.hpp" + +namespace urde +{ +class CWorldLight +{ + ELightType x0_type = ELightType::Custom; + zeus::CVector3f x4_color; + zeus::CVector3f x10_position; + zeus::CVector3f x1c_direction; + float x28_q = 0.f; + float x2c_cutoffAngle = 0.f; + float x30_ = 0.f; + bool x34_castShadows = false; + float x38_ = 0.f; + EFalloffType x3c_falloff = EFalloffType::Linear; + float x40_ = 0.f; +public: + CWorldLight(const CWorldLight&) = default; + CWorldLight(CInputStream& in); + ELightType GetLightType() const; + const zeus::CVector3f& GetDirection() const; + const zeus::CVector3f& GetPosition() const; + bool DoesCastShadows() const; + + CLight GetAsCGraphicsLight() const; +}; + +} + +#endif // CWORLDLIGHT_HPP diff --git a/hecl b/hecl index fdc5d61b4..a21258cf8 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit fdc5d61b4e091a8c5eefa625ea9b21d59977f633 +Subproject commit a21258cf8cc91e042c1ebee64db10c2dca3651e8 diff --git a/specter b/specter index d705b8d7f..d14a7aed7 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit d705b8d7f4f433b0bcbc76a789b3ed7874829e56 +Subproject commit d14a7aed7bd256191ed5bfbbb9a0f9cf4a141796