[DEV] update some physic interface

This commit is contained in:
Edouard DUPIN 2014-11-17 21:44:45 +01:00
parent 4b86e2902a
commit 569d6c0b51
5 changed files with 42 additions and 3 deletions

View File

@ -236,7 +236,8 @@ void ege::Environement::getOrderedElementForDisplay(std::vector<ege::Environemen
result.element = m_listElement[iii]; result.element = m_listElement[iii];
// check distance ... // check distance ...
vec3 destPosition = result.element->getPosition(); vec3 destPosition = result.element->getPosition();
vec3 angleView = (destPosition - _position).normalized(); vec3 angleView = (destPosition - _position);
angleView.safeNormalize();
float dotResult=angleView.dot(_direction); float dotResult=angleView.dot(_direction);
//EGE_DEBUG("Dot position : " << destPosition << " == > dot=" << dotResult); //EGE_DEBUG("Dot position : " << destPosition << " == > dot=" << dotResult);
/* /*

View File

@ -29,7 +29,7 @@
#define ELEMENT_SCALE (1.0f/8.0f) #define ELEMENT_SCALE (1.0f/8.0f)
namespace ege { namespace ege {
class Element { class Element : public std::enable_shared_from_this<Element> {
protected: protected:
std::shared_ptr<ege::Environement> m_env; std::shared_ptr<ege::Environement> m_env;
public: public:

View File

@ -395,6 +395,31 @@ void ege::ElementPhysic::iaDisable() {
m_IA = nullptr; m_IA = nullptr;
} }
void ege::ElementPhysic::setMass(float _value) {
if (m_body == nullptr) {
return;
}
m_body->setMassProps(_value, vec3(0,0,0));
}
void ege::ElementPhysic::setLinearVelocity(const vec3& _value) {
if (m_body == nullptr) {
return;
}
m_body->setLinearVelocity(vec3(0,0,0));
}
void ege::ElementPhysic::setTorqueImpulse(const vec3& _value) {
if (m_body == nullptr) {
return;
}
}
void ege::ElementPhysic::setAngularVelocity(const vec3& _value) {
if (m_body == nullptr) {
return;
}
m_body->setAngularVelocity(_value);
}

View File

@ -109,6 +109,14 @@ namespace ege {
* @return the mass in kG. * @return the mass in kG.
*/ */
const float getInvMass(); const float getInvMass();
virtual void setMass(float _value);
virtual void setLinearVelocity(const vec3& _value);
virtual void setTorqueImpulse(const vec3& _value);
virtual void setAngularVelocity(const vec3& _value);
protected: protected:
bool m_elementInPhysicsSystem; bool m_elementInPhysicsSystem;
public: public:

View File

@ -30,7 +30,8 @@
#undef __class__ #undef __class__
#define __class__ "Scene" #define __class__ "Scene"
ege::widget::Scene::Scene() { ege::widget::Scene::Scene() :
m_cameraName("default") {
addObjectType("ege::widget::Scene"); addObjectType("ege::widget::Scene");
} }
@ -81,6 +82,10 @@ void ege::widget::Scene::onDraw() {
// get camera : // get camera :
std::shared_ptr<ege::Camera> camera = m_env->getCamera(m_cameraName); std::shared_ptr<ege::Camera> camera = m_env->getCamera(m_cameraName);
if (camera == nullptr) {
EGE_ERROR(" can not get camera named: '" << m_cameraName << "'");
return;
}
//EGE_DEBUG("Draw (start)"); //EGE_DEBUG("Draw (start)");
mat4 tmpMatrix; mat4 tmpMatrix;
std::shared_ptr<btDynamicsWorld> world = m_env->getPhysicEngine().getDynamicWorld(); std::shared_ptr<btDynamicsWorld> world = m_env->getPhysicEngine().getDynamicWorld();