Added a movable tree or somthing dunno lol tired-.
This commit is contained in:
+1
-1
Submodule assets updated: d5c5a86713...50ee6f805f
+42
-11
@@ -324,33 +324,64 @@ void GameWorld::Initialize()
|
|||||||
{
|
{
|
||||||
auto tree = CreateEntity();
|
auto tree = CreateEntity();
|
||||||
auto transform = AddComponent<Components::Transform>(tree);
|
auto transform = AddComponent<Components::Transform>(tree);
|
||||||
transform->Position = glm::vec3(0, -10, 0);
|
transform->Position = glm::vec3(0, 10, 0);
|
||||||
auto model = AddComponent<Components::Model>(tree);
|
|
||||||
model->ModelFile = "Models/Tree/Stem/Stem.obj";
|
|
||||||
auto physics = AddComponent<Components::Physics>(tree);
|
auto physics = AddComponent<Components::Physics>(tree);
|
||||||
physics->Mass = 100.f;
|
physics->Mass = 100.f;
|
||||||
physics->Static = false;
|
physics->Static = false;
|
||||||
|
//physics->LinearDamping = 3.f;
|
||||||
physics->CalculateCenterOfMass = true;
|
physics->CalculateCenterOfMass = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
auto leafs = CreateEntity(tree);
|
auto stem = CreateEntity(tree);
|
||||||
auto transform = AddComponent<Components::Transform>(leafs);
|
auto transform = AddComponent<Components::Transform>(stem);
|
||||||
auto model = AddComponent<Components::Model>(leafs);
|
transform->Position = glm::vec3(0, -2.40906f, 0);
|
||||||
model->ModelFile = "Models/Tree/Leafs/Leafs.obj";
|
auto model = AddComponent<Components::Model>(stem);
|
||||||
model->Transparent = true;
|
model->ModelFile = "Models/Tree/Stem/Stem.obj";
|
||||||
CommitEntity(leafs);
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto leafs = CreateEntity(tree);
|
||||||
|
auto transform = AddComponent<Components::Transform>(leafs);
|
||||||
|
transform->Position = glm::vec3(0, -2.45511f, 0);
|
||||||
|
auto model = AddComponent<Components::Model>(leafs);
|
||||||
|
model->ModelFile = "Models/Tree/Leafs/Leafs.obj";
|
||||||
|
model->Transparent = true;
|
||||||
|
CommitEntity(leafs);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
auto shape = CreateEntity(tree);
|
||||||
|
auto transform = AddComponent<Components::Transform>(shape);
|
||||||
|
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
||||||
|
auto mesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
mesh->ResourceName = "Models/Tree/Collision/Collision.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*{
|
||||||
auto shape = CreateEntity(tree);
|
auto shape = CreateEntity(tree);
|
||||||
auto transform = AddComponent<Components::Transform>(shape);
|
auto transform = AddComponent<Components::Transform>(shape);
|
||||||
auto box = AddComponent<Components::BoxShape>(shape);
|
auto box = AddComponent<Components::BoxShape>(shape);
|
||||||
transform->Position = glm::vec3(0.f, 0.f, 2.29552f);
|
transform->Position = glm::vec3(0.f, 0, 0.f);
|
||||||
box->Width = 0.296f;
|
box->Width = 0.296f;
|
||||||
box->Height = 2.511f;
|
box->Height = 2.511f;
|
||||||
box->Depth = 0.296f;
|
box->Depth = 0.296f;
|
||||||
|
|
||||||
CommitEntity(shape);
|
CommitEntity(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto shape = CreateEntity(tree);
|
||||||
|
auto transform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto sphere = AddComponent<Components::SphereShape>(shape);
|
||||||
|
transform->Position = glm::vec3(0, 2.04506f, 0.f);
|
||||||
|
sphere->Radius = 1.389f;
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
}*/
|
||||||
|
|
||||||
CommitEntity(tree);
|
CommitEntity(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ void Systems::PhysicsSystem::Initialize()
|
|||||||
worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY;
|
worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY;
|
||||||
|
|
||||||
// You must specify the size of the broad phase - objects should not be simulated outside this region
|
// You must specify the size of the broad phase - objects should not be simulated outside this region
|
||||||
worldInfo.setBroadPhaseWorldSize(1500.0f);
|
worldInfo.setBroadPhaseWorldSize(500.0f);
|
||||||
m_PhysicsWorld = new hkpWorld(worldInfo);
|
m_PhysicsWorld = new hkpWorld(worldInfo);
|
||||||
|
|
||||||
// When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks
|
// When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks
|
||||||
@@ -376,6 +376,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
rigidBodyInfo.m_inertiaTensor = massProperties.m_inertiaTensor;
|
rigidBodyInfo.m_inertiaTensor = massProperties.m_inertiaTensor;
|
||||||
if(physicsComponent->CalculateCenterOfMass)
|
if(physicsComponent->CalculateCenterOfMass)
|
||||||
physicsComponent->CenterOfMass = HKVECTOR4_TO_GLMVEC3(massProperties.m_centerOfMass);
|
physicsComponent->CenterOfMass = HKVECTOR4_TO_GLMVEC3(massProperties.m_centerOfMass);
|
||||||
|
|
||||||
rigidBodyInfo.m_centerOfMass = GLMVEC3_TO_HKVECTOR4(physicsComponent->CenterOfMass);
|
rigidBodyInfo.m_centerOfMass = GLMVEC3_TO_HKVECTOR4(physicsComponent->CenterOfMass);
|
||||||
rigidBodyInfo.m_mass = massProperties.m_mass;
|
rigidBodyInfo.m_mass = massProperties.m_mass;
|
||||||
rigidBodyInfo.m_linearVelocity = GLMVEC3_TO_HKVECTOR4(physicsComponent->InitialLinearVelocity);
|
rigidBodyInfo.m_linearVelocity = GLMVEC3_TO_HKVECTOR4(physicsComponent->InitialLinearVelocity);
|
||||||
@@ -389,7 +390,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
||||||
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
||||||
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
||||||
rigidBodyInfo.m_enableDeactivation = false;
|
rigidBodyInfo.m_enableDeactivation = true;;
|
||||||
}
|
}
|
||||||
// Create RigidBody
|
// Create RigidBody
|
||||||
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
||||||
@@ -521,7 +522,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
||||||
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
||||||
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
||||||
rigidBodyInfo.m_enableDeactivation = false;
|
rigidBodyInfo.m_enableDeactivation = true;
|
||||||
}
|
}
|
||||||
// Create RigidBody
|
// Create RigidBody
|
||||||
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
||||||
@@ -770,6 +771,7 @@ bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event )
|
|||||||
if(m_RigidBodies.find(event.Entity) != m_RigidBodies.end())
|
if(m_RigidBodies.find(event.Entity) != m_RigidBodies.end())
|
||||||
{
|
{
|
||||||
m_PhysicsWorld->markForWrite();
|
m_PhysicsWorld->markForWrite();
|
||||||
|
m_RigidBodies[event.Entity]->activate();
|
||||||
m_RigidBodies[event.Entity]->setLinearVelocity(GLMVEC3_TO_HKVECTOR4(event.Velocity));
|
m_RigidBodies[event.Entity]->setLinearVelocity(GLMVEC3_TO_HKVECTOR4(event.Velocity));
|
||||||
|
|
||||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user