Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

meshviewer.cpp 38 KiB

11 anni fa
11 anni fa
11 anni fa
10 anni fa
11 anni fa
11 anni fa
11 anni fa
11 anni fa
11 anni fa
11 anni fa
11 anni fa
11 anni fa
11 anni fa
10 anni fa
10 anni fa
10 anni fa
10 anni fa
10 anni fa
11 anni fa
11 anni fa
11 anni fa
10 anni fa
10 anni fa
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. //
  2. // Lol Engine - EasyMesh tutorial
  3. //
  4. // Copyright: (c) 2011-2013 Sam Hocevar <sam@hocevar.net>
  5. // (c) 2012-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
  6. // This program is free software; you can redistribute it and/or
  7. // modify it under the terms of the Do What The Fuck You Want To
  8. // Public License, Version 2, as published by Sam Hocevar. See
  9. // http://www.wtfpl.net/ for more details.
  10. //
  11. #if defined HAVE_CONFIG_H
  12. # include "config.h"
  13. #endif
  14. #include <cfloat> /* for FLT_MAX */
  15. #include "core.h"
  16. #include "scenesetup.h"
  17. using namespace std;
  18. using namespace lol;
  19. static int const TEXTURE_WIDTH = 256;
  20. #define NO_NACL_EM (!__native_client__ && !EMSCRIPTEN)
  21. #define NACL_EM (__native_client__ || EMSCRIPTEN)
  22. #define NO_NACL_EM_INPUT (1)
  23. #define R_M 1.f
  24. #if NACL_EM
  25. #define DEFAULT_WIDTH (800.f * R_M)
  26. #define DEFAULT_HEIGHT (400.f * R_M)
  27. #else
  28. #define DEFAULT_WIDTH (1200.f * R_M)
  29. #define DEFAULT_HEIGHT (400.f * R_M)
  30. #endif //NACL_EM
  31. #define WIDTH ((float)Video::GetSize().x)
  32. #define HEIGHT ((float)Video::GetSize().y)
  33. #define SCREEN_W (10.f / WIDTH)
  34. #define RATIO_HW (HEIGHT / WIDTH)
  35. #define RATIO_WH (WIDTH / HEIGHT)
  36. #define SCREEN_LIMIT 1.4f
  37. #define RESET_TIMER .2f
  38. #define ROT_SPEED vec2(50.f)
  39. #define ROT_CLAMP 89.f
  40. #define POS_SPEED vec2(1.2f)
  41. #define POS_CLAMP 1.f
  42. #define FOV_SPEED 20.f
  43. #define FOV_CLAMP 120.f
  44. #define ZOM_SPEED 3.f
  45. #define ZOM_CLAMP 20.f
  46. #define HST_SPEED .5f
  47. #define HST_CLAMP 1.f
  48. #define WITH_TEXTURE 0
  49. #define HAS_KBOARD (m_input_usage & (1<<IPT_MV_KBOARD))
  50. #define HAS_MOUSE (m_input_usage & (1<<IPT_MV_MOUSE))
  51. LOLFX_RESOURCE_DECLARE(shinyfur);
  52. LOLFX_RESOURCE_DECLARE(shinymvtexture);
  53. enum
  54. {
  55. IPT_MV_KBOARD = 0,
  56. IPT_MV_MOUSE,
  57. INPUT_MAX
  58. };
  59. enum MVKeyboardList
  60. {
  61. KEY_CAM_RESET = 0,
  62. KEY_CAM_POS,
  63. KEY_CAM_FOV,
  64. KEY_CAM_UP,
  65. KEY_CAM_DOWN,
  66. KEY_CAM_LEFT,
  67. KEY_CAM_RIGHT,
  68. KEY_MESH_NEXT,
  69. KEY_MESH_PREV,
  70. KEY_F1,
  71. KEY_F2,
  72. KEY_F3,
  73. KEY_F4,
  74. KEY_F5,
  75. KEY_ESC,
  76. KEY_MAX
  77. };
  78. enum MVMouseKeyList
  79. {
  80. MSE_CAM_ROT = KEY_MAX,
  81. MSE_CAM_POS,
  82. MSE_CAM_FOV,
  83. MSE_FOCUS,
  84. MSE_MAX
  85. };
  86. enum MVMouseAxisList
  87. {
  88. MSEX_CAM_Y = 0,
  89. MSEX_CAM_X,
  90. MSEX_MAX
  91. };
  92. #define MAX_KEYS MSE_MAX
  93. #define MAX_AXIS MSEX_MAX
  94. #define ALL_FEATURES 1
  95. #define NO_SC_SETUP 0
  96. enum GizmoType
  97. {
  98. GZ_Editor = 0,
  99. GZ_LightPos,
  100. GZ_LightDir,
  101. GZ_MAX
  102. };
  103. struct LightData
  104. {
  105. LightData(vec3 pos, vec4 col)
  106. {
  107. m_pos = pos;
  108. m_col = col;
  109. }
  110. vec3 m_pos;
  111. vec4 m_col;
  112. };
  113. class TargetCamera
  114. {
  115. public:
  116. void EmptyTargets() { m_targets.Empty(); }
  117. void AddTarget(vec3 new_target) { m_targets << new_target; }
  118. //This considers the box usage A to B as top-left to bottom-right
  119. void AddTarget(box3 new_target)
  120. {
  121. vec3 base_off = .5f * (new_target.B - new_target.A);
  122. vec3 base_pos = new_target.A + base_off;
  123. int pass = 0;
  124. while (pass < 3)
  125. {
  126. int mask = 3 - max(0, pass - 1);
  127. while (mask-- > 0)
  128. {
  129. ivec3 A((pass == 1 || (pass == 2 && mask == 1))?(1):(0));
  130. ivec3 B((pass == 2)?(1):(0)); B[mask] = 1;
  131. vec3 offset = vec3(ivec3((int)(!A.x != !B.x), (int)(!A.y != !B.y), (int)(!A.z != !B.z)));
  132. AddTarget(base_pos + offset * base_off * 2.f - base_off);
  133. }
  134. pass++;
  135. }
  136. }
  137. Array<vec3> m_targets;
  138. };
  139. class MeshViewer : public WorldEntity
  140. {
  141. public:
  142. MeshViewer(char const *file_name = "data/mesh-buffer.txt")
  143. : m_file_name(file_name)
  144. {
  145. m_init = false;
  146. m_first_tick = false;
  147. // Message Service
  148. MessageService::Setup();
  149. m_ssetup = nullptr;
  150. m_camera = nullptr;
  151. m_controller = nullptr;
  152. //Compile ref meshes
  153. m_gizmos << new EasyMesh();
  154. m_gizmos.Last()->Compile("[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .075 ty .5 dup[rz 90 ry 90 scv#00f dup[ry 90 scv#f00]]][sc#fff ab .1]");
  155. m_gizmos << new EasyMesh();
  156. m_gizmos.Last()->Compile("[sc#666 acap 1 .5 .5 ty -.5 sc#fff asph 2 1]");
  157. m_gizmos << new EasyMesh();
  158. m_gizmos.Last()->Compile("[sc#fff ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 [ad 3 .1 sy -1] ty 1 rz 90 ry 90]");
  159. // Mesh Setup
  160. m_render_max = vec2(-.9f, 4.1f);
  161. m_mesh_render = 0;
  162. m_mesh_id = 0;
  163. m_mesh_id1 = 0.f;
  164. m_default_texture = nullptr;
  165. m_texture_shader = nullptr;
  166. m_texture = nullptr;
  167. //Camera Setup
  168. m_reset_timer = -1.f;
  169. m_fov = -100.f;
  170. m_fov_mesh = 0.f;
  171. m_fov_speed = 0.f;
  172. m_zoom = 0.f;
  173. m_zoom_mesh = 0.f;
  174. m_zoom_speed = 0.f;
  175. m_rot = vec2(/*45.f*/0.f, -45.f);
  176. m_rot_mesh = vec2::zero;
  177. m_rot_speed = vec2::zero;
  178. m_pos = vec2::zero;
  179. m_pos_mesh = vec2::zero;
  180. m_pos_speed = vec2::zero;
  181. m_screen_offset = vec2::zero;
  182. m_hist_scale = vec2(.13f, .03f);
  183. m_hist_scale_mesh = vec2(.0f);
  184. m_hist_scale_speed = vec2(.0f);
  185. m_mat_prev = mat4(quat::fromeuler_xyz(vec3::zero));
  186. m_mat = mat4::translate(vec3(0.f));//mat4(quat::fromeuler_xyz(vec3(m_rot_mesh, .0f)));
  187. m_build_timer = 0.1f;
  188. m_build_time = -1.f;
  189. //stream update
  190. m_stream_update_time = 2.0f;
  191. m_stream_update_timer = 1.0f;
  192. }
  193. ~MeshViewer()
  194. {
  195. if (m_camera)
  196. g_scene->PopCamera(m_camera);
  197. if (m_ssetup)
  198. delete(m_ssetup);
  199. MessageService::Destroy();
  200. m_controller = nullptr;
  201. m_camera = nullptr;
  202. m_ssetup = nullptr;
  203. }
  204. #if NO_NACL_EM_INPUT
  205. bool KeyReleased(MVKeyboardList index) { return (HAS_KBOARD && m_controller->GetKey(index).IsReleased()); }
  206. bool KeyPressed(MVKeyboardList index) { return (HAS_KBOARD && m_controller->GetKey(index).IsPressed()); }
  207. bool KeyDown(MVKeyboardList index) { return (HAS_KBOARD && m_controller->GetKey(index).IsDown()); }
  208. bool KeyReleased(MVMouseKeyList index) { return (HAS_MOUSE && m_controller->GetKey(index).IsReleased()); }
  209. bool KeyPressed(MVMouseKeyList index) { return (HAS_MOUSE && m_controller->GetKey(index).IsPressed()); }
  210. bool KeyDown(MVMouseKeyList index) { return (HAS_MOUSE && m_controller->GetKey(index).IsDown()); }
  211. float AxisValue(MVMouseAxisList index) { return (HAS_MOUSE)?(m_controller->GetAxis(index).GetValue()):(0.f); }
  212. #endif //NO_NACL_EM_INPUT
  213. void Init()
  214. {
  215. m_init = true;
  216. m_input_usage = 0;
  217. #if NO_NACL_EM_INPUT
  218. /* Register an input controller for the keyboard */
  219. m_controller = new Controller("Default", MAX_KEYS, MAX_AXIS);
  220. if (InputDevice::Get(g_name_mouse.C()))
  221. {
  222. m_input_usage |= (1<<IPT_MV_MOUSE);
  223. m_controller->GetKey(MSE_CAM_ROT).BindMouse("Left");
  224. m_controller->GetKey(MSE_CAM_POS).BindMouse("Right");
  225. m_controller->GetKey(MSE_CAM_FOV).BindMouse("Middle");
  226. m_controller->GetKey(MSE_FOCUS).BindMouse("InScreen");
  227. m_controller->GetAxis(MSEX_CAM_Y).BindMouse("Y");
  228. m_controller->GetAxis(MSEX_CAM_X).BindMouse("X");
  229. }
  230. if (InputDevice::Get(g_name_keyboard.C()))
  231. {
  232. m_input_usage |= (1<<IPT_MV_KBOARD);
  233. //Camera keyboard rotation
  234. m_controller->GetKey(KEY_CAM_UP ).BindKeyboard("Up");
  235. m_controller->GetKey(KEY_CAM_DOWN ).BindKeyboard("Down");
  236. m_controller->GetKey(KEY_CAM_LEFT ).BindKeyboard("Left");
  237. m_controller->GetKey(KEY_CAM_RIGHT).BindKeyboard("Right");
  238. //Camera keyboard position switch
  239. m_controller->GetKey(KEY_CAM_POS ).BindKeyboard("LeftShift");
  240. m_controller->GetKey(KEY_CAM_FOV ).BindKeyboard("LeftCtrl");
  241. //Camera unzoom switch
  242. m_controller->GetKey(KEY_CAM_RESET).BindKeyboard("Space");
  243. //Mesh change
  244. m_controller->GetKey(KEY_MESH_NEXT).BindKeyboard("PageUp");
  245. m_controller->GetKey(KEY_MESH_PREV).BindKeyboard("PageDown");
  246. //Base setup
  247. m_controller->GetKey(KEY_F1).BindKeyboard("F1");
  248. m_controller->GetKey(KEY_F2).BindKeyboard("F2");
  249. m_controller->GetKey(KEY_F3).BindKeyboard("F3");
  250. m_controller->GetKey(KEY_F4).BindKeyboard("F4");
  251. m_controller->GetKey(KEY_F5).BindKeyboard("F5");
  252. m_controller->GetKey(KEY_ESC).BindKeyboard("Escape");
  253. }
  254. #endif //NO_NACL_EM_INPUT
  255. m_camera = new Camera();
  256. m_camera->SetView(vec3(0.f, 0.f, 10.f), vec3::zero, vec3::axis_y);
  257. m_camera->SetProjection(0.f, .0001f, 2000.f, WIDTH * SCREEN_W, RATIO_HW);
  258. m_camera->UseShift(true);
  259. g_scene->PushCamera(m_camera);
  260. //Lights setup
  261. m_ssetup = new SceneSetup();
  262. #if NO_SC_SETUP
  263. m_ssetup->m_lights << new Light();
  264. m_ssetup->m_lights.Last()->SetPosition(vec4(4.f, -1.f, -4.f, 0.f));
  265. m_ssetup->m_lights.Last()->SetColor(vec4(.0f, .2f, .5f, 1.f));
  266. Ticker::Ref(m_ssetup->m_lights.Last());
  267. m_ssetup->m_lights << new Light();
  268. m_ssetup->m_lights.Last()->SetPosition(vec4(8.f, 2.f, 6.f, 0.f));
  269. m_ssetup->m_lights.Last()->SetColor(vec4(1.f));
  270. Ticker::Ref(m_ssetup->m_lights.Last());
  271. EasyMesh* em = new EasyMesh();
  272. if (em->Compile("sc#fff ab 1"))
  273. {
  274. if (m_mesh_id == m_meshes.Count() - 1)
  275. m_mesh_id++;
  276. m_meshes.Push(em, nullptr);
  277. }
  278. #else
  279. m_ssetup->Compile("addlight 0.0 position (4 -1 -4) color (.0 .2 .5 1) "
  280. "addlight 0.0 position (8 2 6) color #ffff "
  281. "showgizmo true ");
  282. m_ssetup->Startup();
  283. #endif //NO_SC_SETUP
  284. for (int i = 0; i < m_ssetup->m_lights.Count(); ++i)
  285. {
  286. m_light_datas << LightData(m_ssetup->m_lights[i]->GetPosition().xyz, m_ssetup->m_lights[i]->GetColor());
  287. m_ssetup->m_lights[i]->SetPosition(vec3::zero);
  288. m_ssetup->m_lights[i]->SetColor(vec4::zero);
  289. }
  290. }
  291. virtual void TickGame(float seconds)
  292. {
  293. WorldEntity::TickGame(seconds);
  294. if (!m_init && g_scene)
  295. {
  296. Init();
  297. return;
  298. }
  299. if (!m_init)
  300. return;
  301. m_first_tick = true;
  302. //TODO : This should probably be "standard LoL behaviour"
  303. #if NO_NACL_EM_INPUT
  304. {
  305. //Shutdown logic
  306. if (KeyReleased(KEY_ESC))
  307. Ticker::Shutdown();
  308. }
  309. #endif //NO_NACL_EM_INPUT
  310. //Compute render mesh count
  311. float a_j = lol::abs(m_render_max[1]);
  312. float i_m = m_hist_scale_mesh.x;
  313. float i_trans = a_j - ((a_j * a_j * i_m * i_m + a_j * i_m) * .5f);
  314. m_render_max[1] = a_j * ((RATIO_WH * 1.f) / ((i_trans != 0.f)?(i_trans):(RATIO_WH))) - RATIO_HW * .3f;
  315. //Mesh Change
  316. #if NO_NACL_EM_INPUT
  317. m_mesh_id = clamp(m_mesh_id + ((int)KeyPressed(KEY_MESH_PREV) - (int)KeyPressed(KEY_MESH_NEXT)), 0, m_meshes.Count() - 1);
  318. #endif //NO_NACL_EM_INPUT
  319. m_mesh_id1 = damp(m_mesh_id1, (float)m_mesh_id, .2f, seconds);
  320. #if ALL_FEATURES
  321. //Update light position & damping
  322. for (int i = 0; i < m_ssetup->m_lights.Count(); ++i)
  323. {
  324. vec3 pos = (m_mat * inverse(m_mat_prev) * vec4(m_ssetup->m_lights[i]->GetPosition(), 1.f)).xyz;
  325. vec3 tgt = (m_mat * vec4(m_light_datas[i].m_pos, 1.f)).xyz;
  326. vec3 new_pos = damp(pos, tgt, .3f, seconds);
  327. vec4 new_col = damp(m_ssetup->m_lights[i]->GetColor(), m_light_datas[i].m_col, .3f, seconds);
  328. m_ssetup->m_lights[i]->SetPosition(new_pos);
  329. m_ssetup->m_lights[i]->SetColor(new_col);
  330. }
  331. //Camera update
  332. bool is_pos = false;
  333. bool is_fov = false;
  334. bool is_hsc = false;
  335. vec2 tmpv = vec2::zero;
  336. #if NO_NACL_EM_INPUT
  337. is_pos = KeyDown(KEY_CAM_POS) || KeyDown(MSE_CAM_POS);
  338. is_fov = KeyDown(KEY_CAM_FOV) || KeyDown(MSE_CAM_FOV);
  339. if (KeyDown(MSE_FOCUS) && (KeyDown(MSE_CAM_ROT) || KeyDown(MSE_CAM_POS) || KeyDown(MSE_CAM_FOV)))
  340. {
  341. tmpv += vec2(AxisValue(MSEX_CAM_Y), AxisValue(MSEX_CAM_X));
  342. if (KeyDown(MSE_CAM_ROT))
  343. tmpv *= vec2(1.f, 1.f) * 6.f;
  344. if (KeyDown(MSE_CAM_POS))
  345. tmpv *= vec2(1.f, -1.f) * 3.f;
  346. if (KeyDown(MSE_CAM_FOV))
  347. tmpv = vec2(tmpv.y * 4.f, tmpv.x * 6.f);
  348. }
  349. tmpv += vec2((float)KeyDown(KEY_CAM_UP ) - (float)KeyDown(KEY_CAM_DOWN),
  350. (float)KeyDown(KEY_CAM_RIGHT) - (float)KeyDown(KEY_CAM_LEFT));
  351. #endif //NO_NACL_EM_INPUT
  352. //Base data
  353. vec2 rot = (!is_pos && !is_fov)?(tmpv):(vec2(.0f)); rot = vec2(rot.x, -rot.y);
  354. vec2 pos = ( is_pos && !is_fov)?(tmpv):(vec2(.0f)); pos = -vec2(pos.y, pos.x);
  355. vec2 fov = (!is_pos && is_fov )?(tmpv):(vec2(.0f)); fov = vec2(-fov.x, fov.y);
  356. vec2 hsc = (is_hsc)?(vec2(0.f)):(vec2(0.f));
  357. //speed
  358. m_rot_speed = damp(m_rot_speed, rot * ROT_SPEED, .2f, seconds);
  359. float pos_factor = 1.f / (1.f + m_zoom_mesh * .5f);
  360. m_pos_speed = damp(m_pos_speed, pos * POS_SPEED * pos_factor, .2f, seconds);
  361. float fov_factor = 1.f + lol::pow((m_fov_mesh / FOV_CLAMP) * 1.f, 2.f);
  362. m_fov_speed = damp(m_fov_speed, fov.x * FOV_SPEED * fov_factor, .2f, seconds);
  363. float zom_factor = 1.f + lol::pow((m_zoom_mesh / ZOM_CLAMP) * 1.f, 2.f);
  364. m_zoom_speed = damp(m_zoom_speed, fov.y * ZOM_SPEED * zom_factor, .2f, seconds);
  365. m_hist_scale_speed = damp(m_hist_scale_speed, hsc * HST_SPEED, .2f, seconds);
  366. m_rot += m_rot_speed * seconds;
  367. #if NO_NACL_EM_INPUT
  368. if (m_reset_timer >= 0.f)
  369. m_reset_timer -= seconds;
  370. if (KeyPressed(KEY_CAM_RESET))
  371. {
  372. if (m_reset_timer >= 0.f)
  373. {
  374. m_pos = vec2(0.f);
  375. m_zoom = 0.f;
  376. }
  377. else
  378. m_reset_timer = RESET_TIMER;
  379. }
  380. //Transform update
  381. if (!KeyDown(KEY_CAM_RESET))
  382. {
  383. m_pos += m_pos_speed * seconds;
  384. m_fov += m_fov_speed * seconds;
  385. m_zoom += m_zoom_speed * seconds;
  386. m_hist_scale += m_hist_scale_speed * seconds;
  387. }
  388. #endif //NO_NACL_EM_INPUT
  389. //clamp
  390. vec2 rot_mesh = vec2(SmoothClamp(m_rot.x, -ROT_CLAMP, ROT_CLAMP, ROT_CLAMP * .1f), m_rot.y);
  391. vec2 pos_mesh = vec2(SmoothClamp(m_pos.x, -POS_CLAMP, POS_CLAMP, POS_CLAMP * .1f),
  392. SmoothClamp(m_pos.y, -POS_CLAMP, POS_CLAMP, POS_CLAMP * .1f));
  393. float fov_mesh = SmoothClamp(m_fov, 0.f, FOV_CLAMP, FOV_CLAMP * .1f);
  394. float zoom_mesh = SmoothClamp(m_zoom, -ZOM_CLAMP, ZOM_CLAMP, ZOM_CLAMP * .1f);
  395. vec2 hist_scale_mesh = vec2(SmoothClamp(m_hist_scale.x, 0.f, HST_CLAMP, HST_CLAMP * .1f),
  396. SmoothClamp(m_hist_scale.y, 0.f, HST_CLAMP, HST_CLAMP * .1f));
  397. #if NO_NACL_EM_INPUT
  398. if (KeyDown(KEY_CAM_RESET) && m_reset_timer < 0.f)
  399. {
  400. pos_mesh = vec2::zero;
  401. zoom_mesh = 0.f;
  402. }
  403. #endif //NO_NACL_EM_INPUT
  404. m_rot_mesh = vec2(damp(m_rot_mesh.x, rot_mesh.x, .2f, seconds), damp(m_rot_mesh.y, rot_mesh.y, .2f, seconds));
  405. m_pos_mesh = vec2(damp(m_pos_mesh.x, pos_mesh.x, .2f, seconds), damp(m_pos_mesh.y, pos_mesh.y, .2f, seconds));
  406. m_fov_mesh = damp(m_fov_mesh, fov_mesh, .2f, seconds);
  407. m_zoom_mesh = damp(m_zoom_mesh, zoom_mesh, .2f, seconds);
  408. m_hist_scale_mesh = damp(m_hist_scale_mesh, hist_scale_mesh, .2f, seconds);
  409. //Mesh mat calculation
  410. m_mat_prev = m_mat;
  411. m_mat = mat4::translate(vec3(0.f));
  412. //Target List Setup
  413. TargetCamera tc;
  414. if (m_meshes.Count() && m_mesh_id >= 0)
  415. for (int i = 0; i < m_meshes[m_mesh_id].m1->GetVertexCount(); i++)
  416. tc.AddTarget((m_mat * mat4::translate(m_meshes[m_mesh_id].m1->GetVertexLocation(i))).v3.xyz);
  417. tc.AddTarget(box3(vec3::zero, vec3::one));
  418. for (int k = 0; k < m_ssetup->m_lights.Count() && m_ssetup->m_show_lights; ++k)
  419. {
  420. vec3 light_pos = m_ssetup->m_lights[k]->GetPosition();
  421. mat4 world_cam = m_camera->GetView();
  422. light_pos = (inverse(world_cam) * vec4((world_cam * vec4(light_pos, 1.0f)).xyz * vec3::axis_z, 1.0f)).xyz;
  423. tc.AddTarget(box3(vec3::onen, vec3::one) + light_pos *
  424. ((m_ssetup->m_lights[k]->GetType() == LightType::Directional)?(-1.f):(1.f)));
  425. }
  426. //--
  427. //Update mesh screen location - Get the Min/Max needed
  428. //--
  429. vec2 cam_center(0.f);
  430. float cam_factor = .0f;
  431. vec3 local_min_max[2] = { vec3(FLT_MAX), vec3(-FLT_MAX) };
  432. vec2 screen_min_max[2] = { vec2(FLT_MAX), vec2(-FLT_MAX) };
  433. mat4 world_cam = m_camera->GetView();
  434. mat4 cam_screen = m_camera->GetProjection();
  435. //target on-screen computation
  436. for (int i = 0; i < tc.m_targets.Count(); i++)
  437. {
  438. vec3 obj_loc = tc.m_targets[i];
  439. {
  440. //Debug::DrawBox(obj_loc - vec3(4.f), obj_loc + vec3(4.f), vec4(1.f, 0.f, 0.f, 1.f));
  441. mat4 target_mx = mat4::translate(obj_loc);
  442. vec3 vpos;
  443. //Get location in cam coordinates
  444. target_mx = world_cam * target_mx;
  445. vpos = target_mx.v3.xyz;
  446. local_min_max[0] = min(vpos.xyz, local_min_max[0]);
  447. local_min_max[1] = max(vpos.xyz, local_min_max[1]);
  448. //Get location in screen coordinates
  449. target_mx = cam_screen * target_mx;
  450. vpos = (target_mx.v3 / target_mx.v3.w).xyz;
  451. screen_min_max[0] = min(screen_min_max[0], vpos.xy * vec2(RATIO_WH, 1.f));
  452. screen_min_max[1] = max(screen_min_max[1], vpos.xy * vec2(RATIO_WH, 1.f));
  453. //Build Barycenter
  454. cam_center += vpos.xy;
  455. cam_factor += 1.f;
  456. }
  457. }
  458. float screen_ratio = max(max(lol::abs(screen_min_max[0].x), lol::abs(screen_min_max[0].y)),
  459. max(lol::abs(screen_min_max[1].x), lol::abs(screen_min_max[1].y)));
  460. float z_dist = //m_camera->m_target_distance
  461. length(m_camera->m_position)
  462. + max(local_min_max[0].z, local_min_max[1].z);
  463. vec2 screen_offset = vec2(0.f, -(screen_min_max[1].y + screen_min_max[0].y) * .5f);
  464. m_screen_offset = damp(m_screen_offset, screen_offset, .9f, seconds);
  465. float forced_zoom = m_zoom_mesh;
  466. if (cam_factor > 0.f)
  467. {
  468. vec2 old_sscale = m_camera->GetScreenScale();
  469. float old_ssize = m_camera->GetScreenSize();
  470. float zoom_in = 1.f + lol::max(0.f, forced_zoom);
  471. float zoom_out = 1.f + lol::max(0.f, -forced_zoom);
  472. m_camera->SetScreenScale(max(vec2(0.001f), ((old_sscale * zoom_in) / (screen_ratio * zoom_out * SCREEN_LIMIT))));
  473. m_camera->SetFov(m_fov_mesh);
  474. m_camera->SetScreenInfos(damp(old_ssize, max(1.f, screen_ratio * zoom_out), 1.2f, seconds));
  475. vec3 posz = ((mat4::rotate(m_rot_mesh.y, vec3::axis_y) * mat4::rotate(-m_rot_mesh.x, vec3::axis_x) * vec4::axis_z)).xyz;
  476. vec3 newpos = posz * damp(length(m_camera->m_position), z_dist * 1.2f, .1f, seconds);
  477. m_camera->SetView(newpos, vec3(0.f), vec3::axis_y);
  478. }
  479. //--
  480. //Message Service
  481. //--
  482. String mesh("");
  483. int u = 1;
  484. while (u-- > 0 && MessageService::FetchFirst(MessageBucket::AppIn, mesh))
  485. {
  486. int o = 1;
  487. while (o-- > 0)
  488. {
  489. SceneSetup* new_ssetup = new SceneSetup();
  490. if (new_ssetup->Compile(mesh.C()) && new_ssetup->m_lights.Count())
  491. {
  492. //Store current light datas, in World
  493. Array<LightData> light_datas;
  494. for (int i = 0; i < m_ssetup->m_lights.Count(); ++i)
  495. light_datas << LightData(m_ssetup->m_lights[i]->GetPosition(), m_ssetup->m_lights[i]->GetColor());
  496. if (m_ssetup)
  497. delete(m_ssetup);
  498. m_ssetup = new_ssetup;
  499. m_ssetup->Startup();
  500. //Restore all light datas so blend can occur
  501. mat4 light_mat = m_mat * inverse(mat4(quat::fromeuler_xyz(vec3::zero)));
  502. for (int i = 0; i < m_ssetup->m_lights.Count(); ++i)
  503. {
  504. //Store local dst in current m_ld
  505. LightData ltmp = LightData(m_ssetup->m_lights[i]->GetPosition(), m_ssetup->m_lights[i]->GetColor());
  506. if (i < m_light_datas.Count())
  507. m_light_datas[i] = ltmp;
  508. else
  509. m_light_datas << ltmp;
  510. vec3 loc = vec3::zero;
  511. vec4 col = vec4::zero;
  512. if (i < light_datas.Count())
  513. {
  514. loc = light_datas[i].m_pos;
  515. col = light_datas[i].m_col;
  516. }
  517. //Restore old light datas in new lights
  518. m_ssetup->m_lights[i]->SetPosition(loc);
  519. m_ssetup->m_lights[i]->SetColor(col);
  520. }
  521. }
  522. else
  523. {
  524. m_ssetup->m_custom_cmd += new_ssetup->m_custom_cmd;
  525. delete(new_ssetup);
  526. }
  527. }
  528. }
  529. //Check the custom cmd even if we don't have new messages.
  530. int o = 1;
  531. while (o-- > 0)
  532. {
  533. for (int i = 0; m_ssetup && i < m_ssetup->m_custom_cmd.Count(); ++i)
  534. {
  535. if (m_ssetup->m_custom_cmd[i].m1 == "setmesh")
  536. {
  537. //Create a new mesh
  538. EasyMesh* em = new EasyMesh();
  539. if (em->Compile(m_ssetup->m_custom_cmd[i].m2.C(), false))
  540. {
  541. em->BD()->Cmdi() = 0;
  542. if (m_mesh_id == m_meshes.Count() - 1)
  543. m_mesh_id++;
  544. m_meshes.Push(em, nullptr);
  545. }
  546. else
  547. delete(em);
  548. }
  549. }
  550. }
  551. m_ssetup->m_custom_cmd.Empty();
  552. #endif //ALL_FEATURES
  553. #if NACL_EM
  554. /*
  555. if (m_stream_update_time > .0f)
  556. {
  557. m_stream_update_time = -1.f;
  558. MessageService::Send(MessageBucket::AppIn,
  559. " addlight 0.0 position (4 -1 -4) color (.0 .2 .5 1) \
  560. addlight 0.0 position (8 2 6) color #ffff \
  561. custom setmesh \"[sc#f8f ab 1]\"");
  562. // MessageService::Send(MessageBucket::AppIn, "[sc#f8f ab 1]");
  563. // MessageService::Send(MessageBucket::AppIn, "[sc#f8f ab 1 splt 4 twy 90]");
  564. // MessageService::Send(MessageBucket::AppIn, "[sc#8ff afcb 1 1 1 0]");
  565. // MessageService::Send(MessageBucket::AppIn, "[sc#ff8 afcb 1 1 1 0]");
  566. }
  567. */
  568. #elif WIN32
  569. //--
  570. //File management
  571. //--
  572. m_stream_update_time += seconds;
  573. if (m_stream_update_time > m_stream_update_timer)
  574. {
  575. m_stream_update_time = 0.f;
  576. File f;
  577. f.Open(m_file_name.C(), FileAccess::Read);
  578. String cmd = f.ReadString();
  579. f.Close();
  580. if (cmd.Count()
  581. && (!m_cmdlist.Count() || cmd != m_cmdlist.Last()))
  582. {
  583. m_cmdlist << cmd;
  584. MessageService::Send(MessageBucket::AppIn, cmd);
  585. }
  586. }
  587. #endif //WINDOWS
  588. }
  589. virtual void TickDraw(float seconds)
  590. {
  591. WorldEntity::TickDraw(seconds);
  592. if (!m_init || !m_first_tick)
  593. return;
  594. //TODO : This should probably be "standard LoL behaviour"
  595. #if NO_NACL_EM_INPUT
  596. {
  597. if (KeyReleased(KEY_F2))
  598. Video::SetDebugRenderMode((Video::GetDebugRenderMode() + 1) % DebugRenderMode::Max);
  599. else if (KeyReleased(KEY_F1))
  600. Video::SetDebugRenderMode((Video::GetDebugRenderMode() + DebugRenderMode::Max - 1) % DebugRenderMode::Max);
  601. }
  602. #endif //NO_NACL_EM_INPUT
  603. #if NO_NACL_EM && WITH_TEXTURE
  604. if (!m_default_texture)
  605. {
  606. m_texture_shader = Shader::Create(LOLFX_RESOURCE_NAME(shinymvtexture));
  607. m_texture_uni = m_texture_shader->GetUniformLocation("u_Texture");
  608. m_default_texture = Tiler::Register("data/test-texture.png", ivec2::zero, ivec2(0,1));
  609. }
  610. else if (m_texture && m_default_texture)
  611. m_texture_shader->SetUniform(m_texture_uni, m_default_texture->GetTexture(), 0);
  612. #endif //NO_NACL_EM
  613. g_renderer->SetClearColor(m_ssetup->m_clear_color);
  614. for (int i = 0; i < m_gizmos.Count(); ++i)
  615. {
  616. if (m_gizmos[i]->GetMeshState() == MeshRender::NeedConvert)
  617. m_gizmos[i]->MeshConvert();
  618. else
  619. break;
  620. }
  621. if (m_build_timer > .0f)
  622. {
  623. if (m_build_time < .0f)
  624. {
  625. m_build_time = m_build_timer;
  626. for (int i = 0; i < m_meshes.Count(); ++i)
  627. {
  628. if (m_meshes[i].m1 && m_meshes[i].m1->BD()->Cmdi() < m_meshes[i].m1->BD()->CmdStack().GetCmdNb())
  629. {
  630. EasyMesh* tmp = m_meshes[i].m1;
  631. EasyMesh* newtmp = new EasyMesh(*tmp);
  632. int ii = 1;
  633. #if 1
  634. bool stop = false;
  635. while (!stop)
  636. {
  637. int cmdi = newtmp->BD()->Cmdi() + ii;
  638. if (cmdi < newtmp->BD()->CmdStack().GetCmdNb())
  639. {
  640. switch (newtmp->BD()->CmdStack().GetCmd(cmdi))
  641. {
  642. case EasyMeshCmdType::LoopStart:
  643. case EasyMeshCmdType::LoopEnd:
  644. case EasyMeshCmdType::OpenBrace:
  645. case EasyMeshCmdType::CloseBrace:
  646. case EasyMeshCmdType::ScaleWinding:
  647. case EasyMeshCmdType::QuadWeighting:
  648. case EasyMeshCmdType::PostBuildNormal:
  649. case EasyMeshCmdType::PreventVertCleanup:
  650. case EasyMeshCmdType::SetColorA:
  651. case EasyMeshCmdType::SetColorB:
  652. {
  653. ii++;
  654. break;
  655. }
  656. default:
  657. {
  658. stop = true;
  659. break;
  660. }
  661. }
  662. }
  663. else
  664. stop = true;
  665. }
  666. #endif
  667. newtmp->BD()->CmdExecNb() = ii;
  668. newtmp->ExecuteCmdStack(false);
  669. m_meshes[i].m1 = newtmp;
  670. delete(tmp);
  671. }
  672. }
  673. }
  674. m_build_time -= seconds;
  675. }
  676. #define NORMAL_USAGE 1
  677. #if 0
  678. PrimitiveFace NewFace;
  679. NewFace.SetNormal(vec3::axis_z);
  680. NewFace.SetCenter(vec3::zero);
  681. int imax = 4, jmax = 4;
  682. int sz = 2;
  683. for (int i = 0; i < imax; ++i)
  684. {
  685. for (int j = 0; j < jmax; ++j)
  686. {
  687. NewFace.AddPolygon(vec3(ivec3(i, j, 0) * sz),
  688. vec3(ivec3(i, j, 0) * sz + ivec3(sz, 0, 0)),
  689. vec3(ivec3(i, j, 0) * sz + ivec3(sz, sz, 0)));
  690. NewFace.AddPolygon(vec3(ivec3(i, j, 0) * sz),
  691. vec3(ivec3(i, j, 0) * sz + ivec3(sz, sz, 0)),
  692. vec3(ivec3(i, j, 0) * sz + ivec3( 0, sz, 0)));
  693. }
  694. }
  695. for (int i = 0; i < NewFace.m_edges.Count(); ++i)
  696. {
  697. Debug::DrawLine(NewFace.EV0(i) + vec3(.0f, .0f, 2.f), NewFace.EV1(i) + vec3(.0f, .0f, 2.f),
  698. NewFace.m_edges[i].m3 ? vec4(.0f, .7f, .0f, 1.f) : vec4(.7f, .0f, .0f, 1.f));
  699. Debug::DrawBox(NewFace.EV0(i) + vec3(.0f, .0f, 2.f) + vec3(-.1f),
  700. NewFace.EV0(i) + vec3(.0f, .0f, 2.f) + vec3(+.1f),
  701. NewFace.m_edges[i].m3 ? vec4(.0f, .7f, .0f, 1.f) : vec4(.7f, .0f, .0f, 1.f));
  702. }
  703. NewFace.CleanEdges();
  704. for (int i = 0; i < NewFace.m_edges.Count(); ++i)
  705. {
  706. Debug::DrawLine(NewFace.EV0(i), NewFace.EV1(i), vec4(vec3::zero, 1.f));
  707. Debug::DrawBox(NewFace.EV0(i) + vec3(-.1f),
  708. NewFace.EV0(i) + vec3(+.1f),
  709. vec4(vec3::zero, 1.f));
  710. }
  711. //Try with mesh
  712. PrimitiveMesh NewMesh;
  713. for (int i = m_meshes.Count() - 1; 0 <= i && i < m_meshes.Count(); i++)
  714. {
  715. for (int j = 0; j < m_meshes[i].m1->m_indices.Count(); j += 3)
  716. {
  717. VertexData v[3] = { m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j ]],
  718. m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j+1]],
  719. m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j+2]] };
  720. NewMesh.AddPolygon(v[0].m_coord, v[1].m_coord, v[2].m_coord, v[0].m_normal);
  721. }
  722. NewMesh.CleanFaces();
  723. break;
  724. }
  725. for (int j = 0; j < NewMesh.m_faces.Count(); ++j)
  726. {
  727. for (int i = 0; i < NewMesh.m_faces[j].m_edges.Count(); ++i)
  728. {
  729. vec3 v0 = NewMesh.m_faces[j].EV0(i) + NewMesh.m_faces[j].GetNormal() * .4f;
  730. vec3 v1 = NewMesh.m_faces[j].EV1(i) + NewMesh.m_faces[j].GetNormal() * .4f;
  731. Debug::DrawLine(v0, v1, vec4(vec3::zero, 1.f));
  732. Debug::DrawBox(v0 + vec3(-.1f), v0 + vec3(+.1f), vec4(vec3::zero, 1.f));
  733. }
  734. }
  735. #elif NORMAL_USAGE
  736. vec3 x = vec3(1.f,0.f,0.f);
  737. vec3 y = vec3(0.f,1.f,0.f);
  738. mat4 save_proj = m_camera->GetProjection();
  739. //Y object Offset
  740. mat4 mat_obj_offset = mat4::translate(x * m_screen_offset.x + y * m_screen_offset.y) *
  741. //Mesh Pos Offset
  742. mat4::translate((x * m_pos_mesh.x * RATIO_HW + y * m_pos_mesh.y) * 2.f * (1.f + .5f * m_zoom_mesh / SCREEN_LIMIT));
  743. //Align right meshes
  744. mat4 mat_align = mat4::translate(x - x * RATIO_HW);
  745. mat4 mat_gizmo = mat_obj_offset * mat_align * save_proj;
  746. for (int i = 0; i < m_meshes.Count(); i++)
  747. {
  748. {
  749. if (m_meshes[i].m1->GetMeshState() == MeshRender::NeedConvert)
  750. {
  751. #if WITH_TEXTURE
  752. m_meshes[i].m1->MeshConvert(new DefaultShaderData(((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) |
  753. (1 << VertexUsage::Color) | (1 << VertexUsage::TexCoord)),
  754. m_texture_shader, true));
  755. #else
  756. m_meshes[i].m1->MeshConvert();
  757. #endif //WITH_TEXTURE
  758. }
  759. #if ALL_FEATURES
  760. float j = -(float)(m_meshes.Count() - (i + 1)) + (-m_mesh_id1 + (float)(m_meshes.Count() - 1));
  761. if (m_mesh_id1 - m_render_max[0] > (float)i && m_mesh_id1 - m_render_max[1] < (float)i &&
  762. m_meshes[i].m1->GetMeshState() > MeshRender::NeedConvert)
  763. {
  764. float a_j = lol::abs(j);
  765. float i_trans = (a_j * a_j * m_hist_scale_mesh.x + a_j * m_hist_scale_mesh.x) * .5f;
  766. float i_scale = clamp(1.f - (m_hist_scale_mesh.y * (m_mesh_id1 - (float)i)), 0.f, 1.f);
  767. //Mesh count offset
  768. mat4 mat_count_offset = mat4::translate(x * RATIO_HW * 2.f * (j + i_trans));
  769. //Mesh count scale
  770. mat4 mat_count_scale = mat4::scale(vec3(vec2(i_scale), 1.f));
  771. //Camera projection
  772. mat4 new_proj = mat_obj_offset * mat_count_offset * mat_align * mat_count_scale * save_proj;
  773. m_camera->SetProjection(new_proj);
  774. m_meshes[i].m1->Render(m_mat);
  775. g_renderer->Clear(ClearMask::Depth);
  776. }
  777. m_camera->SetProjection(save_proj);
  778. #else
  779. m_meshes[i].m1->Render(m_mat);
  780. #endif //ALL_FEATURES
  781. }
  782. }
  783. //Scene setup update
  784. if (m_ssetup)
  785. {
  786. m_camera->SetProjection(mat_gizmo);
  787. if (m_ssetup->m_show_gizmo)
  788. m_gizmos[GZ_Editor]->Render(m_mat);
  789. if (m_ssetup->m_show_lights)
  790. {
  791. for (int k = 0; k < m_ssetup->m_lights.Count(); ++k)
  792. {
  793. Light* ltmp = m_ssetup->m_lights[k];
  794. mat4 world = mat4::translate(ltmp->GetPosition());
  795. mat4 local = mat4::translate((inverse(m_mat) * world).v3.xyz);
  796. //dir light
  797. if (ltmp->GetType() == LightType::Directional)
  798. {
  799. m_gizmos[GZ_LightPos]->Render(m_mat * inverse(local));
  800. m_gizmos[GZ_LightDir]->Render(inverse(world) * inverse(mat4::lookat(vec3::zero, -ltmp->GetPosition(), vec3::axis_y)));
  801. }
  802. else //point light
  803. {
  804. m_gizmos[GZ_LightPos]->Render(m_mat * local);
  805. }
  806. }
  807. }
  808. m_camera->SetProjection(save_proj);
  809. }
  810. #endif //NORMAL_USAGE
  811. #if 0 //Debug normal draw
  812. for (int i = m_meshes.Count() - 1; 0 <= i && i < m_meshes.Count(); i++)
  813. {
  814. for (int j = 0; j < m_meshes[i].m1->m_indices.Count(); j += 3)
  815. {
  816. VertexData v[3] = { m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j ]],
  817. m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j+1]],
  818. m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j+2]]
  819. };
  820. for (int k = 0; k < 3; k++)
  821. Debug::DrawLine((m_mat * mat4::translate(v[k].m_coord)).v3.xyz,
  822. (m_mat * mat4::translate(v[(k+1)%3].m_coord)).v3.xyz, vec4(vec3((v[k].m_coord.z + 1.f)*.5f),1.f));
  823. }
  824. for (int j = 0; j < m_meshes[i].m1->m_vert.Count(); j++)
  825. {
  826. VertexData &v = m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j]];
  827. Debug::DrawLine((m_mat * mat4::translate(v.m_coord)).v3.xyz,
  828. (m_mat * mat4::translate(v.m_coord)).v3.xyz +
  829. (m_mat * vec4(v.m_normal * 5.f, 0.f)).xyz, vec4(lol::abs(v.m_normal), 1.f));
  830. }
  831. }
  832. #endif
  833. }
  834. private:
  835. SceneSetup* m_ssetup;
  836. Array<LightData> m_light_datas;
  837. Controller* m_controller;
  838. short m_input_usage;
  839. mat4 m_mat;
  840. mat4 m_mat_prev;
  841. bool m_init;
  842. bool m_first_tick;
  843. //Camera Setup
  844. Camera * m_camera;
  845. float m_reset_timer;
  846. float m_fov;
  847. float m_fov_mesh;
  848. float m_fov_speed;
  849. float m_zoom;
  850. float m_zoom_mesh;
  851. float m_zoom_speed;
  852. vec2 m_rot;
  853. vec2 m_rot_mesh;
  854. vec2 m_rot_speed;
  855. vec2 m_pos;
  856. vec2 m_pos_mesh;
  857. vec2 m_pos_speed;
  858. vec2 m_hist_scale;
  859. vec2 m_hist_scale_mesh;
  860. vec2 m_hist_scale_speed;
  861. vec2 m_screen_offset;
  862. //Mesh update timer
  863. float m_build_timer;
  864. float m_build_time;
  865. //Mesh infos
  866. vec2 m_render_max;
  867. int m_mesh_render;
  868. int m_mesh_id;
  869. float m_mesh_id1;
  870. Array<EasyMesh*, EasyMesh*> m_meshes;
  871. Array<EasyMesh*> m_gizmos;
  872. //File data
  873. String m_file_name;
  874. Array<String> m_cmdlist;
  875. float m_stream_update_time;
  876. float m_stream_update_timer;
  877. //misc datas
  878. Shader * m_texture_shader;
  879. TileSet * m_default_texture;
  880. Texture * m_texture;
  881. ShaderUniform m_texture_uni;
  882. };
  883. //The basic main :
  884. int main(int argc, char **argv)
  885. {
  886. System::Init(argc, argv);
  887. Application app("MeshViewer", ivec2((int)DEFAULT_WIDTH, (int)DEFAULT_HEIGHT), 60.0f);
  888. if (argc > 1)
  889. new MeshViewer(argv[1]);
  890. else
  891. new MeshViewer();
  892. app.Run();
  893. return EXIT_SUCCESS;
  894. }