75 lines
2.2 KiB
C
75 lines
2.2 KiB
C
|
/*
|
||
|
* BallPhysicsComponent.h
|
||
|
*
|
||
|
* Created on: Aug 9, 2019
|
||
|
* Author: fredrick
|
||
|
*/
|
||
|
|
||
|
#ifndef BALLPHYSICSCOMPONENT_H_
|
||
|
#define BALLPHYSICSCOMPONENT_H_
|
||
|
|
||
|
#include <chrono>
|
||
|
#include <memory>
|
||
|
#include <cstdint>
|
||
|
#include <string>
|
||
|
#include <glm/glm.hpp>
|
||
|
#include <glm/gtc/matrix_transform.hpp>
|
||
|
|
||
|
#include <ecos/utility/Random.h>
|
||
|
#include <ecos/core/IDCache.h>
|
||
|
#include <ecos/core/Log.h>
|
||
|
#include <ecos/core/Message.h>
|
||
|
#include <ecos/core/BroadcastObservable.h>
|
||
|
#include <ecos/physics/PhysicsSystem.h>
|
||
|
#include <ecos/physics/TransformChangeMessage.h>
|
||
|
#include <ecos/physics/CollisionStateChangeMessage.h>
|
||
|
#include <ecos/physics/ColliderQueryMessage.h>
|
||
|
#include <ecos/physics/PhysicsComponent.h>
|
||
|
#include <ecos/physics/Collider.h>
|
||
|
|
||
|
namespace JamSpook {
|
||
|
|
||
|
using std::chrono::milliseconds;
|
||
|
using std::weak_ptr;
|
||
|
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;
|
||
|
using ecos::core::logging::LogLevel;
|
||
|
using ecos::core::Message;
|
||
|
using ecos::core::BroadcastObservable;
|
||
|
using ecos::physics::PhysicsSystem;
|
||
|
using ecos::physics::PhysicsComponent;
|
||
|
using ecos::physics::Collider;
|
||
|
using ecos::physics::TransformChangeMessage;
|
||
|
using ecos::physics::CollisionStateChangeMessage;
|
||
|
using ecos::physics::ColliderQueryMessage;
|
||
|
|
||
|
class BallPhysicsComponent:
|
||
|
public ecos::physics::PhysicsComponent
|
||
|
{
|
||
|
public:
|
||
|
BallPhysicsComponent(mat4 transform,
|
||
|
shared_ptr<BroadcastObservable<shared_ptr<Message> > > entity,
|
||
|
weak_ptr<BroadcastObservable<const milliseconds> > physicsSystem,
|
||
|
weak_ptr<BroadcastObservable<shared_ptr<CollisionStateChangeMessage> > > physicsCollisionSubSystem,
|
||
|
weak_ptr<BroadcastObservable<shared_ptr<ColliderQueryMessage> > > physicsColliderQuerySubSystem,
|
||
|
shared_ptr<Collider> collider);
|
||
|
virtual ~BallPhysicsComponent();
|
||
|
|
||
|
virtual void update(const milliseconds dtms);
|
||
|
virtual void onICCMessage(shared_ptr<Message> message);
|
||
|
virtual void onCollision(const string& tag);
|
||
|
};
|
||
|
|
||
|
} // namespace JamSpook
|
||
|
|
||
|
#endif // BALLPHYSICSCOMPONENT_H_
|