evas: Evas_3D - improve Shooter example.

Summary: This example includes some previous developments to create 3d-world mechanics.

Reviewers: cedric, raster, Hermet

Subscribers: cedric, artem.popov

Differential Revision: https://phab.enlightenment.org/D1991

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
perepelits.m 2015-02-18 22:00:58 +01:00 committed by Cedric BAIL
parent 51722a54d8
commit 1544035b64
38 changed files with 17656 additions and 7698 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 MiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 575 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 718 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 882 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 620 KiB

View File

@ -1,19 +1,7 @@
#include "evas-3d-shooter-header.h"
void evas_vec3_set(vec3 *dst, Evas_Real x, Evas_Real y, Evas_Real z)
{
dst->x = x;
dst->y = y;
dst->z = z;
}
void evas_box3_empty_set(Box3 *box)
{
evas_vec3_set(&box->p0, 0.0, 0.0, 0.0);
evas_vec3_set(&box->p1, 0.0, 0.0, 0.0);
}
void evas_box3_set(Box3 *box, Evas_Real x0, Evas_Real y0, Evas_Real z0, Evas_Real x1, Evas_Real y1, Evas_Real z1)
void
evas_box3_set(Box3 *box, Evas_Real x0, Evas_Real y0, Evas_Real z0, Evas_Real x1, Evas_Real y1, Evas_Real z1)
{
box->p0.x = x0;
box->p0.y = y0;
@ -23,98 +11,16 @@ void evas_box3_set(Box3 *box, Evas_Real x0, Evas_Real y0, Evas_Real z0, Evas_Rea
box->p1.z = z1;
}
void evas_box3_union(Box3 *out, const Box3 *a, const Box3 *b)
{
evas_vec3_set(&out->p0, MIN(a->p0.x, b->p0.x), MIN(a->p0.y, b->p0.y), MIN(a->p0.z, b->p0.z));
evas_vec3_set(&out->p1, MAX(a->p1.x, b->p1.x), MAX(a->p1.y, b->p1.y), MAX(a->p1.z, b->p1.z));
}
void _add_annulus(float * current_r1, int size, float r1, float r2, float z1, float z2)
{
int i;
float * current_r2 = current_r1 + 12 * size;
float arc = (float)2 * 3.1415 / size;
for( i = 0 ; i < size ; i++)
{
*current_r1 = r1 * (float)sin(i * arc);
current_r1 += 1;
*current_r1 = r1 * (float)cos(i * arc);
current_r1 += 1;
*current_r1 = z1;
current_r1 += 1;
*current_r1 = (float)sin(i * arc) * (r2 - r1);
current_r1 += 1;
*current_r1 = (float)cos(i * arc) * (r2 - r1);
current_r1 += 1;
*current_r1 = (z2 - z1);
current_r1 += 7;
*current_r2 = r2 * (float)sin(i * arc);
current_r2 += 1;
*current_r2 = r2 * (float)cos(i * arc);
current_r2 += 1;
*current_r2 = z2;
current_r2 += 1;
*current_r2 = (float)sin(i * arc) * (r2 -r1);
current_r2 += 1;
*current_r2 = (float)cos(i * arc) * (r2 - r1);
current_r2 += 1;
*current_r2 = (z2 - z1);
current_r2 += 7;
}
}
void _add_annulus_vertices(unsigned short * current_r1, int size, int first)
{
int i;
for( i = 0 ; i < size - 1 ; i++)
{
*current_r1 = first + i;
current_r1 += 1;
*current_r1 = first + 1 + i;
current_r1 += 1;
*current_r1 = first + size + i;
current_r1 += 1;
*current_r1 = first + size + i;
current_r1 += 1;
*current_r1 = first + 1 + size + i;
current_r1 += 1;
*current_r1 = first + 1 + i;
current_r1 += 1;
}
*current_r1 = first + size - 1;
current_r1 += 1;
*current_r1 = first;
current_r1 += 1;
*current_r1 = first + 2 * size - 1;
current_r1 += 1;
*current_r1 = first + 2 * size - 1;
current_r1 += 1;
*current_r1 = first + size;
current_r1 += 1;
*current_r1 = first;
current_r1 += 1;
}
void
_scale(Evas_3D_Node *node, Evas_Real scale)
{
eo_do(node, evas_3d_node_scale_set(1.0 * scale, 1.0 * scale, 1.0 * scale));
}
void _add_solid_of_revolution(float * start, int size, float * vertic, unsigned short * indic)
float
_distance(float x1, float z1, float x2, float z2)
{
int i;
int accurancy = 35;
float * current = start;
for( i = 0 ; i < size ; i++)
{
_add_annulus(&vertic[i*accurancy*24], accurancy, *current, *(current + 2), *(current + 1), *(current + 3));
current+=2;
_add_annulus_vertices(&indic[i*accurancy*6], accurancy, i*accurancy*2);
}
return sqrt(pow(x2 - x1, 2) + pow(z2 - z1, 2));
}
void
@ -122,7 +28,7 @@ _camera_setup(Scene_Data *data)
{
data->camera = eo_add(EVAS_3D_CAMERA_CLASS, evas);
eo_do(data->camera,
evas_3d_camera_projection_perspective_set(65.0, 1.0, 1.0, 100.0));
evas_3d_camera_projection_perspective_set(65.0, 1.0, 1.0, 300.0));
data->mediator_node = eo_add(EVAS_3D_NODE_CLASS, evas,
evas_3d_node_constructor(EVAS_3D_NODE_TYPE_NODE));
@ -134,7 +40,7 @@ _camera_setup(Scene_Data *data)
eo_do(data->camera_node,
evas_3d_node_camera_set(data->camera),
evas_3d_node_position_set(0.0, 0.0, 1.0);
evas_3d_node_position_set(20.0, 80.0, 30.0);
evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0));
}
@ -146,22 +52,58 @@ _light_setup(Scene_Data *data)
eo_do(data->light,
evas_3d_light_ambient_set(0.2, 0.2, 0.2, 1.0),
evas_3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0),
evas_3d_light_specular_set(1.0, 1.0, 1.0, 1.0));
evas_3d_light_specular_set(0.2, 0.2, 0.2, 1.0),
evas_3d_light_projection_perspective_set(100.0, 1.0, 1.0, 200.0));
data->light_node = eo_add(EVAS_3D_NODE_CLASS, evas,
evas_3d_node_constructor(EVAS_3D_NODE_TYPE_LIGHT));
eo_do(data->light_node,
evas_3d_node_light_set(data->light),
evas_3d_node_position_set(15.0, 0.0, 30.0),
evas_3d_node_position_set(-30.0, 70.0, 0.0),
evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_3D_SPACE_PARENT, 0.0, 0.0, 1.0));
eo_do(data->root_node, evas_3d_node_member_add(data->light_node));
}
Eina_Bool _mesh_aabb(Evas_3D_Mesh **mesh, Scene_Data *scene)
Eina_Bool _mesh_aabb(Evas_3D_Mesh **mesh, Scene_Data *scene, int index)
{
Evas_Real x0, y0, z0, x1, y1, z1;
eo_do(scene->mesh_node_level[10],
Evas_Real x0, y0, z0, x1, y1, z1, r;
Evas_3D_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_3d_node_bounding_sphere_get(&x0, &y0, &z0, &r));
eo_do(scene->mesh_node_ball,
evas_3d_node_scale_set(r, r, r),
evas_3d_node_position_set(x0, y0, z0));
eo_do(node,
evas_3d_node_bounding_box_get(&x0, &y0, &z0, &x1, &y1, &z1));
float vertixes[] =
@ -210,6 +152,7 @@ Eina_Bool _mesh_aabb(Evas_3D_Mesh **mesh, Scene_Data *scene)
if (*mesh)
{
eo_do(*mesh,
evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_LINES),
evas_3d_mesh_frame_vertex_data_copy_set(0, EVAS_3D_VERTEX_POSITION, 6 * sizeof(float), &vertixes[ 0]),
evas_3d_mesh_index_data_copy_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, 48, &indixes[0]));
@ -217,6 +160,7 @@ Eina_Bool _mesh_aabb(Evas_3D_Mesh **mesh, Scene_Data *scene)
}
return EINA_FALSE;
}
void _on_delete(Ecore_Evas *ee EINA_UNUSED)
@ -259,6 +203,44 @@ Eina_Bool _horizontal_circle_resolution(Evas_3D_Node *node, Evas_Real x, Evas_Re
return EINA_TRUE;
}
Eina_Bool _horizontal_circle_object_resolution(Evas_3D_Node *node, Evas_3D_Node *node2, Evas_Real r)
{
Evas_Real x0, y0, z0, x1, y1, z1, x, y, z;
eo_do(node2,
evas_3d_node_position_get(EVAS_3D_SPACE_WORLD, &x, &y, &z));
eo_do(node,
evas_3d_node_bounding_box_get(&x0, &y0, &z0, &x1, &y1, &z1));
if (((x0 - x) * (x0 - x)) + ((z0 - z) * (z0 - z)) < r * r) return EINA_FALSE;
if (((x0 - x) * (x0 - x)) + ((z1 - z) * (z1 - z)) < r * r) return EINA_FALSE;
if (((x1 - x) * (x1 - x)) + ((z0 - z) * (z0 - z)) < r * r) return EINA_FALSE;
if (((x1 - x) * (x1 - x)) + ((z1 - z) * (z1 - z)) < r * r) return EINA_FALSE;
if ((((x + r < x0) && (x + r > x1)) || ((x + r > x0) && (x+r < x1))) && (((z < z0) && (z > z1)) || ((z > z0) && (z < z1))))
return EINA_FALSE;
if ((((x - r < x0) && (x - r > x1)) || ((x - r > x0) && (x-r < x1))) && (((z < z0) && (z > z1)) || ((z > z0) && (z < z1))))
return EINA_FALSE;
if ((((z + r < z0) && (z + r > z1)) || ((z + r > z0) && (z+r < z1))) && (((x < x0) && (x > x1)) || ((x > x0) && (x < x1))))
return EINA_FALSE;
if ((((z - r < z0) && (z - r > z1)) || ((z - r > z0) && (z-r < z1))) && (((x < x0) && (x > x1)) || ((x > x0) && (x < x1))))
return EINA_FALSE;
return EINA_TRUE;
}
Eina_Bool _horizontal_circle_position_resolution(Evas_3D_Node *node, Evas_Real x, Evas_Real z, Evas_Real r)
{
Evas_Real x0, y0, z0;
eo_do(node,
evas_3d_node_position_get(EVAS_3D_SPACE_PARENT, &x0, &y0, &z0));
if (((x0 - x) * (x0 - x)) + ((z0 - z) * (z0 - z)) < r * r) return EINA_FALSE;
return EINA_TRUE;
}
Eina_Bool _horizontal_position_resolution(Evas_3D_Node *node, Evas_Real x, Evas_Real z)
{
Evas_Real x0, y0, z0, x1, y1, z1;
@ -277,3 +259,122 @@ Eina_Bool _horizontal_position_resolution(Evas_3D_Node *node, Evas_Real x, Evas_
return EINA_TRUE;
}
/* Is actual for this example only */
Eina_Bool _horizontal_object_resolution(Evas_3D_Node *node, Evas_Real x1, Evas_Real z1, Evas_Real x2,
Evas_Real z2, Evas_Real x_move, Evas_Real z_move)
{
Evas_Real x3, y3, z3, x4, y4, z4;
eo_do(node,
evas_3d_node_bounding_box_get(&x3, &y3, &z3, &x4, &y4, &z4));
if ((x4 + x_move < x1) || (x4 + x_move > x2) ||
(z4 + z_move < z1) || (z4 + z_move > z2))
return EINA_FALSE;
return EINA_TRUE;
}
Eina_Bool _horizontal_frame_resolution(Evas_3D_Node *node, Evas_Real x1, Evas_Real z1, Evas_Real x2,
Evas_Real z2, Evas_Real *x_move, Evas_Real *z_move)
{
Evas_Real x3, y3, z3, x4, y4, z4;
*x_move = 0;
*z_move = 0;
eo_do(node,
evas_3d_node_bounding_box_get(&x3, &y3, &z3, &x4, &y4, &z4));
if (x3 < x1)
*x_move = x1 - x3;
else if (x4 > x2)
*x_move = x2 - x4;
if (z3 < z1)
*z_move = z1 - z3;
else if (z4 > z2)
*z_move = z2 - z4;
if ((*x_move != 0) || (*z_move != 0))
return EINA_FALSE;
return EINA_TRUE;
}
static void
_generate_square_grid(unsigned short *indices, int count)
{
int i, j;
unsigned short *index = &indices[0];
int vccount = count + 1;
for(j = 0; j < count; j++)
for(i = 0; i < count; i++)
{
*index++ = (unsigned short)(i + vccount * j);
*index++ = i + vccount * (j + 1);
*index++ = i + 1 + vccount * (j + 1);
*index++ = i + vccount * j;
*index++ = i + 1 + vccount * j;
*index++ = i + vccount * (j + 1) + 1;
}
}
void
_set_ball(Eo *mesh, int p)
{
int vcount, icount, vccount, i, j;
double dtheta, dfi, sinth, costh, fi, theta, sinfi, cosfi;
unsigned short *indices;
icount = p * p * 6;
vccount = p + 1;
vcount = vccount * vccount;
dtheta = M_PI / p;
dfi = 2 * M_PI / p;
vec3 *vertices = malloc(sizeof(vec3) * vcount);
vec3 *normals = malloc(sizeof(vec3) * vcount);
for (j = 0; j < vccount; j++)
{
theta = j * dtheta;
sinth = sin(theta);
costh = cos(theta);
for (i = 0; i < vccount; i++)
{
fi = i * dfi;
sinfi = sin(fi);
cosfi = cos(fi);
vertices[i + j * vccount].x = sinth * cosfi;
vertices[i + j * vccount].y = sinth * sinfi;
vertices[i + j * vccount].z = costh;
normals[i + j * vccount].x = vertices[i + j * vccount].x;
normals[i + j * vccount].y = vertices[i + j * vccount].y;
normals[i + j * vccount].z = vertices[i + j * vccount].z;
}
}
indices = malloc(sizeof(short) * icount);
_generate_square_grid(indices, p);
eo_do(mesh, evas_3d_mesh_vertex_count_set(vcount),
evas_3d_mesh_frame_add(0);
evas_3d_mesh_frame_vertex_data_copy_set(0, EVAS_3D_VERTEX_POSITION,
sizeof(vec3), &vertices[0]);
evas_3d_mesh_frame_vertex_data_copy_set(0, EVAS_3D_VERTEX_NORMAL,
sizeof(vec3), &normals[0]);
evas_3d_mesh_index_data_copy_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT,
icount , &indices[0]));
free(vertices);
free(normals);
free(indices);
}

