diff --git a/ege/elements/ElementPhysic.cpp b/ege/elements/ElementPhysic.cpp index cf27e71..b60f40c 100644 --- a/ege/elements/ElementPhysic.cpp +++ b/ege/elements/ElementPhysic.cpp @@ -322,10 +322,12 @@ void ege::ElementPhysic::draw(int32_t _pass) { if (false == m_elementInPhysicsSystem) { return; } + EGE_INFO("draw : " << _pass ); if (_pass == 0) { if( nullptr != m_body && nullptr != m_mesh && m_body->getMotionState() ) { + EGE_INFO(" plop "); btScalar mmm[16]; btDefaultMotionState* myMotionState = (btDefaultMotionState*)m_body->getMotionState(); myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(mmm); diff --git a/ege/physicsShape/PhysicsBox.h b/ege/physicsShape/PhysicsBox.h index eea0b4f..a31e9b9 100644 --- a/ege/physicsShape/PhysicsBox.h +++ b/ege/physicsShape/PhysicsBox.h @@ -31,6 +31,9 @@ namespace ege { const vec3& getSize() const { return m_size; }; + void setSize(const vec3& _size) { + m_size = _size; + } public: virtual const ege::PhysicsBox* toBox() const { return this; diff --git a/ege/resource/Mesh.h b/ege/resource/Mesh.h index 2f4477b..3efc184 100644 --- a/ege/resource/Mesh.h +++ b/ege/resource/Mesh.h @@ -115,6 +115,9 @@ namespace ege { const std::vector>& getPhysicalProperties() const { return m_physics; }; + void addPhysicElement(const std::shared_ptr& _shape) { + m_physics.push_back(_shape); + } private: void* m_pointerShape; //!< all mesh have a basic shape (bullet or other) the void pointer mermit to not depent on the bullet lib public: diff --git a/ege/resource/MeshEmf.cpp b/ege/resource/MeshEmf.cpp index 012958b..310c991 100644 --- a/ege/resource/MeshEmf.cpp +++ b/ege/resource/MeshEmf.cpp @@ -388,7 +388,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) { EGE_ERROR("Allocation error when creating physical shape ..."); continue; } - m_physics.push_back(physics); + addPhysicElement(physics); EGE_VERBOSE(" " << m_physics.size() << " " << inputDataLine); currentMode = EMFModuleMeshPhysicsNamed; } else if (currentMode == EMFModuleMeshPhysicsNamed) { diff --git a/sample/RayTest/appl/Windows.cpp b/sample/RayTest/appl/Windows.cpp index 9994c12..95b4acc 100644 --- a/sample/RayTest/appl/Windows.cpp +++ b/sample/RayTest/appl/Windows.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #undef __class__ #define __class__ "Windows" @@ -93,16 +94,23 @@ void appl::Windows::init() { } myMesh = ege::resource::Mesh::createCube(3); if (myMesh != nullptr) { - std::shared_ptr element = std::make_shared(m_env); - //std::shared_ptr element = std::make_shared(m_env); - element->setPosition(vec3(50,0,0)); + //std::shared_ptr element = std::make_shared(m_env); + std::shared_ptr element = std::make_shared(m_env); + element->setPosition(vec3(20,10,10)); element->setMesh(myMesh); + // add physic interface: + std::shared_ptr physic = std::make_shared(); + physic->setSize(vec3(3.2,3.2,3.2)); + myMesh->addPhysicElement(physic); + m_env->addElement(element); + /* element = std::make_shared(m_env); //std::shared_ptr element = std::make_shared(m_env); element->setPosition(vec3(-50,0,0)); element->setMesh(myMesh); m_env->addElement(element); + */ } }