diff --git a/MAKE.bat b/MAKE.bat index 942295a..d6549da 100644 --- a/MAKE.bat +++ b/MAKE.bat @@ -554,6 +554,7 @@ if "%1"=="fwk_mir" ( rem tidy environment if "%1"=="tidy" ( + call demos\html5\make.bat tidy > nul 2> nul move /y ??-*.png demos > nul 2> nul move /y ??-*.c demos > nul 2> nul del bind\v4k.dll > nul 2> nul diff --git a/demos/html5/MAKE.bat b/demos/html5/MAKE.bat index a8d6037..3c86c38 100644 --- a/demos/html5/MAKE.bat +++ b/demos/html5/MAKE.bat @@ -1,23 +1,65 @@ -if "%1"=="" MAKE.bat demo_collide.c +#!/bin/bash 2>nul || goto :windows -del index.html 2>NUL >NUL -del index.worker.js 2>NUL >NUL -del index.data 2>NUL >NUL +if [ "$1" = "" ]; then + sh MAKE.bat demo_collide.c + exit +fi + +## clone emscripten sdk +git clone https://github.com/emscripten-core/emsdk emsdk +pushd emsdk + ./emsdk install 3.1.55 ## latest + ./emsdk activate 3.1.55 ## latest + source ./emsdk_env.sh +popd + +## cook art +if [ "$(uname)" = "Darwin" ]; then + chmod +x ../../tools/cook.osx + ../../tools/cook.osx --cook-jobs=1 --cook-ini=../../tools/cook.ini + cp .art[00].zip index.zip +else + chmod +x ../../tools/cook.linux + ../../tools/cook.linux --cook-jobs=1 --cook-ini=../../tools/cook.ini + cp .art[00].zip index.zip +fi +cp template.js index.coi.js + +## host webserver, compile and launch +## python -m http.server --bind 127.0.0.1 8000 1> /dev/null 2> /dev/null & +emcc $@ -g ../../engine/v4k.c -I../../engine -o index.html -s FULL_ES3 -s USE_PTHREADS -s USE_GLFW=3 -s SINGLE_FILE=1 -s PRECISE_F32=1 -s TOTAL_MEMORY=256mb -s ENVIRONMENT=worker,web --shell-file template.html -Wfatal-errors --preload-file index.zip -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=128kb -lidbfs.js && emrun index.html # xdg-open http://localhost:8000 + +exit + +:windows + +if "%1"=="" MAKE.bat demo_collide.c +if "%1"=="tidy" del index.* & del *.zip & del temp_* & exit /b && rem rd /q /s emsdk rem clone emscripten sdk if not exist "emsdk" ( git clone https://github.com/emscripten-core/emsdk emsdk pushd emsdk - call emsdk install 3.0.0 && rem latest - call emsdk activate 3.0.0 && rem latest + call emsdk install 3.1.55 && rem latest + call emsdk activate 3.1.55 && rem latest popd ) if "%EMSDK%"=="" call emsdk\emsdk_env.bat --system rem cook art ..\..\tools\cook.exe --cook-jobs=1 --cook-ini=..\..\tools\cook_web.ini +copy /y .art[00].zip index.zip +copy /y template.js index.coi.js -rem host webserver, compile and launch -rem start python -m http.server --bind 127.0.0.1 8000 -call emcc %* -g ..\..\engine\v4k.c -I..\..\engine -o index.html -pthread -s FULL_ES3 -s USE_PTHREADS -s USE_GLFW=3 -s SINGLE_FILE=1 -s PRECISE_F32=1 -s TOTAL_MEMORY=256mb -s ALLOW_MEMORY_GROWTH=1 -s ENVIRONMENT=worker,web --shell-file template.html -Wfatal-errors --preload-file .art[00].zip@index.zip -lidbfs.js -rem emrun index.html +goto skip +rem host webserver:8000 if not open +netstat /ano | find /i "listening" | find ":8000" >nul 2>nul && ( + rem start python -m http.server --bind 127.0.0.1 8000 +) || ( + start python -m http.server --bind 127.0.0.1 8000 +) +:skip + +rem compile and launch +set WARNINGS=-Wno-pointer-sign -Wno-deprecated-non-prototype +emcc %* -g ..\..\engine\v4k.c -I..\..\engine -o index.html %WARNINGS% -pthread -s FULL_ES3 -s USE_PTHREADS -s USE_GLFW=3 -s SINGLE_FILE=1 -s PRECISE_F32=1 -s TOTAL_MEMORY=256mb -s ENVIRONMENT=worker,web --shell-file template.html -Wfatal-errors --preload-file index.zip -s ALLOW_MEMORY_GROWTH=1 -lidbfs.js && start emrun index.html && rem start "" http://localhost:8000 \ No newline at end of file diff --git a/demos/html5/art/cubemaps/stardust/license.txt b/demos/html5/art/cubemaps/stardust/license.txt new file mode 100644 index 0000000..1a5b4e6 --- /dev/null +++ b/demos/html5/art/cubemaps/stardust/license.txt @@ -0,0 +1,184 @@ +Assets from https://github.com/GameTechDev/stardust_vulkan/. Project license below: + +--- + +Apache License + Version 2.0, January 2004 + + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this +License, each Contributor hereby grants to You a perpetual, worldwide, +non-exclusive, no-charge, royalty-free, irrevocable copyright license to +reproduce, prepare Derivative Works of, publicly display, publicly perform, +sublicense, and distribute the Work and such Derivative Works in Source or +Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, +each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) patent +license to make, have made, use, offer to sell, sell, import, and otherwise +transfer the Work, where such license applies only to those patent claims +licensable by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) with the Work +to which such Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Work or a Contribution incorporated within the Work +constitutes direct or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate as of the date +such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or +Derivative Works thereof in any medium, with or without modifications, and in +Source or Object form, provided that You meet the following conditions: + You must give any other recipients of the Work or Derivative Works a copy of + this License; and + + + You must cause any modified files to carry prominent notices stating that You + changed the files; and + + + You must retain, in the Source form of any Derivative Works that You + distribute, all copyright, patent, trademark, and attribution notices from the + Source form of the Work, excluding those notices that do not pertain to any + part of the Derivative Works; and + + + If the Work includes a "NOTICE" text file as part of its distribution, then + any Derivative Works that You distribute must include a readable copy of the + attribution notices contained within such NOTICE file, excluding those notices + that do not pertain to any part of the Derivative Works, in at least one of + the following places: within a NOTICE text file distributed as part of the + Derivative Works; within the Source form or documentation, if provided along + with the Derivative Works; or, within a display generated by the Derivative + Works, if and wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and do not modify the + License. You may add Your own attribution notices within Derivative Works that + You distribute, alongside or as an addendum to the NOTICE text from the Work, + provided that such additional attribution notices cannot be construed as + modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any +Contribution intentionally submitted for inclusion in the Work by You to the +Licensor shall be under the terms and conditions of this License, without any +additional terms or conditions. Notwithstanding the above, nothing herein shall +supersede or modify the terms of any separate license agreement you may have +executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, +trademarks, service marks, or product names of the Licensor, except as required +for reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in +writing, Licensor provides the Work (and each Contributor provides its +Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied, including, without limitation, any warranties +or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any risks +associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in +tort (including negligence), contract, or otherwise, unless required by +applicable law (such as deliberate and grossly negligent acts) or agreed to in +writing, shall any Contributor be liable to You for damages, including any +direct, indirect, special, incidental, or consequential damages of any character +arising as a result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, work stoppage, +computer failure or malfunction, or any and all other commercial damages or +losses), even if such Contributor has been advised of the possibility of such +damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or +Derivative Works thereof, You may choose to offer, and charge a fee for, +acceptance of support, warranty, indemnity, or other liability obligations +and/or rights consistent with this License. However, in accepting such +obligations, You may act only on Your own behalf and on Your sole +responsibility, not on behalf of any other Contributor, and only if You agree to +indemnify, defend, and hold each Contributor harmless for any liability incurred +by, or claims asserted against, such Contributor by reason of your accepting any +such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + +Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, +Version 2.0 (the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or +agreed to in writing, software distributed under the License is distributed on +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +or implied. See the License for the specific language governing permissions and +limitations under the License. diff --git a/demos/html5/art/cubemaps/stardust/negx.png b/demos/html5/art/cubemaps/stardust/negx.png new file mode 100644 index 0000000..0ed2004 Binary files /dev/null and b/demos/html5/art/cubemaps/stardust/negx.png differ diff --git a/demos/html5/art/cubemaps/stardust/negy.png b/demos/html5/art/cubemaps/stardust/negy.png new file mode 100644 index 0000000..f1893c3 Binary files /dev/null and b/demos/html5/art/cubemaps/stardust/negy.png differ diff --git a/demos/html5/art/cubemaps/stardust/negz.png b/demos/html5/art/cubemaps/stardust/negz.png new file mode 100644 index 0000000..c3dc110 Binary files /dev/null and b/demos/html5/art/cubemaps/stardust/negz.png differ diff --git a/demos/html5/art/cubemaps/stardust/posx.png b/demos/html5/art/cubemaps/stardust/posx.png new file mode 100644 index 0000000..bc1f98c Binary files /dev/null and b/demos/html5/art/cubemaps/stardust/posx.png differ diff --git a/demos/html5/art/cubemaps/stardust/posy.png b/demos/html5/art/cubemaps/stardust/posy.png new file mode 100644 index 0000000..a5757df Binary files /dev/null and b/demos/html5/art/cubemaps/stardust/posy.png differ diff --git a/demos/html5/art/cubemaps/stardust/posz.png b/demos/html5/art/cubemaps/stardust/posz.png new file mode 100644 index 0000000..ea84150 Binary files /dev/null and b/demos/html5/art/cubemaps/stardust/posz.png differ diff --git a/demos/html5/art/models/kgirl/animlist.txt b/demos/html5/art/models/kgirl/animlist.txt new file mode 100644 index 0000000..ef2241c --- /dev/null +++ b/demos/html5/art/models/kgirl/animlist.txt @@ -0,0 +1,28 @@ +Kgirl Animation List + +frame: 000-060 Idle (Loop) +frame: 061-065 Run Intro +frame: 066-085 Run (Loop) +frame: 086-090 Run Outro +frame: 091-101 Punch Loop +frame: 102-117 Punch Low +frame: 118-135 Punch Up +frame: 136-172 Punch Mid +frame: 173-185 Jump +frame: 186-203 Kick +frame: 204-221 Kick x3 (Loop) +frame: 228-233 Fall Loop +frame: 234-253 Land +frame: 257-270 Air attack In +frame: 271-282 Air attack Out +frame: 283-290 Dash In +frame: 289-299 Dash (loop) +frame: 300-310 Punch reverse +frame: 311-358 Punch super +frame: 359-389 Charge +frame: 390-409 Hit1 +frame: 410-426 Hit2 +frame: 427-456 Die +frame: 457-474 Get up +frame: 475-477 Walk intro +frame: 478-506 Walk (loop) diff --git a/demos/html5/art/models/kgirl/g01_texture.png b/demos/html5/art/models/kgirl/g01_texture.png new file mode 100644 index 0000000..d845403 Binary files /dev/null and b/demos/html5/art/models/kgirl/g01_texture.png differ diff --git a/demos/html5/art/models/kgirl/kgirls01.fbx b/demos/html5/art/models/kgirl/kgirls01.fbx new file mode 100644 index 0000000..ad6c216 Binary files /dev/null and b/demos/html5/art/models/kgirl/kgirls01.fbx differ diff --git a/demos/html5/art/models/kgirl/kgirls01.fbx@animlist.txt b/demos/html5/art/models/kgirl/kgirls01.fbx@animlist.txt new file mode 100644 index 0000000..5ef639b --- /dev/null +++ b/demos/html5/art/models/kgirl/kgirls01.fbx@animlist.txt @@ -0,0 +1 @@ +frame: 0-506 Take 001 diff --git a/demos/html5/art/models/kgirl/kgirls01.license b/demos/html5/art/models/kgirl/kgirls01.license new file mode 100644 index 0000000..c46d8e0 --- /dev/null +++ b/demos/html5/art/models/kgirl/kgirls01.license @@ -0,0 +1,3 @@ +author: nanofactory +source: https://sketchfab.com/3d-models/kgirls01-d2f946f58a8040ae993cda70c97b302c +license (CC BY-NC-ND 4.0): https://creativecommons.org/licenses/by-nc-nd/4.0/ diff --git a/demos/html5/demo_collide.c b/demos/html5/demo_collide.c index 9f107b9..2430e77 100644 --- a/demos/html5/demo_collide.c +++ b/demos/html5/demo_collide.c @@ -416,169 +416,6 @@ void game_loop(void *userdata) { ddraw_capsule(vec3(x,y-1.0f,z), vec3(x,y+1.0f,z-1.0f), 0.2f); ddraw_box(vec3(0,0,-8.0f), vec3(1,1,1)); } - { - // poly(Pyramid)-Sphere (GJK) intersection*/ - sphere s = sphere(vec3(-10+0.6f*sinf(dx), 3.0f*cosf(dy),-8), 1); - poly pyr = pyramid(vec3(-10.5f,-0.5f,-7.5f), vec3(-10.5f,1.0f,-7.5f), 1.0f); - - gjk_result gjk; - if (poly_hit_sphere(&gjk, pyr, s)) - ddraw_color(RED); - else ddraw_color(WHITE); - - ddraw_sphere(s.c, 1); - ddraw_pyramid(vec3(-10.5f,-0.5f,-7.5f), 0.5f/*vec3(-10.5f,1.0f,-7.5f)*/, 1.0f); - - poly_free(&pyr); - - ddraw_box(gjk.p0, vec3(0.05f, 0.05f, 0.05f)); - ddraw_box(gjk.p1, vec3(0.05f, 0.05f, 0.05f)); - ddraw_line(gjk.p0, gjk.p1); - } - { - // poly(Diamond)-Sphere (GJK) intersection*/ - - sphere s = sphere(vec3(-20+0.6f*sinf(dx), 3.0f*cosf(dy),-8), 1); - poly dmd = diamond(vec3(-20.5f,-0.5f,-7.5f), vec3(-20.5f,1.0f,-7.5f), 0.5f); - - gjk_result gjk; - if (poly_hit_sphere(&gjk, dmd, s)) - ddraw_color(RED); - else ddraw_color(WHITE); - - ddraw_sphere(s.c, 1); - ddraw_diamond(vec3(-20.5f,-0.5f,-7.5f), vec3(-20.5f,1.0f,-7.5f), 0.5f); - - poly_free(&dmd); - - ddraw_box(gjk.p0, vec3(0.05f, 0.05f, 0.05f)); - ddraw_box(gjk.p1, vec3(0.05f, 0.05f, 0.05f)); - ddraw_line(gjk.p0, gjk.p1); - } - { - // poly(Pyramid)-Capsule (GJK) intersection*/ - - const float x = 0.4f*sinf(dx); - const float y = 3.0f*cosf(dy); - const float z = -15; - - capsule c = capsule(vec3(x,y-1.0f,z), vec3(x,y+1.0f,z), 0.2f); - poly pyr = pyramid(vec3(-0.5f,-0.5f,-15.5f), vec3(-0.5f,1.0f,-15.5f), 1.0f); - - gjk_result gjk; - if (poly_hit_capsule(&gjk, pyr, c)) - ddraw_color(RED); - else ddraw_color(WHITE); - - ddraw_capsule(c.a, c.b, c.r); - ddraw_pyramid(vec3(-0.5f,-0.5f,-15.5f), 0.5f/*vec3(-0.5f,1.0f,-15.5f)*/, 1.0f); - - poly_free(&pyr); - - ddraw_box(gjk.p0, vec3(0.05f, 0.05f, 0.05f)); - ddraw_box(gjk.p1, vec3(0.05f, 0.05f, 0.05f)); - ddraw_line(gjk.p0, gjk.p1); - } - - { - // poly(Diamond)-Capsule (GJK) intersection*/ - - const float x = -10 + 0.4f*sinf(dx); - const float y = 3.0f*cosf(dy); - const float z = -15; - - capsule c = capsule(vec3(x,y-1.0f,z), vec3(x,y+1.0f,z), 0.2f); - poly dmd = diamond(vec3(-10.5f,-0.5f,-15.5f), vec3(-10.5f,1.0f,-15.5f), 0.5f); - - gjk_result gjk; - if (poly_hit_capsule(&gjk, dmd, c)) - ddraw_color(RED); - else ddraw_color(WHITE); - - ddraw_capsule(c.a, c.b, c.r); - ddraw_diamond(vec3(-10.5f,-0.5f,-15.5f), vec3(-10.5f,1.0f,-15.5f), 0.5f); - - poly_free(&dmd); - - ddraw_box(gjk.p0, vec3(0.05f, 0.05f, 0.05f)); - ddraw_box(gjk.p1, vec3(0.05f, 0.05f, 0.05f)); - ddraw_line(gjk.p0, gjk.p1); - } - - { - // poly(Diamond)-poly(Pyramid) (GJK) intersection*/ - - const float x = -20 + 0.4f*sinf(dx); - const float y = 3.0f*cosf(dy); - const float z = -15; - - poly pyr = pyramid(vec3(x,y-0.5f,z), vec3(x,y+1,z), 0.8f); - poly dmd = diamond(vec3(-20.5f,-0.5f,-15.5f), vec3(-20.5f,1.0f,-15.5f), 0.5f); - - gjk_result gjk; - if (poly_hit_poly(&gjk, dmd, pyr)) - ddraw_color(RED); - else ddraw_color(WHITE); - - ddraw_pyramid(vec3(x,y-0.5f,z), 1/*vec3(x,y+1,z)*/, 1/*0.8f*/); - ddraw_diamond(vec3(-20.5f,-0.5f,-15.5f), vec3(-20.5f,1.0f,-15.5f), 0.5f); - - poly_free(&dmd); - poly_free(&pyr); - - ddraw_box(gjk.p0, vec3(0.05f, 0.05f, 0.05f)); - ddraw_box(gjk.p1, vec3(0.05f, 0.05f, 0.05f)); - ddraw_line(gjk.p0, gjk.p1); - } - { - // poly(Pyramid)-poly(Diamond) (GJK) intersection*/ - - const float x = 10 + 0.4f*sinf(dx); - const float y = 3.0f*cosf(dy); - const float z = -15; - - poly dmd = diamond(vec3(x,y-0.5f,z), vec3(x,y+1,z), 0.5f); - poly pyr = pyramid(vec3(10.5f,-0.5f,-15.5f), vec3(10.5f,1.0f,-15.5f), 1.0f); - - gjk_result gjk; - if (poly_hit_poly(&gjk, dmd, pyr)) - ddraw_color(RED); - else ddraw_color(WHITE); - - ddraw_diamond(vec3(x,y-0.5f,z), vec3(x,y+1,z), 0.5f); - ddraw_pyramid(vec3(10.5f,-0.5f,-15.5f), 0.5f/*vec3(10.5f,1.0f,-15.5f)*/, 1.0f); - - poly_free(&dmd); - poly_free(&pyr); - - ddraw_box(gjk.p0, vec3(0.05f, 0.05f, 0.05f)); - ddraw_box(gjk.p1, vec3(0.05f, 0.05f, 0.05f)); - ddraw_line(gjk.p0, gjk.p1); - } - { - // poly(Diamond)-AABB (GJK) intersection*/ - - const float x = 20 + 0.4f*sinf(dx); - const float y = 3.0f*cosf(dy); - const float z = -15; - - poly dmd = diamond(vec3(x,y-0.5f,z), vec3(x,y+1,z), 0.5f); - aabb a = aabb(vec3(19.5f,-0.5f,-14.5f), vec3(20.5f,0.5f,-15.5f)); - - gjk_result gjk; - if (poly_hit_aabb(&gjk, dmd, a)) - ddraw_color(RED); - else ddraw_color(WHITE); - - poly_free(&dmd); - - ddraw_diamond(vec3(x,y-0.5f,z), vec3(x,y+1,z), 0.5f); - ddraw_box(vec3(20,0,-15), vec3(1,1,1)); - - ddraw_box(gjk.p0, vec3(0.05f, 0.05f, 0.05f)); - ddraw_box(gjk.p1, vec3(0.05f, 0.05f, 0.05f)); - ddraw_line(gjk.p0, gjk.p1); - } } //fx_begin(); diff --git a/demos/html5/hello.c b/demos/html5/hello.c new file mode 100644 index 0000000..978a44f --- /dev/null +++ b/demos/html5/hello.c @@ -0,0 +1,104 @@ +// playground tests for V4K +// - rlyeh, public domain +// +// # quickstart +// - win/vc : cl hello.c +// - win/clang-cl : clang-cl hello.c +// - win/tcc : tools\tcc hello.c -m64 +// - win/mingw : gcc hello.c -lws2_32 -lwinmm -ldbghelp -lole32 -luser32 -lgdi32 -lcomdlg32 +// - win/clang : clang hello.c -lws2_32 -lwinmm -ldbghelp -lole32 -luser32 -lgdi32 -lcomdlg32 +// - linux : cc hello.c -lm -ldl -lpthread -lX11 +// - linux/tcc : tcc hello.c -lm -ldl -lpthread -lX11 -D__STDC_NO_VLA__ +// - osx : cc -ObjC hello.c -framework cocoa -framework iokit -framework audiotoolbox + +#include "v4k.h" + +// options +unsigned no_flags = 0; +bool do_debugdraw = 1; + +// load skybox: launch with --mie for rayleigh/mie scattering +skybox_t sky; + +// animated models loading +model_t girl; + +// camera +camera_t cam; + +void gameloop(void *userdata) +{ + // input + if( input_down(KEY_ESC) && !is(ems) ) exit(0); + if( input_down(KEY_F5) ) window_reload(); + if( input_down(KEY_F11) ) window_fullscreen( window_has_fullscreen() ^ 1 ); + if( input_down(KEY_X) && input_held(KEY_LALT) ) window_screenshot(__FILE__ ".png"); + if( input_down(KEY_Z) && input_held(KEY_LALT) ) window_record(__FILE__ ".mp4"); + + // fps camera + bool active = ui_active() || ui_hover() || gizmo_active() ? false : input(MOUSE_L) || input(MOUSE_M) || input(MOUSE_R); + if( active ) cam.speed = clampf(cam.speed + input_diff(MOUSE_W) / 10, 0.05f, 5.0f); + vec2 mouse = scale2(vec2(input_diff(MOUSE_X), -input_diff(MOUSE_Y)), 0.2f * active); + vec3 wasdecq = scale3(vec3(input(KEY_D)-input(KEY_A),input(KEY_E)-(input(KEY_C)||input(KEY_Q)),input(KEY_W)-input(KEY_S)), cam.speed); + camera_moveby(&cam, wasdecq); + camera_fps(&cam, mouse.x,mouse.y); + window_cursor( !active ); + + // apply post-fxs from here + //fx_begin(); + + // debug draw + ddraw_ground(0); + if(do_debugdraw) ddraw_demo(); // showcase many debugdraw shapes + ddraw_flush(); + + // draw skybox + skybox_render(&sky, cam.proj, cam.view); + + // animate girl + float delta = window_delta() * 30; // 30fps anim + girl.curframe = model_animate(girl, girl.curframe + delta); + + // draw girl + model_render(girl, cam.proj, cam.view, girl.pivot, no_flags); + + // post-fxs end here + //fx_end(); + + // font demo + font_print(va(FONT_BOTTOM FONT_RIGHT FONT_H6 "%5.2f FPS", window_fps())); + + // draw ui demo (true=showcase windows) + ui_demo(true); + + // draw ui + if( ui_panel("App ", PANEL_OPEN)) + { + ui_section("DebugDraw"); + if( ui_bool("Show debugdraw demo", &do_debugdraw) ) {} + + ui_section("Script"); + if( ui_button("Test Lua") ) script_run("ui_notify(nil, \"Hello from Lua! Version: \" .. _VERSION)"); + + ui_panel_end(); + } +} + +int main() { + // window (80% sized, MSAA x4 flag) + window_create(80, WINDOW_MSAA4); + window_title(__FILE__); + + // load skybox: launch with --mie for rayleigh/mie scattering + sky = skybox(flag("--mie") ? 0 : "cubemaps/stardust", no_flags); + + // animated models loading + girl = model("kgirl/kgirls01.fbx", no_flags); + compose44( girl.pivot, vec3(0,0,0), eulerq(vec3(-90,0,0)), vec3(2,2,2)); // position, rotation, scale + + // camera + cam = camera(); + + // demo loop + window_loop(gameloop, NULL); +} \ No newline at end of file diff --git a/tools/cook_web.ini b/tools/cook_web.ini index 36fc467..96a8821 100644 --- a/tools/cook_web.ini +++ b/tools/cook_web.ini @@ -7,7 +7,7 @@ ; syntax: symbols are defined in KEY=value form, as seen below. TOOLS=./ ; folder where our pipeline tools are located -ART=../engine/art ; comma-separated folder(s) that store all our asset files +ART=../engine/art,../demos/html5/art ; comma-separated folder(s) that store all our asset files ; lines starting with @windows, @linux or @osx will be processed only where OS matches. ; we are defining here some symbols differently for each platform. @@ -38,6 +38,8 @@ ART=../engine/art ; comma-separated folder(s) that store all our asse font=ttf,ttc,otf text=json,xml,csv,ini,cfg,doc,txt,md,c,h,inl,cpp,hpp,htm,html shader=hlsl,fx,dxil,dxbc,glsl,vert,frag,geom,tese,tesc,comp,vs,fs,gs,ts,cs,spirv,spv,slang +model=iqm,iqe,gltf,gltf2,glb,fbx,obj,dae,blend,md3,md5,ms3d,smd,x,3ds,bvh,dxf,lwo +texture=pvr,ktx,ktx2,dds,astc,basis,tga ; ------------------------------------------------------------------------------ ; cook localization files @@ -58,5 +60,93 @@ shader=hlsl,fx,dxil,dxbc,glsl,vert,frag,geom,tese,tesc,comp,vs,fs,gs,ts,cs,spirv ; hint: use plain `0` to exclude those usually large files that compress poorly (<1%) (like mpg) ; hint: use plain `0` to exclude those files we would like to directly stream within the final zipfile (flac,mp3,adpcm wav,...) + +; ------------------------------------------------------------------------------ +; let's cook all images into ktx + +[cook image && !png && !jpg && !hdr] +;TOOLS/cuttlefish.EXE -q -i INPUT -o OUTPUT -f R8G8B8A8 -> ktx +TOOLS/PVRTexToolCLI.EXE -noout -m -i INPUT -o OUTPUT -> png + +[cook texture && tga] +TOOLS/cuttlefish.EXE -q -m -i INPUT -o OUTPUT -f BC1_RGB -> ktx + +[cook texture && !dds && !ktx] +TOOLS/PVRTexToolCLI.EXE -noout -m -i INPUT -o OUTPUT -> dds + +[cook dds] +; @todo: support per-asset options. ie, you can override +; or expand the FLAGS symbol, per asset basis. let's say that for each input `file.ext` +; asset, there could be a sibling `file.ext.ini` file that would contain all the +; initial symbols and flags. then, we can merge (+=), remove (-=) or replace (=) them. +; FLAGS+=-quality 75.00 -p ; merge (+=) these flags on top of any existing per-asset flags. +TOOLS/cuttlefish.EXE -q -m -i INPUT -o OUTPUT -f BC1_RGBA -> ktx + +; # Compatibility and modes. What to choose. +; - iOS: PVRTC1_4_RGB or PVRTC1_4 (RGBA) with q:pvrtcnormal. +; - Desktop (OSX/Linux/Windows): BC1, BC1a or BC3 with q:normal. +; - Android: ETC2_RGB or ETC2_RGBA with q:etcfast. ASTC_4x4 or ASTC_8x8 with q:astcmedium, as a fallback. +; - [ref] https://www.reedbeta.com/blog/understanding-bcn-texture-compression-formats/ +; +; PVRTexToolCLI > DDS +; PVR, KTX, KTX2, [DDS,] ASTC or BASIS +; +; Cuttlefish > KTX +; BMP,CUT,DDS,EXR,G3,GIF,HDR,ICO,IFF,JBIG,JNG,JPEG,JPEG2K,JPEGXR,KOALA,MNG,PCD, +; PCX,PBM/PGM/PPM,PFM,PNG,PIC,PSD,RAW,RAS,SGI,TARGA,TIFF,WBMP,WebP,XBM,XPM +; +; >> bin\cuttlefish -i uv_checker_1k.png -o uv_checker_1k.png.ktx -f bc1_rgba +; R4G4,R4G4B4A4,B4G4R4A4,A4R4G4B4,R5G6B5,B5G6R5,R5G5B5A1,B5G5R5A1,A1R5G5B5,R8,R8G8,R8G8B8,B8G8R8,R8G8B8A8,B8G8R8A8,A8B8G8R8, +; A2R10G10B10,A2B10G10R10,R16,R16G16,R16G16B16,R16G16B16A16,R32,R32G32,R32G32B32,R32G32B32A32,B10G11R11_UFloat,E5B9G9R9_UFloat, +; BC1_RGB,BC1_RGBA,BC2,BC3,BC4,BC5,BC6H,BC7,ETC1,ETC2_R8G8B8,ETC2_R8G8B8A1,ETC2_R8G8B8A8,EAC_R11,EAC_R11G11, +; ASTC_4x4,ASTC_5x4,ASTC_5x5,ASTC_6x5,ASTC_6x6,ASTC_8x5,ASTC_8x6,ASTC_8x8,ASTC_10x5,ASTC_10x6,ASTC_10x8,ASTC_10x10,ASTC_12x10,ASTC_12x12, +; PVRTC1_RGB_2BPP,PVRTC1_RGBA_2BPP,PVRTC1_RGB_4BPP,PVRTC1_RGBA_4BPP,PVRTC2_RGBA_2BPP,PVRTC2_RGBA_4BPP, +; +; >> bin\PVRTexToolCLI -i uv_checker_1k.png -o uv_checker_1k.png.ktx -f bc1 +; PVRTC1_2, PVRTC1_4, PVRTC1_2_RGB, PVRTC1_4_RGB, PVRTC2_2, PVRTC2_4, PVRTC1_HDR_6, PVRTC1_HDR_8, PVRTC2_HDR_6, PVRTC2_HDR_8, +; ETC1, BC1, DXT2, BC2, DXT4, BC3, BC4, BC5, UYVY, YUY2, 1BPP, RGBE9995, RGBG8888, GRGB8888, ETC2_RGB, ETC2_RGBA, ETC2_RGB_A1, EAC_R11, EAC_RG11, +; ASTC_4x4, ASTC_5x4, ASTC_5x5, ASTC_6x5, ASTC_6x6, ASTC_8x5, ASTC_8x6, ASTC_8x8, ASTC_10x5, ASTC_10x6, ASTC_10x8, ASTC_10x10, ASTC_12x10, ASTC_12x12, +; ASTC_3x3x3, ASTC_4x3x3, ASTC_4x4x3, ASTC_4x4x4, ASTC_5x4x4, ASTC_5x5x4, ASTC_5x5x5, ASTC_6x5x5, ASTC_6x6x5, ASTC_6x6x6, BASISU_ETC1S, BASISU_UASTC, RGBM, RGBD +; +; -f [UB, UBN, SB, SBN, US, USN, SS, SSN, UI, UIN, SI, SIN, UF, SF] +; -f [lRGB, sRGB] +; -q [pvrtcfastest,pvrtcfast,pvrtcnormal,pvrtchigh,pvrtcbest] +; -q [etcfast,etcslow,etcfastperceptual,etcslowperceptual] +; -q [astcveryfast,astcfast,astcmedium,astcthorough,astcexhaustive] +; +; -m 16 -mfilter cubic ;; mipmaps +; -c ;; debug mipmap tail chain with saturated colours: truncate upper mipmaps if dont see any original colors +; +; -l ;; bleed +; -flip y,flag ;; flip +; -p ;; premultiply +; -r 512,256 -rfilter cubic ;; resize +; -rotate 0 ;; rotate +; -dither ;; dither +; + +; ------------------------------------------------------------------------------ +; finally, let's cook all models. the logic here is: +; 1. cook all models into iqe (ass2iqe), then into iqm (iqe2iqm): any -> iqe -> iqm +; 2. unless input is iqe. these models will run iqe2iqm only (no ass2iqe): iqe -> iqm. +; 3. unless input is iqm. these models will not run any conversion at all: iqm. +; 4. also, dae models need to flip their UVs coordinates (see -U flag below). + +[cook model && dae] ; pass dae, reject iqm,iqe or any other model +FLAGS= +TOOLS/ass2iqe.EXE FLAGS -o OUTPUT INPUT -U 2> NUL -> iqe + +[cook model && !dae && !iqm && !iqe] ; pass anything which is not iqm,iqe or dae +FLAGS= +TOOLS/ass2iqe.EXE FLAGS -o OUTPUT INPUT 2> NUL -> iqe + +[cook model && !iqm] +TOOLS/iqe2iqm.EXE OUTPUT INPUT > NUL -> iqm + +[cook anim] +FLAGS= +TOOLS/ass2iqe.EXE FLAGS -L -o OUTPUT INPUT 2> NUL -> animlist.txt + + [compress] 0|ULZ=font,text,shader