View File

@ -6,65 +6,126 @@
#include <math.h>
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <Ecore_Getopt.h>
#include <Evas.h>
#include "Eo.h"
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#include "evas-3d-shooter-macros.h"
typedef struct _Scene_Data
{
Eo *texture_diffuse_eagle;
Eo *texture_diffuse_world;
Eo *texture_diffuse_grass;
Eo *texture_diffuse_soldier;
Eo *texture_diffuse_soldier_jump;
Eo *texture_diffuse_head;
Eo *texture_diffuse_wall;
Eo *texture_diffuse_gazebo;
Eo *texture_diffuse_carpet;
Eo *texture_diffuse_column;
Eo *texture_diffuse_column_c;
Eo *texture_diffuse_level[2];
Eo *texture_diffuse_warrior;
Eo *texture_diffuse_snake;
Eo *texture_normal_grass;
Eo *texture_normal_wall;
Eo *texture_normal_gazebo;
Eo *texture_normal_carpet;
Eo *texture_normal_column;
Eo *texture_normal_column_c;
Eo *texture_normal_level[2];
Eo *texture_normal_snake;
Eo *root_node;
Eo *camera_node;
Eo *mesh_node_world;
Eo *mesh_node_grass[30];
Eo *mesh_node_grass;
Eo *light_node;
Eo *mediator_node;
Eo *carp_mediator_node;
Eo *mesh_node_cube;
Eo *mesh_node_eagle;
Eo *mesh_node_gun;
Eo *mesh_node_gun_butt;
Eo *mesh_node_gun_cage;
Eo *mesh_node_gun_bling[3];
Eo *mesh_node_rocket;
Eo *mesh_node_level[11];
Eo *mesh_node_soldier;
Eo *mesh_node_head;
Eo *mesh_node_tommy;
Eo *mesh_node_wall[4];
Eo *mesh_node_gazebo;
Eo *mesh_node_carpet;
Eo *mesh_node_column[4];
Eo *mesh_node_column_c;
Eo *mesh_node_rocket[10];
Eo *mesh_node_level[10];
Eo *mesh_node_snake;
Eo *mesh_node_warrior;
Eo *mesh_node_ball;
Eo *camera;
Eo *light;
Eo *mesh_world;
Eo *mesh_grass[30];
Eo *mesh_grass;
Eo *mesh_cube;
Eo *mesh_eagle;
Eo *mesh_gun;
Eo *mesh_gun_cage;
Eo *mesh_gun_butt;
Eo *mesh_gun_bling[3];
Eo *mesh_rocket;
Eo *mesh_level[4];
Eo *mesh_soldier;
Eo *mesh_soldier_jump;
Eo *mesh_head;
Eo *mesh_tommy;
Eo *mesh_wall[4];
Eo *mesh_gazebo;
Eo *mesh_carpet;
Eo *mesh_column[4];
Eo *mesh_column_c;
Eo *mesh_rocket[10];
Eo *mesh_level[10];
Eo *mesh_snake;
Eo *mesh_warrior;
Eo *mesh_ball;
Eo *material_world;
Eo *material_grass;
Eo *material_eagle;
Eo *material_soldier;
Eo *material_soldier_jump;
Eo *material_head;
Eo *material_tommy;
Eo *material_wall;
Eo *material_gazebo;
Eo *material_carpet;
Eo *material_column;
Eo *material_column_c;
Eo *material_cube;
Eo *material_level;
Eo *material_level[2];
Eo *material_snake;
Eo *material_gun_butt;
Eo *material_gun_bling;
Eo *material_gun_cage;
Eo *gun;
Eo *rocket;
Eo *texture;
Eo *texture_snake;
Eo *material_warrior;
Eo *material_rocket[10];
Eo *material_ball;
Eina_Bool shadow;
Eina_Bool colorpick;
Eina_Bool fog;
Eina_Bool blending;
Eina_Bool normal;
} Scene_Data;
static Evas *evas = NULL;
static Eo *background = NULL;
static Eo *image = NULL;
static const Ecore_Getopt optdesc = {
"ecore_thread_example",
NULL,
"0.0",
"(C) 2011 Enlightenment",
"Public domain?",
"Example program for Ecore_Thread",
0,
{
ECORE_GETOPT_STORE_BOOL('s', "shadow", "If shadow is enable"),
ECORE_GETOPT_STORE_BOOL('c', "colopick", "If colorpick is enable"),
ECORE_GETOPT_STORE_BOOL('f', "fog", "If fog is enable"),
ECORE_GETOPT_STORE_BOOL('b', "blending", "If blending is enable"),
ECORE_GETOPT_HELP('h', "help"),
ECORE_GETOPT_SENTINEL
}
};
typedef struct _vec4
{
float x;
@ -101,29 +162,19 @@ typedef struct _vertex
vec3 texcoord;
} vertex;
void evas_vec3_set(vec3 *dst, Evas_Real x, Evas_Real y, Evas_Real z);
void evas_box3_empty_set(Box3 *box);
void evas_box3_set(Box3 *box, Evas_Real x0, Evas_Real y0, Evas_Real z0, Evas_Real x1, Evas_Real y1, Evas_Real z1);
void evas_box3_union(Box3 *out, const Box3 *a, const Box3 *b);
/* fill vector by indices which are on one rotation ring */
void _add_annulus(float * current_r1, int size, float r1, float r2, float z1, float z2);
/* fill vector by vertices which are arranged between two rotation rings */
void _add_annulus_vertices(unsigned short * current_r1, int size, int first);
void _scale(Evas_3D_Node *node, Evas_Real scale);
void _add_solid_of_revolution(float * start, int size, float * vertic, unsigned short * indic);
float _distance(float x1, float z1, float x2, float z2);
void _camera_setup(Scene_Data *data);
void _light_setup(Scene_Data *data);
Eina_Bool _mesh_aabb(Evas_3D_Mesh **mesh, Scene_Data *scene);
Eina_Bool _mesh_aabb(Evas_3D_Mesh **mesh, Scene_Data *scene, int index);
void _on_delete(Ecore_Evas *ee EINA_UNUSED);
@ -131,4 +182,17 @@ void _on_canvas_resize(Ecore_Evas *ee);
Eina_Bool _horizontal_circle_resolution(Evas_3D_Node *node, Evas_Real x, Evas_Real z, Evas_Real r);
Eina_Bool _horizontal_circle_position_resolution(Evas_3D_Node *node, Evas_Real x, Evas_Real z, Evas_Real r);
Eina_Bool _horizontal_circle_object_resolution(Evas_3D_Node *node, Evas_3D_Node *node2, Evas_Real r);
Eina_Bool _horizontal_position_resolution(Evas_3D_Node *node, Evas_Real x, Evas_Real z);
Eina_Bool _horizontal_object_resolution(Evas_3D_Node *node, Evas_Real x1, Evas_Real z1, Evas_Real x2,
Evas_Real z2, Evas_Real x_move, Evas_Real z_move);
Eina_Bool _horizontal_frame_resolution(Evas_3D_Node *node, Evas_Real x1, Evas_Real z1, Evas_Real x2,
Evas_Real z2, Evas_Real *x_move, Evas_Real *z_move);
void _set_ball(Eo *mesh, int p);

