-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move some meshComponent stuff to scripts
- Loading branch information
1 parent
845d31e
commit ea8b22d
Showing
18 changed files
with
610 additions
and
155 deletions.
There are no files selected for viewing
272 changes: 206 additions & 66 deletions
272
build/r6/scripts/let_there_be_flight/let_there_be_flight.packed.reds
Large diffs are not rendered by default.
Oops, something went wrong.
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
Binary file modified
BIN
+3 KB
(100%)
build/red4ext/plugins/let_there_be_flight/let_there_be_flight.dll
Binary file not shown.
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
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,80 @@ | ||
#include "MeshComponent.hpp" | ||
#include <RED4ext/Scripting/Natives/Generated/ent/HardTransformBinding.hpp> | ||
#include <RED4ext/Scripting/Natives/Generated/ent/VisualControllerComponent.hpp> | ||
#include <RED4ext/Scripting/Natives/Generated/ent/SlotComponent.hpp> | ||
|
||
void MeshComponent::SetMesh(RED4ext::ResRef mesh) { | ||
this->mesh.path = mesh.resource.path; | ||
} | ||
|
||
void IPlacedComponent::SetParentTransform(RED4ext::CName bindName, RED4ext::CName slotName) { | ||
auto rtti = RED4ext::CRTTISystem::Get(); | ||
auto htb = (RED4ext::ent::HardTransformBinding *)rtti->GetClass("entHardTransformBinding")->CreateInstance(); | ||
htb->bindName = bindName; | ||
htb->slotName = slotName; | ||
this->parentTransform = RED4ext::Handle<RED4ext::ent::ITransformBinding>(htb); | ||
} | ||
|
||
void Entity::AddComponent(RED4ext::Handle<RED4ext::ent::IComponent> componentToAdd) { | ||
RED4ext::ent::VisualControllerComponent *vcc = NULL; | ||
auto rtti = RED4ext::CRTTISystem::Get(); | ||
|
||
for (auto const &handle : this->componentsStorage.components) { | ||
auto component = handle.GetPtr(); | ||
if (component->GetNativeType() == rtti->GetClass("entVisualControllerComponent")) { | ||
vcc = reinterpret_cast<RED4ext::ent::VisualControllerComponent *>(component); | ||
break; | ||
} | ||
} | ||
|
||
if (vcc != NULL) { | ||
if (componentToAdd->GetNativeType() == rtti->GetClass("entMeshComponent")) { | ||
auto meshComponent = (RED4ext::ent::MeshComponent *)componentToAdd.instance; | ||
this->componentsStorage.components.EmplaceBack(componentToAdd); | ||
auto vcd = reinterpret_cast<RED4ext::ent::VisualControllerDependency *>( | ||
rtti->GetClass("entVisualControllerDependency")->CreateInstance()); | ||
vcd->appearanceName = meshComponent->meshAppearance; | ||
vcd->componentName = meshComponent->name; | ||
vcd->mesh.path = meshComponent->mesh.path; | ||
vcc->appearanceDependency.EmplaceBack(*vcd); | ||
|
||
if (vcc->resourcePaths.size) { | ||
for (int i = 0; i < vcc->resourcePaths.size; i++) { | ||
if (vcc->resourcePaths[i] == meshComponent->mesh.path) { | ||
break; | ||
} else if (vcc->resourcePaths[i] > meshComponent->mesh.path) { | ||
vcc->resourcePaths.Emplace(&vcc->resourcePaths[i], meshComponent->mesh.path); | ||
break; | ||
} | ||
} | ||
} else { | ||
vcc->resourcePaths.EmplaceBack(meshComponent->mesh.path); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void Entity::AddSlot(RED4ext::CName boneName, RED4ext::CName slotName, RED4ext::Vector3 relativePosition, RED4ext::Quaternion relativeRotation) { | ||
RED4ext::ent::SlotComponent *slotComponent = NULL; | ||
auto rtti = RED4ext::CRTTISystem::Get(); | ||
|
||
for (auto const &handle : this->componentsStorage.components) { | ||
auto component = handle.GetPtr(); | ||
if (component->GetNativeType() == rtti->GetClass("entSlotComponent")) { | ||
if (component->name == "vehicle_slots") { | ||
slotComponent = reinterpret_cast<RED4ext::ent::SlotComponent *>(component); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (slotComponent != NULL) { | ||
auto slot = reinterpret_cast<RED4ext::ent::Slot *>(rtti->GetClass("entSlot")->CreateInstance()); | ||
slot->boneName = boneName; | ||
slot->slotName = slotName; | ||
slot->relativePosition = relativePosition; | ||
slot->relativeRotation = relativeRotation; | ||
slotComponent->slots.EmplaceBack(*slot); | ||
slotComponent->slotIndexLookup.Emplace(slot->slotName, slotComponent->slots.size - 1); | ||
} | ||
} |
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,46 @@ | ||
#pragma once | ||
|
||
#include "Engine/RTTIExpansion.hpp" | ||
#include <RED4ext/Scripting/Natives/Generated/ent/MeshComponent.hpp> | ||
#include <RED4ext/Scripting/Natives/Generated/ent/IPlacedComponent.hpp> | ||
#include <RED4ext/Scripting/Natives/Generated/red/ResourceReferenceScriptToken.hpp> | ||
|
||
class MeshComponent : public Engine::RTTIExpansion<MeshComponent, RED4ext::ent::MeshComponent> { | ||
public: | ||
void SetMesh(RED4ext::ResRef mesh); | ||
|
||
private: | ||
friend Descriptor; | ||
|
||
inline static void OnExpand(Descriptor *aType, RED4ext::CRTTISystem *) { | ||
aType->AddFunction<&MeshComponent::SetMesh>("SetMesh"); | ||
} | ||
}; | ||
|
||
|
||
class IPlacedComponent : public Engine::RTTIExpansion<IPlacedComponent, RED4ext::ent::IPlacedComponent> { | ||
public: | ||
void SetParentTransform(RED4ext::CName bindName, RED4ext::CName slotName); | ||
|
||
private: | ||
friend Descriptor; | ||
|
||
inline static void OnExpand(Descriptor *aType, RED4ext::CRTTISystem *) { | ||
aType->AddFunction<&IPlacedComponent::SetParentTransform>("SetParentTransform"); | ||
} | ||
}; | ||
|
||
|
||
class Entity : public Engine::RTTIExpansion<Entity, RED4ext::ent::Entity> { | ||
public: | ||
void AddComponent(RED4ext::Handle<RED4ext::ent::IComponent> component); | ||
void AddSlot(RED4ext::CName boneName, RED4ext::CName slotName, RED4ext::Vector3 relativePosition, | ||
RED4ext::Quaternion relativeRotation); | ||
private: | ||
friend Descriptor; | ||
|
||
inline static void OnExpand(Descriptor *aType, RED4ext::CRTTISystem *) { | ||
aType->AddFunction<&Entity::AddComponent>("AddComponent"); | ||
aType->AddFunction<&Entity::AddSlot>("AddSlot"); | ||
} | ||
}; |
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
Binary file not shown.
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
Oops, something went wrong.