summaryrefslogtreecommitdiff
path: root/src/examples/evas/shooter/evas-3d-shooter-header.h
blob: 1a84f07f75f41a914da9ff9e0ad0049f1d12617e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#ifndef EVAS_3D_SHOOTER_H_
#define EVAS_3D_SHOOTER_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define PACKAGE_EXAMPLES_DIR "."
#define EFL_EO_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif

#include <stdio.h>
#include <math.h>
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <Ecore_Getopt.h>
#include <Evas.h>
#include "Eo.h"
#include "evas-3d-shooter-macros.h"
#include "../evas-common.h"

typedef struct _Scene_Data
{
   Eo      *cube_primitive;
   Eo      *sphere_primitive;
   Eo      *cylinder_primitive;
   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;
   Eo      *light_node;
   Eo      *mediator_node;
   Eo      *carp_mediator_node;
   Eo      *mesh_node_cube;
   Eo      *mesh_node_eagle;
   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;
   Eo      *mesh_cube;
   Eo      *mesh_eagle;
   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[2];
   Eo      *material_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 vec2 tex_scale = {1, 1};

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;
   float   y;
   float   z;
   float   w;
} vec4;

typedef struct _Box3
{
   vec3    p0;
   vec3    p1;
} Box3;

typedef struct _vertex
{
   vec3    position;
   vec3    normal;
   vec3    tangent;
   vec4    color;
   vec3    texcoord;
} vertex;

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       _scale(Evas_Canvas3D_Node *node, Evas_Real scale);

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_Canvas3D_Mesh **mesh, Scene_Data *scene, int index);

void       _on_delete(Ecore_Evas *ee EINA_UNUSED);

void       _on_canvas_resize(Ecore_Evas *ee);

Eina_Bool _horizontal_circle_resolution(Evas_Canvas3D_Node *node, Evas_Real x, Evas_Real z, Evas_Real r);

Eina_Bool _horizontal_circle_position_resolution(Evas_Canvas3D_Node *node, Evas_Real x, Evas_Real z, Evas_Real r);

Eina_Bool _horizontal_circle_object_resolution(Evas_Canvas3D_Node *node, Evas_Canvas3D_Node *node2, Evas_Real r);

Eina_Bool _horizontal_position_resolution(Evas_Canvas3D_Node *node, Evas_Real x, Evas_Real z);

Eina_Bool _horizontal_object_resolution(Evas_Canvas3D_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_Canvas3D_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);
#endif