diff --git a/assets/meshes/ball.bcosm b/assets/meshes/ball.bcosm new file mode 100644 index 0000000..f23089b Binary files /dev/null and b/assets/meshes/ball.bcosm differ diff --git a/assets/meshes/ball.bcosp b/assets/meshes/ball.bcosp new file mode 100644 index 0000000..66f46c6 Binary files /dev/null and b/assets/meshes/ball.bcosp differ diff --git a/assets/meshes/export-to-bcos_b280.bcosm b/assets/meshes/export-to-bcos_b280.bcosm new file mode 100644 index 0000000..512ac82 Binary files /dev/null and b/assets/meshes/export-to-bcos_b280.bcosm differ diff --git a/assets/meshes/export-to-bcos_b280.bcosp b/assets/meshes/export-to-bcos_b280.bcosp new file mode 100644 index 0000000..3a2977c Binary files /dev/null and b/assets/meshes/export-to-bcos_b280.bcosp differ diff --git a/assets/meshes/export-to-f3d_b280.blend b/assets/meshes/export-to-f3d_b280.blend index 28b45a7..ba5810e 100644 Binary files a/assets/meshes/export-to-f3d_b280.blend and b/assets/meshes/export-to-f3d_b280.blend differ diff --git a/assets/meshes/goal.bcosm b/assets/meshes/goal.bcosm new file mode 100644 index 0000000..20474a8 Binary files /dev/null and b/assets/meshes/goal.bcosm differ diff --git a/assets/meshes/goal.bcosp b/assets/meshes/goal.bcosp new file mode 100644 index 0000000..0746827 Binary files /dev/null and b/assets/meshes/goal.bcosp differ diff --git a/assets/meshes/goal_b270.blend b/assets/meshes/goal_b270.blend index 059c42a..05304eb 100644 Binary files a/assets/meshes/goal_b270.blend and b/assets/meshes/goal_b270.blend differ diff --git a/assets/meshes/goal_b270.blend1 b/assets/meshes/goal_b270.blend1 index d7e5090..059c42a 100644 Binary files a/assets/meshes/goal_b270.blend1 and b/assets/meshes/goal_b270.blend1 differ diff --git a/assets/meshes/jump180.bcosm b/assets/meshes/jump180.bcosm new file mode 100644 index 0000000..7addb39 Binary files /dev/null and b/assets/meshes/jump180.bcosm differ diff --git a/assets/meshes/jump180.bcosp b/assets/meshes/jump180.bcosp new file mode 100644 index 0000000..d898999 Binary files /dev/null and b/assets/meshes/jump180.bcosp differ diff --git a/assets/textures/goal.png b/assets/textures/goal.png index be66f78..91b679e 100644 Binary files a/assets/textures/goal.png and b/assets/textures/goal.png differ diff --git a/assets/textures/goal.xcf b/assets/textures/goal.xcf index e8d66f3..709b600 100644 Binary files a/assets/textures/goal.xcf and b/assets/textures/goal.xcf differ diff --git a/assets/textures/jump180.png b/assets/textures/jump180.png index 025f3ce..d64dcce 100644 Binary files a/assets/textures/jump180.png and b/assets/textures/jump180.png differ diff --git a/assets/textures/jump180.xcf b/assets/textures/jump180.xcf index 220fb39..06e1e3a 100644 Binary files a/assets/textures/jump180.xcf and b/assets/textures/jump180.xcf differ diff --git a/src/JamSpookGame.cpp b/src/JamSpookGame.cpp index 0dfb081..02020c0 100644 --- a/src/JamSpookGame.cpp +++ b/src/JamSpookGame.cpp @@ -41,6 +41,9 @@ JamSpookGame::JamSpookGame(): // Create physics system addSystem(make_shared()); + // Add physics related asset loaders + assetSystem->addLoader(make_shared(assetPath), "CollisionShapeLoader"); + // Create animation system addSystem(make_shared()); @@ -270,8 +273,8 @@ void JamSpookGame::set() ballFactory->createBall(vec3(0, 3, 0), // position 1.0f, // size - 1.0f*2, // size*2 - 1.0f, // restitution + 10.0f, // size*2 + 0.1f, // restitution "base", // ballName vec3(1,1,1)); // lightColor diff --git a/src/JamSpookGame.h b/src/JamSpookGame.h index af3ade8..8c76359 100644 --- a/src/JamSpookGame.h +++ b/src/JamSpookGame.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -93,6 +94,8 @@ using ecos::utility::getIntInRange; using ecos::asset::AssetSystem; using ecos::asset::AssetFileSystem; using ecos::physics::PhysicsSystem; +using ecos::physics::CollisionShapeLoader; +using ecos::graphics::TextureBlankLoader; using ecos::animation::AnimationSystem; using ecos::interaction::InteractionSystem; using ecos::interaction::InputDeviceState; diff --git a/src/entities/BallFactory.cpp b/src/entities/BallFactory.cpp index cc87e8a..54720e0 100644 --- a/src/entities/BallFactory.cpp +++ b/src/entities/BallFactory.cpp @@ -36,7 +36,7 @@ shared_ptr BallFactory::createBall(const vec3 position, mat4 transform = translate(mat4(1), position); // Add physics component - ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem); + ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem, mAssetSystem); shared_ptr physicsComponent = make_shared( transform, @@ -55,6 +55,9 @@ shared_ptr BallFactory::createBall(const vec3 position, 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()->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); // Add graphics component @@ -67,7 +70,7 @@ shared_ptr BallFactory::createBall(const vec3 position, // Add the ModelRenderable of a ball ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); - shared_ptr modelRenderable = modelFactory->createModel("ball.f3d", + shared_ptr modelRenderable = modelFactory->createModel("ball.bcosm", name + "-ball.png", name + "-model"); delete modelFactory; diff --git a/src/entities/BallFactory.h b/src/entities/BallFactory.h index fbdc88d..7743400 100644 --- a/src/entities/BallFactory.h +++ b/src/entities/BallFactory.h @@ -13,6 +13,7 @@ #include #include #include + #include #include @@ -60,10 +61,12 @@ using std::dynamic_pointer_cast; using std::function; using std::bind; using std::vector; + using glm::vec3; using glm::mat4; using glm::quat; using glm::translate; + using ecos::utility::getShared; using ecos::core::IDCache; using ecos::core::logging::Log; @@ -97,19 +100,20 @@ using ecos::physics::PhysicsComponent; using ecos::physics::ColliderFactory; using ecos::physics::Collider; +/// class BallFactory { private: - weak_ptr mAssetSystem; + weak_ptr mAssetSystem; weak_ptr mGraphicsSystem; - weak_ptr mPhysicsSystem; - weak_ptr mRenderLayer; + weak_ptr mPhysicsSystem; + weak_ptr mRenderLayer; public: - BallFactory(weak_ptr assetSystem, + BallFactory(weak_ptr assetSystem, weak_ptr graphicsSystem, - weak_ptr physicsSystem, - weak_ptr renderLayer); + weak_ptr physicsSystem, + weak_ptr renderLayer); virtual ~BallFactory(); shared_ptr createBall(const vec3 position, diff --git a/src/entities/BallPhysicsComponent.h b/src/entities/BallPhysicsComponent.h index 6ff1879..615e5bf 100644 --- a/src/entities/BallPhysicsComponent.h +++ b/src/entities/BallPhysicsComponent.h @@ -12,6 +12,7 @@ #include #include #include + #include #include @@ -35,10 +36,12 @@ using std::shared_ptr; using std::make_shared; using std::dynamic_pointer_cast; using std::string; + using glm::vec3; using glm::mat4; using glm::translate; using glm::scale; + using ecos::utility::getFloatInRange; using ecos::core::IDCache; using ecos::core::logging::Log; @@ -52,6 +55,7 @@ using ecos::physics::TransformChangeMessage; using ecos::physics::CollisionStateChangeMessage; using ecos::physics::ColliderQueryMessage; +/// class BallPhysicsComponent: public ecos::physics::PhysicsComponent { diff --git a/src/entities/BoxFactory.cpp b/src/entities/BoxFactory.cpp index 2615b48..919b1bc 100644 --- a/src/entities/BoxFactory.cpp +++ b/src/entities/BoxFactory.cpp @@ -39,7 +39,7 @@ shared_ptr BoxFactory::createBox(const vec3 position, // Add the ModelRenderable of a ball ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); - shared_ptr modelRenderable = modelFactory->createModel("box-1x1x1.f3d", + shared_ptr modelRenderable = modelFactory->createModel("box-1x1x1.bcosm", "box-1x1x1-albedo.png", "box-1x1x1-model"); delete modelFactory; diff --git a/src/entities/BoxFactory.h b/src/entities/BoxFactory.h index c13c54e..7a7f604 100644 --- a/src/entities/BoxFactory.h +++ b/src/entities/BoxFactory.h @@ -13,6 +13,7 @@ #include #include #include + #include #include @@ -58,10 +59,12 @@ using std::dynamic_pointer_cast; using std::function; using std::bind; using std::vector; + using glm::vec3; using glm::mat4; using glm::quat; using glm::translate; + using ecos::utility::getShared; using ecos::core::IDCache; using ecos::core::logging::Log; @@ -91,17 +94,18 @@ using ecos::graphics::ModelRenderable; using ecos::graphics::lighting::LightSource; using ecos::graphics::lighting::LightSourceFactory; +/// class BoxFactory { private: - weak_ptr mAssetSystem; + weak_ptr mAssetSystem; weak_ptr mGraphicsSystem; - weak_ptr mRenderLayer; + weak_ptr mRenderLayer; public: - BoxFactory(weak_ptr assetSystem, + BoxFactory(weak_ptr assetSystem, weak_ptr graphicsSystem, - weak_ptr renderLayer); + weak_ptr renderLayer); virtual ~BoxFactory(); shared_ptr createBox(const vec3 position, diff --git a/src/entities/GoalFactory.cpp b/src/entities/GoalFactory.cpp index 2ed5e9c..155f10d 100644 --- a/src/entities/GoalFactory.cpp +++ b/src/entities/GoalFactory.cpp @@ -9,10 +9,10 @@ namespace JamSpook { -GoalFactory::GoalFactory(weak_ptr assetSystem, +GoalFactory::GoalFactory(weak_ptr assetSystem, weak_ptr graphicsSystem, - weak_ptr physicsSystem, - weak_ptr renderLayer): + weak_ptr physicsSystem, + weak_ptr renderLayer): mAssetSystem(assetSystem), mGraphicsSystem(graphicsSystem), mPhysicsSystem(physicsSystem), @@ -31,7 +31,7 @@ shared_ptr GoalFactory::createGoal(const vec3 position) mat4 transform = translate(mat4(1), position); // Add physics component - ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem); + ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem, mAssetSystem); shared_ptr physicsComponent = make_shared( transform, @@ -39,12 +39,13 @@ shared_ptr GoalFactory::createGoal(const vec3 position) getShared(mPhysicsSystem), getShared(mPhysicsSystem), getShared(mPhysicsSystem), - colliderFactory->createBoxCollider(position, - quat(vec3(0,0,0)), - vec3(10,1,10), // radius - 100.0f, // mass - entity, - entity->getEntityTag())); + colliderFactory->createConvexHullCollider(position, + quat(vec3(0,0,0)), + "goal.bcosp", // filePath + "goal-shape", // name + 100.0f, // mass + entity, + entity->getEntityTag())); delete colliderFactory; // Note: Editing of rigid body params, maybe only has effect is it has been added to the world. physicsComponent->getCollider()->getRigidBody()->setLinearFactor(btVector3(0, 0, 0)); // deny positional movement movement in any axis @@ -59,9 +60,9 @@ shared_ptr GoalFactory::createGoal(const vec3 position) mRenderLayer); entity->addComponent(graphicsComponent); - // Add the ModelRenderable of a ball + // Add the ModelRenderable ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); - shared_ptr modelRenderable = modelFactory->createModel("goal.f3d", + shared_ptr modelRenderable = modelFactory->createModel("goal.bcosm", "goal.png", "goal-model"); delete modelFactory; diff --git a/src/entities/GoalFactory.h b/src/entities/GoalFactory.h index 15c823c..dfe48fe 100644 --- a/src/entities/GoalFactory.h +++ b/src/entities/GoalFactory.h @@ -12,6 +12,7 @@ #include #include #include + #include #include #include @@ -58,9 +59,11 @@ using std::dynamic_pointer_cast; using std::function; using std::bind; using std::vector; + using glm::vec3; using glm::mat4; using glm::quat; +using glm::quat_cast; using glm::translate; using glm::scale; @@ -95,20 +98,20 @@ using ecos::physics::PhysicsComponent; using ecos::physics::ColliderFactory; using ecos::physics::Collider; -/// Factory to simplify jump180 entity creation +/// Factory to simplify goal entity creation class GoalFactory { private: - weak_ptr mAssetSystem; + weak_ptr mAssetSystem; weak_ptr mGraphicsSystem; - weak_ptr mPhysicsSystem; - weak_ptr mRenderLayer; + weak_ptr mPhysicsSystem; + weak_ptr mRenderLayer; public: - GoalFactory(weak_ptr assetSystem, + GoalFactory(weak_ptr assetSystem, weak_ptr graphicsSystem, - weak_ptr physicsSystem, - weak_ptr renderLayer); + weak_ptr physicsSystem, + weak_ptr renderLayer); virtual ~GoalFactory(); /// Compose a jump180 entity diff --git a/src/entities/GoalPhysicsComponent.h b/src/entities/GoalPhysicsComponent.h index b9415c3..2843df6 100644 --- a/src/entities/GoalPhysicsComponent.h +++ b/src/entities/GoalPhysicsComponent.h @@ -34,6 +34,7 @@ using std::shared_ptr; using std::make_shared; using std::dynamic_pointer_cast; using std::string; + using glm::vec3; using glm::mat4; using glm::translate; @@ -51,6 +52,7 @@ using ecos::physics::TransformChangeMessage; using ecos::physics::CollisionStateChangeMessage; using ecos::physics::ColliderQueryMessage; +/// class GoalPhysicsComponent: public PhysicsComponent { diff --git a/src/entities/Jump180Factory.cpp b/src/entities/Jump180Factory.cpp index 9540732..3f9c835 100644 --- a/src/entities/Jump180Factory.cpp +++ b/src/entities/Jump180Factory.cpp @@ -9,10 +9,10 @@ namespace JamSpook { -Jump180Factory::Jump180Factory(weak_ptr assetSystem, +Jump180Factory::Jump180Factory(weak_ptr assetSystem, weak_ptr graphicsSystem, - weak_ptr physicsSystem, - weak_ptr renderLayer): + weak_ptr physicsSystem, + weak_ptr renderLayer): mAssetSystem(assetSystem), mGraphicsSystem(graphicsSystem), mPhysicsSystem(physicsSystem), @@ -48,7 +48,7 @@ shared_ptr Jump180Factory::createJump180(const vec3 position, // mat4 transform = translate(mat4(1), position); // Add physics component - ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem); + ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem, mAssetSystem); shared_ptr physicsComponent = make_shared( transform, @@ -56,12 +56,13 @@ shared_ptr Jump180Factory::createJump180(const vec3 position, getShared(mPhysicsSystem), getShared(mPhysicsSystem), getShared(mPhysicsSystem), - colliderFactory->createBoxCollider(position, - quat_cast(rotation), - vec3(10,1,10), // radius - 100.0f, // mass - entity, - entity->getEntityTag())); + colliderFactory->createConvexHullCollider(position, + quat_cast(rotation), + "jump180.bcosp", // filePath + "jump180-shape", // name + 100.0f, // mass + entity, + entity->getEntityTag())); delete colliderFactory; // Note: Editing of rigid body params, maybe only has effect is it has been added to the world. physicsComponent->getCollider()->getRigidBody()->setLinearFactor(btVector3(0, 0, 0)); // deny positional movement movement in any axis @@ -78,7 +79,7 @@ shared_ptr Jump180Factory::createJump180(const vec3 position, // Add the ModelRenderable of a ball ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem); - shared_ptr modelRenderable = modelFactory->createModel("jump180.f3d", + shared_ptr modelRenderable = modelFactory->createModel("jump180.bcosm", "jump180.png", "jump180-model"); delete modelFactory; diff --git a/src/entities/Jump180Factory.h b/src/entities/Jump180Factory.h index 394b3d6..bfe7ed6 100644 --- a/src/entities/Jump180Factory.h +++ b/src/entities/Jump180Factory.h @@ -12,6 +12,7 @@ #include #include #include + #include #include #include @@ -59,9 +60,11 @@ using std::dynamic_pointer_cast; using std::function; using std::bind; using std::vector; + using glm::vec3; using glm::mat4; using glm::quat; +using glm::quat_cast; using glm::translate; using glm::scale; using glm::rotate; @@ -103,16 +106,16 @@ using ecos::physics::Collider; class Jump180Factory { private: - weak_ptr mAssetSystem; + weak_ptr mAssetSystem; weak_ptr mGraphicsSystem; - weak_ptr mPhysicsSystem; - weak_ptr mRenderLayer; + weak_ptr mPhysicsSystem; + weak_ptr mRenderLayer; public: - Jump180Factory(weak_ptr assetSystem, + Jump180Factory(weak_ptr assetSystem, weak_ptr graphicsSystem, - weak_ptr physicsSystem, - weak_ptr renderLayer); + weak_ptr physicsSystem, + weak_ptr renderLayer); virtual ~Jump180Factory(); /// Compose a jump180 entity diff --git a/src/entities/Jump180PhysicsComponent.h b/src/entities/Jump180PhysicsComponent.h index 314a1ee..d12958d 100644 --- a/src/entities/Jump180PhysicsComponent.h +++ b/src/entities/Jump180PhysicsComponent.h @@ -12,6 +12,7 @@ #include #include #include + #include #include @@ -34,6 +35,7 @@ using std::shared_ptr; using std::make_shared; using std::dynamic_pointer_cast; using std::string; + using glm::vec3; using glm::mat4; using glm::translate; @@ -51,6 +53,7 @@ using ecos::physics::TransformChangeMessage; using ecos::physics::CollisionStateChangeMessage; using ecos::physics::ColliderQueryMessage; +/// class Jump180PhysicsComponent: public PhysicsComponent { diff --git a/src/entities/LightInteractionComponent.h b/src/entities/LightInteractionComponent.h index 9cb5026..a82e7ef 100755 --- a/src/entities/LightInteractionComponent.h +++ b/src/entities/LightInteractionComponent.h @@ -33,6 +33,7 @@ using std::shared_ptr; using std::make_shared; using std::weak_ptr; using std::dynamic_pointer_cast; + using glm::vec3; using glm::mat4; using glm::translate; diff --git a/src/entities/LightPhysicsComponent.h b/src/entities/LightPhysicsComponent.h index 1b89406..1b8ce37 100644 --- a/src/entities/LightPhysicsComponent.h +++ b/src/entities/LightPhysicsComponent.h @@ -12,6 +12,7 @@ #include #include #include + #include #include @@ -37,6 +38,7 @@ using std::shared_ptr; using std::make_shared; using std::dynamic_pointer_cast; using std::string; + using glm::vec3; using glm::mat4; using glm::translate; diff --git a/src/entities/LightingFactory.h b/src/entities/LightingFactory.h index 4f44011..2bc0a5c 100644 --- a/src/entities/LightingFactory.h +++ b/src/entities/LightingFactory.h @@ -13,6 +13,7 @@ #include #include #include + #include #include #include @@ -64,6 +65,7 @@ using std::dynamic_pointer_cast; using std::function; using std::bind; using std::vector; + using glm::vec3; using glm::mat4; using glm::quat; @@ -108,6 +110,7 @@ using ecos::interaction::InteractionSystem; using ecos::interaction::InputDeviceState; using ecos::interaction::InteractionComponent; +/// class LightingFactory { private: