JAMSPOOK-17 - Better collision shapes for level

- Track pieces exported to bcos formats.
- Textures updated.
- Updated code to match.
This commit is contained in:
Fredrick Amnehagen 2020-08-19 02:00:30 +02:00
parent 12218252a1
commit f5ce454a13
31 changed files with 91 additions and 51 deletions

BIN
assets/meshes/ball.bcosm Normal file

Binary file not shown.

BIN
assets/meshes/ball.bcosp Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/meshes/goal.bcosm Normal file

Binary file not shown.

BIN
assets/meshes/goal.bcosp Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/meshes/jump180.bcosm Normal file

Binary file not shown.

BIN
assets/meshes/jump180.bcosp Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 KiB

After

Width:  |  Height:  |  Size: 965 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

View File

@ -41,6 +41,9 @@ JamSpookGame::JamSpookGame():
// Create physics system // Create physics system
addSystem(make_shared<PhysicsSystem>()); addSystem(make_shared<PhysicsSystem>());
// Add physics related asset loaders
assetSystem->addLoader(make_shared<CollisionShapeLoader>(assetPath), "CollisionShapeLoader");
// Create animation system // Create animation system
addSystem(make_shared<AnimationSystem>()); addSystem(make_shared<AnimationSystem>());
@ -270,8 +273,8 @@ void JamSpookGame::set()
ballFactory->createBall(vec3(0, 3, 0), // position ballFactory->createBall(vec3(0, 3, 0), // position
1.0f, // size 1.0f, // size
1.0f*2, // size*2 10.0f, // size*2
1.0f, // restitution 0.1f, // restitution
"base", // ballName "base", // ballName
vec3(1,1,1)); // lightColor vec3(1,1,1)); // lightColor

View File

@ -30,6 +30,7 @@
#include <ecos/asset/AssetSystem.h> #include <ecos/asset/AssetSystem.h>
#include <ecos/asset/AssetFileSystem.h> #include <ecos/asset/AssetFileSystem.h>
#include <ecos/physics/PhysicsSystem.h> #include <ecos/physics/PhysicsSystem.h>
#include <ecos/physics/loaders/CollisionShapeLoader.h>
#include <ecos/animation/AnimationSystem.h> #include <ecos/animation/AnimationSystem.h>
#include <ecos/interaction/InteractionSystem.h> #include <ecos/interaction/InteractionSystem.h>
#include <ecos/graphics/GraphicsSystem.h> #include <ecos/graphics/GraphicsSystem.h>
@ -93,6 +94,8 @@ using ecos::utility::getIntInRange;
using ecos::asset::AssetSystem; using ecos::asset::AssetSystem;
using ecos::asset::AssetFileSystem; using ecos::asset::AssetFileSystem;
using ecos::physics::PhysicsSystem; using ecos::physics::PhysicsSystem;
using ecos::physics::CollisionShapeLoader;
using ecos::graphics::TextureBlankLoader;
using ecos::animation::AnimationSystem; using ecos::animation::AnimationSystem;
using ecos::interaction::InteractionSystem; using ecos::interaction::InteractionSystem;
using ecos::interaction::InputDeviceState; using ecos::interaction::InputDeviceState;

View File

