Ejemplo n.º 1
0
static void
_camera_light_changeZ_cb(void *data, Evas_Object *obj, void *event_info)
{
   Evas_Real x, y, z;

   if ((Eo*)data)
     {
        eo_do((Eo*)data, evas_canvas3d_node_position_get(EVAS_CANVAS3D_SPACE_PARENT, &x, &y, NULL));
        z = elm_spinner_value_get(obj);
        eo_do((Eo*)data, evas_canvas3d_node_position_set(x, y, z));
     }
}
Ejemplo n.º 2
0
static void
_camera_setup(Scene_Data *data)
{
   data->camera = efl_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);

   evas_canvas3d_camera_projection_perspective_set(data->camera, 60.0, 1.0, 2.0, 50.0);

   data->camera_node =
      efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
   evas_canvas3d_node_camera_set(data->camera_node, data->camera);
   evas_canvas3d_node_position_set(data->camera_node, 0.0, 0.0, 10.0);
   evas_canvas3d_node_look_at_set(data->camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
   evas_canvas3d_node_member_add(data->root_node, data->camera_node);
}
Ejemplo n.º 3
0
static void
_light_setup(Scene_Data *data)
{
   data->light = efl_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
   evas_canvas3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
   evas_canvas3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
   evas_canvas3d_light_specular_set(data->light, 1.0, 1.0, 1.0, 1.0);

   data->light_node =
      efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
   evas_canvas3d_node_light_set(data->light_node, data->light);
   evas_canvas3d_node_position_set(data->light_node, 0.0, 0.0, 10.0);
   evas_canvas3d_node_look_at_set(data->light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
   evas_canvas3d_node_member_add(data->root_node, data->light_node);
}
Ejemplo n.º 4
0
void
_camera_setup(Scene_Data *data)
{
   data->camera = eo_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
   eo_do(data->camera,
         evas_canvas3d_camera_projection_perspective_set(65.0, 1.0, 1.0, 300.0));

   data->mediator_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas,
                                       evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));
   data->camera_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas,
                                     evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA));

   eo_do(data->root_node, evas_canvas3d_node_member_add(data->mediator_node));
   eo_do(data->mediator_node, evas_canvas3d_node_member_add(data->camera_node));

   eo_do(data->camera_node,
         evas_canvas3d_node_camera_set(data->camera),
         evas_canvas3d_node_position_set(20.0, 80.0, 30.0);
         evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
}
Ejemplo n.º 5
0
void
_light_setup(Scene_Data *data)
{
   data->light = eo_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);

   eo_do(data->light,
         evas_canvas3d_light_ambient_set(0.2, 0.2, 0.2, 1.0),
         evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0),
         evas_canvas3d_light_specular_set(0.2, 0.2, 0.2, 1.0),
                  evas_canvas3d_light_projection_perspective_set(100.0, 1.0, 1.0, 200.0));

   data->light_node = eo_add(EVAS_CANVAS3D_NODE_CLASS, evas,
                                    evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT));

   eo_do(data->light_node,
         evas_canvas3d_node_light_set(data->light),
          evas_canvas3d_node_position_set(-30.0, 70.0, 0.0),
         evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 1.0));

   eo_do(data->root_node, evas_canvas3d_node_member_add(data->light_node));
}
Ejemplo n.º 6
0
Eina_Bool _mesh_aabb(Evas_Canvas3D_Mesh **mesh, Scene_Data *scene, int index)
{
   Evas_Real x0, y0, z0, x1, y1, z1, r;
   Evas_Canvas3D_Node *node = NULL;

   if (fmod(index, 12) == 0)
     node = scene->mesh_node_warrior;
   else if (fmod(index, 12) == 1)
     node = scene->mesh_node_eagle;
   else if (fmod(index, 12) == 2)
     node = scene->mesh_node_grass;
   else if (fmod(index, 12) == 3)
     node = scene->mesh_node_soldier;
   else if (fmod(index, 12) == 4)
     node = scene->mesh_node_tommy;
   else if (fmod(index, 12) == 5)
     node = scene->mesh_node_gazebo;
   else if (fmod(index, 12) == 6)
     node = scene->mesh_node_carpet;
   else if (fmod(index, 12) == 7)
     node = scene->mesh_node_wall[0];
   else if (fmod(index, 12) == 8)
     node = scene->mesh_node_wall[1];
   else if (fmod(index, 12) == 9)
     node = scene->mesh_node_column[1];
   else if (fmod(index, 12) == 10)
     node = scene->mesh_node_column_c;
   else if (fmod(index, 12) == 11)
     node = scene->mesh_node_snake;

   eo_do(node,
         evas_canvas3d_node_bounding_sphere_get(&x0, &y0, &z0, &r));

   eo_do(scene->mesh_node_ball,
         evas_canvas3d_node_scale_set(r, r, r),
         evas_canvas3d_node_position_set(x0, y0, z0));

   eo_do(node,
         evas_canvas3d_node_bounding_box_get(&x0, &y0, &z0, &x1, &y1, &z1));

   float vertixes[] =
   {
       x0,  y0,  z1,     0.0,  0.0,  1.0,
       x0,  y1,  z1,     0.0,  0.0,  1.0,
       x1,  y1,  z1,     0.0,  0.0,  1.0,
       x1,  y0,  z1,     0.0,  0.0,  1.0,

       x0,  y0,  z0,     0.0,  0.0, -1.0,
       x1,  y0,  z0,     0.0,  0.0, -1.0,
       x0,  y1,  z0,     0.0,  0.0, -1.0,
       x1,  y1,  z0,     0.0,  0.0, -1.0,

       x0,  y0,  z0,    -1.0,  0.0,  0.0,
       x0,  y1,  z0,    -1.0,  0.0,  0.0,
       x0,  y0,  z1,    -1.0,  0.0,  0.0,
       x0,  y1,  z1,    -1.0,  0.0,  0.0,

       x1,  y0,  z0,     1.0,  0.0,  0.0,
       x1,  y1,  z0,     1.0,  0.0,  0.0,
       x1,  y1,  z1,     1.0,  0.0,  0.0,
       x1,  y0,  z1,     1.0,  0.0,  0.0,

       x0,  y1,  z0,     0.0,  1.0,  0.0,
       x1,  y1,  z0,     0.0,  1.0,  0.0,
       x0,  y1,  z1,     0.0,  1.0,  0.0,
       x1,  y1,  z1,     0.0,  1.0,  0.0,

       x0,  y0,  z0,     0.0, -1.0,  0.0,
       x1,  y0,  z0,     0.0, -1.0,  0.0,
       x1,  y0,  z1,     0.0, -1.0,  0.0,
       x0,  y0,  z1,     0.0, -1.0,  0.0
   };

   unsigned short indixes[] =
   {
      0,  1,  2,  3,  1,  2,  0,  3,
      4,  5,  5,  7,  7,  6,  6,  4,
      8,  9,  9,  11, 11, 10, 10, 8,
      12, 13, 13, 14, 14, 15, 15, 12,
      16, 17, 17, 19, 19, 18, 18, 16,
      20, 21, 21, 22, 22, 23, 23, 20
   };

   if (*mesh)
     {
        eo_do(*mesh,
         evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES),
              evas_canvas3d_mesh_frame_vertex_data_copy_set(0, EVAS_CANVAS3D_VERTEX_POSITION, 6 * sizeof(float), &vertixes[ 0]),
              evas_canvas3d_mesh_index_data_copy_set(EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, 48, &indixes[0]));

        return EINA_TRUE;
     }

   return EINA_FALSE;

}