[DEBUG] new step

This commit is contained in:
Edouard DUPIN 2014-11-21 21:01:26 +01:00
parent b402fc8253
commit e0f0c1d65b
10 changed files with 140 additions and 40 deletions

View File

@ -7,6 +7,7 @@
* *
*/ */
#include <ege/debug.h>
#include <ege/CollisionShapeCreator.h> #include <ege/CollisionShapeCreator.h>
#include <btBulletCollisionCommon.h> #include <btBulletCollisionCommon.h>
@ -29,10 +30,12 @@
btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resource::Mesh>& _mesh) { btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resource::Mesh>& _mesh) {
if (nullptr == _mesh) { if (nullptr == _mesh) {
EGE_DEBUG("Create empty shape (no mesh)");
return new btEmptyShape();; return new btEmptyShape();;
} }
const std::vector<std::shared_ptr<ege::PhysicsShape>>& physiqueProperty = _mesh->getPhysicalProperties(); const std::vector<std::shared_ptr<ege::PhysicsShape>>& physiqueProperty = _mesh->getPhysicalProperties();
if (physiqueProperty.size() == 0) { if (physiqueProperty.size() == 0) {
EGE_DEBUG("Create empty shape (no default shape)");
return new btEmptyShape();; return new btEmptyShape();;
} }
int32_t count = 0; int32_t count = 0;
@ -44,7 +47,10 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
} }
btCompoundShape* outputShape = nullptr; btCompoundShape* outputShape = nullptr;
if (count>1) { if (count>1) {
EGE_DEBUG("Create complexe shape");
outputShape = new btCompoundShape(); outputShape = new btCompoundShape();
} else {
EGE_DEBUG("Create simple shape");
} }
for (size_t iii=0; iii<physiqueProperty.size(); iii++) { for (size_t iii=0; iii<physiqueProperty.size(); iii++) {
if (nullptr == physiqueProperty[iii]) { if (nullptr == physiqueProperty[iii]) {
@ -52,6 +58,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
} }
switch (physiqueProperty[iii]->getType()) { switch (physiqueProperty[iii]->getType()) {
case ege::PhysicsShape::box : { case ege::PhysicsShape::box : {
EGE_DEBUG(" Box");
const ege::PhysicsBox* tmpElement = physiqueProperty[iii]->toBox(); const ege::PhysicsBox* tmpElement = physiqueProperty[iii]->toBox();
if (nullptr == tmpElement) { if (nullptr == tmpElement) {
// ERROR ... // ERROR ...
@ -70,6 +77,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
break; break;
} }
case ege::PhysicsShape::cylinder : { case ege::PhysicsShape::cylinder : {
EGE_DEBUG(" Cylinder");
const ege::PhysicsCylinder* tmpElement = physiqueProperty[iii]->toCylinder(); const ege::PhysicsCylinder* tmpElement = physiqueProperty[iii]->toCylinder();
if (nullptr == tmpElement) { if (nullptr == tmpElement) {
// ERROR ... // ERROR ...
@ -88,6 +96,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
break; break;
} }
case ege::PhysicsShape::capsule : { case ege::PhysicsShape::capsule : {
EGE_DEBUG(" Capsule");
const ege::PhysicsCapsule* tmpElement = physiqueProperty[iii]->toCapsule(); const ege::PhysicsCapsule* tmpElement = physiqueProperty[iii]->toCapsule();
if (nullptr == tmpElement) { if (nullptr == tmpElement) {
// ERROR ... // ERROR ...
@ -106,6 +115,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
break; break;
} }
case ege::PhysicsShape::cone : { case ege::PhysicsShape::cone : {
EGE_DEBUG(" Cone");
const ege::PhysicsCone* tmpElement = physiqueProperty[iii]->toCone(); const ege::PhysicsCone* tmpElement = physiqueProperty[iii]->toCone();
if (nullptr == tmpElement) { if (nullptr == tmpElement) {
// ERROR ... // ERROR ...
@ -124,6 +134,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
break; break;
} }
case ege::PhysicsShape::sphere : { case ege::PhysicsShape::sphere : {
EGE_DEBUG(" Sphere");
const ege::PhysicsSphere* tmpElement = physiqueProperty[iii]->toSphere(); const ege::PhysicsSphere* tmpElement = physiqueProperty[iii]->toSphere();
if (nullptr == tmpElement) { if (nullptr == tmpElement) {
// ERROR ... // ERROR ...
@ -142,6 +153,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
break; break;
} }
case ege::PhysicsShape::convexHull : { case ege::PhysicsShape::convexHull : {
EGE_DEBUG(" convexHull");
const ege::PhysicsConvexHull* tmpElement = physiqueProperty[iii]->toConvexHull(); const ege::PhysicsConvexHull* tmpElement = physiqueProperty[iii]->toConvexHull();
if (nullptr == tmpElement) { if (nullptr == tmpElement) {
// ERROR ... // ERROR ...
@ -160,11 +172,13 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
break; break;
} }
default : default :
EGE_DEBUG(" ???");
// TODO : UNKNOW type ... // TODO : UNKNOW type ...
break; break;
} }
} }
if (nullptr == outputShape) { if (nullptr == outputShape) {
EGE_DEBUG("create empty shape ...");
return new btEmptyShape(); return new btEmptyShape();
} }
return outputShape; return outputShape;

View File

@ -51,19 +51,52 @@ void ege::Material::draw(const std::shared_ptr<ewol::resource::Program>& _prog,
_prog->uniform1f(_glID.m_GL_shininess, m_shininess); _prog->uniform1f(_glID.m_GL_shininess, m_shininess);
if (nullptr != m_texture0) { if (nullptr != m_texture0) {
_prog->setTexture0(_glID.m_GL_texture0, m_texture0->getId()); _prog->setTexture0(_glID.m_GL_texture0, m_texture0->getId());
#if DEBUG
if (_prog->checkIdValidity(_glID.m_GL_texture0) == false) {
EGE_ERROR("try to set texture on a unexistant shader interface (wrong ID)");
}
#endif
} else {
#if DEBUG
if (_prog->checkIdValidity(_glID.m_GL_texture0) == true) {
EGE_ERROR("Missing texture to send on the shader ...");
}
#endif
} }
} }
void ege::Material::setTexture0(const std::string& _filename) { void ege::Material::setTexture0(const std::string& _filename) {
ivec2 tmpSize(256, 256); ivec2 tmpSize(256, 256);
// prevent overloard error : if (_filename != "") {
std::shared_ptr<ewol::resource::TextureFile> tmpCopy = m_texture0; // prevent overloard error :
m_texture0 = ewol::resource::TextureFile::create(_filename, tmpSize); std::shared_ptr<ewol::resource::Texture> tmpCopy = m_texture0;
if (m_texture0 == nullptr) { m_texture0 = ewol::resource::TextureFile::create(_filename, tmpSize);
EGE_ERROR("Can not load specific texture : " << _filename); if (m_texture0 == nullptr) {
// retreave previous texture: EGE_ERROR("Can not load specific texture : " << _filename);
m_texture0 = tmpCopy; // retreave previous texture:
return; m_texture0 = tmpCopy;
if (m_texture0 != nullptr) {
return;
}
}
} else {
m_texture0.reset();
}
}
void ege::Material::setTexture0Magic(const ivec2& _size) {
// create a simple custum texture :
m_texture0 = ewol::resource::Texture::create();
if (m_texture0 != nullptr) {
setImageSize(_size);
egami::Image& img = m_texture0->get();
for (int32_t xxx=0; xxx<_size.x(); ++xxx) {
for (int32_t yyy=0; yyy<_size.y(); ++yyy) {
img.set(ivec2(xxx,yyy), etk::Color<>(1,0,0,1));
}
}
} else {
EGE_ERROR("Can not create empty stupid texture ...");
} }
} }

View File

@ -40,7 +40,7 @@ namespace ege {
vec4 m_specularFactor; vec4 m_specularFactor;
float m_shininess; float m_shininess;
enum ewol::openGL::renderMode m_renderMode; // Select Render mode (triangle/Line/point ...) enum ewol::openGL::renderMode m_renderMode; // Select Render mode (triangle/Line/point ...)
std::shared_ptr<ewol::resource::TextureFile> m_texture0; std::shared_ptr<ewol::resource::Texture> m_texture0;
public: public:
std::vector<uint32_t> m_listIndexFaces; std::vector<uint32_t> m_listIndexFaces;
public: public:
@ -65,6 +65,7 @@ namespace ege {
return m_renderMode; return m_renderMode;
} }
void setTexture0(const std::string& _filename); void setTexture0(const std::string& _filename);
void setTexture0Magic(const ivec2& _size);
void setImageSize(const ivec2& _newSize) { void setImageSize(const ivec2& _newSize) {
if (m_texture0 == nullptr){ if (m_texture0 == nullptr){

View File

@ -34,7 +34,7 @@ const std::string& ege::ElementPhysic::getType() const {
} }
ege::ElementPhysic::ElementPhysic(const std::shared_ptr<ege::Environement>& _env, bool _autoRigidBody) : ege::ElementPhysic::ElementPhysic(const std::shared_ptr<ege::Environement>& _env, bool _autoRigidBody) ://, float _mass) :
ege::Element(_env), ege::Element(_env),
m_body(nullptr), m_body(nullptr),
m_shape(nullptr), m_shape(nullptr),
@ -59,27 +59,25 @@ ege::ElementPhysic::~ElementPhysic() {
void ege::ElementPhysic::createRigidBody(float _mass) { void ege::ElementPhysic::createRigidBody(float _mass) {
/// Create Dynamic Objects /// Create Dynamic Objects
btTransform startTransform; btTransform startTransform;
startTransform.setIdentity(); startTransform.setIdentity();
vec3 localInertia(0,0,0); vec3 localInertia(0,0,0);
//rigidbody is dynamic if and only if mass is non zero, otherwise static //rigidbody is dynamic if and only if mass is non zero, otherwise static
/* if (_mass != 0.0f && getShape()!=nullptr) {
if (mass != 0.0f && getShape()!=nullptr) { getShape()->calculateLocalInertia(_mass, localInertia);
getShape()->calculateLocalInertia(mass, localInertia);
} }
*/
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
m_motionState = new btDefaultMotionState(startTransform); btDefaultMotionState* motionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(_mass,m_motionState,getShape(),localInertia); btRigidBody::btRigidBodyConstructionInfo rbInfo(_mass, motionState, getShape(), localInertia);
m_body = new btRigidBody(rbInfo); m_body = new btRigidBody(rbInfo);
//m_body->applyTorqueImpulse(btVector3(0,0,0.2)); //m_body->applyTorqueImpulse(btVector3(0,0,0.2));
//m_body->setAngularVelocity(vec3(etk::tool::frand(-1,1),etk::tool::frand(-1,1),etk::tool::frand(-1,1))); m_body->setAngularVelocity(vec3(0,0,0));
} }
bool ege::ElementPhysic::setMesh(const std::shared_ptr<ege::resource::Mesh>& _mesh) { bool ege::ElementPhysic::setMesh(const std::shared_ptr<ege::resource::Mesh>& _mesh) {
EGE_WARNING("Set Mesh");
if (nullptr!=m_mesh) { if (nullptr!=m_mesh) {
removeShape(); removeShape();
} }
@ -89,19 +87,30 @@ bool ege::ElementPhysic::setMesh(const std::shared_ptr<ege::resource::Mesh>& _me
return true; return true;
} }
if (m_mesh->getShape() != nullptr) { if (m_mesh->getShape() != nullptr) {
EGE_WARNING("create shape whith mesh internal shape ...");
m_shape = static_cast<btCollisionShape*>(m_mesh->getShape()); m_shape = static_cast<btCollisionShape*>(m_mesh->getShape());
return true; return true;
} }
EGE_WARNING("create the mesh shape with the mesh");
m_mesh->setShape(ege::collision::createShape(m_mesh)); m_mesh->setShape(ege::collision::createShape(m_mesh));
EGE_WARNING("set remove function shape");
m_mesh->setFreeShapeFunction(&FunctionFreeShape); m_mesh->setFreeShapeFunction(&FunctionFreeShape);
m_shape = static_cast<btCollisionShape*>(m_mesh->getShape()); m_shape = static_cast<btCollisionShape*>(m_mesh->getShape());
vec3 localInertia(0,0,0);
m_shape->calculateLocalInertia(50000000, localInertia); // TODO : BETTER ///
return true; return true;
} }
bool ege::ElementPhysic::setShape(btCollisionShape* _shape) { bool ege::ElementPhysic::setShape(btCollisionShape* _shape) {
EGE_WARNING("Set Shape");
removeShape(); removeShape();
m_shape = _shape; m_shape = _shape;
if (_shape == nullptr) {
EGE_WARNING("Remove shape ...");
} else {
EGE_INFO("set shape ...");
}
return true; return true;
} }
@ -115,11 +124,13 @@ void ege::ElementPhysic::removeShape() {
// no mesh == > standalone shape // no mesh == > standalone shape
delete(m_shape); delete(m_shape);
m_shape=nullptr; m_shape=nullptr;
EGE_WARNING("Remove shape .2.");
return; return;
} }
if (m_shape != m_mesh->getShape()) { if (m_shape != m_mesh->getShape()) {
delete(m_shape); delete(m_shape);
m_shape=nullptr; m_shape=nullptr;
EGE_WARNING("Remove shape .3.");
return; return;
} }
// otherwise : the shape is auto remove by the resources when no more needed ... // otherwise : the shape is auto remove by the resources when no more needed ...
@ -360,6 +371,7 @@ void ege::ElementPhysic::draw(int32_t _pass) {
mat4 transformationMatrix(mmm); mat4 transformationMatrix(mmm);
transformationMatrix.transpose(); transformationMatrix.transpose();
EGE_INFO("element pos = " << getPosition() << " mat=" << transformationMatrix);
m_mesh->draw(transformationMatrix); m_mesh->draw(transformationMatrix);
} }
} }
@ -370,9 +382,11 @@ void ege::ElementPhysic::dynamicEnable() {
return; return;
} }
if(m_body != nullptr) { if(m_body != nullptr) {
EGE_ERROR("dynamicEnable : RigidBody");
m_env->getPhysicEngine().getDynamicWorld()->addRigidBody(m_body); m_env->getPhysicEngine().getDynamicWorld()->addRigidBody(m_body);
} }
if(m_IA != nullptr) { if(m_IA != nullptr) {
EGE_ERROR("dynamicEnable : IA");
m_env->getPhysicEngine().getDynamicWorld()->addAction(m_IA); m_env->getPhysicEngine().getDynamicWorld()->addAction(m_IA);
} }
m_elementInPhysicsSystem = true; m_elementInPhysicsSystem = true;
@ -383,9 +397,11 @@ void ege::ElementPhysic::dynamicDisable() {
return; return;
} }
if(m_IA != nullptr) { if(m_IA != nullptr) {
EGE_ERROR("dynamicDisable : IA");
m_env->getPhysicEngine().getDynamicWorld()->removeAction(m_IA); m_env->getPhysicEngine().getDynamicWorld()->removeAction(m_IA);
} }
if(m_body != nullptr) { if(m_body != nullptr) {
EGE_ERROR("dynamicDisable : RigidBody");
// Unlink element from the engine // Unlink element from the engine
m_env->getPhysicEngine().getDynamicWorld()->removeRigidBody(m_body); m_env->getPhysicEngine().getDynamicWorld()->removeRigidBody(m_body);
m_env->getPhysicEngine().getDynamicWorld()->removeCollisionObject(m_body); m_env->getPhysicEngine().getDynamicWorld()->removeCollisionObject(m_body);

View File

@ -37,8 +37,6 @@ namespace ege {
static void FunctionFreeShape(void* _pointer); static void FunctionFreeShape(void* _pointer);
protected: protected:
btRigidBody* m_body; //!< all the element have a body == > otherwise it will be not manage with this system... btRigidBody* m_body; //!< all the element have a body == > otherwise it will be not manage with this system...
private:
btDefaultMotionState* m_motionState;
public: public:
void createRigidBody(float _mass=400000000.0f); void createRigidBody(float _mass=400000000.0f);
public: public:

View File

@ -32,6 +32,9 @@ namespace ege {
float getRadius() const { float getRadius() const {
return m_radius; return m_radius;
}; };
void setRadius(float _radius) {
m_radius = _radius;
};
private: private:
virtual const ege::PhysicsSphere* toSphere() const { virtual const ege::PhysicsSphere* toSphere() const {
return this; return this;

View File

@ -102,7 +102,7 @@ void ege::resource::Mesh::clean() {
} }
//#define DISPLAY_NB_VERTEX_DISPLAYED #define DISPLAY_NB_VERTEX_DISPLAYED
void ege::resource::Mesh::draw(mat4& _positionMatrix, void ege::resource::Mesh::draw(mat4& _positionMatrix,
bool _enableDepthTest, bool _enableDepthTest,
@ -128,14 +128,20 @@ void ege::resource::Mesh::draw(mat4& _positionMatrix,
mat4 tmpMatrix = projMatrix * camMatrix; mat4 tmpMatrix = projMatrix * camMatrix;
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
m_GLprogram->uniformMatrix(m_GLMatrixPosition, _positionMatrix); m_GLprogram->uniformMatrix(m_GLMatrixPosition, _positionMatrix);
EGE_DEBUG(" m_GLMatrix=" << m_GLMatrix << " ==> " << tmpMatrix);
EGE_DEBUG(" m_GLMatrixPosition=" << m_GLMatrixPosition << " ==> " << _positionMatrix);
// position : // position :
m_GLprogram->sendAttributePointer(m_GLPosition, m_verticesVBO, MESH_VBO_VERTICES); m_GLprogram->sendAttributePointer(m_GLPosition, m_verticesVBO, MESH_VBO_VERTICES);
EGE_DEBUG(" m_GLPosition=" << m_GLPosition << " ==> " << "");
// Texture : // Texture :
m_GLprogram->sendAttributePointer(m_GLtexture, m_verticesVBO, MESH_VBO_TEXTURE); m_GLprogram->sendAttributePointer(m_GLtexture, m_verticesVBO, MESH_VBO_TEXTURE);
EGE_DEBUG(" m_GLtexture=" << m_GLtexture << " ==> " << "");
// position : // position :
m_GLprogram->sendAttributePointer(m_GLNormal, m_verticesVBO, MESH_VBO_VERTICES_NORMAL); m_GLprogram->sendAttributePointer(m_GLNormal, m_verticesVBO, MESH_VBO_VERTICES_NORMAL);
EGE_DEBUG(" m_GLNormal=" << m_GLNormal << " ==> " << "");
// position : // position :
m_GLprogram->sendAttributePointer(m_GLColor, m_verticesVBO, MESH_VBO_COLOR); m_GLprogram->sendAttributePointer(m_GLColor, m_verticesVBO, MESH_VBO_COLOR);
EGE_DEBUG(" m_GLColor=" << m_GLColor << " ==> " << "");
// draw lights : // draw lights :
m_light.draw(m_GLprogram); m_light.draw(m_GLprogram);
#ifdef DISPLAY_NB_VERTEX_DISPLAYED #ifdef DISPLAY_NB_VERTEX_DISPLAYED
@ -193,9 +199,18 @@ void ege::resource::Mesh::draw(mat4& _positionMatrix,
} }
} }
#ifdef DISPLAY_NB_VERTEX_DISPLAYED #ifdef DISPLAY_NB_VERTEX_DISPLAYED
EGE_DEBUG(((float)nbElementDraw/(float)nbElementDrawTheoric*100.0f) << "% Request draw : " << m_listFaces.size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]"); if (m_listFaces.size() == 0) {
EGE_ERROR(" !!!! No Face to display elements [" << m_name << "]");
} else {
if (nbElementDrawTheoric != 0) {
EGE_DEBUG(((float)nbElementDraw/(float)nbElementDrawTheoric*100.0f) << "% Request draw : " << m_listFaces.size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]");
} else {
EGE_DEBUG("0% Request draw : " << m_listFaces.size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]");
}
}
#endif #endif
m_GLprogram->unUse(); m_GLprogram->unUse();
if (_enableDepthTest == true){ if (_enableDepthTest == true){
if (false == _enableDepthUpdate) { if (false == _enableDepthUpdate) {
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
@ -203,7 +218,7 @@ void ege::resource::Mesh::draw(mat4& _positionMatrix,
ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST);
} }
// TODO : UNDERSTAND why ... it is needed // TODO : UNDERSTAND why ... it is needed
glBindBuffer(GL_ARRAY_BUFFER,0); //glBindBuffer(GL_ARRAY_BUFFER,0);
} }
// normal calculation of the normal face is really easy : // normal calculation of the normal face is really easy :
@ -267,7 +282,7 @@ void ege::resource::Mesh::generateVBO() {
// when no normal detected == > auto generate Face normal .... // when no normal detected == > auto generate Face normal ....
calculateNormaleFace(m_listFaces.getKeys()[0]); calculateNormaleFace(m_listFaces.getKeys()[0]);
} }
EGE_WARNING("Generate VBO for nb faces : " << m_listFaces.size());
// generate element in 2 pass : // generate element in 2 pass :
// - create new index dependeng a vertex is a unique componenet of position, texture, normal // - create new index dependeng a vertex is a unique componenet of position, texture, normal

View File

@ -10,6 +10,7 @@
#include <ege/resource/Mesh.h> #include <ege/resource/Mesh.h>
std::shared_ptr<ege::resource::Mesh> ege::resource::Mesh::createCube(float _size, const std::string& _materialName, const etk::Color<float>& _color) { std::shared_ptr<ege::resource::Mesh> ege::resource::Mesh::createCube(float _size, const std::string& _materialName, const etk::Color<float>& _color) {
EGE_ERROR(" create a cube _size=" << _size << " _materialName=" << _materialName << " _color=" << _color);
std::shared_ptr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog"); std::shared_ptr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog");
if (out != nullptr) { if (out != nullptr) {
std::shared_ptr<ege::Material> material = std::make_shared<ege::Material>(); std::shared_ptr<ege::Material> material = std::make_shared<ege::Material>();
@ -31,6 +32,8 @@ std::shared_ptr<ege::resource::Mesh> ege::resource::Mesh::createCube(float _size
out->addQuad(_materialName, vec3(-1, 1,-1)*_size, vec3(-1, 1, 1)*_size, vec3( 1, 1, 1)*_size, vec3( 1, 1,-1)*_size, _color); out->addQuad(_materialName, vec3(-1, 1,-1)*_size, vec3(-1, 1, 1)*_size, vec3( 1, 1, 1)*_size, vec3( 1, 1,-1)*_size, _color);
// generate the VBO // generate the VBO
out->generateVBO(); out->generateVBO();
} else {
EGE_ERROR("can not create the basic mesh interface");
} }
return out; return out;
} }

View File

@ -147,6 +147,7 @@ void ege::widget::Scene::systemDraw(const ewol::DrawProperty& _displayProp) {
#ifdef SCENE_BRUT_PERFO_TEST #ifdef SCENE_BRUT_PERFO_TEST
int64_t tmp___startTime0 = ewol::getTime(); int64_t tmp___startTime0 = ewol::getTime();
#endif #endif
glBindBuffer(GL_ARRAY_BUFFER,0);
ewol::openGL::push(); ewol::openGL::push();
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x(), glViewport( m_origin.x(),

View File

@ -17,6 +17,7 @@
#include <ege/elements/ElementBase.h> #include <ege/elements/ElementBase.h>
#include <ege/elements/ElementPhysic.h> #include <ege/elements/ElementPhysic.h>
#include <ege/physicsShape/PhysicsBox.h> #include <ege/physicsShape/PhysicsBox.h>
#include <ege/physicsShape/PhysicsSphere.h>
#undef __class__ #undef __class__
#define __class__ "Windows" #define __class__ "Windows"
@ -26,7 +27,7 @@ appl::Windows::Windows() {
} }
static std::shared_ptr<ege::resource::Mesh> createViewBoxStar() { static std::shared_ptr<ege::resource::Mesh> createViewBoxStar() {
std::shared_ptr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:texturedNoMaterial.prog"); std::shared_ptr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog");
if (out != nullptr) { if (out != nullptr) {
std::shared_ptr<ege::Material> material = std::make_shared<ege::Material>(); std::shared_ptr<ege::Material> material = std::make_shared<ege::Material>();
// set the element material properties : // set the element material properties :
@ -34,13 +35,14 @@ static std::shared_ptr<ege::resource::Mesh> createViewBoxStar() {
material->setDiffuseFactor(vec4(0,0,0,1)); material->setDiffuseFactor(vec4(0,0,0,1));
material->setSpecularFactor(vec4(0,0,0,1)); material->setSpecularFactor(vec4(0,0,0,1));
material->setShininess(1); material->setShininess(1);
material->setTexture0(""); //"
out->addMaterial("basics", material);
// 1024 == > 1<<9 // 1024 == > 1<<9
// 2048 == > 1<<10 // 2048 == > 1<<10
// 4096 == > 1<<11 // 4096 == > 1<<11
int32_t size = 1<<11; int32_t size = 1<<11;
material->setImageSize(ivec2(size,size)); //material->setTexture0(""); //"
material->setTexture0Magic(ivec2(size,size));
out->addMaterial("basics", material);
//material->setImageSize(ivec2(size,size));
egami::Image* myImage = material->get(); egami::Image* myImage = material->get();
if (nullptr == myImage) { if (nullptr == myImage) {
return out; return out;
@ -96,24 +98,38 @@ void appl::Windows::init() {
if (myMesh != nullptr) { if (myMesh != nullptr) {
//std::shared_ptr<ege::ElementBase> element = std::make_shared<ege::ElementBase>(m_env); //std::shared_ptr<ege::ElementBase> element = std::make_shared<ege::ElementBase>(m_env);
std::shared_ptr<ege::ElementPhysic> element = std::make_shared<ege::ElementPhysic>(m_env); std::shared_ptr<ege::ElementPhysic> element = std::make_shared<ege::ElementPhysic>(m_env);
element->setMesh(myMesh);
element->setPosition(vec3(20,10,10));
// add physic interface: // add physic interface:
/*
std::shared_ptr<ege::PhysicsBox> physic = std::make_shared<ege::PhysicsBox>(); std::shared_ptr<ege::PhysicsBox> physic = std::make_shared<ege::PhysicsBox>();
physic->setSize(vec3(3.2,3.2,3.2)); physic->setSize(vec3(3.2,3.2,3.2));
*/
std::shared_ptr<ege::PhysicsSphere> physic = std::make_shared<ege::PhysicsSphere>();
physic->setRadius(4.2f);
myMesh->addPhysicElement(physic); myMesh->addPhysicElement(physic);
m_env->addElement(element);
//element = std::make_shared<ege::ElementBase>(m_env);
element = std::make_shared<ege::ElementPhysic>(m_env);
element->setMesh(myMesh); element->setMesh(myMesh);
element->setPosition(vec3(20,-10,10)); element->createRigidBody(4000000);
element->setPosition(vec3(20,10,10));
m_env->addElement(element);
}
myMesh = ege::resource::Mesh::createCube(3);
if (myMesh != nullptr) {
//element = std::make_shared<ege::ElementBase>(m_env);
std::shared_ptr<ege::ElementPhysic> element = std::make_shared<ege::ElementPhysic>(m_env);
// add physic interface: // add physic interface:
physic = std::make_shared<ege::PhysicsBox>(); std::shared_ptr<ege::PhysicsSphere> physic = std::make_shared<ege::PhysicsSphere>();
physic->setSize(vec3(3.2,3.2,3.2)); physic->setRadius(3.3f);
myMesh->addPhysicElement(physic);
element->setMesh(myMesh);
element->createRigidBody(4000000);
element->setPosition(vec3(20,-10,10));
element->iaEnable();
m_env->addElement(element); m_env->addElement(element);
} }
@ -124,8 +140,8 @@ void appl::Windows::onCallbackPeriodicUpdateCamera(const ewol::event::Time& _eve
static float offset = 0; static float offset = 0;
offset += 0.01; offset += 0.01;
static float offset2 = 0; static float offset2 = 0;
offset2 += 0.003; //offset2 += 0.003;
//m_camera->setEye(vec3(100*std::sin(offset),100*std::cos(offset),40*std::cos(offset2))); m_camera->setEye(vec3(100*std::sin(offset),100*std::cos(offset),40*std::cos(offset2)));
} }