aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xbuild.lua6
-rwxr-xr-xsrc/LuaSL/build.lua4
-rwxr-xr-xsrc/extantz/build.lua7
-rw-r--r--src/extantz/chat.c36
-rw-r--r--src/extantz/crappisspuke.cpp2
-rw-r--r--src/extantz/ephysics_demo.c69
-rw-r--r--src/extantz/extantz.c1069
-rw-r--r--src/extantz/extantz.h17
-rw-r--r--src/extantz/fangWin.c330
-rw-r--r--src/extantz/gears.c354
-rw-r--r--src/extantz/woMan.c300
12 files changed, 1119 insertions, 1076 deletions
diff --git a/.gitignore b/.gitignore
index 12ab02e..4d07ecf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -329,4 +329,3 @@ src/LuaSL/LuaSL_lexer.c
329src/LuaSL/LuaSL_lexer.h 329src/LuaSL/LuaSL_lexer.h
330src/LuaSL/LuaSL_LSL_lexer.c 330src/LuaSL/LuaSL_LSL_lexer.c
331src/LuaSL/LuaSL_LSL_lexer.h 331src/LuaSL/LuaSL_LSL_lexer.h
332
diff --git a/build.lua b/build.lua
index 414ebfa..359dbe8 100755
--- a/build.lua
+++ b/build.lua
@@ -27,7 +27,7 @@ runCommand = function (name, dir, command)
27 os.execute('cd ' .. dir .. '; ' .. command) 27 os.execute('cd ' .. dir .. '; ' .. command)
28end 28end
29 29
30compileFiles = function (name, dir, files) 30compileFiles = function (name, dir, files, extras)
31 local objects = '' 31 local objects = ''
32 print('\n' .. name) 32 print('\n' .. name)
33 for i, v in ipairs(files) do 33 for i, v in ipairs(files) do
@@ -35,7 +35,7 @@ compileFiles = function (name, dir, files)
35 os.execute('cd ' .. dir .. '; gcc ' .. CFLAGS .. ' -c -o ' .. v .. '.o ' .. v .. '.c') 35 os.execute('cd ' .. dir .. '; gcc ' .. CFLAGS .. ' -c -o ' .. v .. '.o ' .. v .. '.c')
36 objects = objects .. ' ' .. v .. '.o' 36 objects = objects .. ' ' .. v .. '.o'
37 end 37 end
38 os.execute('cd ' .. dir .. '; gcc ' .. CFLAGS .. ' -o ' .. name .. ' ' .. objects .. ' ' .. LDFLAGS .. ' ' .. libs) 38 os.execute('cd ' .. dir .. '; gcc ' .. CFLAGS .. ' -o ' .. name .. ' ' .. objects .. ' ' .. extras .. ' ' .. LDFLAGS .. ' ' .. libs)
39end 39end
40 40
41local buildSub = function (name, dir) 41local buildSub = function (name, dir)
@@ -88,7 +88,7 @@ if 'nil' == type(args) then
88 -- Building this passes my "holding breath" test, if it can compile while I'm holding my breath, no need for make files. 88 -- Building this passes my "holding breath" test, if it can compile while I'm holding my breath, no need for make files.
89 print('_______________ BUILDING lemon _______________') 89 print('_______________ BUILDING lemon _______________')
90 removeFiles('libraries/lemon', {'*.o', 'lemon'}) 90 removeFiles('libraries/lemon', {'*.o', 'lemon'})
91 compileFiles('lemon', 'libraries/lemon', {'lemon'}) 91 compileFiles('lemon', 'libraries/lemon', {'lemon'}, '')
92 print('_______________ BUILDING Irrlicht _______________') 92 print('_______________ BUILDING Irrlicht _______________')
93 -- Irrlicht is an external project that comes with make files anyway, and doesn't otherwise pass the test. 93 -- Irrlicht is an external project that comes with make files anyway, and doesn't otherwise pass the test.
94 runCommand('Irrlicht','libraries/irrlicht-1.8.1/source/Irrlicht', 'make') 94 runCommand('Irrlicht','libraries/irrlicht-1.8.1/source/Irrlicht', 'make')
diff --git a/src/LuaSL/build.lua b/src/LuaSL/build.lua
index 6b34145..4bf0c09 100755
--- a/src/LuaSL/build.lua
+++ b/src/LuaSL/build.lua
@@ -28,5 +28,5 @@ CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. lib_d .. '\\"'
28CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"' 28CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"'
29CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"' 29CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"'
30 30
31compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_utilities', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}) 31compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_utilities', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '')
32compileFiles('LuaSL_test', dir, {'LuaSL_test', 'LuaSL_utilities'}) 32compileFiles('LuaSL_test', dir, {'LuaSL_test', 'LuaSL_utilities'}, '')
diff --git a/src/extantz/build.lua b/src/extantz/build.lua
index 51551e9..c7ad5a1 100755
--- a/src/extantz/build.lua
+++ b/src/extantz/build.lua
@@ -17,11 +17,10 @@ CFLAGS = CFLAGS .. ' -I../../libraries/irrlicht-1.8.1/include -I/usr/X11R6/inc
17LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux' 17LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux'
18libs = libs .. ' -lIrrlicht -lGL -lbz2' 18libs = libs .. ' -lIrrlicht -lGL -lbz2'
19 19
20removeFiles(dir, {'../../extantz', 'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', '../../media/extantz.edj'}) 20removeFiles(dir, {'../../extantz', 'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', 'fangWin.o', 'chat.o', 'woMan.o', '../../media/extantz.edj'})
21 21
22runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' extantz.edc ../../media/extantz.edj') 22runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' extantz.edc ../../media/extantz.edj')
23runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -O3 -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS) 23runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -O3 -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS)
24runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -O3 -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS) 24runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -O3 -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS)
25runCommand('extantz', dir, 'g++ ' .. CFLAGS .. ' -O3 -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS) 25runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -O3 -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS)
26runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -c Evas_3D_demo.c -o Evas_3D_demo.o ' .. LDFLAGS) 26compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'Evas_3D_demo', 'fangWin', 'chat', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o')
27runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' extantz.c crappisspuke.o CDemo.o extantzCamera.o Evas_3D_demo.o -o ../../extantz ' .. LDFLAGS .. ' ' .. libs)
diff --git a/src/extantz/chat.c b/src/extantz/chat.c
new file mode 100644
index 0000000..23155a9
--- /dev/null
+++ b/src/extantz/chat.c
@@ -0,0 +1,36 @@
1#include "extantz.h"
2
3
4void chat_add(GLData *gld)
5{
6 Evas_Object *win, *bx, *en;
7
8 win = fang_win_add(gld);
9
10 bx = elm_box_add(win);
11 elm_win_resize_object_add(win, bx);
12 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
13 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
14
15 en = elm_entry_add(win);
16 elm_entry_scrollable_set(en, EINA_TRUE);
17 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
18 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
19 elm_object_text_set(en, "History is shown here");
20 elm_entry_editable_set(en, EINA_FALSE);
21 evas_object_show(en);
22 elm_box_pack_end(bx, en);
23
24 en = elm_entry_add(win);
25 elm_entry_scrollable_set(en, EINA_TRUE);
26 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
27 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
28 elm_object_text_set(en, "");
29 elm_entry_editable_set(en, EINA_TRUE);
30 evas_object_show(en);
31 elm_box_pack_end(bx, en);
32
33 evas_object_show(bx);
34
35 fang_win_complete(gld, win, 30, 500, gld->win_w / 3, gld->win_h / 3);
36}
diff --git a/src/extantz/crappisspuke.cpp b/src/extantz/crappisspuke.cpp
index 2af9dde..d0ec23d 100644
--- a/src/extantz/crappisspuke.cpp
+++ b/src/extantz/crappisspuke.cpp
@@ -21,10 +21,12 @@ extern "C" {
21EAPI int startIrr(GLData *gld) 21EAPI int startIrr(GLData *gld)
22{ 22{
23 SIrrlichtCreationParameters params; 23 SIrrlichtCreationParameters params;
24#if USE_IRR
24 IrrlichtDevice *device; 25 IrrlichtDevice *device;
25 IVideoDriver *driver; 26 IVideoDriver *driver;
26 ISceneManager *smgr; 27 ISceneManager *smgr;
27 bool additive = true; 28 bool additive = true;
29#endif
28 30
29 if (!gld->useIrr) 31 if (!gld->useIrr)
30 return 1; // Return 1 so that the caller stops asking on each frame. 32 return 1; // Return 1 so that the caller stops asking on each frame.
diff --git a/src/extantz/ephysics_demo.c b/src/extantz/ephysics_demo.c
new file mode 100644
index 0000000..e3aa62f
--- /dev/null
+++ b/src/extantz/ephysics_demo.c
@@ -0,0 +1,69 @@
1#include "extantz.h"
2
3
4#if USE_PHYSICS
5
6#define EPHYSICS_TEST_THEME "extantz"
7
8EPhysics_World *ephysicsAdd(GLData *gld)
9{
10 EPhysics_Body *boundary;
11 EPhysics_World *world;
12 EPhysics_Body *box_body1, *box_body2;
13 Evas_Object *box1, *box2;
14 char buf[PATH_MAX];
15
16 // ePhysics stuff.
17 world = ephysics_world_new();
18 ephysics_world_render_geometry_set(world, 0, 0, -50, gld->win_w, gld->win_h, 100);
19
20 boundary = ephysics_body_bottom_boundary_add(world);
21 ephysics_body_restitution_set(boundary, 1);
22 ephysics_body_friction_set(boundary, 0);
23
24 boundary = ephysics_body_top_boundary_add(world);
25 ephysics_body_restitution_set(boundary, 1);
26 ephysics_body_friction_set(boundary, 0);
27
28 boundary = ephysics_body_left_boundary_add(world);
29 ephysics_body_restitution_set(boundary, 1);
30 ephysics_body_friction_set(boundary, 0);
31
32 boundary = ephysics_body_right_boundary_add(world);
33 ephysics_body_restitution_set(boundary, 1);
34 ephysics_body_friction_set(boundary, 0);
35
36 box1 = elm_image_add(gld->win);
37 sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME);
38 elm_image_file_set(box1, strdup(buf), "blue-cube");
39 evas_object_move(box1, gld->win_w / 2 - 80, gld->win_h - 200);
40 evas_object_resize(box1, 70, 70);
41 evas_object_show(box1);
42
43 box_body1 = ephysics_body_box_add(world);
44 ephysics_body_evas_object_set(box_body1, box1, EINA_TRUE);
45 ephysics_body_restitution_set(box_body1, 0.7);
46 ephysics_body_friction_set(box_body1, 0);
47 ephysics_body_linear_velocity_set(box_body1, -150, 200, 0);
48 ephysics_body_angular_velocity_set(box_body1, 0, 0, 36);
49 ephysics_body_sleeping_threshold_set(box_body1, 0.1, 0.1);
50
51 box2 = elm_image_add(gld->win);
52 elm_image_file_set(box2, strdup(buf), "purple-cube");
53 evas_object_move(box2, gld->win_w / 2 + 10, gld->win_h - 200);
54 evas_object_resize(box2, 70, 70);
55 evas_object_show(box2);
56
57 box_body2 = ephysics_body_box_add(world);
58 ephysics_body_evas_object_set(box_body2, box2, EINA_TRUE);
59 ephysics_body_restitution_set(box_body2, 0.7);
60 ephysics_body_friction_set(box_body2, 0);
61 ephysics_body_linear_velocity_set(box_body2, 80, -60, 0);
62 ephysics_body_angular_velocity_set(box_body2, 0, 0, 360);
63 ephysics_body_sleeping_threshold_set(box_body2, 0.1, 0.1);
64
65 ephysics_world_gravity_set(world, 0, 0, 0);
66
67 return world;
68}
69#endif
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index 7eec6dd..a731e6a 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -3,242 +3,6 @@
3 3
4globals ourGlobals; 4globals ourGlobals;
5 5
6Eina_Hash *grids;
7Eina_Hash *viewers;
8
9static char *gridTest[][3] =
10{
11 {"3rd Rock Grid", "http://grid.3rdrockgrid.com:8002/", "http://grid.3rdrockgrid.com/3rg_login"},
12 {"Infinite Grid", "http://grid.infinitegrid.org:8002/", "http://www.infinitegrid.org/loginscreen.php"},
13 {"Second Life Grid", "https://login.agni.lindenlab.com/cgi-bin/login.cgi", "http://secondlife.com/"},
14 {NULL, NULL, NULL}
15};
16
17static char *accountTest[][3] =
18{
19 {"3rd Rock Grid", "onefang rejected", "password"},
20 {"Infinite Grid", "infinite onefang", "MyB1GSecrit"},
21 {"Infinite Grid", "onefang rejected", "MySecrit"},
22 {NULL, NULL, NULL}
23};
24
25
26static char *viewerTest[][3] =
27{
28 {"Imprudence", "1.4.0 beta 3", ""},
29 {"Kokua", "3.4.4.25633", ""},
30 {"meta-impy", "1.4.0 beta 1.5", ""},
31 {"SL", "v3", ""},
32 {NULL, NULL, NULL}
33};
34
35
36static Elm_Genlist_Item_Class *grid_gic = NULL;
37static Elm_Genlist_Item_Class *account_gic = NULL;
38static Elm_Genlist_Item_Class *viewer_gic = NULL;
39
40//static const char *img1 = PACKAGE_DATA_DIR "/media/plant_01.jpg";
41//static const char *img2 = PACKAGE_DATA_DIR "/media/sky_01.jpg";
42static const char *img3 = "rock_01.jpg";
43
44
45#define EPHYSICS_TEST_THEME "extantz"
46
47
48#if DO_GEARS
49//--------------------------------//
50// Gear Stuff.
51
52static GLfloat *vert(GLfloat *p, GLfloat x, GLfloat y, GLfloat z, GLfloat *n)
53{
54 p[0] = x;
55 p[1] = y;
56 p[2] = z;
57 p[3] = n[0];
58 p[4] = n[1];
59 p[5] = n[2];
60
61 return p + 6;
62}
63
64/* Draw a gear wheel. You'll probably want to call this function when
65 * building a display list since we do a lot of trig here.
66 *
67 * Input: inner_radius - radius of hole at center
68 * outer_radius - radius at center of teeth
69 * width - width of gear
70 * teeth - number of teeth
71 * tooth_depth - depth of tooth
72 */
73static Gear *make_gear(GLData *gld, GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth)
74{
75 GLint i;
76 GLfloat r0, r1, r2;
77 GLfloat da;
78 GLfloat *v;
79 Gear *gear;
80 double s[5], c[5];
81 GLfloat normal[3];
82 const int tris_per_tooth = 20;
83 Evas_GL_API *gl = gld->glApi;
84
85 gear = (Gear*)malloc(sizeof(Gear));
86 if (gear == NULL)
87 return NULL;
88
89 r0 = inner_radius;
90 r1 = outer_radius - tooth_depth / 2.0;
91 r2 = outer_radius + tooth_depth / 2.0;
92
93 da = 2.0 * M_PI / teeth / 4.0;
94
95 gear->vertices = calloc(teeth * tris_per_tooth * 3 * 6, sizeof *gear->vertices);
96 s[4] = 0;
97 c[4] = 1;
98 v = gear->vertices;
99 for (i = 0; i < teeth; i++)
100 {
101 s[0] = s[4];
102 c[0] = c[4];
103 s[1] = sin(i * 2.0 * M_PI / teeth + da);
104 c[1] = cos(i * 2.0 * M_PI / teeth + da);
105 s[2] = sin(i * 2.0 * M_PI / teeth + da * 2);
106 c[2] = cos(i * 2.0 * M_PI / teeth + da * 2);
107 s[3] = sin(i * 2.0 * M_PI / teeth + da * 3);
108 c[3] = cos(i * 2.0 * M_PI / teeth + da * 3);
109 s[4] = sin(i * 2.0 * M_PI / teeth + da * 4);
110 c[4] = cos(i * 2.0 * M_PI / teeth + da * 4);
111
112 normal[0] = 0.0;
113 normal[1] = 0.0;
114 normal[2] = 1.0;
115
116 v = vert(v, r2 * c[1], r2 * s[1], width * 0.5, normal);
117
118 v = vert(v, r2 * c[1], r2 * s[1], width * 0.5, normal);
119 v = vert(v, r2 * c[2], r2 * s[2], width * 0.5, normal);
120 v = vert(v, r1 * c[0], r1 * s[0], width * 0.5, normal);
121 v = vert(v, r1 * c[3], r1 * s[3], width * 0.5, normal);
122 v = vert(v, r0 * c[0], r0 * s[0], width * 0.5, normal);
123 v = vert(v, r1 * c[4], r1 * s[4], width * 0.5, normal);
124 v = vert(v, r0 * c[4], r0 * s[4], width * 0.5, normal);
125
126 v = vert(v, r0 * c[4], r0 * s[4], width * 0.5, normal);
127 v = vert(v, r0 * c[0], r0 * s[0], width * 0.5, normal);
128 v = vert(v, r0 * c[4], r0 * s[4], -width * 0.5, normal);
129 v = vert(v, r0 * c[0], r0 * s[0], -width * 0.5, normal);
130
131 normal[0] = 0.0;
132 normal[1] = 0.0;
133 normal[2] = -1.0;
134
135 v = vert(v, r0 * c[4], r0 * s[4], -width * 0.5, normal);
136
137 v = vert(v, r0 * c[4], r0 * s[4], -width * 0.5, normal);
138 v = vert(v, r1 * c[4], r1 * s[4], -width * 0.5, normal);
139 v = vert(v, r0 * c[0], r0 * s[0], -width * 0.5, normal);
140 v = vert(v, r1 * c[3], r1 * s[3], -width * 0.5, normal);
141 v = vert(v, r1 * c[0], r1 * s[0], -width * 0.5, normal);
142 v = vert(v, r2 * c[2], r2 * s[2], -width * 0.5, normal);
143 v = vert(v, r2 * c[1], r2 * s[1], -width * 0.5, normal);
144
145 v = vert(v, r1 * c[0], r1 * s[0], width * 0.5, normal);
146
147 v = vert(v, r1 * c[0], r1 * s[0], width * 0.5, normal);
148 v = vert(v, r1 * c[0], r1 * s[0], -width * 0.5, normal);
149 v = vert(v, r2 * c[1], r2 * s[1], width * 0.5, normal);
150 v = vert(v, r2 * c[1], r2 * s[1], -width * 0.5, normal);
151 v = vert(v, r2 * c[2], r2 * s[2], width * 0.5, normal);
152 v = vert(v, r2 * c[2], r2 * s[2], -width * 0.5, normal);
153 v = vert(v, r1 * c[3], r1 * s[3], width * 0.5, normal);
154 v = vert(v, r1 * c[3], r1 * s[3], -width * 0.5, normal);
155 v = vert(v, r1 * c[4], r1 * s[4], width * 0.5, normal);
156 v = vert(v, r1 * c[4], r1 * s[4], -width * 0.5, normal);
157
158 v = vert(v, r1 * c[4], r1 * s[4], -width * 0.5, normal);
159 }
160
161 gear->count = (v - gear->vertices) / 6;
162
163 gl->glGenBuffers(1, &gear->vbo);
164 gl->glBindBuffer(GL_ARRAY_BUFFER, gear->vbo);
165 gl->glBufferData(GL_ARRAY_BUFFER, gear->count * 6 * 4, gear->vertices, GL_STATIC_DRAW);
166
167
168 return gear;
169}
170
171static void free_gear(Gear *gear)
172{
173 free(gear->vertices);
174 free(gear);
175 gear = NULL;
176}
177
178static void multiply(GLfloat *m, const GLfloat *n)
179{
180 GLfloat tmp[16];
181 const GLfloat *row, *column;
182 div_t d;
183 int i, j;
184
185 for (i = 0; i < 16; i++)
186 {
187 tmp[i] = 0;
188 d = div(i, 4);
189 row = n + d.quot * 4;
190 column = m + d.rem;
191 for (j = 0; j < 4; j++)
192 tmp[i] += row[j] * column[j * 4];
193 }
194 memcpy(m, &tmp, sizeof tmp);
195}
196
197static void rotate(GLfloat *m, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
198{
199 double s, c;
200
201 s = sin(angle);
202 c = cos(angle);
203 GLfloat r[16] =
204 {
205 x * x * (1 - c) + c, y * x * (1 - c) + z * s, x * z * (1 - c) - y * s, 0,
206 x * y * (1 - c) - z * s, y * y * (1 - c) + c, y * z * (1 - c) + x * s, 0,
207 x * z * (1 - c) + y * s, y * z * (1 - c) - x * s, z * z * (1 - c) + c, 0,
208 0, 0, 0, 1
209 };
210
211 multiply(m, r);
212}
213
214static void translate(GLfloat *m, GLfloat x, GLfloat y, GLfloat z)
215{
216 GLfloat t[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 };
217
218 multiply(m, t);
219}
220
221static void draw_gear(GLData *gld, Gear *gear, GLfloat *m, GLfloat x, GLfloat y, GLfloat angle, const GLfloat *color)
222{
223 Evas_GL_API *gl = gld->glApi;
224 GLfloat tmp[16];
225
226 memcpy(tmp, m, sizeof tmp);
227 translate(tmp, x, y, 0);
228 rotate(tmp, 2 * M_PI * angle / 360.0, 0, 0, 1);
229 gl->glUniformMatrix4fv(gld->proj_location, 1, GL_FALSE, tmp);
230 gl->glUniform3fv(gld->light_location, 1, gld->light);
231 gl->glUniform4fv(gld->color_location, 1, color);
232
233 gl->glBindBuffer(GL_ARRAY_BUFFER, gear->vbo);
234
235 gl->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), NULL);
236 gl->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLfloat *) 0 + 3);
237 gl->glEnableVertexAttribArray(0);
238 gl->glEnableVertexAttribArray(1);
239 gl->glDrawArrays(GL_TRIANGLE_STRIP, 0, gear->count);
240}
241#endif
242 6
243 7
244static void gldata_init(GLData *gld) 8static void gldata_init(GLData *gld)
@@ -259,318 +23,6 @@ static void gldata_init(GLData *gld)
259//-------------------------// 23//-------------------------//
260 24
261 25
262#if DO_GEARS
263static const char vertex_shader[] =
264 "uniform mat4 proj;\n"
265 "attribute vec4 position;\n"
266 "attribute vec4 normal;\n"
267 "varying vec3 rotated_normal;\n"
268 "varying vec3 rotated_position;\n"
269 "vec4 tmp;\n"
270 "void main()\n"
271 "{\n"
272 " gl_Position = proj * position;\n"
273 " rotated_position = gl_Position.xyz;\n"
274 " tmp = proj * normal;\n"
275 " rotated_normal = tmp.xyz;\n"
276 "}\n";
277
278 static const char fragment_shader[] =
279 "#ifdef GL_ES\n"
280 "precision mediump float;\n"
281 "#endif\n"
282 "uniform vec4 color;\n"
283 "uniform vec3 light;\n"
284 "varying vec3 rotated_normal;\n"
285 "varying vec3 rotated_position;\n"
286 "vec3 light_direction;\n"
287 "vec4 white = vec4(0.5, 0.5, 0.5, 1.0);\n"
288 "void main()\n"
289 "{\n"
290 " light_direction = normalize(light - rotated_position);\n"
291 " gl_FragColor = color + white * dot(light_direction, rotated_normal);\n"
292 "}\n";
293
294static GLuint load_shader(GLData *gld, GLenum type, const char *shader_src)
295{
296 Evas_GL_API *gl = gld->glApi;
297 GLuint shader;
298 GLint compiled = 0;
299
300 // Create the shader object
301 if (!(shader = gl->glCreateShader(type))) return 0;
302 gl->glShaderSource(shader, 1, &shader_src, NULL);
303 // Compile the shader
304 gl->glCompileShader(shader);
305 gl->glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
306
307 if (!compiled)
308 {
309 GLint len = 0;
310
311 gl->glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
312 if (len > 1)
313 {
314 char *info = malloc(sizeof(char) * len);
315
316 if (info)
317 {
318 gl->glGetShaderInfoLog(shader, len, NULL, info);
319 printf("Error compiling shader:\n"
320 "%s\n", info);
321 free(info);
322 }
323 }
324 gl->glDeleteShader(shader);
325 return 0;
326 }
327 return shader;
328}
329
330static void gears_init(GLData *gld)
331{
332 Evas_GL_API *gl = gld->glApi;
333 GLint linked = 0;
334
335// char msg[512];
336
337 gl->glEnable(GL_CULL_FACE);
338 gl->glEnable(GL_DEPTH_TEST);
339 gl->glEnable(GL_BLEND);
340
341 // Load the vertex/fragment shaders
342 gld->vtx_shader = load_shader(gld, GL_VERTEX_SHADER, vertex_shader);
343 gld->fgmt_shader = load_shader(gld, GL_FRAGMENT_SHADER, fragment_shader);
344
345 // Create the program object
346 if (!(gld->program = gl->glCreateProgram()))
347 return;
348
349 gl->glAttachShader(gld->program, gld->vtx_shader);
350 gl->glAttachShader(gld->program, gld->fgmt_shader);
351
352 // Bind shader attributes.
353 gl->glBindAttribLocation(gld->program, 0, "position");
354 gl->glBindAttribLocation(gld->program, 1, "normal");
355
356 // Link the program
357 gl->glLinkProgram(gld->program);
358 gld->glApi->glGetProgramiv(gld->program, GL_LINK_STATUS, &linked);
359
360 if (!linked)
361 {
362 GLint len = 0;
363
364 gld->glApi->glGetProgramiv(gld->program, GL_INFO_LOG_LENGTH, &len);
365 if (len > 1)
366 {
367 char *info = malloc(sizeof(char) * len);
368
369 if (info)
370 {
371 gld->glApi->glGetProgramInfoLog(gld->program, len, NULL, info);
372 printf("Error linking program:\n%s\n", info);
373 free(info);
374 }
375 }
376 gld->glApi->glDeleteProgram(gld->program);
377 }
378
379 gl->glUseProgram(gld->program);
380 gld->proj_location = gl->glGetUniformLocation(gld->program, "proj");
381 gld->light_location = gl->glGetUniformLocation(gld->program, "light");
382 gld->color_location = gl->glGetUniformLocation(gld->program, "color");
383
384 /* make the gears */
385 gld->gear1 = make_gear(gld, 1.0, 4.0, 1.0, 20, 0.7);
386 gld->gear2 = make_gear(gld, 0.5, 2.0, 2.0, 10, 0.7);
387 gld->gear3 = make_gear(gld, 1.3, 2.0, 0.5, 10, 0.7);
388
389 gld->gearsInited = EINA_TRUE;
390}
391#endif
392
393static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
394{
395 GLData *gld = data;
396 Evas_Event_Key_Down *ev = event_info;
397
398 if (gld->move)
399 {
400 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
401
402 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
403 // TODO - make this a hash lookup dammit.
404 if (0 == strcmp(ev->key, "Escape"))
405 {
406 }
407 else if (0 == strcmp(ev->key, "Left"))
408 gld->move->r = 2.0;
409 else if (0 == strcmp(ev->key, "Right"))
410 gld->move->r = -2.0;
411 else if (0 == strcmp(ev->key, "Up"))
412 gld->move->x = 2.0;
413 else if (0 == strcmp(ev->key, "Down"))
414 gld->move->x = -2.0;
415// else if (0 == strcmp(ev->key, "Prior"))
416// ;
417// else if (0 == strcmp(ev->key, "Next"))
418// ;
419// else if (0 == strcmp(ev->key, "Home"))
420// ;
421// else if (0 == strcmp(ev->key, "End"))
422// ;
423 else if (0 == strcmp(ev->key, "space"))
424 gld->move->jump = 1.0;
425 else
426 printf("Unexpected down keystroke - %s\n", ev->key);
427 }
428 else
429 printf("Camera input not ready\n");
430}
431
432/* SL / OS camera controls
433 up / down / w / s moves avatar forward / backward
434 shifted version does the same
435 double tap triggers run mode / or fast fly mode
436 Running backwards turns your avatar to suit, walking does not.
437 left / right / a / d rotates avatar left / right, strafes in mouselook
438 shifted version turns the avatar to walk sideways, so not really a strafe.
439 So not sure if the "strafe" in mouse look turns the avatar as well?
440 PgDn / c crouch while it is held down move up in flight mode
441 PgUp jump move down in flight mode
442 Home toggle flying
443 End Nothing?
444 Esc return to third person view
445 m toggle mouse look
446 mouse wheel move view closer / further away from current focused object or avatar
447 Alt left click focus on some other object
448 Ins ???
449 Del ???
450 BS ???
451 Tab ???
452
453 Mouse look is just first person view, moving mouse looks left / right / up / down.
454 Not sure if the avatar rotates with left / right, but that's likely.
455
456 mouse moves With the left mouse button held down -
457 left / right up / down
458 ---------------------------------
459 for avatar swings avatar around zoom in and out of avatar
460 for object nothing
461 alt orbit left / right zoom in and out
462 alt ctrl orbit left / right orbit up / down
463 alt shift orbit left / right zoom in and out
464 alt ctrl shift shift view left / right / up / down
465 ctrl Nothing?
466 shift Nothing?
467 ctrl shift Nothing?
468
469 Need to also consider when looking at a moving object / avatar.
470
471 I think there are other letter keys that duplicate arrow keys and such. I'll look for them later, but I don't use them.
472 No idea what the function keys are mapped to, but think it's various non camera stuff.
473 I'm damn well leaving the Win/Command and Menu keys for the OS / window manager. lol
474 Keypad keys? Not interested, I don't have them.
475 Print Screen / SysRq, Pause / Break, other oddball keys, also not interested.
476 NOTE - gonna have an easily programmable "bind key to command" thingy, like E17s, so that can deal with other keys.
477 Should even let them be saveable so people can swap them with other people easily.
478
479 TODO - implement things like space mouse, sixaxis, phone as controller, joysticks, data gloves, etc.
480*/
481
482/* A moveRotate array of floats.
483 * X, Y, Z, and whatever the usual letters are for rotations. lol
484 * Each one means "move or rotate this much in this direction".
485 * Where 1.0 means "what ever the standard move is if that key is held down".
486 * So a keyboard move would just change it's part to 1.0 or -1.0 on key down,
487 * and back to 0.0 on key up. Or 2.0 / -2.0 if in run mode.
488 * Which would even work in fly mode.
489 * A joystick could be set to range over -2.0 to 2.0, and just set it's part directly.
490 * A mouse look rotate, well will come to that when we need to. B-)
491 * Setting the x or y to be the DIFFERENCE in window position of the mouse (-1.0 to 1.0) since the last frame.
492 *
493 * TODO - In the Elm_glview version, 2.0 seems to be correct speed for walking, but I thought 1.0 was in Evas_GL.
494 */
495
496static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
497{
498 GLData *gld = data;
499 Evas_Event_Key_Up *ev = event_info;
500
501 if (gld->move)
502 {
503 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
504
505 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
506 // TODO - make this a hash lookup dammit.
507 if (0 == strcmp(ev->key, "Escape"))
508 {
509 }
510 else if (0 == strcmp(ev->key, "Left"))
511 gld->move->r = 0.0;
512 else if (0 == strcmp(ev->key, "Right"))
513 gld->move->r = 0.0;
514 else if (0 == strcmp(ev->key, "Up"))
515 gld->move->x = 0.0;
516 else if (0 == strcmp(ev->key, "Down"))
517 gld->move->x = 0.0;
518// else if (0 == strcmp(ev->key, "Prior"))
519// ;
520// else if (0 == strcmp(ev->key, "Next"))
521// ;
522// else if (0 == strcmp(ev->key, "Home"))
523// ;
524// else if (0 == strcmp(ev->key, "End"))
525// ;
526 else if (0 == strcmp(ev->key, "space"))
527 gld->move->jump = 0.0;
528 else
529 printf("Unexpected up keystroke - %s\n", ev->key);
530 }
531 else
532 printf("Camera input not ready\n");
533}
534
535// Elm style event callback.
536static Eina_Bool _cb_event_GL(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info)
537{
538 GLData *gld = data;
539 Eina_Bool processed = EINA_FALSE;
540
541 switch (type)
542 {
543 case EVAS_CALLBACK_KEY_DOWN :
544 {
545 _on_camera_input_down(gld, evas_object_evas_get(obj), obj, event_info);
546 processed = EINA_TRUE;
547 break;
548 }
549
550 case EVAS_CALLBACK_KEY_UP :
551 {
552 _on_camera_input_up(gld, evas_object_evas_get(obj), obj, event_info);
553 processed = EINA_TRUE;
554 break;
555 }
556
557 default :
558 printf("Unknown GL input event.\n");
559 }
560
561 return processed;
562}
563
564// Elm inlined image windows needs this to change focus on mouse click.
565// Evas style event callback.
566static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info)
567{
568// GLData *gld = data;
569 Evas_Event_Mouse_Down *ev = event_info;
570
571 if (1 == ev->button)
572 elm_object_focus_set(obj, EINA_TRUE);
573}
574 26
575static void _resize_winwin(GLData *gld) 27static void _resize_winwin(GLData *gld)
576{ 28{
@@ -673,29 +125,7 @@ static void on_pixels(void *data, Evas_Object *obj)
673 125
674#if DO_GEARS 126#if DO_GEARS
675 if (gld->useEGL) 127 if (gld->useEGL)
676 { 128 drawGears(gld);
677 static const GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
678 static const GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
679 static const GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
680 GLfloat m[16];
681
682 // Draw the gears.
683 if (!gld->useIrr)
684 {
685 gl->glClearColor(0.7, 0.0, 1.0, 1.0);
686 gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
687 }
688
689 memcpy(m, gld->proj, sizeof m);
690 rotate(m, 2 * M_PI * gld->view_rotx / 360.0, 1, 0, 0);
691 rotate(m, 2 * M_PI * gld->view_roty / 360.0, 0, 1, 0);
692 rotate(m, 2 * M_PI * gld->view_rotz / 360.0, 0, 0, 1);
693
694 draw_gear(gld, gld->gear1, m, -3.0, -2.0, gld->angle, red);
695 draw_gear(gld, gld->gear2, m, 3.1, -2.0, -2 * gld->angle - 9.0, green);
696 draw_gear(gld, gld->gear3, m, -3.1, 4.2, -2 * gld->angle - 25.0, blue);
697 gld->angle += 2.0;
698 }
699#endif 129#endif
700 130
701 drawIrr_end(gld); 131 drawIrr_end(gld);
@@ -927,180 +357,6 @@ static void init_evas_gl(GLData *gld)
927//-------------------------// 357//-------------------------//
928 358
929 359
930static Evas_Object *_content_image_new(Evas_Object *parent, const char *img)
931{
932 Evas_Object *ic;
933
934 ic = elm_icon_add(parent);
935 elm_image_file_set(ic, img, NULL);
936 return ic;
937}
938
939static void _promote(void *data, Evas_Object *obj , void *event_info )
940{
941 elm_naviframe_item_promote(data);
942}
943
944static char *_grid_label_get(void *data, Evas_Object *obj, const char *part)
945{
946 ezGrid *thisGrid = data;
947 char buf[256];
948
949 if (!strcmp(part, "elm.text"))
950 {
951 int count = eina_clist_count(&(thisGrid->accounts));
952
953 if (0 == count)
954 snprintf(buf, sizeof(buf), "%s (no accounts)", thisGrid->name);
955 else if (1 == count)
956 snprintf(buf, sizeof(buf), "%s (%d account)", thisGrid->name, count);
957 else
958 snprintf(buf, sizeof(buf), "%s (%d accounts)", thisGrid->name, count);
959 }
960 else
961 snprintf(buf, sizeof(buf), "%s", thisGrid->loginURI);
962 return strdup(buf);
963}
964
965static Evas_Object *_grid_content_get(void *data, Evas_Object *obj, const char *part)
966{
967 ezGrid *thisGrid = data;
968 Evas_Object *ic = elm_icon_add(obj);
969
970 if (!strcmp(part, "elm.swallow.icon"))
971 elm_icon_standard_set(ic, thisGrid->icon);
972
973 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
974 return ic;
975}
976
977static char * _account_label_get(void *data, Evas_Object *obj, const char *part)
978{
979 ezAccount *thisAccount = data;
980 char buf[256];
981
982 buf[0] = '\0';
983 if (!strcmp(part, "elm.text"))
984 snprintf(buf, sizeof(buf), "%s", thisAccount->name);
985
986 return strdup(buf);
987}
988
989static Evas_Object *_account_content_get(void *data, Evas_Object *obj, const char *part)
990{
991 ezAccount *thisAccount = data;
992 Evas_Object *ic = elm_icon_add(obj);
993
994 if (!strcmp(part, "elm.swallow.icon"))
995 elm_icon_standard_set(ic, thisAccount->icon);
996
997 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
998 return ic;
999}
1000
1001static char *_viewer_label_get(void *data, Evas_Object *obj, const char *part)
1002{
1003 ezViewer *thisViewer = data;
1004 char buf[256];
1005
1006 if (!strcmp(part, "elm.text"))
1007 snprintf(buf, sizeof(buf), "%s", thisViewer->name);
1008 else
1009 snprintf(buf, sizeof(buf), "%s", thisViewer->version);
1010 return strdup(buf);
1011}
1012
1013static Evas_Object *_viewer_content_get(void *data, Evas_Object *obj, const char *part)
1014{
1015 ezViewer *thisViewer = data;
1016 Evas_Object *ic = elm_icon_add(obj);
1017
1018 if (!strcmp(part, "elm.swallow.icon"))
1019 elm_icon_standard_set(ic, thisViewer->icon);
1020
1021 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1022 return ic;
1023}
1024
1025
1026static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info)
1027{
1028 ezGrid *thisGrid = data;
1029 GLData *gld = thisGrid->gld;
1030 char buf[PATH_MAX];
1031
1032// sprintf(buf, "dillo -f -g '%dx%d+%d+%d' %s &", gld->win_w - (gld->win_w / 5), gld->win_h - 30, gld->win_w / 5, gld->win_y, thisGrid->splashPage);
1033 sprintf(buf, "uzbl -g '%dx%d+%d+%d' -u %s &", gld->win_w - (gld->win_w / 5), gld->win_h - 30, gld->win_w / 5, gld->win_y, thisGrid->splashPage);
1034 printf("%s ### genlist obj [%p], item pointer [%p]\n", buf, obj, event_info);
1035// comment this out for now, busy dealing with input stuff, don't want to trigger this multiple times.
1036// system(buf);
1037}
1038
1039static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1040{
1041 Evas_Event_Mouse_Move *ev = event_info;
1042 Evas_Object *orig = data;
1043 Evas_Coord x, y;
1044 Evas_Map *p;
1045 int i, w, h;
1046
1047 if (!ev->buttons) return;
1048 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1049 evas_object_move(obj,
1050 x + (ev->cur.canvas.x - ev->prev.output.x),
1051 y + (ev->cur.canvas.y - ev->prev.output.y));
1052 evas_object_image_size_get(orig, &w, &h);
1053 p = evas_map_new(4);
1054 evas_object_map_enable_set(orig, EINA_TRUE);
1055// evas_object_raise(orig);
1056 for (i = 0; i < 4; i++)
1057 {
1058 Evas_Object *hand;
1059 char key[32];
1060
1061 snprintf(key, sizeof(key), "h-%i\n", i);
1062 hand = evas_object_data_get(orig, key);
1063 evas_object_raise(hand);
1064 evas_object_geometry_get(hand, &x, &y, NULL, NULL);
1065 x += 15;
1066 y += 15;
1067 evas_map_point_coord_set(p, i, x, y, 0);
1068 if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0);
1069 else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0);
1070 else if (i == 2) evas_map_point_image_uv_set(p, i, w, h);
1071 else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h);
1072 }
1073 evas_object_map_set(orig, p);
1074 evas_map_free(p);
1075}
1076
1077static void create_handles(Evas_Object *obj)
1078{
1079 int i;
1080 Evas_Coord x, y, w, h;
1081
1082 evas_object_geometry_get(obj, &x, &y, &w, &h);
1083 for (i = 0; i < 4; i++)
1084 {
1085 Evas_Object *hand;
1086 char buf[PATH_MAX];
1087 char key[32];
1088
1089 hand = evas_object_image_filled_add(evas_object_evas_get(obj));
1090 evas_object_resize(hand, 31, 31);
1091 snprintf(buf, sizeof(buf), "%s/media/pt.png", elm_app_data_dir_get());
1092 evas_object_image_file_set(hand, buf, NULL);
1093 if (i == 0) evas_object_move(hand, x - 15, y - 15);
1094 else if (i == 1) evas_object_move(hand, x + w - 15, y - 15);
1095 else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15);
1096 else if (i == 3) evas_object_move(hand, x - 15, y + h - 15);
1097 evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
1098 evas_object_show(hand);
1099 snprintf(key, sizeof(key), "h-%i\n", i);
1100 evas_object_data_set(obj, key, hand);
1101 }
1102}
1103
1104static Evas_Object *_toolbar_menu_add(Evas_Object *win, Evas_Object *tb, char *label) 360static Evas_Object *_toolbar_menu_add(Evas_Object *win, Evas_Object *tb, char *label)
1105{ 361{
1106 Evas_Object *menu= NULL; 362 Evas_Object *menu= NULL;
@@ -1117,283 +373,14 @@ static Evas_Object *_toolbar_menu_add(Evas_Object *win, Evas_Object *tb, char *l
1117 return menu; 373 return menu;
1118} 374}
1119 375
1120static Evas_Object *fang_win_add(GLData *gld)
1121{
1122 Evas_Object *win, *bg;
1123
1124 // In theory this should create an EWS window, in practice, I'm not seeing any difference.
1125 // Guess I'll have to implement my own internal window manager. I don't think a basic one will be that hard. Famous last words.
1126// elm_config_engine_set("ews");
1127 win = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE);
1128 // On mouse down we try to shift focus to the backing image, this seems to be the correct thing to force focus onto it's widgets.
1129 // According to the Elm inlined image window example, this is what's needed to.
1130 evas_object_event_callback_add(elm_win_inlined_image_object_get(win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld);
1131 elm_win_alpha_set(win, EINA_TRUE);
1132
1133 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
1134 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
1135 bg = evas_object_rectangle_add(evas_object_evas_get(win));
1136 evas_object_color_set(bg, 50, 0, 100, 100);
1137 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1138 elm_win_resize_object_add(win, bg);
1139 evas_object_show(bg);
1140
1141 return win;
1142}
1143
1144static void fang_win_complete(GLData *gld, Evas_Object *win, int x, int y, int w, int h)
1145{
1146 // image object for win is unlinked to its pos/size - so manual control
1147 // this allows also for using map and other things with it.
1148 evas_object_move(elm_win_inlined_image_object_get(win), x, y);
1149 // Odd, it needs to be resized twice. WTF?
1150 evas_object_resize(win, w, h);
1151 evas_object_resize(elm_win_inlined_image_object_get(win), w, h);
1152 evas_object_show(win);
1153 create_handles(elm_win_inlined_image_object_get(win));
1154}
1155
1156static void overlay_add(GLData *gld)
1157{
1158 Evas_Object *bg;
1159//, *bx, *tb, *menu;
1160// Elm_Object_Item *tb_it, *menu_it;
1161
1162 // There many are reasons for this window.
1163 // The first is to cover the GL and provide something to click on to change focus.
1164 // The second is to provide something to click on for all the GL type clicking stuff that needs to be done. In other words, no click through,we catch the clicks here.
1165 // So we can probably avoid the following issue -
1166 // How to do click through? evas_object_pass_events_set(rectangle, EINA_TRUE), and maybe need to do that to the underlaying window to?
1167 // Though if the rectangle is entirely transparent, or even hidden, events might pass through anyway.
1168 // Gotta have click through on the parts where there's no other window.
1169 // The third is to have the other windows live here.
1170 // This idea doesn't work, as it breaks the damn focus again.
1171 // Don't think it's needed anyway.
1172 // While on the subject of layers, need a HUD layer of some sort, but Irrlicht might support that itself.
1173
1174 gld->winwin = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE);
1175 // On mouse down we try to shift focus to the backing image, this seems to be the correct thing to force focus onto it's widgets.
1176 // According to the Elm inlined image window example, this is what's needed to.
1177 evas_object_event_callback_add(elm_win_inlined_image_object_get(gld->winwin), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld);
1178 // In this code, we are making our own camera, so grab it's input when we are focused.
1179 evas_object_event_callback_add(gld->winwin, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld);
1180 evas_object_event_callback_add(gld->winwin, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld);
1181 elm_object_event_callback_add(gld->winwin, _cb_event_GL, gld);
1182
1183 elm_win_alpha_set(gld->winwin, EINA_TRUE);
1184 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
1185 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
1186 bg = evas_object_rectangle_add(evas_object_evas_get(gld->winwin));
1187 evas_object_color_set(bg, 0, 0, 0, 0);
1188 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1189 elm_win_resize_object_add(gld->winwin, bg);
1190 evas_object_show(bg);
1191
1192 // image object for win is unlinked to its pos/size - so manual control
1193 // this allows also for using map and other things with it.
1194 evas_object_move(elm_win_inlined_image_object_get(gld->winwin), 0, 0);
1195 // Odd, it needs to be resized twice. WTF?
1196 evas_object_resize(gld->winwin, gld->win_w, gld->win_h);
1197 evas_object_resize(elm_win_inlined_image_object_get(gld->winwin), gld->win_w, gld->win_h);
1198 evas_object_show(gld->winwin);
1199}
1200
1201static void chat_add(GLData *gld)
1202{
1203 Evas_Object *win, *bx, *en;
1204
1205 win = fang_win_add(gld);
1206
1207 bx = elm_box_add(win);
1208 elm_win_resize_object_add(win, bx);
1209 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1210 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1211
1212 en = elm_entry_add(win);
1213 elm_entry_scrollable_set(en, EINA_TRUE);
1214 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1215 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
1216 elm_object_text_set(en, "History is shown here");
1217 elm_entry_editable_set(en, EINA_FALSE);
1218 evas_object_show(en);
1219 elm_box_pack_end(bx, en);
1220
1221 en = elm_entry_add(win);
1222 elm_entry_scrollable_set(en, EINA_TRUE);
1223 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1224 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
1225 elm_object_text_set(en, "");
1226 elm_entry_editable_set(en, EINA_TRUE);
1227 evas_object_show(en);
1228 elm_box_pack_end(bx, en);
1229
1230 evas_object_show(bx);
1231
1232 fang_win_complete(gld, win, 30, 500, gld->win_w / 3, gld->win_h / 3);
1233}
1234
1235
1236static void woMan_add(GLData *gld)
1237{
1238// Evas_Object *win, *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu;
1239 Evas_Object *win, *bx, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu;
1240 Elm_Object_Item *tb_it, *menu_it, *tab_it;
1241 char buf[PATH_MAX];
1242 int i;
1243
1244 win = fang_win_add(gld);
1245
1246 bx = elm_box_add(win);
1247 elm_win_resize_object_add(win, bx);
1248 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1249 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1250
1251 // A tab thingy.
1252 tb = elm_toolbar_add(win);
1253 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
1254 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
1255 elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
1256
1257 // Menu.
1258 tb_it = elm_toolbar_item_append(tb, NULL, "Menu", NULL, NULL);
1259 elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
1260 // Priority is for when toolbar items are set to hide or menu when there are too many of them. They get hidden or put on the menu based on priority.
1261 elm_toolbar_item_priority_set(tb_it, 9999);
1262 elm_toolbar_menu_parent_set(tb, win);
1263 menu = elm_toolbar_item_menu_get(tb_it);
1264
1265 menu_it = elm_menu_item_add(menu, NULL, NULL, "edit", NULL, NULL);
1266 elm_menu_item_add(menu, menu_it, NULL, "preferences", NULL, NULL);
1267 menu_it = elm_menu_item_add(menu, NULL, NULL, "help", NULL, NULL);
1268 elm_menu_item_add(menu, menu_it, NULL, "about woMan", NULL, NULL);
1269 elm_menu_item_separator_add(menu, NULL);
1270 menu_it = elm_menu_item_add(menu, NULL, NULL, "advanced", NULL, NULL);
1271 elm_menu_item_add(menu, menu_it, NULL, "debug settings", NULL, NULL);
1272
1273 // The toolbar needs to be packed into the box AFTER the menus are added.
1274 elm_box_pack_end(bx, tb);
1275 evas_object_show(tb);
1276
1277 gridList = elm_genlist_add(win);
1278 grids = eina_hash_stringshared_new(free);
1279
1280 grid_gic = elm_genlist_item_class_new();
1281 grid_gic->item_style = "double_label";
1282 grid_gic->func.text_get = _grid_label_get;
1283 grid_gic->func.content_get = _grid_content_get;
1284 grid_gic->func.state_get = NULL;
1285 grid_gic->func.del = NULL;
1286 for (i = 0; NULL != gridTest[i][0]; i++)
1287 {
1288 ezGrid *thisGrid = calloc(1, sizeof(ezGrid));
1289
1290 if (thisGrid)
1291 {
1292 eina_clist_init(&(thisGrid->accounts));
1293 eina_clist_init(&(thisGrid->landmarks));
1294 thisGrid->name = gridTest[i][0];
1295 thisGrid->loginURI = gridTest[i][1];
1296 thisGrid->splashPage = gridTest[i][2];
1297 thisGrid->icon = "folder";
1298 thisGrid->gld = gld;
1299 thisGrid->item = elm_genlist_item_append(gridList, grid_gic, thisGrid, NULL, ELM_GENLIST_ITEM_TREE, _grid_sel_cb, thisGrid);
1300 eina_hash_add(grids, thisGrid->name, thisGrid);
1301 }
1302 }
1303
1304 account_gic = elm_genlist_item_class_new();
1305 account_gic->item_style = "default";
1306 account_gic->func.text_get = _account_label_get;
1307 account_gic->func.content_get = _account_content_get;
1308 account_gic->func.state_get = NULL;
1309 account_gic->func.del = NULL;
1310 for (i = 0; NULL != accountTest[i][0]; i++)
1311 {
1312 ezAccount *thisAccount = calloc(1, sizeof(ezAccount));
1313 ezGrid *grid = eina_hash_find(grids, accountTest[i][0]);
1314
1315 if (thisAccount && grid)
1316 {
1317 thisAccount->name = accountTest[i][1];
1318 thisAccount->password = accountTest[i][2];
1319 thisAccount->icon = "file";
1320 elm_genlist_item_append(gridList, account_gic, thisAccount, grid->item, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1321 eina_clist_add_tail(&(grid->accounts), &(thisAccount->grid));
1322 }
1323 }
1324
1325 // Viewers stuff
1326 viewerList = elm_genlist_add(win);
1327 viewer_gic = elm_genlist_item_class_new();
1328 viewer_gic->item_style = "double_label";
1329 viewer_gic->func.text_get = _viewer_label_get;
1330 viewer_gic->func.content_get = _viewer_content_get;
1331 viewer_gic->func.state_get = NULL;
1332 viewer_gic->func.del = NULL;
1333 for (i = 0; NULL != viewerTest[i][0]; i++)
1334 {
1335 ezViewer *thisViewer = calloc(1, sizeof(ezViewer));
1336
1337 if (thisViewer)
1338 {
1339 thisViewer->name = viewerTest[i][0];
1340 thisViewer->version = viewerTest[i][1];
1341 thisViewer->path = viewerTest[i][2];
1342 thisViewer->icon = "file";
1343 thisViewer->item = elm_genlist_item_append(viewerList, viewer_gic, thisViewer, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1344 }
1345 }
1346
1347 // Toolbar pages
1348 nf = elm_naviframe_add(win);
1349 evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1350 evas_object_size_hint_align_set(nf, EVAS_HINT_FILL, EVAS_HINT_FILL);
1351 evas_object_show(nf);
1352
1353 sprintf(buf, "%s/%s", elm_app_data_dir_get(), img3);
1354 tab = viewerList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Viewers", _promote, tab_it);
1355 tab = _content_image_new(win, strdup(buf)); tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Landmarks", _promote, tab_it);
1356 tab = gridList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Grids", _promote, tab_it);
1357 elm_box_pack_end(bx, nf);
1358
1359#if USE_EO
1360 // Not ready for prime time yet, or I'm missing a step. Causes it to hang after closing the window.
1361 // Slightly better now, it bitches instead of hanging.
1362 bt = eo_add(ELM_OBJ_BUTTON_CLASS, win);
1363 elm_object_text_set(bt, "Login"); // No eo interface for this that I can find.
1364 eo_do(bt,
1365// evas_obj_text_set("Login"),
1366 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL),
1367 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0),
1368 evas_obj_visibility_set(EINA_TRUE)
1369 );
1370#else
1371 bt = elm_button_add(win);
1372 elm_object_text_set(bt, "Login");
1373 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1374 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1375 evas_object_show(bt);
1376#endif
1377// evas_object_smart_callback_add(bt, "clicked", NULL, NULL);
1378 elm_box_pack_end(bx, bt);
1379 evas_object_show(bx);
1380
1381 fang_win_complete(gld, win, 30, 30, gld->win_w / 3, gld->win_h / 3);
1382}
1383 376
1384EAPI_MAIN int elm_main(int argc, char **argv) 377EAPI_MAIN int elm_main(int argc, char **argv)
1385{ 378{
1386// Evas_Object *bg, *menu, *bt, *tb;
1387 Evas_Object *obj, *menu, *tb; 379 Evas_Object *obj, *menu, *tb;
1388 Elm_Object_Item *tb_it; 380 Elm_Object_Item *tb_it;
1389//, *menu_it;
1390 EPhysics_Body *boundary;
1391 EPhysics_World *world; 381 EPhysics_World *world;
1392 EPhysics_Body *box_body1, *box_body2;
1393 Evas_Object *box1, *box2;
1394 GLData *gld = NULL; 382 GLData *gld = NULL;
1395 char buf[PATH_MAX]; 383 char buf[PATH_MAX];
1396// int i;
1397// Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't. 384// Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't.
1398 385
1399 HamrTime(elm_main, "extantz"); 386 HamrTime(elm_main, "extantz");
@@ -1433,7 +420,6 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1433 return 1; 420 return 1;
1434#endif 421#endif
1435 422
1436// elm_win_title_set(gld->win, "extantz virtual world manager");
1437 evas_object_smart_callback_add(gld->win, "delete,request", _on_done, gld); 423 evas_object_smart_callback_add(gld->win, "delete,request", _on_done, gld);
1438 424
1439 // Get the screen size. 425 // Get the screen size.
@@ -1467,7 +453,8 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1467 453
1468 overlay_add(gld); 454 overlay_add(gld);
1469 woMan_add(gld); 455 woMan_add(gld);
1470 chat_add(gld); 456 // TODO - This is what causes it to hang after quitting. Fix it.
457// chat_add(gld);
1471 458
1472 // Gotta do this after adding the windows, otherwise the menu renders under the window. 459 // Gotta do this after adding the windows, otherwise the menu renders under the window.
1473 // This sucks, gotta redefine this menu each time we create a new window? 460 // This sucks, gotta redefine this menu each time we create a new window?
@@ -1526,55 +513,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1526 513
1527#if USE_PHYSICS 514#if USE_PHYSICS
1528 // ePhysics stuff. 515 // ePhysics stuff.
1529 world = ephysics_world_new(); 516 world = ephysicsAdd(gld);
1530 ephysics_world_render_geometry_set(world, 0, 0, -50, gld->win_w, gld->win_h, 100);
1531
1532 boundary = ephysics_body_bottom_boundary_add(world);
1533 ephysics_body_restitution_set(boundary, 1);
1534 ephysics_body_friction_set(boundary, 0);
1535
1536 boundary = ephysics_body_top_boundary_add(world);
1537 ephysics_body_restitution_set(boundary, 1);
1538 ephysics_body_friction_set(boundary, 0);
1539
1540 boundary = ephysics_body_left_boundary_add(world);
1541 ephysics_body_restitution_set(boundary, 1);
1542 ephysics_body_friction_set(boundary, 0);
1543
1544 boundary = ephysics_body_right_boundary_add(world);
1545 ephysics_body_restitution_set(boundary, 1);
1546 ephysics_body_friction_set(boundary, 0);
1547
1548 box1 = elm_image_add(gld->win);
1549 sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME);
1550 elm_image_file_set(box1, strdup(buf), "blue-cube");
1551 evas_object_move(box1, gld->win_w / 2 - 80, gld->win_h - 200);
1552 evas_object_resize(box1, 70, 70);
1553 evas_object_show(box1);
1554
1555 box_body1 = ephysics_body_box_add(world);
1556 ephysics_body_evas_object_set(box_body1, box1, EINA_TRUE);
1557 ephysics_body_restitution_set(box_body1, 0.7);
1558 ephysics_body_friction_set(box_body1, 0);
1559 ephysics_body_linear_velocity_set(box_body1, -150, 200, 0);
1560 ephysics_body_angular_velocity_set(box_body1, 0, 0, 36);
1561 ephysics_body_sleeping_threshold_set(box_body1, 0.1, 0.1);
1562
1563 box2 = elm_image_add(gld->win);
1564 elm_image_file_set(box2, strdup(buf), "purple-cube");
1565 evas_object_move(box2, gld->win_w / 2 + 10, gld->win_h - 200);
1566 evas_object_resize(box2, 70, 70);
1567 evas_object_show(box2);
1568
1569 box_body2 = ephysics_body_box_add(world);
1570 ephysics_body_evas_object_set(box_body2, box2, EINA_TRUE);
1571 ephysics_body_restitution_set(box_body2, 0.7);
1572 ephysics_body_friction_set(box_body2, 0);
1573 ephysics_body_linear_velocity_set(box_body2, 80, -60, 0);
1574 ephysics_body_angular_velocity_set(box_body2, 0, 0, 360);
1575 ephysics_body_sleeping_threshold_set(box_body2, 0.1, 0.1);
1576
1577 ephysics_world_gravity_set(world, 0, 0, 0);
1578#endif 517#endif
1579 518
1580 evas_object_move(gld->win, gld->win_x, gld->win_y); 519 evas_object_move(gld->win, gld->win_x, gld->win_y);
diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h
index ba30405..6e0e03e 100644
--- a/src/extantz/extantz.h
+++ b/src/extantz/extantz.h
@@ -1,5 +1,5 @@
1#define USE_EO 0 1#define USE_EO 0
2#define USE_PHYSICS 0 2#define USE_PHYSICS 1
3#define USE_EGL 1 // If using Evas_GL, though it might be via Elm. 3#define USE_EGL 1 // If using Evas_GL, though it might be via Elm.
4#define USE_ELM_GL 1 4#define USE_ELM_GL 1
5#define USE_IRR 0 5#define USE_IRR 0
@@ -201,12 +201,27 @@ struct _GLData
201}; 201};
202 202
203 203
204void gears_init(GLData *gld);
205void drawGears(GLData *gld);
206void free_gear(Gear *gear);
207
208EPhysics_World *ephysicsAdd(GLData *gld);
209
204EAPI int startIrr(GLData *gld); 210EAPI int startIrr(GLData *gld);
205EAPI void drawIrr_start(GLData *gld); 211EAPI void drawIrr_start(GLData *gld);
206EAPI void drawIrr_end(GLData *gld); 212EAPI void drawIrr_end(GLData *gld);
207EAPI void finishIrr(GLData *gld); 213EAPI void finishIrr(GLData *gld);
214
208EAPI void Evas_3D_Demo_add(globals *ourGlobals); 215EAPI void Evas_3D_Demo_add(globals *ourGlobals);
209 216
217Evas_Object *fang_win_add(GLData *gld);
218void fang_win_complete(GLData *gld, Evas_Object *win, int x, int y, int w, int h);
219void overlay_add(GLData *gld);
220
221void chat_add(GLData *gld);
222void woMan_add(GLData *gld);
223
224
210#ifdef __cplusplus 225#ifdef __cplusplus
211} 226}
212#endif 227#endif
diff --git a/src/extantz/fangWin.c b/src/extantz/fangWin.c
new file mode 100644
index 0000000..7503fe0
--- /dev/null
+++ b/src/extantz/fangWin.c
@@ -0,0 +1,330 @@
1#include "extantz.h"
2
3
4static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
5{
6 GLData *gld = data;
7 Evas_Event_Key_Down *ev = event_info;
8
9 if (gld->move)
10 {
11 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
12
13 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
14 // TODO - make this a hash lookup dammit.
15 if (0 == strcmp(ev->key, "Escape"))
16 {
17 }
18 else if (0 == strcmp(ev->key, "Left"))
19 gld->move->r = 2.0;
20 else if (0 == strcmp(ev->key, "Right"))
21 gld->move->r = -2.0;
22 else if (0 == strcmp(ev->key, "Up"))
23 gld->move->x = 2.0;
24 else if (0 == strcmp(ev->key, "Down"))
25 gld->move->x = -2.0;
26// else if (0 == strcmp(ev->key, "Prior"))
27// ;
28// else if (0 == strcmp(ev->key, "Next"))
29// ;
30// else if (0 == strcmp(ev->key, "Home"))
31// ;
32// else if (0 == strcmp(ev->key, "End"))
33// ;
34 else if (0 == strcmp(ev->key, "space"))
35 gld->move->jump = 1.0;
36 else
37 printf("Unexpected down keystroke - %s\n", ev->key);
38 }
39 else
40 printf("Camera input not ready\n");
41}
42
43/* SL / OS camera controls
44 up / down / w / s moves avatar forward / backward
45 shifted version does the same
46 double tap triggers run mode / or fast fly mode
47 Running backwards turns your avatar to suit, walking does not.
48 left / right / a / d rotates avatar left / right, strafes in mouselook
49 shifted version turns the avatar to walk sideways, so not really a strafe.
50 So not sure if the "strafe" in mouse look turns the avatar as well?
51 PgDn / c crouch while it is held down move up in flight mode
52 PgUp jump move down in flight mode
53 Home toggle flying
54 End Nothing?
55 Esc return to third person view
56 m toggle mouse look
57 mouse wheel move view closer / further away from current focused object or avatar
58 Alt left click focus on some other object
59 Ins ???
60 Del ???
61 BS ???
62 Tab ???
63
64 Mouse look is just first person view, moving mouse looks left / right / up / down.
65 Not sure if the avatar rotates with left / right, but that's likely.
66
67 mouse moves With the left mouse button held down -
68 left / right up / down
69 ---------------------------------
70 for avatar swings avatar around zoom in and out of avatar
71 for object nothing
72 alt orbit left / right zoom in and out
73 alt ctrl orbit left / right orbit up / down
74 alt shift orbit left / right zoom in and out
75 alt ctrl shift shift view left / right / up / down
76 ctrl Nothing?
77 shift Nothing?
78 ctrl shift Nothing?
79
80 Need to also consider when looking at a moving object / avatar.
81
82 I think there are other letter keys that duplicate arrow keys and such. I'll look for them later, but I don't use them.
83 No idea what the function keys are mapped to, but think it's various non camera stuff.
84 I'm damn well leaving the Win/Command and Menu keys for the OS / window manager. lol
85 Keypad keys? Not interested, I don't have them.
86 Print Screen / SysRq, Pause / Break, other oddball keys, also not interested.
87 NOTE - gonna have an easily programmable "bind key to command" thingy, like E17s, so that can deal with other keys.
88 Should even let them be saveable so people can swap them with other people easily.
89
90 TODO - implement things like space mouse, sixaxis, phone as controller, joysticks, data gloves, etc.
91*/
92
93/* A moveRotate array of floats.
94 * X, Y, Z, and whatever the usual letters are for rotations. lol
95 * Each one means "move or rotate this much in this direction".
96 * Where 1.0 means "what ever the standard move is if that key is held down".
97 * So a keyboard move would just change it's part to 1.0 or -1.0 on key down,
98 * and back to 0.0 on key up. Or 2.0 / -2.0 if in run mode.
99 * Which would even work in fly mode.
100 * A joystick could be set to range over -2.0 to 2.0, and just set it's part directly.
101 * A mouse look rotate, well will come to that when we need to. B-)
102 * Setting the x or y to be the DIFFERENCE in window position of the mouse (-1.0 to 1.0) since the last frame.
103 *
104 * TODO - In the Elm_glview version, 2.0 seems to be correct speed for walking, but I thought 1.0 was in Evas_GL.
105 */
106
107static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
108{
109 GLData *gld = data;
110 Evas_Event_Key_Up *ev = event_info;
111
112 if (gld->move)
113 {
114 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
115
116 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
117 // TODO - make this a hash lookup dammit.
118 if (0 == strcmp(ev->key, "Escape"))
119 {
120 }
121 else if (0 == strcmp(ev->key, "Left"))
122 gld->move->r = 0.0;
123 else if (0 == strcmp(ev->key, "Right"))
124 gld->move->r = 0.0;
125 else if (0 == strcmp(ev->key, "Up"))
126 gld->move->x = 0.0;
127 else if (0 == strcmp(ev->key, "Down"))
128 gld->move->x = 0.0;
129// else if (0 == strcmp(ev->key, "Prior"))
130// ;
131// else if (0 == strcmp(ev->key, "Next"))
132// ;
133// else if (0 == strcmp(ev->key, "Home"))
134// ;
135// else if (0 == strcmp(ev->key, "End"))
136// ;
137 else if (0 == strcmp(ev->key, "space"))
138 gld->move->jump = 0.0;
139 else
140 printf("Unexpected up keystroke - %s\n", ev->key);
141 }
142 else
143 printf("Camera input not ready\n");
144}
145
146// Elm style event callback.
147static Eina_Bool _cb_event_GL(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info)
148{
149 GLData *gld = data;
150 Eina_Bool processed = EINA_FALSE;
151
152 switch (type)
153 {
154 case EVAS_CALLBACK_KEY_DOWN :
155 {
156 _on_camera_input_down(gld, evas_object_evas_get(obj), obj, event_info);
157 processed = EINA_TRUE;
158 break;
159 }
160
161 case EVAS_CALLBACK_KEY_UP :
162 {
163 _on_camera_input_up(gld, evas_object_evas_get(obj), obj, event_info);
164 processed = EINA_TRUE;
165 break;
166 }
167
168 default :
169 printf("Unknown GL input event.\n");
170 }
171
172 return processed;
173}
174
175// Elm inlined image windows needs this to change focus on mouse click.
176// Evas style event callback.
177static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info)
178{
179// GLData *gld = data;
180 Evas_Event_Mouse_Down *ev = event_info;
181
182 if (1 == ev->button)
183 elm_object_focus_set(obj, EINA_TRUE);
184}
185
186static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
187{
188 Evas_Event_Mouse_Move *ev = event_info;
189 Evas_Object *orig = data;
190 Evas_Coord x, y;
191 Evas_Map *p;
192 int i, w, h;
193
194 if (!ev->buttons) return;
195 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
196 evas_object_move(obj,
197 x + (ev->cur.canvas.x - ev->prev.output.x),
198 y + (ev->cur.canvas.y - ev->prev.output.y));
199 evas_object_image_size_get(orig, &w, &h);
200 p = evas_map_new(4);
201 evas_object_map_enable_set(orig, EINA_TRUE);
202// evas_object_raise(orig);
203 for (i = 0; i < 4; i++)
204 {
205 Evas_Object *hand;
206 char key[32];
207
208 snprintf(key, sizeof(key), "h-%i\n", i);
209 hand = evas_object_data_get(orig, key);
210 evas_object_raise(hand);
211 evas_object_geometry_get(hand, &x, &y, NULL, NULL);
212 x += 15;
213 y += 15;
214 evas_map_point_coord_set(p, i, x, y, 0);
215 if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0);
216 else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0);
217 else if (i == 2) evas_map_point_image_uv_set(p, i, w, h);
218 else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h);
219 }
220 evas_object_map_set(orig, p);
221 evas_map_free(p);
222}
223
224static void create_handles(Evas_Object *obj)
225{
226 int i;
227 Evas_Coord x, y, w, h;
228
229 evas_object_geometry_get(obj, &x, &y, &w, &h);
230 for (i = 0; i < 4; i++)
231 {
232 Evas_Object *hand;
233 char buf[PATH_MAX];
234 char key[32];
235
236 hand = evas_object_image_filled_add(evas_object_evas_get(obj));
237 evas_object_resize(hand, 31, 31);
238 snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get());
239 evas_object_image_file_set(hand, buf, NULL);
240 if (i == 0) evas_object_move(hand, x - 15, y - 15);
241 else if (i == 1) evas_object_move(hand, x + w - 15, y - 15);
242 else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15);
243 else if (i == 3) evas_object_move(hand, x - 15, y + h - 15);
244 evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
245 evas_object_show(hand);
246 snprintf(key, sizeof(key), "h-%i\n", i);
247 evas_object_data_set(obj, key, hand);
248 }
249}
250
251Evas_Object *fang_win_add(GLData *gld)
252{
253 Evas_Object *win, *bg;
254
255 // In theory this should create an EWS window, in practice, I'm not seeing any difference.
256 // Guess I'll have to implement my own internal window manager. I don't think a basic one will be that hard. Famous last words.
257// elm_config_engine_set("ews");
258 win = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE);
259 // On mouse down we try to shift focus to the backing image, this seems to be the correct thing to force focus onto it's widgets.
260 // According to the Elm inlined image window example, this is what's needed to.
261 evas_object_event_callback_add(elm_win_inlined_image_object_get(win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld);
262 elm_win_alpha_set(win, EINA_TRUE);
263
264 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
265 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
266 bg = evas_object_rectangle_add(evas_object_evas_get(win));
267 evas_object_color_set(bg, 50, 0, 100, 100);
268 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
269 elm_win_resize_object_add(win, bg);
270 evas_object_show(bg);
271
272 return win;
273}
274
275void fang_win_complete(GLData *gld, Evas_Object *win, int x, int y, int w, int h)
276{
277 // image object for win is unlinked to its pos/size - so manual control
278 // this allows also for using map and other things with it.
279 evas_object_move(elm_win_inlined_image_object_get(win), x, y);
280 // Odd, it needs to be resized twice. WTF?
281 evas_object_resize(win, w, h);
282 evas_object_resize(elm_win_inlined_image_object_get(win), w, h);
283 evas_object_show(win);
284 create_handles(elm_win_inlined_image_object_get(win));
285}
286
287void overlay_add(GLData *gld)
288{
289 Evas_Object *bg;
290//, *bx, *tb, *menu;
291// Elm_Object_Item *tb_it, *menu_it;
292
293 // There many are reasons for this window.
294 // The first is to cover the GL and provide something to click on to change focus.
295 // The second is to provide something to click on for all the GL type clicking stuff that needs to be done. In other words, no click through,we catch the clicks here.
296 // So we can probably avoid the following issue -
297 // How to do click through? evas_object_pass_events_set(rectangle, EINA_TRUE), and maybe need to do that to the underlaying window to?
298 // Though if the rectangle is entirely transparent, or even hidden, events might pass through anyway.
299 // Gotta have click through on the parts where there's no other window.
300 // The third is to have the other windows live here.
301 // This idea doesn't work, as it breaks the damn focus again.
302 // Don't think it's needed anyway.
303 // While on the subject of layers, need a HUD layer of some sort, but Irrlicht might support that itself.
304
305 gld->winwin = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE);
306 // On mouse down we try to shift focus to the backing image, this seems to be the correct thing to force focus onto it's widgets.
307 // According to the Elm inlined image window example, this is what's needed to.
308 evas_object_event_callback_add(elm_win_inlined_image_object_get(gld->winwin), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld);
309 // In this code, we are making our own camera, so grab it's input when we are focused.
310 evas_object_event_callback_add(gld->winwin, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld);
311 evas_object_event_callback_add(gld->winwin, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld);
312 elm_object_event_callback_add(gld->winwin, _cb_event_GL, gld);
313
314 elm_win_alpha_set(gld->winwin, EINA_TRUE);
315 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
316 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
317 bg = evas_object_rectangle_add(evas_object_evas_get(gld->winwin));
318 evas_object_color_set(bg, 0, 0, 0, 0);
319 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
320 elm_win_resize_object_add(gld->winwin, bg);
321 evas_object_show(bg);
322
323 // image object for win is unlinked to its pos/size - so manual control
324 // this allows also for using map and other things with it.
325 evas_object_move(elm_win_inlined_image_object_get(gld->winwin), 0, 0);
326 // Odd, it needs to be resized twice. WTF?
327 evas_object_resize(gld->winwin, gld->win_w, gld->win_h);
328 evas_object_resize(elm_win_inlined_image_object_get(gld->winwin), gld->win_w, gld->win_h);
329 evas_object_show(gld->winwin);
330}
diff --git a/src/extantz/gears.c b/src/extantz/gears.c
new file mode 100644
index 0000000..68f817e
--- /dev/null
+++ b/src/extantz/gears.c
@@ -0,0 +1,354 @@
1#include "extantz.h"
2
3
4
5#if DO_GEARS
6//--------------------------------//
7// Gear Stuff.
8
9static GLfloat *vert(GLfloat *p, GLfloat x, GLfloat y, GLfloat z, GLfloat *n)
10{
11 p[0] = x;
12 p[1] = y;
13 p[2] = z;
14 p[3] = n[0];
15 p[4] = n[1];
16 p[5] = n[2];
17
18 return p + 6;
19}
20
21/* Draw a gear wheel. You'll probably want to call this function when
22 * building a display list since we do a lot of trig here.
23 *
24 * Input: inner_radius - radius of hole at center
25 * outer_radius - radius at center of teeth
26 * width - width of gear
27 * teeth - number of teeth
28 * tooth_depth - depth of tooth
29 */
30static Gear *make_gear(GLData *gld, GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth)
31{
32 GLint i;
33 GLfloat r0, r1, r2;
34 GLfloat da;
35 GLfloat *v;
36 Gear *gear;
37 double s[5], c[5];
38 GLfloat normal[3];
39 const int tris_per_tooth = 20;
40 Evas_GL_API *gl = gld->glApi;
41
42 gear = (Gear*)malloc(sizeof(Gear));
43 if (gear == NULL)
44 return NULL;
45
46 r0 = inner_radius;
47 r1 = outer_radius - tooth_depth / 2.0;
48 r2 = outer_radius + tooth_depth / 2.0;
49
50 da = 2.0 * M_PI / teeth / 4.0;
51
52 gear->vertices = calloc(teeth * tris_per_tooth * 3 * 6, sizeof *gear->vertices);
53 s[4] = 0;
54 c[4] = 1;
55 v = gear->vertices;
56 for (i = 0; i < teeth; i++)
57 {
58 s[0] = s[4];
59 c[0] = c[4];
60 s[1] = sin(i * 2.0 * M_PI / teeth + da);
61 c[1] = cos(i * 2.0 * M_PI / teeth + da);
62 s[2] = sin(i * 2.0 * M_PI / teeth + da * 2);
63 c[2] = cos(i * 2.0 * M_PI / teeth + da * 2);
64 s[3] = sin(i * 2.0 * M_PI / teeth + da * 3);
65 c[3] = cos(i * 2.0 * M_PI / teeth + da * 3);
66 s[4] = sin(i * 2.0 * M_PI / teeth + da * 4);
67 c[4] = cos(i * 2.0 * M_PI / teeth + da * 4);
68
69 normal[0] = 0.0;
70 normal[1] = 0.0;
71 normal[2] = 1.0;
72
73 v = vert(v, r2 * c[1], r2 * s[1], width * 0.5, normal);
74
75 v = vert(v, r2 * c[1], r2 * s[1], width * 0.5, normal);
76 v = vert(v, r2 * c[2], r2 * s[2], width * 0.5, normal);
77 v = vert(v, r1 * c[0], r1 * s[0], width * 0.5, normal);
78 v = vert(v, r1 * c[3], r1 * s[3], width * 0.5, normal);
79 v = vert(v, r0 * c[0], r0 * s[0], width * 0.5, normal);
80 v = vert(v, r1 * c[4], r1 * s[4], width * 0.5, normal);
81 v = vert(v, r0 * c[4], r0 * s[4], width * 0.5, normal);
82
83 v = vert(v, r0 * c[4], r0 * s[4], width * 0.5, normal);
84 v = vert(v, r0 * c[0], r0 * s[0], width * 0.5, normal);
85 v = vert(v, r0 * c[4], r0 * s[4], -width * 0.5, normal);
86 v = vert(v, r0 * c[0], r0 * s[0], -width * 0.5, normal);
87
88 normal[0] = 0.0;
89 normal[1] = 0.0;
90 normal[2] = -1.0;
91
92 v = vert(v, r0 * c[4], r0 * s[4], -width * 0.5, normal);
93
94 v = vert(v, r0 * c[4], r0 * s[4], -width * 0.5, normal);
95 v = vert(v, r1 * c[4], r1 * s[4], -width * 0.5, normal);
96 v = vert(v, r0 * c[0], r0 * s[0], -width * 0.5, normal);
97 v = vert(v, r1 * c[3], r1 * s[3], -width * 0.5, normal);
98 v = vert(v, r1 * c[0], r1 * s[0], -width * 0.5, normal);
99 v = vert(v, r2 * c[2], r2 * s[2], -width * 0.5, normal);
100 v = vert(v, r2 * c[1], r2 * s[1], -width * 0.5, normal);
101
102 v = vert(v, r1 * c[0], r1 * s[0], width * 0.5, normal);
103
104 v = vert(v, r1 * c[0], r1 * s[0], width * 0.5, normal);
105 v = vert(v, r1 * c[0], r1 * s[0], -width * 0.5, normal);
106 v = vert(v, r2 * c[1], r2 * s[1], width * 0.5, normal);
107 v = vert(v, r2 * c[1], r2 * s[1], -width * 0.5, normal);
108 v = vert(v, r2 * c[2], r2 * s[2], width * 0.5, normal);
109 v = vert(v, r2 * c[2], r2 * s[2], -width * 0.5, normal);
110 v = vert(v, r1 * c[3], r1 * s[3], width * 0.5, normal);
111 v = vert(v, r1 * c[3], r1 * s[3], -width * 0.5, normal);
112 v = vert(v, r1 * c[4], r1 * s[4], width * 0.5, normal);
113 v = vert(v, r1 * c[4], r1 * s[4], -width * 0.5, normal);
114
115 v = vert(v, r1 * c[4], r1 * s[4], -width * 0.5, normal);
116 }
117
118 gear->count = (v - gear->vertices) / 6;
119
120 gl->glGenBuffers(1, &gear->vbo);
121 gl->glBindBuffer(GL_ARRAY_BUFFER, gear->vbo);
122 gl->glBufferData(GL_ARRAY_BUFFER, gear->count * 6 * 4, gear->vertices, GL_STATIC_DRAW);
123
124
125 return gear;
126}
127
128void free_gear(Gear *gear)
129{
130 free(gear->vertices);
131 free(gear);
132 gear = NULL;
133}
134
135static void multiply(GLfloat *m, const GLfloat *n)
136{
137 GLfloat tmp[16];
138 const GLfloat *row, *column;
139 div_t d;
140 int i, j;
141
142 for (i = 0; i < 16; i++)
143 {
144 tmp[i] = 0;
145 d = div(i, 4);
146 row = n + d.quot * 4;
147 column = m + d.rem;
148 for (j = 0; j < 4; j++)
149 tmp[i] += row[j] * column[j * 4];
150 }
151 memcpy(m, &tmp, sizeof tmp);
152}
153
154static void rotate(GLfloat *m, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
155{
156 double s, c;
157
158 s = sin(angle);
159 c = cos(angle);
160 GLfloat r[16] =
161 {
162 x * x * (1 - c) + c, y * x * (1 - c) + z * s, x * z * (1 - c) - y * s, 0,
163 x * y * (1 - c) - z * s, y * y * (1 - c) + c, y * z * (1 - c) + x * s, 0,
164 x * z * (1 - c) + y * s, y * z * (1 - c) - x * s, z * z * (1 - c) + c, 0,
165 0, 0, 0, 1
166 };
167
168 multiply(m, r);
169}
170
171static void translate(GLfloat *m, GLfloat x, GLfloat y, GLfloat z)
172{
173 GLfloat t[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 };
174
175 multiply(m, t);
176}
177
178static void draw_gear(GLData *gld, Gear *gear, GLfloat *m, GLfloat x, GLfloat y, GLfloat angle, const GLfloat *color)
179{
180 Evas_GL_API *gl = gld->glApi;
181 GLfloat tmp[16];
182
183 memcpy(tmp, m, sizeof tmp);
184 translate(tmp, x, y, 0);
185 rotate(tmp, 2 * M_PI * angle / 360.0, 0, 0, 1);
186 gl->glUniformMatrix4fv(gld->proj_location, 1, GL_FALSE, tmp);
187 gl->glUniform3fv(gld->light_location, 1, gld->light);
188 gl->glUniform4fv(gld->color_location, 1, color);
189
190 gl->glBindBuffer(GL_ARRAY_BUFFER, gear->vbo);
191
192 gl->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), NULL);
193 gl->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLfloat *) 0 + 3);
194 gl->glEnableVertexAttribArray(0);
195 gl->glEnableVertexAttribArray(1);
196 gl->glDrawArrays(GL_TRIANGLE_STRIP, 0, gear->count);
197}
198
199
200void drawGears(GLData *gld)
201{
202 Evas_GL_API *gl = gld->glApi;
203 static const GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
204 static const GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
205 static const GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
206 GLfloat m[16];
207
208 // Draw the gears.
209 if (!gld->useIrr)
210 {
211 gl->glClearColor(0.7, 0.0, 1.0, 1.0);
212 gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
213 }
214
215 memcpy(m, gld->proj, sizeof m);
216 rotate(m, 2 * M_PI * gld->view_rotx / 360.0, 1, 0, 0);
217 rotate(m, 2 * M_PI * gld->view_roty / 360.0, 0, 1, 0);
218 rotate(m, 2 * M_PI * gld->view_rotz / 360.0, 0, 0, 1);
219
220 draw_gear(gld, gld->gear1, m, -3.0, -2.0, gld->angle, red);
221 draw_gear(gld, gld->gear2, m, 3.1, -2.0, -2 * gld->angle - 9.0, green);
222 draw_gear(gld, gld->gear3, m, -3.1, 4.2, -2 * gld->angle - 25.0, blue);
223 gld->angle += 2.0;
224}
225
226static const char vertex_shader[] =
227 "uniform mat4 proj;\n"
228 "attribute vec4 position;\n"
229 "attribute vec4 normal;\n"
230 "varying vec3 rotated_normal;\n"
231 "varying vec3 rotated_position;\n"
232 "vec4 tmp;\n"
233 "void main()\n"
234 "{\n"
235 " gl_Position = proj * position;\n"
236 " rotated_position = gl_Position.xyz;\n"
237 " tmp = proj * normal;\n"
238 " rotated_normal = tmp.xyz;\n"
239 "}\n";
240
241 static const char fragment_shader[] =
242 "#ifdef GL_ES\n"
243 "precision mediump float;\n"
244 "#endif\n"
245 "uniform vec4 color;\n"
246 "uniform vec3 light;\n"
247 "varying vec3 rotated_normal;\n"
248 "varying vec3 rotated_position;\n"
249 "vec3 light_direction;\n"
250 "vec4 white = vec4(0.5, 0.5, 0.5, 1.0);\n"
251 "void main()\n"
252 "{\n"
253 " light_direction = normalize(light - rotated_position);\n"
254 " gl_FragColor = color + white * dot(light_direction, rotated_normal);\n"
255 "}\n";
256
257static GLuint load_shader(GLData *gld, GLenum type, const char *shader_src)
258{
259 Evas_GL_API *gl = gld->glApi;
260 GLuint shader;
261 GLint compiled = 0;
262
263 // Create the shader object
264 if (!(shader = gl->glCreateShader(type))) return 0;
265 gl->glShaderSource(shader, 1, &shader_src, NULL);
266 // Compile the shader
267 gl->glCompileShader(shader);
268 gl->glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
269
270 if (!compiled)
271 {
272 GLint len = 0;
273
274 gl->glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
275 if (len > 1)
276 {
277 char *info = malloc(sizeof(char) * len);
278
279 if (info)
280 {
281 gl->glGetShaderInfoLog(shader, len, NULL, info);
282 printf("Error compiling shader:\n"
283 "%s\n", info);
284 free(info);
285 }
286 }
287 gl->glDeleteShader(shader);
288 return 0;
289 }
290 return shader;
291}
292
293void gears_init(GLData *gld)
294{
295 Evas_GL_API *gl = gld->glApi;
296 GLint linked = 0;
297
298// char msg[512];
299
300 gl->glEnable(GL_CULL_FACE);
301 gl->glEnable(GL_DEPTH_TEST);
302 gl->glEnable(GL_BLEND);
303
304 // Load the vertex/fragment shaders
305 gld->vtx_shader = load_shader(gld, GL_VERTEX_SHADER, vertex_shader);
306 gld->fgmt_shader = load_shader(gld, GL_FRAGMENT_SHADER, fragment_shader);
307
308 // Create the program object
309 if (!(gld->program = gl->glCreateProgram()))
310 return;
311
312 gl->glAttachShader(gld->program, gld->vtx_shader);
313 gl->glAttachShader(gld->program, gld->fgmt_shader);
314
315 // Bind shader attributes.
316 gl->glBindAttribLocation(gld->program, 0, "position");
317 gl->glBindAttribLocation(gld->program, 1, "normal");
318
319 // Link the program
320 gl->glLinkProgram(gld->program);
321 gld->glApi->glGetProgramiv(gld->program, GL_LINK_STATUS, &linked);
322
323 if (!linked)
324 {
325 GLint len = 0;
326
327 gld->glApi->glGetProgramiv(gld->program, GL_INFO_LOG_LENGTH, &len);
328 if (len > 1)
329 {
330 char *info = malloc(sizeof(char) * len);
331
332 if (info)
333 {
334 gld->glApi->glGetProgramInfoLog(gld->program, len, NULL, info);
335 printf("Error linking program:\n%s\n", info);
336 free(info);
337 }
338 }
339 gld->glApi->glDeleteProgram(gld->program);
340 }
341
342 gl->glUseProgram(gld->program);
343 gld->proj_location = gl->glGetUniformLocation(gld->program, "proj");
344 gld->light_location = gl->glGetUniformLocation(gld->program, "light");
345 gld->color_location = gl->glGetUniformLocation(gld->program, "color");
346
347 /* make the gears */
348 gld->gear1 = make_gear(gld, 1.0, 4.0, 1.0, 20, 0.7);
349 gld->gear2 = make_gear(gld, 0.5, 2.0, 2.0, 10, 0.7);
350 gld->gear3 = make_gear(gld, 1.3, 2.0, 0.5, 10, 0.7);
351
352 gld->gearsInited = EINA_TRUE;
353}
354#endif
diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c
new file mode 100644
index 0000000..6eac003
--- /dev/null
+++ b/src/extantz/woMan.c
@@ -0,0 +1,300 @@
1#include "extantz.h"
2
3
4Eina_Hash *grids;
5Eina_Hash *viewers;
6
7static char *gridTest[][3] =
8{
9 {"3rd Rock Grid", "http://grid.3rdrockgrid.com:8002/", "http://grid.3rdrockgrid.com/3rg_login"},
10 {"Infinite Grid", "http://grid.infinitegrid.org:8002/", "http://www.infinitegrid.org/loginscreen.php"},
11 {"Second Life Grid", "https://login.agni.lindenlab.com/cgi-bin/login.cgi", "http://secondlife.com/"},
12 {NULL, NULL, NULL}
13};
14
15static char *accountTest[][3] =
16{
17 {"3rd Rock Grid", "onefang rejected", "password"},
18 {"Infinite Grid", "infinite onefang", "MyB1GSecrit"},
19 {"Infinite Grid", "onefang rejected", "MySecrit"},
20 {NULL, NULL, NULL}
21};
22
23
24static char *viewerTest[][3] =
25{
26 {"Imprudence", "1.4.0 beta 3", ""},
27 {"Kokua", "3.4.4.25633", ""},
28 {"meta-impy", "1.4.0 beta 1.5", ""},
29 {"SL", "v3", ""},
30 {NULL, NULL, NULL}
31};
32
33
34static Elm_Genlist_Item_Class *grid_gic = NULL;
35static Elm_Genlist_Item_Class *account_gic = NULL;
36static Elm_Genlist_Item_Class *viewer_gic = NULL;
37
38//static const char *img1 = PACKAGE_DATA_DIR "plant_01.jpg";
39//static const char *img2 = PACKAGE_DATA_DIR "sky_01.jpg";
40static const char *img3 = "rock_01.jpg";
41
42
43
44static Evas_Object *_content_image_new(Evas_Object *parent, const char *img)
45{
46 Evas_Object *ic;
47
48 ic = elm_icon_add(parent);
49 elm_image_file_set(ic, img, NULL);
50 return ic;
51}
52
53static void _promote(void *data, Evas_Object *obj , void *event_info )
54{
55 elm_naviframe_item_promote(data);
56}
57
58static char *_grid_label_get(void *data, Evas_Object *obj, const char *part)
59{
60 ezGrid *thisGrid = data;
61 char buf[256];
62
63 if (!strcmp(part, "elm.text"))
64 {
65 int count = eina_clist_count(&(thisGrid->accounts));
66
67 if (0 == count)
68 snprintf(buf, sizeof(buf), "%s (no accounts)", thisGrid->name);
69 else if (1 == count)
70 snprintf(buf, sizeof(buf), "%s (%d account)", thisGrid->name, count);
71 else
72 snprintf(buf, sizeof(buf), "%s (%d accounts)", thisGrid->name, count);
73 }
74 else
75 snprintf(buf, sizeof(buf), "%s", thisGrid->loginURI);
76 return strdup(buf);
77}
78
79static Evas_Object *_grid_content_get(void *data, Evas_Object *obj, const char *part)
80{
81 ezGrid *thisGrid = data;
82 Evas_Object *ic = elm_icon_add(obj);
83
84 if (!strcmp(part, "elm.swallow.icon"))
85 elm_icon_standard_set(ic, thisGrid->icon);
86
87 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
88 return ic;
89}
90
91static char * _account_label_get(void *data, Evas_Object *obj, const char *part)
92{
93 ezAccount *thisAccount = data;
94 char buf[256];
95
96 buf[0] = '\0';
97 if (!strcmp(part, "elm.text"))
98 snprintf(buf, sizeof(buf), "%s", thisAccount->name);
99
100 return strdup(buf);
101}
102
103static Evas_Object *_account_content_get(void *data, Evas_Object *obj, const char *part)
104{
105 ezAccount *thisAccount = data;
106 Evas_Object *ic = elm_icon_add(obj);
107
108 if (!strcmp(part, "elm.swallow.icon"))
109 elm_icon_standard_set(ic, thisAccount->icon);
110
111 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
112 return ic;
113}
114
115static char *_viewer_label_get(void *data, Evas_Object *obj, const char *part)
116{
117 ezViewer *thisViewer = data;
118 char buf[256];
119
120 if (!strcmp(part, "elm.text"))
121 snprintf(buf, sizeof(buf), "%s", thisViewer->name);
122 else
123 snprintf(buf, sizeof(buf), "%s", thisViewer->version);
124 return strdup(buf);
125}
126
127static Evas_Object *_viewer_content_get(void *data, Evas_Object *obj, const char *part)
128{
129 ezViewer *thisViewer = data;
130 Evas_Object *ic = elm_icon_add(obj);
131
132 if (!strcmp(part, "elm.swallow.icon"))
133 elm_icon_standard_set(ic, thisViewer->icon);
134
135 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
136 return ic;
137}
138
139
140static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info)
141{
142 ezGrid *thisGrid = data;
143 GLData *gld = thisGrid->gld;
144 char buf[PATH_MAX];
145
146// sprintf(buf, "dillo -f -g '%dx%d+%d+%d' %s &", gld->win_w - (gld->win_w / 5), gld->win_h - 30, gld->win_w / 5, gld->win_y, thisGrid->splashPage);
147 sprintf(buf, "uzbl -g '%dx%d+%d+%d' -u %s &", gld->win_w - (gld->win_w / 5), gld->win_h - 30, gld->win_w / 5, gld->win_y, thisGrid->splashPage);
148 printf("%s ### genlist obj [%p], item pointer [%p]\n", buf, obj, event_info);
149// comment this out for now, busy dealing with input stuff, don't want to trigger this multiple times.
150// system(buf);
151}
152
153
154void woMan_add(GLData *gld)
155{
156// Evas_Object *win, *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu;
157 Evas_Object *win, *bx, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu;
158 Elm_Object_Item *tb_it, *menu_it, *tab_it;
159 char buf[PATH_MAX];
160 int i;
161
162 win = fang_win_add(gld);
163
164 bx = elm_box_add(win);
165 elm_win_resize_object_add(win, bx);
166 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
167 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
168
169 // A tab thingy.
170 tb = elm_toolbar_add(win);
171 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
172 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
173 elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
174
175 // Menu.
176 tb_it = elm_toolbar_item_append(tb, NULL, "Menu", NULL, NULL);
177 elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
178 // Priority is for when toolbar items are set to hide or menu when there are too many of them. They get hidden or put on the menu based on priority.
179 elm_toolbar_item_priority_set(tb_it, 9999);
180 elm_toolbar_menu_parent_set(tb, win);
181 menu = elm_toolbar_item_menu_get(tb_it);
182
183 menu_it = elm_menu_item_add(menu, NULL, NULL, "edit", NULL, NULL);
184 elm_menu_item_add(menu, menu_it, NULL, "preferences", NULL, NULL);
185 menu_it = elm_menu_item_add(menu, NULL, NULL, "help", NULL, NULL);
186 elm_menu_item_add(menu, menu_it, NULL, "about woMan", NULL, NULL);
187 elm_menu_item_separator_add(menu, NULL);
188 menu_it = elm_menu_item_add(menu, NULL, NULL, "advanced", NULL, NULL);
189 elm_menu_item_add(menu, menu_it, NULL, "debug settings", NULL, NULL);
190
191 // The toolbar needs to be packed into the box AFTER the menus are added.
192 elm_box_pack_end(bx, tb);
193 evas_object_show(tb);
194
195 gridList = elm_genlist_add(win);
196 grids = eina_hash_stringshared_new(free);
197
198 grid_gic = elm_genlist_item_class_new();
199 grid_gic->item_style = "double_label";
200 grid_gic->func.text_get = _grid_label_get;
201 grid_gic->func.content_get = _grid_content_get;
202 grid_gic->func.state_get = NULL;
203 grid_gic->func.del = NULL;
204 for (i = 0; NULL != gridTest[i][0]; i++)
205 {
206 ezGrid *thisGrid = calloc(1, sizeof(ezGrid));
207
208 if (thisGrid)
209 {
210 eina_clist_init(&(thisGrid->accounts));
211 eina_clist_init(&(thisGrid->landmarks));
212 thisGrid->name = gridTest[i][0];
213 thisGrid->loginURI = gridTest[i][1];
214 thisGrid->splashPage = gridTest[i][2];
215 thisGrid->icon = "folder";
216 thisGrid->gld = gld;
217 thisGrid->item = elm_genlist_item_append(gridList, grid_gic, thisGrid, NULL, ELM_GENLIST_ITEM_TREE, _grid_sel_cb, thisGrid);
218 eina_hash_add(grids, thisGrid->name, thisGrid);
219 }
220 }
221
222 account_gic = elm_genlist_item_class_new();
223 account_gic->item_style = "default";
224 account_gic->func.text_get = _account_label_get;
225 account_gic->func.content_get = _account_content_get;
226 account_gic->func.state_get = NULL;
227 account_gic->func.del = NULL;
228 for (i = 0; NULL != accountTest[i][0]; i++)
229 {
230 ezAccount *thisAccount = calloc(1, sizeof(ezAccount));
231 ezGrid *grid = eina_hash_find(grids, accountTest[i][0]);
232
233 if (thisAccount && grid)
234 {
235 thisAccount->name = accountTest[i][1];
236 thisAccount->password = accountTest[i][2];
237 thisAccount->icon = "file";
238 elm_genlist_item_append(gridList, account_gic, thisAccount, grid->item, ELM_GENLIST_ITEM_NONE, NULL, NULL);
239 eina_clist_add_tail(&(grid->accounts), &(thisAccount->grid));
240 }
241 }
242
243 // Viewers stuff
244 viewerList = elm_genlist_add(win);
245 viewer_gic = elm_genlist_item_class_new();
246 viewer_gic->item_style = "double_label";
247 viewer_gic->func.text_get = _viewer_label_get;
248 viewer_gic->func.content_get = _viewer_content_get;
249 viewer_gic->func.state_get = NULL;
250 viewer_gic->func.del = NULL;
251 for (i = 0; NULL != viewerTest[i][0]; i++)
252 {
253 ezViewer *thisViewer = calloc(1, sizeof(ezViewer));
254
255 if (thisViewer)
256 {
257 thisViewer->name = viewerTest[i][0];
258 thisViewer->version = viewerTest[i][1];
259 thisViewer->path = viewerTest[i][2];
260 thisViewer->icon = "file";
261 thisViewer->item = elm_genlist_item_append(viewerList, viewer_gic, thisViewer, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
262 }
263 }
264
265 // Toolbar pages
266 nf = elm_naviframe_add(win);
267 evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
268 evas_object_size_hint_align_set(nf, EVAS_HINT_FILL, EVAS_HINT_FILL);
269 evas_object_show(nf);
270
271 sprintf(buf, "%s/%s", elm_app_data_dir_get(), img3);
272 tab = viewerList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Viewers", _promote, tab_it);
273 tab = _content_image_new(win, strdup(buf)); tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Landmarks", _promote, tab_it);
274 tab = gridList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Grids", _promote, tab_it);
275 elm_box_pack_end(bx, nf);
276
277#if USE_EO
278 // Not ready for prime time yet, or I'm missing a step. Causes it to hang after closing the window.
279 // Slightly better now, it bitches instead of hanging.
280 bt = eo_add(ELM_OBJ_BUTTON_CLASS, win);
281 elm_object_text_set(bt, "Login"); // No eo interface for this that I can find.
282 eo_do(bt,
283// evas_obj_text_set("Login"),
284 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL),
285 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0),
286 evas_obj_visibility_set(EINA_TRUE)
287 );
288#else
289 bt = elm_button_add(win);
290 elm_object_text_set(bt, "Login");
291 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
292 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
293 evas_object_show(bt);
294#endif
295// evas_object_smart_callback_add(bt, "clicked", NULL, NULL);
296 elm_box_pack_end(bx, bt);
297 evas_object_show(bx);
298
299 fang_win_complete(gld, win, 30, 30, gld->win_w / 3, gld->win_h / 3);
300}