JAMSPOOK-10 - Implement track pieces into game

- Positioned and rotated the objects, also realigned the camera.
- Experimenting with rotations and resizing the track pieces.
This commit is contained in:
Fredrick Amnehagen 2020-08-14 22:22:24 +02:00
parent 43cbe8af9b
commit 90cab0df85
13 changed files with 35 additions and 12 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 859 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 862 KiB

BIN
assets/textures/jump180.xcf Normal file

Binary file not shown.

View File

@ -92,8 +92,9 @@ JamSpookGame::JamSpookGame():
// 16.0f/9.0f,
mCamera = camFactory->createPerspective(vec3(-20.0f, 20.0f, 20.0f),
vec3(0.0f, 0.0f, 0.0f),
// mCamera = camFactory->createPerspective(vec3(-40.0f, 40.0f, 40.0f),
mCamera = camFactory->createPerspective(vec3(-60.0f, 40.0f, 60.0f),
vec3(0.0f, -20.0f, 0.0f),
vec3(0.0f, 1.0f, 0.0f),
90.0f/2,
static_cast<float>(mWindow->getWindowSize().x)/mWindow->getWindowSize().y,
@ -245,8 +246,8 @@ void JamSpookGame::set()
dynamic_pointer_cast<PhysicsSystem>(findSystem(IDCache::get("PhysicsSystem"))),
renderLayerGame);
jump180Factory->createJump180(vec3(0,-1, 0));
jump180Factory->createJump180(vec3(0,-2, 1));
jump180Factory->createJump180(vec3(0, 0, 0), vec3(0, 0, 0));
jump180Factory->createJump180(vec3(18,-10, 12), vec3(0, 180, 0));
jump180Factory.reset();
@ -257,7 +258,7 @@ void JamSpookGame::set()
dynamic_pointer_cast<PhysicsSystem>(findSystem(IDCache::get("PhysicsSystem"))),
renderLayerGame);
goalFactory->createGoal(vec3(-8,-4, -2));
goalFactory->createGoal(vec3(0, -25, -10));
goalFactory.reset();

View File

@ -10,9 +10,9 @@
namespace JamSpook {
Jump180Factory::Jump180Factory(weak_ptr<AssetSystem> assetSystem,
weak_ptr<GraphicsSystem> graphicsSystem,
weak_ptr<PhysicsSystem> physicsSystem,
weak_ptr<RenderLayer> renderLayer):
weak_ptr<GraphicsSystem> graphicsSystem,
weak_ptr<PhysicsSystem> physicsSystem,
weak_ptr<RenderLayer> renderLayer):
mAssetSystem(assetSystem),
mGraphicsSystem(graphicsSystem),
mPhysicsSystem(physicsSystem),
@ -22,13 +22,30 @@ Jump180Factory::Jump180Factory(weak_ptr<AssetSystem> assetSystem,
Jump180Factory::~Jump180Factory()
{}
shared_ptr<Entity> Jump180Factory::createJump180(const vec3 position)
shared_ptr<Entity> Jump180Factory::createJump180(const vec3 position,
const vec3 eulerRotationXYZDegrees)
{
// Create instance
shared_ptr<Entity> entity = make_shared<Entity>();
entity->setEntityTag("jump180");
SceneGraph::addEntity(entity);
mat4 transform = translate(mat4(1), position);
// Create transform
// mat4 rotateToCenter = eulerAngleXYZ(radians(static_cast<float>(-90)),
// radians(static_cast<float>(0)),
// radians(static_cast<float>(0)));
mat4 rotation = eulerAngleXYZ(
radians(static_cast<float>(eulerRotationXYZDegrees.x)),
radians(static_cast<float>(eulerRotationXYZDegrees.y)),
radians(static_cast<float>(eulerRotationXYZDegrees.z)));
mat4 translation = translate(mat4(1.0f), position);
mat4 transform = rotation * translation;// * rotateToCenter;
// mat4 transform = translate(mat4(1), position);
// Add physics component
ColliderFactory* colliderFactory = new ColliderFactory(mPhysicsSystem);
@ -40,7 +57,7 @@ shared_ptr<Entity> Jump180Factory::createJump180(const vec3 position)
getShared(mPhysicsSystem),
getShared(mPhysicsSystem),
colliderFactory->createBoxCollider(position,
quat(vec3(0,0,0)),
quat_cast(rotation),
vec3(10,1,10), // radius
100.0f, // mass
entity,

View File

@ -14,6 +14,7 @@
#include <vector>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtx/string_cast.hpp>
#include <ecos/utility/Memory.h>
@ -63,6 +64,9 @@ using glm::mat4;
using glm::quat;
using glm::translate;
using glm::scale;
using glm::rotate;
using glm::eulerAngleXYZ;
using glm::radians;
using ecos::utility::getShared;
using ecos::core::IDCache;
@ -112,7 +116,8 @@ public:
virtual ~Jump180Factory();
/// Compose a jump180 entity
shared_ptr<Entity> createJump180(const vec3 position);
shared_ptr<Entity> createJump180(const vec3 position,
const vec3 eulerRotationXYZDegrees);
};
} // namespace JamSpook