ephysics: apply perspective and back face culling on

soft body




SVN revision: 78478
This commit is contained in:
Bruno Dilly 2012-10-25 21:53:37 +00:00
parent 98d327c3b6
commit 03c52724db
2 changed files with 27 additions and 0 deletions

View File

@ -158,6 +158,8 @@ test_flag(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info _
ephysics_world_light_set(world, 300, 50, -200, 255, 255, 255, 0, 0, 0);
ephysics_world_light_all_bodies_set(world, EINA_TRUE);
ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
EINA_TRUE);
boundary = ephysics_body_bottom_boundary_add(test_data->world);
ephysics_body_restitution_set(boundary, 0.65);

View File

@ -78,10 +78,14 @@ _ephysics_body_soft_body_slices_apply(void *data __UNUSED__, Evas *e __UNUSED__,
int lr, lg, lb, ar, ag, ab;
Evas_Coord lx, ly, lz;
Eina_Bool light = EINA_FALSE;
EPhysics_Camera *camera;
int px, py, pz, foc;
Eina_Bool perspective = EINA_FALSE;
soft_data = (EPhysics_Body_Soft_Body_Data *)evas_object_data_get(obj,
SOFT_DATA);
body = soft_data->body;
camera = ephysics_world_camera_get(body->world);
rate = ephysics_world_rate_get(body->world);
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, NULL, &wh,
@ -96,6 +100,12 @@ _ephysics_body_soft_body_slices_apply(void *data __UNUSED__, Evas *e __UNUSED__,
light = EINA_TRUE;
}
if (ephysics_camera_perspective_enabled_get(camera))
{
ephysics_camera_perspective_get(camera, &px, &py, &pz, &foc);
perspective = EINA_TRUE;
}
EINA_LIST_FOREACH(soft_data->slices, l, list_data)
{
slice = (EPhysics_Body_Soft_Body_Slice *)list_data;
@ -131,6 +141,21 @@ _ephysics_body_soft_body_slices_apply(void *data __UNUSED__, Evas *e __UNUSED__,
evas_map_point_coord_set(map, 2, x2, y2, z2);
evas_map_point_coord_set(map, 3, x2, y2, z2);
if (perspective)
evas_map_util_3d_perspective(map, px, py, pz, foc);
if (body->back_face_culling)
{
if (evas_map_util_clockwise_get(map))
evas_object_show(slice->evas_obj);
else
{
evas_map_free(map);
evas_object_hide(slice->evas_obj);
continue;
}
}
if (light)
evas_map_util_3d_lighting(map, lx, ly, lz, lr, lg, lb, ar, ag, ab);