[DEV] transfert on Environement and some shared_ptr added
This commit is contained in:
parent
6adec3434e
commit
95e13b8126
@ -31,7 +31,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
|
||||
if (nullptr == _mesh) {
|
||||
return new btEmptyShape();;
|
||||
}
|
||||
const std::vector<ege::PhysicsShape*>& physiqueProperty = _mesh->getPhysicalProperties();
|
||||
const std::vector<std::shared_ptr<ege::PhysicsShape>>& physiqueProperty = _mesh->getPhysicalProperties();
|
||||
if (physiqueProperty.size() == 0) {
|
||||
return new btEmptyShape();;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
@ -34,11 +34,11 @@ const std::string& ege::ElementGame::getType() const {
|
||||
}
|
||||
|
||||
|
||||
ege::ElementGame::ElementGame(ege::Environement& _env) :
|
||||
ege::ElementGame::ElementGame(const std::shared_ptr<ege::Environement>& _env) :
|
||||
m_env(_env),
|
||||
m_body(nullptr),
|
||||
m_uID(0),
|
||||
m_mesh(nullptr),
|
||||
m_mesh(),
|
||||
m_shape(nullptr),
|
||||
m_life(100),
|
||||
m_lifeMax(100),
|
||||
@ -60,10 +60,8 @@ ege::ElementGame::~ElementGame() {
|
||||
// same ...
|
||||
dynamicDisable();
|
||||
removeShape();
|
||||
if (nullptr != m_body) {
|
||||
delete(m_body);
|
||||
m_body = nullptr;
|
||||
}
|
||||
delete m_body;
|
||||
m_body = nullptr;
|
||||
EGE_DEBUG("Destroy element : uId=" << m_uID);
|
||||
}
|
||||
|
||||
@ -483,10 +481,10 @@ void ege::ElementGame::dynamicEnable() {
|
||||
return;
|
||||
}
|
||||
if(nullptr!=m_body) {
|
||||
m_env.getDynamicWorld()->addRigidBody(m_body);
|
||||
m_env->getDynamicWorld()->addRigidBody(m_body);
|
||||
}
|
||||
if(nullptr!=m_IA) {
|
||||
m_env.getDynamicWorld()->addAction(m_IA);
|
||||
m_env->getDynamicWorld()->addAction(m_IA);
|
||||
}
|
||||
m_elementInPhysicsSystem = true;
|
||||
}
|
||||
@ -496,12 +494,12 @@ void ege::ElementGame::dynamicDisable() {
|
||||
return;
|
||||
}
|
||||
if(nullptr!=m_IA) {
|
||||
m_env.getDynamicWorld()->removeAction(m_IA);
|
||||
m_env->getDynamicWorld()->removeAction(m_IA);
|
||||
}
|
||||
if(nullptr!=m_body) {
|
||||
// Unlink element from the engine
|
||||
m_env.getDynamicWorld()->removeRigidBody(m_body);
|
||||
m_env.getDynamicWorld()->removeCollisionObject(m_body);
|
||||
m_env->getDynamicWorld()->removeRigidBody(m_body);
|
||||
m_env->getDynamicWorld()->removeCollisionObject(m_body);
|
||||
}
|
||||
m_elementInPhysicsSystem = false;
|
||||
}
|
||||
@ -517,7 +515,7 @@ void ege::ElementGame::iaEnable() {
|
||||
return;
|
||||
}
|
||||
if (true == m_elementInPhysicsSystem) {
|
||||
m_env.getDynamicWorld()->addAction(m_IA);
|
||||
m_env->getDynamicWorld()->addAction(m_IA);
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,7 +525,7 @@ void ege::ElementGame::iaDisable() {
|
||||
return;
|
||||
}
|
||||
if (true == m_elementInPhysicsSystem) {
|
||||
m_env.getDynamicWorld()->removeAction(m_IA);
|
||||
m_env->getDynamicWorld()->removeAction(m_IA);
|
||||
}
|
||||
// remove IA :
|
||||
delete(m_IA);
|
||||
|
@ -33,7 +33,7 @@ namespace ege {
|
||||
private:
|
||||
static void FunctionFreeShape(void* _pointer);
|
||||
protected:
|
||||
ege::Environement& m_env;
|
||||
std::shared_ptr<ege::Environement> m_env;
|
||||
protected:
|
||||
btRigidBody* m_body; //!< all the element have a body == > otherwise it will be not manage with this system...
|
||||
public:
|
||||
@ -42,7 +42,7 @@ namespace ege {
|
||||
* The objest will be stored in a pool of element and keep a second time if needed == > redure memory allocation,
|
||||
* when needed, the system will call the init and un-init function...
|
||||
*/
|
||||
ElementGame(ege::Environement& _env);
|
||||
ElementGame(const std::shared_ptr<ege::Environement>& _env);
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@ -150,7 +150,7 @@ namespace ege {
|
||||
*/
|
||||
virtual void setFireOn(int32_t _groupIdSource, int32_t _type, float _power, const vec3& _center=vec3(0,0,0));
|
||||
/**
|
||||
* @brief Call chan the element life change
|
||||
* @brief Call chan the element life change
|
||||
*/
|
||||
virtual void onLifeChange() { };
|
||||
protected:
|
||||
@ -234,7 +234,7 @@ namespace ege {
|
||||
* @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 ...
|
||||
* @param[in] _removedElement Pointer on the element removed.
|
||||
*/
|
||||
virtual void elementIsRemoved(ege::ElementGame* _removedElement) { };
|
||||
virtual void elementIsRemoved(std::shared_ptr<ege::ElementGame> _removedElement) { };
|
||||
protected:
|
||||
bool m_fixe; //!< is a fixed element == > used for placement of every elements
|
||||
public:
|
||||
@ -275,7 +275,10 @@ namespace ege {
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
localIA(ElementGame& element) : m_element(element) { };
|
||||
localIA(ElementGame& _element) :
|
||||
m_element(_element) {
|
||||
|
||||
};
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
|
@ -9,21 +9,36 @@
|
||||
#include <ege/debug.h>
|
||||
#include <ege/Environement.h>
|
||||
#include <ege/ElementGame.h>
|
||||
#include <ewol/object/Manager.h>
|
||||
|
||||
#include <ewol/openGL/openGL.h>
|
||||
#include <etk/math/Matrix4.h>
|
||||
#include <BulletDynamics/Dynamics/btRigidBody.h>
|
||||
#include <LinearMath/btDefaultMotionState.h>
|
||||
#include <BulletDynamics/Dynamics/btDynamicsWorld.h>
|
||||
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
|
||||
#include <LinearMath/btIDebugDraw.h>
|
||||
#include <btBulletCollisionCommon.h>
|
||||
#include <BulletCollision/CollisionShapes/btConvexPolyhedron.h>
|
||||
#include <BulletCollision/CollisionShapes/btShapeHull.h>
|
||||
#include <LinearMath/btTransformUtil.h>
|
||||
#include <LinearMath/btIDebugDraw.h>
|
||||
#include <btBulletDynamicsCommon.h>
|
||||
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Environement"
|
||||
|
||||
|
||||
ege::ElementGame* ege::Environement::getElementNearest(ege::ElementGame* _sourceRequest, float& _distance) {
|
||||
if (nullptr == _sourceRequest) {
|
||||
std::shared_ptr<ege::ElementGame> ege::Environement::getElementNearest(std::shared_ptr<ege::ElementGame> _sourceRequest, float& _distance) {
|
||||
if (_sourceRequest == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
vec3 sourcePosition = _sourceRequest->getPosition();
|
||||
ege::ElementGame* result = nullptr;
|
||||
std::shared_ptr<ege::ElementGame> result = nullptr;
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
// chack nullptr pointer
|
||||
if (nullptr == m_listElementGame[iii]) {
|
||||
if (m_listElementGame[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (m_listElementGame[iii]->getGroup() <= 0) {
|
||||
@ -82,10 +97,10 @@ void ege::Environement::getElementNearestFixed(const vec3& _sourcePosition,
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
// chack nullptr pointer
|
||||
result.element = m_listElementGame[iii];
|
||||
if (nullptr == result.element) {
|
||||
if (result.element == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (false == result.element->isFixed()) {
|
||||
if (result.element->isFixed() == false) {
|
||||
continue;
|
||||
}
|
||||
// check distance ...
|
||||
@ -116,7 +131,7 @@ static etk::Hash<ege::createElement_tf>& getHachTableCreating() {
|
||||
}
|
||||
|
||||
void ege::Environement::addCreator(const std::string& _type, ege::createElement_tf _creator) {
|
||||
if (nullptr == _creator) {
|
||||
if (_creator == nullptr) {
|
||||
EGE_ERROR("Try to add an empty CREATOR ...");
|
||||
return;
|
||||
}
|
||||
@ -125,25 +140,23 @@ void ege::Environement::addCreator(const std::string& _type, ege::createElement_
|
||||
EGE_DEBUG("Add creator: " << _type << " (done)");
|
||||
}
|
||||
|
||||
ege::ElementGame* ege::Environement::createElement(const std::string& _type, bool _autoAddElement, enum ege::property _property, void* _value) {
|
||||
std::shared_ptr<ege::ElementGame> ege::Environement::createElement(const std::string& _type, bool _autoAddElement, enum ege::property _property, void* _value) {
|
||||
if (false == getHachTableCreating().exist(_type)) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (nullptr == creatorPointer) {
|
||||
if (creatorPointer == nullptr) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::ElementGame* tmpElement = creatorPointer(*this);
|
||||
if (nullptr == tmpElement) {
|
||||
std::shared_ptr<ege::ElementGame> tmpElement = creatorPointer(std::dynamic_pointer_cast<ege::Environement>(shared_from_this()));
|
||||
if (tmpElement == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (false == tmpElement->init(_property, _value)) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
// remove created element ...
|
||||
delete(tmpElement);
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddElement == true) {
|
||||
@ -152,26 +165,26 @@ ege::ElementGame* ege::Environement::createElement(const std::string& _type, boo
|
||||
return tmpElement;
|
||||
}
|
||||
|
||||
ege::ElementGame* ege::Environement::createElement(const std::string& _type, std::string& _description, bool _autoAddElement) {
|
||||
std::shared_ptr<ege::ElementGame> ege::Environement::createElement(const std::string& _type, std::string& _description, bool _autoAddElement) {
|
||||
return createElement(_type, _autoAddElement, ege::typeString, static_cast<void*>(&_description));
|
||||
}
|
||||
|
||||
ege::ElementGame* ege::Environement::createElement(const std::string& _type, ejson::Value* _value, bool _autoAddElement) {
|
||||
std::shared_ptr<ege::ElementGame> ege::Environement::createElement(const std::string& _type, ejson::Value* _value, bool _autoAddElement) {
|
||||
return createElement(_type, _autoAddElement, ege::typeJson, static_cast<void*>(_value));
|
||||
}
|
||||
|
||||
ege::ElementGame* ege::Environement::createElement(const std::string& _type, exml::Node* _node, bool _autoAddElement) {
|
||||
std::shared_ptr<ege::ElementGame> ege::Environement::createElement(const std::string& _type, exml::Node* _node, bool _autoAddElement) {
|
||||
return createElement(_type, _autoAddElement, ege::typeXml, static_cast<void*>(_node));
|
||||
}
|
||||
|
||||
|
||||
void ege::Environement::addElementGame(ege::ElementGame* _newElement) {
|
||||
void ege::Environement::addElementGame(std::shared_ptr<ege::ElementGame> _newElement) {
|
||||
// prevent memory allocation and un allocation ...
|
||||
if (nullptr == _newElement) {
|
||||
if (_newElement == nullptr) {
|
||||
return;
|
||||
}
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
if (nullptr == m_listElementGame[iii]) {
|
||||
if (m_listElementGame[iii] == nullptr) {
|
||||
m_listElementGame[iii] = _newElement;
|
||||
m_listElementGame[iii]->dynamicEnable();
|
||||
return;
|
||||
@ -181,13 +194,13 @@ void ege::Environement::addElementGame(ege::ElementGame* _newElement) {
|
||||
_newElement->dynamicEnable();
|
||||
}
|
||||
|
||||
void ege::Environement::rmElementGame(ege::ElementGame* _removeElement) {
|
||||
if (nullptr == _removeElement) {
|
||||
void ege::Environement::rmElementGame(std::shared_ptr<ege::ElementGame> _removeElement) {
|
||||
if (_removeElement == nullptr) {
|
||||
return;
|
||||
}
|
||||
// inform the element that an element has been removed == > this permit to keep pointer on elements ...
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
if (nullptr != m_listElementGame[iii]) {
|
||||
if (m_listElementGame[iii] != nullptr) {
|
||||
m_listElementGame[iii]->elementIsRemoved(_removeElement);
|
||||
}
|
||||
}
|
||||
@ -197,8 +210,7 @@ void ege::Environement::rmElementGame(ege::ElementGame* _removeElement) {
|
||||
m_listElementGame[iii]->onDestroy();
|
||||
m_listElementGame[iii]->dynamicDisable();
|
||||
m_listElementGame[iii]->unInit();
|
||||
delete(m_listElementGame[iii]);
|
||||
m_listElementGame[iii] = nullptr;
|
||||
m_listElementGame[iii].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,17 +283,91 @@ void ege::Environement::generateInteraction(ege::ElementInteraction& _event) {
|
||||
}
|
||||
|
||||
ege::Environement::Environement() :
|
||||
m_dynamicsWorld(nullptr),
|
||||
signalPlayTimeChange(*this, "time-change"),
|
||||
m_dynamicsWorld(),
|
||||
m_listElementGame(),
|
||||
m_status(*this, "status", gameStart, "Satus of the activity of the Environement"),
|
||||
m_ratio(*this, "ratio", 1.0f, "game speed ratio"),
|
||||
m_particuleEngine(*this) {
|
||||
// nothing to do ...
|
||||
m_status.add(gameStart, "start", "Scene is started");
|
||||
m_status.add(gameStop, "stop", "Scene is stopped");
|
||||
}
|
||||
|
||||
void ege::Environement::init() {
|
||||
ewol::Object::init();
|
||||
getObjectManager().periodicCall.bind(shared_from_this(), &ege::Environement::periodicCall);
|
||||
|
||||
}
|
||||
|
||||
void ege::Environement::clear() {
|
||||
for (auto &it : m_listElementGame) {
|
||||
if (it != nullptr) {
|
||||
delete it;
|
||||
it = nullptr;
|
||||
}
|
||||
}
|
||||
m_listElementGame.clear();
|
||||
}
|
||||
|
||||
|
||||
void ege::Environement::periodicCall(const ewol::event::Time& _event) {
|
||||
float curentDelta = _event.getDeltaCall();
|
||||
// small hack to change speed ...
|
||||
curentDelta *= m_ratio;
|
||||
// check if the processing is availlable
|
||||
if (m_status.get() == gameStop) {
|
||||
return;
|
||||
}
|
||||
// update game time:
|
||||
int32_t lastGameTime = m_gameTime*0.000001f;
|
||||
m_gameTime += curentDelta;
|
||||
if (lastGameTime != (int32_t)(m_gameTime*0.000001f)) {
|
||||
signalPlayTimeChange.emit(m_gameTime*0.000001f);
|
||||
}
|
||||
|
||||
//EWOL_DEBUG("Time: m_lastCallTime=" << m_lastCallTime << " deltaTime=" << deltaTime);
|
||||
|
||||
// update camera positions:
|
||||
for (auto &it : m_listCamera) {
|
||||
if (it.second != nullptr) {
|
||||
it.second->periodicCall(curentDelta);
|
||||
}
|
||||
}
|
||||
//EGE_DEBUG("stepSimulation (start)");
|
||||
///step the simulation
|
||||
if (m_dynamicsWorld != nullptr) {
|
||||
m_dynamicsWorld->stepSimulation(curentDelta);
|
||||
//optional but useful: debug drawing
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
}
|
||||
m_particuleEngine.update(curentDelta);
|
||||
// remove all element that requested it ...
|
||||
{
|
||||
int32_t numberEnnemyKilled=0;
|
||||
int32_t victoryPoint=0;
|
||||
auto it(m_listElementGame.begin());
|
||||
while (it != m_listElementGame.end()) {
|
||||
if(*it != nullptr) {
|
||||
if ((*it)->needToRemove() == true) {
|
||||
if ((*it)->getGroup() > 1) {
|
||||
numberEnnemyKilled++;
|
||||
victoryPoint++;
|
||||
}
|
||||
EGE_DEBUG("[" << (*it)->getUID() << "] element Removing ... " << (*it)->getType());
|
||||
rmElementGame((*it));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0 != numberEnnemyKilled) {
|
||||
//signalKillEnemy.emit(numberEnnemyKilled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ege::Environement::addCamera(const std::string& _name, const std::shared_ptr<ege::Camera>& _camera) {
|
||||
m_listCamera.insert(std::make_pair(_name, _camera));
|
||||
}
|
||||
|
||||
std::shared_ptr<ege::Camera> ege::Environement::getCamera(const std::string& _name) {
|
||||
auto cameraIt = m_listCamera.find(_name);
|
||||
if (cameraIt != m_listCamera.end()) {
|
||||
return cameraIt->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ class btDynamicsWorld;
|
||||
#include <ejson/ejson.h>
|
||||
#include <exml/exml.h>
|
||||
#include <ege/ParticuleEngine.h>
|
||||
#include <ewol/object/Object.h>
|
||||
#include <ewol/signal/Signal.h>
|
||||
#include <ewol/event/Time.h>
|
||||
|
||||
namespace ege {
|
||||
enum property {
|
||||
@ -36,7 +39,13 @@ namespace ege {
|
||||
};
|
||||
class ElementGame;
|
||||
class Environement;
|
||||
typedef ege::ElementGame* (*createElement_tf)(ege::Environement& _env);
|
||||
typedef std::shared_ptr<ege::ElementGame> (*createElement_tf)(const std::shared_ptr<ege::Environement>& _env);
|
||||
|
||||
enum gameStatus {
|
||||
gameStart,
|
||||
gamePause,
|
||||
gameStop
|
||||
};
|
||||
|
||||
class ElementInteraction {
|
||||
protected:
|
||||
@ -76,13 +85,58 @@ namespace ege {
|
||||
virtual void applyEvent(ege::ElementGame& _element) { };
|
||||
};
|
||||
|
||||
class Environement {
|
||||
private:
|
||||
btDynamicsWorld* m_dynamicsWorld; //!< curent system world description
|
||||
std::vector<ege::ElementGame*> m_listElementGame; //!< List of all element added in the Game
|
||||
class Environement : public ewol::Object {
|
||||
public:
|
||||
// extern event
|
||||
ewol::Signal<float> signalPlayTimeChange;
|
||||
private:
|
||||
std::shared_ptr<btDynamicsWorld> m_dynamicsWorld; //!< curent system world description
|
||||
std::vector<std::shared_ptr<ege::ElementGame>> m_listElementGame; //!< List of all element added in the Game
|
||||
protected:
|
||||
Environement();
|
||||
void init();
|
||||
public:
|
||||
DECLARE_FACTORY(Environement);
|
||||
virtual ~Environement() { };
|
||||
protected:
|
||||
ewol::parameter::List<enum gameStatus> m_status; //!< the display is running (not in pause)
|
||||
public:
|
||||
/**
|
||||
* @brief Get the game status.
|
||||
* @return the current status.
|
||||
*/
|
||||
enum gameStatus getGameStatus() {
|
||||
return m_status.get();
|
||||
}
|
||||
/**
|
||||
* @brief Set the game status.
|
||||
* @param[in] _value New game status.
|
||||
*/
|
||||
void setGameStatus(enum gameStatus _value) {
|
||||
m_status.set(_value);
|
||||
}
|
||||
protected:
|
||||
ewol::parameter::List<float> m_ratio; //!< Speed ratio
|
||||
public:
|
||||
/**
|
||||
* @brief Get the game speed ratio.
|
||||
* @return the current ratio.
|
||||
*/
|
||||
float getSpeedRatio() {
|
||||
return m_ratio.get();
|
||||
}
|
||||
/**
|
||||
* @brief Set the game ratio.
|
||||
* @param[in] _value New game ratio.
|
||||
*/
|
||||
void setSpeedRatio(float _value) {
|
||||
m_ratio.set(_value);
|
||||
}
|
||||
protected:
|
||||
std::map<std::string, std::shared_ptr<ege::Camera>> m_listCamera; //!< list of all camera in the world
|
||||
public:
|
||||
void addCamera(const std::string& _name, const std::shared_ptr<ege::Camera>& _camera);
|
||||
std::shared_ptr<ege::Camera> getCamera(const std::string& _name);
|
||||
public:
|
||||
/**
|
||||
* @brief Remove all from the current environement
|
||||
@ -102,35 +156,35 @@ namespace ege {
|
||||
* @return nullptr if an error occured OR the pointer on the element and it is already added on the system.
|
||||
* @note Pointer is return in case of setting properties on it...
|
||||
*/
|
||||
ege::ElementGame* createElement(const std::string& _type, bool _autoAddElement=true, enum ege::property _property=ege::typeNone, void* _value=nullptr);
|
||||
ege::ElementGame* createElement(const std::string& _type, std::string& _description, bool _autoAddElement=true);
|
||||
ege::ElementGame* createElement(const std::string& _type, ejson::Value* _value, bool _autoAddElement=true);
|
||||
ege::ElementGame* createElement(const std::string& _type, exml::Node* _node, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::ElementGame> createElement(const std::string& _type, bool _autoAddElement=true, enum ege::property _property=ege::typeNone, void* _value=nullptr);
|
||||
std::shared_ptr<ege::ElementGame> createElement(const std::string& _type, std::string& _description, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::ElementGame> createElement(const std::string& _type, ejson::Value* _value, bool _autoAddElement=true);
|
||||
std::shared_ptr<ege::ElementGame> createElement(const std::string& _type, exml::Node* _node, bool _autoAddElement=true);
|
||||
public:
|
||||
class ResultNearestElement {
|
||||
public:
|
||||
ege::ElementGame* element;
|
||||
std::shared_ptr<ege::ElementGame> element;
|
||||
float dist;
|
||||
};
|
||||
/**
|
||||
* @brief set the curent world
|
||||
* @param[in] _newWorld Pointer on the current world
|
||||
*/
|
||||
void setDynamicWorld(btDynamicsWorld* _newWorld) {
|
||||
void setDynamicWorld(const std::shared_ptr<btDynamicsWorld>& _newWorld) {
|
||||
m_dynamicsWorld=_newWorld;
|
||||
};
|
||||
/**
|
||||
* @brief get the curent world
|
||||
* @return pointer on the current world
|
||||
*/
|
||||
btDynamicsWorld* getDynamicWorld() {
|
||||
std::shared_ptr<btDynamicsWorld> getDynamicWorld() {
|
||||
return m_dynamicsWorld;
|
||||
};
|
||||
/**
|
||||
* @breif get a reference on the curent list of element games
|
||||
* @return all element list
|
||||
*/
|
||||
std::vector<ege::ElementGame*>& getElementGame() {
|
||||
std::vector<std::shared_ptr<ege::ElementGame>>& getElementGame() {
|
||||
return m_listElementGame;
|
||||
};
|
||||
/**
|
||||
@ -139,7 +193,7 @@ namespace ege {
|
||||
* @param[in] _distance Maximum distance search == > return the element distance
|
||||
* @return Pointer on the neares element OR nullptr
|
||||
*/
|
||||
ege::ElementGame* getElementNearest(ege::ElementGame* _sourceRequest, float& _distance);
|
||||
std::shared_ptr<ege::ElementGame> getElementNearest(std::shared_ptr<ege::ElementGame> _sourceRequest, float& _distance);
|
||||
|
||||
void getElementNearest(const vec3& _sourcePosition,
|
||||
float _distanceMax,
|
||||
@ -151,12 +205,12 @@ namespace ege {
|
||||
* @brief add an element on the list availlable.
|
||||
* @param[in] _newElement Element to add.
|
||||
*/
|
||||
void addElementGame(ege::ElementGame* _newElement);
|
||||
void addElementGame(std::shared_ptr<ege::ElementGame> _newElement);
|
||||
/**
|
||||
* @brief remove an element on the list availlable.
|
||||
* @param[in] _removeElement Element to remove.
|
||||
*/
|
||||
void rmElementGame(ege::ElementGame* _removeElement);
|
||||
void rmElementGame(std::shared_ptr<ege::ElementGame> _removeElement);
|
||||
/**
|
||||
* @brief get the element order from the nearest to the farest, and remove all element that are not in the camera angle and axes.
|
||||
* @param[in,out] _resultList List of the element ordered.
|
||||
@ -179,6 +233,12 @@ namespace ege {
|
||||
ege::ParticuleEngine& getParticuleEngine() {
|
||||
return m_particuleEngine;
|
||||
};
|
||||
protected:
|
||||
int64_t m_gameTime; //!< time of the game running
|
||||
public:
|
||||
|
||||
private:
|
||||
void periodicCall(const ewol::event::Time& _event);
|
||||
};
|
||||
};
|
||||
|
||||
|
35
ege/Game.h
35
ege/Game.h
@ -45,45 +45,10 @@ namespace ege {
|
||||
void init();
|
||||
public:
|
||||
~Game()
|
||||
protected:
|
||||
ewol::parameter::List<enum gameStatus> m_status; //!< the display is running (not in pause)
|
||||
public:
|
||||
/**
|
||||
* @brief Get the game status.
|
||||
* @return the current status.
|
||||
*/
|
||||
enum gameStatus getGameStatus() {
|
||||
return m_status.get()
|
||||
}
|
||||
/**
|
||||
* @brief Set the game status.
|
||||
* @param[in] _value New game status.
|
||||
*/
|
||||
enum gameStatus setGameStatus(enum gameStatus _value) {
|
||||
return m_status.set(_value)
|
||||
}
|
||||
protected:
|
||||
ewol::parameter::List<float> m_ratio; //!< Speed ratio
|
||||
public:
|
||||
/**
|
||||
* @brief Get the game speed ratio.
|
||||
* @return the current ratio.
|
||||
*/
|
||||
float getSpeedRatio() {
|
||||
return m_ratio.get()
|
||||
}
|
||||
/**
|
||||
* @brief Set the game ratio.
|
||||
* @param[in] _value New game ratio.
|
||||
*/
|
||||
enum gameStatus setSpeedRatio(float _value) {
|
||||
return m_ratio.set(_value)
|
||||
}
|
||||
protected:
|
||||
ege::PhysicEngine m_physicEngine; //!< physic engine interface
|
||||
ege::AudioEngine m_AudioEngine; //!< physic engine interface
|
||||
ege::IAEngine m_iAEngine; //!< physic engine interface
|
||||
std::map<std::string, std::shared_ptr<ege::Camera>> m_listCamera; //!< list of all camera in the world
|
||||
|
||||
}
|
||||
}
|
||||
|
66
ege/physics/Engine.cpp
Normal file
66
ege/physics/Engine.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ege/physics/Engine.h>
|
||||
|
||||
|
||||
|
||||
ege::physics::Engine::Engine() {
|
||||
setBulletConfig();
|
||||
}
|
||||
|
||||
ege::physics::Engine::~Engine() {
|
||||
/*
|
||||
m_dynamicsWorld.release();
|
||||
m_solver.release();
|
||||
m_broadphase.release();
|
||||
m_dispatcher.release();
|
||||
m_collisionConfiguration.release();
|
||||
*/
|
||||
}
|
||||
|
||||
void ege::physics::Engine::setBulletConfig(std::make_shared(btDefaultCollisionConfiguration> _collisionConfiguration,
|
||||
std::make_shared(btCollisionDispatcher> _dispatcher,
|
||||
std::make_shared(btBroadphaseInterface> _broadphase,
|
||||
std::make_shared(btConstraintSolver> _solver,
|
||||
std::make_shared(btDynamicsWorld> _dynamicsWorld) {
|
||||
if (_collisionConfiguration != nullptr) {
|
||||
m_collisionConfiguration = _collisionConfiguration;
|
||||
} else {
|
||||
m_collisionConfiguration = std::make_shared(btDefaultCollisionConfiguration());
|
||||
}
|
||||
///use the default collision dispatcher.
|
||||
if (_dispatcher != nullptr) {
|
||||
m_dispatcher = _dispatcher;
|
||||
} else {
|
||||
m_dispatcher = std::make_shared(btCollisionDispatcher(m_collisionConfiguration));
|
||||
}
|
||||
if (_broadphase != nullptr) {
|
||||
m_broadphase = _broadphase;
|
||||
} else {
|
||||
m_broadphase = std::make_shared(btDbvtBroadphase());
|
||||
}
|
||||
|
||||
///the default constraint solver.
|
||||
if (_solver != nullptr) {
|
||||
m_solver = _solver;
|
||||
} else {
|
||||
m_solver = std::make_shared(btSequentialImpulseConstraintSolver());
|
||||
}
|
||||
|
||||
if (_dynamicsWorld != nullptr) {
|
||||
m_dynamicsWorld = _dynamicsWorld;
|
||||
} else {
|
||||
m_dynamicsWorld = std::make_shared(btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration));
|
||||
// By default we set no gravity
|
||||
m_dynamicsWorld->setGravity(btVector3(0,0,0));
|
||||
}
|
||||
|
||||
m_env.setDynamicWorld(m_dynamicsWorld);
|
||||
|
||||
}
|
58
ege/physics/Engine.h
Normal file
58
ege/physics/Engine.h
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EGE_PHYSICS_ENGINE_H__
|
||||
#define __EGE_PHYSICS_ENGINE_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/math/Matrix4.h>
|
||||
#include <vector>
|
||||
#include <ewol/debug.h>
|
||||
#include <ege/Camera.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
#include <ewol/resource/Manager.h>
|
||||
#include <ege/ElementGame.h>
|
||||
#include <ewol/Dimension.h>
|
||||
|
||||
class btBroadphaseInterface;
|
||||
class btCollisionShape;
|
||||
class btOverlappingPairCache;
|
||||
class btCollisionDispatcher;
|
||||
class btConstraintSolver;
|
||||
struct btCollisionAlgorithmCreateFunc;
|
||||
class btDefaultCollisionConfiguration;
|
||||
class btDynamicsWorld;
|
||||
#include <LinearMath/btScalar.h>
|
||||
class btVector3;
|
||||
|
||||
|
||||
namespace ege {
|
||||
namespace physics {
|
||||
class Engine {
|
||||
private:
|
||||
///this is the most important class
|
||||
std::shared_ptr<btDefaultCollisionConfiguration< m_collisionConfiguration;
|
||||
std::shared_ptr<btCollisionDispatcher> m_dispatcher;
|
||||
std::shared_ptr<btBroadphaseInterface> m_broadphase;
|
||||
std::shared_ptr<btConstraintSolver> m_solver;
|
||||
std::shared_ptr<btDynamicsWorld> m_dynamicsWorld;
|
||||
public:
|
||||
Engine();
|
||||
~Engine();
|
||||
void setBulletConfig(std::shared_ptr<btDefaultCollisionConfiguration> _collisionConfiguration=nullptr,
|
||||
std::shared_ptr<btCollisionDispatcher> _dispatcher=nullptr,
|
||||
std::shared_ptr<btBroadphaseInterface> _broadphase=nullptr,
|
||||
std::shared_ptr<btConstraintSolver> _solver=nullptr,
|
||||
std::shared_ptr<btDynamicsWorld> _dynamicsWorld=nullptr);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -15,21 +15,21 @@
|
||||
#include <ege/physicsShape/PhysicsSphere.h>
|
||||
|
||||
|
||||
ege::PhysicsShape* ege::PhysicsShape::create(const std::string& _name) {
|
||||
ege::PhysicsShape* tmpp = nullptr;
|
||||
std::shared_ptr<ege::PhysicsShape> ege::PhysicsShape::create(const std::string& _name) {
|
||||
std::shared_ptr<ege::PhysicsShape> tmpp = nullptr;
|
||||
std::string name = etk::tolower(_name);
|
||||
if (name == "box") {
|
||||
tmpp = new ege::PhysicsBox();
|
||||
tmpp = std::make_shared<ege::PhysicsBox>();
|
||||
} else if (name == "sphere") {
|
||||
tmpp = new ege::PhysicsSphere();
|
||||
tmpp = std::make_shared<ege::PhysicsSphere>();
|
||||
} else if (name == "cone") {
|
||||
tmpp = new ege::PhysicsCone();
|
||||
tmpp = std::make_shared<ege::PhysicsCone>();
|
||||
} else if (name == "cylinder") {
|
||||
tmpp = new ege::PhysicsCylinder();
|
||||
tmpp = std::make_shared<ege::PhysicsCylinder>();
|
||||
} else if (name == "capsule") {
|
||||
tmpp = new ege::PhysicsCapsule();
|
||||
tmpp = std::make_shared<ege::PhysicsCapsule>();
|
||||
} else if (name == "convexhull") {
|
||||
tmpp = new ege::PhysicsConvexHull();
|
||||
tmpp = std::make_shared<ege::PhysicsConvexHull>();
|
||||
} else {
|
||||
EGE_ERROR("Create an unknow element : '" << _name << "' availlable : [BOX,SPHERE,CONE,CYLINDER,CAPSULE,CONVEXHULL]");
|
||||
return nullptr;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <etk/types.h>
|
||||
#include <etk/math/Vector4D.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace ege {
|
||||
@ -26,7 +27,7 @@ namespace ege {
|
||||
|
||||
class PhysicsShape {
|
||||
public:
|
||||
static ege::PhysicsShape* create(const std::string& _name);
|
||||
static std::shared_ptr<ege::PhysicsShape> create(const std::string& _name);
|
||||
public:
|
||||
enum type {
|
||||
unknow,
|
||||
|
@ -19,9 +19,7 @@
|
||||
|
||||
ege::resource::Mesh::Mesh() :
|
||||
m_normalMode(normalModeNone),
|
||||
m_checkNormal(false),
|
||||
m_pointerShape(nullptr),
|
||||
m_functionFreeShape(nullptr) {
|
||||
m_checkNormal(false) {
|
||||
addObjectType("ege::resource::Mesh");
|
||||
}
|
||||
|
||||
@ -82,13 +80,7 @@ ege::resource::Mesh::~Mesh() {
|
||||
}
|
||||
|
||||
void ege::resource::Mesh::clean() {
|
||||
for (auto &elem : m_physics) {
|
||||
delete(elem);
|
||||
}
|
||||
m_physics.clear();
|
||||
for (int32_t iii=0; iii<m_materials.size(); ++iii) {
|
||||
delete(m_materials[iii]);
|
||||
}
|
||||
m_materials.clear();
|
||||
m_listFaces.clear();
|
||||
m_listVertexNormal.clear();
|
||||
@ -603,9 +595,9 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
int32_t meshFaceMaterialID = -1;
|
||||
// material global param :
|
||||
std::string materialName = "";
|
||||
ege::Material* material = nullptr;
|
||||
std::shared_ptr<ege::Material> material;
|
||||
// physical shape:
|
||||
ege::PhysicsShape* physics = nullptr;
|
||||
std::shared_ptr<ege::PhysicsShape> physics;
|
||||
while(1) {
|
||||
int32_t level = countIndent(fileName);
|
||||
if (level == 0) {
|
||||
@ -848,7 +840,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
materialName = "";
|
||||
material = nullptr;
|
||||
}
|
||||
material = new ege::Material();
|
||||
material = std::make_shared<ege::Material>();
|
||||
materialName = inputDataLine;
|
||||
currentMode = EMFModuleMaterialNamed;
|
||||
EGE_VERBOSE(" "<< materialName);
|
||||
@ -927,7 +919,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
&& material!=nullptr) {
|
||||
m_materials.add(materialName, material);
|
||||
materialName = "";
|
||||
material = nullptr;
|
||||
material.reset();
|
||||
}
|
||||
EGE_VERBOSE("Stop parsing Mesh file");
|
||||
|
||||
@ -936,7 +928,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ege::resource::Mesh::addMaterial(const std::string& _name, ege::Material* _data) {
|
||||
void ege::resource::Mesh::addMaterial(const std::string& _name, std::shared_ptr<ege::Material> _data) {
|
||||
if (nullptr == _data) {
|
||||
EGE_ERROR(" can not add material with null pointer");
|
||||
return;
|
||||
|
@ -57,16 +57,16 @@ namespace ege {
|
||||
int32_t m_GLtexture;
|
||||
int32_t m_bufferOfset;
|
||||
int32_t m_numberOfElments;
|
||||
MaterialGlId m_GLMaterial;
|
||||
ege::Light m_light;
|
||||
MaterialGlId m_GLMaterial;
|
||||
ege::Light m_light;
|
||||
protected:
|
||||
std::vector<vec3> m_listVertex; //!< List of all vertex in the element
|
||||
std::vector<vec2> m_listUV; //!< List of all UV point in the mesh (for the specify texture)
|
||||
std::vector<vec3> m_listFacesNormal; //!< 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<ege::Material*> m_materials;
|
||||
std::vector<ege::PhysicsShape*> m_physics; //!< collision shape module ... (independent of bullet lib)
|
||||
etk::Hash<std::shared_ptr<ege::Material>> m_materials;
|
||||
std::vector<std::shared_ptr<ege::PhysicsShape>> m_physics; //!< collision shape module ... (independent of bullet lib)
|
||||
void clean();
|
||||
protected:
|
||||
std::shared_ptr<ewol::resource::VirtualBufferObject> m_verticesVBO;
|
||||
@ -95,7 +95,7 @@ namespace ege {
|
||||
bool loadOBJ(const std::string& _fileName);
|
||||
bool loadEMF(const std::string& _fileName);
|
||||
public:
|
||||
void addMaterial(const std::string& _name, ege::Material* _data);
|
||||
void addMaterial(const std::string& _name, std::shared_ptr<ege::Material> _data);
|
||||
public:
|
||||
/**
|
||||
* @brief set the check of normal position befor sending it to the openGl card
|
||||
@ -111,7 +111,7 @@ namespace ege {
|
||||
bool getCheckNormal() {
|
||||
return m_checkNormal;
|
||||
};
|
||||
const std::vector<ege::PhysicsShape*>& getPhysicalProperties() const {
|
||||
const std::vector<std::shared_ptr<ege::PhysicsShape>>& getPhysicalProperties() const {
|
||||
return m_physics;
|
||||
};
|
||||
private:
|
||||
|
@ -32,7 +32,7 @@ static int32_t addUV(std::vector<vec2>& _listUV, int32_t _uvId, float _add) {
|
||||
return _listUV.size()-1;
|
||||
}
|
||||
|
||||
void ege::icoSphere::create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
void ege::icoSphere::create(etk::Hash<std::shared_ptr<ege::Material>>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, float _size, int32_t _recursionLevel) {
|
||||
/*
|
||||
5
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace ege {
|
||||
namespace icoSphere {
|
||||
void create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
void create(etk::Hash<std::shared_ptr<ege::Material>>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, float _size, int32_t _recursionLevel);
|
||||
};
|
||||
};
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <ege/debug.h>
|
||||
#include <ege/resource/tools/isoSphere.h>
|
||||
|
||||
void ege::isoSphere::create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
void ege::isoSphere::create(etk::Hash<std::shared_ptr<ege::Material>>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, int32_t _recursionLevel) {
|
||||
_recursionLevel = std::max(_recursionLevel, 3);
|
||||
float size = 1.0f;
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace ege {
|
||||
namespace isoSphere {
|
||||
void create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
void create(etk::Hash<std::shared_ptr<ege::Material>>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, int32_t _recursionLevel);
|
||||
};
|
||||
};
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
|
||||
void ege::viewBox::create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
void ege::viewBox::create(etk::Hash<std::shared_ptr<ege::Material>>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, float _size) {
|
||||
// This is the direct generation basis on the .obj system
|
||||
/*
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace ege {
|
||||
namespace viewBox {
|
||||
void create(etk::Hash<ege::Material*>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
void create(etk::Hash<std::shared_ptr<ege::Material>>& _materials, etk::Hash<FaceIndexing>& _listFaces, std::vector<vec3>& _listVertex, std::vector<vec2>& _listUV,
|
||||
const std::string& _materialName, float _size);
|
||||
};
|
||||
};
|
||||
|
@ -30,29 +30,28 @@
|
||||
#undef __class__
|
||||
#define __class__ "Scene"
|
||||
|
||||
ege::widget::Scene::Scene() :
|
||||
signalPlayTimeChange(*this, "time-change"),
|
||||
signalKillEnemy(*this, "kill-ennemy"),
|
||||
m_gameTime(0),
|
||||
m_angleView(M_PI/3.0),
|
||||
m_dynamicsWorld(nullptr),
|
||||
m_camera(nullptr),
|
||||
m_isRunning(*this, "status", gameStart, "Satus of the activity of the Scene"),
|
||||
m_debugMode(false),
|
||||
m_debugDrawing(nullptr) {
|
||||
ege::widget::Scene::Scene() //:
|
||||
//signalKillEnemy(*this, "kill-ennemy"),
|
||||
//m_gameTime(0),
|
||||
//m_angleView(M_PI/3.0),
|
||||
//m_dynamicsWorld(nullptr),
|
||||
//m_camera(nullptr),
|
||||
//m_debugMode(false),
|
||||
//m_debugDrawing(nullptr)
|
||||
{
|
||||
addObjectType("ege::widget::Scene");
|
||||
}
|
||||
|
||||
void ege::widget::Scene::init(bool _setAutoBullet, bool _setAutoCamera) {
|
||||
void ege::widget::Scene::init(std::shared_ptr<ege::Environement> _env) {
|
||||
m_env = _env;
|
||||
ewol::Widget::init();
|
||||
setKeyboardRepeate(false);
|
||||
setCanHaveFocus(true);
|
||||
periodicCallEnable();
|
||||
m_isRunning.add(gameStart, "start", "Scene is started");
|
||||
m_isRunning.add(gameStop, "stop", "Scene is stopped");
|
||||
|
||||
m_debugDrawing = ewol::resource::Colored3DObject::create();
|
||||
//m_debugDrawing = ewol::resource::Colored3DObject::create();
|
||||
|
||||
/*
|
||||
m_ratioTime = 1.0f;
|
||||
if (_setAutoBullet == true) {
|
||||
setBulletConfig();
|
||||
@ -60,49 +59,10 @@ void ege::widget::Scene::init(bool _setAutoBullet, bool _setAutoCamera) {
|
||||
if (_setAutoCamera == true) {
|
||||
setCamera();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void ege::widget::Scene::setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration,
|
||||
btCollisionDispatcher* _dispatcher,
|
||||
btBroadphaseInterface* _broadphase,
|
||||
btConstraintSolver* _solver,
|
||||
btDynamicsWorld* _dynamicsWorld) {
|
||||
if (nullptr != _collisionConfiguration) {
|
||||
m_collisionConfiguration = _collisionConfiguration;
|
||||
} else {
|
||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
}
|
||||
///use the default collision dispatcher.
|
||||
if (nullptr != _dispatcher) {
|
||||
m_dispatcher = _dispatcher;
|
||||
} else {
|
||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||
}
|
||||
if (nullptr != _broadphase) {
|
||||
m_broadphase = _broadphase;
|
||||
} else {
|
||||
m_broadphase = new btDbvtBroadphase();
|
||||
}
|
||||
|
||||
///the default constraint solver.
|
||||
if (nullptr != _solver) {
|
||||
m_solver = _solver;
|
||||
} else {
|
||||
m_solver = new btSequentialImpulseConstraintSolver();
|
||||
}
|
||||
|
||||
if (nullptr != _dynamicsWorld) {
|
||||
m_dynamicsWorld = _dynamicsWorld;
|
||||
} else {
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||
// By default we set no gravity
|
||||
m_dynamicsWorld->setGravity(btVector3(0,0,0));
|
||||
}
|
||||
|
||||
m_env.setDynamicWorld(m_dynamicsWorld);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void ege::widget::Scene::setCamera(ege::Camera* _camera) {
|
||||
if (nullptr != _camera) {
|
||||
m_camera = _camera;
|
||||
@ -112,10 +72,9 @@ void ege::widget::Scene::setCamera(ege::Camera* _camera) {
|
||||
m_camera->setEye(vec3(0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
ege::widget::Scene::~Scene() {
|
||||
|
||||
/*
|
||||
/*
|
||||
ewol::resource::release(m_directDrawObject);
|
||||
//cleanup in the reverse order of creation/initialization
|
||||
//remove the rigidbodies from the dynamics world and delete them
|
||||
@ -128,12 +87,6 @@ ege::widget::Scene::~Scene() {
|
||||
m_dynamicsWorld->removeCollisionObject( obj );
|
||||
delete obj;
|
||||
}
|
||||
|
||||
delete m_dynamicsWorld;
|
||||
delete m_solver;
|
||||
delete m_broadphase;
|
||||
delete m_dispatcher;
|
||||
delete m_collisionConfiguration;
|
||||
*/
|
||||
}
|
||||
|
||||
@ -143,26 +96,6 @@ void ege::widget::Scene::onRegenerateDisplay() {
|
||||
}
|
||||
}
|
||||
|
||||
void ege::widget::Scene::pause() {
|
||||
EGE_DEBUG("Set pause");
|
||||
m_isRunning.set(gameStop);
|
||||
}
|
||||
|
||||
void ege::widget::Scene::resume() {
|
||||
EGE_DEBUG("Set resume");
|
||||
m_isRunning.set(gameStart);
|
||||
}
|
||||
|
||||
void ege::widget::Scene::pauseToggle() {
|
||||
if(m_isRunning.get() == gameStart) {
|
||||
EGE_DEBUG("Set Toggle: pause");
|
||||
m_isRunning.set(gameStop);
|
||||
} else {
|
||||
EGE_DEBUG("Set Toggle: resume");
|
||||
m_isRunning.set(gameStart);
|
||||
}
|
||||
}
|
||||
|
||||
//#define SCENE_DISPLAY_SPEED
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -179,15 +112,19 @@ void ege::widget::Scene::onDraw() {
|
||||
g_counterNbTimeDisplay++;
|
||||
g_startTime = ewol::getTime();
|
||||
#endif
|
||||
// get camera :
|
||||
std::shared_ptr<ege::Camera> camera = m_env->getCamera(m_cameraName);
|
||||
//EGE_DEBUG("Draw (start)");
|
||||
mat4 tmpMatrix;
|
||||
if (m_dynamicsWorld) {
|
||||
m_env.getOrderedElementForDisplay(m_displayElementOrdered, m_camera->getOrigin(), m_camera->getViewVector());
|
||||
std::shared_ptr<btDynamicsWorld> world = m_env->getDynamicWorld();
|
||||
if (world != nullptr) {
|
||||
|
||||
m_env->getOrderedElementForDisplay(m_displayElementOrdered, camera->getOrigin(), camera->getViewVector());
|
||||
//EGE_DEBUG("DRAW : " << m_displayElementOrdered.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(*m_camera);
|
||||
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)
|
||||
@ -205,9 +142,12 @@ void ege::widget::Scene::onDraw() {
|
||||
m_displayElementOrdered[iii].element->draw(pass);
|
||||
}
|
||||
}
|
||||
/*
|
||||
for (size_t iii=0; iii<m_displayElementOrdered.size(); iii++) {
|
||||
m_displayElementOrdered[iii].element->drawLife(m_debugDrawing, *m_camera);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
#ifdef DEBUG
|
||||
if (true == m_debugMode) {
|
||||
for (size_t iii=0; iii<m_displayElementOrdered.size(); iii++) {
|
||||
@ -215,9 +155,10 @@ void ege::widget::Scene::onDraw() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
if (nullptr!=m_camera) {
|
||||
m_env.getParticuleEngine().draw(*m_camera);
|
||||
if (camera != nullptr) {
|
||||
m_env->getParticuleEngine().draw(*camera);
|
||||
}
|
||||
#ifdef SCENE_DISPLAY_SPEED
|
||||
float localTime = (float)(ewol::getTime() - g_startTime) / 1000.0f;
|
||||
@ -238,59 +179,6 @@ btRigidBody& btActionInterface::getFixedBody() {
|
||||
}
|
||||
|
||||
void ege::widget::Scene::periodicCall(const ewol::event::Time& _event) {
|
||||
float curentDelta=_event.getDeltaCall();
|
||||
// small hack to change speed ...
|
||||
if (m_ratioTime != 1) {
|
||||
curentDelta *= m_ratioTime;
|
||||
}
|
||||
// check if the processing is availlable
|
||||
if (m_isRunning.get() == gameStop) {
|
||||
markToRedraw();
|
||||
return;
|
||||
}
|
||||
// update game time:
|
||||
int32_t lastGameTime = m_gameTime;
|
||||
m_gameTime += curentDelta;
|
||||
if (lastGameTime != (int32_t)m_gameTime) {
|
||||
signalPlayTimeChange.emit(m_gameTime);
|
||||
}
|
||||
|
||||
//EWOL_DEBUG("Time: m_lastCallTime=" << m_lastCallTime << " deltaTime=" << deltaTime);
|
||||
|
||||
// update camera positions:
|
||||
if (nullptr != m_camera) {
|
||||
m_camera->periodicCall(curentDelta);
|
||||
}
|
||||
//EGE_DEBUG("stepSimulation (start)");
|
||||
///step the simulation
|
||||
if (m_dynamicsWorld) {
|
||||
m_dynamicsWorld->stepSimulation(curentDelta);
|
||||
//optional but useful: debug drawing
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
}
|
||||
m_env.getParticuleEngine().update(curentDelta);
|
||||
// remove all element that requested it ...
|
||||
{
|
||||
int32_t numberEnnemyKilled=0;
|
||||
int32_t victoryPoint=0;
|
||||
std::vector<ege::ElementGame*>& elementList = m_env.getElementGame();
|
||||
for (int32_t iii=elementList.size()-1; iii >= 0; --iii) {
|
||||
if(nullptr != elementList[iii]) {
|
||||
if (true == elementList[iii]->needToRemove()) {
|
||||
if (elementList[iii]->getGroup() > 1) {
|
||||
numberEnnemyKilled++;
|
||||
victoryPoint++;
|
||||
}
|
||||
EGE_DEBUG("[" << elementList[iii]->getUID() << "] element Removing ... " << elementList[iii]->getType());
|
||||
m_env.rmElementGame(elementList[iii]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != numberEnnemyKilled) {
|
||||
signalKillEnemy.emit(numberEnnemyKilled);
|
||||
}
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@ -317,17 +205,17 @@ int64_t tmp___startTime1 = ewol::getTime();
|
||||
#endif
|
||||
float ratio = m_size.x() / m_size.y();
|
||||
//EWOL_INFO("ratio : " << ratio);
|
||||
mat4 tmpProjection = etk::matPerspective(m_angleView, ratio, GAME_Z_NEAR, GAME_Z_FAR);
|
||||
// TODO : mat4 tmpProjection = etk::matPerspective(m_angleView, ratio, GAME_Z_NEAR, GAME_Z_FAR);
|
||||
#ifdef SCENE_BRUT_PERFO_TEST
|
||||
float tmp___localTime1 = (float)(ewol::getTime() - tmp___startTime1) / 1000.0f;
|
||||
EWOL_DEBUG(" SCENE111 : " << tmp___localTime1 << "ms ");
|
||||
int64_t tmp___startTime2 = ewol::getTime();
|
||||
#endif
|
||||
ewol::openGL::setCameraMatrix(m_camera->getMatrix());
|
||||
// TODO : ewol::openGL::setCameraMatrix(m_camera->getMatrix());
|
||||
//mat4 tmpMat = tmpProjection * m_camera->getMatrix();
|
||||
// set internal matrix system :
|
||||
//ewol::openGL::setMatrix(tmpMat);
|
||||
ewol::openGL::setMatrix(tmpProjection);
|
||||
// TODO : ewol::openGL::setMatrix(tmpProjection);
|
||||
#ifdef SCENE_BRUT_PERFO_TEST
|
||||
float tmp___localTime2 = (float)(ewol::getTime() - tmp___startTime2) / 1000.0f;
|
||||
EWOL_DEBUG(" SCENE222 : " << tmp___localTime2 << "ms ");
|
||||
@ -348,7 +236,7 @@ float tmp___localTime4 = (float)(ewol::getTime() - tmp___startTime4) / 1000.0f;
|
||||
EWOL_DEBUG(" SCENE444 : " << tmp___localTime4 << "ms ");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
vec2 ege::widget::Scene::calculateDeltaAngle(const vec2& _posScreen) {
|
||||
double ratio = m_size.x() / m_size.y();
|
||||
vec2 pos = vec2(m_size.x()/-2.0, m_size.y()/-2.0) + _posScreen;
|
||||
@ -365,16 +253,19 @@ vec2 ege::widget::Scene::calculateDeltaAngle(const vec2& _posScreen) {
|
||||
return vec2(angleX,
|
||||
angleY);
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
vec3 ege::widget::Scene::convertScreenPositionInMapPosition(const vec2& _posScreen) {
|
||||
return m_camera->projectOnZGround(calculateDeltaAngle(_posScreen));
|
||||
}
|
||||
|
||||
*/
|
||||
void ege::widget::Scene::onParameterChangeValue(const ewol::parameter::Ref& _paramPointer) {
|
||||
ewol::Widget::onParameterChangeValue(_paramPointer);
|
||||
/*
|
||||
if (_paramPointer == m_isRunning) {
|
||||
// nothing to do ...
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,95 +36,57 @@ class btVector3;
|
||||
namespace ege {
|
||||
namespace widget {
|
||||
class Scene : public ewol::Widget {
|
||||
public:
|
||||
// extern event
|
||||
ewol::Signal<float> signalPlayTimeChange;
|
||||
ewol::Signal<int32_t> signalKillEnemy;
|
||||
protected:
|
||||
ege::Environement m_env;
|
||||
std::shared_ptr<ege::Environement> m_env;
|
||||
protected:
|
||||
/**
|
||||
* @brief Constructor of the widget classes
|
||||
* @return (no execption generated (not managed in embended platform))
|
||||
*/
|
||||
Scene();
|
||||
void init(bool _setAutoBullet=true, bool _setAutoCamera=true);
|
||||
void init(std::shared_ptr<ege::Environement> _env);
|
||||
public:
|
||||
DECLARE_FACTORY(Scene);
|
||||
/**
|
||||
* @brief Destructor of the widget classes
|
||||
*/
|
||||
virtual ~Scene();
|
||||
void setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration=nullptr,
|
||||
btCollisionDispatcher* _dispatcher=nullptr,
|
||||
btBroadphaseInterface* _broadphase=nullptr,
|
||||
btConstraintSolver* _solver=nullptr,
|
||||
btDynamicsWorld* _dynamicsWorld=nullptr);
|
||||
void setCamera(ege::Camera* _camera=nullptr);
|
||||
private:
|
||||
float m_gameTime; //!< time of the game running
|
||||
protected:
|
||||
float m_angleView;
|
||||
///this is the most important class
|
||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||
btCollisionDispatcher* m_dispatcher;
|
||||
btBroadphaseInterface* m_broadphase;
|
||||
btConstraintSolver* m_solver;
|
||||
btDynamicsWorld* m_dynamicsWorld;
|
||||
// camera section
|
||||
ege::Camera* m_camera; //!< display point of view.
|
||||
// Other elements
|
||||
std::string m_cameraName;
|
||||
public:
|
||||
enum gameStatus {
|
||||
gameStart,
|
||||
gameStop
|
||||
};
|
||||
void setCamera(const std::string& _cameraName) {
|
||||
m_cameraName = _cameraName;
|
||||
}
|
||||
protected:
|
||||
ewol::parameter::List<enum gameStatus> m_isRunning; //!< the display is running (not in pause)
|
||||
float m_ratioTime; //!< Ratio time for the speed of the game ...
|
||||
// Note : This is only for temporary elements : on the display
|
||||
std::vector<ege::Environement::ResultNearestElement> m_displayElementOrdered;
|
||||
public:
|
||||
/**
|
||||
* @brief set the scene in pause for a while
|
||||
*/
|
||||
void pause();
|
||||
/**
|
||||
* @brief resume the scene activity
|
||||
*/
|
||||
void resume();
|
||||
/**
|
||||
* @brief Toggle between pause and running
|
||||
*/
|
||||
void pauseToggle();
|
||||
protected:
|
||||
bool m_debugMode;
|
||||
std::shared_ptr<ewol::resource::Colored3DObject> m_debugDrawing; //!< for the debug draw elements
|
||||
//bool m_debugMode;
|
||||
//std::shared_ptr<ewol::resource::Colored3DObject> m_debugDrawing; //!< for the debug draw elements
|
||||
public:
|
||||
/**
|
||||
* @brief Toggle the debug mode == > usefull for DEBUG only ...
|
||||
*/
|
||||
/*
|
||||
void debugToggle() {
|
||||
m_debugMode = m_debugMode?false:true;
|
||||
};
|
||||
*/
|
||||
protected:
|
||||
// Derived function
|
||||
virtual void ScenePeriodicCall(int64_t _localTime, int32_t _deltaTime) { };
|
||||
//virtual void ScenePeriodicCall(int64_t _localTime, int32_t _deltaTime) { };
|
||||
public:
|
||||
vec2 calculateDeltaAngle(const vec2& _posScreen);
|
||||
vec3 convertScreenPositionInMapPosition(const vec2& _posScreen);
|
||||
//vec2 calculateDeltaAngle(const vec2& _posScreen);
|
||||
//vec3 convertScreenPositionInMapPosition(const vec2& _posScreen);
|
||||
/**
|
||||
* @brief get the current camera reference for the scene rendering
|
||||
*/
|
||||
/*
|
||||
ege::Camera& getCamera() {
|
||||
return *m_camera;
|
||||
};
|
||||
/**
|
||||
* @brief set the curent Time Ratio (default 1)
|
||||
*/
|
||||
void setRatioTime(float _newRatio) {
|
||||
m_ratioTime = _newRatio;
|
||||
};
|
||||
|
||||
*/
|
||||
/*
|
||||
void renderscene(int pass);
|
||||
void drawOpenGL(btScalar* m,
|
||||
const btCollisionShape* _shape,
|
||||
@ -139,7 +101,7 @@ namespace ege {
|
||||
etk::Color<float>& _tmpColor);
|
||||
void getElementAroundNewElement(vec3 _sourcePosition,
|
||||
std::vector<ege::Environement::ResultNearestElement>& _resultList);
|
||||
|
||||
*/
|
||||
protected: // Derived function
|
||||
virtual void onDraw();
|
||||
virtual void onParameterChangeValue(const ewol::parameter::Ref& _paramPointer);
|
||||
|
0
sample/Accelerometer/README.md
Normal file
0
sample/Accelerometer/README.md
Normal file
0
sample/CameraPosition/README.md
Normal file
0
sample/CameraPosition/README.md
Normal file
0
sample/Collision/README.md
Normal file
0
sample/Collision/README.md
Normal file
0
sample/DoubleView/README.md
Normal file
0
sample/DoubleView/README.md
Normal file
0
sample/GameFPS/README.md
Normal file
0
sample/GameFPS/README.md
Normal file
0
sample/GamePad/README.md
Normal file
0
sample/GamePad/README.md
Normal file
0
sample/GameRacer/README.md
Normal file
0
sample/GameRacer/README.md
Normal file
0
sample/GameSpaceSimulation/README.md
Normal file
0
sample/GameSpaceSimulation/README.md
Normal file
0
sample/Light/README.md
Normal file
0
sample/Light/README.md
Normal file
0
sample/Material/README.md
Normal file
0
sample/Material/README.md
Normal file
0
sample/MeshCreator/README.md
Normal file
0
sample/MeshCreator/README.md
Normal file
38
sample/MeshCreator/appl/Windows.cpp
Normal file
38
sample/MeshCreator/appl/Windows.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/ewol.h>
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Windows.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ege/widget/Scene.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Windows"
|
||||
|
||||
appl::Windows::Windows() {
|
||||
addObjectType("appl::Windows");
|
||||
}
|
||||
void appl::Windows::init() {
|
||||
ewol::widget::Windows::init();
|
||||
setTitle("example ege : MeshCreator");
|
||||
|
||||
m_env = ege::Environement::create();
|
||||
// Create basic Camera
|
||||
m_env->addCamera("basic", std::make_shared<ege::Camera>());
|
||||
|
||||
std::shared_ptr<ege::widget::Scene> tmpWidget = ege::widget::Scene::create(m_env);
|
||||
if (tmpWidget == nullptr) {
|
||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
tmpWidget->setExpand(bvec2(true,true));
|
||||
tmpWidget->setFill(bvec2(true,true));
|
||||
tmpWidget->setCamera("basic");
|
||||
setSubWidget(tmpWidget);
|
||||
}
|
||||
}
|
29
sample/MeshCreator/appl/Windows.h
Normal file
29
sample/MeshCreator/appl/Windows.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __APPL_WINDOWS_H__
|
||||
#define __APPL_WINDOWS_H__
|
||||
|
||||
#include <ewol/widget/Windows.h>
|
||||
#include <ege/Environement.h>
|
||||
|
||||
namespace appl {
|
||||
class Windows : public ewol::widget::Windows {
|
||||
private:
|
||||
std::shared_ptr<ege::Environement> m_env;
|
||||
protected:
|
||||
Windows();
|
||||
void init();
|
||||
public:
|
||||
DECLARE_FACTORY(Windows);
|
||||
virtual ~Windows() { };
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
15
sample/MeshCreator/appl/debug.cpp
Normal file
15
sample/MeshCreator/appl/debug.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.h>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = etk::log::registerInstance("GP-spaceShip");
|
||||
return g_val;
|
||||
}
|
52
sample/MeshCreator/appl/debug.h
Normal file
52
sample/MeshCreator/appl/debug.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __APPL_DEBUG_H__
|
||||
#define __APPL_DEBUG_H__
|
||||
|
||||
#include <etk/log.h>
|
||||
|
||||
namespace appl {
|
||||
int32_t getLogId();
|
||||
};
|
||||
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
|
||||
#define APPL_BASE(info,data) \
|
||||
do { \
|
||||
if (info <= etk::log::getLevel(appl::getLogId())) { \
|
||||
std::stringbuf sb; \
|
||||
std::ostream tmpStream(&sb); \
|
||||
tmpStream << data; \
|
||||
etk::log::logStream(appl::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define APPL_CRITICAL(data) APPL_BASE(1, data)
|
||||
#define APPL_ERROR(data) APPL_BASE(2, data)
|
||||
#define APPL_WARNING(data) APPL_BASE(3, data)
|
||||
#ifdef DEBUG
|
||||
#define APPL_INFO(data) APPL_BASE(4, data)
|
||||
#define APPL_DEBUG(data) APPL_BASE(5, data)
|
||||
#define APPL_VERBOSE(data) APPL_BASE(6, data)
|
||||
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
|
||||
#else
|
||||
#define APPL_INFO(data) do { } while(false)
|
||||
#define APPL_DEBUG(data) do { } while(false)
|
||||
#define APPL_VERBOSE(data) do { } while(false)
|
||||
#define APPL_TODO(data) do { } while(false)
|
||||
#endif
|
||||
|
||||
#define APPL_ASSERT(cond,data) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
APPL_CRITICAL(data); \
|
||||
assert(!#cond); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
57
sample/MeshCreator/appl/main.cpp
Normal file
57
sample/MeshCreator/appl/main.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/context/commandLine.h>
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Windows.h>
|
||||
#include <ewol/object/Object.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
#include <ewol/context/Context.h>
|
||||
|
||||
|
||||
class MainApplication : public ewol::context::Application {
|
||||
public:
|
||||
bool init(ewol::Context& _context, size_t _initId) {
|
||||
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
|
||||
|
||||
// TODO : Remove this : Move if in the windows properties
|
||||
_context.setSize(vec2(800, 600));
|
||||
|
||||
// select internal data for font ...
|
||||
_context.getFontDefault().setUseExternal(true);
|
||||
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
|
||||
|
||||
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
|
||||
// create the specific windows
|
||||
_context.setWindows(basicWindows);
|
||||
APPL_INFO("==> Init APPL (END)");
|
||||
return true;
|
||||
}
|
||||
|
||||
void unInit(ewol::Context& _context) {
|
||||
APPL_INFO("==> Un-Init APPL (START)");
|
||||
// nothing to do ...
|
||||
APPL_INFO("==> Un-Init APPL (END)");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
// second possibility
|
||||
return ewol::run(new MainApplication(), _argc, _argv);
|
||||
}
|
||||
|
||||
|
14
sample/MeshCreator/appl/main.h
Normal file
14
sample/MeshCreator/appl/main.h
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __APPL_MAIN_H__
|
||||
#define __APPL_MAIN_H__
|
||||
|
||||
|
||||
#endif
|
||||
|
40
sample/MeshCreator/lutin_egeMeshCreator.py
Normal file
40
sample/MeshCreator/lutin_egeMeshCreator.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python
|
||||
import lutinModule as module
|
||||
import lutinTools as tools
|
||||
import lutinDebug as debug
|
||||
import datetime
|
||||
|
||||
|
||||
def get_desc():
|
||||
return "ege sample : MeshCreator"
|
||||
|
||||
def create(target):
|
||||
# module name is 'edn' and type binary.
|
||||
myModule = module.Module(__file__, 'egeMeshCreator', 'PACKAGE')
|
||||
|
||||
myModule.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/main.cpp',
|
||||
'appl/Windows.cpp'
|
||||
])
|
||||
|
||||
myModule.add_module_depend('ege')
|
||||
|
||||
myModule.add_path(tools.get_current_path(__file__))
|
||||
|
||||
#myModule.copy_folder("data/*")
|
||||
|
||||
# set the package properties :
|
||||
myModule.pkg_set("VERSION", "0.0.0")
|
||||
myModule.pkg_set("VERSION_CODE", "0")
|
||||
myModule.pkg_set("COMPAGNY_TYPE", "org")
|
||||
myModule.pkg_set("COMPAGNY_NAME", "ege")
|
||||
myModule.pkg_set("MAINTAINER", ["noOne <no.one@noreplay.com>"])
|
||||
myModule.pkg_set("SECTION", ["Game"])
|
||||
myModule.pkg_set("PRIORITY", "optional")
|
||||
myModule.pkg_set("DESCRIPTION", "ege sample : MeshCreator")
|
||||
myModule.pkg_set("NAME", "egeMeshCreator")
|
||||
|
||||
# add the currrent module at the
|
||||
return myModule
|
||||
|
0
sample/Particle/README.md
Normal file
0
sample/Particle/README.md
Normal file
0
sample/Script/README.md
Normal file
0
sample/Script/README.md
Normal file
0
sample/StereoVision/README.md
Normal file
0
sample/StereoVision/README.md
Normal file
Loading…
x
Reference in New Issue
Block a user