[DEV] some renames to be more common with other engines
This commit is contained in:
parent
3f22081ced
commit
d154b0c901
@ -31,12 +31,12 @@ namespace ege {
|
|||||||
*/
|
*/
|
||||||
virtual const std::string& getType() const;
|
virtual const std::string& getType() const;
|
||||||
/**
|
/**
|
||||||
* @brief An ege::Element component has been removed ==> need remove it in local if needed
|
* @brief An ege::Entity component has been removed ==> need remove it in local if needed
|
||||||
* @param[in] _ref Referrence on the component
|
* @param[in] _ref Referrence on the component
|
||||||
*/
|
*/
|
||||||
virtual void componentRemove(const ememory::SharedPtr<ege::Component>& _ref);
|
virtual void componentRemove(const ememory::SharedPtr<ege::Component>& _ref);
|
||||||
/**
|
/**
|
||||||
* @brief An ege::Element component has been added ==> need add it in local if needed
|
* @brief An ege::Entity component has been added ==> need add it in local if needed
|
||||||
* @param[in] _ref Referrence on the component
|
* @param[in] _ref Referrence on the component
|
||||||
*/
|
*/
|
||||||
virtual void componentAdd(const ememory::SharedPtr<ege::Component>& _ref);
|
virtual void componentAdd(const ememory::SharedPtr<ege::Component>& _ref);
|
||||||
|
@ -6,17 +6,17 @@
|
|||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/elements/Element.hpp>
|
#include <ege/Entity.hpp>
|
||||||
#include <ege/Environement.hpp>
|
#include <ege/Environement.hpp>
|
||||||
|
|
||||||
|
|
||||||
const std::string& ege::Element::getType() const {
|
const std::string& ege::Entity::getType() const {
|
||||||
static const std::string nameType("----");
|
static const std::string nameType("----");
|
||||||
return nameType;
|
return nameType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ege::Element::Element(const ememory::SharedPtr<ege::Environement>& _env) :
|
ege::Entity::Entity(const ememory::SharedPtr<ege::Environement>& _env) :
|
||||||
m_env(_env),
|
m_env(_env),
|
||||||
m_uID(0),
|
m_uID(0),
|
||||||
m_life(100),
|
m_life(100),
|
||||||
@ -25,16 +25,16 @@ ege::Element::Element(const ememory::SharedPtr<ege::Environement>& _env) :
|
|||||||
m_radius(0) {
|
m_radius(0) {
|
||||||
static uint32_t unique=0;
|
static uint32_t unique=0;
|
||||||
m_uID = unique;
|
m_uID = unique;
|
||||||
EGE_DEBUG("Create element: uId=" << m_uID);
|
EGE_DEBUG("Create Entity: uId=" << m_uID);
|
||||||
//m_debugText.setFontSize(12);
|
//m_debugText.setFontSize(12);
|
||||||
unique++;
|
unique++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ege::Element::~Element() {
|
ege::Entity::~Entity() {
|
||||||
EGE_DEBUG("Destroy element: uId=" << m_uID);
|
EGE_DEBUG("Destroy Entity: uId=" << m_uID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::Element::addComponent(const ememory::SharedPtr<ege::Component>& _ref) {
|
void ege::Entity::addComponent(const ememory::SharedPtr<ege::Component>& _ref) {
|
||||||
if (_ref == nullptr) {
|
if (_ref == nullptr) {
|
||||||
EGE_ERROR("try to add an empty component");
|
EGE_ERROR("try to add an empty component");
|
||||||
return;
|
return;
|
||||||
@ -93,7 +93,7 @@ void ege::Element::addComponent(const ememory::SharedPtr<ege::Component>& _ref)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::Element::rmComponent(const ememory::SharedPtr<ege::Component>& _ref) {
|
void ege::Entity::rmComponent(const ememory::SharedPtr<ege::Component>& _ref) {
|
||||||
if (_ref == nullptr) {
|
if (_ref == nullptr) {
|
||||||
EGE_ERROR("try to remove an empty component");
|
EGE_ERROR("try to remove an empty component");
|
||||||
return;
|
return;
|
||||||
@ -123,7 +123,7 @@ void ege::Element::rmComponent(const ememory::SharedPtr<ege::Component>& _ref) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::Element::rmComponent(const std::string& _type) {
|
void ege::Entity::rmComponent(const std::string& _type) {
|
||||||
int32_t findId = -1;
|
int32_t findId = -1;
|
||||||
ememory::SharedPtr<ege::Component> componentRemoved;
|
ememory::SharedPtr<ege::Component> componentRemoved;
|
||||||
// check if not exist
|
// check if not exist
|
||||||
@ -155,45 +155,45 @@ void ege::Element::rmComponent(const std::string& _type) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ege::Element::init() {
|
bool ege::Entity::init() {
|
||||||
EGE_WARNING("init() not implemented: uId=" << m_uID);
|
EGE_WARNING("init() not implemented: uId=" << m_uID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool ege::Element::initString(const std::string& _description) {
|
bool ege::Entity::initString(const std::string& _description) {
|
||||||
EGE_WARNING("String Init not implemented: uId=" << m_uID);
|
EGE_WARNING("String Init not implemented: uId=" << m_uID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool ege::Element::initXML(const exml::Node& _node) {
|
bool ege::Entity::initXML(const exml::Node& _node) {
|
||||||
EGE_WARNING("xml Init not implemented: uId=" << m_uID);
|
EGE_WARNING("xml Init not implemented: uId=" << m_uID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool ege::Element::initJSON(const ejson::Value& _value) {
|
bool ege::Entity::initJSON(const ejson::Value& _value) {
|
||||||
EGE_WARNING("JSON Init not implemented: uId=" << m_uID);
|
EGE_WARNING("JSON Init not implemented: uId=" << m_uID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool ege::Element::initVoid(void* _value) {
|
bool ege::Entity::initVoid(void* _value) {
|
||||||
EGE_WARNING("joid* Init not implemented: uId=" << m_uID);
|
EGE_WARNING("joid* Init not implemented: uId=" << m_uID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool ege::Element::unInit() {
|
bool ege::Entity::unInit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float ege::Element::getLifeRatio() {
|
float ege::Entity::getLifeRatio() {
|
||||||
if (0 >= m_life) {
|
if (0 >= m_life) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_life/m_lifeMax;
|
return m_life/m_lifeMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::Element::setFireOn(int32_t _groupIdSource, int32_t _type, float _power, const vec3& _center) {
|
void ege::Entity::setFireOn(int32_t _groupIdSource, int32_t _type, float _power, const vec3& _center) {
|
||||||
float previousLife = m_life;
|
float previousLife = m_life;
|
||||||
m_life += _power;
|
m_life += _power;
|
||||||
m_life = std::avg(0.0f, m_life, m_lifeMax);
|
m_life = std::avg(0.0f, m_life, m_lifeMax);
|
||||||
if (m_life <= 0) {
|
if (m_life <= 0) {
|
||||||
EGE_DEBUG("[" << getUID() << "] element is killed ..." << getType());
|
EGE_DEBUG("[" << getUID() << "] Entity is killed ..." << getType());
|
||||||
}
|
}
|
||||||
if (m_life != previousLife) {
|
if (m_life != previousLife) {
|
||||||
onLifeChange();
|
onLifeChange();
|
||||||
@ -206,7 +206,7 @@ const float lifeWidth = 2.0f;
|
|||||||
const float lifeYPos = 1.7f;
|
const float lifeYPos = 1.7f;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void ege::Element::drawLife(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera) {
|
void ege::Entity::drawLife(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera) {
|
||||||
if (_draw == nullptr) {
|
if (_draw == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ void ege::Element::drawLife(ememory::SharedPtr<ewol::resource::Colored3DObject>
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ege::Element::drawDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera) {
|
void ege::Entity::drawDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera) {
|
||||||
/*
|
/*
|
||||||
m_debugText.clear();
|
m_debugText.clear();
|
||||||
m_debugText.setColor(etk::Color<>(0x00, 0xFF, 0x00, 0xFF));
|
m_debugText.setColor(etk::Color<>(0x00, 0xFF, 0x00, 0xFF));
|
@ -23,23 +23,23 @@
|
|||||||
#define INDEX_FORWARD_AXIS (1)
|
#define INDEX_FORWARD_AXIS (1)
|
||||||
#define INDEX_UP_AXIS (2)
|
#define INDEX_UP_AXIS (2)
|
||||||
|
|
||||||
#define ELEMENT_SCALE (1.0f/8.0f)
|
#define Entity_SCALE (1.0f/8.0f)
|
||||||
|
|
||||||
namespace ege {
|
namespace ege {
|
||||||
class Element : public ememory::EnableSharedFromThis<Element> {
|
class Entity : public ememory::EnableSharedFromThis<Entity> {
|
||||||
protected:
|
protected:
|
||||||
ememory::SharedPtr<ege::Environement> m_env;
|
ememory::SharedPtr<ege::Environement> m_env;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor (when constructer is called just add element that did not change.
|
* @brief Constructor (when constructer is called just add Entity that did not change.
|
||||||
* The objest will be stored in a pool of element and keep a second time if needed == > redure memory allocation,
|
* The objest will be stored in a pool of Entity and keep a second time if needed == > redure memory allocation,
|
||||||
* when needed, the system will call the init and un-init function...
|
* when needed, the system will call the init and un-init function...
|
||||||
*/
|
*/
|
||||||
Element(const ememory::SharedPtr<ege::Environement>& _env);
|
Entity(const ememory::SharedPtr<ege::Environement>& _env);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~Element();
|
virtual ~Entity();
|
||||||
protected:
|
protected:
|
||||||
std::vector<ememory::SharedPtr<ege::Component>> m_component;
|
std::vector<ememory::SharedPtr<ege::Component>> m_component;
|
||||||
public:
|
public:
|
||||||
@ -48,15 +48,15 @@ namespace ege {
|
|||||||
void rmComponent(const std::string& _type);
|
void rmComponent(const std::string& _type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get the element Type description string.
|
* @brief get the Entity Type description string.
|
||||||
* @return A reference on the descriptive string.
|
* @return A reference on the descriptive string.
|
||||||
*/
|
*/
|
||||||
virtual const std::string& getType() const;
|
virtual const std::string& getType() const;
|
||||||
/**
|
/**
|
||||||
* @brief init the element with the defined properties
|
* @brief init the Entity with the defined properties
|
||||||
* @param[in] _property Type of the next element
|
* @param[in] _property Type of the next Entity
|
||||||
* @param[in] _value pointer on the value type
|
* @param[in] _value pointer on the value type
|
||||||
* @return true, the element is corectly initialized.
|
* @return true, the Entity is corectly initialized.
|
||||||
*/
|
*/
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
virtual bool initString(const std::string& _description);
|
virtual bool initString(const std::string& _description);
|
||||||
@ -65,10 +65,10 @@ namespace ege {
|
|||||||
virtual bool initVoid(void* _value);
|
virtual bool initVoid(void* _value);
|
||||||
virtual bool unInit();
|
virtual bool unInit();
|
||||||
private:
|
private:
|
||||||
uint32_t m_uID; //!< This is a reference on a basic element ID
|
uint32_t m_uID; //!< This is a reference on a basic Entity ID
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief get the curent Element Unique ID in the all Game.
|
* @brief get the curent Entity Unique ID in the all Game.
|
||||||
* @return The requested Unique ID.
|
* @return The requested Unique ID.
|
||||||
*/
|
*/
|
||||||
inline uint32_t getUID() const {
|
inline uint32_t getUID() const {
|
||||||
@ -76,7 +76,7 @@ namespace ege {
|
|||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
float m_life; //!< Current life of the object
|
float m_life; //!< Current life of the object
|
||||||
float m_lifeMax; //!< Maximum possible life of the element
|
float m_lifeMax; //!< Maximum possible life of the Entity
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief get the curent life ratio [0..1]
|
* @brief get the curent life ratio [0..1]
|
||||||
@ -84,21 +84,21 @@ namespace ege {
|
|||||||
*/
|
*/
|
||||||
float getLifeRatio();
|
float getLifeRatio();
|
||||||
/**
|
/**
|
||||||
* @brief Check if the element is dead.
|
* @brief Check if the Entity is dead.
|
||||||
* @return true if the element does not exist anymore, false otherwise.
|
* @return true if the Entity does not exist anymore, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool isDead() {
|
bool isDead() {
|
||||||
return (0 >= m_life)?true:false;
|
return (0 >= m_life)?true:false;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief Request if the element might be removed from the system
|
* @brief Request if the Entity might be removed from the system
|
||||||
* @return true == > the object is removed
|
* @return true == > the object is removed
|
||||||
*/
|
*/
|
||||||
virtual bool needToRemove() {
|
virtual bool needToRemove() {
|
||||||
return isDead();
|
return isDead();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief apply a fire on the element at a current power and a specific power.
|
* @brief apply a fire on the Entity at a current power and a specific power.
|
||||||
* @param[in] _groupIdSource Source Id of the group, by default all event arrive at all group, buf some event can not be obviously apply at the ennemy like reparing ....
|
* @param[in] _groupIdSource Source Id of the group, by default all event arrive at all group, buf some event can not be obviously apply at the ennemy like reparing ....
|
||||||
* @param[in] _type Type of event on the life propertied
|
* @param[in] _type Type of event on the life propertied
|
||||||
* @param[in] _power Power of the event (can be >0 for adding life).
|
* @param[in] _power Power of the event (can be >0 for adding life).
|
||||||
@ -106,22 +106,22 @@ namespace ege {
|
|||||||
*/
|
*/
|
||||||
virtual void setFireOn(int32_t _groupIdSource, int32_t _type, float _power, const vec3& _center=vec3(0,0,0));
|
virtual void setFireOn(int32_t _groupIdSource, int32_t _type, float _power, const vec3& _center=vec3(0,0,0));
|
||||||
/**
|
/**
|
||||||
* @brief Call when the element life change.
|
* @brief Call when the Entity life change.
|
||||||
*/
|
*/
|
||||||
virtual void onLifeChange() { };
|
virtual void onLifeChange() { };
|
||||||
protected:
|
protected:
|
||||||
int32_t m_group; //!< Every element has a generic group
|
int32_t m_group; //!< Every Entity has a generic group
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief get the Group of the element.
|
* @brief get the Group of the Entity.
|
||||||
* @return The group ID
|
* @return The group ID
|
||||||
*/
|
*/
|
||||||
inline int32_t getGroup() const {
|
inline int32_t getGroup() const {
|
||||||
return m_group;
|
return m_group;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief set the group of the curent element
|
* @brief set the group of the curent Entity
|
||||||
* @param[in] newGroup The new Group ID of the element.
|
* @param[in] newGroup The new Group ID of the Entity.
|
||||||
*/
|
*/
|
||||||
inline void setGroup(int32_t _newGroup) {
|
inline void setGroup(int32_t _newGroup) {
|
||||||
m_group=_newGroup;
|
m_group=_newGroup;
|
||||||
@ -131,28 +131,28 @@ namespace ege {
|
|||||||
//ewol::compositing::Text m_debugText; // ==> this is reall y a bad idea==> it is inneficient ...
|
//ewol::compositing::Text m_debugText; // ==> this is reall y a bad idea==> it is inneficient ...
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Debug display of the current element
|
* @brief Debug display of the current Entity
|
||||||
* @param[in,out] _draw Basic system to draw the debug shape and informations
|
* @param[in,out] _draw Basic system to draw the debug shape and informations
|
||||||
* @param[in] _camera Current camera for display
|
* @param[in] _camera Current camera for display
|
||||||
*/
|
*/
|
||||||
virtual void drawDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera);
|
virtual void drawDebug(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera);
|
||||||
/**
|
/**
|
||||||
* @brief Event arrive when an element has been remove from the system == > this permit to keep pointer of ennemy, and not search them every cycle ...
|
* @brief Event arrive when an Entity has been remove from the system == > this permit to keep pointer of ennemy, and not search them every cycle ...
|
||||||
* @param[in] _removedElement Pointer on the element removed.
|
* @param[in] _removedEntity Pointer on the Entity removed.
|
||||||
*/
|
*/
|
||||||
virtual void elementIsRemoved(ememory::SharedPtr<ege::Element> _removedElement) { };
|
virtual void entityIsRemoved(ememory::SharedPtr<ege::Entity> _removedEntity) { };
|
||||||
protected:
|
protected:
|
||||||
float m_radius; //!< Radius of the element (all element have a radius, if == 0 ==> then ghost ...
|
float m_radius; //!< Radius of the Entity (all Entity have a radius, if == 0 ==> then ghost ...
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief get the current space needed by the element in the workspace
|
* @brief get the current space needed by the Entity in the workspace
|
||||||
* @return The dimention needed.
|
* @return The dimention needed.
|
||||||
*/
|
*/
|
||||||
inline float getRadius() {
|
inline float getRadius() {
|
||||||
return m_radius;
|
return m_radius;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief, call when the element is removed (call only one time)
|
* @brief, call when the Entity is removed (call only one time)
|
||||||
*/
|
*/
|
||||||
virtual void onDestroy() {};
|
virtual void onDestroy() {};
|
||||||
/**
|
/**
|
||||||
@ -160,7 +160,7 @@ namespace ege {
|
|||||||
*/
|
*/
|
||||||
virtual void dynamicEnable() {};
|
virtual void dynamicEnable() {};
|
||||||
/**
|
/**
|
||||||
* @brief remove this element from the physique engine
|
* @brief remove this Entity from the physique engine
|
||||||
*/
|
*/
|
||||||
virtual void dynamicDisable() {};
|
virtual void dynamicDisable() {};
|
||||||
|
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/Environement.hpp>
|
#include <ege/Environement.hpp>
|
||||||
#include <ege/elements/Element.hpp>
|
#include <ege/Entity.hpp>
|
||||||
#include <ewol/object/Manager.hpp>
|
#include <ewol/object/Manager.hpp>
|
||||||
|
|
||||||
#include <ege/particule/Engine.hpp>
|
#include <ege/particule/Engine.hpp>
|
||||||
@ -116,52 +116,52 @@ void ege::Environement::engineComponentAdd(const ememory::SharedPtr<ege::Compone
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ememory::SharedPtr<ege::Element> ege::Environement::getElementNearest(ememory::SharedPtr<ege::Element> _sourceRequest, float& _distance) {
|
ememory::SharedPtr<ege::Entity> ege::Environement::getEntityNearest(ememory::SharedPtr<ege::Entity> _sourceRequest, float& _distance) {
|
||||||
if (_sourceRequest == nullptr) {
|
if (_sourceRequest == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
vec3 sourcePosition = _sourceRequest->getPosition();
|
vec3 sourcePosition = _sourceRequest->getPosition();
|
||||||
ememory::SharedPtr<ege::Element> result = nullptr;
|
ememory::SharedPtr<ege::Entity> result = nullptr;
|
||||||
for (size_t iii=0; iii<m_listElement.size() ; iii++) {
|
for (size_t iii=0; iii<m_listEntity.size() ; iii++) {
|
||||||
// chack nullptr pointer
|
// chack nullptr pointer
|
||||||
if (m_listElement[iii] == nullptr) {
|
if (m_listEntity[iii] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (m_listElement[iii]->getGroup() <= 0) {
|
if (m_listEntity[iii]->getGroup() <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// check if they are in the same group:
|
// check if they are in the same group:
|
||||||
if (m_listElement[iii]->getGroup() == _sourceRequest->getGroup()) {
|
if (m_listEntity[iii]->getGroup() == _sourceRequest->getGroup()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// check distance ...
|
// check distance ...
|
||||||
vec3 destPosition = m_listElement[iii]->getPosition();
|
vec3 destPosition = m_listEntity[iii]->getPosition();
|
||||||
float distance = (sourcePosition - destPosition).length();
|
float distance = (sourcePosition - destPosition).length();
|
||||||
//EGE_DEBUG("Distance : " << _distance << " >? " << distance << " id=" << iii);
|
//EGE_DEBUG("Distance : " << _distance << " >? " << distance << " id=" << iii);
|
||||||
if (_distance>distance) {
|
if (_distance>distance) {
|
||||||
_distance = distance;
|
_distance = distance;
|
||||||
result = m_listElement[iii];
|
result = m_listEntity[iii];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ege::Environement::getElementNearest(const vec3& _sourcePosition,
|
void ege::Environement::getEntityNearest(const vec3& _sourcePosition,
|
||||||
float _distanceMax,
|
float _distanceMax,
|
||||||
std::vector<ege::Environement::ResultNearestElement>& _resultList) {
|
std::vector<ege::Environement::ResultNearestEntity>& _resultList) {
|
||||||
_resultList.clear();
|
_resultList.clear();
|
||||||
ege::Environement::ResultNearestElement result;
|
ege::Environement::ResultNearestEntity result;
|
||||||
result.dist = 99999999999.0f;
|
result.dist = 99999999999.0f;
|
||||||
result.element = nullptr;
|
result.entity = nullptr;
|
||||||
for (size_t iii=0; iii<m_listElement.size() ; iii++) {
|
for (size_t iii=0; iii<m_listEntity.size() ; iii++) {
|
||||||
// chack nullptr pointer
|
// chack nullptr pointer
|
||||||
result.element = m_listElement[iii];
|
result.entity = m_listEntity[iii];
|
||||||
if (result.element == nullptr) {
|
if (result.entity == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// check distance ...
|
// check distance ...
|
||||||
vec3 destPosition = result.element->getPosition();
|
vec3 destPosition = result.entity->getPosition();
|
||||||
if (_sourcePosition == destPosition) {
|
if (_sourcePosition == destPosition) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -173,30 +173,30 @@ void ege::Environement::getElementNearest(const vec3& _sourcePosition,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::Environement::getElementNearestFixed(const vec3& _sourcePosition,
|
void ege::Environement::getEntityNearestFixed(const vec3& _sourcePosition,
|
||||||
float _distanceMax,
|
float _distanceMax,
|
||||||
std::vector<ege::Environement::ResultNearestElement>& _resultList) {
|
std::vector<ege::Environement::ResultNearestEntity>& _resultList) {
|
||||||
_resultList.clear();
|
_resultList.clear();
|
||||||
ege::Environement::ResultNearestElement result;
|
ege::Environement::ResultNearestEntity result;
|
||||||
result.dist = 99999999999.0f;
|
result.dist = 99999999999.0f;
|
||||||
result.element = nullptr;
|
result.entity = nullptr;
|
||||||
for (size_t iii=0; iii<m_listElement.size() ; iii++) {
|
for (size_t iii=0; iii<m_listEntity.size() ; iii++) {
|
||||||
// chack nullptr pointer
|
// chack nullptr pointer
|
||||||
result.element = m_listElement[iii];
|
result.entity = m_listEntity[iii];
|
||||||
if (result.element == nullptr) {
|
if (result.entity == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (result.element->isFixed() == false) {
|
if (result.entity->isFixed() == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// check distance ...
|
// check distance ...
|
||||||
vec3 destPosition = result.element->getPositionTheoric();
|
vec3 destPosition = result.entity->getPositionTheoric();
|
||||||
result.dist = (_sourcePosition - destPosition).length();
|
result.dist = (_sourcePosition - destPosition).length();
|
||||||
//EGE_DEBUG("Distance : " << _distance << " >? " << distance << " id=" << iii);
|
//EGE_DEBUG("Distance : " << _distance << " >? " << distance << " id=" << iii);
|
||||||
if (_distanceMax <= result.dist) {
|
if (_distanceMax <= result.dist) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// try to add the element at the best positions:
|
// try to add the entity at the best positions:
|
||||||
size_t jjj;
|
size_t jjj;
|
||||||
for (jjj=0; jjj<_resultList.size(); jjj++) {
|
for (jjj=0; jjj<_resultList.size(); jjj++) {
|
||||||
if (_resultList[jjj].dist>result.dist) {
|
if (_resultList[jjj].dist>result.dist) {
|
||||||
@ -204,7 +204,7 @@ void ege::Environement::getElementNearestFixed(const vec3& _sourcePosition,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add element at the end :
|
// add entity at the end :
|
||||||
if (jjj >= _resultList.size()) {
|
if (jjj >= _resultList.size()) {
|
||||||
_resultList.push_back(result);
|
_resultList.push_back(result);
|
||||||
}
|
}
|
||||||
@ -212,12 +212,12 @@ void ege::Environement::getElementNearestFixed(const vec3& _sourcePosition,
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static etk::Hash<ege::createElement_tf>& getHachTableCreating() {
|
static etk::Hash<ege::createEntity_tf>& getHachTableCreating() {
|
||||||
static etk::Hash<ege::createElement_tf> s_table;
|
static etk::Hash<ege::createEntity_tf> s_table;
|
||||||
return s_table;
|
return s_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::Environement::addCreator(const std::string& _type, ege::createElement_tf _creator) {
|
void ege::Environement::addCreator(const std::string& _type, ege::createEntity_tf _creator) {
|
||||||
if (_creator == nullptr) {
|
if (_creator == nullptr) {
|
||||||
EGE_ERROR("Try to add an empty CREATOR ...");
|
EGE_ERROR("Try to add an empty CREATOR ...");
|
||||||
return;
|
return;
|
||||||
@ -228,183 +228,183 @@ void ege::Environement::addCreator(const std::string& _type, ege::createElement_
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ememory::SharedPtr<ege::Element> ege::Environement::createElement(const std::string& _type, const std::string& _description, bool _autoAddElement) {
|
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const std::string& _type, const std::string& _description, bool _autoAddEntity) {
|
||||||
if (getHachTableCreating().exist(_type) == false) {
|
if (getHachTableCreating().exist(_type) == false) {
|
||||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
ege::createEntity_tf creatorPointer = getHachTableCreating()[_type];
|
||||||
if (creatorPointer == nullptr) {
|
if (creatorPointer == nullptr) {
|
||||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ege::Element> tmpElement = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||||
if (tmpElement == nullptr) {
|
if (tmpEntity == nullptr) {
|
||||||
EGE_ERROR("allocation error '" << _type << "'");
|
EGE_ERROR("allocation error '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (tmpElement->initString(_description) == false) {
|
if (tmpEntity->initString(_description) == false) {
|
||||||
EGE_ERROR("Init error ... '" << _type << "'");
|
EGE_ERROR("Init error ... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (_autoAddElement == true) {
|
if (_autoAddEntity == true) {
|
||||||
addElement(tmpElement);
|
addEntity(tmpEntity);
|
||||||
}
|
}
|
||||||
return tmpElement;
|
return tmpEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
ememory::SharedPtr<ege::Element> ege::Environement::createElement(const std::string& _type, const ejson::Value& _value, bool _autoAddElement) {
|
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const std::string& _type, const ejson::Value& _value, bool _autoAddEntity) {
|
||||||
if (getHachTableCreating().exist(_type) == false) {
|
if (getHachTableCreating().exist(_type) == false) {
|
||||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
ege::createEntity_tf creatorPointer = getHachTableCreating()[_type];
|
||||||
if (creatorPointer == nullptr) {
|
if (creatorPointer == nullptr) {
|
||||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ege::Element> tmpElement = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||||
if (tmpElement == nullptr) {
|
if (tmpEntity == nullptr) {
|
||||||
EGE_ERROR("allocation error '" << _type << "'");
|
EGE_ERROR("allocation error '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (tmpElement->initJSON(_value) == false) {
|
if (tmpEntity->initJSON(_value) == false) {
|
||||||
EGE_ERROR("Init error ... '" << _type << "'");
|
EGE_ERROR("Init error ... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (_autoAddElement == true) {
|
if (_autoAddEntity == true) {
|
||||||
addElement(tmpElement);
|
addEntity(tmpEntity);
|
||||||
}
|
}
|
||||||
return tmpElement;
|
return tmpEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
ememory::SharedPtr<ege::Element> ege::Environement::createElement(const std::string& _type, const exml::Node& _node, bool _autoAddElement) {
|
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const std::string& _type, const exml::Node& _node, bool _autoAddEntity) {
|
||||||
if (getHachTableCreating().exist(_type) == false) {
|
if (getHachTableCreating().exist(_type) == false) {
|
||||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
ege::createEntity_tf creatorPointer = getHachTableCreating()[_type];
|
||||||
if (creatorPointer == nullptr) {
|
if (creatorPointer == nullptr) {
|
||||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ege::Element> tmpElement = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||||
if (tmpElement == nullptr) {
|
if (tmpEntity == nullptr) {
|
||||||
EGE_ERROR("allocation error '" << _type << "'");
|
EGE_ERROR("allocation error '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (tmpElement->initXML(_node) == false) {
|
if (tmpEntity->initXML(_node) == false) {
|
||||||
EGE_ERROR("Init error ... '" << _type << "'");
|
EGE_ERROR("Init error ... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (_autoAddElement == true) {
|
if (_autoAddEntity == true) {
|
||||||
addElement(tmpElement);
|
addEntity(tmpEntity);
|
||||||
}
|
}
|
||||||
return tmpElement;
|
return tmpEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
ememory::SharedPtr<ege::Element> ege::Environement::createElement(const std::string& _type, void* _data, bool _autoAddElement) {
|
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const std::string& _type, void* _data, bool _autoAddEntity) {
|
||||||
if (getHachTableCreating().exist(_type) == false) {
|
if (getHachTableCreating().exist(_type) == false) {
|
||||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
ege::createEntity_tf creatorPointer = getHachTableCreating()[_type];
|
||||||
if (creatorPointer == nullptr) {
|
if (creatorPointer == nullptr) {
|
||||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ege::Element> tmpElement = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||||
if (tmpElement == nullptr) {
|
if (tmpEntity == nullptr) {
|
||||||
EGE_ERROR("allocation error '" << _type << "'");
|
EGE_ERROR("allocation error '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (tmpElement->initVoid(_data) == false) {
|
if (tmpEntity->initVoid(_data) == false) {
|
||||||
EGE_ERROR("Init error ... '" << _type << "'");
|
EGE_ERROR("Init error ... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (_autoAddElement == true) {
|
if (_autoAddEntity == true) {
|
||||||
addElement(tmpElement);
|
addEntity(tmpEntity);
|
||||||
}
|
}
|
||||||
return tmpElement;
|
return tmpEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
ememory::SharedPtr<ege::Element> ege::Environement::createElement(const std::string& _type, bool _autoAddElement) {
|
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const std::string& _type, bool _autoAddEntity) {
|
||||||
if (getHachTableCreating().exist(_type) == false) {
|
if (getHachTableCreating().exist(_type) == false) {
|
||||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
ege::createEntity_tf creatorPointer = getHachTableCreating()[_type];
|
||||||
if (creatorPointer == nullptr) {
|
if (creatorPointer == nullptr) {
|
||||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ege::Element> tmpElement = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||||
if (tmpElement == nullptr) {
|
if (tmpEntity == nullptr) {
|
||||||
EGE_ERROR("allocation error '" << _type << "'");
|
EGE_ERROR("allocation error '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (tmpElement->init() == false) {
|
if (tmpEntity->init() == false) {
|
||||||
EGE_ERROR("Init error ... '" << _type << "'");
|
EGE_ERROR("Init error ... '" << _type << "'");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (_autoAddElement == true) {
|
if (_autoAddEntity == true) {
|
||||||
addElement(tmpElement);
|
addEntity(tmpEntity);
|
||||||
}
|
}
|
||||||
return tmpElement;
|
return tmpEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::Environement::addElement(ememory::SharedPtr<ege::Element> _newElement) {
|
void ege::Environement::addEntity(ememory::SharedPtr<ege::Entity> _newEntity) {
|
||||||
// prevent memory allocation and un allocation ...
|
// prevent memory allocation and un allocation ...
|
||||||
if (_newElement == nullptr) {
|
if (_newEntity == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (size_t iii=0; iii<m_listElement.size() ; iii++) {
|
for (size_t iii=0; iii<m_listEntity.size() ; iii++) {
|
||||||
if (m_listElement[iii] == nullptr) {
|
if (m_listEntity[iii] == nullptr) {
|
||||||
m_listElement[iii] = _newElement;
|
m_listEntity[iii] = _newEntity;
|
||||||
m_listElement[iii]->dynamicEnable();
|
m_listEntity[iii]->dynamicEnable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_listElement.push_back(_newElement);
|
m_listEntity.push_back(_newEntity);
|
||||||
_newElement->dynamicEnable();
|
_newEntity->dynamicEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::Environement::rmElement(ememory::SharedPtr<ege::Element> _removeElement) {
|
void ege::Environement::rmEntity(ememory::SharedPtr<ege::Entity> _removeEntity) {
|
||||||
if (_removeElement == nullptr) {
|
if (_removeEntity == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// inform the element that an element has been removed == > this permit to keep pointer on elements ...
|
// inform the entity that an entity has been removed == > this permit to keep pointer on entitys ...
|
||||||
for (size_t iii=0; iii<m_listElement.size() ; iii++) {
|
for (size_t iii=0; iii<m_listEntity.size() ; iii++) {
|
||||||
if (m_listElement[iii] != nullptr) {
|
if (m_listEntity[iii] != nullptr) {
|
||||||
m_listElement[iii]->elementIsRemoved(_removeElement);
|
m_listEntity[iii]->entityIsRemoved(_removeEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ream remove on the element :
|
// ream remove on the entity :
|
||||||
for (size_t iii=0; iii<m_listElement.size() ; iii++) {
|
for (size_t iii=0; iii<m_listEntity.size() ; iii++) {
|
||||||
if (_removeElement == m_listElement[iii]) {
|
if (_removeEntity == m_listEntity[iii]) {
|
||||||
m_listElement[iii]->onDestroy();
|
m_listEntity[iii]->onDestroy();
|
||||||
m_listElement[iii]->dynamicDisable();
|
m_listEntity[iii]->dynamicDisable();
|
||||||
m_listElement[iii]->unInit();
|
m_listEntity[iii]->unInit();
|
||||||
m_listElement[iii].reset();
|
m_listEntity[iii].reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::Environement::generateInteraction(ege::ElementInteraction& _event) {
|
void ege::Environement::generateInteraction(ege::EntityInteraction& _event) {
|
||||||
// inform the element that an element has been removed == > this permit to keep pointer on elements ...
|
// inform the entity that an entity has been removed == > this permit to keep pointer on entitys ...
|
||||||
for (size_t iii=0; iii<m_listElement.size() ; iii++) {
|
for (size_t iii=0; iii<m_listEntity.size() ; iii++) {
|
||||||
if (m_listElement[iii] == nullptr) {
|
if (m_listEntity[iii] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_event.applyEvent(*m_listElement[iii]);
|
_event.applyEvent(*m_listEntity[iii]);
|
||||||
/*
|
/*
|
||||||
vec3 destPosition = m_listElement[iii]->getPosition();
|
vec3 destPosition = m_listEntity[iii]->getPosition();
|
||||||
float dist = (sourcePosition - destPosition).length;
|
float dist = (sourcePosition - destPosition).length;
|
||||||
if (dist == 0 || dist>decreasePower) {
|
if (dist == 0 || dist>decreasePower) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
float inpact = (decreasePower-dist)/decreasePower * power;
|
float inpact = (decreasePower-dist)/decreasePower * power;
|
||||||
g_listElement[iii]->setFireOn(groupIdSource, type, -inpact, sourcePosition);
|
g_listEntity[iii]->setFireOn(groupIdSource, type, -inpact, sourcePosition);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,7 +418,7 @@ ege::Environement::Environement() :
|
|||||||
propertyRatio(this, "ratio",
|
propertyRatio(this, "ratio",
|
||||||
1.0f,
|
1.0f,
|
||||||
"game speed ratio"),
|
"game speed ratio"),
|
||||||
m_listElement() {
|
m_listEntity() {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
propertyStatus.add(gameStart, "start", "Scene is started");
|
propertyStatus.add(gameStart, "start", "Scene is started");
|
||||||
propertyStatus.add(gamePause, "pause", "Scene is paused");
|
propertyStatus.add(gamePause, "pause", "Scene is paused");
|
||||||
@ -431,7 +431,7 @@ ege::Environement::Environement() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ege::Environement::clear() {
|
void ege::Environement::clear() {
|
||||||
m_listElement.clear();
|
m_listEntity.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -500,22 +500,22 @@ void ege::Environement::onCallbackPeriodicCall(const ewol::event::Time& _event)
|
|||||||
// TODO : m_physicEngine.debugDrawWorld();
|
// TODO : m_physicEngine.debugDrawWorld();
|
||||||
// TODO : EGE_INFO(" Update particule engine");
|
// TODO : EGE_INFO(" Update particule engine");
|
||||||
// TODO : m_particuleEngine.update(curentDelta);
|
// TODO : m_particuleEngine.update(curentDelta);
|
||||||
// remove all element that requested it ...
|
// remove all entity that requested it ...
|
||||||
/**
|
/**
|
||||||
{
|
{
|
||||||
int32_t numberEnnemyKilled=0;
|
int32_t numberEnnemyKilled=0;
|
||||||
int32_t victoryPoint=0;
|
int32_t victoryPoint=0;
|
||||||
auto it(m_listElement.begin());
|
auto it(m_listEntity.begin());
|
||||||
while (it != m_listElement.end()) {
|
while (it != m_listEntity.end()) {
|
||||||
if(*it != nullptr) {
|
if(*it != nullptr) {
|
||||||
if ((*it)->needToRemove() == true) {
|
if ((*it)->needToRemove() == true) {
|
||||||
if ((*it)->getGroup() > 1) {
|
if ((*it)->getGroup() > 1) {
|
||||||
numberEnnemyKilled++;
|
numberEnnemyKilled++;
|
||||||
victoryPoint++;
|
victoryPoint++;
|
||||||
}
|
}
|
||||||
EGE_INFO("[" << (*it)->getUID() << "] element Removing ... " << (*it)->getType());
|
EGE_INFO("[" << (*it)->getUID() << "] entity Removing ... " << (*it)->getType());
|
||||||
rmElement((*it));
|
rmEntity((*it));
|
||||||
it = m_listElement.begin();
|
it = m_listEntity.begin();
|
||||||
} else {
|
} else {
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace ege {
|
namespace ege {
|
||||||
class Environement;
|
class Environement;
|
||||||
class ElementInteraction;
|
class EntityInteraction;
|
||||||
};
|
};
|
||||||
#include <ege/camera/Camera.hpp>
|
#include <ege/camera/Camera.hpp>
|
||||||
|
|
||||||
@ -26,9 +26,9 @@ namespace ege {
|
|||||||
#include <ege/resource/Mesh.hpp>
|
#include <ege/resource/Mesh.hpp>
|
||||||
|
|
||||||
namespace ege {
|
namespace ege {
|
||||||
class Element;
|
class Entity;
|
||||||
class Environement;
|
class Environement;
|
||||||
typedef ememory::SharedPtr<ege::Element> (*createElement_tf)(const ememory::SharedPtr<ege::Environement>& _env);
|
typedef ememory::SharedPtr<ege::Entity> (*createEntity_tf)(const ememory::SharedPtr<ege::Environement>& _env);
|
||||||
|
|
||||||
enum gameStatus {
|
enum gameStatus {
|
||||||
gameStart,
|
gameStart,
|
||||||
@ -36,7 +36,7 @@ namespace ege {
|
|||||||
gameStop
|
gameStop
|
||||||
};
|
};
|
||||||
|
|
||||||
class ElementInteraction {
|
class EntityInteraction {
|
||||||
protected:
|
protected:
|
||||||
int32_t m_type;
|
int32_t m_type;
|
||||||
public:
|
public:
|
||||||
@ -65,15 +65,15 @@ namespace ege {
|
|||||||
return m_positionSource;
|
return m_positionSource;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
ElementInteraction(int32_t _type, int32_t _groupSource, const vec3& _pos) :
|
EntityInteraction(int32_t _type, int32_t _groupSource, const vec3& _pos) :
|
||||||
m_type(_type),
|
m_type(_type),
|
||||||
m_groupSource(_groupSource),
|
m_groupSource(_groupSource),
|
||||||
m_positionSource(_pos)
|
m_positionSource(_pos)
|
||||||
{ };
|
{ };
|
||||||
public:
|
public:
|
||||||
virtual void applyEvent(ege::Element& _element) { };
|
virtual void applyEvent(ege::Entity& _entity) { };
|
||||||
};
|
};
|
||||||
// TODO : An element must be created by a local factory...
|
// TODO : An entity must be created by a local factory...
|
||||||
class Environement : public ewol::Object {
|
class Environement : public ewol::Object {
|
||||||
public:
|
public:
|
||||||
// Signals
|
// Signals
|
||||||
@ -92,7 +92,7 @@ namespace ege {
|
|||||||
void engineComponentAdd(const ememory::SharedPtr<ege::Component>& _ref);
|
void engineComponentAdd(const ememory::SharedPtr<ege::Component>& _ref);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ememory::SharedPtr<ege::Element>> m_listElement; //!< List of all element added in the Game
|
std::vector<ememory::SharedPtr<ege::Entity>> m_listEntity; //!< List of all entity added in the Game
|
||||||
protected:
|
protected:
|
||||||
Environement();
|
Environement();
|
||||||
public:
|
public:
|
||||||
@ -128,28 +128,28 @@ namespace ege {
|
|||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
/**
|
/**
|
||||||
* @brief add a creator element system
|
* @brief add a creator entity system
|
||||||
* @param[in] _type Type of the element.
|
* @param[in] _type Type of the entity.
|
||||||
* @param[in] _creator Function pointer that reference the element creating.
|
* @param[in] _creator Function pointer that reference the entity creating.
|
||||||
*/
|
*/
|
||||||
static void addCreator(const std::string& _type, ege::createElement_tf _creator);
|
static void addCreator(const std::string& _type, ege::createEntity_tf _creator);
|
||||||
/**
|
/**
|
||||||
* @brief Create an element on the curent scene.
|
* @brief Create an entity on the curent scene.
|
||||||
* @param[in] _type Type of the element that might be created.
|
* @param[in] _type Type of the entity that might be created.
|
||||||
* @param[in] _description String that describe the content of the element properties.
|
* @param[in] _description String that describe the content of the entity properties.
|
||||||
* @param[in] _autoAddElement this permit to add the element if it is created == > no more action ...
|
* @param[in] _autoAddEntity this permit to add the entity if it is created == > no more action ...
|
||||||
* @return nullptr if an error occured OR the pointer on the element and it is already added on the system.
|
* @return nullptr if an error occured OR the pointer on the entity and it is already added on the system.
|
||||||
* @note Pointer is return in case of setting properties on it...
|
* @note Pointer is return in case of setting properties on it...
|
||||||
*/
|
*/
|
||||||
ememory::SharedPtr<ege::Element> createElement(const std::string& _type, const std::string& _description, bool _autoAddElement=true);
|
ememory::SharedPtr<ege::Entity> createEntity(const std::string& _type, const std::string& _description, bool _autoAddEntity=true);
|
||||||
ememory::SharedPtr<ege::Element> createElement(const std::string& _type, const ejson::Value& _value, bool _autoAddElement=true);
|
ememory::SharedPtr<ege::Entity> createEntity(const std::string& _type, const ejson::Value& _value, bool _autoAddEntity=true);
|
||||||
ememory::SharedPtr<ege::Element> createElement(const std::string& _type, const exml::Node& _node, bool _autoAddElement=true);
|
ememory::SharedPtr<ege::Entity> createEntity(const std::string& _type, const exml::Node& _node, bool _autoAddEntity=true);
|
||||||
ememory::SharedPtr<ege::Element> createElement(const std::string& _type, void* _data, bool _autoAddElement=true);
|
ememory::SharedPtr<ege::Entity> createEntity(const std::string& _type, void* _data, bool _autoAddEntity=true);
|
||||||
ememory::SharedPtr<ege::Element> createElement(const std::string& _type, bool _autoAddElement=true);
|
ememory::SharedPtr<ege::Entity> createEntity(const std::string& _type, bool _autoAddEntity=true);
|
||||||
public:
|
public:
|
||||||
class ResultNearestElement {
|
class ResultNearestEntity {
|
||||||
public:
|
public:
|
||||||
ememory::SharedPtr<ege::Element> element;
|
ememory::SharedPtr<ege::Entity> entity;
|
||||||
float dist;
|
float dist;
|
||||||
};
|
};
|
||||||
#if 0
|
#if 0
|
||||||
@ -169,43 +169,43 @@ namespace ege {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* @breif get a reference on the curent list of element games
|
* @breif get a reference on the curent list of entity games
|
||||||
* @return all element list
|
* @return all entity list
|
||||||
*/
|
*/
|
||||||
std::vector<ememory::SharedPtr<ege::Element>>& getElement() {
|
std::vector<ememory::SharedPtr<ege::Entity>>& getEntity() {
|
||||||
return m_listElement;
|
return m_listEntity;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief get the nearest Element
|
* @brief get the nearest Entity
|
||||||
* @param[in] _sourceRequest Pointer on the element that request this.
|
* @param[in] _sourceRequest Pointer on the entity that request this.
|
||||||
* @param[in] _distance Maximum distance search == > return the element distance
|
* @param[in] _distance Maximum distance search == > return the entity distance
|
||||||
* @return Pointer on the neares element OR nullptr
|
* @return Pointer on the neares entity OR nullptr
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
ememory::SharedPtr<ege::Element> getElementNearest(ememory::SharedPtr<ege::Element> _sourceRequest, float& _distance);
|
ememory::SharedPtr<ege::Entity> getEntityNearest(ememory::SharedPtr<ege::Entity> _sourceRequest, float& _distance);
|
||||||
|
|
||||||
void getElementNearest(const vec3& _sourcePosition,
|
void getEntityNearest(const vec3& _sourcePosition,
|
||||||
float _distanceMax,
|
float _distanceMax,
|
||||||
std::vector<ege::Environement::ResultNearestElement>& _resultList);
|
std::vector<ege::Environement::ResultNearestEntity>& _resultList);
|
||||||
void getElementNearestFixed(const vec3& _sourcePosition,
|
void getEntityNearestFixed(const vec3& _sourcePosition,
|
||||||
float _distanceMax,
|
float _distanceMax,
|
||||||
std::vector<ege::Environement::ResultNearestElement>& _resultList);
|
std::vector<ege::Environement::ResultNearestEntity>& _resultList);
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief add an element on the list availlable.
|
* @brief add an entity on the list availlable.
|
||||||
* @param[in] _newElement Element to add.
|
* @param[in] _newEntity Entity to add.
|
||||||
*/
|
*/
|
||||||
void addElement(ememory::SharedPtr<ege::Element> _newElement);
|
void addEntity(ememory::SharedPtr<ege::Entity> _newEntity);
|
||||||
/**
|
/**
|
||||||
* @brief remove an element on the list availlable.
|
* @brief remove an entity on the list availlable.
|
||||||
* @param[in] _removeElement Element to remove.
|
* @param[in] _removeEntity Entity to remove.
|
||||||
*/
|
*/
|
||||||
void rmElement(ememory::SharedPtr<ege::Element> _removeElement);
|
void rmEntity(ememory::SharedPtr<ege::Entity> _removeEntity);
|
||||||
/**
|
/**
|
||||||
* @brief generate an event on all the sub element of the game == > usefull for explosion, or lazer fire ...
|
* @brief generate an event on all the sub entity of the game == > usefull for explosion, or lazer fire ...
|
||||||
* @param[in] _event event that might be apply ...
|
* @param[in] _event event that might be apply ...
|
||||||
*/
|
*/
|
||||||
void generateInteraction(ege::ElementInteraction& _event);
|
void generateInteraction(ege::EntityInteraction& _event);
|
||||||
protected:
|
protected:
|
||||||
int64_t m_gameTime; //!< time of the game running
|
int64_t m_gameTime; //!< time of the game running
|
||||||
public:
|
public:
|
||||||
|
14
ege/Ray.cpp
14
ege/Ray.cpp
@ -6,7 +6,7 @@
|
|||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <ege/Ray.hpp>
|
#include <ege/Ray.hpp>
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/elements/Element.hpp>
|
#include <ege/Entity.hpp>
|
||||||
#include <etk/math/Vector3D.hpp>
|
#include <etk/math/Vector3D.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ std::pair<vec3,vec3> ege::Ray::testRay(ege::physics::Engine& _engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>> ege::Ray::testRayObject(ege::physics::Engine& _engine) {
|
std::pair<ememory::SharedPtr<ege::Entity>, std::pair<vec3,vec3>> ege::Ray::testRayObject(ege::physics::Engine& _engine) {
|
||||||
vec3 start = m_origin;
|
vec3 start = m_origin;
|
||||||
vec3 stop = m_origin+m_direction*1000.0f;
|
vec3 stop = m_origin+m_direction*1000.0f;
|
||||||
// Start and End are vectors
|
// Start and End are vectors
|
||||||
@ -69,17 +69,17 @@ std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>> ege::Ray::test
|
|||||||
if(rayCallback.hasHit()) {
|
if(rayCallback.hasHit()) {
|
||||||
vec3 end = rayCallback.m_hitPointWorld;
|
vec3 end = rayCallback.m_hitPointWorld;
|
||||||
vec3 normal = rayCallback.m_hitNormalWorld;
|
vec3 normal = rayCallback.m_hitNormalWorld;
|
||||||
ege::Element* elem = static_cast<ege::Element*>(rayCallback.m_collisionObject->getUserPointer());
|
ege::Entity* elem = static_cast<ege::Entity*>(rayCallback.m_collisionObject->getUserPointer());
|
||||||
if (elem != nullptr) {
|
if (elem != nullptr) {
|
||||||
EGE_VERBOSE(" hit at point=" << end << " normal=" << normal);
|
EGE_VERBOSE(" hit at point=" << end << " normal=" << normal);
|
||||||
return std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>>(elem->sharedFromThis(), std::pair<vec3,vec3>(end,normal));
|
return std::pair<ememory::SharedPtr<ege::Entity>, std::pair<vec3,vec3>>(elem->sharedFromThis(), std::pair<vec3,vec3>(end,normal));
|
||||||
}
|
}
|
||||||
EGE_VERBOSE(" Can not get the element pointer");
|
EGE_VERBOSE(" Can not get the entity pointer");
|
||||||
return std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>>(nullptr, std::pair<vec3,vec3>(end,normal));
|
return std::pair<ememory::SharedPtr<ege::Entity>, std::pair<vec3,vec3>>(nullptr, std::pair<vec3,vec3>(end,normal));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
EGE_VERBOSE(" No Hit");
|
EGE_VERBOSE(" No Hit");
|
||||||
return std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>>(nullptr, std::pair<vec3,vec3>(vec3(0,0,0),vec3(0,0,0)));
|
return std::pair<ememory::SharedPtr<ege::Entity>, std::pair<vec3,vec3>>(nullptr, std::pair<vec3,vec3>(vec3(0,0,0),vec3(0,0,0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 ege::Ray::testRayZeroPlane() {
|
vec3 ege::Ray::testRayZeroPlane() {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <etk/math/Vector3D.hpp>
|
#include <etk/math/Vector3D.hpp>
|
||||||
namespace ege {
|
namespace ege {
|
||||||
class Ray;
|
class Ray;
|
||||||
class Element;
|
class Entity;
|
||||||
};
|
};
|
||||||
#include <ege/physics/Engine.hpp>
|
#include <ege/physics/Engine.hpp>
|
||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
@ -65,7 +65,7 @@ namespace ege {
|
|||||||
void set(const vec3& _origin, const vec3& _direction);
|
void set(const vec3& _origin, const vec3& _direction);
|
||||||
public:
|
public:
|
||||||
std::pair<vec3,vec3> testRay(ege::physics::Engine& _engine);
|
std::pair<vec3,vec3> testRay(ege::physics::Engine& _engine);
|
||||||
std::pair<ememory::SharedPtr<ege::Element>, std::pair<vec3,vec3>> testRayObject(ege::physics::Engine& _engine);
|
std::pair<ememory::SharedPtr<ege::Entity>, std::pair<vec3,vec3>> testRayObject(ege::physics::Engine& _engine);
|
||||||
vec3 testRayZeroPlane();
|
vec3 testRayZeroPlane();
|
||||||
};
|
};
|
||||||
std::ostream& operator <<(std::ostream& _os, const ege::Ray& _obj);
|
std::ostream& operator <<(std::ostream& _os, const ege::Ray& _obj);
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
#include <ege/physics/Component.hpp>
|
#include <ege/physics/Component.hpp>
|
||||||
#include <ege/physics/Engine.hpp>
|
#include <ege/physics/Engine.hpp>
|
||||||
#include <ege/Environement.hpp>
|
#include <ege/Environement.hpp>
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
#include <ege/physics/shape/Shape.hpp>
|
||||||
#include <ege/physicsShape/PhysicsBox.hpp>
|
#include <ege/physics/shape/Box.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCapsule.hpp>
|
#include <ege/physics/shape/Capsule.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCone.hpp>
|
#include <ege/physics/shape/Cone.hpp>
|
||||||
#include <ege/physicsShape/PhysicsConvexHull.hpp>
|
#include <ege/physics/shape/ConvexHull.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCylinder.hpp>
|
#include <ege/physics/shape/Cylinder.hpp>
|
||||||
#include <ege/physicsShape/PhysicsSphere.hpp>
|
#include <ege/physics/shape/Sphere.hpp>
|
||||||
|
|
||||||
const std::string& ege::physics::Component::getType() const {
|
const std::string& ege::physics::Component::getType() const {
|
||||||
static std::string tmp("physics");
|
static std::string tmp("physics");
|
||||||
@ -80,9 +80,9 @@ void ege::physics::Component::generate() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (it->getType()) {
|
switch (it->getType()) {
|
||||||
case ege::PhysicsShape::box : {
|
case ege::physics::Shape::type::box : {
|
||||||
EGE_DEBUG(" Box");
|
EGE_DEBUG(" Box");
|
||||||
const ege::PhysicsBox* tmpElement = it->toBox();
|
const ege::physics::shape::Box* tmpElement = it->toBox();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Box ==> can not cast in BOX");
|
EGE_ERROR(" Box ==> can not cast in BOX");
|
||||||
continue;
|
continue;
|
||||||
@ -106,9 +106,9 @@ void ege::physics::Component::generate() {
|
|||||||
m_listProxyShape.push_back(proxyShape);
|
m_listProxyShape.push_back(proxyShape);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::cylinder : {
|
case ege::physics::Shape::type::cylinder : {
|
||||||
EGE_DEBUG(" Cylinder");
|
EGE_DEBUG(" Cylinder");
|
||||||
const ege::PhysicsCylinder* tmpElement = it->toCylinder();
|
const ege::physics::shape::Cylinder* tmpElement = it->toCylinder();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Cylinder ==> can not cast in Cylinder");
|
EGE_ERROR(" Cylinder ==> can not cast in Cylinder");
|
||||||
continue;
|
continue;
|
||||||
@ -127,9 +127,9 @@ void ege::physics::Component::generate() {
|
|||||||
m_listProxyShape.push_back(proxyShape);
|
m_listProxyShape.push_back(proxyShape);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::capsule : {
|
case ege::physics::Shape::type::capsule : {
|
||||||
EGE_DEBUG(" Capsule");
|
EGE_DEBUG(" Capsule");
|
||||||
const ege::PhysicsCapsule* tmpElement = it->toCapsule();
|
const ege::physics::shape::Capsule* tmpElement = it->toCapsule();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Capsule ==> can not cast in Capsule");
|
EGE_ERROR(" Capsule ==> can not cast in Capsule");
|
||||||
continue;
|
continue;
|
||||||
@ -148,9 +148,9 @@ void ege::physics::Component::generate() {
|
|||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::cone : {
|
case ege::physics::Shape::type::cone : {
|
||||||
EGE_DEBUG(" Cone");
|
EGE_DEBUG(" Cone");
|
||||||
const ege::PhysicsCone* tmpElement = it->toCone();
|
const ege::physics::shape::Cone* tmpElement = it->toCone();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Cone ==> can not cast in Cone");
|
EGE_ERROR(" Cone ==> can not cast in Cone");
|
||||||
continue;
|
continue;
|
||||||
@ -169,9 +169,9 @@ void ege::physics::Component::generate() {
|
|||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::sphere : {
|
case ege::physics::Shape::type::sphere : {
|
||||||
EGE_DEBUG(" Sphere");
|
EGE_DEBUG(" Sphere");
|
||||||
const ege::PhysicsSphere* tmpElement = it->toSphere();
|
const ege::physics::shape::Sphere* tmpElement = it->toSphere();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Sphere ==> can not cast in Sphere");
|
EGE_ERROR(" Sphere ==> can not cast in Sphere");
|
||||||
continue;
|
continue;
|
||||||
@ -202,9 +202,9 @@ void ege::physics::Component::generate() {
|
|||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::convexHull : {
|
case ege::physics::Shape::type::convexHull : {
|
||||||
EGE_DEBUG(" convexHull");
|
EGE_DEBUG(" convexHull");
|
||||||
const ege::PhysicsConvexHull* tmpElement = it->toConvexHull();
|
const ege::physics::shape::ConvexHull* tmpElement = it->toConvexHull();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" convexHull ==> can not cast in convexHull");
|
EGE_ERROR(" convexHull ==> can not cast in convexHull");
|
||||||
continue;
|
continue;
|
||||||
@ -311,15 +311,15 @@ void ege::physics::Component::setAngularVelocity(const vec3& _angularVelocity) {
|
|||||||
m_rigidBody->setAngularVelocity(value);
|
m_rigidBody->setAngularVelocity(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<ememory::SharedPtr<ege::PhysicsShape>>& ege::physics::Component::getShape() const {
|
const std::vector<ememory::SharedPtr<ege::physics::Shape>>& ege::physics::Component::getShape() const {
|
||||||
return m_shape;
|
return m_shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::physics::Component::setShape(const std::vector<ememory::SharedPtr<ege::PhysicsShape>>& _prop) {
|
void ege::physics::Component::setShape(const std::vector<ememory::SharedPtr<ege::physics::Shape>>& _prop) {
|
||||||
m_shape = _prop;
|
m_shape = _prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ege::physics::Component::addShape(const ememory::SharedPtr<ege::PhysicsShape>& _shape) {
|
void ege::physics::Component::addShape(const ememory::SharedPtr<ege::physics::Shape>& _shape) {
|
||||||
m_shape.push_back(_shape);
|
m_shape.push_back(_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,9 +337,9 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (it->getType()) {
|
switch (it->getType()) {
|
||||||
case ege::PhysicsShape::box: {
|
case ege::physics::Shape::type::box: {
|
||||||
EGE_DEBUG(" Box");
|
EGE_DEBUG(" Box");
|
||||||
const ege::PhysicsBox* tmpElement = it->toBox();
|
const ege::physics::shape::Box* tmpElement = it->toBox();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Box ==> can not cast in BOX");
|
EGE_ERROR(" Box ==> can not cast in BOX");
|
||||||
continue;
|
continue;
|
||||||
@ -352,9 +352,9 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
_draw->drawSquare(tmpElement->getSize(), transformationMatrixLocal, tmpColor);
|
_draw->drawSquare(tmpElement->getSize(), transformationMatrixLocal, tmpColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::cylinder : {
|
case ege::physics::Shape::type::cylinder : {
|
||||||
EGE_DEBUG(" Cylinder");
|
EGE_DEBUG(" Cylinder");
|
||||||
const ege::PhysicsCylinder* tmpElement = it->toCylinder();
|
const ege::physics::shape::Cylinder* tmpElement = it->toCylinder();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Cylinder ==> can not cast in Cylinder");
|
EGE_ERROR(" Cylinder ==> can not cast in Cylinder");
|
||||||
continue;
|
continue;
|
||||||
@ -367,9 +367,9 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
//_draw->drawSphere(radius, 10, 10, _transformationMatrix, tmpColor);
|
//_draw->drawSphere(radius, 10, 10, _transformationMatrix, tmpColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::capsule : {
|
case ege::physics::Shape::type::capsule : {
|
||||||
EGE_DEBUG(" Capsule");
|
EGE_DEBUG(" Capsule");
|
||||||
const ege::PhysicsCapsule* tmpElement = it->toCapsule();
|
const ege::physics::shape::Capsule* tmpElement = it->toCapsule();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Capsule ==> can not cast in Capsule");
|
EGE_ERROR(" Capsule ==> can not cast in Capsule");
|
||||||
continue;
|
continue;
|
||||||
@ -388,9 +388,9 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::cone : {
|
case ege::physics::Shape::type::cone : {
|
||||||
EGE_DEBUG(" Cone");
|
EGE_DEBUG(" Cone");
|
||||||
const ege::PhysicsCone* tmpElement = it->toCone();
|
const ege::physics::shape::Cone* tmpElement = it->toCone();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Cone ==> can not cast in Cone");
|
EGE_ERROR(" Cone ==> can not cast in Cone");
|
||||||
continue;
|
continue;
|
||||||
@ -409,9 +409,9 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::sphere : {
|
case ege::physics::Shape::type::sphere : {
|
||||||
EGE_DEBUG(" Sphere");
|
EGE_DEBUG(" Sphere");
|
||||||
const ege::PhysicsSphere* tmpElement = it->toSphere();
|
const ege::physics::shape::Sphere* tmpElement = it->toSphere();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Sphere ==> can not cast in Sphere");
|
EGE_ERROR(" Sphere ==> can not cast in Sphere");
|
||||||
continue;
|
continue;
|
||||||
@ -424,9 +424,9 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
_draw->drawSphere(tmpElement->getRadius(), 10, 10, transformationMatrixLocal, tmpColor);
|
_draw->drawSphere(tmpElement->getRadius(), 10, 10, transformationMatrixLocal, tmpColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::PhysicsShape::convexHull : {
|
case ege::physics::Shape::type::convexHull : {
|
||||||
EGE_DEBUG(" convexHull");
|
EGE_DEBUG(" convexHull");
|
||||||
const ege::PhysicsConvexHull* tmpElement = it->toConvexHull();
|
const ege::physics::shape::ConvexHull* tmpElement = it->toConvexHull();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" convexHull ==> can not cast in convexHull");
|
EGE_ERROR(" convexHull ==> can not cast in convexHull");
|
||||||
continue;
|
continue;
|
||||||
|
@ -79,11 +79,11 @@ namespace ege {
|
|||||||
*/
|
*/
|
||||||
void setAngularVelocity(const vec3& _angularVelocity);
|
void setAngularVelocity(const vec3& _angularVelocity);
|
||||||
protected:
|
protected:
|
||||||
std::vector<ememory::SharedPtr<ege::PhysicsShape>> m_shape; //!< collision shape module ... (independent of bullet lib)
|
std::vector<ememory::SharedPtr<ege::physics::Shape>> m_shape; //!< collision shape module ... (independent of bullet lib)
|
||||||
public:
|
public:
|
||||||
const std::vector<ememory::SharedPtr<ege::PhysicsShape>>& getShape() const;
|
const std::vector<ememory::SharedPtr<ege::physics::Shape>>& getShape() const;
|
||||||
void setShape(const std::vector<ememory::SharedPtr<ege::PhysicsShape>>& _prop);
|
void setShape(const std::vector<ememory::SharedPtr<ege::physics::Shape>>& _prop);
|
||||||
void addShape(const ememory::SharedPtr<ege::PhysicsShape>& _shape);
|
void addShape(const ememory::SharedPtr<ege::physics::Shape>& _shape);
|
||||||
void generate();
|
void generate();
|
||||||
void drawShape(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera);
|
void drawShape(ememory::SharedPtr<ewol::resource::Colored3DObject> _draw, ememory::SharedPtr<ege::Camera> _camera);
|
||||||
private:
|
private:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ege/elements/Element.hpp>
|
#include <ege/Entity.hpp>
|
||||||
#include <ege/physics/Engine.hpp>
|
#include <ege/physics/Engine.hpp>
|
||||||
|
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
@ -48,8 +48,8 @@ extern ContactProcessedCallback gContactProcessedCallback;
|
|||||||
|
|
||||||
// TODO : remove double collision call ...
|
// TODO : remove double collision call ...
|
||||||
static bool handleContactsProcess(btManifoldPoint& _point, btCollisionObject* _body0, btCollisionObject* _body1) {
|
static bool handleContactsProcess(btManifoldPoint& _point, btCollisionObject* _body0, btCollisionObject* _body1) {
|
||||||
ege::ElementPhysic* elem0 = static_cast<ege::ElementPhysic*>(_body0->getUserPointer());
|
ege::Entityhysic* elem0 = static_cast<ege::EntityPhysic*>(_body0->getUserPointer());
|
||||||
ege::ElementPhysic* elem1 = static_cast<ege::ElementPhysic*>(_body1->getUserPointer());
|
ege::EntityPhysic* elem1 = static_cast<ege::EntityPhysic*>(_body1->getUserPointer());
|
||||||
if ( elem0 == nullptr
|
if ( elem0 == nullptr
|
||||||
|| elem1 == nullptr) {
|
|| elem1 == nullptr) {
|
||||||
EGE_WARNING("callback of collision error");
|
EGE_WARNING("callback of collision error");
|
||||||
@ -151,8 +151,8 @@ std::vector<ege::physics::Engine::collisionPoints> ege::physics::Engine::getList
|
|||||||
|| obB == nullptr) {
|
|| obB == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ege::ElementPhysic* elem0 = static_cast<ege::ElementPhysic*>(obA->getUserPointer());
|
ege::EntityPhysic* elem0 = static_cast<ege::EntityPhysic*>(obA->getUserPointer());
|
||||||
ege::ElementPhysic* elem1 = static_cast<ege::ElementPhysic*>(obB->getUserPointer());
|
ege::EntityPhysic* elem1 = static_cast<ege::EntityPhysic*>(obB->getUserPointer());
|
||||||
if ( elem0 == nullptr
|
if ( elem0 == nullptr
|
||||||
|| elem1 == nullptr) {
|
|| elem1 == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <etk/math/Vector3D.hpp>
|
#include <etk/math/Vector3D.hpp>
|
||||||
#include <ege/physicsShape/PhysicsBox.hpp>
|
#include <ege/physics/shape/Box.hpp>
|
||||||
|
|
||||||
|
|
||||||
bool ege::PhysicsBox::parse(const char* _line) {
|
bool ege::physics::shape::Box::parse(const char* _line) {
|
||||||
if (ege::PhysicsShape::parse(_line) == true) {
|
if (ege::physics::Shape::parse(_line) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(strncmp(_line, "half-extents:", 13) == 0) {
|
if(strncmp(_line, "half-extents:", 13) == 0) {
|
46
ege/physics/shape/Box.hpp
Normal file
46
ege/physics/shape/Box.hpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <ege/physics/shape/Shape.hpp>
|
||||||
|
|
||||||
|
namespace ege {
|
||||||
|
namespace physics {
|
||||||
|
namespace shape {
|
||||||
|
class Box : public ege::physics::Shape {
|
||||||
|
public:
|
||||||
|
Box() {};
|
||||||
|
virtual ~Box() {};
|
||||||
|
public:
|
||||||
|
virtual bool parse(const char* _line);
|
||||||
|
virtual void display() {};
|
||||||
|
public:
|
||||||
|
virtual enum ege::physics::Shape::type getType() const {
|
||||||
|
return ege::physics::Shape::type::box;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
vec3 m_size; // Box size property in X, Y and Z
|
||||||
|
public:
|
||||||
|
const vec3& getSize() const {
|
||||||
|
return m_size;
|
||||||
|
};
|
||||||
|
void setSize(const vec3& _size) {
|
||||||
|
m_size = _size;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
virtual const ege::physics::shape::Box* toBox() const {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Box* toBox() {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,12 +4,12 @@
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCapsule.hpp>
|
#include <ege/physics/shape/Capsule.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ege::PhysicsCapsule::parse(const char* _line) {
|
bool ege::physics::shape::Capsule::parse(const char* _line) {
|
||||||
if (ege::PhysicsShape::parse(_line) == true) {
|
if (ege::physics::Shape::parse(_line) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(strncmp(_line, "radius:", 7) == 0) {
|
if(strncmp(_line, "radius:", 7) == 0) {
|
50
ege/physics/shape/Capsule.hpp
Normal file
50
ege/physics/shape/Capsule.hpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <ege/physics/shape/Shape.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace ege {
|
||||||
|
namespace physics {
|
||||||
|
namespace shape {
|
||||||
|
class Capsule : public ege::physics::Shape {
|
||||||
|
public:
|
||||||
|
Capsule() {};
|
||||||
|
virtual ~Capsule() {};
|
||||||
|
public:
|
||||||
|
virtual bool parse(const char* _line);
|
||||||
|
virtual void display() {};
|
||||||
|
public:
|
||||||
|
virtual enum ege::physics::Shape::type getType() const {
|
||||||
|
return ege::physics::Shape::type::capsule;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
float m_radius;
|
||||||
|
public:
|
||||||
|
float getRadius() const {
|
||||||
|
return m_radius;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
float m_height;
|
||||||
|
public:
|
||||||
|
float getHeight() const {
|
||||||
|
return m_height;
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
virtual const ege::physics::shape::Capsule* toCapsule() const {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Capsule* toCapsule() {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,12 +4,12 @@
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCone.hpp>
|
#include <ege/physics/shape/Cone.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ege::PhysicsCone::parse(const char* _line) {
|
bool ege::physics::shape::Cone::parse(const char* _line) {
|
||||||
if (ege::PhysicsShape::parse(_line) == true) {
|
if (ege::physics::Shape::parse(_line) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(strncmp(_line, "radius:", 7) == 0) {
|
if(strncmp(_line, "radius:", 7) == 0) {
|
48
ege/physics/shape/Cone.hpp
Normal file
48
ege/physics/shape/Cone.hpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <ege/physics/shape/Shape.hpp>
|
||||||
|
|
||||||
|
namespace ege {
|
||||||
|
namespace physics {
|
||||||
|
namespace shape {
|
||||||
|
class Cone : public ege::physics::Shape {
|
||||||
|
public:
|
||||||
|
Cone() {};
|
||||||
|
virtual ~Cone() {};
|
||||||
|
public:
|
||||||
|
virtual bool parse(const char* _line);
|
||||||
|
virtual void display() {};
|
||||||
|
public:
|
||||||
|
virtual enum ege::physics::Shape::type getType() const {
|
||||||
|
return ege::physics::Shape::type::cone;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
float m_radius;
|
||||||
|
public:
|
||||||
|
float getRadius() const {
|
||||||
|
return m_radius;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
float m_height;
|
||||||
|
public:
|
||||||
|
float getHeight() const {
|
||||||
|
return m_height;
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
virtual const ege::physics::shape::Cone* toCone() const {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Cone* toCone() {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,12 +4,12 @@
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/physicsShape/PhysicsConvexHull.hpp>
|
#include <ege/physics/shape/ConvexHull.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ege::PhysicsConvexHull::parse(const char* _line) {
|
bool ege::physics::shape::ConvexHull::parse(const char* _line) {
|
||||||
if (ege::PhysicsShape::parse(_line) == true) {
|
if (ege::physics::Shape::parse(_line) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(strncmp(_line, "points:", 6) == 0) {
|
if(strncmp(_line, "points:", 6) == 0) {
|
48
ege/physics/shape/ConvexHull.hpp
Normal file
48
ege/physics/shape/ConvexHull.hpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <ege/physics/shape/Shape.hpp>
|
||||||
|
|
||||||
|
namespace ege {
|
||||||
|
namespace physics {
|
||||||
|
namespace shape {
|
||||||
|
class ConvexHull : public ege::physics::Shape {
|
||||||
|
public:
|
||||||
|
ConvexHull() {};
|
||||||
|
virtual ~ConvexHull() {};
|
||||||
|
public:
|
||||||
|
virtual bool parse(const char* _line);
|
||||||
|
virtual void display() {};
|
||||||
|
public:
|
||||||
|
virtual enum ege::physics::Shape::type getType() const {
|
||||||
|
return ege::physics::Shape::type::convexHull;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
vec3 m_scale;
|
||||||
|
public:
|
||||||
|
vec3 getScale() const {
|
||||||
|
return m_scale;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
std::vector<vec3> m_points;
|
||||||
|
public:
|
||||||
|
const std::vector<vec3>& getPointList() const {
|
||||||
|
return m_points;
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
virtual const ege::physics::shape::ConvexHull* toConvexHull() const {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::ConvexHull* toConvexHull() {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,11 +4,11 @@
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCylinder.hpp>
|
#include <ege/physics/shape/Cylinder.hpp>
|
||||||
|
|
||||||
|
|
||||||
bool ege::PhysicsCylinder::parse(const char* _line) {
|
bool ege::physics::shape::Cylinder::parse(const char* _line) {
|
||||||
if (ege::PhysicsShape::parse(_line) == true) {
|
if (ege::physics::Shape::parse(_line) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(strncmp(_line, "half-extents:", 13) == 0) {
|
if(strncmp(_line, "half-extents:", 13) == 0) {
|
44
ege/physics/shape/Cylinder.hpp
Normal file
44
ege/physics/shape/Cylinder.hpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <ege/physics/shape/Shape.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace ege {
|
||||||
|
namespace physics {
|
||||||
|
namespace shape {
|
||||||
|
class Cylinder : public ege::physics::Shape {
|
||||||
|
public:
|
||||||
|
Cylinder() {};
|
||||||
|
virtual ~Cylinder() {};
|
||||||
|
public:
|
||||||
|
virtual bool parse(const char* _line);
|
||||||
|
virtual void display() {};
|
||||||
|
public:
|
||||||
|
virtual enum ege::physics::Shape::type getType() const {
|
||||||
|
return ege::physics::Shape::type::cylinder;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
vec3 m_size;
|
||||||
|
public:
|
||||||
|
vec3 getSize() const {
|
||||||
|
return m_size;
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
virtual const ege::physics::shape::Cylinder* toCylinder() const {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Cylinder* toCylinder() {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,30 +4,30 @@
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
#include <ege/physics/shape/Shape.hpp>
|
||||||
#include <ege/physicsShape/PhysicsBox.hpp>
|
#include <ege/physics/shape/Box.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCapsule.hpp>
|
#include <ege/physics/shape/Capsule.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCone.hpp>
|
#include <ege/physics/shape/Cone.hpp>
|
||||||
#include <ege/physicsShape/PhysicsConvexHull.hpp>
|
#include <ege/physics/shape/ConvexHull.hpp>
|
||||||
#include <ege/physicsShape/PhysicsCylinder.hpp>
|
#include <ege/physics/shape/Cylinder.hpp>
|
||||||
#include <ege/physicsShape/PhysicsSphere.hpp>
|
#include <ege/physics/shape/Sphere.hpp>
|
||||||
|
|
||||||
|
|
||||||
ememory::SharedPtr<ege::PhysicsShape> ege::PhysicsShape::create(const std::string& _name) {
|
ememory::SharedPtr<ege::physics::Shape> ege::physics::Shape::create(const std::string& _name) {
|
||||||
ememory::SharedPtr<ege::PhysicsShape> tmpp = nullptr;
|
ememory::SharedPtr<ege::physics::Shape> tmpp = nullptr;
|
||||||
std::string name = etk::tolower(_name);
|
std::string name = etk::tolower(_name);
|
||||||
if (name == "box") {
|
if (name == "box") {
|
||||||
tmpp = ememory::makeShared<ege::PhysicsBox>();
|
tmpp = ememory::makeShared<ege::physics::shape::Box>();
|
||||||
} else if (name == "sphere") {
|
} else if (name == "sphere") {
|
||||||
tmpp = ememory::makeShared<ege::PhysicsSphere>();
|
tmpp = ememory::makeShared<ege::physics::shape::Sphere>();
|
||||||
} else if (name == "cone") {
|
} else if (name == "cone") {
|
||||||
tmpp = ememory::makeShared<ege::PhysicsCone>();
|
tmpp = ememory::makeShared<ege::physics::shape::Cone>();
|
||||||
} else if (name == "cylinder") {
|
} else if (name == "cylinder") {
|
||||||
tmpp = ememory::makeShared<ege::PhysicsCylinder>();
|
tmpp = ememory::makeShared<ege::physics::shape::Cylinder>();
|
||||||
} else if (name == "capsule") {
|
} else if (name == "capsule") {
|
||||||
tmpp = ememory::makeShared<ege::PhysicsCapsule>();
|
tmpp = ememory::makeShared<ege::physics::shape::Capsule>();
|
||||||
} else if (name == "convexhull") {
|
} else if (name == "convexhull") {
|
||||||
tmpp = ememory::makeShared<ege::PhysicsConvexHull>();
|
tmpp = ememory::makeShared<ege::physics::shape::ConvexHull>();
|
||||||
} else {
|
} else {
|
||||||
EGE_ERROR("Create an unknow element : '" << _name << "' availlable : [BOX,SPHERE,CONE,CYLINDER,CAPSULE,CONVEXHULL]");
|
EGE_ERROR("Create an unknow element : '" << _name << "' availlable : [BOX,SPHERE,CONE,CYLINDER,CAPSULE,CONVEXHULL]");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -39,7 +39,7 @@ ememory::SharedPtr<ege::PhysicsShape> ege::PhysicsShape::create(const std::strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ege::PhysicsShape::parse(const char* _line) {
|
bool ege::physics::Shape::parse(const char* _line) {
|
||||||
if(strncmp(_line, "origin:", 7) == 0) {
|
if(strncmp(_line, "origin:", 7) == 0) {
|
||||||
sscanf(&_line[7], "%f %f %f", &m_origin.m_floats[0], &m_origin.m_floats[1], &m_origin.m_floats[2] );
|
sscanf(&_line[7], "%f %f %f", &m_origin.m_floats[0], &m_origin.m_floats[1], &m_origin.m_floats[2] );
|
||||||
EGE_VERBOSE(" Origin=" << m_origin);
|
EGE_VERBOSE(" Origin=" << m_origin);
|
145
ege/physics/shape/Shape.hpp
Normal file
145
ege/physics/shape/Shape.hpp
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <etk/math/Vector4D.hpp>
|
||||||
|
#include <etk/math/Vector3D.hpp>
|
||||||
|
#include <etk/math/Quaternion.hpp>
|
||||||
|
#include <ememory/memory.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace ege {
|
||||||
|
namespace physics {
|
||||||
|
namespace shape {
|
||||||
|
class Box;
|
||||||
|
class Cylinder;
|
||||||
|
class Capsule;
|
||||||
|
class Cone;
|
||||||
|
class ConvexHull;
|
||||||
|
class Sphere;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Shape {
|
||||||
|
public:
|
||||||
|
static ememory::SharedPtr<ege::physics::Shape> create(const std::string& _name);
|
||||||
|
public:
|
||||||
|
enum class type {
|
||||||
|
unknow,
|
||||||
|
box,
|
||||||
|
capsule,
|
||||||
|
cone,
|
||||||
|
convexHull,
|
||||||
|
cylinder,
|
||||||
|
sphere
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
Shape() :
|
||||||
|
m_quaternion(1,0,0,0),
|
||||||
|
m_origin(0,0,0),
|
||||||
|
m_mass(1) { // by default set mass at 1g
|
||||||
|
|
||||||
|
}
|
||||||
|
virtual ~Shape() = default;
|
||||||
|
public:
|
||||||
|
virtual enum ege::physics::Shape::type getType() const {
|
||||||
|
return ege::physics::Shape::type::unknow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool parse(const char* _line);
|
||||||
|
virtual void display() {
|
||||||
|
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
vec4 m_quaternion;
|
||||||
|
public:
|
||||||
|
const vec4& getQuaternion() const {
|
||||||
|
return m_quaternion;
|
||||||
|
}
|
||||||
|
etk::Quaternion getOrientation() const {
|
||||||
|
return etk::Quaternion(m_quaternion.x(), m_quaternion.y(), m_quaternion.z(), m_quaternion.w());
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
vec3 m_origin;
|
||||||
|
public:
|
||||||
|
const vec3& getOrigin() const {
|
||||||
|
return m_origin;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
float m_mass; //!< element mass in "g" then 1000 for 1kg
|
||||||
|
public:
|
||||||
|
float getMass() const {
|
||||||
|
return m_mass;
|
||||||
|
}
|
||||||
|
void setMass(float _mass) {
|
||||||
|
m_mass = _mass;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
bool isBox() {
|
||||||
|
return getType() == ege::physics::Shape::type::box;
|
||||||
|
};
|
||||||
|
bool isCylinder() {
|
||||||
|
return getType() == ege::physics::Shape::type::cylinder;
|
||||||
|
};
|
||||||
|
bool isCapsule() {
|
||||||
|
return getType() == ege::physics::Shape::type::capsule;
|
||||||
|
};
|
||||||
|
bool isCone() {
|
||||||
|
return getType() == ege::physics::Shape::type::cone;
|
||||||
|
};
|
||||||
|
bool isConvexHull() {
|
||||||
|
return getType() == ege::physics::Shape::type::convexHull;
|
||||||
|
};
|
||||||
|
bool isSphere() {
|
||||||
|
return getType() == ege::physics::Shape::type::sphere;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual const ege::physics::shape::Box* toBox() const {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Box* toBox() {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual const ege::physics::shape::Cylinder* toCylinder() const {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Cylinder* toCylinder() {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual const ege::physics::shape::Capsule* toCapsule() const {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Capsule* toCapsule() {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual const ege::physics::shape::Cone* toCone() const {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Cone* toCone() {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual const ege::physics::shape::ConvexHull* toConvexHull() const {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::ConvexHull* toConvexHull() {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual const ege::physics::shape::Sphere* toSphere() const {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Sphere* toSphere() {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,12 +4,12 @@
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/physicsShape/PhysicsSphere.hpp>
|
#include <ege/physics/shape/Sphere.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ege::PhysicsSphere::parse(const char* _line) {
|
bool ege::physics::shape::Sphere::parse(const char* _line) {
|
||||||
if (ege::PhysicsShape::parse(_line) == true) {
|
if (ege::physics::Shape::parse(_line) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(strncmp(_line, "radius:", 7) == 0) {
|
if(strncmp(_line, "radius:", 7) == 0) {
|
47
ege/physics/shape/Sphere.hpp
Normal file
47
ege/physics/shape/Sphere.hpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <ege/physics/shape/Shape.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace ege {
|
||||||
|
namespace physics {
|
||||||
|
namespace shape {
|
||||||
|
class Sphere : public ege::physics::Shape {
|
||||||
|
public:
|
||||||
|
Sphere() {};
|
||||||
|
virtual ~Sphere() {};
|
||||||
|
public:
|
||||||
|
virtual bool parse(const char* _line);
|
||||||
|
virtual void display() {};
|
||||||
|
public:
|
||||||
|
virtual enum ege::physics::Shape::type getType() const {
|
||||||
|
return ege::physics::Shape::type::sphere;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
float m_radius; // props["radius"] = obj.scale.x
|
||||||
|
public:
|
||||||
|
float getRadius() const {
|
||||||
|
return m_radius;
|
||||||
|
};
|
||||||
|
void setRadius(float _radius) {
|
||||||
|
m_radius = _radius;
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
virtual const ege::physics::shape::Sphere* toSphere() const {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
virtual ege::physics::shape::Sphere* toSphere() {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,42 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
|
||||||
|
|
||||||
namespace ege {
|
|
||||||
class PhysicsBox : public ege::PhysicsShape {
|
|
||||||
public:
|
|
||||||
PhysicsBox() {};
|
|
||||||
virtual ~PhysicsBox() {};
|
|
||||||
public:
|
|
||||||
virtual bool parse(const char* _line);
|
|
||||||
virtual void display() {};
|
|
||||||
public:
|
|
||||||
virtual enum ege::PhysicsShape::type getType() const {
|
|
||||||
return ege::PhysicsShape::box;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
vec3 m_size; // Box size property in X, Y and Z
|
|
||||||
public:
|
|
||||||
const vec3& getSize() const {
|
|
||||||
return m_size;
|
|
||||||
};
|
|
||||||
void setSize(const vec3& _size) {
|
|
||||||
m_size = _size;
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
virtual const ege::PhysicsBox* toBox() const {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsBox* toBox() {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace ege {
|
|
||||||
class PhysicsCapsule : public ege::PhysicsShape {
|
|
||||||
public:
|
|
||||||
PhysicsCapsule() {};
|
|
||||||
virtual ~PhysicsCapsule() {};
|
|
||||||
public:
|
|
||||||
virtual bool parse(const char* _line);
|
|
||||||
virtual void display() {};
|
|
||||||
public:
|
|
||||||
virtual enum ege::PhysicsShape::type getType() const {
|
|
||||||
return ege::PhysicsShape::capsule;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
float m_radius;
|
|
||||||
public:
|
|
||||||
float getRadius() const {
|
|
||||||
return m_radius;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
float m_height;
|
|
||||||
public:
|
|
||||||
float getHeight() const {
|
|
||||||
return m_height;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
virtual const ege::PhysicsCapsule* toCapsule() const {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsCapsule* toCapsule() {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
|
||||||
|
|
||||||
namespace ege {
|
|
||||||
class PhysicsCone : public ege::PhysicsShape {
|
|
||||||
public:
|
|
||||||
PhysicsCone() {};
|
|
||||||
virtual ~PhysicsCone() {};
|
|
||||||
public:
|
|
||||||
virtual bool parse(const char* _line);
|
|
||||||
virtual void display() {};
|
|
||||||
public:
|
|
||||||
virtual enum ege::PhysicsShape::type getType() const {
|
|
||||||
return ege::PhysicsShape::cone;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
float m_radius;
|
|
||||||
public:
|
|
||||||
float getRadius() const {
|
|
||||||
return m_radius;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
float m_height;
|
|
||||||
public:
|
|
||||||
float getHeight() const {
|
|
||||||
return m_height;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
virtual const ege::PhysicsCone* toCone() const {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsCone* toCone() {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
|
||||||
|
|
||||||
namespace ege {
|
|
||||||
class PhysicsConvexHull : public ege::PhysicsShape {
|
|
||||||
public:
|
|
||||||
PhysicsConvexHull() {};
|
|
||||||
virtual ~PhysicsConvexHull() {};
|
|
||||||
public:
|
|
||||||
virtual bool parse(const char* _line);
|
|
||||||
virtual void display() {};
|
|
||||||
public:
|
|
||||||
virtual enum ege::PhysicsShape::type getType() const {
|
|
||||||
return ege::PhysicsShape::convexHull;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
vec3 m_scale;
|
|
||||||
public:
|
|
||||||
vec3 getScale() const {
|
|
||||||
return m_scale;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
std::vector<vec3> m_points;
|
|
||||||
public:
|
|
||||||
const std::vector<vec3>& getPointList() const {
|
|
||||||
return m_points;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
virtual const ege::PhysicsConvexHull* toConvexHull() const {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsConvexHull* toConvexHull() {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace ege {
|
|
||||||
class PhysicsCylinder : public ege::PhysicsShape {
|
|
||||||
public:
|
|
||||||
PhysicsCylinder() {};
|
|
||||||
virtual ~PhysicsCylinder() {};
|
|
||||||
public:
|
|
||||||
virtual bool parse(const char* _line);
|
|
||||||
virtual void display() {};
|
|
||||||
public:
|
|
||||||
virtual enum ege::PhysicsShape::type getType() const {
|
|
||||||
return ege::PhysicsShape::cylinder;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
vec3 m_size;
|
|
||||||
public:
|
|
||||||
vec3 getSize() const {
|
|
||||||
return m_size;
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
virtual const ege::PhysicsCylinder* toCylinder() const {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsCylinder* toCylinder() {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,143 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
|
||||||
#include <etk/math/Vector4D.hpp>
|
|
||||||
#include <etk/math/Vector3D.hpp>
|
|
||||||
#include <etk/math/Quaternion.hpp>
|
|
||||||
#include <ememory/memory.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace ege {
|
|
||||||
class PhysicsBox;
|
|
||||||
class PhysicsCylinder;
|
|
||||||
class PhysicsCapsule;
|
|
||||||
class PhysicsCone;
|
|
||||||
class PhysicsConvexHull;
|
|
||||||
class PhysicsSphere;
|
|
||||||
|
|
||||||
class PhysicsShape {
|
|
||||||
public:
|
|
||||||
static ememory::SharedPtr<ege::PhysicsShape> create(const std::string& _name);
|
|
||||||
public:
|
|
||||||
enum type {
|
|
||||||
unknow,
|
|
||||||
box,
|
|
||||||
capsule,
|
|
||||||
cone,
|
|
||||||
convexHull,
|
|
||||||
cylinder,
|
|
||||||
sphere
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
PhysicsShape() :
|
|
||||||
m_quaternion(1,0,0,0),
|
|
||||||
m_origin(0,0,0),
|
|
||||||
m_mass(1) { // by default set mass at 1g
|
|
||||||
|
|
||||||
}
|
|
||||||
virtual ~PhysicsShape() {
|
|
||||||
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
virtual enum ege::PhysicsShape::type getType() const {
|
|
||||||
return ege::PhysicsShape::unknow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual bool parse(const char* _line);
|
|
||||||
virtual void display() {
|
|
||||||
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
vec4 m_quaternion;
|
|
||||||
public:
|
|
||||||
const vec4& getQuaternion() const {
|
|
||||||
return m_quaternion;
|
|
||||||
}
|
|
||||||
etk::Quaternion getOrientation() const {
|
|
||||||
return etk::Quaternion(m_quaternion.x(), m_quaternion.y(), m_quaternion.z(), m_quaternion.w());
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
vec3 m_origin;
|
|
||||||
public:
|
|
||||||
const vec3& getOrigin() const {
|
|
||||||
return m_origin;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
float m_mass; //!< element mass in "g" then 1000 for 1kg
|
|
||||||
public:
|
|
||||||
float getMass() const {
|
|
||||||
return m_mass;
|
|
||||||
}
|
|
||||||
void setMass(float _mass) {
|
|
||||||
m_mass = _mass;
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
bool isBox() {
|
|
||||||
return getType() == ege::PhysicsShape::box;
|
|
||||||
};
|
|
||||||
bool isCylinder() {
|
|
||||||
return getType() == ege::PhysicsShape::cylinder;
|
|
||||||
};
|
|
||||||
bool isCapsule() {
|
|
||||||
return getType() == ege::PhysicsShape::capsule;
|
|
||||||
};
|
|
||||||
bool isCone() {
|
|
||||||
return getType() == ege::PhysicsShape::cone;
|
|
||||||
};
|
|
||||||
bool isConvexHull() {
|
|
||||||
return getType() == ege::PhysicsShape::convexHull;
|
|
||||||
};
|
|
||||||
bool isSphere() {
|
|
||||||
return getType() == ege::PhysicsShape::sphere;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual const ege::PhysicsBox* toBox() const {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsBox* toBox() {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual const ege::PhysicsCylinder* toCylinder() const {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsCylinder* toCylinder() {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual const ege::PhysicsCapsule* toCapsule() const {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsCapsule* toCapsule() {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual const ege::PhysicsCone* toCone() const {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsCone* toCone() {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual const ege::PhysicsConvexHull* toConvexHull() const {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsConvexHull* toConvexHull() {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual const ege::PhysicsSphere* toSphere() const {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsSphere* toSphere() {
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
* @license MPL v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace ege {
|
|
||||||
class PhysicsSphere : public ege::PhysicsShape {
|
|
||||||
public:
|
|
||||||
PhysicsSphere() {};
|
|
||||||
virtual ~PhysicsSphere() {};
|
|
||||||
public:
|
|
||||||
virtual bool parse(const char* _line);
|
|
||||||
virtual void display() {};
|
|
||||||
public:
|
|
||||||
virtual enum ege::PhysicsShape::type getType() const {
|
|
||||||
return ege::PhysicsShape::sphere;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
float m_radius; // props["radius"] = obj.scale.x
|
|
||||||
public:
|
|
||||||
float getRadius() const {
|
|
||||||
return m_radius;
|
|
||||||
};
|
|
||||||
void setRadius(float _radius) {
|
|
||||||
m_radius = _radius;
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
virtual const ege::PhysicsSphere* toSphere() const {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
virtual ege::PhysicsSphere* toSphere() {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
|||||||
#include <ege/resource/tools/Face.hpp>
|
#include <ege/resource/tools/Face.hpp>
|
||||||
#include <ege/resource/tools/FaceIndexing.hpp>
|
#include <ege/resource/tools/FaceIndexing.hpp>
|
||||||
|
|
||||||
#include <ege/physicsShape/PhysicsShape.hpp>
|
#include <ege/physics/shape/Shape.hpp>
|
||||||
// VBO table property:
|
// VBO table property:
|
||||||
#define MESH_VBO_VERTICES (0)
|
#define MESH_VBO_VERTICES (0)
|
||||||
#define MESH_VBO_TEXTURE (1)
|
#define MESH_VBO_TEXTURE (1)
|
||||||
@ -80,7 +80,7 @@ namespace ege {
|
|||||||
std::vector<vec3> m_listVertexNormal; //!< List of all Face normal, when calculated
|
std::vector<vec3> m_listVertexNormal; //!< List of all Face normal, when calculated
|
||||||
etk::Hash<FaceIndexing> m_listFaces; //!< List of all Face for the mesh
|
etk::Hash<FaceIndexing> m_listFaces; //!< List of all Face for the mesh
|
||||||
etk::Hash<ememory::SharedPtr<ege::Material>> m_materials;
|
etk::Hash<ememory::SharedPtr<ege::Material>> m_materials;
|
||||||
std::vector<ememory::SharedPtr<ege::PhysicsShape>> m_physics; //!< collision shape module ... (independent of bullet lib)
|
std::vector<ememory::SharedPtr<ege::physics::Shape>> m_physics; //!< collision shape module ... (independent of bullet lib)
|
||||||
void clean();
|
void clean();
|
||||||
protected:
|
protected:
|
||||||
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_verticesVBO;
|
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_verticesVBO;
|
||||||
@ -131,10 +131,10 @@ namespace ege {
|
|||||||
bool getCheckNormal() {
|
bool getCheckNormal() {
|
||||||
return m_checkNormal;
|
return m_checkNormal;
|
||||||
};
|
};
|
||||||
const std::vector<ememory::SharedPtr<ege::PhysicsShape>>& getPhysicalProperties() const {
|
const std::vector<ememory::SharedPtr<ege::physics::Shape>>& getPhysicalProperties() const {
|
||||||
return m_physics;
|
return m_physics;
|
||||||
};
|
};
|
||||||
void addPhysicElement(const ememory::SharedPtr<ege::PhysicsShape>& _shape) {
|
void addPhysicElement(const ememory::SharedPtr<ege::physics::Shape>& _shape) {
|
||||||
m_physics.push_back(_shape);
|
m_physics.push_back(_shape);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
@ -174,7 +174,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
|||||||
std::string materialName = "";
|
std::string materialName = "";
|
||||||
ememory::SharedPtr<ege::Material> material;
|
ememory::SharedPtr<ege::Material> material;
|
||||||
// physical shape:
|
// physical shape:
|
||||||
ememory::SharedPtr<ege::PhysicsShape> physics;
|
ememory::SharedPtr<ege::physics::Shape> physics;
|
||||||
bool haveUVMapping = false;
|
bool haveUVMapping = false;
|
||||||
size_t offsetVertexId = 0;
|
size_t offsetVertexId = 0;
|
||||||
size_t offsetUV = 0;
|
size_t offsetUV = 0;
|
||||||
@ -435,7 +435,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
|||||||
}
|
}
|
||||||
removeEndLine(inputDataLine);
|
removeEndLine(inputDataLine);
|
||||||
if (level == 2) {
|
if (level == 2) {
|
||||||
physics = ege::PhysicsShape::create(inputDataLine);
|
physics = ege::physics::Shape::create(inputDataLine);
|
||||||
if (physics == nullptr) {
|
if (physics == nullptr) {
|
||||||
EGE_ERROR("Allocation error when creating physical shape ...");
|
EGE_ERROR("Allocation error when creating physical shape ...");
|
||||||
continue;
|
continue;
|
||||||
@ -532,7 +532,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
|||||||
removeEndLine(inputDataLine);
|
removeEndLine(inputDataLine);
|
||||||
if (level == 1) {
|
if (level == 1) {
|
||||||
EGE_ERROR("Load shape : " << inputDataLine);
|
EGE_ERROR("Load shape : " << inputDataLine);
|
||||||
physics = ege::PhysicsShape::create(inputDataLine);
|
physics = ege::physics::Shape::create(inputDataLine);
|
||||||
if (physics == nullptr) {
|
if (physics == nullptr) {
|
||||||
EGE_ERROR("Allocation error when creating physical shape ...");
|
EGE_ERROR("Allocation error when creating physical shape ...");
|
||||||
continue;
|
continue;
|
||||||
|
@ -23,7 +23,7 @@ namespace etk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ege::widget::Scene::Scene() :
|
ege::widget::Scene::Scene() :
|
||||||
signalDisplayDebug(this, "drawDebug", "Call to draw debug after all elements"),
|
signalDisplayDebug(this, "drawDebug", "Call to draw debug after all entitys"),
|
||||||
propertyDebugPhysic(this, "debugPhysic",
|
propertyDebugPhysic(this, "debugPhysic",
|
||||||
false,
|
false,
|
||||||
"Display debug of the physic interface"),
|
"Display debug of the physic interface"),
|
||||||
@ -73,75 +73,6 @@ void ege::widget::Scene::onDraw() {
|
|||||||
#endif
|
#endif
|
||||||
gale::openGL::clearColor(etk::color::black);
|
gale::openGL::clearColor(etk::color::black);
|
||||||
m_env->render(echrono::Duration(1.0/60.0), m_cameraName);
|
m_env->render(echrono::Duration(1.0/60.0), m_cameraName);
|
||||||
#if 0
|
|
||||||
// draw constant object:
|
|
||||||
{
|
|
||||||
mat4 tmpMatrix;
|
|
||||||
for (auto &it : m_env->getStaticMeshToDraw()) {
|
|
||||||
if (it != nullptr) {
|
|
||||||
it->draw(tmpMatrix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get camera:
|
|
||||||
ememory::SharedPtr<ege::Camera> camera = m_env->getCamera(m_cameraName);
|
|
||||||
if (camera == nullptr) {
|
|
||||||
EGE_ERROR(" can not get camera named: '" << m_cameraName << "'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//EGE_DEBUG("Draw (start)");
|
|
||||||
mat4 tmpMatrix;
|
|
||||||
m_env->getOrderedElementForDisplay(m_displayElementOrdered, camera->getEye(), camera->getViewVector());
|
|
||||||
EGE_VERBOSE("DRAW : " << m_displayElementOrdered.size() << "/" << m_env->getElement().size() << " elements");
|
|
||||||
|
|
||||||
// TODO : remove this == > no more needed ==> checked in the generate the list of the element ordered
|
|
||||||
for (size_t iii=0; iii<m_displayElementOrdered.size(); iii++) {
|
|
||||||
m_displayElementOrdered[iii].element->preCalculationDraw(*camera);
|
|
||||||
}
|
|
||||||
// note : the first pass is done at the reverse way to prevent multiple display od the same point in the screen
|
|
||||||
// (and we remember that the first pass is to display all the non transparent elements)
|
|
||||||
for (int32_t iii=m_displayElementOrdered.size()-1; iii >= 0; iii--) {
|
|
||||||
m_displayElementOrdered[iii].element->draw(0);
|
|
||||||
}
|
|
||||||
// for the other pass the user can draw transparent elements ...
|
|
||||||
for (int32_t pass=1; pass <= NUMBER_OF_SUB_PASS+1; pass++) {
|
|
||||||
for (size_t iii=0; iii<m_displayElementOrdered.size(); iii++) {
|
|
||||||
m_displayElementOrdered[iii].element->draw(pass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (propertyDebugPhysic.get() == true) {
|
|
||||||
// Draw debug ... (Object)
|
|
||||||
for (int32_t iii=m_displayElementOrdered.size()-1; iii >= 0; iii--) {
|
|
||||||
m_displayElementOrdered[iii].element->drawDebug(m_debugDrawProperty, camera);
|
|
||||||
}
|
|
||||||
// Draw debug ... (Camera)
|
|
||||||
/*
|
|
||||||
std::map<std::string, ememory::SharedPtr<ege::Camera>> listCamera = m_env->getCameraList();
|
|
||||||
for (auto &itCam : listCamera) {
|
|
||||||
if (itCam.second != nullptr) {
|
|
||||||
itCam.second->drawDebug(m_debugDrawProperty, camera);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
if (propertyDebugNormal.get() == true) {
|
|
||||||
// Draw debug ... (Object)
|
|
||||||
for (int32_t iii=m_displayElementOrdered.size()-1; iii >= 0; iii--) {
|
|
||||||
m_displayElementOrdered[iii].element->drawNormalDebug(m_debugDrawProperty, camera);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (propertyDebugApplication.get() == true) {
|
|
||||||
// Draw debug ... (User)
|
|
||||||
signalDisplayDebug.emit(m_debugDrawProperty);
|
|
||||||
}
|
|
||||||
/* TODO: set it back ...
|
|
||||||
if (camera != nullptr) {
|
|
||||||
m_env->getParticuleEngine().draw(*camera);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
#ifdef SCENE_DISPLAY_SPEED
|
#ifdef SCENE_DISPLAY_SPEED
|
||||||
echrono::Duration localTime = echrono::Steady::now() - g_startTime;
|
echrono::Duration localTime = echrono::Steady::now() - g_startTime;
|
||||||
if (localTime>1) {
|
if (localTime>1) {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <ewol/widget/Widget.hpp>
|
#include <ewol/widget/Widget.hpp>
|
||||||
#include <gale/renderer/openGL/openGL.hpp>
|
#include <gale/renderer/openGL/openGL.hpp>
|
||||||
#include <gale/resource/Manager.hpp>
|
#include <gale/resource/Manager.hpp>
|
||||||
#include <ege/elements/Element.hpp>
|
#include <ege/Entity.hpp>
|
||||||
#include <gale/Dimension.hpp>
|
#include <gale/Dimension.hpp>
|
||||||
#include <ewol/widget/Widget.hpp>
|
#include <ewol/widget/Widget.hpp>
|
||||||
#include <esignal/Signal.hpp>
|
#include <esignal/Signal.hpp>
|
||||||
@ -66,8 +66,8 @@ namespace ege {
|
|||||||
return m_cameraName;
|
return m_cameraName;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
// Note : This is only for temporary elements : on the display
|
// Note : This is only for temporary entitys : on the display
|
||||||
std::vector<ege::Environement::ResultNearestElement> m_displayElementOrdered;
|
std::vector<ege::Environement::ResultNearestEntity> m_displayEntityOrdered;
|
||||||
protected:
|
protected:
|
||||||
esignal::Connection m_PCH; //!< Periodic call handle to remove it when needed
|
esignal::Connection m_PCH; //!< Periodic call handle to remove it when needed
|
||||||
/**
|
/**
|
||||||
|
32
lutin_ege.py
32
lutin_ege.py
@ -36,7 +36,7 @@ def configure(target, my_module):
|
|||||||
'ege/position/Component.cpp',
|
'ege/position/Component.cpp',
|
||||||
'ege/physics/Component.cpp',
|
'ege/physics/Component.cpp',
|
||||||
'ege/physics/Engine.cpp',
|
'ege/physics/Engine.cpp',
|
||||||
'ege/elements/Element.cpp',
|
'ege/Entity.cpp',
|
||||||
#'ege/elements/ElementBase.cpp',
|
#'ege/elements/ElementBase.cpp',
|
||||||
#'ege/elements/ElementPhysic.cpp',
|
#'ege/elements/ElementPhysic.cpp',
|
||||||
'ege/particule/Component.cpp',
|
'ege/particule/Component.cpp',
|
||||||
@ -61,13 +61,13 @@ def configure(target, my_module):
|
|||||||
'ege/resource/tools/viewBox.cpp',
|
'ege/resource/tools/viewBox.cpp',
|
||||||
'ege/Light.cpp',
|
'ege/Light.cpp',
|
||||||
'ege/Material.cpp',
|
'ege/Material.cpp',
|
||||||
'ege/physicsShape/PhysicsShape.cpp',
|
'ege/physics/shape/Shape.cpp',
|
||||||
'ege/physicsShape/PhysicsBox.cpp',
|
'ege/physics/shape/Box.cpp',
|
||||||
'ege/physicsShape/PhysicsCapsule.cpp',
|
'ege/physics/shape/Capsule.cpp',
|
||||||
'ege/physicsShape/PhysicsCone.cpp',
|
'ege/physics/shape/Cone.cpp',
|
||||||
'ege/physicsShape/PhysicsConvexHull.cpp',
|
'ege/physics/shape/ConvexHull.cpp',
|
||||||
'ege/physicsShape/PhysicsCylinder.cpp',
|
'ege/physics/shape/Cylinder.cpp',
|
||||||
'ege/physicsShape/PhysicsSphere.cpp',
|
'ege/physics/shape/Sphere.cpp',
|
||||||
'ege/Ray.cpp',
|
'ege/Ray.cpp',
|
||||||
])
|
])
|
||||||
my_module.copy_path('data/ParticuleMesh.*')
|
my_module.copy_path('data/ParticuleMesh.*')
|
||||||
@ -88,7 +88,7 @@ def configure(target, my_module):
|
|||||||
'ege/position/Component.hpp',
|
'ege/position/Component.hpp',
|
||||||
'ege/physics/Engine.hpp',
|
'ege/physics/Engine.hpp',
|
||||||
'ege/physics/Component.hpp',
|
'ege/physics/Component.hpp',
|
||||||
'ege/elements/Element.hpp',
|
'ege/Entity.hpp',
|
||||||
#'ege/elements/ElementBase.hpp',
|
#'ege/elements/ElementBase.hpp',
|
||||||
#'ege/elements/ElementPhysic.hpp',
|
#'ege/elements/ElementPhysic.hpp',
|
||||||
'ege/particule/Component.hpp',
|
'ege/particule/Component.hpp',
|
||||||
@ -109,13 +109,13 @@ def configure(target, my_module):
|
|||||||
'ege/resource/tools/FaceIndexing.hpp',
|
'ege/resource/tools/FaceIndexing.hpp',
|
||||||
'ege/Light.hpp',
|
'ege/Light.hpp',
|
||||||
'ege/Material.hpp',
|
'ege/Material.hpp',
|
||||||
'ege/physicsShape/PhysicsShape.hpp',
|
'ege/physics/shape/Shape.hpp',
|
||||||
'ege/physicsShape/PhysicsBox.hpp',
|
'ege/physics/shape/Box.hpp',
|
||||||
'ege/physicsShape/PhysicsCapsule.hpp',
|
'ege/physics/shape/Capsule.hpp',
|
||||||
'ege/physicsShape/PhysicsCone.hpp',
|
'ege/physics/shape/Cone.hpp',
|
||||||
'ege/physicsShape/PhysicsConvexHull.hpp',
|
'ege/physics/shape/ConvexHull.hpp',
|
||||||
'ege/physicsShape/PhysicsCylinder.hpp',
|
'ege/physics/shape/Cylinder.hpp',
|
||||||
'ege/physicsShape/PhysicsSphere.hpp',
|
'ege/physics/shape/Sphere.hpp',
|
||||||
'ege/Ray.hpp',
|
'ege/Ray.hpp',
|
||||||
])
|
])
|
||||||
# TODO: Remove this ...
|
# TODO: Remove this ...
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
#include <ege/widget/Scene.hpp>
|
#include <ege/widget/Scene.hpp>
|
||||||
#include <ege/camera/View.hpp>
|
#include <ege/camera/View.hpp>
|
||||||
#include <etk/tool.hpp>
|
#include <etk/tool.hpp>
|
||||||
#include <ege/elements/Element.hpp>
|
#include <ege/Entity.hpp>
|
||||||
#include <ege/physicsShape/PhysicsBox.hpp>
|
#include <ege/physics/shape/Box.hpp>
|
||||||
#include <ege/physicsShape/PhysicsSphere.hpp>
|
#include <ege/physics/shape/Sphere.hpp>
|
||||||
#include <ege/position/Component.hpp>
|
#include <ege/position/Component.hpp>
|
||||||
#include <ege/render/Component.hpp>
|
#include <ege/render/Component.hpp>
|
||||||
#include <ege/physics/Component.hpp>
|
#include <ege/physics/Component.hpp>
|
||||||
@ -99,7 +99,7 @@ void appl::Windows::init() {
|
|||||||
// Create an external box: (no physics)
|
// Create an external box: (no physics)
|
||||||
myMesh = createViewBoxStar();
|
myMesh = createViewBoxStar();
|
||||||
if (myMesh != nullptr) {
|
if (myMesh != nullptr) {
|
||||||
ememory::SharedPtr<ege::Element> element = ememory::makeShared<ege::Element>(m_env);
|
ememory::SharedPtr<ege::Entity> element = ememory::makeShared<ege::Entity>(m_env);
|
||||||
// 1st Position component:
|
// 1st Position component:
|
||||||
etk::Transform3D transform(vec3(0,0,0), etk::Quaternion::identity());
|
etk::Transform3D transform(vec3(0,0,0), etk::Quaternion::identity());
|
||||||
ememory::SharedPtr<ege::position::Component> componentPosition = ememory::makeShared<ege::position::Component>(transform);
|
ememory::SharedPtr<ege::position::Component> componentPosition = ememory::makeShared<ege::position::Component>(transform);
|
||||||
@ -108,12 +108,12 @@ void appl::Windows::init() {
|
|||||||
ememory::SharedPtr<ege::render::Component> componentRender = ememory::makeShared<ege::render::Component>(myMesh);
|
ememory::SharedPtr<ege::render::Component> componentRender = ememory::makeShared<ege::render::Component>(myMesh);
|
||||||
element->addComponent(componentRender);
|
element->addComponent(componentRender);
|
||||||
// add it ..
|
// add it ..
|
||||||
m_env->addElement(element);
|
m_env->addEntity(element);
|
||||||
}
|
}
|
||||||
// create basic gird: (no physics)
|
// create basic gird: (no physics)
|
||||||
myMesh = ege::resource::Mesh::createGrid(10, vec3(0,0,0), 5);
|
myMesh = ege::resource::Mesh::createGrid(10, vec3(0,0,0), 5);
|
||||||
if (myMesh != nullptr) {
|
if (myMesh != nullptr) {
|
||||||
ememory::SharedPtr<ege::Element> element = ememory::makeShared<ege::Element>(m_env);
|
ememory::SharedPtr<ege::Entity> element = ememory::makeShared<ege::Entity>(m_env);
|
||||||
// 1st Position component:
|
// 1st Position component:
|
||||||
etk::Transform3D transform(vec3(0,0,0), etk::Quaternion::identity());
|
etk::Transform3D transform(vec3(0,0,0), etk::Quaternion::identity());
|
||||||
ememory::SharedPtr<ege::position::Component> componentPosition = ememory::makeShared<ege::position::Component>(transform);
|
ememory::SharedPtr<ege::position::Component> componentPosition = ememory::makeShared<ege::position::Component>(transform);
|
||||||
@ -122,12 +122,12 @@ void appl::Windows::init() {
|
|||||||
ememory::SharedPtr<ege::render::Component> componentRender = ememory::makeShared<ege::render::Component>(myMesh);
|
ememory::SharedPtr<ege::render::Component> componentRender = ememory::makeShared<ege::render::Component>(myMesh);
|
||||||
element->addComponent(componentRender);
|
element->addComponent(componentRender);
|
||||||
// add it ..
|
// add it ..
|
||||||
m_env->addElement(element);
|
m_env->addEntity(element);
|
||||||
}
|
}
|
||||||
// create cubes ...
|
// create cubes ...
|
||||||
myMesh = ege::resource::Mesh::createCube(3, "basics", etk::color::green);
|
myMesh = ege::resource::Mesh::createCube(3, "basics", etk::color::green);
|
||||||
if (myMesh != nullptr) {
|
if (myMesh != nullptr) {
|
||||||
ememory::SharedPtr<ege::Element> element = ememory::makeShared<ege::Element>(m_env);
|
ememory::SharedPtr<ege::Entity> element = ememory::makeShared<ege::Entity>(m_env);
|
||||||
// add all component:
|
// add all component:
|
||||||
// 1st Position component:
|
// 1st Position component:
|
||||||
etk::Transform3D transform(vec3(0,0,2), etk::Quaternion::identity());
|
etk::Transform3D transform(vec3(0,0,2), etk::Quaternion::identity());
|
||||||
@ -136,18 +136,18 @@ void appl::Windows::init() {
|
|||||||
element->addComponent(componentRender);
|
element->addComponent(componentRender);
|
||||||
// 3rd some physic:
|
// 3rd some physic:
|
||||||
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
||||||
ememory::SharedPtr<ege::PhysicsBox> physic = ememory::makeShared<ege::PhysicsBox>();
|
ememory::SharedPtr<ege::physics::shape::Box> physic = ememory::makeShared<ege::physics::shape::Box>();
|
||||||
physic->setSize(vec3(3.01,3.01,3.01));
|
physic->setSize(vec3(3.01,3.01,3.01));
|
||||||
physic->setMass(300000);
|
physic->setMass(300000);
|
||||||
componentPhysics->addShape(physic);
|
componentPhysics->addShape(physic);
|
||||||
componentPhysics->generate();
|
componentPhysics->generate();
|
||||||
element->addComponent(componentPhysics);
|
element->addComponent(componentPhysics);
|
||||||
// add it ..
|
// add it ..
|
||||||
m_env->addElement(element);
|
m_env->addEntity(element);
|
||||||
}
|
}
|
||||||
myMesh = ege::resource::Mesh::createCube(3, "basics", etk::color::orange);
|
myMesh = ege::resource::Mesh::createCube(3, "basics", etk::color::orange);
|
||||||
if (myMesh != nullptr) {
|
if (myMesh != nullptr) {
|
||||||
ememory::SharedPtr<ege::Element> element = ememory::makeShared<ege::Element>(m_env);
|
ememory::SharedPtr<ege::Entity> element = ememory::makeShared<ege::Entity>(m_env);
|
||||||
// add all component:
|
// add all component:
|
||||||
// 1st Position component:
|
// 1st Position component:
|
||||||
etk::Transform3D transform(vec3(20,-10,10), etk::Quaternion::identity());
|
etk::Transform3D transform(vec3(20,-10,10), etk::Quaternion::identity());
|
||||||
@ -158,18 +158,18 @@ void appl::Windows::init() {
|
|||||||
element->addComponent(componentRender);
|
element->addComponent(componentRender);
|
||||||
// 3rd some physic:
|
// 3rd some physic:
|
||||||
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
||||||
ememory::SharedPtr<ege::PhysicsBox> physic = ememory::makeShared<ege::PhysicsBox>();
|
ememory::SharedPtr<ege::physics::shape::Box> physic = ememory::makeShared<ege::physics::shape::Box>();
|
||||||
physic->setSize(vec3(3.01,3.01,3.01));
|
physic->setSize(vec3(3.01,3.01,3.01));
|
||||||
physic->setMass(50000);
|
physic->setMass(50000);
|
||||||
componentPhysics->addShape(physic);
|
componentPhysics->addShape(physic);
|
||||||
componentPhysics->generate();
|
componentPhysics->generate();
|
||||||
element->addComponent(componentPhysics);
|
element->addComponent(componentPhysics);
|
||||||
// add it ..
|
// add it ..
|
||||||
m_env->addElement(element);
|
m_env->addEntity(element);
|
||||||
}
|
}
|
||||||
myMesh = ege::resource::Mesh::createSphere(4, "basics", etk::color::blue);
|
myMesh = ege::resource::Mesh::createSphere(4, "basics", etk::color::blue);
|
||||||
if (myMesh != nullptr) {
|
if (myMesh != nullptr) {
|
||||||
ememory::SharedPtr<ege::Element> element = ememory::makeShared<ege::Element>(m_env);
|
ememory::SharedPtr<ege::Entity> element = ememory::makeShared<ege::Entity>(m_env);
|
||||||
// add all component:
|
// add all component:
|
||||||
// 1st Position component:
|
// 1st Position component:
|
||||||
etk::Transform3D transform(vec3(-20,10,10), etk::Quaternion::identity());
|
etk::Transform3D transform(vec3(-20,10,10), etk::Quaternion::identity());
|
||||||
@ -180,26 +180,26 @@ void appl::Windows::init() {
|
|||||||
element->addComponent(componentRender);
|
element->addComponent(componentRender);
|
||||||
// 3rd some physic:
|
// 3rd some physic:
|
||||||
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
||||||
ememory::SharedPtr<ege::PhysicsSphere> physic = ememory::makeShared<ege::PhysicsSphere>();
|
ememory::SharedPtr<ege::physics::shape::Sphere> physic = ememory::makeShared<ege::physics::shape::Sphere>();
|
||||||
physic->setRadius(4.01);
|
physic->setRadius(4.01);
|
||||||
physic->setMass(500000);
|
physic->setMass(500000);
|
||||||
componentPhysics->addShape(physic);
|
componentPhysics->addShape(physic);
|
||||||
componentPhysics->generate();
|
componentPhysics->generate();
|
||||||
element->addComponent(componentPhysics);
|
element->addComponent(componentPhysics);
|
||||||
// add it ..
|
// add it ..
|
||||||
m_env->addElement(element);
|
m_env->addEntity(element);
|
||||||
}
|
}
|
||||||
m_env->propertyStatus.set(ege::gameStart);
|
m_env->propertyStatus.set(ege::gameStart);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
namespace appl {
|
namespace appl {
|
||||||
class ElementHerit : public ege::ElementPhysic {
|
class EntityHerit : public ege::EntityPhysic {
|
||||||
public:
|
public:
|
||||||
ElementHerit(const ememory::SharedPtr<ege::Environement>& _env, bool _autoRigidBody=true) :
|
EntityHerit(const ememory::SharedPtr<ege::Environement>& _env, bool _autoRigidBody=true) :
|
||||||
ege::ElementPhysic(_env, _autoRigidBody) {
|
ege::EntityPhysic(_env, _autoRigidBody) {
|
||||||
setCollisionDetectionStatus(true);
|
setCollisionDetectionStatus(true);
|
||||||
}
|
}
|
||||||
virtual void onCollisionDetected(const ememory::SharedPtr<ege::Element>& _obj, const vec3& _point, const vec3& _normal) {
|
virtual void onCollisionDetected(const ememory::SharedPtr<ege::Entity>& _obj, const vec3& _point, const vec3& _normal) {
|
||||||
APPL_WARNING("[" << getUID() << "] collision : pos=" << _point << " norm=" <<_normal);
|
APPL_WARNING("[" << getUID() << "] collision : pos=" << _point << " norm=" <<_normal);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -217,7 +217,7 @@ bool appl::Windows::onEventInput(const ewol::event::Input& _event) {
|
|||||||
ememory::SharedPtr<ege::resource::Mesh> myMesh;
|
ememory::SharedPtr<ege::resource::Mesh> myMesh;
|
||||||
myMesh = ege::resource::Mesh::createCube(1, "basics", etk::color::orange);
|
myMesh = ege::resource::Mesh::createCube(1, "basics", etk::color::orange);
|
||||||
if (myMesh != nullptr) {
|
if (myMesh != nullptr) {
|
||||||
ememory::SharedPtr<ege::Element> element = ememory::makeShared<ege::Element>(m_env);
|
ememory::SharedPtr<ege::Entity> element = ememory::makeShared<ege::Entity>(m_env);
|
||||||
// add all component:
|
// add all component:
|
||||||
// 1st Position component:
|
// 1st Position component:
|
||||||
etk::Transform3D transform(ray.getOrigin(), etk::Quaternion::identity());
|
etk::Transform3D transform(ray.getOrigin(), etk::Quaternion::identity());
|
||||||
@ -228,7 +228,7 @@ bool appl::Windows::onEventInput(const ewol::event::Input& _event) {
|
|||||||
element->addComponent(componentRender);
|
element->addComponent(componentRender);
|
||||||
// 3rd some physic:
|
// 3rd some physic:
|
||||||
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
||||||
ememory::SharedPtr<ege::PhysicsBox> physic = ememory::makeShared<ege::PhysicsBox>();
|
ememory::SharedPtr<ege::physics::shape::Box> physic = ememory::makeShared<ege::physics::shape::Box>();
|
||||||
physic->setSize(vec3(1.01,1.01,1.01));
|
physic->setSize(vec3(1.01,1.01,1.01));
|
||||||
physic->setMass(1000);
|
physic->setMass(1000);
|
||||||
componentPhysics->setType(ege::physics::Component::type::bodyDynamic);
|
componentPhysics->setType(ege::physics::Component::type::bodyDynamic);
|
||||||
@ -239,7 +239,7 @@ bool appl::Windows::onEventInput(const ewol::event::Input& _event) {
|
|||||||
componentPhysics->setLinearVelocity(ray.getDirection()*100);
|
componentPhysics->setLinearVelocity(ray.getDirection()*100);
|
||||||
element->addComponent(componentPhysics);
|
element->addComponent(componentPhysics);
|
||||||
// add it ..
|
// add it ..
|
||||||
m_env->addElement(element);
|
m_env->addEntity(element);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user