forked from rrika/cdcEngineDXHR
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam Jensen
committed
Mar 7, 2024
1 parent
3533b09
commit 9ce5251
Showing
16 changed files
with
246 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
#pragma once | ||
|
||
namespace cdc { class IAnimGraphNode; } | ||
namespace cdc { | ||
|
||
class IAnimGraphNode; | ||
|
||
class AnimComponentV2 { | ||
public: | ||
cdc::IAnimGraphNode *firstNode = nullptr; // 54 | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
target_sources(dxhr PRIVATE | ||
ObjectComponent.cpp | ||
ObjectManager.cpp) | ||
ObjectManager.cpp | ||
UberObject.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
#include "cdcWorld/UserDataComponent.h" | ||
|
||
class ObjState : public InstanceUserData { | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include "cdcAnim/AnimComponentV2.h" | ||
#include "cdcWorld/Object.h" | ||
#include "cdcWorld/Instance.h" | ||
#include "cdcWorld/InstanceManager.h" | ||
#include "cdcWorld/InstncG2.h" | ||
#include "cdc/dtp/objectbasedata.h" | ||
#include "UberObject.h" | ||
|
||
Instance *UBEROBJECT_BirthSectionInstance(Instance *parent, uint32_t modelIndex, uint32_t id) { | ||
// TODO | ||
Instance *instance = InstanceManager::CreateInstance2(); | ||
instance->DefaultInit( | ||
parent->object, | ||
modelIndex, | ||
id, | ||
parent->intro, | ||
parent->introData, | ||
&parent->position, | ||
&parent->rotation, | ||
/*pDerivedObject=*/ nullptr, | ||
/*flags=*/ 0); | ||
|
||
instance->position = parent->position; // but DefaultInit just did that | ||
instance->rotation = parent->rotation; // but DefaultInit just did that | ||
|
||
// TODO | ||
|
||
instance->objectComponent.SetInstance(instance); | ||
|
||
// TODO | ||
|
||
dtp::ObjectBaseData *dtpData = instance->object->dtpData; | ||
if (dtpData->hasAnimGraph || dtpData->numHostedAnimGraphs) { | ||
dtp::Model *model = instance->GetModels()[modelIndex]; | ||
// instance->animComponentV2 = new cdc::AnimComponentV2(instance); | ||
// instance->animComponentV2->Init(model); | ||
} | ||
|
||
return instance; | ||
} | ||
|
||
UberObjectComposite::UberObjectComposite(Instance *instance, bool deferSectionInit) { | ||
auto *prop = (dtp::UberObjectProp*) instance->object->data; // actually reads a cached version thereof | ||
UserDataComponent::CreateIfNeeded(instance)->userData = this; | ||
// TODO | ||
this->instance = instance; | ||
// TODO | ||
|
||
numSections = prop->numSections; | ||
sectionList = new int32_t[numSections]; | ||
for (uint32_t i=0; i<numSections; i++) | ||
sectionList[i] = 0x7FFFFFFF; | ||
|
||
if (!deferSectionInit) | ||
CreateSections(instance); | ||
} | ||
|
||
uint32_t CurrentBirthID = 0x1000000; // how is this initialized | ||
|
||
void UberObjectComposite::CreateSections(Instance *instance) { | ||
if (!createdSections) { | ||
createdSections = true; | ||
auto *prop = (dtp::UberObjectProp*) instance->object->data; // actually reads a cached version thereof | ||
if (sectionsIntroUniqueID == ~0u) { | ||
sectionsIntroUniqueID = CurrentBirthID; | ||
CurrentBirthID += prop->numSections; | ||
} | ||
|
||
for (uint32_t i=0; i<numSections; i++) { | ||
Instance *child = CreateSectionInstance(instance, &prop->sectionList[i], i); | ||
sectionList[i] = child ? child->introUniqueID : 0x7FFFFFFF; | ||
} | ||
} | ||
} | ||
|
||
Instance *UberObjectComposite::CreateSectionInstance(Instance *instance, dtp::UberObjectProp::SectionProp *info, uint32_t index) { | ||
Instance *child = UBEROBJECT_BirthSectionInstance(instance, info->modelIndex, sectionsIntroUniqueID + index); | ||
// TODO | ||
if (child) { | ||
// TODO | ||
cdc::G2Instance_SetTransformsToIdentity(child); | ||
} | ||
return child; | ||
} | ||
|
||
UberObjectSection::UberObjectSection(Instance *instance, UberObjectComposite *composite, dtp::UberObjectProp::SectionProp *info, uint32_t index) { | ||
// TODO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
#include <cstdint> | ||
#include "cdcObjects/Objects.h" | ||
#include "cdc/dtp/objecttypes/uberobject.h" | ||
|
||
// There is a string .\game\Objects\UberObject.cpp in DXHRDC.exe suggesting this file should go there, | ||
// but Tomb Raider later moved it to cdcObjects/ which makes more sense IMO. | ||
|
||
class Instance; | ||
|
||
Instance *UBEROBJECT_BirthSectionInstance(Instance *parent, uint32_t modelIndex, uint32_t id); | ||
|
||
class UberObjectComposite : public ObjState { | ||
Instance *instance; // 54 | ||
bool createdSections = false; // 5D | ||
uint32_t sectionsIntroUniqueID = ~0u; // 60 | ||
int32_t *sectionList = nullptr; // 64 | ||
uint32_t numSections = 0; // 68 | ||
public: | ||
UberObjectComposite(Instance *instance, bool deferSectionInit); | ||
void CreateSections(Instance *instance); | ||
Instance *CreateSectionInstance(Instance *instance, dtp::UberObjectProp::SectionProp *info, uint32_t index); | ||
}; | ||
|
||
class UberObjectSection : public ObjState { | ||
public: | ||
UberObjectSection(Instance *instance, UberObjectComposite *composite, dtp::UberObjectProp::SectionProp *info, uint32_t index); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "UserDataComponent.h" | ||
#include "cdcWorld/Instance.h" | ||
|
||
UserDataComponent *UserDataComponent::CreateIfNeeded(Instance *instance) { | ||
if (!instance->userDataComponent) { | ||
auto *udc = new UserDataComponent(instance); | ||
instance->userDataComponent = udc; | ||
} | ||
return instance->userDataComponent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
#include "cdcWorld/InstanceComponent.h" | ||
|
||
// namespaced as cdc::InstanceUserData in Tomb Raider | ||
struct InstanceUserData { | ||
// empty | ||
}; | ||
|
||
// namespaced as cdc::UserDataComponent in Tomb Raider | ||
class UserDataComponent : public InstanceComponent { | ||
public: | ||
Instance *instance; | ||
InstanceUserData *userData; | ||
|
||
UserDataComponent(Instance *i) : instance(i), userData(nullptr) {} | ||
static UserDataComponent *CreateIfNeeded(Instance*); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
#include <cstdint> | ||
|
||
namespace dtp { | ||
|
||
struct UberObjectProp { | ||
struct SectionProp { | ||
uint8_t pad[0x28]; | ||
uint8_t modelIndex; // 28 | ||
uint8_t pad29[0x2F0-0x29]; | ||
}; | ||
uint16_t version; // 0 | ||
uint16_t family; // 2 | ||
uint16_t id; // 4 | ||
uint16_t type; // 6 | ||
uint32_t numSections; // 8 | ||
SectionProp *sectionList; // C | ||
}; | ||
|
||
static_assert(sizeof(UberObjectProp::SectionProp) == 0x2F0); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "UberObject_DX3.h" | ||
|
||
void UBEROBJECT_DX3_Init(Instance *instance, GameTracker*) { | ||
// TODO | ||
new UberObjectComposite_DX3(instance); | ||
} | ||
|
||
UberObjectComposite_DX3::UberObjectComposite_DX3(Instance *instance) : | ||
UberObjectComposite(instance, /*deferSectionInit=*/ true) | ||
{ | ||
CreateSections(instance); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
#include "cdcObjects/UberObject.h" | ||
|
||
struct GameTracker; | ||
|
||
void UBEROBJECT_DX3_Init(Instance*, GameTracker*); | ||
|
||
class UberObjectComposite_DX3 : public UberObjectComposite { | ||
public: | ||
UberObjectComposite_DX3(Instance *instance); | ||
}; | ||
|
||
class UberObjectSection_DX3 : public UberObjectSection { | ||
|
||
}; |