[DEBUG] new step
This commit is contained in:
parent
b402fc8253
commit
e0f0c1d65b
@ -7,6 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ege/debug.h>
|
||||
#include <ege/CollisionShapeCreator.h>
|
||||
|
||||
#include <btBulletCollisionCommon.h>
|
||||
@ -29,10 +30,12 @@
|
||||
|
||||
btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resource::Mesh>& _mesh) {
|
||||
if (nullptr == _mesh) {
|
||||
EGE_DEBUG("Create empty shape (no mesh)");
|
||||
return new btEmptyShape();;
|
||||
}
|
||||
const std::vector<std::shared_ptr<ege::PhysicsShape>>& physiqueProperty = _mesh->getPhysicalProperties();
|
||||
if (physiqueProperty.size() == 0) {
|
||||
EGE_DEBUG("Create empty shape (no default shape)");
|
||||
return new btEmptyShape();;
|
||||
}
|
||||
int32_t count = 0;
|
||||
@ -44,7 +47,10 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
|
||||
}
|
||||
btCompoundShape* outputShape = nullptr;
|
||||
if (count>1) {
|
||||
EGE_DEBUG("Create complexe shape");
|
||||
outputShape = new btCompoundShape();
|
||||
} else {
|
||||
EGE_DEBUG("Create simple shape");
|
||||
}
|
||||
for (size_t iii=0; iii<physiqueProperty.size(); iii++) {
|
||||
if (nullptr == physiqueProperty[iii]) {
|
||||
@ -52,6 +58,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
|
||||
}
|
||||
switch (physiqueProperty[iii]->getType()) {
|
||||
case ege::PhysicsShape::box : {
|
||||
EGE_DEBUG(" Box");
|
||||
const ege::PhysicsBox* tmpElement = physiqueProperty[iii]->toBox();
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
@ -70,6 +77,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
|
||||
break;
|
||||
}
|
||||
case ege::PhysicsShape::cylinder : {
|
||||
EGE_DEBUG(" Cylinder");
|
||||
const ege::PhysicsCylinder* tmpElement = physiqueProperty[iii]->toCylinder();
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
@ -88,6 +96,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
|
||||
break;
|
||||
}
|
||||
case ege::PhysicsShape::capsule : {
|
||||
EGE_DEBUG(" Capsule");
|
||||
const ege::PhysicsCapsule* tmpElement = physiqueProperty[iii]->toCapsule();
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
@ -106,6 +115,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
|
||||
break;
|
||||
}
|
||||
case ege::PhysicsShape::cone : {
|
||||
EGE_DEBUG(" Cone");
|
||||
const ege::PhysicsCone* tmpElement = physiqueProperty[iii]->toCone();
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
@ -124,6 +134,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
|
||||
break;
|
||||
}
|
||||
case ege::PhysicsShape::sphere : {
|
||||
EGE_DEBUG(" Sphere");
|
||||
const ege::PhysicsSphere* tmpElement = physiqueProperty[iii]->toSphere();
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
@ -142,6 +153,7 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
|
||||
break;
|
||||
}
|
||||
case ege::PhysicsShape::convexHull : {
|
||||
EGE_DEBUG(" convexHull");
|
||||
const ege::PhysicsConvexHull* tmpElement = physiqueProperty[iii]->toConvexHull();
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
@ -160,11 +172,13 @@ btCollisionShape* ege::collision::createShape(const std::shared_ptr<ege::resourc
|
||||
break;
|
||||
}
|
||||
default :
|
||||
EGE_DEBUG(" ???");
|
||||
// TODO : UNKNOW type ...
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nullptr == outputShape) {
|
||||
EGE_DEBUG("create empty shape ...");
|
||||
return new btEmptyShape();
|
||||
}
|
||||
return outputShape;
|
||||
|
@ -51,19 +51,52 @@ void ege::Material::draw(const std::shared_ptr<ewol::resource::Program>& _prog,
|
||||
_prog->uniform1f(_glID.m_GL_shininess, m_shininess);
|
||||
if (nullptr != m_texture0) {
|
||||
_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) {
|
||||
ivec2 tmpSize(256, 256);
|
||||
// prevent overloard error :
|
||||
std::shared_ptr<ewol::resource::TextureFile> tmpCopy = m_texture0;
|
||||
m_texture0 = ewol::resource::TextureFile::create(_filename, tmpSize);
|
||||
if (m_texture0 == nullptr) {
|
||||
EGE_ERROR("Can not load specific texture : " << _filename);
|
||||
// retreave previous texture:
|
||||
m_texture0 = tmpCopy;
|
||||
return;
|
||||
if (_filename != "") {
|
||||
// prevent overloard error :
|
||||
std::shared_ptr<ewol::resource::Texture> tmpCopy = m_texture0;
|
||||
m_texture0 = ewol::resource::TextureFile::create(_filename, tmpSize);
|
||||
if (m_texture0 == nullptr) {
|
||||
EGE_ERROR("Can not load specific texture : " << _filename);
|
||||
// retreave previous texture:
|
||||
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 ...");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace ege {
|
||||
vec4 m_specularFactor;
|
||||
float m_shininess;
|
||||
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:
|
||||
std::vector<uint32_t> m_listIndexFaces;
|
||||
public:
|
||||
@ -65,6 +65,7 @@ namespace ege {
|
||||
return m_renderMode;
|
||||
}
|
||||
void setTexture0(const std::string& _filename);
|
||||
void setTexture0Magic(const ivec2& _size);
|
||||
|
||||
void setImageSize(const ivec2& _newSize) {
|
||||
if (m_texture0 == nullptr){
|
||||
|
@ -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),
|
||||
m_body(nullptr),
|
||||
m_shape(nullptr),
|
||||
@ -59,27 +59,25 @@ ege::ElementPhysic::~ElementPhysic() {
|
||||
|
||||
|
||||
void ege::ElementPhysic::createRigidBody(float _mass) {
|
||||
|
||||
/// Create Dynamic Objects
|
||||
btTransform startTransform;
|
||||
startTransform.setIdentity();
|
||||
vec3 localInertia(0,0,0);
|
||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||
/*
|
||||
if (mass != 0.0f && getShape()!=nullptr) {
|
||||
getShape()->calculateLocalInertia(mass, localInertia);
|
||||
if (_mass != 0.0f && getShape()!=nullptr) {
|
||||
getShape()->calculateLocalInertia(_mass, localInertia);
|
||||
}
|
||||
*/
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
m_motionState = new btDefaultMotionState(startTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(_mass,m_motionState,getShape(),localInertia);
|
||||
btDefaultMotionState* motionState = new btDefaultMotionState(startTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(_mass, motionState, getShape(), localInertia);
|
||||
m_body = new btRigidBody(rbInfo);
|
||||
//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) {
|
||||
EGE_WARNING("Set Mesh");
|
||||
if (nullptr!=m_mesh) {
|
||||
removeShape();
|
||||
}
|
||||
@ -89,19 +87,30 @@ bool ege::ElementPhysic::setMesh(const std::shared_ptr<ege::resource::Mesh>& _me
|
||||
return true;
|
||||
}
|
||||
if (m_mesh->getShape() != nullptr) {
|
||||
EGE_WARNING("create shape whith mesh internal shape ...");
|
||||
m_shape = static_cast<btCollisionShape*>(m_mesh->getShape());
|
||||
return true;
|
||||
}
|
||||
EGE_WARNING("create the mesh shape with the mesh");
|
||||
m_mesh->setShape(ege::collision::createShape(m_mesh));
|
||||
EGE_WARNING("set remove function shape");
|
||||
m_mesh->setFreeShapeFunction(&FunctionFreeShape);
|
||||
m_shape = static_cast<btCollisionShape*>(m_mesh->getShape());
|
||||
vec3 localInertia(0,0,0);
|
||||
m_shape->calculateLocalInertia(50000000, localInertia); // TODO : BETTER ///
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ege::ElementPhysic::setShape(btCollisionShape* _shape) {
|
||||
EGE_WARNING("Set Shape");
|
||||
removeShape();
|
||||
m_shape = _shape;
|
||||
if (_shape == nullptr) {
|
||||
EGE_WARNING("Remove shape ...");
|
||||
} else {
|
||||
EGE_INFO("set shape ...");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -115,11 +124,13 @@ void ege::ElementPhysic::removeShape() {
|
||||
// no mesh == > standalone shape
|
||||
delete(m_shape);
|
||||
m_shape=nullptr;
|
||||
EGE_WARNING("Remove shape .2.");
|
||||
return;
|
||||
}
|
||||
if (m_shape != m_mesh->getShape()) {
|
||||
delete(m_shape);
|
||||
m_shape=nullptr;
|
||||
EGE_WARNING("Remove shape .3.");
|
||||
return;
|
||||
}
|
||||
// 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);
|
||||
transformationMatrix.transpose();
|
||||
EGE_INFO("element pos = " << getPosition() << " mat=" << transformationMatrix);
|
||||
m_mesh->draw(transformationMatrix);
|
||||
}
|
||||
}
|
||||
@ -370,9 +382,11 @@ void ege::ElementPhysic::dynamicEnable() {
|
||||
return;
|
||||
}
|
||||
if(m_body != nullptr) {
|
||||
EGE_ERROR("dynamicEnable : RigidBody");
|
||||
m_env->getPhysicEngine().getDynamicWorld()->addRigidBody(m_body);
|
||||
}
|
||||
if(m_IA != nullptr) {
|
||||
EGE_ERROR("dynamicEnable : IA");
|
||||
m_env->getPhysicEngine().getDynamicWorld()->addAction(m_IA);
|
||||
}
|
||||
m_elementInPhysicsSystem = true;
|
||||
@ -383,9 +397,11 @@ void ege::ElementPhysic::dynamicDisable() {
|
||||
return;
|
||||
}
|
||||
if(m_IA != nullptr) {
|
||||
EGE_ERROR("dynamicDisable : IA");
|
||||
m_env->getPhysicEngine().getDynamicWorld()->removeAction(m_IA);
|
||||
}
|
||||
if(m_body != nullptr) {
|
||||
EGE_ERROR("dynamicDisable : RigidBody");
|
||||
// Unlink element from the engine
|
||||
m_env->getPhysicEngine().getDynamicWorld()->removeRigidBody(m_body);
|
||||
m_env->getPhysicEngine().getDynamicWorld()->removeCollisionObject(m_body);
|
||||
|
@ -37,8 +37,6 @@ namespace ege {
|
||||
static void FunctionFreeShape(void* _pointer);
|
||||
protected:
|
||||
btRigidBody* m_body; //!< all the element have a body == > otherwise it will be not manage with this system...
|
||||
private:
|
||||
btDefaultMotionState* m_motionState;
|
||||
public:
|
||||
void createRigidBody(float _mass=400000000.0f);
|
||||
public:
|
||||
|
@ -32,6 +32,9 @@ namespace ege {
|
||||
float getRadius() const {
|
||||
return m_radius;
|
||||
};
|
||||
void setRadius(float _radius) {
|
||||
m_radius = _radius;
|
||||
};
|
||||
private:
|
||||
virtual const ege::PhysicsSphere* toSphere() const {
|
||||
return this;
|
||||
|
@ -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,
|
||||
bool _enableDepthTest,
|
||||
@ -128,14 +128,20 @@ void ege::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
mat4 tmpMatrix = projMatrix * camMatrix;
|
||||
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix);
|
||||
m_GLprogram->uniformMatrix(m_GLMatrixPosition, _positionMatrix);
|
||||
EGE_DEBUG(" m_GLMatrix=" << m_GLMatrix << " ==> " << tmpMatrix);
|
||||
EGE_DEBUG(" m_GLMatrixPosition=" << m_GLMatrixPosition << " ==> " << _positionMatrix);
|
||||
// position :
|
||||
m_GLprogram->sendAttributePointer(m_GLPosition, m_verticesVBO, MESH_VBO_VERTICES);
|
||||
EGE_DEBUG(" m_GLPosition=" << m_GLPosition << " ==> " << "");
|
||||
// Texture :
|
||||
m_GLprogram->sendAttributePointer(m_GLtexture, m_verticesVBO, MESH_VBO_TEXTURE);
|
||||
EGE_DEBUG(" m_GLtexture=" << m_GLtexture << " ==> " << "");
|
||||
// position :
|
||||
m_GLprogram->sendAttributePointer(m_GLNormal, m_verticesVBO, MESH_VBO_VERTICES_NORMAL);
|
||||
EGE_DEBUG(" m_GLNormal=" << m_GLNormal << " ==> " << "");
|
||||
// position :
|
||||
m_GLprogram->sendAttributePointer(m_GLColor, m_verticesVBO, MESH_VBO_COLOR);
|
||||
EGE_DEBUG(" m_GLColor=" << m_GLColor << " ==> " << "");
|
||||
// draw lights :
|
||||
m_light.draw(m_GLprogram);
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
@ -193,9 +199,18 @@ void ege::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
}
|
||||
}
|
||||
#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
|
||||
m_GLprogram->unUse();
|
||||
|
||||
if (_enableDepthTest == true){
|
||||
if (false == _enableDepthUpdate) {
|
||||
glDepthMask(GL_TRUE);
|
||||
@ -203,7 +218,7 @@ void ege::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
}
|
||||
// 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 :
|
||||
@ -267,7 +282,7 @@ void ege::resource::Mesh::generateVBO() {
|
||||
// when no normal detected == > auto generate Face normal ....
|
||||
calculateNormaleFace(m_listFaces.getKeys()[0]);
|
||||
}
|
||||
|
||||
EGE_WARNING("Generate VBO for nb faces : " << m_listFaces.size());
|
||||
|
||||
// generate element in 2 pass :
|
||||
// - create new index dependeng a vertex is a unique componenet of position, texture, normal
|
||||
|
@ -10,6 +10,7 @@
|
||||
#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) {
|
||||
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");
|
||||
if (out != nullptr) {
|
||||
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);
|
||||
// generate the VBO
|
||||
out->generateVBO();
|
||||
} else {
|
||||
EGE_ERROR("can not create the basic mesh interface");
|
||||
}
|
||||
return out;
|
||||
}
|
@ -147,6 +147,7 @@ void ege::widget::Scene::systemDraw(const ewol::DrawProperty& _displayProp) {
|
||||
#ifdef SCENE_BRUT_PERFO_TEST
|
||||
int64_t tmp___startTime0 = ewol::getTime();
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||
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
|
||||
glViewport( m_origin.x(),
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <ege/elements/ElementBase.h>
|
||||
#include <ege/elements/ElementPhysic.h>
|
||||
#include <ege/physicsShape/PhysicsBox.h>
|
||||
#include <ege/physicsShape/PhysicsSphere.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Windows"
|
||||
@ -26,7 +27,7 @@ appl::Windows::Windows() {
|
||||
}
|
||||
|
||||
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) {
|
||||
std::shared_ptr<ege::Material> material = std::make_shared<ege::Material>();
|
||||
// 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->setSpecularFactor(vec4(0,0,0,1));
|
||||
material->setShininess(1);
|
||||
material->setTexture0(""); //"
|
||||
out->addMaterial("basics", material);
|
||||
// 1024 == > 1<<9
|
||||
// 2048 == > 1<<10
|
||||
// 4096 == > 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();
|
||||
if (nullptr == myImage) {
|
||||
return out;
|
||||
@ -96,24 +98,38 @@ void appl::Windows::init() {
|
||||
if (myMesh != nullptr) {
|
||||
//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);
|
||||
element->setMesh(myMesh);
|
||||
element->setPosition(vec3(20,10,10));
|
||||
// add physic interface:
|
||||
/*
|
||||
std::shared_ptr<ege::PhysicsBox> physic = std::make_shared<ege::PhysicsBox>();
|
||||
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);
|
||||
|
||||
m_env->addElement(element);
|
||||
|
||||
|
||||
//element = std::make_shared<ege::ElementBase>(m_env);
|
||||
element = std::make_shared<ege::ElementPhysic>(m_env);
|
||||
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:
|
||||
physic = std::make_shared<ege::PhysicsBox>();
|
||||
physic->setSize(vec3(3.2,3.2,3.2));
|
||||
std::shared_ptr<ege::PhysicsSphere> physic = std::make_shared<ege::PhysicsSphere>();
|
||||
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);
|
||||
|
||||
}
|
||||
@ -124,8 +140,8 @@ void appl::Windows::onCallbackPeriodicUpdateCamera(const ewol::event::Time& _eve
|
||||
static float offset = 0;
|
||||
offset += 0.01;
|
||||
static float offset2 = 0;
|
||||
offset2 += 0.003;
|
||||
//m_camera->setEye(vec3(100*std::sin(offset),100*std::cos(offset),40*std::cos(offset2)));
|
||||
//offset2 += 0.003;
|
||||
m_camera->setEye(vec3(100*std::sin(offset),100*std::cos(offset),40*std::cos(offset2)));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user