|
|
|
@ -65,58 +65,20 @@ namespace Sandbox
|
|
|
|
|
SHResourceManager::FinaliseChanges();
|
|
|
|
|
|
|
|
|
|
// Create Materials
|
|
|
|
|
auto matInst = graphicsSystem->AddOrGetBaseMaterialInstance();
|
|
|
|
|
auto customMat = graphicsSystem->AddMaterialInstanceCopy(matInst);
|
|
|
|
|
customMat->SetProperty("data.color", SHVec4(0.0f, 1.0f, 1.0f, 1.0f));
|
|
|
|
|
customMat->SetProperty("data.textureIndex", 0);
|
|
|
|
|
customMat->SetProperty("data.alpha", 0.1f);
|
|
|
|
|
auto baseRaccoonMat = graphicsSystem->AddOrGetBaseMaterialInstance();
|
|
|
|
|
auto baseRaccoonMatInstant = graphicsSystem->AddMaterialInstanceCopy(baseRaccoonMat);
|
|
|
|
|
baseRaccoonMatInstant->SetProperty("data.color", SHVec4(0.0f, 0.0f, 0.0f, 1.0f));
|
|
|
|
|
baseRaccoonMatInstant->SetProperty("data.textureIndex", 0);
|
|
|
|
|
baseRaccoonMatInstant->SetProperty("data.alpha", 0.1f);
|
|
|
|
|
|
|
|
|
|
// Create Stress Test Objects
|
|
|
|
|
static const SHVec3 TEST_OBJ_SCALE = SHVec3::One;
|
|
|
|
|
constexpr int NUM_ROWS = 3;
|
|
|
|
|
constexpr int NUM_COLS = 1;
|
|
|
|
|
static const SHVec3 TEST_OBJ_SPACING = { 0.1f, 0.1f, 0.1f };
|
|
|
|
|
static const SHVec3 TEST_OBJ_START_POS = { -(NUM_COLS / 2 * TEST_OBJ_SPACING.x) + 1.0f, -2.0f, -1.0f };
|
|
|
|
|
auto baseFloorMatInstant = graphicsSystem->AddMaterialInstanceCopy(baseRaccoonMat);
|
|
|
|
|
baseFloorMatInstant->SetProperty("data.color", SHVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
|
|
|
|
baseFloorMatInstant->SetProperty("data.textureIndex", 0);
|
|
|
|
|
baseFloorMatInstant->SetProperty("data.alpha", 0.1f);
|
|
|
|
|
|
|
|
|
|
for (int y = 0; y < NUM_ROWS; ++y)
|
|
|
|
|
for (int x = 0; x < NUM_COLS; ++x)
|
|
|
|
|
{
|
|
|
|
|
auto entity = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent, SHRigidBodyComponent, SHColliderComponent>();
|
|
|
|
|
auto& renderable = *SHComponentManager::GetComponent_s<SHRenderable>(entity);
|
|
|
|
|
auto& transform = *SHComponentManager::GetComponent_s<SHTransformComponent>(entity);
|
|
|
|
|
auto& collider = *SHComponentManager::GetComponent_s<SHColliderComponent>(entity);
|
|
|
|
|
auto dummy = SHEntityManager::CreateEntity<>();
|
|
|
|
|
|
|
|
|
|
//renderable.Mesh = handles.front();
|
|
|
|
|
renderable.SetMesh(CUBE_MESH);
|
|
|
|
|
renderable.SetMaterial(customMat);
|
|
|
|
|
|
|
|
|
|
if (y == 50)
|
|
|
|
|
renderable.GetModifiableMaterial()->SetProperty("data.color", SHVec4(1.0f, 0.0f, 0.0f, 1.0f));
|
|
|
|
|
|
|
|
|
|
//Set initial positions
|
|
|
|
|
transform.SetWorldPosition(TEST_OBJ_START_POS + SHVec3{ x * TEST_OBJ_SPACING.x, y * TEST_OBJ_SPACING.y, SHMath::GenerateRandomNumber(-3.5f, -5.0f) });
|
|
|
|
|
//transform.SetWorldPosition({-1.0f, -1.0f, -1.0f});
|
|
|
|
|
transform.SetWorldRotation(SHMath::GenerateRandomNumber(0.0f, 360.0f), SHMath::GenerateRandomNumber(0.0f, 360.0f), SHMath::GenerateRandomNumber(0.0f, 360.0f));
|
|
|
|
|
transform.SetWorldScale(TEST_OBJ_SCALE);
|
|
|
|
|
|
|
|
|
|
collider.AddBoundingBox(SHVec3::One, SHVec3::Zero);
|
|
|
|
|
stressTestObjects.emplace_back(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto raccoonSpin = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
|
|
|
|
|
auto& renderable = *SHComponentManager::GetComponent_s<SHRenderable>(raccoonSpin);
|
|
|
|
|
auto& transform = *SHComponentManager::GetComponent_s<SHTransformComponent>(raccoonSpin);
|
|
|
|
|
|
|
|
|
|
renderable.SetMesh(handles.front());
|
|
|
|
|
renderable.SetMaterial(customMat);
|
|
|
|
|
renderable.GetModifiableMaterial()->SetProperty("data.color", SHVec4(0.0f, 0.0f, 0.0f, 0.0f));
|
|
|
|
|
renderable.GetModifiableMaterial()->SetProperty("data.alpha", 1.0f);
|
|
|
|
|
renderable.GetModifiableMaterial()->SetProperty("data.textureIndex", 0);
|
|
|
|
|
|
|
|
|
|
transform.SetWorldPosition({ -3.0f, -1.0f, -1.0f });
|
|
|
|
|
transform.SetLocalScale({ 5.0f, 5.0f, 5.0f });
|
|
|
|
|
|
|
|
|
|
auto floor = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent, SHRigidBodyComponent, SHColliderComponent>();
|
|
|
|
|
auto floor = SHEntityManager::CreateEntity<SHTransformComponent,SHRenderable, SHRigidBodyComponent, SHColliderComponent>();
|
|
|
|
|
auto& floorRenderable = *SHComponentManager::GetComponent_s<SHRenderable>(floor);
|
|
|
|
|
auto& floorTransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(floor);
|
|
|
|
|
auto& floorRigidBody = *SHComponentManager::GetComponent_s<SHRigidBodyComponent>(floor);
|
|
|
|
@ -125,7 +87,7 @@ namespace Sandbox
|
|
|
|
|
floorRenderable.SetMesh(CUBE_MESH);
|
|
|
|
|
floorRenderable.SetMaterial(graphicsSystem->GetDefaultMaterialInstance());
|
|
|
|
|
|
|
|
|
|
floorTransform.SetWorldScale({ 7.5f, 0.5f, 7.5 });
|
|
|
|
|
floorTransform.SetWorldScale({ 17.5f, 0.5f, 17.5f });
|
|
|
|
|
floorTransform.SetWorldPosition({ 0.0f, -3.0f, -5.0f });
|
|
|
|
|
|
|
|
|
|
floorRigidBody.SetType(SHRigidBodyComponent::Type::STATIC);
|
|
|
|
@ -138,16 +100,95 @@ namespace Sandbox
|
|
|
|
|
//testObjRenderable.Mesh = CUBE_MESH;
|
|
|
|
|
//testObjRenderable.SetMaterial(matInst);
|
|
|
|
|
|
|
|
|
|
//raccoon =======================================================================================================================
|
|
|
|
|
auto racoon = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent, SHRigidBodyComponent, SHColliderComponent>(MAX_EID, "Player");
|
|
|
|
|
auto& racoonRenderable = *SHComponentManager::GetComponent_s<SHRenderable>(racoon);
|
|
|
|
|
auto& racoonTransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(racoon);
|
|
|
|
|
auto& racoonRigidBody = *SHComponentManager::GetComponent_s<SHRigidBodyComponent>(racoon);
|
|
|
|
|
auto& racoonCollider = *SHComponentManager::GetComponent_s<SHColliderComponent>(racoon);
|
|
|
|
|
|
|
|
|
|
racoonRenderable.SetMesh(handles.front());
|
|
|
|
|
racoonRenderable.SetMaterial(baseRaccoonMatInstant);
|
|
|
|
|
|
|
|
|
|
racoonTransform.SetWorldScale({ 2.0f, 2.0f, 2.0f });
|
|
|
|
|
racoonTransform.SetWorldPosition({ -3.0f, -2.0f, -5.0f });
|
|
|
|
|
|
|
|
|
|
racoonCollider.AddBoundingBox();
|
|
|
|
|
racoonCollider.GetCollider(0).SetPositionOffset(SHVec3(0.0f,0.5f,0.0f));
|
|
|
|
|
racoonCollider.GetCollider(0).SetBoundingBox(SHVec3(0.5f, 0.5f, 0.5f));
|
|
|
|
|
|
|
|
|
|
auto racoonItemLocation = SHEntityManager::CreateEntity<SHTransformComponent>();
|
|
|
|
|
auto& racoonItemLocationTransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(racoonItemLocation);
|
|
|
|
|
SHSceneManager::GetCurrentSceneGraph().SetParent(racoonItemLocation, racoon);
|
|
|
|
|
|
|
|
|
|
auto racoonCamera = SHEntityManager::CreateEntity<SHTransformComponent>();
|
|
|
|
|
SHSceneManager::GetCurrentSceneGraph().SetParent(racoonCamera, racoon);
|
|
|
|
|
//================================================================================================================================
|
|
|
|
|
|
|
|
|
|
//item ===========================================================================================================================
|
|
|
|
|
auto item = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent, SHRigidBodyComponent, SHColliderComponent>(MAX_EID, "item");
|
|
|
|
|
auto& itemRenderable = *SHComponentManager::GetComponent_s<SHRenderable>(item);
|
|
|
|
|
auto& itemTransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(item);
|
|
|
|
|
auto& itemRigidBody = *SHComponentManager::GetComponent_s<SHRigidBodyComponent>(item);
|
|
|
|
|
auto& itemCollider = *SHComponentManager::GetComponent_s<SHColliderComponent>(item);
|
|
|
|
|
|
|
|
|
|
itemRenderable.SetMesh(handles.front());
|
|
|
|
|
itemRenderable.SetMaterial(baseRaccoonMatInstant);
|
|
|
|
|
|
|
|
|
|
itemTransform.SetWorldScale({ 2.0f, 2.0f, 2.0f });
|
|
|
|
|
itemTransform.SetWorldPosition({ 0.0f, -2.0f, -5.0f });
|
|
|
|
|
|
|
|
|
|
itemCollider.AddBoundingBox();
|
|
|
|
|
itemCollider.AddBoundingBox(SHVec3(2.0f,2.0f,2.0f));
|
|
|
|
|
itemCollider.GetCollider(1).SetIsTrigger(true);
|
|
|
|
|
|
|
|
|
|
itemCollider.GetCollider(0).SetPositionOffset(SHVec3(0.0f, 0.5f, 0.0f));
|
|
|
|
|
itemCollider.GetCollider(0).SetBoundingBox(SHVec3(0.5f, 0.5f, 0.5f));
|
|
|
|
|
|
|
|
|
|
itemCollider.GetCollider(1).SetPositionOffset(SHVec3(0.0f, 0.5f, 0.0f));
|
|
|
|
|
itemCollider.GetCollider(1).SetBoundingBox(SHVec3(1.0f, 1.0f, 1.0f));
|
|
|
|
|
|
|
|
|
|
itemRigidBody.SetInterpolate(false);
|
|
|
|
|
itemRigidBody.SetFreezeRotationX(true);
|
|
|
|
|
itemRigidBody.SetFreezeRotationY(true);
|
|
|
|
|
itemRigidBody.SetFreezeRotationZ(true);
|
|
|
|
|
//================================================================================================================================
|
|
|
|
|
|
|
|
|
|
//AI =============================================================================================================================
|
|
|
|
|
auto AI = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent, SHRigidBodyComponent, SHColliderComponent>(MAX_EID, "AI");
|
|
|
|
|
auto& AIRenderable = *SHComponentManager::GetComponent_s<SHRenderable>(AI);
|
|
|
|
|
auto& AITransform = *SHComponentManager::GetComponent_s<SHTransformComponent>(AI);
|
|
|
|
|
auto& AIRigidBody = *SHComponentManager::GetComponent_s<SHRigidBodyComponent>(AI);
|
|
|
|
|
auto& AICollider = *SHComponentManager::GetComponent_s<SHColliderComponent>(AI);
|
|
|
|
|
|
|
|
|
|
AIRenderable.SetMesh(handles.front());
|
|
|
|
|
AIRenderable.SetMaterial(baseRaccoonMatInstant);
|
|
|
|
|
|
|
|
|
|
AITransform.SetWorldScale({ 2.0f, 2.0f, 2.0f });
|
|
|
|
|
AITransform.SetWorldPosition({ -8.0f, -2.0f, 2.5f });
|
|
|
|
|
|
|
|
|
|
AICollider.AddBoundingBox();
|
|
|
|
|
AICollider.GetCollider(0).SetPositionOffset(SHVec3(0.0f, 0.5f, 0.0f));
|
|
|
|
|
AICollider.GetCollider(0).SetBoundingBox(SHVec3(0.5f, 0.5f, 0.5f));
|
|
|
|
|
|
|
|
|
|
AIRigidBody.SetInterpolate(false);
|
|
|
|
|
AIRigidBody.SetFreezeRotationX(true);
|
|
|
|
|
AIRigidBody.SetFreezeRotationY(true);
|
|
|
|
|
AIRigidBody.SetFreezeRotationZ(true);
|
|
|
|
|
//================================================================================================================================
|
|
|
|
|
|
|
|
|
|
SHADE::SHScriptEngine* scriptEngine = static_cast<SHADE::SHScriptEngine*>(SHADE::SHSystemManager::GetSystem<SHADE::SHScriptEngine>());
|
|
|
|
|
scriptEngine->AddScript(raccoonSpin, "RaccoonSpin");
|
|
|
|
|
scriptEngine->AddScript(racoon, "PlayerController");
|
|
|
|
|
scriptEngine->AddScript(racoon, "PickAndThrow");
|
|
|
|
|
scriptEngine->AddScript(racoonCamera, "ThirdPersonCamera");
|
|
|
|
|
scriptEngine->AddScript(AI, "AIPrototype");
|
|
|
|
|
|
|
|
|
|
auto raccoonShowcase = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
|
|
|
|
|
auto& renderableShowcase = *SHComponentManager::GetComponent_s<SHRenderable>(raccoonShowcase);
|
|
|
|
|
auto& transformShowcase = *SHComponentManager::GetComponent_s<SHTransformComponent>(raccoonShowcase);
|
|
|
|
|
|
|
|
|
|
renderableShowcase.SetMesh(handles.front());
|
|
|
|
|
renderableShowcase.SetMaterial(customMat);
|
|
|
|
|
renderableShowcase.SetMaterial(baseRaccoonMatInstant);
|
|
|
|
|
renderableShowcase.GetModifiableMaterial()->SetProperty("data.color", SHVec4(0.0f, 0.0f, 0.0f, 0.0f));
|
|
|
|
|
renderableShowcase.GetModifiableMaterial()->SetProperty("data.alpha", 1.0f);
|
|
|
|
|
renderableShowcase.GetModifiableMaterial()->SetProperty("data.textureIndex", 0);
|
|
|
|
|