EPhysics: multi point deformation

This patch introduces support for multi point deformation mapping,
it's wrapped with an evas smart object to handle multiple slices.


Patch by: Leandro Dorileo <dorileo@profusion.mobi>



SVN revision: 77466
This commit is contained in:
Leandro Dorileo 2012-10-04 22:40:07 +00:00 committed by Bruno Dilly
parent da4c5234f2
commit 1cb8f6fc0c
5 changed files with 746 additions and 379 deletions

View File

@ -26,7 +26,33 @@ _world_populate(Test_Data *test_data)
evas_object_show(evas_obj);
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
fall_body = ephysics_body_circle_add(test_data->world);
fall_body = ephysics_body_soft_circle_add(test_data->world);
ephysics_body_soft_body_hardness_set(fall_body, 10);
ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
ephysics_body_restitution_set(fall_body, 0.95);
ephysics_body_friction_set(fall_body, 0.1);
ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
update_object_cb, shadow);
test_data->bodies = eina_list_append(test_data->bodies, fall_body);
shadow = elm_layout_add(test_data->win);
elm_layout_file_set(
shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
evas_object_move(shadow, 200, FLOOR_Y);
evas_object_resize(shadow, 70, 3);
evas_object_show(shadow);
test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
evas_obj = elm_image_add(test_data->win);
elm_image_file_set(evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
"big-blue-ball");
evas_object_move(evas_obj, 300, 100);
evas_object_resize(evas_obj, 70, 70);
evas_object_show(evas_obj);
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
fall_body = ephysics_body_soft_circle_add(test_data->world);
ephysics_body_soft_body_hardness_set(fall_body, 30);
ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
ephysics_body_restitution_set(fall_body, 0.95);
ephysics_body_friction_set(fall_body, 0.1);
@ -45,7 +71,7 @@ _world_populate(Test_Data *test_data)
evas_obj = elm_image_add(test_data->win);
elm_image_file_set(evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
"big-blue-ball");
evas_object_move(evas_obj, 100, 100);
evas_object_move(evas_obj, 200, 10);
evas_object_resize(evas_obj, 70, 70);
evas_object_show(evas_obj);
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
@ -76,12 +102,13 @@ _world_populate(Test_Data *test_data)
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
fall_body = ephysics_body_soft_box_add(test_data->world);
ephysics_body_soft_body_hardness_set(fall_body, 50);
ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
ephysics_body_soft_body_hardness_set(fall_body, 10);
evas_obj = ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
update_object_cb, shadow);
ephysics_body_restitution_set(fall_body, 0.5);
ephysics_body_friction_set(fall_body, 0.1);
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
test_data->bodies = eina_list_append(test_data->bodies, fall_body);
}
@ -113,6 +140,7 @@ test_soft_body(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
world = ephysics_world_new();
ephysics_world_simulation_set(world, 1/150.f, 5);
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
test_data->world = world;

View File

@ -1578,12 +1578,16 @@ EAPI EPhysics_Body *ephysics_body_circle_add(EPhysics_World *world);
* Just like rotation, deformation will be applied on associated
* evas object using evas map.
*
* @note When working with soft bodies it's importante to adjust the simulation's
* fixed time step due its multi point nature.
*
* For a rigid circle, check @ref ephysics_body_circle_add().
*
* @param world The world this body will belongs to.
* @return a new body or @c NULL, on errors.
*
* @see ephysics_body_del().
* @see ephysics_world_simulation_set().
*
* @ingroup EPhysics_Body
*/
@ -1619,6 +1623,9 @@ EAPI EPhysics_Body *ephysics_body_box_add(EPhysics_World *world);
* Just like rotation, deformation will be applied on associated
* evas object using evas map.
*
* @note When working with soft bodies it's importante to adjust the simulation's
* fixed time step due its multi point nature.
*
* For a rigid circle, check @ref ephysics_body_circle_add().
*
* @param world The world this body will belongs to.
@ -1626,6 +1633,7 @@ EAPI EPhysics_Body *ephysics_body_box_add(EPhysics_World *world);
*
* @see ephysics_body_del().
* @see ephysics_body_evas_object_set().
* @see ephysics_world_simulation_set().
*
* @ingroup EPhysics_Body
*/
@ -1768,19 +1776,27 @@ EAPI EPhysics_World *ephysics_body_world_get(const EPhysics_Body *body);
* updates of associated evas objects, or complement updates, like changing
* evas objects properties under certain conditions of position or rotation.
*
* Case @p body is a soft one a new evas_object will be returned, actually
* this is an smart object which maps many slices of @p evas_obj to reflect
* the soft body deformation.
*
* @param body The body to associate to an evas object.
* @param evas_obj The evas object that will be associated to this @p body.
* @param use_obj_pos If @c EINA_TRUE it will set the physics body position
* to match evas object position taking world rate on consideration.
* @return NULL on failure, @p evas_obj case @p body is a rigid body or a
* new Evas_Object if @p body is a soft body.
*
* @see ephysics_body_box_add().
* @see ephysics_body_soft_box_add().
* @see ephysics_body_circle_add().
* @see ephysics_body_soft_circle_add().
* @see ephysics_body_evas_object_unset().
* @see ephysics_world_rate_set().
*
* @ingroup EPhysics_Body
*/
EAPI void ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
EAPI Evas_Object *ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
/**
* @brief

View File

@ -32,6 +32,323 @@ struct _EPhysics_Body_Collision {
Evas_Coord y;
};
typedef struct _EPhysics_Body_Soft_Body_Slice
{
int index;
Evas_Object *evas_obj;
} EPhysics_Body_Soft_Body_Slice;
static const Evas_Smart_Cb_Description _smart_callbacks[] =
{
{"children,changed", "i"},
{NULL, NULL}
};
typedef struct _EPhysics_Body_Soft_Body_Smart_Data
{
Evas_Object_Smart_Clipped_Data base;
Evas_Object *base_obj;
EPhysics_Body *body;
Eina_List *slices;
} EPhysics_Body_Soft_Body_Smart_Data;
#define SMART_CLASS_NAME "EPhysics_Body_Soft_Body"
#define EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(o, ptr) \
ptr = (EPhysics_Body_Soft_Body_Smart_Data *) evas_object_smart_data_get(o) \
EVAS_SMART_SUBCLASS_NEW(SMART_CLASS_NAME,
_ephysics_body_soft_body_evas, Evas_Smart_Class,
Evas_Smart_Class, evas_object_smart_clipped_class_get,
_smart_callbacks);
static void
_ephysics_body_soft_body_slices_apply(Evas_Object *obj)
{
double rate;
void *data;
Eina_List *l;
Evas_Coord x, y, h, wy, wh, y0, y1, y2, x0, x1, x2;
Evas_Map *map;
btVector3 p0, p1, p2;
btSoftBody::tFaceArray faces;
EPhysics_Body_Soft_Body_Slice *slice;
EPhysics_Body_Soft_Body_Smart_Data *smart_data;
EPhysics_Body *body;
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
body = smart_data->body;
rate = ephysics_world_rate_get(body->world);
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, &wh);
EINA_LIST_FOREACH(smart_data->slices, l, data)
{
slice = (EPhysics_Body_Soft_Body_Slice *)data;
evas_object_geometry_get(slice->evas_obj, &x, &y, NULL, &h);
faces = body->soft_body->m_faces;
p0 = faces[slice->index].m_n[0]->m_x;
p1 = faces[slice->index].m_n[1]->m_x;
p2 = faces[slice->index].m_n[2]->m_x;
y0 = wh + wy - (p0.y() * rate);
y1 = wh + wy - (p1.y() * rate);
y2 = wh + wy - (p2.y() * rate);
x0 = p0.x() * rate;
x1 = p1.x() * rate;
x2 = p2.x() * rate;
evas_object_map_enable_set(slice->evas_obj, EINA_FALSE);
map = (Evas_Map *)evas_object_map_get((const Evas_Object *)
slice->evas_obj);
evas_object_image_smooth_scale_set(slice->evas_obj, EINA_TRUE);
evas_map_point_coord_set(map, 0, x0, y0, 0);
evas_map_point_coord_set(map, 1, x1, y1, 0);
evas_map_point_coord_set(map, 2, x2, y2, 0);
evas_map_point_coord_set(map, 3, x2, y2, 0);
evas_object_map_set(slice->evas_obj, map);
evas_object_map_enable_set(slice->evas_obj, EINA_TRUE);
}
}
static EPhysics_Body_Soft_Body_Slice *
_ephysics_body_soft_body_slice_new(int index, Evas_Object *evas_obj)
{
EPhysics_Body_Soft_Body_Slice *slice;
slice = (EPhysics_Body_Soft_Body_Slice *)malloc(
sizeof(EPhysics_Body_Soft_Body_Slice));
if (!slice)
{
ERR("Couldn't allocate EPhysics_Soft_Body_Slice memory.");
return NULL;
}
slice->index = index;
slice->evas_obj = evas_obj;
return slice;
}
static Eina_Bool
_ephysics_body_soft_body_slices_init(EPhysics_Body *body, Evas_Object *obj)
{
double rate;
Evas_Coord x, y, w, h, wy, wh, y0, y1, y2, x0, x1, x2;
Evas_Map *map;
Evas *evas;
EPhysics_Body_Soft_Body_Smart_Data *smart_data;
btSoftBody::tFaceArray faces;
EPhysics_Body_Soft_Body_Slice *slice;
btVector3 p0, p1, p2;
evas = evas_object_evas_get(body->evas_obj);
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, &wh);
rate = ephysics_world_rate_get(body->world);
for (int i = 0; i < body->slices; i++)
{
slice = _ephysics_body_soft_body_slice_new(body->points_deform[i],
evas_object_image_filled_add(evas));
if (!slice)
return EINA_FALSE;
evas_object_image_source_set(slice->evas_obj, smart_data->base_obj);
evas_object_geometry_get(smart_data->base_obj, &x, &y, &w, &h);
evas_object_resize(slice->evas_obj, w, h);
evas_object_move(slice->evas_obj, x, y);
evas_object_show(slice->evas_obj);
faces = body->soft_body->m_faces;
p0 = faces[slice->index].m_n[0]->m_x;
p1 = faces[slice->index].m_n[1]->m_x;
p2 = faces[slice->index].m_n[2]->m_x;
y0 = wh + wy - (p0.y() * rate);
y1 = wh + wy - (p1.y() * rate);
y2 = wh + wy - (p2.y() * rate);
x0 = p0.x() * rate;
x1 = p1.x() * rate;
x2 = p2.x() * rate;
map = evas_map_new(4);
evas_map_util_points_populate_from_object(map, slice->evas_obj);
evas_map_point_image_uv_set(map, 0, x0 - x, y0 - y);
evas_map_point_image_uv_set(map, 1, x1 - x, y1 - y);
evas_map_point_image_uv_set(map, 2, x2 - x, y2 - y);
evas_map_point_image_uv_set(map, 3, x2 - x, y2 - y);
evas_map_point_coord_set(map, 0, x0, y0, 0);
evas_map_point_coord_set(map, 1, x1, y1, 0);
evas_map_point_coord_set(map, 2, x2, y2, 0);
evas_map_point_coord_set(map, 3, x2, y2, 0);
evas_object_map_set(slice->evas_obj, map);
evas_object_map_enable_set(slice->evas_obj, EINA_TRUE);
evas_map_free(map);
smart_data->slices = eina_list_append(smart_data->slices, slice);
evas_object_smart_member_add(slice->evas_obj, obj);
}
return EINA_TRUE;
}
static void
_ephysics_body_soft_body_evas_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{
EPhysics_Body_Soft_Body_Smart_Data *smart_data;
Eina_List *l;
void *data;
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
EINA_LIST_FOREACH(smart_data->slices, l, data)
{
EPhysics_Body_Soft_Body_Slice *slice;
slice = (EPhysics_Body_Soft_Body_Slice *)data;
evas_object_move(slice->evas_obj, x, y);
}
_ephysics_body_soft_body_slices_apply(obj);
}
static void
_ephysics_body_soft_body_evas_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
{
EPhysics_Body_Soft_Body_Smart_Data *smart_data;
Eina_List *l;
void *data;
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
EINA_LIST_FOREACH(smart_data->slices, l, data)
{
EPhysics_Body_Soft_Body_Slice *slice;
slice = (EPhysics_Body_Soft_Body_Slice *)data;
evas_object_resize(slice->evas_obj, w, h);
}
_ephysics_body_soft_body_slices_apply(obj);
}
static void
_ephysics_body_soft_body_evas_smart_hide(Evas_Object *obj)
{
EPhysics_Body_Soft_Body_Smart_Data *smart_data;
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
evas_object_hide(smart_data->base_obj);
}
static void
_ephysics_body_soft_body_evas_smart_show(Evas_Object *obj)
{
EPhysics_Body_Soft_Body_Smart_Data *smart_data;
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
evas_object_show(smart_data->base_obj);
}
static void
_ephysics_body_soft_body_evas_smart_del(Evas_Object *obj)
{
EPhysics_Body_Soft_Body_Smart_Data *smart_data;
void *data;
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
EINA_LIST_FREE(smart_data->slices, data)
{
EPhysics_Body_Soft_Body_Slice *slice;
slice = (EPhysics_Body_Soft_Body_Slice *)data;
evas_object_del(slice->evas_obj);
free(slice);
}
_ephysics_body_soft_body_evas_parent_sc->del(obj);
}
static void
_ephysics_body_soft_body_evas_smart_calculate(Evas_Object *obj)
{
EPhysics_Body_Soft_Body_Smart_Data *smart_data;
Evas_Coord x, y, w, h;
Eina_List *l;
void *data;
evas_object_geometry_get(obj, &x, &y, &w, &h);
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
EINA_LIST_FOREACH(smart_data->slices, l, data)
{
EPhysics_Body_Soft_Body_Slice *slice;
slice = (EPhysics_Body_Soft_Body_Slice *)data;
evas_object_move(slice->evas_obj, x, y);
evas_object_resize(slice->evas_obj, w, h);
}
}
static void
_ephysics_body_soft_body_evas_smart_add(Evas_Object *obj)
{
EPhysics_Body_Soft_Body_Smart_Data *priv;
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, priv);
if (!priv) {
priv = (EPhysics_Body_Soft_Body_Smart_Data *)calloc(1,
sizeof(EPhysics_Body_Soft_Body_Smart_Data));
if (!priv) return;
evas_object_smart_data_set(obj, priv);
}
_ephysics_body_soft_body_evas_parent_sc->add(obj);
}
static void
_ephysics_body_soft_body_evas_smart_set_user(Evas_Smart_Class *sc)
{
sc->add = _ephysics_body_soft_body_evas_smart_add;
sc->move = _ephysics_body_soft_body_evas_smart_move;
sc->del = _ephysics_body_soft_body_evas_smart_del;
sc->resize = _ephysics_body_soft_body_evas_smart_resize;
sc->hide = _ephysics_body_soft_body_evas_smart_hide;
sc->show = _ephysics_body_soft_body_evas_smart_show;
sc->calculate = _ephysics_body_soft_body_evas_smart_calculate;
}
static Evas_Object *
_ephysics_body_soft_body_evas_add(EPhysics_Body *body)
{
EPhysics_Body_Soft_Body_Smart_Data *priv;
Evas *evas;
Evas_Object *obj;
Evas_Coord x, y, w, h;
evas = evas_object_evas_get(body->evas_obj);
obj = evas_object_smart_add(evas,
_ephysics_body_soft_body_evas_smart_class_new());
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, priv);
priv->base_obj = body->evas_obj;
priv->body = body;
evas_object_geometry_get(body->evas_obj, &x, &y, &w, &h);
evas_object_move(obj, x, y);
evas_object_resize(obj, w, h);
evas_object_show(obj);
if(!_ephysics_body_soft_body_slices_init(body, obj))
return NULL;
evas_object_move(priv->base_obj, 0, -h);
return obj;
}
static void
_ephysics_body_forces_update(EPhysics_Body *body)
{
@ -287,32 +604,6 @@ _ephysics_body_evas_obj_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj
DBG("Evas object deleted. Updating body: %p", body);
}
static void
_ephysics_body_soft_body_points_distance_get(const EPhysics_Body *body, double distances[4][3])
{
btVector3 center;
btScalar raius;
body->soft_body->getCollisionShape()->getBoundingSphere(center, raius);
for (int m = 0; m < 4; m++)
{
for (int n = 0; n < 3; n++)
{
btVector3 node;
double distance;
node = body->soft_body->
m_faces[body->points_deform[m][n]].m_n[1]->m_x;
distance = sqrt(pow(center.x() - node.x(), 2) +
pow(center.y() - node.y(), 2));
distances[m][n] = distance;
}
}
}
static void
_ephysics_body_soft_body_anchors_rebuild(int node, btRigidBody *rigid_body, btSoftBody *soft_body)
{
@ -345,7 +636,6 @@ _ephysics_body_soft_body_constraints_rebuild(EPhysics_Body *body)
soft_body->generateClusters(0);
soft_body->generateBendingConstraints(10, soft_body->m_materials[0]);
_ephysics_body_soft_body_points_distance_get(body, body->distances);
}
inline static double
@ -478,32 +768,6 @@ _ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Eva
DBG("Body %p scale changed to %lf, %lf.", body, sx, sy);
}
static void
_ephysics_body_soft_body_deform(EPhysics_Body *body, double rate, Evas_Map *map)
{
double curr_distances[4][3];
_ephysics_body_soft_body_points_distance_get(body, curr_distances);
for (int m = 0; m < 4; m++)
{
Evas_Coord px, py, pz;
double dx = 0, dy = 0;
evas_map_point_coord_get(map, m, &px, &py, &pz);
for (int n = 0; n < 3; n++)
{
double diff = (curr_distances[m][n] - body->distances[m][n]);
dx += diff;
dy += diff;
}
evas_map_point_coord_set(map, m, px - (dx * rate), py - (dy * rate),
pz);
}
}
static void
_ephysics_body_evas_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
@ -545,6 +809,8 @@ _ephysics_body_del(EPhysics_Body *body)
EINA_LIST_FREE(body->collision_groups, group)
eina_stringshare_del((Eina_Stringshare *)group);
free(body->points_deform);
delete body->rigid_body->getMotionState();
delete body->collision_shape;
delete body->rigid_body;
@ -587,15 +853,15 @@ _ephysics_body_evas_object_default_update(EPhysics_Body *body)
return;
}
if (body->soft_body)
return;
rot = - trans.getRotation().getAngle() * RAD_TO_DEG *
trans.getRotation().getAxis().getZ();
map = evas_map_new(4);
evas_map_util_points_populate_from_object(map, body->evas_obj);
if (body->soft_body)
_ephysics_body_soft_body_deform(body, rate, map);
evas_map_util_rotate(map, rot, x + (w * body->cm.x), y +
(h * body->cm.y));
evas_object_map_set(body->evas_obj, map);
@ -749,10 +1015,10 @@ static void
_ephysics_body_soft_body_hardness_set(EPhysics_Body *body, double hardness)
{
btSoftBody *soft_body = body->soft_body;
soft_body->m_cfg.kAHR = (hardness / 100) * 0.6;
soft_body->m_materials[0]->m_kVST = (hardness / 100);
soft_body->m_materials[0]->m_kLST = (hardness / 100);
soft_body->m_materials[0]->m_kAST = (hardness / 100);
soft_body->m_cfg.kAHR = (hardness / 1000) * 0.6;
soft_body->m_materials[0]->m_kVST = (hardness / 1000);
soft_body->m_materials[0]->m_kLST = (hardness / 1000);
soft_body->m_materials[0]->m_kAST = (hardness / 1000);
DBG("Soft body %p hardness set to %lf.", body, hardness);
}
@ -801,7 +1067,7 @@ ephysics_body_soft_body_hardness_get(const EPhysics_Body *body)
}
static EPhysics_Body *
_ephysics_body_soft_add(EPhysics_World *world, btCollisionShape *collision_shape, btSoftBody *soft_body)
_ephysics_body_soft_body_add(EPhysics_World *world, btCollisionShape *collision_shape, btSoftBody *soft_body)
{
EPhysics_Body *body;
@ -814,6 +1080,8 @@ _ephysics_body_soft_add(EPhysics_World *world, btCollisionShape *collision_shape
return NULL;
}
body->soft_body = soft_body;
body->soft_body->getCollisionShape()->setMargin(btScalar(0.02));
body->soft_body->setUserPointer(body);
body->soft_body->setTotalMass(body->mass);
@ -821,7 +1089,6 @@ _ephysics_body_soft_add(EPhysics_World *world, btCollisionShape *collision_shape
body->soft_body->m_cfg.collisions += btSoftBody::fCollision::VF_SS;
_ephysics_body_soft_body_hardness_set(body, 100);
body->rigid_body->setCollisionFlags(
btCollisionObject::CF_NO_CONTACT_RESPONSE);
@ -837,6 +1104,8 @@ ephysics_body_soft_circle_add(EPhysics_World *world)
btCollisionShape *shape;
btSoftBodyWorldInfo *world_info;
btSoftBody *soft_body;
int points[19] = {16, 58, 44, 79, 97, 35, 6, 27, 45, 1, 38, 18, 21, 10, 26,
7, 86, 37, 55};
if (!world)
{
@ -845,7 +1114,8 @@ ephysics_body_soft_circle_add(EPhysics_World *world)
}
ephysics_world_lock_take(world);
shape = new btCylinderShapeZ(btVector3(0.25, 0.25, 0.25));
shape = new btCylinderShapeZ(btVector3(0.5, 0.5, 0.5));
if (!shape)
{
ERR("Couldn't create a new cylinder shape.");
@ -862,25 +1132,20 @@ ephysics_body_soft_circle_add(EPhysics_World *world)
goto no_soft_body;
}
body = _ephysics_body_soft_add(world, shape, soft_body);
body = _ephysics_body_soft_body_add(world, shape, soft_body);
if (!body)
goto no_body;
body->points_deform[0][0] = 72;
body->points_deform[0][1] = 69;
body->points_deform[0][2] = 3;
body->slices = 19;
body->points_deform = (int *)malloc(body->slices * sizeof(int));
if (!body->points_deform)
{
ERR("Couldn't create points of deformation.");
goto no_deform;
}
body->points_deform[1][0] = 72;
body->points_deform[1][1] = 6;
body->points_deform[1][2] = 65;
body->points_deform[2][0] = 54;
body->points_deform[2][1] = 47;
body->points_deform[2][2] = 65;
body->points_deform[3][0] = 57;
body->points_deform[3][1] = 3;
body->points_deform[3][2] = 76;
for (int i = 0; i < body->slices; i++)
body->points_deform[i] = points[i];
ephysics_world_lock_release(world);
return body;
@ -889,6 +1154,8 @@ no_body:
delete soft_body;
no_soft_body:
delete shape;
no_deform:
ephysics_world_body_del(world, body);
no_collision_shape:
ephysics_world_lock_release(world);
return NULL;
@ -926,6 +1193,9 @@ ephysics_body_soft_box_add(EPhysics_World *world)
btCollisionShape *shape;
btSoftBodyWorldInfo *world_info;
btSoftBody *soft_body;
int points[16] = {14, 85, 88, 28, 41, 55, 10, 24, 93, 79, 56, 86, 91, 8,
27, 1};
if (!world)
{
@ -951,25 +1221,20 @@ ephysics_body_soft_box_add(EPhysics_World *world)
goto no_soft_body;
}
body = _ephysics_body_soft_add(world, shape, soft_body);
body = _ephysics_body_soft_body_add(world, shape, soft_body);
if (!body)
goto no_body;
body->points_deform[0][0] = 85;
body->points_deform[0][1] = 12;
body->points_deform[0][2] = 30;
body->slices = 16;
body->points_deform = (int *)malloc(body->slices * sizeof(int));
if (!body->points_deform)
{
ERR("Couldn't create points of deformation.");
goto no_deform;
}
body->points_deform[1][0] = 27;
body->points_deform[1][1] = 80;
body->points_deform[1][2] = 69;
body->points_deform[2][0] = 50;
body->points_deform[2][1] = 40;
body->points_deform[2][2] = 60;
body->points_deform[3][0] = 18;
body->points_deform[3][1] = 62;
body->points_deform[3][2] = 8;
for (int i = 0; i < body->slices; i++)
body->points_deform[i] = points[i];
ephysics_world_lock_release(world);
return body;
@ -978,6 +1243,8 @@ no_body:
delete soft_body;
no_soft_body:
delete shape;
no_deform:
ephysics_world_body_del(world, body);
no_collision_shape:
ephysics_world_lock_release(world);
return NULL;
@ -1244,7 +1511,7 @@ ephysics_body_del(EPhysics_Body *body)
ephysics_world_lock_release(body->world);
}
EAPI void
EAPI Evas_Object *
ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
{
int obj_x, obj_y, obj_w, obj_h;
@ -1252,13 +1519,13 @@ ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_B
if (!body)
{
ERR("Can't set evas object to body, the last wasn't provided.");
return;
return NULL;
}
if (!evas_obj)
{
ERR("Can't set evas object to body, the first wasn't provided.");
return;
return NULL;
}
if (body->evas_obj)
@ -1271,19 +1538,32 @@ ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_B
body->evas_obj = evas_obj;
evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_DEL,
_ephysics_body_evas_obj_del_cb, body);
if (!use_obj_pos)
return;
return evas_obj;
evas_object_geometry_get(body->evas_obj, &obj_x, &obj_y, &obj_w, &obj_h);
ephysics_world_lock_take(body->world);
_ephysics_body_geometry_set(body, obj_x, obj_y, obj_w, obj_h,
ephysics_world_rate_get(body->world));
if (body->soft_body)
{
body->evas_obj = _ephysics_body_soft_body_evas_add(body);
evas_object_event_callback_del(evas_obj, EVAS_CALLBACK_DEL,
_ephysics_body_evas_obj_del_cb);
evas_object_event_callback_add(body->evas_obj, EVAS_CALLBACK_DEL,
_ephysics_body_evas_obj_del_cb, body);
}
ephysics_world_lock_release(body->world);
evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_RESIZE,
evas_object_event_callback_add(body->evas_obj, EVAS_CALLBACK_RESIZE,
_ephysics_body_evas_obj_resize_cb, body);
return evas_obj;
}
EAPI Evas_Object *

View File

@ -93,8 +93,8 @@ struct _EPhysics_Body {
} cm;
Eina_Bool active:1;
Eina_Bool deleted:1;
double distances[4][3];
int points_deform[4][3];
int slices;
int *points_deform;
};
extern int _ephysics_log_dom;

View File

@ -1,292 +1,335 @@
#ifndef EPHYSICS_TRIMESH_H
#define EPHYSICS_TRIMESH_H
#define CYLINDER_NUM_VERTICES 46
#define CYLINDER_NUM_TRIANGLES 80
#define CYLINDER_NUM_VERTICES 58
#define CYLINDER_NUM_TRIANGLES 104
static btScalar cylinder_vertices[CYLINDER_NUM_VERTICES * 3] = {
btScalar(0.378791), btScalar(-0.156900), btScalar(0.410000),
btScalar(0.381661), btScalar(0.142468), btScalar(0.410000),
btScalar(0.205276), btScalar(0.346467), btScalar(0.410000),
btScalar(-0.062845), btScalar(0.397499), btScalar(0.410000),
btScalar(-0.312196), btScalar(0.256566), btScalar(0.410000),
btScalar(-0.409345), btScalar(0.003295), btScalar(0.410000),
btScalar(-0.315929), btScalar(-0.250980), btScalar(0.410000),
btScalar(-0.085737), btScalar(-0.392946), btScalar(0.410000),
btScalar(0.181088), btScalar(-0.362629), btScalar(0.410000),
btScalar(0.378791), btScalar(-0.156900), btScalar(-0.410000),
btScalar(0.183474), btScalar(-0.361035), btScalar(-0.410000),
btScalar(-0.085737), btScalar(-0.392946), btScalar(-0.410000),
btScalar(-0.315929), btScalar(-0.250980), btScalar(-0.410000),
btScalar(-0.409345), btScalar(0.003295), btScalar(-0.410000),
btScalar(-0.312196), btScalar(0.256566), btScalar(-0.410000),
btScalar(-0.062845), btScalar(0.397499), btScalar(-0.410000),
btScalar(0.204218), btScalar(0.347174), btScalar(-0.410000),
btScalar(0.381661), btScalar(0.142468), btScalar(-0.410000),
btScalar(0.197462), btScalar(0.068348), btScalar(0.410000),
btScalar(-0.036961), btScalar(0.150675), btScalar(0.410000),
btScalar(0.067713), btScalar(-0.147128), btScalar(0.410000),
btScalar(-0.178972), btScalar(-0.060078), btScalar(0.410000),
btScalar(0.120907), btScalar(-0.105917), btScalar(-0.410000),
btScalar(-0.151098), btScalar(-0.043779), btScalar(-0.410000),
btScalar(0.039171), btScalar(0.161620), btScalar(-0.410000),
btScalar(0.311630), btScalar(-0.257414), btScalar(0.203297),
btScalar(-0.392051), btScalar(0.090235), btScalar(0.134737),
btScalar(-0.360756), btScalar(-0.183891), btScalar(0.144512),
btScalar(-0.141439), btScalar(-0.381866), btScalar(0.155320),
btScalar(0.110283), btScalar(-0.388063), btScalar(0.161516),
btScalar(0.320615), btScalar(-0.243966), btScalar(-0.082931),
btScalar(0.043971), btScalar(-0.401254), btScalar(-0.106715),
btScalar(-0.237476), btScalar(-0.324952), btScalar(-0.131440),
btScalar(-0.392954), btScalar(-0.085698), btScalar(-0.130760),
btScalar(-0.355705), btScalar(0.191451), btScalar(-0.132884),
btScalar(-0.115651), btScalar(0.386996), btScalar(-0.130213),
btScalar(0.169937), btScalar(0.370080), btScalar(-0.151207),
btScalar(0.388128), btScalar(0.109959), btScalar(-0.173023),
btScalar(0.401935), btScalar(-0.040547), btScalar(0.142301),
btScalar(0.319544), btScalar(0.245570), btScalar(0.129082),
btScalar(0.058047), btScalar(0.398454), btScalar(0.125903),
btScalar(-0.223604), btScalar(0.334221), btScalar(0.131019),
btScalar(-0.118588), btScalar(-0.126284), btScalar(-0.116393),
btScalar(0.107303), btScalar(0.062176), btScalar(0.066999),
btScalar(-0.052534), btScalar(0.162121), btScalar(-0.154024),
btScalar(-0.027084), btScalar(-0.147475), btScalar(0.173698),
btScalar(0.508134), btScalar(-0.210476), btScalar(0.550000),
btScalar(0.530611), btScalar(0.097476), btScalar(0.550000),
btScalar(0.406474), btScalar(0.362621), btScalar(0.550000),
btScalar(0.165687), btScalar(0.517043), btScalar(0.550000),
btScalar(-0.145614), btScalar(0.521036), btScalar(0.550000),
btScalar(-0.405485), btScalar(0.364100), btScalar(0.550000),
btScalar(-0.536816), btScalar(0.066283), btScalar(0.550000),
btScalar(-0.491202), btScalar(-0.235817), btScalar(0.550000),
btScalar(-0.289243), btScalar(-0.455503), btScalar(0.550000),
btScalar(0.018444), btScalar(-0.546331), btScalar(0.550000),
btScalar(0.321449), btScalar(-0.433984), btScalar(0.550000),
btScalar(0.508134), btScalar(-0.210476), btScalar(-0.550000),
btScalar(0.321449), btScalar(-0.433984), btScalar(-0.550000),
btScalar(0.023871), btScalar(-0.545252), btScalar(-0.550000),
btScalar(-0.289243), btScalar(-0.455503), btScalar(-0.550000),
btScalar(-0.490465), btScalar(-0.236920), btScalar(-0.550000),
btScalar(-0.537432), btScalar(0.063186), btScalar(-0.550000),
btScalar(-0.407240), btScalar(0.361475), btScalar(-0.550000),
btScalar(-0.145614), btScalar(0.521036), btScalar(-0.550000),
btScalar(0.162590), btScalar(0.517659), btScalar(-0.550000),
btScalar(0.405750), btScalar(0.363704), btScalar(-0.550000),
btScalar(0.529995), btScalar(0.100572), btScalar(-0.550000),
btScalar(0.225162), btScalar(-0.126432), btScalar(0.550000),
btScalar(0.182505), btScalar(0.180319), btScalar(0.550000),
btScalar(-0.135548), btScalar(0.257663), btScalar(0.550000),
btScalar(-0.128146), btScalar(-0.029182), btScalar(0.550000),
btScalar(-0.047689), btScalar(-0.299859), btScalar(0.550000),
btScalar(0.192370), btScalar(-0.050817), btScalar(-0.550000),
btScalar(-0.080199), btScalar(-0.257948), btScalar(-0.550000),
btScalar(-0.229392), btScalar(0.019540), btScalar(-0.550000),
btScalar(-0.034804), btScalar(0.258372), btScalar(-0.550000),
btScalar(0.241500), btScalar(0.226175), btScalar(-0.550000),
btScalar(0.532902), btScalar(-0.085955), btScalar(0.216643),
btScalar(0.483467), btScalar(0.247392), btScalar(0.234226),
btScalar(0.278528), btScalar(0.462663), btScalar(0.218255),
btScalar(-0.041739), btScalar(0.541698), btScalar(0.182347),
btScalar(-0.330369), btScalar(0.428024), btScalar(0.180626),
btScalar(-0.518580), btScalar(0.157959), btScalar(0.172947),
btScalar(-0.521671), btScalar(-0.142420), btScalar(0.183206),
btScalar(-0.340102), btScalar(-0.421520), btScalar(0.186658),
btScalar(-0.046556), btScalar(-0.540740), btScalar(0.196846),
btScalar(0.325206), btScalar(-0.431473), btScalar(0.238916),
btScalar(0.479824), btScalar(-0.252844), btScalar(-0.162453),
btScalar(0.184507), btScalar(-0.513299), btScalar(-0.136220),
btScalar(-0.159624), btScalar(-0.518249), btScalar(-0.150107),
btScalar(-0.426985), btScalar(-0.331923), btScalar(-0.168222),
btScalar(-0.541617), btScalar(-0.042144), btScalar(-0.168426),
btScalar(-0.470990), btScalar(0.266065), btScalar(-0.185909),
btScalar(-0.239361), btScalar(0.488834), btScalar(-0.187932),
btScalar(0.134846), btScalar(0.523178), btScalar(-0.152636),
btScalar(0.397364), btScalar(0.376254), btScalar(-0.269892),
btScalar(0.531212), btScalar(0.094456), btScalar(-0.324493),
btScalar(0.382010), btScalar(0.393518), btScalar(-0.011940),
btScalar(0.523986), btScalar(0.130780), btScalar(-0.048009),
btScalar(0.041379), btScalar(-0.196807), btScalar(0.054210),
btScalar(0.013146), btScalar(0.357496), btScalar(0.024686),
btScalar(-0.047077), btScalar(0.119424), btScalar(-0.167934),
btScalar(0.055271), btScalar(0.158920), btScalar(0.227414),
};
static int cylinder_indices[CYLINDER_NUM_TRIANGLES][3] = {
{0, 1, 18},
{1, 2, 18},
{2, 3, 19},
{18, 2, 19},
{3, 4, 19},
{8, 0, 20},
{7, 8, 20},
{0, 18, 20},
{4, 5, 21},
{19, 4, 21},
{5, 6, 21},
{6, 7, 21},
{7, 20, 21},
{18, 19, 20},
{20, 19, 21},
{9, 10, 22},
{10, 11, 22},
{11, 12, 23},
{22, 11, 23},
{12, 13, 23},
{17, 9, 22},
{13, 14, 23},
{14, 15, 24},
{23, 14, 24},
{15, 16, 24},
{16, 17, 24},
{17, 22, 24},
{23, 24, 22},
{0, 8, 25},
{5, 4, 26},
{6, 5, 27},
{5, 26, 27},
{7, 6, 28},
{6, 27, 28},
{8, 7, 29},
{25, 8, 29},
{7, 28, 29},
{10, 9, 30},
{11, 10, 31},
{10, 30, 31},
{12, 11, 32},
{11, 31, 32},
{13, 12, 33},
{12, 32, 33},
{14, 13, 34},
{13, 33, 34},
{15, 14, 35},
{14, 34, 35},
{16, 15, 36},
{15, 35, 36},
{17, 16, 37},
{16, 36, 37},
{1, 0, 38},
{2, 1, 39},
{3, 2, 40},
{4, 3, 41},
{26, 4, 41},
{3, 40, 41},
{1, 38, 39},
{17, 37, 9},
{38, 0, 25},
{30, 9, 37},
{40, 2, 39},
{39, 38, 37},
{28, 27, 32},
{31, 30, 29},
{32, 31, 28},
{33, 32, 27},
{34, 33, 26},
{36, 35, 40},
{37, 36, 39},
{30, 37, 38},
{34, 26, 41},
{27, 26, 33},
{40, 39, 36},
{28, 31, 29},
{40, 35, 41},
{30, 38, 25},
{25, 29, 30},
{41, 35, 34},
{0, 1, 22},
{1, 2, 23},
{22, 1, 23},
{2, 3, 23},
{3, 4, 24},
{23, 3, 24},
{4, 5, 24},
{10, 0, 22},
{25, 24, 6},
{5, 6, 24},
{6, 7, 25},
{7, 8, 26},
{25, 7, 26},
{8, 9, 26},
{22, 26, 10},
{9, 10, 26},
{26, 22, 25},
{22, 23, 25},
{23, 24, 25},
{11, 12, 27},
{13, 28, 12},
{13, 14, 28},
{27, 12, 28},
{14, 15, 28},
{15, 16, 29},
{28, 15, 29},
{16, 17, 29},
{21, 11, 27},
{17, 18, 30},
{29, 17, 30},
{18, 19, 30},
{19, 20, 31},
{30, 19, 31},
{20, 21, 31},
{31, 21, 27},
{30, 31, 27},
{28, 29, 27},
{30, 27, 29},
{1, 0, 32},
{2, 1, 33},
{1, 32, 33},
{3, 2, 34},
{2, 33, 34},
{4, 3, 35},
{3, 34, 35},
{5, 4, 36},
{4, 35, 36},
{6, 5, 37},
{5, 36, 37},
{7, 6, 38},
{6, 37, 38},
{8, 7, 39},
{7, 38, 39},
{9, 8, 40},
{8, 39, 40},
{10, 9, 41},
{9, 40, 41},
{12, 11, 42},
{13, 12, 43},
{12, 42, 43},
{14, 13, 44},
{13, 43, 44},
{15, 14, 45},
{14, 44, 45},
{16, 15, 46},
{15, 45, 46},
{17, 16, 47},
{16, 46, 47},
{18, 17, 48},
{17, 47, 48},
{19, 18, 49},
{18, 48, 49},
{20, 19, 50},
{19, 49, 50},
{21, 20, 51},
{20, 50, 51},
{10, 41, 0},
{21, 51, 11},
{0, 41, 32},
{11, 51, 42},
{34, 33, 52},
{35, 34, 49},
{36, 35, 48},
{37, 36, 47},
{38, 37, 46},
{39, 38, 45},
{40, 39, 44},
{41, 40, 43},
{48, 35, 49},
{44, 43, 40},
{45, 44, 39},
{46, 45, 38},
{47, 46, 37},
{48, 47, 36},
{50, 49, 52},
{51, 50, 53},
{50, 52, 53},
{33, 32, 53},
{43, 42, 41},
{41, 42, 32},
{52, 49, 34},
{33, 53, 52},
{32, 42, 53},
{42, 51, 53},
};
#define CUBE_NUM_VERTICES 54
#define CUBE_NUM_TRIANGLES 90
#define CUBE_NUM_VERTICES 61
#define CUBE_NUM_TRIANGLES 96
static btScalar cube_vertices[CUBE_NUM_VERTICES * 3] = {
btScalar(0.400000), btScalar(-0.400000), btScalar(-0.400000),
btScalar(0.400000), btScalar(-0.400000), btScalar(-0.129695),
btScalar(0.400000), btScalar(-0.400000), btScalar(0.157468),
btScalar(0.400000), btScalar(-0.400000), btScalar(0.400000),
btScalar(-0.400000), btScalar(-0.400000), btScalar(-0.400000),
btScalar(-0.137266), btScalar(-0.400000), btScalar(-0.400000),
btScalar(0.142832), btScalar(-0.400000), btScalar(-0.400000),
btScalar(-0.400000), btScalar(-0.400000), btScalar(0.400000),
btScalar(-0.400000), btScalar(-0.400000), btScalar(0.144537),
btScalar(-0.400000), btScalar(-0.400000), btScalar(-0.132810),
btScalar(0.147946), btScalar(-0.400000), btScalar(0.400000),
btScalar(-0.127038), btScalar(-0.400000), btScalar(0.400000),
btScalar(0.400000), btScalar(-0.156914), btScalar(-0.400000),
btScalar(0.400000), btScalar(0.110878), btScalar(-0.400000),
btScalar(0.400000), btScalar(0.400000), btScalar(-0.400000),
btScalar(0.400000), btScalar(0.400000), btScalar(0.400000),
btScalar(0.400000), btScalar(0.143565), btScalar(0.400000),
btScalar(0.400000), btScalar(-0.142881), btScalar(0.400000),
btScalar(0.400000), btScalar(0.400000), btScalar(-0.142285),
btScalar(0.400000), btScalar(0.400000), btScalar(0.142285),
btScalar(-0.400000), btScalar(-0.155504), btScalar(-0.400000),
btScalar(-0.400000), btScalar(0.143304), btScalar(-0.400000),
btScalar(-0.400000), btScalar(0.400000), btScalar(-0.400000),
btScalar(-0.137266), btScalar(0.400000), btScalar(-0.400000),
btScalar(0.142832), btScalar(0.400000), btScalar(-0.400000),
btScalar(-0.400000), btScalar(0.400000), btScalar(0.400000),
btScalar(-0.400000), btScalar(0.123157), btScalar(0.400000),
btScalar(-0.400000), btScalar(-0.151643), btScalar(0.400000),
btScalar(0.147946), btScalar(0.400000), btScalar(0.400000),
btScalar(-0.127038), btScalar(0.400000), btScalar(0.400000),
btScalar(-0.400000), btScalar(0.400000), btScalar(-0.145673),
btScalar(-0.400000), btScalar(0.400000), btScalar(0.145673),
btScalar(0.149457), btScalar(-0.400000), btScalar(0.029476),
btScalar(-0.118651), btScalar(-0.400000), btScalar(-0.091520),
btScalar(-0.116729), btScalar(-0.400000), btScalar(0.185444),
btScalar(0.400000), btScalar(-0.030750), btScalar(0.108353),
btScalar(0.400000), btScalar(-0.017128), btScalar(-0.173998),
btScalar(-0.098445), btScalar(-0.123516), btScalar(-0.400000),
btScalar(0.189421), btScalar(-0.129196), btScalar(-0.400000),
btScalar(0.028300), btScalar(0.131810), btScalar(-0.400000),
btScalar(-0.121334), btScalar(-0.101441), btScalar(0.400000),
btScalar(0.149876), btScalar(0.018849), btScalar(0.400000),
btScalar(-0.114236), btScalar(0.180350), btScalar(0.400000),
btScalar(0.140128), btScalar(0.400000), btScalar(0.051515),
btScalar(-0.119461), btScalar(0.400000), btScalar(-0.055704),
btScalar(-0.400000), btScalar(-0.140426), btScalar(-0.044838),
btScalar(-0.400000), btScalar(0.123997), btScalar(0.045044),
btScalar(-0.157858), btScalar(-0.190293), btScalar(0.146609),
btScalar(0.104141), btScalar(-0.199541), btScalar(0.222140),
btScalar(-0.207788), btScalar(0.065226), btScalar(0.172945),
btScalar(0.103299), btScalar(-0.168979), btScalar(-0.094225),
btScalar(0.130475), btScalar(0.068676), btScalar(-0.129420),
btScalar(0.065630), btScalar(0.075409), btScalar(0.150963),
btScalar(-0.172328), btScalar(0.041173), btScalar(-0.142551),
btScalar(0.550000), btScalar(-0.550000), btScalar(-0.550000),
btScalar(0.550000), btScalar(-0.550000), btScalar(-0.215571),
btScalar(0.550000), btScalar(-0.550000), btScalar(0.149207),
btScalar(0.550000), btScalar(-0.550000), btScalar(0.550000),
btScalar(-0.550000), btScalar(-0.550000), btScalar(-0.550000),
btScalar(-0.215767), btScalar(-0.550000), btScalar(-0.550000),
btScalar(0.178583), btScalar(-0.550000), btScalar(-0.550000),
btScalar(-0.550000), btScalar(-0.550000), btScalar(0.550000),
btScalar(-0.550000), btScalar(-0.550000), btScalar(0.205306),
btScalar(-0.550000), btScalar(-0.550000), btScalar(-0.180403),
btScalar(0.213790), btScalar(-0.550000), btScalar(0.550000),
btScalar(-0.152594), btScalar(-0.550000), btScalar(0.550000),
btScalar(0.550000), btScalar(-0.171346), btScalar(-0.550000),
btScalar(0.550000), btScalar(0.218404), btScalar(-0.550000),
btScalar(0.550000), btScalar(0.550000), btScalar(-0.550000),
btScalar(0.550000), btScalar(0.550000), btScalar(0.550000),
btScalar(0.550000), btScalar(0.216178), btScalar(0.550000),
btScalar(0.550000), btScalar(-0.168604), btScalar(0.550000),
btScalar(0.550000), btScalar(0.550000), btScalar(-0.230974),
btScalar(0.550000), btScalar(0.550000), btScalar(0.154825),
btScalar(-0.550000), btScalar(-0.201191), btScalar(-0.550000),
btScalar(-0.550000), btScalar(0.180873), btScalar(-0.550000),
btScalar(-0.550000), btScalar(0.550000), btScalar(-0.550000),
btScalar(-0.167045), btScalar(0.550000), btScalar(-0.550000),
btScalar(0.207428), btScalar(0.550000), btScalar(-0.550000),
btScalar(-0.550000), btScalar(0.550000), btScalar(0.550000),
btScalar(-0.550000), btScalar(0.235945), btScalar(0.550000),
btScalar(-0.550000), btScalar(-0.152540), btScalar(0.550000),
btScalar(0.202185), btScalar(0.550000), btScalar(0.550000),
btScalar(-0.178486), btScalar(0.550000), btScalar(0.550000),
btScalar(-0.550000), btScalar(0.550000), btScalar(-0.200119),
btScalar(-0.550000), btScalar(0.550000), btScalar(0.178238),
btScalar(0.183518), btScalar(-0.550000), btScalar(-0.048608),
btScalar(-0.193942), btScalar(-0.550000), btScalar(-0.265714),
btScalar(-0.176127), btScalar(-0.550000), btScalar(0.121548),
btScalar(0.550000), btScalar(-0.228480), btScalar(-0.211018),
btScalar(0.550000), btScalar(0.115197), btScalar(-0.269727),
btScalar(0.550000), btScalar(0.087351), btScalar(0.133224),
btScalar(0.019637), btScalar(-0.192951), btScalar(-0.550000),
btScalar(0.260210), btScalar(0.183806), btScalar(-0.550000),
btScalar(-0.127158), btScalar(0.171482), btScalar(-0.550000),
btScalar(-0.144513), btScalar(-0.112619), btScalar(0.550000),
btScalar(0.201326), btScalar(0.040933), btScalar(0.550000),
btScalar(-0.167096), btScalar(0.273800), btScalar(0.550000),
btScalar(0.207212), btScalar(0.550000), btScalar(-0.049764),
btScalar(-0.148416), btScalar(0.550000), btScalar(-0.261736),
btScalar(-0.150781), btScalar(0.550000), btScalar(0.120466),
btScalar(-0.550000), btScalar(-0.243131), btScalar(0.177642),
btScalar(-0.550000), btScalar(-0.017683), btScalar(-0.199324),
btScalar(-0.550000), btScalar(0.150767), btScalar(0.162842),
btScalar(-0.138413), btScalar(-0.072881), btScalar(-0.103734),
btScalar(0.139934), btScalar(0.152037), btScalar(-0.158703),
btScalar(0.254965), btScalar(-0.254145), btScalar(-0.307055),
btScalar(0.228935), btScalar(-0.176885), btScalar(0.123000),
btScalar(0.115739), btScalar(0.220857), btScalar(0.251735),
};
static int cube_indices[CUBE_NUM_TRIANGLES][3] = {
{0, 1, 6},
{1, 2, 32},
{2, 3, 10},
{4, 5, 9},
{5, 6, 33},
{9, 5, 33},
{8, 34, 7},
{8, 9, 33},
{10, 11, 34},
{11, 7, 34},
{2, 10, 32},
{6, 1, 32},
{34, 8, 33},
{6, 32, 33},
{10, 34, 32},
{32, 34, 33},
{36, 1, 12},
{2, 1, 35},
{3, 2, 17},
{12, 13, 36},
{13, 14, 18},
{15, 16, 19},
{19, 16, 35},
{16, 17, 35},
{18, 19, 35},
{17, 2, 35},
{0, 12, 1},
{13, 18, 36},
{35, 1, 36},
{36, 18, 35},
{6, 38, 0},
{5, 4, 20},
{6, 5, 37},
{5, 20, 37},
{13, 12, 38},
{14, 13, 24},
{20, 21, 37},
{21, 22, 23},
{23, 24, 39},
{21, 23, 39},
{24, 13, 39},
{12, 0, 38},
{13, 38, 39},
{37, 21, 39},
{39, 38, 37},
{6, 37, 38},
{10, 3, 17},
{7, 11, 27},
{27, 11, 40},
{11, 10, 40},
{16, 15, 28},
{17, 16, 41},
{26, 42, 25},
{26, 27, 40},
{28, 29, 42},
{29, 25, 42},
{16, 28, 41},
{10, 17, 41},
{10, 41, 40},
{26, 40, 42},
{42, 40, 41},
{28, 42, 41},
{18, 14, 24},
{15, 19, 28},
{19, 18, 43},
{28, 19, 43},
{23, 22, 30},
{24, 23, 44},
{25, 29, 31},
{29, 28, 43},
{23, 30, 44},
{44, 30, 31},
{43, 44, 29},
{18, 24, 43},
{31, 29, 44},
{24, 44, 43},
{4, 9, 20},
{8, 7, 27},
{9, 8, 45},
{8, 27, 45},
{22, 21, 30},
{26, 25, 31},
{26, 31, 46},
{27, 26, 46},
{31, 30, 46},
{20, 9, 45},
{30, 21, 46},
{45, 27, 46},
{46, 21, 45},
{21, 20, 45},
{0, 1, 6},
{1, 2, 32},
{2, 3, 10},
{5, 33, 4},
{5, 6, 33},
{9, 4, 33},
{7, 8, 11},
{8, 9, 34},
{11, 8, 34},
{9, 33, 34},
{10, 11, 34},
{2, 10, 32},
{6, 1, 32},
{6, 32, 33},
{33, 32, 34},
{34, 32, 10},
{12, 35, 0},
{2, 1, 35},
{3, 2, 17},
{12, 13, 36},
{36, 13, 18},
{15, 16, 19},
{19, 16, 37},
{16, 17, 37},
{18, 19, 37},
{17, 2, 37},
{14, 18, 13},
{1, 0, 35},
{35, 12, 36},
{18, 37, 36},
{35, 36, 37},
{2, 35, 37},
{0, 6, 12},
{5, 4, 20},
{6, 5, 38},
{5, 20, 38},
{13, 12, 39},
{13, 39, 14},
{21, 40, 20},
{21, 22, 23},
{23, 24, 40},
{21, 23, 40},
{24, 14, 39},
{12, 6, 38},
{38, 20, 40},
{38, 40, 39},
{40, 24, 39},
{12, 38, 39},
{10, 3, 17},
{7, 11, 27},
{27, 11, 41},
{11, 10, 41},
{16, 15, 28},
{17, 16, 42},
{26, 43, 25},
{26, 27, 41},
{28, 29, 43},
{16, 28, 42},
{41, 43, 26},
{10, 17, 42},
{41, 10, 42},
{28, 43, 42},
{41, 42, 43},
{29, 25, 43},
{18, 14, 24},
{15, 19, 28},
{19, 18, 44},
{28, 19, 44},
{30, 45, 22},
{24, 23, 45},
{25, 29, 31},
{29, 28, 46},
{31, 29, 46},
{28, 44, 46},
{30, 31, 46},
{23, 22, 45},
{18, 24, 44},
{30, 46, 45},
{45, 46, 44},
{44, 24, 45},
{4, 9, 20},
{27, 47, 7},
{9, 8, 47},
{8, 7, 47},
{21, 20, 48},
{22, 21, 30},
{26, 25, 31},
{26, 31, 49},
{27, 26, 49},
{31, 30, 49},
{30, 21, 48},
{47, 27, 49},
{20, 9, 48},
{30, 48, 49},
{47, 49, 48},
{9, 47, 48},
};
#endif