@ -36,7 +36,7 @@ shared_ptr<Entity> BallFactory::createBall(const vec3 position,
mat4 transform = translate(mat4(1), position); mat4 transform = translate(mat4(1), position);
// Add physics component // Add physics component
ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem); ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem, mAssetSystem);
shared_ptr<BallPhysicsComponent> physicsComponent = shared_ptr<BallPhysicsComponent> physicsComponent =
make_shared<BallPhysicsComponent>( make_shared<BallPhysicsComponent>(
transform, transform,
@ -55,6 +55,9 @@ shared_ptr<Entity> BallFactory::createBall(const vec3 position,
physicsComponent->getCollider()->getRigidBody()->setLinearFactor(btVector3(1,1,1)); // allow all positional movement movement physicsComponent->getCollider()->getRigidBody()->setLinearFactor(btVector3(1,1,1)); // allow all positional movement movement
physicsComponent->getCollider()->getRigidBody()->setAngularFactor(btVector3(1,1,1)); // allow all rotational movement movement physicsComponent->getCollider()->getRigidBody()->setAngularFactor(btVector3(1,1,1)); // allow all rotational movement movement
physicsComponent->getCollider()->getRigidBody()->setRestitution(restitution); physicsComponent->getCollider()->getRigidBody()->setRestitution(restitution);
// physicsComponent->getCollider()->getRigidBody()->setGravity(btVector3(0,-1,0)); // no gravity, length of zero
physicsComponent->getCollider()->getRigidBody()->setActivationState(DISABLE_DEACTIVATION); // RigidBody may never sleep. (Note: Or else it will not respond to setLinearVelocity when standing still for too long(a couple of seconds).)
entity->addComponent(physicsComponent); entity->addComponent(physicsComponent);
// Add graphics component // Add graphics component
@ -67,7 +70,7 @@ shared_ptr<Entity> BallFactory::createBall(const vec3 position,
// Add the ModelRenderable of a ball // Add the ModelRenderable of a ball
ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem);
shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("ball.f3d", shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("ball.bcosm",
name + "-ball.png", name + "-ball.png",
name + "-model"); name + "-model");
delete modelFactory; delete modelFactory;

View File

@ -13,6 +13,7 @@
#include <memory> #include <memory>
#include <functional> #include <functional>
#include <vector> #include <vector>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
@ -60,10 +61,12 @@ using std::dynamic_pointer_cast;
using std::function; using std::function;
using std::bind; using std::bind;
using std::vector; using std::vector;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::quat; using glm::quat;
using glm::translate; using glm::translate;
using ecos::utility::getShared; using ecos::utility::getShared;
using ecos::core::IDCache; using ecos::core::IDCache;
using ecos::core::logging::Log; using ecos::core::logging::Log;
@ -97,6 +100,7 @@ using ecos::physics::PhysicsComponent;
using ecos::physics::ColliderFactory; using ecos::physics::ColliderFactory;
using ecos::physics::Collider; using ecos::physics::Collider;
///
class BallFactory class BallFactory
{ {
private: private:

View File

@ -12,6 +12,7 @@
#include <memory> #include <memory>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
@ -35,10 +36,12 @@ using std::shared_ptr;
using std::make_shared; using std::make_shared;
using std::dynamic_pointer_cast; using std::dynamic_pointer_cast;
using std::string; using std::string;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::translate; using glm::translate;
using glm::scale; using glm::scale;
using ecos::utility::getFloatInRange; using ecos::utility::getFloatInRange;
using ecos::core::IDCache; using ecos::core::IDCache;
using ecos::core::logging::Log; using ecos::core::logging::Log;
@ -52,6 +55,7 @@ using ecos::physics::TransformChangeMessage;
using ecos::physics::CollisionStateChangeMessage; using ecos::physics::CollisionStateChangeMessage;
using ecos::physics::ColliderQueryMessage; using ecos::physics::ColliderQueryMessage;
///
class BallPhysicsComponent: class BallPhysicsComponent:
public ecos::physics::PhysicsComponent public ecos::physics::PhysicsComponent
{ {

View File

@ -39,7 +39,7 @@ shared_ptr<Entity> BoxFactory::createBox(const vec3 position,
// Add the ModelRenderable of a ball // Add the ModelRenderable of a ball
ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem);
shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("box-1x1x1.f3d", shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("box-1x1x1.bcosm",
"box-1x1x1-albedo.png", "box-1x1x1-albedo.png",
"box-1x1x1-model"); "box-1x1x1-model");
delete modelFactory; delete modelFactory;

View File

@ -13,6 +13,7 @@
#include <memory> #include <memory>
#include <functional> #include <functional>
#include <vector> #include <vector>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
@ -58,10 +59,12 @@ using std::dynamic_pointer_cast;
using std::function; using std::function;
using std::bind; using std::bind;
using std::vector; using std::vector;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::quat; using glm::quat;
using glm::translate; using glm::translate;
using ecos::utility::getShared; using ecos::utility::getShared;
using ecos::core::IDCache; using ecos::core::IDCache;
using ecos::core::logging::Log; using ecos::core::logging::Log;
@ -91,6 +94,7 @@ using ecos::graphics::ModelRenderable;
using ecos::graphics::lighting::LightSource; using ecos::graphics::lighting::LightSource;
using ecos::graphics::lighting::LightSourceFactory; using ecos::graphics::lighting::LightSourceFactory;
///
class BoxFactory class BoxFactory
{ {
private: private:

View File

@ -31,7 +31,7 @@ shared_ptr<Entity> GoalFactory::createGoal(const vec3 position)
mat4 transform = translate(mat4(1), position); mat4 transform = translate(mat4(1), position);
// Add physics component // Add physics component
ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem); ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem, mAssetSystem);
shared_ptr<GoalPhysicsComponent> physicsComponent = shared_ptr<GoalPhysicsComponent> physicsComponent =
make_shared<GoalPhysicsComponent>( make_shared<GoalPhysicsComponent>(
transform, transform,
@ -39,9 +39,10 @@ shared_ptr<Entity> GoalFactory::createGoal(const vec3 position)
getShared(mPhysicsSystem), getShared(mPhysicsSystem),
getShared(mPhysicsSystem), getShared(mPhysicsSystem),
getShared(mPhysicsSystem), getShared(mPhysicsSystem),
colliderFactory->createBoxCollider(position, colliderFactory->createConvexHullCollider(position,
quat(vec3(0,0,0)), quat(vec3(0,0,0)),
vec3(10,1,10), // radius "goal.bcosp", // filePath
"goal-shape", // name
100.0f, // mass 100.0f, // mass
entity, entity,
entity->getEntityTag())); entity->getEntityTag()));
@ -59,9 +60,9 @@ shared_ptr<Entity> GoalFactory::createGoal(const vec3 position)
mRenderLayer); mRenderLayer);
entity->addComponent(graphicsComponent); entity->addComponent(graphicsComponent);
// Add the ModelRenderable of a ball // Add the ModelRenderable
ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem);
shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("goal.f3d", shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("goal.bcosm",
"goal.png", "goal.png",
"goal-model"); "goal-model");
delete modelFactory; delete modelFactory;

View File

@ -12,6 +12,7 @@
#include <memory> #include <memory>
#include <functional> #include <functional>
#include <vector> #include <vector>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/string_cast.hpp> #include <glm/gtx/string_cast.hpp>
@ -58,9 +59,11 @@ using std::dynamic_pointer_cast;
using std::function; using std::function;
using std::bind; using std::bind;
using std::vector; using std::vector;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::quat; using glm::quat;
using glm::quat_cast;
using glm::translate; using glm::translate;
using glm::scale; using glm::scale;
@ -95,7 +98,7 @@ using ecos::physics::PhysicsComponent;
using ecos::physics::ColliderFactory; using ecos::physics::ColliderFactory;
using ecos::physics::Collider; using ecos::physics::Collider;
/// Factory to simplify jump180 entity creation /// Factory to simplify goal entity creation
class GoalFactory class GoalFactory
{ {
private: private:

View File

@ -34,6 +34,7 @@ using std::shared_ptr;
using std::make_shared; using std::make_shared;
using std::dynamic_pointer_cast; using std::dynamic_pointer_cast;
using std::string; using std::string;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::translate; using glm::translate;
@ -51,6 +52,7 @@ using ecos::physics::TransformChangeMessage;
using ecos::physics::CollisionStateChangeMessage; using ecos::physics::CollisionStateChangeMessage;
using ecos::physics::ColliderQueryMessage; using ecos::physics::ColliderQueryMessage;
///
class GoalPhysicsComponent: class GoalPhysicsComponent:
public PhysicsComponent public PhysicsComponent
{ {

View File

@ -48,7 +48,7 @@ shared_ptr<Entity> Jump180Factory::createJump180(const vec3 position,
// mat4 transform = translate(mat4(1), position); // mat4 transform = translate(mat4(1), position);
// Add physics component // Add physics component
ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem); ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem, mAssetSystem);
shared_ptr<Jump180PhysicsComponent> physicsComponent = shared_ptr<Jump180PhysicsComponent> physicsComponent =
make_shared<Jump180PhysicsComponent>( make_shared<Jump180PhysicsComponent>(
transform, transform,
@ -56,9 +56,10 @@ shared_ptr<Entity> Jump180Factory::createJump180(const vec3 position,
getShared(mPhysicsSystem), getShared(mPhysicsSystem),
getShared(mPhysicsSystem), getShared(mPhysicsSystem),
getShared(mPhysicsSystem), getShared(mPhysicsSystem),
colliderFactory->createBoxCollider(position, colliderFactory->createConvexHullCollider(position,
quat_cast(rotation), quat_cast(rotation),
vec3(10,1,10), // radius "jump180.bcosp", // filePath
"jump180-shape", // name
100.0f, // mass 100.0f, // mass
entity, entity,
entity->getEntityTag())); entity->getEntityTag()));
@ -78,7 +79,7 @@ shared_ptr<Entity> Jump180Factory::createJump180(const vec3 position,
// Add the ModelRenderable of a ball // Add the ModelRenderable of a ball
ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem);
shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("jump180.f3d", shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("jump180.bcosm",
"jump180.png", "jump180.png",
"jump180-model"); "jump180-model");
delete modelFactory; delete modelFactory;

View File

@ -12,6 +12,7 @@
#include <memory> #include <memory>
#include <functional> #include <functional>
#include <vector> #include <vector>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/euler_angles.hpp> #include <glm/gtx/euler_angles.hpp>
@ -59,9 +60,11 @@ using std::dynamic_pointer_cast;
using std::function; using std::function;
using std::bind; using std::bind;
using std::vector; using std::vector;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::quat; using glm::quat;
using glm::quat_cast;
using glm::translate; using glm::translate;
using glm::scale; using glm::scale;
using glm::rotate; using glm::rotate;

View File

@ -12,6 +12,7 @@
#include <memory> #include <memory>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
@ -34,6 +35,7 @@ using std::shared_ptr;
using std::make_shared; using std::make_shared;
using std::dynamic_pointer_cast; using std::dynamic_pointer_cast;
using std::string; using std::string;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::translate; using glm::translate;
@ -51,6 +53,7 @@ using ecos::physics::TransformChangeMessage;
using ecos::physics::CollisionStateChangeMessage; using ecos::physics::CollisionStateChangeMessage;
using ecos::physics::ColliderQueryMessage; using ecos::physics::ColliderQueryMessage;
///
class Jump180PhysicsComponent: class Jump180PhysicsComponent:
public PhysicsComponent public PhysicsComponent
{ {

View File

@ -33,6 +33,7 @@ using std::shared_ptr;
using std::make_shared; using std::make_shared;
using std::weak_ptr; using std::weak_ptr;
using std::dynamic_pointer_cast; using std::dynamic_pointer_cast;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::translate; using glm::translate;

View File

@ -12,6 +12,7 @@
#include <memory> #include <memory>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
@ -37,6 +38,7 @@ using std::shared_ptr;
using std::make_shared; using std::make_shared;
using std::dynamic_pointer_cast; using std::dynamic_pointer_cast;
using std::string; using std::string;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::translate; using glm::translate;

View File

@ -13,6 +13,7 @@
#include <memory> #include <memory>
#include <functional> #include <functional>
#include <vector> #include <vector>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/euler_angles.hpp> #include <glm/gtx/euler_angles.hpp>
@ -64,6 +65,7 @@ using std::dynamic_pointer_cast;
using std::function; using std::function;
using std::bind; using std::bind;
using std::vector; using std::vector;
using glm::vec3; using glm::vec3;
using glm::mat4; using glm::mat4;
using glm::quat; using glm::quat;
@ -108,6 +110,7 @@ using ecos::interaction::InteractionSystem;
using ecos::interaction::InputDeviceState; using ecos::interaction::InputDeviceState;
using ecos::interaction::InteractionComponent; using ecos::interaction::InteractionComponent;
///
class LightingFactory class LightingFactory
{ {
private: private: