[DEV] Simplify the Game engine
This commit is contained in:
parent
549ac760d7
commit
93d3e62b8e
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
|||||||
Subproject commit ba9e2fca7bece1f46eac6f29c0ca5e2c54f59d89
|
Subproject commit 3b5aa7b84f5f41c72eccf3c2fecb6f8404401e9b
|
@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/game/Bounding.h>
|
|
||||||
#include <ewol/game/BoundingAABB.h>
|
|
||||||
|
|
||||||
|
|
||||||
game::Bounding::Bounding(boundingMode mode) :
|
|
||||||
m_mode(mode),
|
|
||||||
m_hasContact(false)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
game::Bounding::~Bounding(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
game::Bounding* game::CreateBounding(game::boundingMode mode)
|
|
||||||
{
|
|
||||||
switch(mode) {
|
|
||||||
case game::BoundingModeAABB:
|
|
||||||
|
|
||||||
return new game::BoundingAABB();
|
|
||||||
default:
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GAME_BOUNDING_H__
|
|
||||||
#define __GAME_BOUNDING_H__
|
|
||||||
|
|
||||||
#include <ewol/debug.h>
|
|
||||||
#include <ewol/game/MeshObject.h>
|
|
||||||
#include <etk/math/Matrix4.h>
|
|
||||||
//#include <ewol/game/Contact.h>
|
|
||||||
|
|
||||||
namespace game
|
|
||||||
{
|
|
||||||
typedef enum {
|
|
||||||
BoundingModePlane, //!< plane Bounding.
|
|
||||||
BoundingModeSphere, //!< Sphere.
|
|
||||||
BoundingModeAABB, //!< Anti-aligned Bounding Boxes.
|
|
||||||
BoundingModeOBB, //!< Oriented Bounding Box.
|
|
||||||
// TODO : Add more if needed to implement
|
|
||||||
} boundingMode;
|
|
||||||
|
|
||||||
class Bounding
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
boundingMode m_mode; //!< bounding mode of this system.
|
|
||||||
bool m_hasContact; //!< this bounding is on contact with something else ...
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @biref Main constructor.
|
|
||||||
* @param[in] mode Bounding mode.
|
|
||||||
*/
|
|
||||||
Bounding(boundingMode mode);
|
|
||||||
/**
|
|
||||||
* @biref Main constructor.
|
|
||||||
*/
|
|
||||||
virtual ~Bounding(void);
|
|
||||||
/**
|
|
||||||
* @brief Get the bounding type
|
|
||||||
* @return the bounding type;
|
|
||||||
*/
|
|
||||||
boundingMode GetType(void) { return m_mode; };
|
|
||||||
/**
|
|
||||||
* @brief Update Bounding properties.
|
|
||||||
*/
|
|
||||||
virtual void Update(game::MeshObject& object, mat4& transformMatrix) {};
|
|
||||||
/**
|
|
||||||
* @brief Draw the bounding ==> for test ...
|
|
||||||
*/
|
|
||||||
virtual void Draw(void) {};
|
|
||||||
/**
|
|
||||||
* @brief Detect the colision positions.
|
|
||||||
*/
|
|
||||||
//virtual void GenerateContact(game::Element* ourElement, game::Bounding* otherbounding, game::Element* otherElements, etk::Vector<game::Contact>& contactList);
|
|
||||||
virtual bool HasContact(game::Bounding& otherbounding) { return false; };
|
|
||||||
/**
|
|
||||||
* @brief Set the contact property at a specific value ...
|
|
||||||
*/
|
|
||||||
void SetContactMode(bool newStatus) { m_hasContact=newStatus; };
|
|
||||||
|
|
||||||
bool GetContactStatus(void) { return m_hasContact; };
|
|
||||||
};
|
|
||||||
|
|
||||||
Bounding* CreateBounding(boundingMode mode);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -13,9 +13,10 @@
|
|||||||
|
|
||||||
|
|
||||||
game::BoundingAABB::BoundingAABB(void) :
|
game::BoundingAABB::BoundingAABB(void) :
|
||||||
Bounding(game::BoundingModeAABB),
|
m_hasContact(false),
|
||||||
m_PointStart(-1,-1,-1),
|
m_center(0,0,0),
|
||||||
m_PointStop(1,1,1)
|
m_size(1,1,1),
|
||||||
|
m_oldUserPosition(0,0,0)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (false == ewol::resource::Keep(m_displayBounding) ) {
|
if (false == ewol::resource::Keep(m_displayBounding) ) {
|
||||||
@ -36,37 +37,46 @@ game::BoundingAABB::~BoundingAABB(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void game::BoundingAABB::Update(game::MeshObject& object, mat4& transformMatrix)
|
void game::BoundingAABB::Update(game::MeshObject& object, mat4& rotation, vec3& position, vec3& scale)
|
||||||
{
|
{
|
||||||
|
vec3 pointStart;
|
||||||
|
vec3 pointStop;
|
||||||
|
mat4 transformMatrix = etk::matTranslate(position)
|
||||||
|
* etk::matScale(scale)
|
||||||
|
* rotation;
|
||||||
for (int32_t iii=0; iii<object.m_vertices.Size(); iii++) {
|
for (int32_t iii=0; iii<object.m_vertices.Size(); iii++) {
|
||||||
vec3 point = transformMatrix * object.m_vertices[iii];
|
vec3 point = transformMatrix * object.m_vertices[iii];
|
||||||
if (0 == iii) {
|
if (0 == iii) {
|
||||||
m_PointStart = point;
|
pointStart = point;
|
||||||
m_PointStop = point;
|
pointStop = point;
|
||||||
} else {
|
} else {
|
||||||
if (m_PointStart.x > point.x) {
|
if (pointStart.x > point.x) {
|
||||||
m_PointStart.x = point.x;
|
pointStart.x = point.x;
|
||||||
} else if (m_PointStop.x < point.x) {
|
} else if (pointStop.x < point.x) {
|
||||||
m_PointStop.x = point.x;
|
pointStop.x = point.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_PointStart.y > point.y) {
|
if (pointStart.y > point.y) {
|
||||||
m_PointStart.y = point.y;
|
pointStart.y = point.y;
|
||||||
} else if (m_PointStop.y < point.y) {
|
} else if (pointStop.y < point.y) {
|
||||||
m_PointStop.y = point.y;
|
pointStop.y = point.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_PointStart.z > point.z) {
|
if (pointStart.z > point.z) {
|
||||||
m_PointStart.z = point.z;
|
pointStart.z = point.z;
|
||||||
} else if (m_PointStop.z < point.z) {
|
} else if (pointStop.z < point.z) {
|
||||||
m_PointStop.z = point.z;
|
pointStop.z = point.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_size = (pointStop - pointStart) / 2;
|
||||||
|
m_center = pointStop - m_size;
|
||||||
|
m_oldUserPosition = position;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
vec3 tmpBB(0.001,0.001,0.001);
|
vec3 tmpBB(0.001,0.001,0.001);
|
||||||
vec3 tmpStart = m_PointStart - tmpBB;
|
vec3 tmpStart = pointStart - tmpBB;
|
||||||
vec3 tmpStop = m_PointStop + tmpBB;
|
vec3 tmpStop = pointStop + tmpBB;
|
||||||
// (start) X / Y
|
// (start) X / Y
|
||||||
vec3 tmpPos = tmpStart;
|
vec3 tmpPos = tmpStart;
|
||||||
m_vertices[0] = tmpStart;
|
m_vertices[0] = tmpStart;
|
||||||
@ -167,26 +177,14 @@ void game::BoundingAABB::Draw(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool game::BoundingAABB::HasContact(game::Bounding& otherbounding)
|
bool game::BoundingAABB::HasContact(game::BoundingAABB& obj)
|
||||||
{
|
{
|
||||||
switch(otherbounding.GetType()) {
|
if( (abs(m_center.x-obj.m_center.x) > m_size.x+obj.m_size.x)
|
||||||
case game::BoundingModeAABB:
|
|| (abs(m_center.y-obj.m_center.y) > m_size.y+obj.m_size.y)
|
||||||
{
|
|| (abs(m_center.z-obj.m_center.z) > m_size.z+obj.m_size.z) ) {
|
||||||
game::BoundingAABB& other = static_cast<game::BoundingAABB&>(otherbounding);
|
return false;
|
||||||
if( m_PointStart.x > other.m_PointStop.x
|
|
||||||
|| m_PointStop.x < other.m_PointStart.x
|
|
||||||
|| m_PointStart.y > other.m_PointStop.y
|
|
||||||
|| m_PointStop.y < other.m_PointStart.y
|
|
||||||
|| m_PointStart.z > other.m_PointStop.z
|
|
||||||
|| m_PointStop.z < other.m_PointStart.z) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
EWOL_DEBUG("TODO ... ");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,18 +9,19 @@
|
|||||||
#ifndef __GAME_BOUNDING_AABB_H__
|
#ifndef __GAME_BOUNDING_AABB_H__
|
||||||
#define __GAME_BOUNDING_AABB_H__
|
#define __GAME_BOUNDING_AABB_H__
|
||||||
|
|
||||||
#include "ewol/game/Bounding.h"
|
|
||||||
#include "etk/math/Vector3D.h"
|
#include "etk/math/Vector3D.h"
|
||||||
#include "etk/math/Matrix4.h"
|
#include "etk/math/Matrix4.h"
|
||||||
#include "ewol/renderer/resources/Colored3DObject.h"
|
#include "ewol/renderer/resources/Colored3DObject.h"
|
||||||
|
|
||||||
namespace game
|
namespace game
|
||||||
{
|
{
|
||||||
class BoundingAABB : public Bounding
|
class BoundingAABB
|
||||||
{
|
{
|
||||||
private :
|
private :
|
||||||
vec3 m_PointStart;
|
bool m_hasContact; //!< this bounding is on contact with something else ...
|
||||||
vec3 m_PointStop;
|
vec3 m_center;
|
||||||
|
vec3 m_size;
|
||||||
|
vec3 m_oldUserPosition; // this is due to the fact object are never centered ...
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
ewol::Colored3DObject* m_displayBounding;
|
ewol::Colored3DObject* m_displayBounding;
|
||||||
etk::Vector<vec3> m_vertices;
|
etk::Vector<vec3> m_vertices;
|
||||||
@ -28,19 +29,32 @@ namespace game
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @biref Main constructor.
|
* @biref Main constructor.
|
||||||
* @param[in] mode Bounding mode.
|
|
||||||
*/
|
*/
|
||||||
BoundingAABB(void);
|
BoundingAABB(void);
|
||||||
/**
|
/**
|
||||||
* @biref Main constructor.
|
* @biref Main constructor.
|
||||||
*/
|
*/
|
||||||
virtual ~BoundingAABB(void);
|
virtual ~BoundingAABB(void);
|
||||||
// herited methodes
|
/**
|
||||||
virtual void Update(game::MeshObject& object, mat4& transformMatrix);
|
* @brief Update Bounding properties.
|
||||||
// herited methodes
|
*/
|
||||||
|
virtual void Update(game::MeshObject& object, mat4& rotation, vec3& position, vec3& scale);
|
||||||
|
/**
|
||||||
|
* @brief Draw the bounding ==> for test ...
|
||||||
|
*/
|
||||||
virtual void Draw(void);
|
virtual void Draw(void);
|
||||||
// herited methodes
|
/**
|
||||||
virtual bool HasContact(game::Bounding& otherbounding);
|
* @brief Detect the colision positions.
|
||||||
|
*/
|
||||||
|
virtual bool HasContact(game::BoundingAABB& otherbounding);
|
||||||
|
/**
|
||||||
|
* @brief Set the contact property at a specific value ...
|
||||||
|
*/
|
||||||
|
void SetContactMode(bool newStatus) { m_hasContact=newStatus; };
|
||||||
|
/**
|
||||||
|
* @brief Get the current contact status
|
||||||
|
*/
|
||||||
|
bool GetContactStatus(void) { return m_hasContact; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/debug.h>
|
|
||||||
#include <ewol/game/BoundingOBB.h>
|
|
||||||
|
|
||||||
|
|
||||||
game::BoundingOBB::BoundingOBB(game::MeshObject& object) :
|
|
||||||
Bounding(game::BoundingModeOBB)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
game::BoundingOBB::~BoundingOBB(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void game::BoundingOBB::Update(game::MeshObject& object, mat4& transformMatrix)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GAME_BOUNDING_OBB_H__
|
|
||||||
#define __GAME_BOUNDING_OBB_H__
|
|
||||||
|
|
||||||
#include "ewol/game/Bounding.h"
|
|
||||||
#include "etk/math/Vector3D.h"
|
|
||||||
|
|
||||||
namespace game
|
|
||||||
{
|
|
||||||
class BoundingOBB : public Bounding
|
|
||||||
{
|
|
||||||
private :
|
|
||||||
vec3 m_PointCenter;
|
|
||||||
vec3 m_radius;
|
|
||||||
vec3 m_angle;
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @biref Main constructor.
|
|
||||||
* @param[in] mode Bounding mode.
|
|
||||||
*/
|
|
||||||
BoundingOBB(game::MeshObject& object);
|
|
||||||
/**
|
|
||||||
* @biref Main constructor.
|
|
||||||
*/
|
|
||||||
virtual ~BoundingOBB(void);
|
|
||||||
/**
|
|
||||||
* @brief Update Bounding properties.
|
|
||||||
*/
|
|
||||||
virtual void Update(game::MeshObject& object, mat4& transformMatrix);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/debug.h>
|
|
||||||
#include <ewol/game/BoundingPlane.h>
|
|
||||||
|
|
||||||
|
|
||||||
game::BoundingPlane::BoundingPlane(void) :
|
|
||||||
Bounding(game::BoundingModePlane)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
game::BoundingPlane::~BoundingPlane(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void game::BoundingPlane::Update(game::MeshObject& object, mat4& transformMatrix)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GAME_BOUNDING_PLANE_H__
|
|
||||||
#define __GAME_BOUNDING_PLANE_H__
|
|
||||||
|
|
||||||
#include "ewol/game/Bounding.h"
|
|
||||||
#include "etk/math/Vector3D.h"
|
|
||||||
|
|
||||||
namespace game
|
|
||||||
{
|
|
||||||
class BoundingPlane : public Bounding
|
|
||||||
{
|
|
||||||
private :
|
|
||||||
vec3 m_equation;
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @biref Main constructor.
|
|
||||||
* @param[in] mode Bounding mode.
|
|
||||||
*/
|
|
||||||
BoundingPlane(void);
|
|
||||||
/**
|
|
||||||
* @biref Main constructor.
|
|
||||||
*/
|
|
||||||
virtual ~BoundingPlane(void);
|
|
||||||
/**
|
|
||||||
* @brief Update Bounding properties.
|
|
||||||
*/
|
|
||||||
virtual void Update(game::MeshObject& object, mat4& transformMatrix);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/debug.h>
|
|
||||||
#include <ewol/game/BoundingSphere.h>
|
|
||||||
|
|
||||||
|
|
||||||
game::BoundingSphere::BoundingSphere(void) :
|
|
||||||
Bounding(game::BoundingModeSphere)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
game::BoundingSphere::~BoundingSphere(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void game::BoundingSphere::Update(game::MeshObject& object, mat4& transformMatrix)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GAME_BOUNDING_SPHERE_H__
|
|
||||||
#define __GAME_BOUNDING_SPHERE_H__
|
|
||||||
|
|
||||||
#include "ewol/game/Bounding.h"
|
|
||||||
#include "etk/math/Vector3D.h"
|
|
||||||
|
|
||||||
namespace game
|
|
||||||
{
|
|
||||||
class BoundingSphere : public Bounding
|
|
||||||
{
|
|
||||||
private :
|
|
||||||
vec3 m_position; //!< Position of the center of the bounding
|
|
||||||
float m_radius; //!< Radius of the Bounding
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @biref Main constructor.
|
|
||||||
* @param[in] mode Bounding mode.
|
|
||||||
*/
|
|
||||||
BoundingSphere(void);
|
|
||||||
/**
|
|
||||||
* @biref Main constructor.
|
|
||||||
*/
|
|
||||||
virtual ~BoundingSphere(void);
|
|
||||||
/**
|
|
||||||
* @brief Update Bounding properties.
|
|
||||||
*/
|
|
||||||
virtual void Update(game::MeshObject& object, mat4& transformMatrix);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -16,7 +16,6 @@ static int32_t uniqueId = 0;
|
|||||||
|
|
||||||
game::Element::Element(etk::UString meshResource) :
|
game::Element::Element(etk::UString meshResource) :
|
||||||
m_resource(NULL),
|
m_resource(NULL),
|
||||||
m_bounding(NULL),
|
|
||||||
m_matrixNeedUpdate(true),
|
m_matrixNeedUpdate(true),
|
||||||
m_scale(1,1,1),
|
m_scale(1,1,1),
|
||||||
m_speedMax(2000000, 2000000, 2000000),
|
m_speedMax(2000000, 2000000, 2000000),
|
||||||
@ -33,7 +32,6 @@ game::Element::Element(etk::UString meshResource) :
|
|||||||
m_resource = tmpObject;
|
m_resource = tmpObject;
|
||||||
}
|
}
|
||||||
uniqueId++;
|
uniqueId++;
|
||||||
m_bounding = game::CreateBounding(game::BoundingModeAABB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
game::Element::~Element(void)
|
game::Element::~Element(void)
|
||||||
@ -43,10 +41,6 @@ game::Element::~Element(void)
|
|||||||
ewol::resource::Release(tmpObject);
|
ewol::resource::Release(tmpObject);
|
||||||
m_resource = NULL;
|
m_resource = NULL;
|
||||||
}
|
}
|
||||||
if (NULL != m_bounding) {
|
|
||||||
delete(m_bounding);
|
|
||||||
m_bounding = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void game::Element::Draw(void)
|
void game::Element::Draw(void)
|
||||||
@ -59,10 +53,8 @@ void game::Element::Draw(void)
|
|||||||
|
|
||||||
void game::Element::DrawDebug(void)
|
void game::Element::DrawDebug(void)
|
||||||
{
|
{
|
||||||
if (NULL != m_bounding) {
|
//EWOL_DEBUG("draw bounding" << m_uniqueId);
|
||||||
//EWOL_DEBUG("draw bounding" << m_uniqueId);
|
m_bounding.Draw();
|
||||||
m_bounding->Draw();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -100,15 +92,14 @@ void game::Element::ProcessGravity(float delta, game::Gravity& gravity)
|
|||||||
|
|
||||||
void game::Element::ProcessPosition(float delta)
|
void game::Element::ProcessPosition(float delta)
|
||||||
{
|
{
|
||||||
if( NULL!=m_bounding
|
if(true == m_bounding.GetContactStatus()) {
|
||||||
&& true == m_bounding->GetContactStatus()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vec3 m_speed0(m_speed);
|
vec3 m_speed0(m_speed);
|
||||||
vec3 curentAcceleration(m_gravityForce + m_userAcceleration);
|
vec3 curentAcceleration(m_gravityForce + m_userAcceleration);
|
||||||
m_speed += curentAcceleration*delta;
|
m_speed += curentAcceleration*delta;
|
||||||
vec3 tmpPos = m_position +m_speed0*delta + curentAcceleration*delta*delta/2.0f ;
|
vec3 tmpPos = m_position +m_speed*delta;
|
||||||
|
// TODO : Detect collision of other elements ...
|
||||||
if (m_position != tmpPos) {
|
if (m_position != tmpPos) {
|
||||||
m_position = tmpPos;
|
m_position = tmpPos;
|
||||||
m_matrixNeedUpdate = true;
|
m_matrixNeedUpdate = true;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/game/Gravity.h>
|
#include <ewol/game/Gravity.h>
|
||||||
#include <ewol/renderer/resources/Mesh.h>
|
#include <ewol/renderer/resources/Mesh.h>
|
||||||
#include <ewol/game/Bounding.h>
|
#include <ewol/game/BoundingAABB.h>
|
||||||
|
|
||||||
namespace game
|
namespace game
|
||||||
{
|
{
|
||||||
@ -24,12 +24,11 @@ namespace game
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
ewol::Mesh* m_resource; //!< Resource to display the element.
|
ewol::Mesh* m_resource; //!< Resource to display the element.
|
||||||
game::Bounding* m_bounding; //!< Bounding of this element
|
game::BoundingAABB m_bounding; //!< Bounding of this element
|
||||||
private:
|
private:
|
||||||
bool m_matrixNeedUpdate; //!< the matrix need to be regenerated
|
bool m_matrixNeedUpdate; //!< the matrix need to be regenerated
|
||||||
mat4 m_matrix; //!< generated display matrix.
|
mat4 m_matrix; //!< generated display matrix.
|
||||||
vec3 m_scale; //!< scale of the element. (change the size in dynamic from the loaded model)
|
vec3 m_scale; //!< scale of the element. (change the size in dynamic from the loaded model)
|
||||||
vec3 m_displayAngle; //!< Rotate the model.
|
|
||||||
mat4 m_displayRotation; //!< Associated matrix of totation associated with m_displayAngle.
|
mat4 m_displayRotation; //!< Associated matrix of totation associated with m_displayAngle.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -93,7 +92,6 @@ namespace game
|
|||||||
{
|
{
|
||||||
m_position = vec3(0,0,0);
|
m_position = vec3(0,0,0);
|
||||||
m_speed = vec3(0,0,0);
|
m_speed = vec3(0,0,0);
|
||||||
m_displayAngle = vec3(0,0,0);
|
|
||||||
m_displayRotation.Identity();
|
m_displayRotation.Identity();
|
||||||
m_matrix.Identity();
|
m_matrix.Identity();
|
||||||
};
|
};
|
||||||
@ -116,13 +114,12 @@ namespace game
|
|||||||
m_matrixNeedUpdate = true;
|
m_matrixNeedUpdate = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Rotate the curent object
|
* @brief Rotate the current object
|
||||||
* @param[in] vect rotation angle
|
* @param[in] vect rotation angle
|
||||||
* @param[in] angleRad radian angle
|
* @param[in] angleRad radian angle
|
||||||
*/
|
*/
|
||||||
void Rotate(etk::Vector3D<float> vect, float angleRad=0.0)
|
void Rotate(etk::Vector3D<float> vect, float angleRad=0.0)
|
||||||
{
|
{
|
||||||
m_displayAngle.RotateAxis(angleRad, vect);
|
|
||||||
m_displayRotation = etk::matRotate(vect, angleRad) * m_displayRotation;
|
m_displayRotation = etk::matRotate(vect, angleRad) * m_displayRotation;
|
||||||
m_matrixNeedUpdate = true;
|
m_matrixNeedUpdate = true;
|
||||||
}
|
}
|
||||||
@ -134,10 +131,10 @@ namespace game
|
|||||||
{
|
{
|
||||||
if (m_matrixNeedUpdate == true) {
|
if (m_matrixNeedUpdate == true) {
|
||||||
m_matrixNeedUpdate = false;
|
m_matrixNeedUpdate = false;
|
||||||
m_matrix = etk::matTranslate(m_position) * etk::matScale(m_scale) * m_displayRotation;
|
m_matrix = etk::matTranslate(m_position)
|
||||||
if (m_bounding!=NULL) {
|
* etk::matScale(m_scale)
|
||||||
m_bounding->Update(m_resource->m_object, m_matrix);
|
* m_displayRotation;
|
||||||
}
|
m_bounding.Update(m_resource->m_object, m_displayRotation, m_position, m_scale);
|
||||||
}
|
}
|
||||||
return m_matrix;
|
return m_matrix;
|
||||||
};
|
};
|
||||||
@ -146,7 +143,7 @@ namespace game
|
|||||||
m_speed = newSpeed;
|
m_speed = newSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
game::Bounding* GetBounding(void)
|
game::BoundingAABB& GetBounding(void)
|
||||||
{
|
{
|
||||||
return m_bounding;
|
return m_bounding;
|
||||||
}
|
}
|
||||||
|
@ -65,34 +65,20 @@ void game::Engine::ProcessCollision(float deltaTime)
|
|||||||
m_contacts.Clear();
|
m_contacts.Clear();
|
||||||
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
||||||
if (NULL != m_elements[iii]) {
|
if (NULL != m_elements[iii]) {
|
||||||
game::Bounding* bounding1 = m_elements[iii]->GetBounding();
|
game::BoundingAABB& bounding1 = m_elements[iii]->GetBounding();
|
||||||
if (NULL != bounding1) {
|
bounding1.SetContactMode(false);
|
||||||
bounding1->SetContactMode(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
||||||
if (NULL != m_elements[iii]) {
|
if (NULL != m_elements[iii]) {
|
||||||
game::Bounding* bounding1 = m_elements[iii]->GetBounding();
|
game::BoundingAABB& bounding1 = m_elements[iii]->GetBounding();
|
||||||
if (NULL != bounding1) {
|
for (int32_t jjj=iii+1; jjj<m_elements.Size() ; jjj++) {
|
||||||
for (int32_t jjj=iii+1; jjj<m_elements.Size() ; jjj++) {
|
if (NULL!=m_elements[jjj]) {
|
||||||
if (NULL!=m_elements[jjj]) {
|
game::BoundingAABB& bounding2 = m_elements[jjj]->GetBounding();
|
||||||
game::Bounding* bounding2 = m_elements[jjj]->GetBounding();
|
if (true == bounding2.HasContact(bounding1)) {
|
||||||
if (NULL != bounding2) {
|
bounding2.SetContactMode(true);
|
||||||
bool hasContactConfirmed = false;
|
bounding1.SetContactMode(true);
|
||||||
if (bounding1->GetType() < bounding2->GetType()) {
|
|
||||||
//bounding2->GenerateContact(m_elements[jjj], bounding1, m_elements[iii], m_contacts);
|
|
||||||
hasContactConfirmed = bounding2->HasContact(*bounding1);
|
|
||||||
} else {
|
|
||||||
//bounding1->GenerateContact(m_elements[iii], bounding2, m_elements[jjj], m_contacts);
|
|
||||||
hasContactConfirmed = bounding1->HasContact(*bounding2);
|
|
||||||
}
|
|
||||||
if (true == hasContactConfirmed) {
|
|
||||||
bounding2->SetContactMode(true);
|
|
||||||
bounding1->SetContactMode(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <etk/types.h>
|
|
||||||
#include <ewol/debug.h>
|
|
||||||
#include <ewol/game/Geometry.h>
|
|
||||||
#include <ewol/game/BoundingAABB.h>
|
|
||||||
#include <ewol/game/BoundingOBB.h>
|
|
||||||
#include <ewol/game/BoundingPlane.h>
|
|
||||||
#include <ewol/game/BoundingSphere.h>
|
|
||||||
|
|
||||||
game::Geometry::Geometry(game::MeshObject& object) :
|
|
||||||
m_dynamic(false),
|
|
||||||
m_object(object),
|
|
||||||
m_bounding(NULL),
|
|
||||||
m_mass(NULL)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
game::Geometry::~Geometry(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void game::Geometry::SetStatic(void)
|
|
||||||
{
|
|
||||||
m_dynamic = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void game::Geometry::SetDynamic(void)
|
|
||||||
{
|
|
||||||
m_dynamic = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void game::Geometry::SetBoundingMode(game::boundingMode type)
|
|
||||||
{
|
|
||||||
if (NULL != m_bounding) {
|
|
||||||
if (m_bounding->GetType() != type) {
|
|
||||||
delete(m_bounding);
|
|
||||||
m_bounding = NULL;
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
switch(type)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case BoundingModeNone:
|
|
||||||
break;
|
|
||||||
case BoundingModePlane:
|
|
||||||
EWOL_TODO("Implement plane...");
|
|
||||||
break;
|
|
||||||
case BoundingModeAABB:
|
|
||||||
m_bounding = new game::BoundingAABB();
|
|
||||||
break;
|
|
||||||
case BoundingModeSphere:
|
|
||||||
m_bounding = new game::BoundingSphere();
|
|
||||||
break;
|
|
||||||
case BoundingModeOBB:
|
|
||||||
m_bounding = new game::BoundingOBB(m_object, m_property);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void game::Geometry::BoundingUpdate(void)
|
|
||||||
{
|
|
||||||
if (NULL != m_bounding) {
|
|
||||||
//m_bounding->Update(m_object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GAME_GEOMETRY_H__
|
|
||||||
#define __GAME_GEOMETRY_H__
|
|
||||||
|
|
||||||
#include <ewol/debug.h>
|
|
||||||
#include <ewol/game/Bounding.h>
|
|
||||||
#include <ewol/game/Mass.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace game
|
|
||||||
{
|
|
||||||
class Geometry
|
|
||||||
{
|
|
||||||
private :
|
|
||||||
bool m_dynamic; //!< Set at true if the Geometry can move or not (bounding can change)
|
|
||||||
game::MeshObject& m_object; //!< Object vertex/ normal and other properties
|
|
||||||
game::Bounding* m_bounding; //!< Bounding interface.
|
|
||||||
game::Mass* m_mass; //!< Mass properties.
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief main constructor
|
|
||||||
* @param[in] object the reference mesh object (must not be NULL)
|
|
||||||
*/
|
|
||||||
Geometry(game::MeshObject& object);
|
|
||||||
/**
|
|
||||||
* @brief main destructor
|
|
||||||
*/
|
|
||||||
~Geometry(void);
|
|
||||||
/**
|
|
||||||
* @brief Set this object static (the bounding does not change)
|
|
||||||
*/
|
|
||||||
void SetStatic(void);
|
|
||||||
/**
|
|
||||||
* @brief Set this object Dynamic (the bounding change...)
|
|
||||||
*/
|
|
||||||
void SetDynamic(void);
|
|
||||||
/**
|
|
||||||
* @brief Set bounding type
|
|
||||||
* @param[in] type Selected bounding methode (if no set, by default it does not have one)
|
|
||||||
*/
|
|
||||||
void SetBoundingMode(game::boundingMode type);
|
|
||||||
/**
|
|
||||||
* @brief Update the bounding properties.
|
|
||||||
*/
|
|
||||||
void BoundingUpdate(void);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -84,12 +84,7 @@ FILE_LIST+= ewol/widget/Widget.cpp \
|
|||||||
FILE_LIST+= ewol/widget/Scene.cpp \
|
FILE_LIST+= ewol/widget/Scene.cpp \
|
||||||
ewol/game/Engine.cpp \
|
ewol/game/Engine.cpp \
|
||||||
ewol/game/Element.cpp \
|
ewol/game/Element.cpp \
|
||||||
ewol/game/Bounding.cpp \
|
|
||||||
ewol/game/BoundingAABB.cpp \
|
ewol/game/BoundingAABB.cpp \
|
||||||
ewol/game/BoundingOBB.cpp \
|
|
||||||
ewol/game/BoundingPlane.cpp \
|
|
||||||
ewol/game/BoundingSphere.cpp \
|
|
||||||
ewol/game/Geometry.cpp \
|
|
||||||
ewol/game/Gravity.cpp \
|
ewol/game/Gravity.cpp \
|
||||||
ewol/game/Camera.cpp \
|
ewol/game/Camera.cpp \
|
||||||
ewol/game/Contact.cpp \
|
ewol/game/Contact.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user