JAMSPOOK-27 - Added ghosts
This commit is contained in:
parent
e55db1dd14
commit
bf46723715
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
|
@ -41,7 +41,8 @@ JamSpookGame::JamSpookGame():
|
||||||
addSystem(make_shared<PhysicsSystem>());
|
addSystem(make_shared<PhysicsSystem>());
|
||||||
|
|
||||||
// Add physics related asset loaders
|
// Add physics related asset loaders
|
||||||
assetSystem->addLoader(make_shared<CollisionShapeLoader>(assetPath), "CollisionShapeLoader");
|
assetSystem->addLoader(make_shared<CollisionShapeLoader>(assetPath), "CollisionShapeLoader");
|
||||||
|
assetSystem->addLoader(make_shared<StaticCollisionShapeLoader>(assetPath), "StaticCollisionShapeLoader");
|
||||||
|
|
||||||
// Create animation system
|
// Create animation system
|
||||||
addSystem(make_shared<AnimationSystem>());
|
addSystem(make_shared<AnimationSystem>());
|
||||||
|
@ -66,11 +67,11 @@ JamSpookGame::JamSpookGame():
|
||||||
addSystem(make_shared<DevILSystem>());
|
addSystem(make_shared<DevILSystem>());
|
||||||
|
|
||||||
// Add graphics related asset loaders
|
// Add graphics related asset loaders
|
||||||
assetSystem->addLoader(make_shared<MeshLoader>(assetPath), "MeshLoader");
|
assetSystem->addLoader(make_shared<MeshLoader>(assetPath), "MeshLoader");
|
||||||
assetSystem->addLoader(make_shared<ShaderLoader>(assetPath), "ShaderLoader");
|
assetSystem->addLoader(make_shared<ShaderLoader>(assetPath), "ShaderLoader");
|
||||||
assetSystem->addLoader(make_shared<ShaderProgramLoader>(assetPath), "ShaderProgramLoader");
|
assetSystem->addLoader(make_shared<ShaderProgramLoader>(assetPath), "ShaderProgramLoader");
|
||||||
assetSystem->addLoader(make_shared<TextureFileLoader>(assetPath), "TextureFileLoader");
|
assetSystem->addLoader(make_shared<TextureFileLoader>(assetPath), "TextureFileLoader");
|
||||||
assetSystem->addLoader(make_shared<TextureBlankLoader>(assetPath), "TextureBlankLoader");
|
assetSystem->addLoader(make_shared<TextureBlankLoader>(assetPath), "TextureBlankLoader");
|
||||||
|
|
||||||
// Add render layer compositor shader
|
// Add render layer compositor shader
|
||||||
ShaderProgramFactory* shaderProgramFactory = new ShaderProgramFactory(assetSystem);
|
ShaderProgramFactory* shaderProgramFactory = new ShaderProgramFactory(assetSystem);
|
||||||
|
@ -200,9 +201,9 @@ void JamSpookGame::set()
|
||||||
dynamic_pointer_cast<InteractionSystem>(findSystem(IDCache::get("InteractionSystem"))));
|
dynamic_pointer_cast<InteractionSystem>(findSystem(IDCache::get("InteractionSystem"))));
|
||||||
|
|
||||||
lightingFactory->createSun(10.0f,
|
lightingFactory->createSun(10.0f,
|
||||||
vec3(0,0,0),
|
vec3(45,-45,0),
|
||||||
vec3(1,1,1),
|
vec3(1,1,1),
|
||||||
0.1f,
|
0.5f,
|
||||||
renderLayerGame);
|
renderLayerGame);
|
||||||
|
|
||||||
lightingFactory.reset();
|
lightingFactory.reset();
|
||||||
|
@ -234,8 +235,8 @@ void JamSpookGame::set()
|
||||||
dynamic_pointer_cast<PhysicsSystem>(findSystem(IDCache::get("PhysicsSystem"))),
|
dynamic_pointer_cast<PhysicsSystem>(findSystem(IDCache::get("PhysicsSystem"))),
|
||||||
renderLayerGame);
|
renderLayerGame);
|
||||||
|
|
||||||
jump180Factory->createJump180(vec3(0, 0, 0), vec3(0, 0, 0));
|
jump180Factory->createJump180(vec3(0, -1, 0), vec3(0, 0, 0));
|
||||||
jump180Factory->createJump180(vec3(25,-15, 14), vec3(0, 180, 0));
|
jump180Factory->createJump180(vec3(25,-16, 14), vec3(0, 180, 0));
|
||||||
|
|
||||||
jump180Factory.reset();
|
jump180Factory.reset();
|
||||||
|
|
||||||
|
@ -246,7 +247,7 @@ void JamSpookGame::set()
|
||||||
dynamic_pointer_cast<PhysicsSystem>(findSystem(IDCache::get("PhysicsSystem"))),
|
dynamic_pointer_cast<PhysicsSystem>(findSystem(IDCache::get("PhysicsSystem"))),
|
||||||
renderLayerGame);
|
renderLayerGame);
|
||||||
|
|
||||||
goalFactory->createGoal(vec3(-1, -30, -12));
|
goalFactory->createGoal(vec3(-1, -31, -12));
|
||||||
// goalFactory->createGoal(vec3(0, 0, 0));
|
// goalFactory->createGoal(vec3(0, 0, 0));
|
||||||
|
|
||||||
goalFactory.reset();
|
goalFactory.reset();
|
||||||
|
@ -261,6 +262,31 @@ void JamSpookGame::set()
|
||||||
// trackPieceFactory->createRoad();
|
// trackPieceFactory->createRoad();
|
||||||
// trackPieceFactory->createTunnel();
|
// trackPieceFactory->createTunnel();
|
||||||
// trackPieceFactory->createMountain();
|
// trackPieceFactory->createMountain();
|
||||||
|
|
||||||
|
// trackPieceFactory->createStaticPlatform();
|
||||||
|
|
||||||
|
trackPieceFactory->createGhost("SadGhost",
|
||||||
|
"ghost-white-diffuse.png",
|
||||||
|
vec3(20, -15, 10),
|
||||||
|
quat(vec3(radians(0.0f), radians(45.0f), radians(0.0f))),
|
||||||
|
5.0f);
|
||||||
|
|
||||||
|
trackPieceFactory->createGhost("AngryGhost",
|
||||||
|
"ghost-red-diffuse.png",
|
||||||
|
vec3(-8, -25, -18),
|
||||||
|
quat(vec3(radians(0.0f), radians(15.0f), radians(0.0f))),
|
||||||
|
5.0f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// End scene entities
|
||||||
|
trackPieceFactory->createGhost("SadGhost",
|
||||||
|
"ghost-white-diffuse.png",
|
||||||
|
vec3(1005, 4, 1001),
|
||||||
|
quat(vec3(radians(0.0f), radians(45.0f), radians(0.0f))));
|
||||||
|
|
||||||
trackPieceFactory->createSign("ThankYouSign",
|
trackPieceFactory->createSign("ThankYouSign",
|
||||||
"sign-thanks-diffuse.png",
|
"sign-thanks-diffuse.png",
|
||||||
vec3(994, 0, 1000),
|
vec3(994, 0, 1000),
|
||||||
|
@ -326,7 +352,7 @@ void JamSpookGame::set()
|
||||||
renderLayerGame);
|
renderLayerGame);
|
||||||
|
|
||||||
shared_ptr<Entity> endGameEntity = resetTriggerFactory->
|
shared_ptr<Entity> endGameEntity = resetTriggerFactory->
|
||||||
createResetTrigger(vec3(-1, -30, -12),
|
createResetTrigger(vec3(-1, -31, -12),
|
||||||
vec3(1));
|
vec3(1));
|
||||||
|
|
||||||
// shared_ptr<Entity> endGameEntity = resetTriggerFactory->
|
// shared_ptr<Entity> endGameEntity = resetTriggerFactory->
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#include <ecos/physics/PhysicsSystem.h>
|
#include <ecos/physics/PhysicsSystem.h>
|
||||||
#include <ecos/physics/loaders/CollisionShapeLoader.h>
|
#include <ecos/physics/loaders/CollisionShapeLoader.h>
|
||||||
|
#include <ecos/physics/loaders/StaticCollisionShapeLoader.h>
|
||||||
|
|
||||||
#include <ecos/animation/AnimationSystem.h>
|
#include <ecos/animation/AnimationSystem.h>
|
||||||
|
|
||||||
|
@ -116,6 +117,7 @@ using ecos::asset::DataManagementMode;
|
||||||
|
|
||||||
using ecos::physics::PhysicsSystem;
|
using ecos::physics::PhysicsSystem;
|
||||||
using ecos::physics::CollisionShapeLoader;
|
using ecos::physics::CollisionShapeLoader;
|
||||||
|
using ecos::physics::StaticCollisionShapeLoader;
|
||||||
|
|
||||||
using ecos::animation::AnimationSystem;
|
using ecos::animation::AnimationSystem;
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,8 @@ void KartPhysicsComponent::onICCMessage(shared_ptr<Message> message)
|
||||||
|
|
||||||
void KartPhysicsComponent::onCollision(const string& tag)
|
void KartPhysicsComponent::onCollision(const string& tag)
|
||||||
{
|
{
|
||||||
if (tag == "goal")
|
if (tag == "goal"
|
||||||
|
|| tag == "jump180")
|
||||||
{
|
{
|
||||||
ICCBroadcast(make_shared<Message>(IDCache::get("GroundCollisionMessage")));
|
ICCBroadcast(make_shared<Message>(IDCache::get("GroundCollisionMessage")));
|
||||||
}
|
}
|
||||||
|
@ -92,7 +93,8 @@ void KartPhysicsComponent::onCollision(const string& tag)
|
||||||
|
|
||||||
void KartPhysicsComponent::onSeparation(const string& tag)
|
void KartPhysicsComponent::onSeparation(const string& tag)
|
||||||
{
|
{
|
||||||
if (tag == "goal")
|
if (tag == "goal"
|
||||||
|
|| tag == "jump180")
|
||||||
{
|
{
|
||||||
ICCBroadcast(make_shared<Message>(IDCache::get("GroundSeparationMessage")));
|
ICCBroadcast(make_shared<Message>(IDCache::get("GroundSeparationMessage")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,4 +218,95 @@ shared_ptr<Entity> TrackPieceFactory::createSign(
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shared_ptr<Entity> TrackPieceFactory::createGhost(
|
||||||
|
const string name,
|
||||||
|
const string diffuseTextureFilePath,
|
||||||
|
vec3 position,
|
||||||
|
quat orientation,
|
||||||
|
float scaling)
|
||||||
|
{
|
||||||
|
// Create instance
|
||||||
|
shared_ptr<Entity> entity = make_shared<Entity>();
|
||||||
|
entity->setEntityTag(name + "_ghost");
|
||||||
|
SceneGraph::addEntity(entity);
|
||||||
|
|
||||||
|
// Create transform
|
||||||
|
mat4 translationMatrix = translate(mat4(1.0f), position);
|
||||||
|
mat4 rotationMatrix = glm::toMat4(orientation);
|
||||||
|
mat4 scalingMatrix = glm::scale(mat4(1), vec3(scaling));
|
||||||
|
|
||||||
|
|
||||||
|
mat4 transform = translationMatrix * rotationMatrix * scalingMatrix;// * rotateToCenter;
|
||||||
|
|
||||||
|
// Add graphics component
|
||||||
|
shared_ptr<GraphicsComponent> graphicsComponent = make_shared<GraphicsComponent>(transform,
|
||||||
|
entity,
|
||||||
|
getShared(mGraphicsSystem),
|
||||||
|
mRenderLayer);
|
||||||
|
entity->addComponent(graphicsComponent);
|
||||||
|
|
||||||
|
// Add the ModelRenderable
|
||||||
|
ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem);
|
||||||
|
shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("ghost.bcosm",
|
||||||
|
diffuseTextureFilePath,
|
||||||
|
name + "-model");
|
||||||
|
delete modelFactory;
|
||||||
|
graphicsComponent->addRenderable(modelRenderable);
|
||||||
|
|
||||||
|
// Return instance
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_ptr<Entity> TrackPieceFactory::createStaticPlatform()
|
||||||
|
{
|
||||||
|
// Create instance
|
||||||
|
shared_ptr<Entity> entity = make_shared<Entity>();
|
||||||
|
entity->setEntityTag("staticPlatform");
|
||||||
|
SceneGraph::addEntity(entity);
|
||||||
|
|
||||||
|
// Create transform
|
||||||
|
mat4 transform = mat4(1);
|
||||||
|
|
||||||
|
// Add physics component
|
||||||
|
ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem, mAssetSystem);
|
||||||
|
shared_ptr<TrackPiecePhysicsComponent> physicsComponent =
|
||||||
|
make_shared<TrackPiecePhysicsComponent>(
|
||||||
|
transform,
|
||||||
|
entity,
|
||||||
|
getShared(mPhysicsSystem),
|
||||||
|
getShared(mPhysicsSystem),
|
||||||
|
getShared(mPhysicsSystem),
|
||||||
|
colliderFactory->createStaticMeshCollider(vec3(0),
|
||||||
|
quat_cast(mat4(1)),
|
||||||
|
"static-platform.bcosps", // filePath
|
||||||
|
"static-platform-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
|
||||||
|
physicsComponent->getCollider()->getRigidBody()->setAngularFactor(btVector3(0, 0, 0)); // deny rotational movement movement in any axis
|
||||||
|
physicsComponent->getCollider()->getRigidBody()->setRestitution(1);
|
||||||
|
entity->addComponent(physicsComponent);
|
||||||
|
|
||||||
|
// Add graphics component
|
||||||
|
shared_ptr<GraphicsComponent> graphicsComponent = make_shared<GraphicsComponent>(transform,
|
||||||
|
entity,
|
||||||
|
getShared(mGraphicsSystem),
|
||||||
|
mRenderLayer);
|
||||||
|
entity->addComponent(graphicsComponent);
|
||||||
|
|
||||||
|
// Add the ModelRenderable of a ball
|
||||||
|
ModelRenderableFactory* modelFactory = new ModelRenderableFactory(mAssetSystem);
|
||||||
|
shared_ptr<ModelRenderable> modelRenderable = modelFactory->createModel("static-platform.bcosm",
|
||||||
|
"static-platform-diffuse.png",
|
||||||
|
"static-platform-model");
|
||||||
|
delete modelFactory;
|
||||||
|
graphicsComponent->addRenderable(modelRenderable);
|
||||||
|
|
||||||
|
// Return instance
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace JamSpook
|
} // namespace JamSpook
|
||||||
|
|
|
@ -140,6 +140,15 @@ public:
|
||||||
const string diffuseTextureFilePath,
|
const string diffuseTextureFilePath,
|
||||||
vec3 position,
|
vec3 position,
|
||||||
quat orientation);
|
quat orientation);
|
||||||
|
|
||||||
|
/// Compose a ghost entity
|
||||||
|
shared_ptr<Entity> createGhost(const string name,
|
||||||
|
const string diffuseTextureFilePath,
|
||||||
|
vec3 position,
|
||||||
|
quat orientation,
|
||||||
|
float scaling = 1.0f);
|
||||||
|
|
||||||
|
shared_ptr<Entity> createStaticPlatform();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace JamSpook
|
} // namespace JamSpook
|
||||||
|
|
Loading…
Reference in New Issue