[DEV] add shape cone, cylinder, sphere, capsule
This commit is contained in:
parent
d154b0c901
commit
3c6c79b8bd
@ -80,7 +80,7 @@ void ege::physics::Component::generate() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (it->getType()) {
|
switch (it->getType()) {
|
||||||
case ege::physics::Shape::type::box : {
|
case ege::physics::Shape::type::box: {
|
||||||
EGE_DEBUG(" Box");
|
EGE_DEBUG(" Box");
|
||||||
const ege::physics::shape::Box* tmpElement = it->toBox();
|
const ege::physics::shape::Box* tmpElement = it->toBox();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
@ -106,15 +106,15 @@ void ege::physics::Component::generate() {
|
|||||||
m_listProxyShape.push_back(proxyShape);
|
m_listProxyShape.push_back(proxyShape);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::cylinder : {
|
case ege::physics::Shape::type::cylinder: {
|
||||||
EGE_DEBUG(" Cylinder");
|
EGE_DEBUG(" Cylinder");
|
||||||
const ege::physics::shape::Cylinder* tmpElement = it->toCylinder();
|
const ege::physics::shape::Cylinder* tmpElement = it->toCylinder();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Cylinder ==> can not cast in Cylinder");
|
EGE_ERROR(" Cylinder ==> can not cast in Cylinder");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Create the box shape
|
// Create the Cylinder shape
|
||||||
rp3d::CylinderShape* shape = new rp3d::CylinderShape(tmpElement->getSize().x(), tmpElement->getSize().y());
|
rp3d::CylinderShape* shape = new rp3d::CylinderShape(tmpElement->getRadius(), tmpElement->getSize());
|
||||||
rp3d::Vector3 position(it->getOrigin().x(),
|
rp3d::Vector3 position(it->getOrigin().x(),
|
||||||
it->getOrigin().y(),
|
it->getOrigin().y(),
|
||||||
it->getOrigin().z());
|
it->getOrigin().z());
|
||||||
@ -127,49 +127,49 @@ void ege::physics::Component::generate() {
|
|||||||
m_listProxyShape.push_back(proxyShape);
|
m_listProxyShape.push_back(proxyShape);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::capsule : {
|
case ege::physics::Shape::type::capsule: {
|
||||||
EGE_DEBUG(" Capsule");
|
EGE_DEBUG(" Capsule");
|
||||||
const ege::physics::shape::Capsule* tmpElement = it->toCapsule();
|
const ege::physics::shape::Capsule* tmpElement = it->toCapsule();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Capsule ==> can not cast in Capsule");
|
EGE_ERROR(" Capsule ==> can not cast in Capsule");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
// Create the Capsule shape
|
||||||
btCollisionShape* tmpShape = new btCapsuleShape(tmpElement->getRadius(), tmpElement->getHeight());
|
rp3d::CapsuleShape* shape = new rp3d::CapsuleShape(tmpElement->getRadius(), tmpElement->getSize());
|
||||||
if (tmpShape != nullptr) {
|
rp3d::Vector3 position(it->getOrigin().x(),
|
||||||
if (outputShape == nullptr) {
|
it->getOrigin().y(),
|
||||||
return tmpShape;
|
it->getOrigin().z());
|
||||||
} else {
|
rp3d::Quaternion orientation(it->getQuaternion().x(),
|
||||||
vec4 qqq = tmpElement->getQuaternion();
|
it->getQuaternion().y(),
|
||||||
const btTransform localTransform(btQuaternion(qqq.x(),qqq.y(),qqq.z(),qqq.w()), tmpElement->getOrigin());
|
it->getQuaternion().z(),
|
||||||
outputShape->addChildShape(localTransform, tmpShape);
|
it->getQuaternion().w());
|
||||||
}
|
rp3d::Transform transform(position, orientation);
|
||||||
}
|
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||||
*/
|
m_listProxyShape.push_back(proxyShape);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::cone : {
|
case ege::physics::Shape::type::cone: {
|
||||||
EGE_DEBUG(" Cone");
|
EGE_DEBUG(" Cone");
|
||||||
const ege::physics::shape::Cone* tmpElement = it->toCone();
|
const ege::physics::shape::Cone* tmpElement = it->toCone();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Cone ==> can not cast in Cone");
|
EGE_ERROR(" Cone ==> can not cast in Cone");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
// Create the Cone shape
|
||||||
btCollisionShape* tmpShape = new btConeShape(tmpElement->getRadius(), tmpElement->getHeight());
|
rp3d::ConeShape* shape = new rp3d::ConeShape(tmpElement->getRadius(), tmpElement->getSize());
|
||||||
if (tmpShape != nullptr) {
|
rp3d::Vector3 position(it->getOrigin().x(),
|
||||||
if (outputShape == nullptr) {
|
it->getOrigin().y(),
|
||||||
return tmpShape;
|
it->getOrigin().z());
|
||||||
} else {
|
rp3d::Quaternion orientation(it->getQuaternion().x(),
|
||||||
vec4 qqq = tmpElement->getQuaternion();
|
it->getQuaternion().y(),
|
||||||
const btTransform localTransform(btQuaternion(qqq.x(),qqq.y(),qqq.z(),qqq.w()), tmpElement->getOrigin());
|
it->getQuaternion().z(),
|
||||||
outputShape->addChildShape(localTransform, tmpShape);
|
it->getQuaternion().w());
|
||||||
}
|
rp3d::Transform transform(position, orientation);
|
||||||
}
|
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||||
*/
|
m_listProxyShape.push_back(proxyShape);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::sphere : {
|
case ege::physics::Shape::type::sphere: {
|
||||||
EGE_DEBUG(" Sphere");
|
EGE_DEBUG(" Sphere");
|
||||||
const ege::physics::shape::Sphere* tmpElement = it->toSphere();
|
const ege::physics::shape::Sphere* tmpElement = it->toSphere();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
@ -188,21 +188,9 @@ void ege::physics::Component::generate() {
|
|||||||
rp3d::Transform transform(position, orientation);
|
rp3d::Transform transform(position, orientation);
|
||||||
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
rp3d::ProxyShape* proxyShape = m_rigidBody->addCollisionShape(shape, transform, it->getMass());
|
||||||
m_listProxyShape.push_back(proxyShape);
|
m_listProxyShape.push_back(proxyShape);
|
||||||
/*
|
|
||||||
btCollisionShape* tmpShape = new btSphereShape(tmpElement->getRadius());
|
|
||||||
if (tmpShape != nullptr) {
|
|
||||||
if (outputShape == nullptr) {
|
|
||||||
return tmpShape;
|
|
||||||
} else {
|
|
||||||
vec4 qqq = tmpElement->getQuaternion();
|
|
||||||
const btTransform localTransform(btQuaternion(qqq.x(),qqq.y(),qqq.z(),qqq.w()), tmpElement->getOrigin());
|
|
||||||
outputShape->addChildShape(localTransform, tmpShape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::convexHull : {
|
case ege::physics::Shape::type::convexHull: {
|
||||||
EGE_DEBUG(" convexHull");
|
EGE_DEBUG(" convexHull");
|
||||||
const ege::physics::shape::ConvexHull* tmpElement = it->toConvexHull();
|
const ege::physics::shape::ConvexHull* tmpElement = it->toConvexHull();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
@ -225,7 +213,7 @@ void ege::physics::Component::generate() {
|
|||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
EGE_DEBUG(" ???");
|
EGE_DEBUG(" ???");
|
||||||
// TODO : UNKNOW type ...
|
// TODO: UNKNOW type ...
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,7 +340,7 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
_draw->drawSquare(tmpElement->getSize(), transformationMatrixLocal, tmpColor);
|
_draw->drawSquare(tmpElement->getSize(), transformationMatrixLocal, tmpColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::cylinder : {
|
case ege::physics::Shape::type::cylinder: {
|
||||||
EGE_DEBUG(" Cylinder");
|
EGE_DEBUG(" Cylinder");
|
||||||
const ege::physics::shape::Cylinder* tmpElement = it->toCylinder();
|
const ege::physics::shape::Cylinder* tmpElement = it->toCylinder();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
@ -364,52 +352,40 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
mat4 transformationMatrixLocal(mmm);
|
mat4 transformationMatrixLocal(mmm);
|
||||||
transformationMatrixLocal.transpose();
|
transformationMatrixLocal.transpose();
|
||||||
transformationMatrixLocal = transformationMatrix * transformationMatrixLocal;
|
transformationMatrixLocal = transformationMatrix * transformationMatrixLocal;
|
||||||
//_draw->drawSphere(radius, 10, 10, _transformationMatrix, tmpColor);
|
_draw->drawCylinder(tmpElement->getRadius(), tmpElement->getSize(), 10, 10, transformationMatrixLocal, tmpColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::capsule : {
|
case ege::physics::Shape::type::capsule: {
|
||||||
EGE_DEBUG(" Capsule");
|
EGE_DEBUG(" Capsule");
|
||||||
const ege::physics::shape::Capsule* tmpElement = it->toCapsule();
|
const ege::physics::shape::Capsule* tmpElement = it->toCapsule();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Capsule ==> can not cast in Capsule");
|
EGE_ERROR(" Capsule ==> can not cast in Capsule");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
etk::Transform3D transformLocal(it->getOrigin(), it->getOrientation());
|
||||||
btCollisionShape* tmpShape = new btCapsuleShape(tmpElement->getRadius(), tmpElement->getHeight());
|
transformLocal.getOpenGLMatrix(mmm);
|
||||||
if (tmpShape != nullptr) {
|
mat4 transformationMatrixLocal(mmm);
|
||||||
if (outputShape == nullptr) {
|
transformationMatrixLocal.transpose();
|
||||||
return tmpShape;
|
transformationMatrixLocal = transformationMatrix * transformationMatrixLocal;
|
||||||
} else {
|
_draw->drawCapsule(tmpElement->getRadius(), tmpElement->getSize(), 10, 10, transformationMatrixLocal, tmpColor);
|
||||||
vec4 qqq = tmpElement->getQuaternion();
|
|
||||||
const btTransform localTransform(btQuaternion(qqq.x(),qqq.y(),qqq.z(),qqq.w()), tmpElement->getOrigin());
|
|
||||||
outputShape->addChildShape(localTransform, tmpShape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::cone : {
|
case ege::physics::Shape::type::cone: {
|
||||||
EGE_DEBUG(" Cone");
|
EGE_DEBUG(" Cone");
|
||||||
const ege::physics::shape::Cone* tmpElement = it->toCone();
|
const ege::physics::shape::Cone* tmpElement = it->toCone();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
EGE_ERROR(" Cone ==> can not cast in Cone");
|
EGE_ERROR(" Cone ==> can not cast in Cone");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
etk::Transform3D transformLocal(it->getOrigin(), it->getOrientation());
|
||||||
btCollisionShape* tmpShape = new btConeShape(tmpElement->getRadius(), tmpElement->getHeight());
|
transformLocal.getOpenGLMatrix(mmm);
|
||||||
if (tmpShape != nullptr) {
|
mat4 transformationMatrixLocal(mmm);
|
||||||
if (outputShape == nullptr) {
|
transformationMatrixLocal.transpose();
|
||||||
return tmpShape;
|
transformationMatrixLocal = transformationMatrix * transformationMatrixLocal;
|
||||||
} else {
|
_draw->drawCone(tmpElement->getRadius(), tmpElement->getSize(), 10, 10, transformationMatrixLocal, tmpColor);
|
||||||
vec4 qqq = tmpElement->getQuaternion();
|
|
||||||
const btTransform localTransform(btQuaternion(qqq.x(),qqq.y(),qqq.z(),qqq.w()), tmpElement->getOrigin());
|
|
||||||
outputShape->addChildShape(localTransform, tmpShape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::sphere : {
|
case ege::physics::Shape::type::sphere: {
|
||||||
EGE_DEBUG(" Sphere");
|
EGE_DEBUG(" Sphere");
|
||||||
const ege::physics::shape::Sphere* tmpElement = it->toSphere();
|
const ege::physics::shape::Sphere* tmpElement = it->toSphere();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
@ -424,7 +400,7 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
_draw->drawSphere(tmpElement->getRadius(), 10, 10, transformationMatrixLocal, tmpColor);
|
_draw->drawSphere(tmpElement->getRadius(), 10, 10, transformationMatrixLocal, tmpColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ege::physics::Shape::type::convexHull : {
|
case ege::physics::Shape::type::convexHull: {
|
||||||
EGE_DEBUG(" convexHull");
|
EGE_DEBUG(" convexHull");
|
||||||
const ege::physics::shape::ConvexHull* tmpElement = it->toConvexHull();
|
const ege::physics::shape::ConvexHull* tmpElement = it->toConvexHull();
|
||||||
if (tmpElement == nullptr) {
|
if (tmpElement == nullptr) {
|
||||||
@ -447,7 +423,7 @@ void ege::physics::Component::drawShape(ememory::SharedPtr<ewol::resource::Color
|
|||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
EGE_DEBUG(" ???");
|
EGE_DEBUG(" ???");
|
||||||
// TODO : UNKNOW type ...
|
// TODO: UNKNOW type ...
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ bool ege::physics::shape::Capsule::parse(const char* _line) {
|
|||||||
EGE_VERBOSE(" radius=" << m_radius);
|
EGE_VERBOSE(" radius=" << m_radius);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(strncmp(_line, "height:", 7) == 0) {
|
if(strncmp(_line, "size:", 5) == 0) {
|
||||||
sscanf(&_line[7], "%f", &m_height );
|
sscanf(&_line[5], "%f", &m_size );
|
||||||
EGE_VERBOSE(" height=" << m_height);
|
EGE_VERBOSE(" height=" << m_size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -15,7 +15,9 @@ namespace ege {
|
|||||||
namespace shape {
|
namespace shape {
|
||||||
class Capsule : public ege::physics::Shape {
|
class Capsule : public ege::physics::Shape {
|
||||||
public:
|
public:
|
||||||
Capsule() {};
|
Capsule() :
|
||||||
|
m_radius(1.0f),
|
||||||
|
m_size(1.0f) {};
|
||||||
virtual ~Capsule() {};
|
virtual ~Capsule() {};
|
||||||
public:
|
public:
|
||||||
virtual bool parse(const char* _line);
|
virtual bool parse(const char* _line);
|
||||||
@ -23,26 +25,32 @@ namespace ege {
|
|||||||
public:
|
public:
|
||||||
virtual enum ege::physics::Shape::type getType() const {
|
virtual enum ege::physics::Shape::type getType() const {
|
||||||
return ege::physics::Shape::type::capsule;
|
return ege::physics::Shape::type::capsule;
|
||||||
};
|
}
|
||||||
private:
|
private:
|
||||||
float m_radius;
|
float m_radius;
|
||||||
public:
|
public:
|
||||||
float getRadius() const {
|
float getRadius() const {
|
||||||
return m_radius;
|
return m_radius;
|
||||||
};
|
}
|
||||||
|
void setRadius(float _radius) {
|
||||||
|
m_radius = _radius;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
float m_height;
|
float m_size;
|
||||||
public:
|
public:
|
||||||
float getHeight() const {
|
float getSize() const {
|
||||||
return m_height;
|
return m_size;
|
||||||
};
|
}
|
||||||
|
void setSize(float _size) {
|
||||||
|
m_size = _size;
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
virtual const ege::physics::shape::Capsule* toCapsule() const {
|
virtual const ege::physics::shape::Capsule* toCapsule() const {
|
||||||
return this;
|
return this;
|
||||||
};
|
}
|
||||||
virtual ege::physics::shape::Capsule* toCapsule() {
|
virtual ege::physics::shape::Capsule* toCapsule() {
|
||||||
return this;
|
return this;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ bool ege::physics::shape::Cone::parse(const char* _line) {
|
|||||||
EGE_VERBOSE(" radius=" << m_radius);
|
EGE_VERBOSE(" radius=" << m_radius);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(strncmp(_line, "height:", 7) == 0) {
|
if(strncmp(_line, "size:", 5) == 0) {
|
||||||
sscanf(&_line[7], "%f", &m_height );
|
sscanf(&_line[5], "%f", &m_size );
|
||||||
EGE_VERBOSE(" height=" << m_height);
|
EGE_VERBOSE(" size=" << m_size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,13 +27,19 @@ namespace ege {
|
|||||||
public:
|
public:
|
||||||
float getRadius() const {
|
float getRadius() const {
|
||||||
return m_radius;
|
return m_radius;
|
||||||
};
|
}
|
||||||
|
void setRadius(float _radius) {
|
||||||
|
m_radius = _radius;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
float m_height;
|
float m_size;
|
||||||
public:
|
public:
|
||||||
float getHeight() const {
|
float getSize() const {
|
||||||
return m_height;
|
return m_size;
|
||||||
};
|
}
|
||||||
|
void setSize(float _size) {
|
||||||
|
m_size = _size;
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
virtual const ege::physics::shape::Cone* toCone() const {
|
virtual const ege::physics::shape::Cone* toCone() const {
|
||||||
return this;
|
return this;
|
||||||
|
@ -11,9 +11,14 @@ bool ege::physics::shape::Cylinder::parse(const char* _line) {
|
|||||||
if (ege::physics::Shape::parse(_line) == true) {
|
if (ege::physics::Shape::parse(_line) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(strncmp(_line, "half-extents:", 13) == 0) {
|
if(strncmp(_line, "radius:", 7) == 0) {
|
||||||
sscanf(&_line[13], "%f %f %f", &m_size.m_floats[0], &m_size.m_floats[1], &m_size.m_floats[2] );
|
sscanf(&_line[7], "%f", &m_radius );
|
||||||
EGE_VERBOSE(" halfSize=" << m_size);
|
EGE_VERBOSE(" radius=" << m_radius);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(strncmp(_line, "size:", 5) == 0) {
|
||||||
|
sscanf(&_line[5], "%f", &m_size );
|
||||||
|
EGE_VERBOSE(" size=" << m_size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -15,7 +15,9 @@ namespace ege {
|
|||||||
namespace shape {
|
namespace shape {
|
||||||
class Cylinder : public ege::physics::Shape {
|
class Cylinder : public ege::physics::Shape {
|
||||||
public:
|
public:
|
||||||
Cylinder() {};
|
Cylinder() :
|
||||||
|
m_radius(1.0f),
|
||||||
|
m_size(1.0f) {};
|
||||||
virtual ~Cylinder() {};
|
virtual ~Cylinder() {};
|
||||||
public:
|
public:
|
||||||
virtual bool parse(const char* _line);
|
virtual bool parse(const char* _line);
|
||||||
@ -25,11 +27,23 @@ namespace ege {
|
|||||||
return ege::physics::Shape::type::cylinder;
|
return ege::physics::Shape::type::cylinder;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
vec3 m_size;
|
float m_radius;
|
||||||
public:
|
public:
|
||||||
vec3 getSize() const {
|
float getRadius() const {
|
||||||
|
return m_radius;
|
||||||
|
}
|
||||||
|
void setRadius(float _radius) {
|
||||||
|
m_radius = _radius;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
float m_size;
|
||||||
|
public:
|
||||||
|
float getSize() const {
|
||||||
return m_size;
|
return m_size;
|
||||||
};
|
}
|
||||||
|
void setSize(float _size) {
|
||||||
|
m_size = _size;
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
virtual const ege::physics::shape::Cylinder* toCylinder() const {
|
virtual const ege::physics::shape::Cylinder* toCylinder() const {
|
||||||
return this;
|
return this;
|
||||||
|
@ -25,7 +25,7 @@ namespace ege {
|
|||||||
return ege::physics::Shape::type::sphere;
|
return ege::physics::Shape::type::sphere;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
float m_radius; // props["radius"] = obj.scale.x
|
float m_radius;
|
||||||
public:
|
public:
|
||||||
float getRadius() const {
|
float getRadius() const {
|
||||||
return m_radius;
|
return m_radius;
|
||||||
|
@ -42,9 +42,24 @@ namespace ege {
|
|||||||
const etk::Color<float>& _color=etk::color::green,
|
const etk::Color<float>& _color=etk::color::green,
|
||||||
int32_t _lats = 10,
|
int32_t _lats = 10,
|
||||||
int32_t _longs = 10);
|
int32_t _longs = 10);
|
||||||
static ememory::SharedPtr<ege::resource::Mesh> createCylinder(float _size=1.0f,
|
static ememory::SharedPtr<ege::resource::Mesh> createCylinder(float _radius = 1.0f,
|
||||||
|
float _size = 1.0f,
|
||||||
const std::string& _materialName="basics",
|
const std::string& _materialName="basics",
|
||||||
const etk::Color<float>& _color=etk::color::green);
|
const etk::Color<float>& _color=etk::color::green,
|
||||||
|
int32_t _lats = 10,
|
||||||
|
int32_t _longs = 10);
|
||||||
|
static ememory::SharedPtr<ege::resource::Mesh> createCapsule(float _radius = 1.0f,
|
||||||
|
float _size = 1.0f,
|
||||||
|
const std::string& _materialName="basics",
|
||||||
|
const etk::Color<float>& _color=etk::color::green,
|
||||||
|
int32_t _lats = 10,
|
||||||
|
int32_t _longs = 10);
|
||||||
|
static ememory::SharedPtr<ege::resource::Mesh> createCone(float _radius = 1.0f,
|
||||||
|
float _size = 1.0f,
|
||||||
|
const std::string& _materialName="basics",
|
||||||
|
const etk::Color<float>& _color=etk::color::green,
|
||||||
|
int32_t _lats = 10,
|
||||||
|
int32_t _longs = 10);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @not_in_doc
|
* @not_in_doc
|
||||||
|
104
ege/resource/MeshCapsule.cpp
Normal file
104
ege/resource/MeshCapsule.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ege/debug.hpp>
|
||||||
|
#include <ege/resource/Mesh.hpp>
|
||||||
|
|
||||||
|
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCapsule(float _radius, float _size, const std::string& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) {
|
||||||
|
EGE_VERBOSE(" create a capsule _size=" << _size << " _materialName=" << _materialName << " _color=" << _color);
|
||||||
|
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog");
|
||||||
|
if (out != nullptr) {
|
||||||
|
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
|
||||||
|
// set the element material properties :
|
||||||
|
material->setAmbientFactor(vec4(1,1,1,1));
|
||||||
|
material->setDiffuseFactor(vec4(0,0,0,1));
|
||||||
|
material->setSpecularFactor(vec4(0,0,0,1));
|
||||||
|
material->setShininess(1);
|
||||||
|
material->setRenderMode(gale::openGL::renderMode::triangle);
|
||||||
|
out->addMaterial(_materialName, material);
|
||||||
|
|
||||||
|
out->addFaceIndexing(_materialName);
|
||||||
|
|
||||||
|
// center to border (TOP)
|
||||||
|
float offset = _size*0.5f;
|
||||||
|
for(int32_t iii=_lats/2+1; iii<=_lats; ++iii) {
|
||||||
|
float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats);
|
||||||
|
float y0 = _radius*sin(lat0);
|
||||||
|
float yr0 = _radius*cos(lat0);
|
||||||
|
|
||||||
|
float lat1 = M_PI * (-0.5f + float(iii) / _lats);
|
||||||
|
float y1 = _radius*sin(lat1);
|
||||||
|
float yr1 = _radius*cos(lat1);
|
||||||
|
|
||||||
|
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
||||||
|
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
||||||
|
float x = cos(lng);
|
||||||
|
float z = sin(lng);
|
||||||
|
vec3 v1 = vec3(x * yr1, y1+offset, z * yr1);
|
||||||
|
vec3 v4 = vec3(x * yr0, y0+offset, z * yr0);
|
||||||
|
|
||||||
|
lng = 2 * M_PI * float(jjj) / _longs;
|
||||||
|
x = cos(lng);
|
||||||
|
z = sin(lng);
|
||||||
|
vec3 v2 = vec3(x * yr1, y1+offset, z * yr1);
|
||||||
|
vec3 v3 = vec3(x * yr0, y0+offset, z * yr0);
|
||||||
|
out->addQuad(_materialName, v1, v2, v3, v4, _color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Cylinder
|
||||||
|
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
||||||
|
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
||||||
|
|
||||||
|
float y = _size*0.5f;
|
||||||
|
|
||||||
|
float x = cos(lng)*_radius;
|
||||||
|
float z = sin(lng)*_radius;
|
||||||
|
vec3 v2 = vec3(x, y, z);
|
||||||
|
vec3 v2b = vec3(x, -y, z);
|
||||||
|
|
||||||
|
lng = 2.0f * M_PI * float(jjj) / _longs;
|
||||||
|
x = cos(lng)*_radius;
|
||||||
|
z = sin(lng)*_radius;
|
||||||
|
vec3 v3 = vec3(x, y, z);
|
||||||
|
vec3 v3b = vec3(x, -y, z);
|
||||||
|
|
||||||
|
out->addQuad(_materialName, v2, v3, v3b, v2b, _color);
|
||||||
|
}
|
||||||
|
// center to border (BUTTOM)
|
||||||
|
offset = -_size*0.5f;
|
||||||
|
for(int32_t iii=0; iii<=_lats/2; ++iii) {
|
||||||
|
float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats);
|
||||||
|
float y0 = _radius*sin(lat0);
|
||||||
|
float yr0 = _radius*cos(lat0);
|
||||||
|
|
||||||
|
float lat1 = M_PI * (-0.5f + float(iii) / _lats);
|
||||||
|
float y1 = _radius*sin(lat1);
|
||||||
|
float yr1 = _radius*cos(lat1);
|
||||||
|
|
||||||
|
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
||||||
|
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
||||||
|
float x = cos(lng);
|
||||||
|
float z = sin(lng);
|
||||||
|
vec3 v1 = vec3(x * yr1, y1+offset, z * yr1);
|
||||||
|
vec3 v4 = vec3(x * yr0, y0+offset, z * yr0);
|
||||||
|
|
||||||
|
lng = 2 * M_PI * float(jjj) / _longs;
|
||||||
|
x = cos(lng);
|
||||||
|
z = sin(lng);
|
||||||
|
vec3 v2 = vec3(x * yr1, y1+offset, z * yr1);
|
||||||
|
vec3 v3 = vec3(x * yr0, y0+offset, z * yr0);
|
||||||
|
out->addQuad(_materialName, v1, v2, v3, v4, _color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out->setNormalMode(ege::resource::Mesh::normalMode::face);
|
||||||
|
out->calculateNormaleFace(_materialName);
|
||||||
|
// generate the VBO
|
||||||
|
out->generateVBO();
|
||||||
|
} else {
|
||||||
|
EGE_ERROR("can not create the basic mesh interface");
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
64
ege/resource/MeshCone.cpp
Normal file
64
ege/resource/MeshCone.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ege/debug.hpp>
|
||||||
|
#include <ege/resource/Mesh.hpp>
|
||||||
|
|
||||||
|
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCone(float _radius, float _size, const std::string& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) {
|
||||||
|
EGE_VERBOSE(" create a cylinder _size=" << _size << " _materialName=" << _materialName << " _color=" << _color);
|
||||||
|
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog");
|
||||||
|
if (out != nullptr) {
|
||||||
|
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
|
||||||
|
// set the element material properties :
|
||||||
|
material->setAmbientFactor(vec4(1,1,1,1));
|
||||||
|
material->setDiffuseFactor(vec4(0,0,0,1));
|
||||||
|
material->setSpecularFactor(vec4(0,0,0,1));
|
||||||
|
material->setShininess(1);
|
||||||
|
material->setRenderMode(gale::openGL::renderMode::triangle);
|
||||||
|
out->addMaterial(_materialName, material);
|
||||||
|
|
||||||
|
out->addFaceIndexing(_materialName);
|
||||||
|
|
||||||
|
// center to border (TOP)
|
||||||
|
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
||||||
|
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
||||||
|
vec3 v1 = vec3(0.0f, -_size/2, 0.0f);
|
||||||
|
|
||||||
|
float x = cos(lng)*_radius;
|
||||||
|
float z = sin(lng)*_radius;
|
||||||
|
vec3 v2 = vec3(x, _size/2, z);
|
||||||
|
|
||||||
|
lng = 2.0f * M_PI * float(jjj) / _longs;
|
||||||
|
x = cos(lng)*_radius;
|
||||||
|
z = sin(lng)*_radius;
|
||||||
|
vec3 v3 = vec3(x, _size/2, z);
|
||||||
|
out->addTriangle(_materialName, v1, v2, v3, _color);
|
||||||
|
}
|
||||||
|
// center to border (BUTTOM)
|
||||||
|
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
||||||
|
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
||||||
|
|
||||||
|
vec3 v1 = vec3(0.0f, _size/2, 0.0f);
|
||||||
|
|
||||||
|
float x = cos(lng)*_radius;
|
||||||
|
float z = sin(lng)*_radius;
|
||||||
|
vec3 v2 = vec3(x, _size/2, z);
|
||||||
|
|
||||||
|
lng = 2.0f * M_PI * float(jjj) / _longs;
|
||||||
|
x = cos(lng)*_radius;
|
||||||
|
z = sin(lng)*_radius;
|
||||||
|
vec3 v3 = vec3(x, _size/2, z);
|
||||||
|
out->addTriangle(_materialName, v1, v3, v2, _color);
|
||||||
|
}
|
||||||
|
out->setNormalMode(ege::resource::Mesh::normalMode::face);
|
||||||
|
out->calculateNormaleFace(_materialName);
|
||||||
|
// generate the VBO
|
||||||
|
out->generateVBO();
|
||||||
|
} else {
|
||||||
|
EGE_ERROR("can not create the basic mesh interface");
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
@ -7,8 +7,8 @@
|
|||||||
#include <ege/debug.hpp>
|
#include <ege/debug.hpp>
|
||||||
#include <ege/resource/Mesh.hpp>
|
#include <ege/resource/Mesh.hpp>
|
||||||
|
|
||||||
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCylinder(float _size, const std::string& _materialName, const etk::Color<float>& _color) {
|
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCylinder(float _radius, float _size, const std::string& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) {
|
||||||
EGE_VERBOSE(" create a cube _size=" << _size << " _materialName=" << _materialName << " _color=" << _color);
|
EGE_VERBOSE(" create a cylinder _size=" << _size << " _materialName=" << _materialName << " _color=" << _color);
|
||||||
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog");
|
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog");
|
||||||
if (out != nullptr) {
|
if (out != nullptr) {
|
||||||
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
|
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
|
||||||
@ -22,12 +22,59 @@ ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCylinder(floa
|
|||||||
|
|
||||||
out->addFaceIndexing(_materialName);
|
out->addFaceIndexing(_materialName);
|
||||||
|
|
||||||
out->addQuad(_materialName, vec3(-1,-1,-1)*_size, vec3(-1, 1,-1)*_size, vec3( 1, 1,-1)*_size, vec3( 1,-1,-1)*_size, _color);
|
// center to border (TOP)
|
||||||
out->addQuad(_materialName, vec3(-1, 1, 1)*_size, vec3(-1,-1, 1)*_size, vec3( 1,-1, 1)*_size, vec3( 1, 1, 1)*_size, _color);
|
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
||||||
out->addQuad(_materialName, vec3(-1,-1,-1)*_size, vec3(-1,-1, 1)*_size, vec3(-1, 1, 1)*_size, vec3(-1, 1,-1)*_size, _color);
|
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
||||||
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);
|
float y = _size*0.5f;
|
||||||
out->addQuad(_materialName, vec3(-1, 1,-1)*_size, vec3(-1, 1, 1)*_size, vec3( 1, 1, 1)*_size, vec3( 1, 1,-1)*_size, _color);
|
vec3 v1 = vec3(0.0f, y, 0.0f);
|
||||||
|
|
||||||
|
float x = cos(lng)*_radius;
|
||||||
|
float z = sin(lng)*_radius;
|
||||||
|
vec3 v2 = vec3(x, y, z);
|
||||||
|
|
||||||
|
lng = 2.0f * M_PI * float(jjj) / _longs;
|
||||||
|
x = cos(lng)*_radius;
|
||||||
|
z = sin(lng)*_radius;
|
||||||
|
vec3 v3 = vec3(x, y, z);
|
||||||
|
out->addTriangle(_materialName, v1, v3, v2, _color);
|
||||||
|
}
|
||||||
|
// Cylinder
|
||||||
|
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
||||||
|
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
||||||
|
|
||||||
|
float y = _size*0.5f;
|
||||||
|
|
||||||
|
float x = cos(lng)*_radius;
|
||||||
|
float z = sin(lng)*_radius;
|
||||||
|
vec3 v2 = vec3(x, y, z);
|
||||||
|
vec3 v2b = vec3(x, -y, z);
|
||||||
|
|
||||||
|
lng = 2.0f * M_PI * float(jjj) / _longs;
|
||||||
|
x = cos(lng)*_radius;
|
||||||
|
z = sin(lng)*_radius;
|
||||||
|
vec3 v3 = vec3(x, y, z);
|
||||||
|
vec3 v3b = vec3(x, -y, z);
|
||||||
|
|
||||||
|
out->addQuad(_materialName, v2, v3, v3b, v2b, _color);
|
||||||
|
}
|
||||||
|
// center to border (BUTTOM)
|
||||||
|
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
||||||
|
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
||||||
|
|
||||||
|
float y = _size*-0.5f;
|
||||||
|
vec3 v1 = vec3(0.0f, y, 0.0f);
|
||||||
|
|
||||||
|
float x = cos(lng)*_radius;
|
||||||
|
float z = sin(lng)*_radius;
|
||||||
|
vec3 v2 = vec3(x, y, z);
|
||||||
|
|
||||||
|
lng = 2.0f * M_PI * float(jjj) / _longs;
|
||||||
|
x = cos(lng)*_radius;
|
||||||
|
z = sin(lng)*_radius;
|
||||||
|
vec3 v3 = vec3(x, y, z);
|
||||||
|
out->addTriangle(_materialName, v1, v2, v3, _color);
|
||||||
|
}
|
||||||
out->setNormalMode(ege::resource::Mesh::normalMode::face);
|
out->setNormalMode(ege::resource::Mesh::normalMode::face);
|
||||||
out->calculateNormaleFace(_materialName);
|
out->calculateNormaleFace(_materialName);
|
||||||
// generate the VBO
|
// generate the VBO
|
||||||
|
@ -21,31 +21,30 @@ ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createSphere(float
|
|||||||
out->addMaterial(_materialName, material);
|
out->addMaterial(_materialName, material);
|
||||||
|
|
||||||
out->addFaceIndexing(_materialName);
|
out->addFaceIndexing(_materialName);
|
||||||
|
|
||||||
for(int32_t iii=0; iii<=_lats; ++iii) {
|
for(int32_t iii=0; iii<=_lats; ++iii) {
|
||||||
float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats);
|
float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats);
|
||||||
float z0 = _radius*sin(lat0);
|
float y0 = _radius*sin(lat0);
|
||||||
float zr0 = _radius*cos(lat0);
|
float yr0 = _radius*cos(lat0);
|
||||||
|
|
||||||
float lat1 = M_PI * (-0.5f + float(iii) / _lats);
|
float lat1 = M_PI * (-0.5f + float(iii) / _lats);
|
||||||
float z1 = _radius*sin(lat1);
|
float y1 = _radius*sin(lat1);
|
||||||
float zr1 = _radius*cos(lat1);
|
float yr1 = _radius*cos(lat1);
|
||||||
|
|
||||||
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
for(int32_t jjj=0; jjj<_longs; ++jjj) {
|
||||||
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
|
||||||
float x = cos(lng);
|
float x = cos(lng);
|
||||||
float y = sin(lng);
|
float z = sin(lng);
|
||||||
vec3 v1 = vec3(x * zr1, y * zr1, z1);
|
vec3 v1 = vec3(x * yr1, y1, z * yr1);
|
||||||
vec3 v4 = vec3(x * zr0, y * zr0, z0);
|
vec3 v4 = vec3(x * yr0, y0, z * yr0);
|
||||||
|
|
||||||
lng = 2 * M_PI * float(jjj) / _longs;
|
lng = 2 * M_PI * float(jjj) / _longs;
|
||||||
x = cos(lng);
|
x = cos(lng);
|
||||||
y = sin(lng);
|
z = sin(lng);
|
||||||
vec3 v2 = vec3(x * zr1, y * zr1, z1);
|
vec3 v2 = vec3(x * yr1, y1, z * yr1);
|
||||||
vec3 v3 = vec3(x * zr0, y * zr0, z0);
|
vec3 v3 = vec3(x * yr0, y0, z * yr0);
|
||||||
|
|
||||||
out->addTriangle(_materialName, v1, v3, v2, _color);
|
out->addTriangle(_materialName, v1, v2, v3, _color);
|
||||||
out->addTriangle(_materialName, v1, v4, v3, _color);
|
out->addTriangle(_materialName, v1, v3, v4, _color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out->setNormalMode(ege::resource::Mesh::normalMode::face);
|
out->setNormalMode(ege::resource::Mesh::normalMode::face);
|
||||||
|
@ -54,6 +54,8 @@ def configure(target, my_module):
|
|||||||
'ege/resource/MeshCube.cpp',
|
'ege/resource/MeshCube.cpp',
|
||||||
'ege/resource/MeshSphere.cpp',
|
'ege/resource/MeshSphere.cpp',
|
||||||
'ege/resource/MeshCylinder.cpp',
|
'ege/resource/MeshCylinder.cpp',
|
||||||
|
'ege/resource/MeshCapsule.cpp',
|
||||||
|
'ege/resource/MeshCone.cpp',
|
||||||
'ege/resource/MeshObj.cpp',
|
'ege/resource/MeshObj.cpp',
|
||||||
'ege/resource/ParticuleMesh.cpp',
|
'ege/resource/ParticuleMesh.cpp',
|
||||||
'ege/resource/tools/icoSphere.cpp',
|
'ege/resource/tools/icoSphere.cpp',
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
#include <ege/Entity.hpp>
|
#include <ege/Entity.hpp>
|
||||||
#include <ege/physics/shape/Box.hpp>
|
#include <ege/physics/shape/Box.hpp>
|
||||||
#include <ege/physics/shape/Sphere.hpp>
|
#include <ege/physics/shape/Sphere.hpp>
|
||||||
|
#include <ege/physics/shape/Cylinder.hpp>
|
||||||
|
#include <ege/physics/shape/Capsule.hpp>
|
||||||
|
#include <ege/physics/shape/Cone.hpp>
|
||||||
#include <ege/position/Component.hpp>
|
#include <ege/position/Component.hpp>
|
||||||
#include <ege/render/Component.hpp>
|
#include <ege/render/Component.hpp>
|
||||||
#include <ege/physics/Component.hpp>
|
#include <ege/physics/Component.hpp>
|
||||||
@ -189,6 +192,75 @@ void appl::Windows::init() {
|
|||||||
// add it ..
|
// add it ..
|
||||||
m_env->addEntity(element);
|
m_env->addEntity(element);
|
||||||
}
|
}
|
||||||
|
myMesh = ege::resource::Mesh::createCylinder(4, 8, "basics", etk::color::blue);
|
||||||
|
if (myMesh != nullptr) {
|
||||||
|
ememory::SharedPtr<ege::Entity> element = ememory::makeShared<ege::Entity>(m_env);
|
||||||
|
// add all component:
|
||||||
|
// 1st Position component:
|
||||||
|
etk::Transform3D transform(vec3(20,10,10), etk::Quaternion::identity());
|
||||||
|
//ememory::SharedPtr<ege::position::Component> componentPosition = ememory::makeShared<ege::position::Component>(transform);
|
||||||
|
//element->addComponent(componentPosition);
|
||||||
|
// 2nd something to diplay:
|
||||||
|
ememory::SharedPtr<ege::render::Component> componentRender = ememory::makeShared<ege::render::Component>(myMesh);
|
||||||
|
element->addComponent(componentRender);
|
||||||
|
// 3rd some physic:
|
||||||
|
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
||||||
|
ememory::SharedPtr<ege::physics::shape::Cylinder> physic = ememory::makeShared<ege::physics::shape::Cylinder>();
|
||||||
|
physic->setRadius(4.01);
|
||||||
|
physic->setSize(8.01);
|
||||||
|
physic->setMass(500000);
|
||||||
|
componentPhysics->addShape(physic);
|
||||||
|
componentPhysics->generate();
|
||||||
|
element->addComponent(componentPhysics);
|
||||||
|
// add it ..
|
||||||
|
m_env->addEntity(element);
|
||||||
|
}
|
||||||
|
myMesh = ege::resource::Mesh::createCapsule(4, 8, "basics", etk::color::purple);
|
||||||
|
if (myMesh != nullptr) {
|
||||||
|
ememory::SharedPtr<ege::Entity> element = ememory::makeShared<ege::Entity>(m_env);
|
||||||
|
// add all component:
|
||||||
|
// 1st Position component:
|
||||||
|
etk::Transform3D transform(vec3(20,-10,-10), etk::Quaternion::identity());
|
||||||
|
//ememory::SharedPtr<ege::position::Component> componentPosition = ememory::makeShared<ege::position::Component>(transform);
|
||||||
|
//element->addComponent(componentPosition);
|
||||||
|
// 2nd something to diplay:
|
||||||
|
ememory::SharedPtr<ege::render::Component> componentRender = ememory::makeShared<ege::render::Component>(myMesh);
|
||||||
|
element->addComponent(componentRender);
|
||||||
|
// 3rd some physic:
|
||||||
|
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
||||||
|
ememory::SharedPtr<ege::physics::shape::Capsule> physic = ememory::makeShared<ege::physics::shape::Capsule>();
|
||||||
|
physic->setRadius(4.01);
|
||||||
|
physic->setSize(8.01);
|
||||||
|
physic->setMass(500000);
|
||||||
|
componentPhysics->addShape(physic);
|
||||||
|
componentPhysics->generate();
|
||||||
|
element->addComponent(componentPhysics);
|
||||||
|
// add it ..
|
||||||
|
m_env->addEntity(element);
|
||||||
|
}
|
||||||
|
myMesh = ege::resource::Mesh::createCone(4, 8, "basics", etk::color::purple);
|
||||||
|
if (myMesh != nullptr) {
|
||||||
|
ememory::SharedPtr<ege::Entity> element = ememory::makeShared<ege::Entity>(m_env);
|
||||||
|
// add all component:
|
||||||
|
// 1st Position component:
|
||||||
|
etk::Transform3D transform(vec3(20, 20,-10), etk::Quaternion::identity());
|
||||||
|
//ememory::SharedPtr<ege::position::Component> componentPosition = ememory::makeShared<ege::position::Component>(transform);
|
||||||
|
//element->addComponent(componentPosition);
|
||||||
|
// 2nd something to diplay:
|
||||||
|
ememory::SharedPtr<ege::render::Component> componentRender = ememory::makeShared<ege::render::Component>(myMesh);
|
||||||
|
element->addComponent(componentRender);
|
||||||
|
// 3rd some physic:
|
||||||
|
ememory::SharedPtr<ege::physics::Component> componentPhysics = ememory::makeShared<ege::physics::Component>(m_env, transform);
|
||||||
|
ememory::SharedPtr<ege::physics::shape::Cone> physic = ememory::makeShared<ege::physics::shape::Cone>();
|
||||||
|
physic->setRadius(4.01);
|
||||||
|
physic->setSize(8.01);
|
||||||
|
physic->setMass(500000);
|
||||||
|
componentPhysics->addShape(physic);
|
||||||
|
componentPhysics->generate();
|
||||||
|
element->addComponent(componentPhysics);
|
||||||
|
// add it ..
|
||||||
|
m_env->addEntity(element);
|
||||||
|
}
|
||||||
m_env->propertyStatus.set(ege::gameStart);
|
m_env->propertyStatus.set(ege::gameStart);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user