| @@ -81,7 +81,6 @@ demos/lol.js/lol.js | |||
| doc/samples/benchsuite | |||
| doc/samples/bluenoise | |||
| doc/samples/btphystest | |||
| doc/samples/meshviewer/meshviewer | |||
| doc/samples/sandbox/sample | |||
| doc/samples/math/pi | |||
| doc/samples/math/poly | |||
| @@ -269,7 +269,6 @@ AC_CONFIG_FILES( | |||
| doc/doxygen.cfg | |||
| doc/samples/Makefile | |||
| doc/samples/math/Makefile | |||
| doc/samples/meshviewer/Makefile | |||
| doc/samples/sandbox/Makefile | |||
| doc/tutorial/Makefile | |||
| tools/Makefile | |||
| @@ -1,7 +1,7 @@ | |||
| include $(top_srcdir)/build/autotools/common.am | |||
| SUBDIRS = math meshviewer sandbox | |||
| SUBDIRS = math sandbox | |||
| bench: benchsuite$(EXEEXT) | |||
| ./benchsuite$(EXEEXT) | |||
| @@ -1,19 +0,0 @@ | |||
| include $(top_srcdir)/build/autotools/common.am | |||
| if BUILD_SAMPLES | |||
| if LOL_USE_GL | |||
| noinst_PROGRAMS = meshviewer | |||
| endif | |||
| endif | |||
| meshviewer_SOURCES = meshviewer.cpp meshviewer.h \ | |||
| scenesetup.cpp scenesetup.h \ | |||
| shinymvtexture.lolfx shinyfur.lolfx | |||
| meshviewer_CPPFLAGS = $(AM_CPPFLAGS) | |||
| meshviewer_DEPENDENCIES = @LOL_DEPS@ @LOL_LUA_DEPS@ | |||
| meshviewer_LDFLAGS = $(AM_LDFLAGS) @LOL_LUA_DEPS@ | |||
| if LOL_USE_EMSCRIPTEN | |||
| meshviewer_LDFLAGS += -s EXPORTED_FUNCTIONS="['_main', '_C_Send']" | |||
| endif | |||
| @@ -1,106 +0,0 @@ | |||
| //------------------------------------------------------------------------- | |||
| //Command vars operations | |||
| //------------------------------------------------------------------------- | |||
| CmdVar("[ ]", ["Opens a new scope,\nevery operations between the braces\nwill only be done to the vertices added\nsince the start of this scope."]); | |||
| CmdVar("float", ["Fraction value", "0.0"]); | |||
| CmdVar("int", ["No decimal value", "0"]); | |||
| CmdVar("bool", ["Boolean value", "true/false", "1/0"]); | |||
| CmdVar("color", ["Red/Green/Blue/{Alpha}", | |||
| "HEXA: #ABC{D}", " #AABBCC{DD}", | |||
| "FLOAT: f f f f", " (f f f f)", " (f)"]); | |||
| CmdVar("vec3", ["X/Y/Z as float", " f f f", "(f f f)", "(f)"]); | |||
| CmdVar("vec2", ["X/Y/Z as float", " f f", "(f f)", "(f)"]); | |||
| //------------------------------------------------------------------------- | |||
| //Mesh CSG operations | |||
| //------------------------------------------------------------------------- | |||
| CmdType(["csgu", "csgunion"], "Performs a Union operation as :\n(current_scope_outside + new_scope_Outside)", [CmdArg("[ ]", "New scope")]); | |||
| CmdType(["csgs", "csgsubstract"], "Performs a Substract operation as :\n(current_scope_Outside + new_scope_Inside-inverted)", [CmdArg("[ ]", "New scope")]); | |||
| CmdType(["csgsl", "csgsubstractloss"], "Performs a Substract operation without keeping the new_scope part", [CmdArg("[ ]", "New scope")]); | |||
| CmdType(["csga", "csgand"], "Performs an And operation as :\n(current_scope_Inside + new_scope__Inside)", [CmdArg("[ ]", "New scope")]); | |||
| CmdType(["csgx", "csgxor"], "Performs a Xor operation as :\n(current_scope_Outside + current_scope_Inside-inverted + new_scope_Outside + new_scope_Inside-inverted)", [CmdArg("[ ]", "New scope")]); | |||
| //------------------------------------------------------------------------- | |||
| //Mesh Base operations | |||
| //------------------------------------------------------------------------- | |||
| CmdType(["tsw", "tglscalewind"], "When active, on negative-scaling,\nnormal-vector correction will not occur\nDefault : Inactive"); | |||
| CmdType(["tqw", "tglquadweight"], "When active, quad will have a fifth center vertex\nDefault : Inactive"); | |||
| CmdType(["tpbn", "tglpstbuildnormal"], "When active, normal will be only computed after all the command\nDefault : Inactive"); | |||
| CmdType(["tvnc", "tglvertnocleanup"], "When active, vertices cleanup will not be done at the end of all the commands\nDefault : Inactive"); | |||
| CmdType(["sc", "setcolor"], "Set A & B color", [CmdArg("color", "color")]); | |||
| CmdType(["sca", "setcolora"], "Set A color", [CmdArg("color", "color")]); | |||
| CmdType(["scb", "setcolorb"], "Set B color", [CmdArg("color", "color")]); | |||
| CmdType(["scv", "setcolorv"], "Set the color of all vertices in this scope", [CmdArg("color", "color")]); | |||
| CmdType(["lp", "loop"], "Performs a loop with the code in the braces.\nDoesn't open a new scope.", [CmdArg("int", "loopnb"), CmdArg("[ ]", "Loop command")]); | |||
| //------------------------------------------------------------------------- | |||
| //Vertices operations | |||
| //------------------------------------------------------------------------- | |||
| CmdType(["vm", "vertmerge"], "Will merge all the same face vertices"); | |||
| CmdType(["vs", "vertseparate"], "Will separate all the same face vertices"); | |||
| //------------------------------------------------------------------------- | |||
| //Mesh transform operations | |||
| //------------------------------------------------------------------------- | |||
| CmdType(["tx", "translatex"], "Translate vertices along the X axis", [CmdArg("float", "n")]); | |||
| CmdType(["ty", "translatey"], "Translate vertices along the Y axis", [CmdArg("float", "n")]); | |||
| CmdType(["tz", "translatez"], "Translate vertices along the Z axis", [CmdArg("float", "n")]); | |||
| CmdType(["t", "translate"], "Translate vertices", [CmdArg("vec3", "v")]); | |||
| CmdType(["rx", "rotatex"], "Rotate vertices along the X axis", [CmdArg("float", "degree")]); | |||
| CmdType(["ry", "rotatey"], "Rotate vertices along the Y axis", [CmdArg("float", "degree")]); | |||
| CmdType(["rz", "rotatez"], "Rotate vertices along the Z axis", [CmdArg("float", "degree")]); | |||
| CmdType(["r", "rotate"], "Rotate vertices along the given axis", [CmdArg("float", "degree"), CmdArg("vec3", "axis")]); | |||
| CmdType(["rj", "radialjitter"], "Randomly move vertices along Origin-to-vertex as f(vtx) = vtx + o2v * (1.0 + rand(r))", [CmdArg("float", "r")]); | |||
| CmdType(["tax", "taperx"], "multiply axis y/z by f(x)\nf(z) = z * (1.0 + (nz * f(x) + xoff))\nf(x) = absolute ? abs_x : x", [CmdArg("float", "ny"), CmdArg("float", "nz"), CmdArg("float", "xoff", "0.0"), CmdArg("bool", "absolute", "true")]); | |||
| CmdType(["tay", "tapery"], "multiply axis x/z by f(y)\nf(x) = x * (1.0 + (nx * f(y) + yoff))\nf(y) = absolute ? abs_y : y", [CmdArg("float", "nx"), CmdArg("float", "nz"), CmdArg("float", "yoff", "0.0"), CmdArg("bool", "absolute", "true")]); | |||
| CmdType(["taz", "taperz"], "multiply axis x/y by f(z)\nf(y) = y * (1.0 + (ny * f(z) + zoff))\nf(z) = absolute ? abs_z : z", [CmdArg("float", "nx"), CmdArg("float", "ny"), CmdArg("float", "zoff", "0.0"), CmdArg("bool", "absolute", "true")]); | |||
| CmdType(["twx", "twistx"], "Twist vertices around x axis with x as rotation value\nf(p) = (RotateX(x * t + toff) * p)", [CmdArg("float", "t"), CmdArg("float", "toff", "0.0")]); | |||
| CmdType(["twy", "twisty"], "Twist vertices around y axis with y as rotation value\nf(p) = (RotateY(y * t + toff) * p)", [CmdArg("float", "t"), CmdArg("float", "toff", "0.0")]); | |||
| CmdType(["twz", "twistz"], "Twist vertices around z axis with z as rotation value\nf(p) = (RotateZ(z * t + toff) * p)", [CmdArg("float", "t"), CmdArg("float", "toff", "0.0")]); | |||
| CmdType(["shx", "shearx"], "Shear vertices using x value as shear quantity\nf(z) = z + (nz * f(x) + xoff)\nf(x) = absolute ? abs_x : x", [CmdArg("float", "ny"), CmdArg("float", "nz"), CmdArg("float", "xoff", "0.0"), CmdArg("bool", "absolute", "true")]); | |||
| CmdType(["shy", "sheary"], "Shear vertices using y value as shear quantity\nf(x) = x + (nx * f(y) + yoff)\nf(y) = absolute ? abs_y : y", [CmdArg("float", "nx"), CmdArg("float", "nz"), CmdArg("float", "yoff", "0.0"), CmdArg("bool", "absolute", "true")]); | |||
| CmdType(["shz", "shearz"], "Shear vertices using z value as shear quantity\nf(y) = y + (ny * f(z) + zoff)\nf(z) = absolute ? abs_z : z", [CmdArg("float", "nx"), CmdArg("float", "ny"), CmdArg("float", "zoff", "0.0"), CmdArg("bool", "absolute", "true")]); | |||
| CmdType(["stx", "stretchx"], "Stretch vertices using x value as stretch quantity\nf(z) = z + (pow(x, nz) + xoff)", [CmdArg("float", "ny"), CmdArg("float", "nz"), CmdArg("float", "xoff", "0.0")]); | |||
| CmdType(["sty", "stretchy"], "Stretch vertices using y value as stretch quantity\nf(x) = x + (pow(y, nx) + yoff)", [CmdArg("float", "nx"), CmdArg("float", "nz"), CmdArg("float", "yoff", "0.0")]); | |||
| CmdType(["stz", "stretchz"], "Stretch vertices using z value as stretch quantity\nf(y) = y + (pow(z, ny) + zoff)", [CmdArg("float", "nx"), CmdArg("float", "ny"), CmdArg("float", "zoff", "0.0")]); | |||
| CmdType(["bdxy", "bendxy"], "Bend vertices using x as bend quantity along y axis\nf(p) = (RotateY(x * t + toff) * p)", [CmdArg("float", "t"), CmdArg("float", "toff", "0.0")]); | |||
| CmdType(["bdxz", "bendxz"], "Bend vertices using x as bend quantity along z axis\nf(p) = (RotateZ(x * t + toff) * p)", [CmdArg("float", "t"), CmdArg("float", "toff", "0.0")]); | |||
| CmdType(["bdyx", "bendyx"], "Bend vertices using y as bend quantity along x axis\nf(p) = (RotateX(y * t + toff) * p)", [CmdArg("float", "t"), CmdArg("float", "toff", "0.0")]); | |||
| CmdType(["bdyz", "bendyz"], "Bend vertices using y as bend quantity along z axis\nf(p) = (RotateZ(y * t + toff) * p)", [CmdArg("float", "t"), CmdArg("float", "toff", "0.0")]); | |||
| CmdType(["bdzx", "bendzx"], "Bend vertices using z as bend quantity along x axis\nf(p) = (RotateX(z * t + toff) * p)", [CmdArg("float", "t"), CmdArg("float", "toff", "0.0")]); | |||
| CmdType(["bdzy", "bendzy"], "Bend vertices using z as bend quantity along y axis\nf(p) = (RotateY(z * t + toff) * p)", [CmdArg("float", "t"), CmdArg("float", "toff", "0.0")]); | |||
| CmdType(["sx", "scalex"], "Scale vertices", [CmdArg("vec3", "s")]); | |||
| CmdType(["sy", "scaley"], "Scale vertices", [CmdArg("vec3", "s")]); | |||
| CmdType(["sz", "scalez"], "Scale vertices", [CmdArg("vec3", "s")]); | |||
| CmdType(["s", "scale"], "Uniformly Scale vertices", [CmdArg("float", "s")]); | |||
| CmdType(["dup", "duplicate"], "Duplicate scope mesh and apply commands in the brackets.", [CmdArg("[ ]", "")]); | |||
| CmdType(["mx", "mirrorx"], "Mirror vertices through X-plane"); | |||
| CmdType(["my", "mirrory"], "Mirror vertices through Y-plane"); | |||
| CmdType(["mz", "mirrorz"], "Mirror vertices through Z-plane"); | |||
| CmdType(["ch", "chamfer"], "DOES NOT WORK: Performs a chamfer operation", [CmdArg("float", "f")]); | |||
| CmdType(["splt", "splittriangle"], "split triangles in 4 smaller ones", [CmdArg("int", "pass")]); | |||
| CmdType(["smth", "smooth"], "Smooth the mesh by subdivising it", [CmdArg("int", "pass"), CmdArg("int", "split_per_pass"), CmdArg("int", "smooth_per_pass")]); | |||
| //------------------------------------------------------------------------- | |||
| //Mesh shape operations | |||
| //------------------------------------------------------------------------- | |||
| CmdType(["ac", "addcylinder"], "Cylinder centered on (0,0,0) with BBox:\nMin: [-.5 * max(d1, d2),-.5 * h,-.5 * max(d1, d2)]\nMax: [ .5 * max(d1, d2), .5 * h, .5 * max(d1, d2)]", | |||
| [CmdArg("int", "nsides"), CmdArg("float", "h"), CmdArg("float", "d1"), CmdArg("float", "d2", "d1"), | |||
| CmdArg("bool", "dualsides", "false"), CmdArg("bool", "smooth", "false"), CmdArg("bool", "close", "false")]); | |||
| CmdType(["asph", "addsphere"], "Sphere centered on (0,0,0) with BBox:\nMin: [-.5 * d]\nMax: [ .5 * d]", [CmdArg("int", "ndivisions"), CmdArg("float", "d")]); | |||
| CmdType(["acap", "addcapsule"], "Capsule centered on (0,0,0) with BBox:\nMin: [-.5 * d,-(.5 * d + h),-.5 * d]\nMax: [ .5 * d, (.5 * d + h), .5 * d]", [CmdArg("int", "ndivisions"), CmdArg("float", "h"), CmdArg("float", "d")]); | |||
| CmdType(["ato", "addtorus"], "Torus centered on (0,0,0) with BBox:\nMax: [-.5 * d2]\nMax: [ .5 * d2]", [CmdArg("int", "ndivisions"), CmdArg("float", "d1"), CmdArg("float", "d2")]); | |||
| CmdType(["ab", "addbox"], "Box centered on (0,0,0) with BBox:\nMin: [-.5 * size]\nMax: [ .5 * size]", [CmdArg("vec3", "size"), CmdArg("float", "chamf", "0.0")]); | |||
| CmdType(["ascb", "addsmoothchamfbox"], "Box centered on (0,0,0) with BBox:\nMin: [-.5 * size]\nMax: [ .5 * size]", [CmdArg("vec3", "size"), CmdArg("float", "chamf")]); | |||
| CmdType(["afcb", "addflatchamfbox"], "Box centered on (0,0,0) with BBox:\nMin: [-.5 * size]\nMax: [ .5 * size]", [CmdArg("vec3", "size"), CmdArg("float", "chamf")]); | |||
| CmdType(["as", "addstar"], "Append a Star centered on (0,0,0)\nContained in a disc of max(d1, d2) diameter.", | |||
| [CmdArg("int", "nbranches"), CmdArg("float", "d1"), CmdArg("float", "d2"), | |||
| CmdArg("bool", "fade", "false"), CmdArg("bool", "fade2", "false")]); | |||
| CmdType(["aes", "addexpandedstar"], "Star centered on (0,0,0)\nContained in a disc of max(max(d1, d2), max(d1 + extrad, d2 + extrad)) diameter.\nExpanded star branches use Color2.", | |||
| [CmdArg("int", "nbranches"), CmdArg("float", "d1"), CmdArg("float", "d2"), CmdArg("float", "extrad", "0.0")]); | |||
| CmdType(["ad", "adddisc"], "Disc centered on (0,0,0) with d diameter.", [CmdArg("int", "nsides"), CmdArg("float", "d"), CmdArg("bool", "fade", "false")]); | |||
| CmdType(["at", "addtriangle"], "Triangle centered on (0,0,0)\nContained in a disc of d diameter.", [CmdArg("float", "d"), CmdArg("bool", "fade", "false")]); | |||
| CmdType(["aq", "addquad"], "Quad centered on (0,0,0) with BBox:\nMin: [-size * .5f, 0,-size * .5f]\nMax: [ size * .5f, 0, size * .5f]", [CmdArg("float", "size"), CmdArg("bool", "fade", "false")]); | |||
| CmdType(["acg", "addcog"], "Gear centered on (0,0,0) with BBox:\nMin: [-.5 * max(d1, d2),-.5 * h,-.5 * max(d1, d2)]\nMax: [ .5 * max(d1, d2), .5 * h, .5 * max(d1, d2)]", | |||
| [CmdArg("float", "h"), CmdArg("vec2", "d10d20"), CmdArg("vec2", "d11d21"), CmdArg("vec2", "d12d22"), | |||
| CmdArg("float", "sidemul", "0.0"), CmdArg("bool", "offset", "false")]); | |||
| @@ -1,10 +0,0 @@ | |||
| [Debug] | |||
| Pos=60,60 | |||
| Size=400,400 | |||
| Collapsed=0 | |||
| [Camera Setup] | |||
| Pos=60,60 | |||
| Size=307,314 | |||
| Collapsed=0 | |||
| @@ -1,344 +0,0 @@ | |||
| // | |||
| // Lol Engine — EasyMesh tutorial | |||
| // | |||
| // Copyright © 2009—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
| // © 2012—2018 Sam Hocevar <sam@hocevar.net> | |||
| // | |||
| // Lol Engine is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #pragma once | |||
| #include <string> | |||
| #include <map> | |||
| namespace lol | |||
| { | |||
| enum | |||
| { | |||
| IPT_MV_KBOARD = 0, | |||
| IPT_MV_MOUSE, | |||
| INPUT_MAX | |||
| }; | |||
| enum MVKeyboardList | |||
| { | |||
| KEY_CAM_RESET = 0, | |||
| KEY_CAM_POS, | |||
| KEY_CAM_FOV, | |||
| KEY_CAM_UP, | |||
| KEY_CAM_DOWN, | |||
| KEY_CAM_LEFT, | |||
| KEY_CAM_RIGHT, | |||
| KEY_MESH_NEXT, | |||
| KEY_MESH_PREV, | |||
| KEY_F1, | |||
| KEY_F2, | |||
| KEY_F3, | |||
| KEY_F4, | |||
| KEY_F5, | |||
| KEY_ESC, | |||
| KEY_MAX | |||
| }; | |||
| enum MVMouseKeyList | |||
| { | |||
| MSE_CAM_ROT = KEY_MAX, | |||
| MSE_CAM_POS, | |||
| MSE_CAM_FOV, | |||
| MSE_FOCUS, | |||
| MSE_MAX | |||
| }; | |||
| enum MVMouseAxisList | |||
| { | |||
| MSEX_CAM_Y = 0, | |||
| MSEX_CAM_X, | |||
| MSEX_MAX | |||
| }; | |||
| #define MAX_KEYS MSE_MAX | |||
| #define MAX_AXIS MSEX_MAX | |||
| //MeshViewerInput --------------------------------------------------------- | |||
| struct MeshViewerKeyInputBase : public StructSafeEnum | |||
| { | |||
| enum Type | |||
| { | |||
| KBD_BEG = 0, | |||
| Exit = KBD_BEG, | |||
| KBD_END, | |||
| MSE_BEG = KBD_END, | |||
| LeftClick = MSE_BEG, | |||
| RightClick, | |||
| MiddleClick, | |||
| Focus, | |||
| MSE_END, | |||
| MAX = MSE_END, | |||
| }; | |||
| protected: | |||
| virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
| { | |||
| enum_map[Exit] = g_name_key_Escape; | |||
| enum_map[LeftClick] = g_name_mouse_key_left; | |||
| enum_map[RightClick] = g_name_mouse_key_right; | |||
| enum_map[MiddleClick] = g_name_mouse_key_middle; | |||
| enum_map[Focus] = g_name_mouse_key_in_screen; | |||
| return true; | |||
| } | |||
| }; | |||
| typedef SafeEnum<MeshViewerKeyInputBase> MeshViewerKeyInput; | |||
| #define ALL_FEATURES 1 | |||
| #define NO_SC_SETUP 0 | |||
| enum GizmoType | |||
| { | |||
| GZ_Editor = 0, | |||
| GZ_LightPos, | |||
| GZ_LightDir, | |||
| GZ_MAX | |||
| }; | |||
| struct LightData | |||
| { | |||
| LightData(vec3 pos, vec4 col) | |||
| { | |||
| m_pos = pos; | |||
| m_col = col; | |||
| } | |||
| vec3 m_pos; | |||
| vec4 m_col; | |||
| }; | |||
| //ViewerObject ---------------------------------------------------------------- | |||
| class ViewerObject | |||
| { | |||
| public: | |||
| ViewerObject() { } | |||
| ViewerObject(std::string const& name) : m_name(name) { } | |||
| virtual ~ViewerObject() { } | |||
| virtual void tick_draw(float seconds, Scene &scene) { } | |||
| std::string GetName() { return m_name; } | |||
| protected: | |||
| std::string m_name; | |||
| }; | |||
| //EasyMeshViewerObject -------------------------------------------------------- | |||
| class EasyMeshViewerObject : public ViewerObject | |||
| { | |||
| typedef ViewerObject super; | |||
| public: | |||
| EasyMeshViewerObject() | |||
| : ViewerObject() { } | |||
| EasyMeshViewerObject(std::string const& name, EasyMesh const& mesh) | |||
| : ViewerObject(name) | |||
| { | |||
| Init(name, mesh); | |||
| } | |||
| virtual ~EasyMeshViewerObject() { } | |||
| virtual void tick_draw(float seconds, Scene &scene); | |||
| void Init(std::string const& name, EasyMesh const& mesh) | |||
| { | |||
| m_name = name; | |||
| m_mesh = mesh; | |||
| } | |||
| protected: | |||
| EasyMesh m_mesh; | |||
| }; | |||
| //MeshViewerLoadJob ----------------------------------------------------------- | |||
| class MeshViewerLoadJob : public ThreadJob | |||
| { | |||
| friend class BaseThreadManager; | |||
| typedef ThreadJob super; | |||
| public: | |||
| inline MeshViewerLoadJob() : ThreadJob() { } | |||
| inline MeshViewerLoadJob(std::string const& path) | |||
| : ThreadJob(ThreadJobType::WORK_TODO), m_path(path) { } | |||
| virtual ~MeshViewerLoadJob() { } | |||
| virtual void RetrieveResult(class MeshViewer* app) { } | |||
| protected: | |||
| virtual bool DoWork() { return super::DoWork(); } | |||
| protected: | |||
| std::string m_path; | |||
| }; | |||
| //EasyMeshLoadJob ------------------------------------------------------------- | |||
| class EasyMeshLoadJob : public MeshViewerLoadJob | |||
| { | |||
| friend class BaseThreadManager; | |||
| typedef EasyMeshLoadJob super; | |||
| public: | |||
| inline EasyMeshLoadJob() : MeshViewerLoadJob() { } | |||
| inline EasyMeshLoadJob(std::string const& path) | |||
| : MeshViewerLoadJob(path) { } | |||
| virtual ~EasyMeshLoadJob() { } | |||
| static MeshViewerLoadJob* GetInstance(std::string const& path); | |||
| virtual void RetrieveResult(class MeshViewer* app); | |||
| protected: | |||
| static bool Check(std::string const& path) { return path.find(".easymesh") != std::string::npos; } | |||
| virtual bool DoWork(); | |||
| protected: | |||
| EasyMeshLuaLoader m_loader; | |||
| array<EasyMeshViewerObject*> m_meshes; | |||
| }; | |||
| //MeshViewer ------------------------------------------------------------------ | |||
| class MeshViewer : public WorldEntity | |||
| { | |||
| typedef WorldEntity super; | |||
| public: | |||
| MeshViewer(char const *file_name = "../data/meshviewer.easymesh.lua"); | |||
| ~MeshViewer(); | |||
| void Start(); | |||
| void Stop(); | |||
| void UpdateSceneSetup(bool only_destroy = false); | |||
| MeshViewerLoadJob* GetLoadJob(std::string const& path); | |||
| void AddViewerObj(ViewerObject* obj) { m_objs << obj; } | |||
| virtual void tick_game(float seconds); | |||
| virtual void tick_draw(float seconds, Scene &scene); | |||
| bool KeyReleased(MVKeyboardList index); | |||
| bool KeyPressed(MVKeyboardList index); | |||
| bool KeyDown(MVKeyboardList index); | |||
| bool KeyReleased(MVMouseKeyList index); | |||
| bool KeyPressed(MVMouseKeyList index); | |||
| bool KeyDown(MVMouseKeyList index); | |||
| float AxisValue(MVMouseAxisList index); | |||
| void Prepare(); | |||
| void Unprepare(); | |||
| void Update(float seconds); | |||
| void Draw(float seconds, Scene &scene); | |||
| private: | |||
| //Main stuff -------------------------------------------------------------- | |||
| bool m_init = false; | |||
| bool m_first_tick = false; | |||
| InputProfile m_profile; | |||
| Camera* m_camera = nullptr; | |||
| Text* m_text = nullptr; | |||
| //ImGui stuff | |||
| bool m_menu_cam_useage = true; | |||
| float m_menu_cam_fov = radians(40.f); | |||
| vec3 m_menu_cam_pos = vec3(20.f, 45.f, 45.f); | |||
| int m_menu_mesh_idx = 0; | |||
| array<char const *> m_menu_mesh_names_char; | |||
| array<std::string> m_menu_mesh_names_str; | |||
| //Scene setup data | |||
| SceneSetupLuaLoader m_ssetup_loader; | |||
| FileUpdateStatus *m_ssetup_file_status = nullptr; | |||
| std::string m_ssetup_file_name; | |||
| std::string m_ssetup_name; | |||
| std::map<std::string, SceneSetup*> m_ssetups; | |||
| //File data | |||
| std::string m_file_name; | |||
| FileUpdateStatus* m_file_status; | |||
| //Object data | |||
| array<ViewerObject*> m_objs; | |||
| //Entities listing | |||
| array<Entity*> m_entities; | |||
| //Input | |||
| Controller* m_controller = nullptr; | |||
| //Thread stuff | |||
| FileUpdateTester* m_file_check = nullptr; | |||
| DefaultThreadManager* m_file_loader = nullptr; | |||
| //OLD --------------------------------------------------------------------- | |||
| SceneSetup *m_ssetup = nullptr; | |||
| array<LightData> m_light_datas; | |||
| short m_input_usage; | |||
| mat4 m_mat; | |||
| mat4 m_mat_prev; | |||
| //Camera Setup | |||
| float m_reset_timer; | |||
| float m_fov; | |||
| float m_fov_mesh; | |||
| float m_fov_speed; | |||
| float m_zoom; | |||
| float m_zoom_mesh; | |||
| float m_zoom_speed; | |||
| vec2 m_rot; | |||
| vec2 m_rot_mesh; | |||
| vec2 m_rot_speed; | |||
| vec2 m_pos; | |||
| vec2 m_pos_mesh; | |||
| vec2 m_pos_speed; | |||
| vec2 m_hist_scale; | |||
| vec2 m_hist_scale_mesh; | |||
| vec2 m_hist_scale_speed; | |||
| vec2 m_screen_offset; | |||
| //Mesh update timer | |||
| float m_build_timer; | |||
| float m_build_time; | |||
| //Mesh infos | |||
| vec2 m_render_max; | |||
| int m_mesh_render; | |||
| int m_mesh_id; | |||
| float m_mesh_id1; | |||
| array<EasyMesh*, EasyMesh*> m_meshes; | |||
| array<EasyMesh*> m_gizmos; | |||
| //File data | |||
| array<std::string> m_cmdlist; | |||
| float m_stream_update_time; | |||
| float m_stream_update_timer; | |||
| //misc datas | |||
| Shader * m_texture_shader; | |||
| TileSet * m_default_texture; | |||
| Texture * m_texture; | |||
| ShaderUniform m_texture_uni; | |||
| }; | |||
| } /* namespace lol */ | |||
| @@ -1,88 +0,0 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <PropertyGroup Label="LolMacros"> | |||
| <LolDir Condition="Exists('$(SolutionDir)\lol')">$(SolutionDir)\lol</LolDir> | |||
| <LolDir Condition="!Exists('$(SolutionDir)\lol')">$(SolutionDir)</LolDir> | |||
| </PropertyGroup> | |||
| <ItemGroup Label="ProjectConfigurations"> | |||
| <ProjectConfiguration Include="Debug|ORBIS"> | |||
| <Configuration>Debug</Configuration> | |||
| <Platform>ORBIS</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Debug|Win32"> | |||
| <Configuration>Debug</Configuration> | |||
| <Platform>Win32</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Debug|x64"> | |||
| <Configuration>Debug</Configuration> | |||
| <Platform>x64</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Release|ORBIS"> | |||
| <Configuration>Release</Configuration> | |||
| <Platform>ORBIS</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Release|Win32"> | |||
| <Configuration>Release</Configuration> | |||
| <Platform>Win32</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Release|x64"> | |||
| <Configuration>Release</Configuration> | |||
| <Platform>x64</Platform> | |||
| </ProjectConfiguration> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ClCompile Include="meshviewer.cpp" /> | |||
| <ClCompile Include="scenesetup.cpp" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ProjectReference Include="$(LolDir)\src\lol-core.vcxproj"> | |||
| <Project>{9e62f2fe-3408-4eae-8238-fd84238ceeda}</Project> | |||
| </ProjectReference> | |||
| <ProjectReference Condition="'$(enable_bullet)'!='no'" Include="$(LolDir)\src\3rdparty\lol-bullet.vcxproj"> | |||
| <Project>{83d3b207-c601-4025-8f41-01dedc354661}</Project> | |||
| </ProjectReference> | |||
| <ProjectReference Include="$(LolDir)\src\3rdparty\lol-lua.vcxproj"> | |||
| <Project>{d84021ca-b233-4e0f-8a52-071b83bbccc4}</Project> | |||
| </ProjectReference> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <None Include="../data/mesh-buffer.txt"> | |||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | |||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |||
| </None> | |||
| <None Include="..\data\meshviewer.easymesh.lua"> | |||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |||
| </None> | |||
| <None Include="..\data\meshviewer.init.lua"> | |||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | |||
| </None> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <LolFxCompile Include="shinyfur.lolfx" /> | |||
| <LolFxCompile Include="shinymvtexture.lolfx" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ClInclude Include="meshviewer.h" /> | |||
| <ClInclude Include="scenesetup.h" /> | |||
| </ItemGroup> | |||
| <PropertyGroup Label="Globals"> | |||
| <ProjectGuid>{7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}</ProjectGuid> | |||
| <ConfigurationType>Application</ConfigurationType> | |||
| <Keyword>Win32Proj</Keyword> | |||
| </PropertyGroup> | |||
| <Import Project="$(LolDir)\build\msbuild\lol.config.props" /> | |||
| <ImportGroup Label="ExtensionSettings"> | |||
| <Import Project="$(LolDir)\build\msbuild\lolfx.props" /> | |||
| </ImportGroup> | |||
| <ImportGroup Label="PropertySheets"> | |||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||
| <Import Project="$(LolDir)\build\msbuild\lol.vars.props" /> | |||
| </ImportGroup> | |||
| <PropertyGroup Label="UserMacros" /> | |||
| <Import Project="$(LolDir)\build\msbuild\lol.rules.props" /> | |||
| <ItemDefinitionGroup /> | |||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||
| <ImportGroup Label="ExtensionTargets"> | |||
| <Import Project="$(LolDir)\build\msbuild\lolfx.targets" /> | |||
| </ImportGroup> | |||
| </Project> | |||
| @@ -1,313 +0,0 @@ | |||
| // | |||
| // Lol Engine — Mesh viewer | |||
| // | |||
| // Copyright © 2003—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
| // © 2013—2018 Sam Hocevar <sam@hocevar.net> | |||
| // | |||
| // Lol Engine is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #if HAVE_CONFIG_H | |||
| # include "config.h" | |||
| #endif | |||
| #include <lol/engine.h> | |||
| #include <lol/lua.h> | |||
| #include <string> | |||
| #include <map> | |||
| #include "scenesetup.h" | |||
| namespace lol | |||
| { | |||
| //----------------------------------------------------------------------------- | |||
| //CTor/DTor | |||
| SceneSetup::SceneSetup(std::string const& name) | |||
| { | |||
| m_name = name; | |||
| m_clear_color = vec4(vec3::zero, 1.f); | |||
| m_show_gizmo = true; | |||
| m_show_lights = true; | |||
| } | |||
| //---- | |||
| SceneSetup::~SceneSetup() | |||
| { | |||
| Shutdown(true); | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| bool SceneSetup::Startup() | |||
| { | |||
| for (int i = 0; i < m_lights.count(); i++) | |||
| Ticker::Ref(m_lights[i]); | |||
| return true; | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| bool SceneSetup::Shutdown(bool destroy) | |||
| { | |||
| for (int i = 0; i < m_lights.count(); i++) | |||
| if (m_lights[i]->IsTicked()) | |||
| Ticker::Unref(m_lights[i]); | |||
| if (destroy) | |||
| m_lights.clear(); | |||
| return true; | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetup::AddLight(LightType type) | |||
| { | |||
| m_last_cmd = SceneSetup::Command::AddLight; | |||
| m_lights << new Light(); | |||
| m_lights.last()->SetType(type); | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetup::SetupScene() | |||
| { | |||
| m_last_cmd = SceneSetup::Command::SetupScene; | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetup::SetPosition(vec3 const& v) | |||
| { | |||
| switch (m_last_cmd.ToScalar()) | |||
| { | |||
| case SceneSetup::Command::AddLight: | |||
| m_lights.last()->SetPosition(v); | |||
| break; | |||
| } | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetup::SetLookAt(vec3 const& v) | |||
| { | |||
| switch (m_last_cmd.ToScalar()) | |||
| { | |||
| case SceneSetup::Command::AddLight: | |||
| //TODO: Do better | |||
| m_lights.last()->SetPosition(v - m_lights.last()->GetPosition()); | |||
| break; | |||
| } | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetup::SetColor(vec4 const& c) | |||
| { | |||
| switch (m_last_cmd.ToScalar()) | |||
| { | |||
| case SceneSetup::Command::AddLight: | |||
| m_lights.last()->SetColor(c); | |||
| break; | |||
| case SceneSetup::Command::SetupScene: | |||
| m_clear_color = c; | |||
| break; | |||
| } | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetup::Show(SceneSetup::Display const& d) | |||
| { | |||
| Set(d, DisplayFlag::On); | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetup::Hide(SceneSetup::Display const& d) | |||
| { | |||
| Set(d, DisplayFlag::Off); | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetup::Toggle(SceneSetup::Display const& d) | |||
| { | |||
| Set(d, DisplayFlag::Toggle); | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetup::Set(SceneSetup::Display const& d, DisplayFlag const& f) | |||
| { | |||
| bool value = f == DisplayFlag::On ? true : false; | |||
| switch (m_last_cmd.ToScalar()) | |||
| { | |||
| case SceneSetup::Command::SetupScene: | |||
| switch (d.ToScalar()) | |||
| { | |||
| case SceneSetup::Display::Gizmo: | |||
| m_show_gizmo = f == DisplayFlag::Toggle ? !m_show_gizmo : value; | |||
| break; | |||
| case SceneSetup::Display::Light: | |||
| m_show_lights = f == DisplayFlag::Toggle ? !m_show_lights : value; | |||
| break; | |||
| } | |||
| break; | |||
| } | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| SceneSetupLuaObject::SceneSetupLuaObject(std::string const& name) : LuaObject() | |||
| { | |||
| m_setup = new SceneSetup(name); | |||
| SceneSetupLuaLoader::RegisterSetup(m_setup); | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| SceneSetupLuaObject::~SceneSetupLuaObject() | |||
| { | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| SceneSetupLuaObject* SceneSetupLuaObject::New(lua_State* l, int arg_nb) | |||
| { | |||
| UNUSED(arg_nb); | |||
| auto s = LuaStack::Begin(l); | |||
| auto n = s.Get<std::string>(); | |||
| return new SceneSetupLuaObject(n); | |||
| } | |||
| //-- Setup command ------------------------------------------------------------ | |||
| int SceneSetupLuaObject::AddLight(lua_State* l) | |||
| { | |||
| auto s = LuaStack::Begin(l); | |||
| auto o = s.GetPtr<SceneSetupLuaObject>(); | |||
| auto t = s.Get<std::string>(); | |||
| o->m_setup->AddLight(FindValue<LightType>(t)); | |||
| return s.End(); | |||
| } | |||
| int SceneSetupLuaObject::SetupScene(lua_State* l) | |||
| { | |||
| auto s = LuaStack::Begin(l); | |||
| auto o = s.GetPtr<SceneSetupLuaObject>(); | |||
| o->m_setup->SetupScene(); | |||
| return s.End(); | |||
| } | |||
| //-- main funcs --------------------------------------------------------------- | |||
| int SceneSetupLuaObject::SetPosition(lua_State* l) | |||
| { | |||
| auto s = LuaStack::Begin(l); | |||
| auto o = s.GetPtr<SceneSetupLuaObject>(); | |||
| auto c = s.Get<vec3>(); | |||
| o->m_setup->SetPosition(c); | |||
| return s.End(); | |||
| } | |||
| int SceneSetupLuaObject::SetLookAt(lua_State* l) | |||
| { | |||
| auto s = LuaStack::Begin(l); | |||
| auto o = s.GetPtr<SceneSetupLuaObject>(); | |||
| auto c = s.Get<vec3>(); | |||
| o->m_setup->SetLookAt(c); | |||
| return s.End(); | |||
| } | |||
| int SceneSetupLuaObject::SetColor(lua_State* l) | |||
| { | |||
| auto s = LuaStack::Begin(l); | |||
| auto o = s.GetPtr<SceneSetupLuaObject>(); | |||
| auto c = s.Get<vec4>(); | |||
| o->m_setup->SetColor(c); | |||
| return s.End(); | |||
| } | |||
| int SceneSetupLuaObject::Show(lua_State* l) | |||
| { | |||
| auto s = LuaStack::Begin(l); | |||
| auto o = s.GetPtr<SceneSetupLuaObject>(); | |||
| auto e = s.GetEnum<SceneSetup::DisplayBase>(); | |||
| o->m_setup->Show(e); | |||
| return s.End(); | |||
| } | |||
| int SceneSetupLuaObject::Hide(lua_State* l) | |||
| { | |||
| auto s = LuaStack::Begin(l); | |||
| auto o = s.GetPtr<SceneSetupLuaObject>(); | |||
| auto e = s.GetEnum<SceneSetup::DisplayBase>(); | |||
| o->m_setup->Hide(e); | |||
| return s.End(); | |||
| } | |||
| int SceneSetupLuaObject::Toggle(lua_State* l) | |||
| { | |||
| auto s = LuaStack::Begin(l); | |||
| auto o = s.GetPtr<SceneSetupLuaObject>(); | |||
| auto e = s.GetEnum<SceneSetup::DisplayBase>(); | |||
| o->m_setup->Toggle(e); | |||
| return s.End(); | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| const LuaObjectLibrary* SceneSetupLuaObject::GetLib() | |||
| { | |||
| typedef SceneSetupLuaObject SSLO; | |||
| static const LuaObjectLibrary lib = LuaObjectLibrary( | |||
| "SceneSetup", | |||
| //Statics | |||
| { { nullptr, nullptr } }, | |||
| //Methods | |||
| { | |||
| //----------------------------------------------------------------- | |||
| { "AddLight", AddLight }, | |||
| { "Setup", SetupScene }, | |||
| //-- main funcs | |||
| { "Position", SetPosition }, | |||
| { "LookAt", SetLookAt }, | |||
| { "Color", SetColor }, | |||
| { "Show", Show }, | |||
| { "Hide", Hide }, | |||
| { "Toggle", Toggle }, | |||
| }, | |||
| //Variables | |||
| { { nullptr, nullptr, nullptr } }); | |||
| return &lib; | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| std::map<std::string, SceneSetup*> SceneSetupLuaLoader::m_setups; | |||
| SceneSetupLuaLoader::SceneSetupLuaLoader() : LuaLoader() | |||
| { | |||
| lua_State* l = GetLuaState(); | |||
| LuaObjectHelper::Register<SceneSetupLuaObject>(l); | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| SceneSetupLuaLoader::~SceneSetupLuaLoader() { } | |||
| //----------------------------------------------------------------------------- | |||
| static array<SceneSetupLuaObject*> g_instances; | |||
| void SceneSetupLuaLoader::Store(LuaObject* obj) | |||
| { | |||
| SceneSetupLuaObject* ezm = static_cast<SceneSetupLuaObject*>(obj); | |||
| g_instances << ezm; | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| array<SceneSetupLuaObject*>& SceneSetupLuaLoader::GetInstances() | |||
| { | |||
| return g_instances; | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| void SceneSetupLuaLoader::RegisterSetup(SceneSetup* setup) | |||
| { | |||
| m_setups[setup->m_name] = setup; | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| bool SceneSetupLuaLoader::GetRegisteredSetups(std::map<std::string, SceneSetup*>& setups) | |||
| { | |||
| setups = m_setups; | |||
| return m_setups.size() > 0; | |||
| } | |||
| //----------------------------------------------------------------------------- | |||
| bool SceneSetupLuaLoader::GetLoadedSetups(std::map<std::string, SceneSetup*>& setups) | |||
| { | |||
| return GetRegisteredSetups(setups); | |||
| } | |||
| } /* namespace lol */ | |||
| @@ -1,227 +0,0 @@ | |||
| // | |||
| // Lol Engine — Mesh viewer | |||
| // | |||
| // Copyright © 2003—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
| // © 2013—2018 Sam Hocevar <sam@hocevar.net> | |||
| // | |||
| // Lol Engine is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #pragma once | |||
| // | |||
| // The Scene setup class | |||
| // ---------------- | |||
| // | |||
| #include <string> | |||
| #include <map> | |||
| namespace lol | |||
| { | |||
| //----------------------------------------------------------------------------- | |||
| class SceneSetup | |||
| { | |||
| friend class SceneSetupLuaLoader; | |||
| friend class SceneSetupLuaObject; | |||
| public: | |||
| //CTor/DTor | |||
| SceneSetup() : SceneSetup("default") { } | |||
| SceneSetup(std::string const& name); | |||
| ~SceneSetup(); | |||
| static std::string GetName() { return "<scenesetup>"; } | |||
| //-- | |||
| bool Startup(); | |||
| bool Shutdown(bool destroy=false); | |||
| //-- Setup command | |||
| void AddLight(LightType type); | |||
| void SetupScene(); | |||
| //-- main funcs | |||
| void SetPosition(vec3 const& v); | |||
| void SetLookAt(vec3 const& v); | |||
| void SetColor(vec4 const& c); | |||
| //------------------------------------------------------------------------- | |||
| struct DisplayBase : public StructSafeEnum | |||
| { | |||
| enum Type | |||
| { | |||
| Gizmo, | |||
| Light, | |||
| Max | |||
| }; | |||
| protected: | |||
| virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
| { | |||
| enum_map[Gizmo] = "Gizmo"; | |||
| enum_map[Light] = "Light"; | |||
| return true; | |||
| } | |||
| }; | |||
| typedef SafeEnum<DisplayBase> Display; | |||
| void Show(Display const& d); | |||
| void Hide(Display const& d); | |||
| void Toggle(Display const& d); | |||
| protected: | |||
| void Set(Display const& d, DisplayFlag const& f); | |||
| protected: | |||
| //------------------------------------------------------------------------- | |||
| struct CommandBase : public StructSafeEnum | |||
| { | |||
| enum Type | |||
| { | |||
| AddLight, | |||
| SetupScene, | |||
| Max | |||
| }; | |||
| protected: | |||
| virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
| { | |||
| enum_map[AddLight] = "AddLight"; | |||
| enum_map[SetupScene] = "SetupScene"; | |||
| return true; | |||
| } | |||
| }; | |||
| typedef SafeEnum<CommandBase> Command; | |||
| public: | |||
| //-- | |||
| std::string m_name; | |||
| Command m_last_cmd; | |||
| vec4 m_clear_color; | |||
| array<Light *> m_lights; | |||
| array<std::string, std::string> m_custom_cmd; | |||
| bool m_show_gizmo; | |||
| bool m_show_lights; | |||
| }; | |||
| //----------------------------------------------------------------------------- | |||
| class SceneSetupLuaObject : public LuaObject | |||
| { | |||
| public: | |||
| //------------------------------------------------------------------------- | |||
| SceneSetupLuaObject(std::string const& name); | |||
| virtual ~SceneSetupLuaObject(); | |||
| //------------------------------------------------------------------------- | |||
| static SceneSetupLuaObject* New(lua_State* l, int arg_nb); | |||
| static const LuaObjectLibrary* GetLib(); | |||
| //------------------------------------------------------------------------- | |||
| public: | |||
| //-- Setup command | |||
| static int AddLight(lua_State* l); | |||
| static int SetupScene(lua_State* l); | |||
| //-- main funcs | |||
| static int SetPosition(lua_State* l); | |||
| static int SetLookAt(lua_State* l); | |||
| static int SetColor(lua_State* l); | |||
| static int Show(lua_State* l); | |||
| static int Hide(lua_State* l); | |||
| static int Toggle(lua_State* l); | |||
| //-- Setup command | |||
| void AddLight(LightType type); | |||
| void SetupScene(); | |||
| //-- main funcs | |||
| void SetPosition(vec3& v); | |||
| void SetLookAt(vec3& v); | |||
| void SetColor(vec4& c); | |||
| void Show(SceneSetup::Display const& d); | |||
| void Hide(SceneSetup::Display const& d); | |||
| void Toggle(SceneSetup::Display const& d); | |||
| private: | |||
| SceneSetup* m_setup = nullptr; | |||
| }; | |||
| //----------------------------------------------------------------------------- | |||
| class SceneSetupLuaLoader : public LuaLoader | |||
| { | |||
| friend class SceneSetupLuaObject; | |||
| public: | |||
| SceneSetupLuaLoader(); | |||
| virtual ~SceneSetupLuaLoader(); | |||
| //Virtual Store lua object ------------------------------------------------ | |||
| virtual void Store(LuaObject* obj); | |||
| array<SceneSetupLuaObject*>& GetInstances(); | |||
| //------------------------------------------------------------------------- | |||
| protected: | |||
| static void RegisterSetup(SceneSetup* setup); | |||
| static bool GetRegisteredSetups(std::map<std::string, SceneSetup*>& setups); | |||
| public: | |||
| bool GetLoadedSetups(std::map<std::string, SceneSetup*>& setups); | |||
| private: | |||
| static std::map<std::string, SceneSetup*> m_setups; | |||
| }; | |||
| /* | |||
| addlight { return token::T_ADDLIGHT; } | |||
| position { return token::T_OBJPOSITION; } | |||
| lookat { return token::T_OBJLOOKAT; } | |||
| color { return token::T_OBJCOLOR; } | |||
| clearcolor { return token::T_CLEARCOLOR; } | |||
| showgizmo { return token::T_SHOWGIZMO; } | |||
| showlight { return token::T_SHOWLIGHT; } | |||
| custom { return token::T_CUSTOMCMD; } | |||
| custom { return token::T_CUSTOMCMD; } | |||
| light_command: | |||
| T_ADDLIGHT { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; } | |||
| | T_ADDLIGHT fv { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; | |||
| uc.m_sstp.m_lights.last()->SetType(LightType($2)); } | |||
| | T_ADDLIGHT svv { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; | |||
| uc.m_sstp.m_lights.last()->SetType(FindValue<LightType>($2)); } | |||
| ; | |||
| setup_command: | |||
| T_OBJPOSITION v3 { if (uc.m_last_cmd == "ADDLIGHT") | |||
| uc.m_sstp.m_lights.last()->SetPosition(vec3($2[0], $2[1], $2[2])); } | |||
| | T_OBJLOOKAT v3 { if (uc.m_last_cmd == "ADDLIGHT") | |||
| { | |||
| } } | |||
| | T_OBJCOLOR v4{ if (uc.m_last_cmd == "ADDLIGHT") | |||
| uc.m_sstp.m_lights.last()->SetColor(vec4($2[0], $2[1], $2[2], $2[3])); } | |||
| | T_OBJCOLOR COLOR{ uint32_t x = $2; | |||
| ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); | |||
| vec4 vv = vec4(v) * (1.f / 255.f); | |||
| if (uc.m_last_cmd == "ADDLIGHT") | |||
| uc.m_sstp.m_lights.last()->SetColor(vv); } | |||
| ; | |||
| scene_command: | |||
| T_CLEARCOLOR v4{ uc.m_sstp.m_clear_color = vec4($2[0], $2[1], $2[2], $2[3]); } | |||
| T_CLEARCOLOR v3{ uc.m_sstp.m_clear_color = vec4($2[0], $2[1], $2[2], 1.f); } | |||
| | T_CLEARCOLOR COLOR{ uint32_t x = $2; ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); | |||
| uc.m_sstp.m_clear_color = vec4(v) * (1.f / 255.f); } | |||
| | T_SHOWGIZMO bv{ uc.m_sstp.m_show_gizmo = $2; } | |||
| | T_SHOWLIGHT bv{ uc.m_sstp.m_show_lights = $2; } | |||
| ; | |||
| custom_command: | |||
| T_CUSTOMCMD svv sv{ uc.m_sstp.m_custom_cmd.push($2, $3); } | |||
| ; | |||
| */ | |||
| } /* namespace lol */ | |||
| @@ -1,21 +0,0 @@ | |||
| //------------------------------------------------------------------------- | |||
| //Command vars operations | |||
| //------------------------------------------------------------------------- | |||
| CmdVar("float", ["Fraction value", "0.0"]); | |||
| CmdVar("int", ["No decimal value", "0"]); | |||
| CmdVar("bool", ["Boolean value", "true/false", "1/0"]); | |||
| CmdVar("color", ["Red/Green/Blue/{Alpha}", | |||
| "HEXA: #ABC{D}", " #AABBCC{DD}", | |||
| "FLOAT: f f f f", " (f f f f)", " (f)"]); | |||
| CmdVar("vec3", ["X/Y/Z as float", " f f f", "(f f f)", "(f)"]); | |||
| //------------------------------------------------------------------------- | |||
| //scene operations | |||
| //------------------------------------------------------------------------- | |||
| CmdType(["addlight"], "Add a light to the scene.\nUse other commands after this one to fully setup.", [CmdArg("float", "type")]); | |||
| CmdType(["position"], "Set a position.\nWhen put after a light, sets its position.", [CmdArg("vec3", "pos")]); | |||
| CmdType(["color"], "Set a color.", [CmdArg("color", "color")]); | |||
| CmdType(["clearcolor"], "Sets the color used for screen clearing.", [CmdArg("color", "color")]); | |||
| CmdType(["showgizmo"], "If true, show the axis gizmo.", [CmdArg("bool", "show")]); | |||
| CmdType(["showlight"], "If true, show the light locations.", [CmdArg("bool", "show")]); | |||
| @@ -1,117 +0,0 @@ | |||
| [vert.glsl] | |||
| #version 130 | |||
| in vec3 in_position; | |||
| in vec3 in_Normal; | |||
| in vec4 in_color; | |||
| uniform mat4 u_modelview; | |||
| uniform mat4 u_view; | |||
| uniform mat4 u_projection; | |||
| uniform mat3 u_normalmat; | |||
| uniform float u_damage; | |||
| out vec4 pass_vertex; /* View space */ | |||
| out vec3 pass_tnormal; | |||
| out vec4 pass_color; | |||
| void main(void) | |||
| { | |||
| vec4 vertex = vec4(in_position + (in_Normal * u_damage), 1.0); | |||
| float dam_perc = u_damage / (0.1 * 40); | |||
| vec3 vGravity = vec3(0.0, -0.981, 0.0) * 2.0; | |||
| float k = pow(dam_perc, 3); | |||
| vertex = u_modelview * vertex + u_view * vec4(vGravity * k, 1.0); | |||
| vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
| pass_vertex = vertex; | |||
| pass_tnormal = tnorm; | |||
| pass_color = in_color; | |||
| gl_Position = u_projection * vertex; | |||
| } | |||
| [frag.glsl] | |||
| #version 130 | |||
| #if defined GL_ES | |||
| precision highp float; | |||
| #endif | |||
| in vec4 pass_vertex; /* View space */ | |||
| in vec3 pass_tnormal; | |||
| in vec4 pass_color; | |||
| uniform mat4 u_view; | |||
| uniform mat4 u_inv_view; | |||
| uniform mat4 u_inv_modelview; | |||
| uniform float u_damage; | |||
| //Light list | |||
| uniform vec4 u_lights[8 * 2]; | |||
| void main(void) | |||
| { | |||
| /* Material properties */ | |||
| vec3 specular_reflect = vec3(0.8, 0.75, 0.4); | |||
| float specular_power = 60.0; | |||
| /* World properties */ | |||
| vec3 ambient = vec3(0.7, 0.7, 0.7); | |||
| vec3 specular = vec3(0.0, 0.0, 0.0); | |||
| vec3 diffuse = vec3(0.0, 0.0, 0.0); | |||
| /* Light precalculations */ | |||
| vec3 v = normalize(-pass_vertex.xyz); | |||
| /* Apply lighting */ | |||
| for (int i = 0; i < 8; i++) | |||
| { | |||
| vec4 pos = u_lights[i * 2]; | |||
| vec4 color = u_lights[i * 2 + 1]; | |||
| vec3 s, r; | |||
| if (pos.w > 0.0) | |||
| { | |||
| /* Point light -- no attenuation yet */ | |||
| s = normalize((u_view * pos).xyz - pass_vertex.xyz); | |||
| r = reflect(-s, pass_tnormal); | |||
| } | |||
| else | |||
| { | |||
| /* Directional light */ | |||
| s = normalize(-pos.xyz); | |||
| r = reflect(s, pass_tnormal); | |||
| } | |||
| float sdotn = max(dot(s, pass_tnormal), 0.0); | |||
| diffuse += color.xyz * sdotn; | |||
| if (sdotn > 0.0) | |||
| specular += color.xyz * specular_reflect | |||
| * pow(max(dot(r, v), 0.0), specular_power); | |||
| } | |||
| vec3 light = ambient + diffuse + specular; | |||
| vec4 world_vertex = u_inv_modelview * pass_vertex; | |||
| vec4 world_normal = u_inv_modelview * vec4(pass_tnormal, 1.0); | |||
| float dam_perc = u_damage / (0.1 * 40); | |||
| float PI = 3.14159265358979323846264; | |||
| dam_perc = (sin(PI * (dam_perc - 0.5)) * 0.5 + 0.5); | |||
| dam_perc *= dam_perc; | |||
| dam_perc = 1.0 - dam_perc; | |||
| float mod = 2.0; | |||
| float transp = dam_perc; | |||
| /* | |||
| abs(sin(world_vertex.x * mod) * dam_perc * 0.5 + 0.5) * | |||
| abs(sin(world_vertex.y * mod) * dam_perc * 0.5 + 0.5) * | |||
| abs(sin(world_vertex.z * mod) * dam_perc * 0.5 + 0.5) | |||
| */ | |||
| //vec4 real_color = mix(pass_color, vec4(1.2, 1.2, 1.2, 1.0), u_damage); | |||
| // - u_damage | |||
| gl_FragColor = pass_color * vec4(light, (u_damage == 0)?(1.0):(transp)); | |||
| } | |||
| @@ -1,98 +0,0 @@ | |||
| [vert.glsl] | |||
| #version 130 | |||
| in vec3 in_position; | |||
| in vec3 in_Normal; | |||
| in vec4 in_color; | |||
| in vec2 in_texcoord; | |||
| uniform mat4 u_modelview; | |||
| uniform mat4 u_view; | |||
| uniform mat4 u_projection; | |||
| uniform mat3 u_normalmat; | |||
| out vec4 pass_vertex; /* View space */ | |||
| out vec3 pass_tnormal; | |||
| out vec4 pass_color; | |||
| out vec2 pass_texcoord; | |||
| void main(void) | |||
| { | |||
| vec4 vertex = u_modelview * vec4(in_position, 1.0); | |||
| vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
| pass_vertex = vertex; | |||
| pass_tnormal = tnorm; | |||
| pass_color = in_color; | |||
| pass_texcoord = in_texcoord; | |||
| gl_Position = u_projection * vertex; | |||
| } | |||
| [frag.glsl] | |||
| #version 130 | |||
| #if defined GL_ES | |||
| precision highp float; | |||
| #endif | |||
| in vec4 pass_vertex; /* View space */ | |||
| in vec3 pass_tnormal; | |||
| in vec4 pass_color; | |||
| in vec2 pass_texcoord; | |||
| uniform mat4 u_view; | |||
| uniform mat4 u_inv_view; | |||
| uniform mat4 u_inv_modelview; | |||
| uniform sampler2D u_Texture; | |||
| //Light list | |||
| uniform vec4 u_lights[8 * 2]; | |||
| void main(void) | |||
| { | |||
| /* Material properties */ | |||
| vec3 specular_reflect = vec3(0.8, 0.75, 0.4); | |||
| float specular_power = 60.0; | |||
| /* World properties */ | |||
| vec3 ambient = vec3(0.7, 0.7, 0.7); | |||
| vec3 specular = vec3(0.0, 0.0, 0.0); | |||
| vec3 diffuse = vec3(0.0, 0.0, 0.0); | |||
| /* Light precalculations */ | |||
| vec3 v = normalize(-pass_vertex.xyz); | |||
| /* Apply lighting */ | |||
| for (int i = 0; i < 8; i++) | |||
| { | |||
| vec4 pos = u_lights[i * 2]; | |||
| vec4 color = u_lights[i * 2 + 1]; | |||
| vec3 s, r; | |||
| if (pos.w > 0.0) | |||
| { | |||
| /* Point light -- no attenuation yet */ | |||
| s = normalize((u_view * pos).xyz - pass_vertex.xyz); | |||
| r = reflect(-s, pass_tnormal); | |||
| } | |||
| else | |||
| { | |||
| /* Directional light */ | |||
| s = normalize(-pos.xyz); | |||
| r = reflect(s, pass_tnormal); | |||
| } | |||
| float sdotn = max(dot(s, pass_tnormal), 0.0); | |||
| diffuse += color.xyz * sdotn; | |||
| if (sdotn > 0.0) | |||
| specular += color.xyz * specular_reflect | |||
| * pow(max(dot(r, v), 0.0), specular_power); | |||
| } | |||
| vec3 light = ambient + diffuse + specular; | |||
| gl_FragColor = texture2D(u_Texture, pass_texcoord.xy) * pass_color * vec4(light, 1.0f); | |||
| } | |||
| @@ -44,8 +44,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "03_noise", "doc\tutorial\03 | |||
| EndProject | |||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "04_texture", "doc\tutorial\04_texture.vcxproj", "{834852DB-EDB6-4FD0-BCF9-45CD01126962}" | |||
| EndProject | |||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "meshviewer", "doc\samples\meshviewer\meshviewer.vcxproj", "{7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}" | |||
| EndProject | |||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "12_Voronoi", "doc\tutorial\12_Voronoi.vcxproj", "{6BF81B39-EDC2-4227-9982-C2D8ABEA95AF}" | |||
| EndProject | |||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "07_input", "doc\tutorial\07_input.vcxproj", "{572E5B9C-7E19-489C-BD8A-E8401CFBBC47}" | |||
| @@ -233,16 +231,6 @@ Global | |||
| {834852DB-EDB6-4FD0-BCF9-45CD01126962}.Release|Win32.Build.0 = Release|Win32 | |||
| {834852DB-EDB6-4FD0-BCF9-45CD01126962}.Release|x64.ActiveCfg = Release|x64 | |||
| {834852DB-EDB6-4FD0-BCF9-45CD01126962}.Release|x64.Build.0 = Release|x64 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Debug|ORBIS.ActiveCfg = Debug|Win32 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Debug|Win32.ActiveCfg = Debug|Win32 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Debug|Win32.Build.0 = Debug|Win32 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Debug|x64.ActiveCfg = Debug|x64 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Debug|x64.Build.0 = Debug|x64 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Release|ORBIS.ActiveCfg = Release|Win32 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Release|Win32.ActiveCfg = Release|Win32 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Release|Win32.Build.0 = Release|Win32 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Release|x64.ActiveCfg = Release|x64 | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E}.Release|x64.Build.0 = Release|x64 | |||
| {6BF81B39-EDC2-4227-9982-C2D8ABEA95AF}.Debug|ORBIS.ActiveCfg = Debug|Win32 | |||
| {6BF81B39-EDC2-4227-9982-C2D8ABEA95AF}.Debug|Win32.ActiveCfg = Debug|Win32 | |||
| {6BF81B39-EDC2-4227-9982-C2D8ABEA95AF}.Debug|x64.ActiveCfg = Debug|x64 | |||
| @@ -326,7 +314,6 @@ Global | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| {B0A53D75-CBB4-4FDF-93AC-2D12A79ADA0E} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| {834852DB-EDB6-4FD0-BCF9-45CD01126962} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| {7CE9FE12-E4AB-4A22-90D4-2C15F0C30D4E} = {B6297FF2-63D0-41EE-BE13-EFF720C9B0FA} | |||
| {6BF81B39-EDC2-4227-9982-C2D8ABEA95AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| {572E5B9C-7E19-489C-BD8A-E8401CFBBC47} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| {E05E23A5-67DE-42B5-98A3-E63CCE0CC0AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| @@ -31,50 +31,6 @@ lolunit_declare_fixture(thread_test) | |||
| { | |||
| } | |||
| lolunit_declare_test(threads) | |||
| { | |||
| msg::info("%s START\n", m_manager.GetName().c_str()); | |||
| //Start threads manager | |||
| m_manager.Start(); | |||
| msg::info("%s STARTED\n", m_manager.GetName().c_str()); | |||
| UnitTestJob job[4]; | |||
| lolunit_assert_equal(0, m_manager.Test_GetDispatchCount()); | |||
| m_manager.AddJob(&job[0]); | |||
| lolunit_assert_equal(1, m_manager.Test_GetDispatchCount()); | |||
| lolunit_assert_equal(false, job[0].IsDone()); | |||
| bool dispatch_check = true; | |||
| while (!m_manager.IsDone()) | |||
| { | |||
| m_manager.tick_game(1.f / 60.f); | |||
| if (dispatch_check) | |||
| { | |||
| lolunit_assert_equal(0, m_manager.Test_GetDispatchCount()); | |||
| #if !defined(LOL_FEATURE_THREADS) || !LOL_FEATURE_THREADS | |||
| lolunit_assert_equal(0, m_manager.Test_GetDispatchedCount()); | |||
| #else //LOL_FEATURE_THREADS | |||
| lolunit_assert_equal(1, m_manager.Test_GetDispatchedCount()); | |||
| #endif | |||
| m_manager.AddJob(&job[1]); | |||
| m_manager.AddJob(&job[2]); | |||
| m_manager.AddJob(&job[3]); | |||
| dispatch_check = false; | |||
| } | |||
| } | |||
| lolunit_assert_equal(true, job[0].IsDone()); | |||
| lolunit_assert_equal(true, job[1].IsDone()); | |||
| lolunit_assert_equal(true, job[2].IsDone()); | |||
| lolunit_assert_equal(true, job[3].IsDone()); | |||
| array<ThreadJob*> results; | |||
| m_manager.GetWorkResult(results); | |||
| lolunit_assert_equal(4, results.count()); | |||
| msg::info("%s STOP\n", m_manager.GetName().c_str()); | |||
| //Stop manager | |||
| m_manager.Stop(); | |||
| msg::info("%s STOPPED\n", m_manager.GetName().c_str()); | |||
| } | |||
| lolunit_declare_test(queue_try_push) | |||
| { | |||
| queue<int, 1> q; | |||