View File

@ -0,0 +1,236 @@
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define FOG_COLOR 0.5, 0.5, 0.5
#define FOG_FACTOR 0.01
#define WIDTH 1920
#define HEIGHT 1080
#define SOLDIER_RADIUS 5.3 /* soldier couldn't get сloser to camera than SOLDIER_RADIUS */
#define COLUMN_RADIUS 3.0 /* warrior couldn't get сloser to any column than WARRIOR_COLUMN */
#define WALL_RADIUS 2.2 /* camera couldn't get сloser to wall than WALL_RADIUS */
#define JUMP_HIGHT 4
#define GUN_DIR_X 0
#define GUN_DIR_Y -2
#define GUN_DIR_Z 105
#define ROCKET_POS_X 0.4
#define ROCKET_POS_Y -3.1
#define ROCKET_POS_Z 0.0
#define TOMMY_POS_X 1.0
#define TOMMY_POS_Y -3.3
#define TOMMY_POS_Z -9.0
#define TOMMY_JUMP_X 0.7
#define TOMMY_JUMP_Y 3.3
#define TOMMY_JUMP_Z -4.1
#define GUN_SPEED 0.001
#define WARRIOR_SPEED 0.001
#define WARRIOR_SPEED2 0.003
#define SNAKE_SPEED 0.1
#define SNAKE_SPEED2 0.001
#define ROCKET_SPEED 2
#define TO_RADIAN M_PI / 180
#define JUMP 0.2
#define STEP 2.5
#define FALL_SPEED_UP 0.04
#define CAMERA_SPEED 2
#define CAMERA_MOVE 0.3
#define SOLDIER_FRAME_X1 -43
#define SOLDIER_FRAME_X2 76
#define SOLDIER_FRAME_Z1 -55
#define SOLDIER_FRAME_Z2 30.3
#define ROCKET_FRAME_X1 -47
#define ROCKET_FRAME_X2 80
#define ROCKET_FRAME_Z1 -59
#define ROCKET_FRAME_Z2 34
#define SNAKE_FRAME_X1 -47
#define SNAKE_FRAME_X2 79
#define SNAKE_FRAME_Z1 -59
#define SNAKE_FRAME_Z2 32
#define KEY_MOTION(lateral, camera) \
{ \
lateral_motion_indicator = lateral; \
camera_move = camera; \
}
#define ENABLE_FOG(mesh) \
eo_do(mesh, evas_3d_mesh_fog_enable_set(EINA_TRUE), \
evas_3d_mesh_fog_color_set(FOG_COLOR, FOG_FACTOR));
#define DISABLE_FOG(mesh) \
eo_do(mesh, evas_3d_mesh_fog_enable_set(EINA_FALSE));
#define ENABLE_NORMAL(mesh) \
eo_do(mesh, evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP));
#define DISABLE_NORMAL(mesh) \
eo_do(mesh, evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
#define SETUP_MESH(Object, Name, a, d, s) \
data->material_##Object = eo_add(EVAS_3D_MATERIAL_CLASS, evas); \
\
eo_do(data->material_##Object, \
evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), \
evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), \
evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), \
evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE), \
evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, a, a, a, 1.0), \
evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, d, d, d, 1.0), \
evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, s, s, s, 1.0), \
evas_3d_material_shininess_set(50.0)); \
\
data->mesh_##Name = eo_add(EVAS_3D_MESH_CLASS, evas); \
\
eo_do(data->mesh_##Name, \
evas_3d_mesh_frame_add(0), \
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_DIFFUSE), \
evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES), \
evas_3d_mesh_frame_material_set(0, data->material_##Object));
#define SETUP_MESH_NODE(Name) \
data->mesh_node_##Name = eo_add(EVAS_3D_NODE_CLASS, evas, \
evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH)); \
\
eo_do(data->mesh_node_##Name, \
evas_3d_node_mesh_add(data->mesh_##Name));
#define MATERIAL_TEXTURE_SET(Object, Name, file, image) \
eo_do(data->mesh_##Name, \
efl_file_set(file, NULL), \
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG), \
evas_3d_mesh_frame_material_set(0, data->material_##Object)); \
\
data->texture_diffuse_##Object = eo_add(EVAS_3D_TEXTURE_CLASS, evas); \
\
eo_do(data->texture_diffuse_##Object, \
evas_3d_texture_file_set(image, NULL), \
evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, \
EVAS_3D_TEXTURE_FILTER_NEAREST), \
evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT)); \
\
eo_do(data->material_##Object, \
evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, \
data->texture_diffuse_##Object), \
evas_3d_material_texture_set(EVAS_3D_MATERIAL_AMBIENT, \
data->texture_diffuse_##Object));
#define CUBE_TEXTURE_SET(Object, Name, v_count, vertex1, vertex2, i_count, index, image) \
int textcoords_count = 12; \
int pos_count = 12; \
if (&vertex1[10] != vertex2) \
{ \
textcoords_count =2; \
pos_count = 10; \
} \
eo_do(data->mesh_##Name, \
evas_3d_mesh_vertex_count_set(v_count), \
evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, \
pos_count * sizeof(float), &vertex1[ 0]), \
evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL, \
pos_count * sizeof(float), &vertex1[ 3]), \
evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR, \
pos_count * sizeof(float), &vertex1[ 6]), \
evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD, \
textcoords_count * sizeof(float), vertex2), \
evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, \
i_count, &index[0]), \
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP)); \
\
data->texture_diffuse_##Object = eo_add(EVAS_3D_TEXTURE_CLASS, evas); \
\
eo_do(data->texture_diffuse_##Object, \
evas_3d_texture_file_set(image, NULL), \
evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, \
EVAS_3D_TEXTURE_FILTER_NEAREST), \
evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT)); \
\
eo_do(data->material_##Object, \
evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, \
data->texture_diffuse_##Object), \
evas_3d_material_texture_set(EVAS_3D_MATERIAL_AMBIENT, \
data->texture_diffuse_##Object));
#define NORMAL_SET(Object, Name, normal) \
data->texture_normal_##Object = eo_add(EVAS_3D_TEXTURE_CLASS, evas); \
\
eo_do(data->texture_normal_##Object, \
evas_3d_texture_file_set(normal, NULL), \
evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, \
EVAS_3D_TEXTURE_FILTER_NEAREST), \
evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT)); \
\
eo_do(data->material_##Object, \
evas_3d_material_texture_set(EVAS_3D_MATERIAL_NORMAL, \
data->texture_normal_##Object)); \
\
eo_do(data->mesh_##Name, \
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP));
#define SPHERE_SET(Name) \
eo_do(data->mesh_##Name, \
evas_3d_mesh_vertex_count_set(vertex_count), \
evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, \
sizeof(vertex), &vertices[0].position), \
evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL, \
sizeof(vertex), &vertices[0].normal), \
evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TANGENT, \
sizeof(vertex), &vertices[0].tangent), \
evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR, \
sizeof(vertex), &vertices[0].color); \
evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD, \
sizeof(vertex), &vertices[0].texcoord), \
evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, \
index_count, &indices[0]));
#define TEXTCOORDS_SET(Name, fb1, fb2, lr1, lr2, tb1, tb2) \
static float Name##_textcoords[] = \
{ \
/* Front */ \
0.0, 0.0, \
fb1, 0.0, \
0.0, fb2, \
fb1, fb2, \
\
/* Back */ \
0.0, fb2, \
fb1, fb2, \
0.0, 0.0, \
fb1, 0.0, \
\
/* Left */ \
0.0, lr2, \
lr1, lr2, \
0.0, 0.0, \
lr1, 0.0, \
\
/* Right */ \
0.0, lr2, \
lr1, lr2, \
0.0, 0.0, \
lr1, 0.0, \
\
/* Top */ \
0.0, tb2, \
tb1, tb2, \
0.0, 0.0, \
tb1, 0.0, \
\
/* Bottom */ \
0.0, tb2, \
tb1, tb2, \
0.0, 0.0, \
tb1, 0.0, \
};

File diff suppressed because it is too large Load Diff