├── .github ├── FUNDING.yml └── workflows │ ├── c-cpp.yml │ ├── cmake.yml │ └── msbuild.yml ├── .gitignore ├── .gitmodules ├── .travis.yml ├── .vscode └── settings.json ├── CMakeLists.txt ├── LICENSE ├── README.md ├── appveyor.yml ├── assetkit.png ├── autogen.sh ├── build-deps.sh ├── configure.ac ├── docs ├── make.bat └── source │ ├── api.rst │ ├── assetkit.png │ ├── build.rst │ ├── conf.py │ ├── getting_started.rst │ ├── index.rst │ ├── opt.rst │ ├── quick_intro.rst │ └── version.rst ├── include └── ak │ ├── animation.h │ ├── assetkit.h │ ├── bbox.h │ ├── cam.h │ ├── common.h │ ├── context.h │ ├── controller.h │ ├── coord-util.h │ ├── coord.h │ ├── core-types.h │ ├── geom.h │ ├── image.h │ ├── instance.h │ ├── library.h │ ├── light.h │ ├── map.h │ ├── material.h │ ├── memory.h │ ├── node.h │ ├── options.h │ ├── path.h │ ├── profile.h │ ├── sid.h │ ├── source.h │ ├── string.h │ ├── texture.h │ ├── transform.h │ ├── trash.h │ ├── type.h │ ├── url.h │ ├── util.h │ └── version.h ├── makefile.am ├── post-build.sh ├── scripts └── strpool.py ├── src ├── CMakeLists.txt ├── accessor.c ├── accessor.h ├── array.c ├── array.h ├── asset.c ├── assetkit.c ├── base64.c ├── base64.h ├── bbox │ ├── CMakeLists.txt │ ├── bbox.c │ ├── bbox.h │ ├── geom.c │ ├── mesh.c │ ├── mesh_prim.c │ └── scene.c ├── bitwise │ ├── CMakeLists.txt │ └── bitwise.h ├── camera │ ├── CMakeLists.txt │ └── cam.c ├── common.c ├── common.h ├── config.h ├── coord │ ├── CMakeLists.txt │ ├── camera.c │ ├── common.c │ ├── common.h │ ├── doc.c │ ├── geom.c │ ├── mesh.c │ ├── node.c │ ├── scene.c │ ├── transform.c │ ├── transforms.c │ └── vector.c ├── data.c ├── data.h ├── default │ ├── CMakeLists.txt │ ├── cam.c │ ├── cam.h │ ├── cmp.c │ ├── coord.c │ ├── id.c │ ├── light.c │ ├── light.h │ ├── material.c │ ├── material.h │ ├── opt.c │ ├── opt.h │ ├── semantic.c │ ├── semantic.h │ ├── type.c │ └── type.h ├── endian.h ├── find.c ├── geom │ ├── CMakeLists.txt │ └── mesh.c ├── id.c ├── id.h ├── image │ ├── CMakeLists.txt │ └── image.c ├── instance │ ├── CMakeLists.txt │ ├── inst.c │ └── list.c ├── io │ ├── 3mf │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── imp │ │ │ ├── 3mf.c │ │ │ ├── 3mf.h │ │ │ ├── CMakeLists.txt │ │ │ └── common.h │ ├── CMakeLists.txt │ ├── common │ │ ├── CMakeLists.txt │ │ ├── postscript.c │ │ ├── postscript.h │ │ ├── util.c │ │ └── util.h │ ├── dae │ │ ├── 1.4 │ │ │ ├── CMakeLists.txt │ │ │ ├── dae14.c │ │ │ ├── dae14.h │ │ │ ├── image.c │ │ │ ├── image.h │ │ │ ├── surface.c │ │ │ └── surface.h │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── brep │ │ │ ├── CMakeLists.txt │ │ │ ├── brep.c │ │ │ ├── brep.h │ │ │ ├── curve.c │ │ │ ├── curve.h │ │ │ ├── nurb.c │ │ │ ├── nurb.h │ │ │ ├── surface.c │ │ │ ├── surface.h │ │ │ ├── topology.c │ │ │ └── topology.h │ │ ├── bugfix │ │ │ ├── CMakeLists.txt │ │ │ ├── transp.c │ │ │ └── transp.h │ │ ├── common.h │ │ ├── core │ │ │ ├── CMakeLists.txt │ │ │ ├── anim.c │ │ │ ├── anim.h │ │ │ ├── asset.c │ │ │ ├── asset.h │ │ │ ├── cam.c │ │ │ ├── cam.h │ │ │ ├── color.c │ │ │ ├── color.h │ │ │ ├── ctlr.c │ │ │ ├── ctlr.h │ │ │ ├── enum.c │ │ │ ├── enum.h │ │ │ ├── geom.c │ │ │ ├── geom.h │ │ │ ├── light.c │ │ │ ├── light.h │ │ │ ├── line.c │ │ │ ├── line.h │ │ │ ├── mesh.c │ │ │ ├── mesh.h │ │ │ ├── morph.c │ │ │ ├── morph.h │ │ │ ├── node.c │ │ │ ├── node.h │ │ │ ├── param.c │ │ │ ├── param.h │ │ │ ├── poly.c │ │ │ ├── poly.h │ │ │ ├── scene.c │ │ │ ├── scene.h │ │ │ ├── skin.c │ │ │ ├── skin.h │ │ │ ├── source.c │ │ │ ├── source.h │ │ │ ├── spline.c │ │ │ ├── spline.h │ │ │ ├── techn.c │ │ │ ├── techn.h │ │ │ ├── triangle.c │ │ │ ├── triangle.h │ │ │ ├── value.c │ │ │ ├── value.h │ │ │ ├── vert.c │ │ │ └── vert.h │ │ ├── ctlr.c │ │ ├── dae.c │ │ ├── dae.h │ │ ├── fixup │ │ │ ├── CMakeLists.txt │ │ │ ├── angle.c │ │ │ ├── angle.h │ │ │ ├── ctlr.c │ │ │ ├── ctlr.h │ │ │ ├── geom.c │ │ │ ├── geom.h │ │ │ ├── mesh.c │ │ │ ├── mesh.h │ │ │ ├── node.c │ │ │ ├── node.h │ │ │ ├── tex.c │ │ │ └── tex.h │ │ ├── fx │ │ │ ├── CMakeLists.txt │ │ │ ├── colortex.c │ │ │ ├── colortex.h │ │ │ ├── effect.c │ │ │ ├── effect.h │ │ │ ├── fltprm.c │ │ │ ├── fltprm.h │ │ │ ├── img.c │ │ │ ├── img.h │ │ │ ├── mat.c │ │ │ ├── mat.h │ │ │ ├── profile.c │ │ │ ├── profile.h │ │ │ ├── samp.c │ │ │ ├── samp.h │ │ │ ├── techn.c │ │ │ └── techn.h │ │ ├── postscript.c │ │ ├── postscript.h │ │ ├── strpool.c │ │ ├── strpool.h │ │ ├── strpool.json │ │ └── strpool.py │ ├── gltf │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── common.h │ │ ├── imp │ │ │ ├── CMakeLists.txt │ │ │ ├── common.h │ │ │ ├── core │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── accessor.c │ │ │ │ ├── accessor.h │ │ │ │ ├── anim.c │ │ │ │ ├── anim.h │ │ │ │ ├── asset.c │ │ │ │ ├── asset.h │ │ │ │ ├── buffer.c │ │ │ │ ├── buffer.h │ │ │ │ ├── camera.c │ │ │ │ ├── camera.h │ │ │ │ ├── enum.c │ │ │ │ ├── enum.h │ │ │ │ ├── image.c │ │ │ │ ├── image.h │ │ │ │ ├── material.c │ │ │ │ ├── material.h │ │ │ │ ├── mesh.c │ │ │ │ ├── mesh.h │ │ │ │ ├── node.c │ │ │ │ ├── node.h │ │ │ │ ├── profile.c │ │ │ │ ├── profile.h │ │ │ │ ├── sampler.c │ │ │ │ ├── sampler.h │ │ │ │ ├── scene.c │ │ │ │ ├── scene.h │ │ │ │ ├── skin.c │ │ │ │ ├── skin.h │ │ │ │ ├── texture.c │ │ │ │ └── texture.h │ │ │ ├── gltf.c │ │ │ ├── gltf.h │ │ │ ├── mesh_fixup.c │ │ │ ├── mesh_fixup.h │ │ │ ├── postscript.c │ │ │ └── postscript.h │ │ ├── strpool.c │ │ ├── strpool.h │ │ ├── strpool.json │ │ └── strpool.py │ ├── obj │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── common.h │ │ ├── group.c │ │ ├── group.h │ │ ├── mtl.c │ │ ├── mtl.h │ │ ├── obj.c │ │ ├── obj.h │ │ ├── util.c │ │ └── util.h │ ├── ply │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── ascii.c │ │ ├── bin.c │ │ ├── common.h │ │ ├── ply.c │ │ ├── ply.h │ │ └── util.h │ └── stl │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── common.h │ │ ├── stl.c │ │ └── stl.h ├── json.h ├── lib │ ├── CMakeLists.txt │ ├── geom.c │ └── lib.c ├── light │ ├── CMakeLists.txt │ └── light.c ├── main.c ├── map.c ├── mem │ ├── CMakeLists.txt │ ├── common.h │ ├── ext.c │ ├── intr.c │ ├── lt.c │ ├── lt.h │ ├── mem.c │ ├── mmap.c │ ├── rb.c │ └── rb.h ├── mesh │ ├── CMakeLists.txt │ ├── duplicator.c │ ├── edit.c │ ├── edit_buff.c │ ├── edit_buff_fixup.c │ ├── edit_common.h │ ├── edit_index.c │ ├── index.c │ ├── index.h │ ├── input.c │ ├── isolate.c │ ├── material.c │ ├── normal.c │ └── triangulate.c ├── miniz │ ├── CMakeLists.txt │ ├── LICENSE │ ├── miniz.c │ └── miniz.h ├── morph │ ├── CMakeLists.txt │ └── intr.c ├── node │ ├── CMakeLists.txt │ └── node.c ├── profile.c ├── profile.h ├── resc │ ├── CMakeLists.txt │ ├── path.c │ ├── resource.c │ ├── resource.h │ └── url.c ├── sid.c ├── sid.h ├── sid_constr.c ├── skin │ ├── CMakeLists.txt │ ├── fix.c │ ├── fix.h │ └── skin.c ├── string.c ├── strpool.c ├── strpool.h ├── strpool.json ├── strpool.py ├── transform │ ├── CMakeLists.txt │ ├── dup.c │ ├── trans.c │ └── traverse.c ├── trash.c ├── trash.h ├── tree.c ├── tree.h ├── type.c ├── type.h ├── utils.c ├── utils.h ├── win32 │ ├── CMakeLists.txt │ ├── dllmain.c │ └── strptime.c ├── xml.c └── xml.h ├── test ├── include │ └── common.h ├── runner.c ├── src │ ├── collada │ │ └── test_dae_load.c │ ├── test_common.h │ └── test_memory.c └── tests.h └── win ├── .gitignore ├── assetkit.sln ├── assetkit.vcxproj ├── assetkit.vcxproj.filters ├── build.bat └── packages.config /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [recp] 4 | patreon: recp 5 | open_collective: assetkit 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: build-deps 17 | run: sh ./build-deps.sh 18 | - name: autogen 19 | run: sh ./autogen.sh 20 | - name: configure 21 | run: ./configure 22 | - name: make 23 | run: make 24 | -------------------------------------------------------------------------------- /.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: CMake 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 11 | BUILD_TYPE: Release 12 | 13 | jobs: 14 | build: 15 | # The CMake configure and build commands are platform agnostic and should work equally 16 | # well on Windows or Mac. You can convert this to a matrix build if you need 17 | # cross-platform coverage. 18 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | 24 | - name: Configure CMake 25 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 26 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 27 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 28 | 29 | - name: Build 30 | # Build your program with the given configuration 31 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} 32 | 33 | # - name: Test 34 | # working-directory: ${{github.workspace}}/build 35 | # # Execute tests defined by the CMake configuration. 36 | # # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 37 | # run: ctest -C ${{env.BUILD_TYPE}} 38 | 39 | -------------------------------------------------------------------------------- /.github/workflows/msbuild.yml: -------------------------------------------------------------------------------- 1 | name: MSBuild 2 | 3 | on: [push] 4 | 5 | env: 6 | # Path to the solution file relative to the root of the project. 7 | SOLUTION_FILE_PATH: ./win 8 | 9 | # Configuration type to build. 10 | # You can convert this to a build matrix if you need coverage of multiple configuration types. 11 | # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 12 | BUILD_CONFIGURATION: Release 13 | 14 | jobs: 15 | build: 16 | runs-on: windows-latest 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | 21 | - name: Add MSBuild to PATH 22 | uses: microsoft/setup-msbuild@v1.0.2 23 | 24 | - name: Restore NuGet packages 25 | working-directory: ${{env.GITHUB_WORKSPACE}} 26 | run: nuget restore ${{env.SOLUTION_FILE_PATH}} 27 | 28 | - name: Build 29 | working-directory: ${{env.GITHUB_WORKSPACE}} 30 | # Add additional options to the MSBuild command line here (like platform or verbosity level). 31 | # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference 32 | run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.xcodeproj 2 | *.xcworkspace 3 | *.sln 4 | *.vcxproj 5 | *.vcxproj.* 6 | *.suo 7 | *.sdf 8 | *.opensdf 9 | ipch/ 10 | Debug/ 11 | Release/ 12 | .DS_Store 13 | .vs 14 | *.nupkg 15 | *.opendb 16 | packages.config 17 | /aclocal.m4 18 | /ar-lib 19 | /autom4te.cache/ 20 | /compile 21 | /config.guess 22 | /config.log 23 | /config.status 24 | /config.sub 25 | /configure 26 | /depcomp 27 | /install-sh 28 | /ltmain.sh 29 | /missing 30 | /libtool 31 | .libs/ 32 | .deps/ 33 | *.[oa] 34 | *.l[oa] 35 | Makefile 36 | Makefile.in 37 | m4/*.m4 38 | .buildstamp 39 | .dirstamp 40 | packages/ 41 | .anjuta/* 42 | *.anjuta* 43 | config.h.* 44 | libxml* 45 | xml2* 46 | python/setup.py 47 | config.h 48 | stamp* 49 | COPYING 50 | .idea/* 51 | *.VC.db 52 | test-driver 53 | /include/include/ 54 | *.log 55 | test/ak-tests.trs 56 | test/ak-tests 57 | *.gcov 58 | *.gcno 59 | *.gcda 60 | tests.trs 61 | tests 62 | *.userprefs 63 | *.orig 64 | cmake-build-debug 65 | win/x64/* 66 | win/x86/* 67 | build/ 68 | .cache/ 69 | .scannerwork/ 70 | .project 71 | .cproject 72 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/cglm"] 2 | path = deps/cglm 3 | url = https://github.com/recp/cglm.git 4 | [submodule "deps/json"] 5 | path = deps/json 6 | url = https://github.com/recp/json.git 7 | [submodule "deps/xml"] 8 | path = deps/xml 9 | url = https://github.com/recp/xml.git 10 | [submodule "deps/ds"] 11 | path = deps/ds 12 | url = https://github.com/recp/ds.git 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | sudo: required 8 | dist: trusty 9 | 10 | compiler: 11 | - clang 12 | - gcc 13 | 14 | matrix: 15 | fast_finish: true 16 | exclude: 17 | # Skip GCC builds on macOS. 18 | - os: osx 19 | compiler: gcc 20 | include: 21 | # Additional GCC builds for code coverage. 22 | - os: linux 23 | compiler: gcc 24 | env: CODE_COVERAGE=ON 25 | 26 | cache: 27 | apt: true 28 | 29 | addons: 30 | apt: 31 | packages: 32 | - lcov 33 | 34 | branches: 35 | only: 36 | - master 37 | 38 | script: 39 | - sh ./build-deps.sh 40 | - sh ./autogen.sh 41 | - if [[ "$CC" == "gcc" && "$CODE_COVERAGE" == "ON" ]]; then 42 | ./configure CFLAGS="-ftest-coverage -fprofile-arcs"; 43 | else 44 | ./configure; 45 | fi 46 | - make -j8 47 | # - make check 48 | 49 | after_success: 50 | - if [[ "$CC" == "gcc" && "$CODE_COVERAGE" == "ON" ]]; then 51 | pip install --user cpp-coveralls && 52 | coveralls 53 | --build-root . 54 | --exclude lib 55 | --exclude test 56 | --gcov-options '\-lp' 57 | --verbose; 58 | fi 59 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "workbench.colorTheme": "Visual Studio Light - C++" 3 | } -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2017 2 | 3 | build_script: 4 | - ps: >- 5 | cd win 6 | 7 | .\build.bat 8 | -------------------------------------------------------------------------------- /assetkit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recp/AssetKit/871af8bcafd0f79af76e5cf430c736bb8ac2294d/assetkit.png -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Copyright (C) 2020 Recep Aslantas 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | cd $(dirname "$0") 19 | 20 | autoheader 21 | 22 | if [ "$(uname)" = "Darwin" ]; then 23 | glibtoolize 24 | else 25 | libtoolize 26 | fi 27 | 28 | aclocal -I m4 29 | autoconf 30 | automake --add-missing --copy 31 | -------------------------------------------------------------------------------- /build-deps.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Copyright (C) 2020 Recep Aslantas 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # check if deps are pulled 19 | git submodule update --init --recursive 20 | 21 | cd $(dirname "$0") 22 | 23 | if [ "$(uname)" = "Darwin" ]; then 24 | LIBTOOLIZE='glibtoolize' 25 | else 26 | LIBTOOLIZE='libtoolize' 27 | fi 28 | 29 | # general deps: gcc make autoconf automake libtool cmake 30 | 31 | # libds 32 | cd ./deps/ds 33 | sh ./autogen.sh 34 | ./configure 35 | make -j8 36 | 37 | cd ../../ 38 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=python -msphinx 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | set SPHINXPROJ=cglm 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The Sphinx module was not found. Make sure you have Sphinx installed, 20 | echo.then set the SPHINXBUILD environment variable to point to the full 21 | echo.path of the 'sphinx-build' executable. Alternatively you may add the 22 | echo.Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /docs/source/api.rst: -------------------------------------------------------------------------------- 1 | API documentation 2 | ================================ 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | :caption: API categories: 7 | 8 | version 9 | -------------------------------------------------------------------------------- /docs/source/assetkit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/recp/AssetKit/871af8bcafd0f79af76e5cf430c736bb8ac2294d/docs/source/assetkit.png -------------------------------------------------------------------------------- /docs/source/getting_started.rst: -------------------------------------------------------------------------------- 1 | Getting Started 2 | ================================ 3 | 4 | There are lot of file formats out there. It is not easy to implement each of them 5 | individually in an engine or software. 6 | 7 | **AssetKit** provides single extensible interface for all file formats that is supported. 8 | **AssetKit** tries to full support all major file formats. 9 | -------------------------------------------------------------------------------- /docs/source/version.rst: -------------------------------------------------------------------------------- 1 | .. default-domain:: C 2 | 3 | version 4 | ================================================================================ 5 | 6 | Header: ak/version.h 7 | 8 | **AssetKit** uses semantic versioning (http://semver.org) which is MAJOR.MINOR.PATCH 9 | 10 | | **AK_VERSION_MAJOR** is major number of the version. 11 | | **AK_VERSION_MINOR** is minor number of the version. 12 | | **AK_VERSION_PATCH** is patch number of the version. 13 | 14 | every release increases these numbers. You can check existing version by 15 | including `ak/version.h` 16 | -------------------------------------------------------------------------------- /include/ak/context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef assetkit_context_h 18 | #define assetkit_context_h 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include "common.h" 24 | #include "map.h" 25 | #include "util.h" 26 | 27 | typedef struct AkContext { 28 | AkDoc *doc; 29 | AkTechniqueHint *techniqueHint; 30 | AkInstanceMaterial *instanceMaterial; 31 | // AkMap *bindVertexInput; 32 | } AkContext; 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif /* assetkit_context_h */ 38 | -------------------------------------------------------------------------------- /include/ak/coord-util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef assetkit_coord_util_h 18 | #define assetkit_coord_util_h 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include "common.h" 24 | 25 | struct AkNode; 26 | struct AkVisualScene; 27 | 28 | AK_EXPORT 29 | void 30 | ak_changeCoordSys(AkDoc * __restrict doc, 31 | AkCoordSys * newCoordSys); 32 | 33 | AK_EXPORT 34 | void 35 | ak_changeCoordSysGeom(AkGeometry * __restrict geom, 36 | AkCoordSys * newCoordSys); 37 | 38 | AK_EXPORT 39 | void 40 | ak_changeCoordSysMesh(AkMesh * __restrict mesh, 41 | AkCoordSys * newCoordSys); 42 | 43 | AK_EXPORT 44 | void 45 | ak_fixNodeCoordSys(struct AkNode * __restrict node); 46 | 47 | AK_EXPORT 48 | void 49 | ak_fixSceneCoordSys(struct AkVisualScene * __restrict scene); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif /* assetkit_coord_util_h */ 55 | -------------------------------------------------------------------------------- /include/ak/library.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef assetkit_lib_h 18 | #define assetkit_lib_h 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include "common.h" 24 | #include "cam.h" 25 | #include "light.h" 26 | 27 | typedef struct AkLibrary { 28 | /* const char * id; */ 29 | 30 | struct AkLibrary *next; 31 | const char *name; 32 | AkTree *extra; 33 | AkOneWayIterBase *chld; 34 | uint64_t count; 35 | } AkLibrary; 36 | 37 | AK_EXPORT 38 | AkGeometry * 39 | ak_libFirstGeom(AkDoc * __restrict doc); 40 | 41 | AK_EXPORT 42 | AkResult 43 | ak_libAddCamera(AkDoc * __restrict doc, AkCamera * __restrict cam); 44 | 45 | AK_EXPORT 46 | AkResult 47 | ak_libAddLight(AkDoc * __restrict doc, AkLight * __restrict light); 48 | 49 | AK_EXPORT 50 | void 51 | ak_libInsertInto(AkLibrary *lib, void *item, int32_t prevoff, int32_t nextoff); 52 | 53 | AK_EXPORT 54 | AkLibrary* 55 | ak_libFirstOrCreat(AkDoc * __restrict doc, uint32_t itemOffset); 56 | 57 | AK_EXPORT 58 | AkLibrary* 59 | ak_libImageFirstOrCreat(AkDoc * __restrict doc); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #endif /* assetkit_lib_h */ 65 | -------------------------------------------------------------------------------- /include/ak/map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* TODO: use separate rbtree instead of heap's rbtree (optional) 18 | * this map impl have many TODOs 19 | */ 20 | 21 | #ifndef assetkit_map_h 22 | #define assetkit_map_h 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "common.h" 28 | #include "memory.h" 29 | #include 30 | 31 | typedef struct AkMapItem { 32 | struct AkMapItem *prev; 33 | struct AkMapItem *next; 34 | void *data; 35 | bool isMapItem; 36 | } AkMapItem; 37 | 38 | typedef struct AkMap { 39 | AkHeap *heap; 40 | AkMapItem *root; 41 | } AkMap; 42 | 43 | typedef AkHeapSrchCmpFn AkMapCmp; 44 | 45 | AK_EXPORT 46 | void 47 | ak_map_addptr(AkMap *map, void *ptr); 48 | 49 | AK_EXPORT 50 | void* 51 | ak_map_find(AkMap *map, void *id); 52 | 53 | AK_EXPORT 54 | AkMapItem* 55 | ak_map_findm(AkMap *map, void *id); 56 | 57 | AK_EXPORT 58 | void 59 | ak_map_add(AkMap *map, 60 | void *value, 61 | void *id); 62 | 63 | AK_EXPORT 64 | void 65 | ak_multimap_add(AkMap *map, 66 | void *value, 67 | void *id); 68 | 69 | AK_EXPORT 70 | AkMap * 71 | ak_map_new(AkMapCmp cmp); 72 | 73 | AK_EXPORT 74 | void 75 | ak_map_destroy(AkMap *map); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | #endif /* assetkit_map_h */ 81 | -------------------------------------------------------------------------------- /include/ak/path.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef assetkit_path_h 18 | #define assetkit_path_h 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include "common.h" 24 | #include 25 | 26 | struct AkHeap; 27 | struct AkDoc; 28 | 29 | AK_EXPORT 30 | const char * 31 | ak_path_fragment(const char *path); 32 | 33 | AK_EXPORT 34 | size_t 35 | ak_path_trim(const char *path, 36 | char *trimmed); 37 | 38 | AK_EXPORT 39 | int 40 | ak_path_join(char *fragments[], 41 | char *buf, 42 | size_t *size); 43 | 44 | AK_EXPORT 45 | int 46 | ak_path_isfile(const char *path); 47 | 48 | AK_EXPORT 49 | char* 50 | ak_path_dir(struct AkHeap * __restrict heap, 51 | void * __restrict memparent, 52 | const char * __restrict path); 53 | 54 | AK_EXPORT 55 | const char* 56 | ak_fullpath(struct AkDoc * __restrict doc, 57 | const char * __restrict ref, 58 | char * __restrict buf); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #endif /* assetkit_path_h */ 64 | -------------------------------------------------------------------------------- /include/ak/trash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef assetkit_trash_h 18 | #define assetkit_trash_h 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include "common.h" 24 | 25 | AK_EXPORT 26 | void ak_trash_add(void *mem); 27 | 28 | AK_EXPORT 29 | void 30 | ak_trash_empty(void); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | #endif /* assetkit_trash_h */ 36 | -------------------------------------------------------------------------------- /include/ak/url.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef assetkit_url_h 18 | #define assetkit_url_h 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #include "common.h" 24 | 25 | typedef struct AkURL { 26 | const char *url; /* only fragment */ 27 | struct AkDoc *doc; /* document */ 28 | void *ptr; /* direct link */ 29 | void *reserved; /* private */ 30 | } AkURL; 31 | 32 | void 33 | ak_url_init(void *parent, 34 | char *urlstring, 35 | AkURL *dest); 36 | 37 | void 38 | ak_url_dup(AkURL *src, 39 | void *parent, 40 | AkURL *dest); 41 | 42 | void 43 | ak_url_init_with_id(AkHeapAllocator *alc, 44 | void *parent, 45 | char *idstirng, 46 | AkURL *dest); 47 | 48 | char * 49 | ak_url_string(AkHeapAllocator *alc, char *id); 50 | 51 | void 52 | ak_url_ref(AkURL *url); 53 | 54 | void 55 | ak_url_unref(AkURL *url); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | #endif /* assetkit_url_h */ 61 | -------------------------------------------------------------------------------- /include/ak/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef assetkit_util_h 18 | #define assetkit_util_h 19 | 20 | #include "common.h" 21 | 22 | /* pre-defined compare funcs */ 23 | 24 | AK_EXPORT 25 | int 26 | ak_cmp_str(void *key1, void *key2); 27 | 28 | AK_EXPORT 29 | int 30 | ak_cmp_ptr(void *key1, void *key2); 31 | 32 | AK_EXPORT 33 | int 34 | ak_digitsize(size_t number); 35 | 36 | #endif /* assetkit_util_h */ 37 | -------------------------------------------------------------------------------- /include/ak/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef assetkit_version_h 18 | #define assetkit_version_h 19 | 20 | #define AK_VERSION_MAJOR 0 21 | #define AK_VERSION_MINOR 3 22 | #define AK_VERSION_PATCH 2 23 | 24 | #endif /* assetkit_version_h */ 25 | -------------------------------------------------------------------------------- /post-build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Copyright (C) 2020 Recep Aslantas 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | #cd $(dirname "$0") 19 | # 20 | #realpath() { 21 | # [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" 22 | #} 23 | # 24 | #mkdir -p .libs 25 | # 26 | ##TODO: implement this to other platforms e.g. linux, windows 27 | #if [ "$(uname)" = "Darwin" ]; then 28 | # ak_dylib=$(realpath .libs/libassetkit.dylib) 29 | # 30 | # libds_dylib=$(readlink ./lib/libds/.libs/libds.dylib) 31 | # 32 | # cp ./lib/libds/.libs/$libds_dylib .libs/$libds_dylib 33 | # 34 | # install_name_tool -change /usr/local/lib/$libds_dylib \ 35 | # @loader_path/$libds_dylib \ 36 | # $ak_dylib 37 | #fi 38 | -------------------------------------------------------------------------------- /scripts/strpool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # Copyright (C) 2020 Recep Aslantas 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | from os.path import realpath 19 | from os.path import dirname 20 | 21 | basedir = dirname(realpath(__file__)) + '/../' 22 | 23 | strpools = [ 24 | 'src/strpool.py', 25 | 'src/io/dae/strpool.py', 26 | 'src/io/gltf/strpool.py' 27 | ] 28 | 29 | for sp in strpools: 30 | __file__ = basedir + sp 31 | exec(open(__file__).read()) 32 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | 7 | add_subdirectory(bbox) 8 | add_subdirectory(bitwise) 9 | add_subdirectory(camera) 10 | add_subdirectory(coord) 11 | add_subdirectory(default) 12 | add_subdirectory(geom) 13 | add_subdirectory(image) 14 | add_subdirectory(instance) 15 | add_subdirectory(io) 16 | add_subdirectory(lib) 17 | add_subdirectory(light) 18 | add_subdirectory(mem) 19 | add_subdirectory(mesh) 20 | add_subdirectory(morph) 21 | add_subdirectory(node) 22 | add_subdirectory(resc) 23 | add_subdirectory(skin) 24 | add_subdirectory(transform) 25 | add_subdirectory(miniz) 26 | 27 | if(MSVC OR MSYS OR MINGW) 28 | add_subdirectory(win32) 29 | endif() 30 | -------------------------------------------------------------------------------- /src/accessor.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "accessor.h" 18 | #include "default/semantic.h" 19 | #include 20 | 21 | AkAccessor* 22 | ak_accessor_dup(AkAccessor *oldacc) { 23 | AkHeap *heap; 24 | AkAccessor *acc; 25 | 26 | heap = ak_heap_getheap(oldacc); 27 | acc = ak_heap_alloc(heap, ak_mem_parent(oldacc), sizeof(*acc)); 28 | 29 | memcpy(acc, oldacc, sizeof(*oldacc)); 30 | ak_setypeid(acc, AKT_ACCESSOR); 31 | 32 | return acc; 33 | } 34 | -------------------------------------------------------------------------------- /src/accessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_accessor_h 18 | #define ak_accessor_h 19 | 20 | #include "common.h" 21 | 22 | AkAccessor* 23 | ak_accessor_dup(AkAccessor *oldacc); 24 | 25 | AK_INLINE 26 | bool 27 | ak_areSimilarLayouts(AkAccessor *acc1, AkAccessor *acc2) { 28 | return (acc1 == acc2) || ( 29 | acc1->componentType == acc2->componentType 30 | && acc1->count == acc2->count 31 | && acc1->componentCount == acc2->componentCount 32 | && acc1->componentSize == acc2->componentSize 33 | ); 34 | } 35 | 36 | 37 | #endif /* ak_accessor_h */ 38 | -------------------------------------------------------------------------------- /src/array.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_array_h 18 | #define ak_array_h 19 | 20 | #include "../include/ak/assetkit.h" 21 | 22 | AK_HIDE 23 | AkResult 24 | ak_strtostr_array(AkHeap * __restrict heap, 25 | void * __restrict memParent, 26 | char *content, 27 | char separator, 28 | AkStringArray ** __restrict array); 29 | 30 | AK_HIDE 31 | AkResult 32 | ak_strtostr_arrayL(AkHeap * __restrict heap, 33 | void * __restrict memParent, 34 | char *content, 35 | char separator, 36 | AkStringArrayL ** __restrict array); 37 | 38 | #endif /* ak_array_h */ 39 | -------------------------------------------------------------------------------- /src/asset.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common.h" 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | AK_EXPORT 24 | void* 25 | ak_getAssetInfo(void * __restrict obj, 26 | size_t itemOffset) { 27 | AkHeapNode *hnode; 28 | char **ai; 29 | void **found; 30 | 31 | assert(obj && itemOffset < sizeof(AkAssetInf)); 32 | 33 | 34 | hnode = ak__alignof(obj); 35 | 36 | do { 37 | if ((ai = ak_heap_ext_get(hnode, AK_HEAP_NODE_FLAGS_INF)) 38 | && (found = (void **)(*ai + itemOffset))) 39 | return *found; 40 | 41 | hnode = ak_heap_parent(hnode); 42 | if (!hnode) 43 | return NULL; 44 | } while (true); 45 | } 46 | 47 | AK_EXPORT 48 | AkCoordSys* 49 | ak_getCoordSys(void * __restrict obj) { 50 | /* TODO: return default coord sys if null */ 51 | return ak_getAssetInfo(obj, offsetof(AkAssetInf, coordSys)); 52 | } 53 | 54 | AK_EXPORT 55 | bool 56 | ak_hasCoordSys(void * __restrict obj) { 57 | AkHeapNode *hnode; 58 | char **ai; 59 | void **found; 60 | 61 | hnode = ak__alignof(obj); 62 | ai = ak_heap_ext_get(hnode, AK_HEAP_NODE_FLAGS_INF); 63 | if (!ai) 64 | return false; 65 | 66 | found = (void **)(*ai + offsetof(AkAssetInf, coordSys)); 67 | return found != NULL; 68 | } 69 | -------------------------------------------------------------------------------- /src/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Base64 encoding/decoding (RFC1341) 3 | * Copyright (c) 2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * 7 | * Modified by Recep Aslantas (github @recp) 8 | */ 9 | 10 | #ifndef BASE64_H 11 | #define BASE64_H 12 | 13 | #include 14 | #include 15 | #include "../include/ak/memory.h" 16 | #include "../include/ak/source.h" 17 | 18 | AK_HIDE 19 | unsigned char* 20 | base64_encode(AkHeap * __restrict heap, 21 | void * __restrict memparent, 22 | const unsigned char * __restrict src, 23 | size_t len, 24 | size_t * __restrict out_len); 25 | 26 | AK_HIDE 27 | unsigned char* 28 | base64_decode(AkHeap * __restrict heap, 29 | void * __restrict memparent, 30 | const unsigned char * __restrict src, 31 | size_t len, 32 | size_t * __restrict out_len); 33 | 34 | AK_HIDE 35 | void 36 | base64_buff(const char * __restrict b64, 37 | size_t len, 38 | AkBuffer * __restrict buff); 39 | 40 | #endif /* BASE64_H */ 41 | -------------------------------------------------------------------------------- /src/bbox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | bbox.h 4 | bbox.c 5 | geom.c 6 | mesh_prim.c 7 | mesh.c 8 | scene.c 9 | ) 10 | -------------------------------------------------------------------------------- /src/bbox/bbox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "bbox.h" 18 | #include 19 | 20 | void 21 | ak_bbox_pick(vec3 min, vec3 max, vec3 vec) { 22 | glm_vec3_minv(min, vec, min); 23 | glm_vec3_maxv(max, vec, max); 24 | } 25 | 26 | void 27 | ak_bbox_pick_pbox(AkBoundingBox *parent, 28 | AkBoundingBox *chld) { 29 | glm_vec3_minv(parent->min, chld->min, parent->min); 30 | glm_vec3_maxv(parent->max, chld->max, parent->max); 31 | } 32 | 33 | void 34 | ak_bbox_pick_pbox2(AkBoundingBox *parent, 35 | float vec1[3], 36 | float vec2[3]) { 37 | glm_vec3_minv(parent->min, vec1, parent->min); 38 | glm_vec3_minv(parent->min, vec2, parent->min); 39 | 40 | glm_vec3_maxv(parent->max, vec1, parent->max); 41 | glm_vec3_maxv(parent->max, vec2, parent->max); 42 | } 43 | 44 | void 45 | ak_bbox_center(AkBoundingBox * __restrict bbox, 46 | float center[3]) { 47 | glm_vec3_center(bbox->min, bbox->max, center); 48 | } 49 | 50 | float 51 | ak_bbox_radius(AkBoundingBox * __restrict bbox) { 52 | return glm_vec3_distance(bbox->max, bbox->min) * 0.5f; 53 | } 54 | -------------------------------------------------------------------------------- /src/bbox/bbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_src_bbox_h 18 | #define ak_src_bbox_h 19 | 20 | #include "../common.h" 21 | #include "../../include/ak/bbox.h" 22 | 23 | AK_INLINE 24 | void 25 | ak_bbox_invalidate(AkBoundingBox * __restrict bbox) { 26 | glm_vec3_broadcast(FLT_MAX, bbox->min); 27 | glm_vec3_broadcast(-FLT_MAX, bbox->max); 28 | } 29 | 30 | void 31 | ak_bbox_pick(float min[3], 32 | float max[3], 33 | float vec[3]); 34 | 35 | void 36 | ak_bbox_pick_pbox(AkBoundingBox *parent, 37 | AkBoundingBox *chld); 38 | 39 | void 40 | ak_bbox_pick_pbox2(AkBoundingBox *parent, 41 | float vec1[3], 42 | float vec2[3]); 43 | 44 | #endif /* ak_src_bbox_h */ 45 | -------------------------------------------------------------------------------- /src/bbox/geom.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "bbox.h" 18 | 19 | void 20 | ak_bbox_geom(struct AkGeometry * __restrict geom) { 21 | AkObject *primitive; 22 | 23 | primitive = geom->gdata; 24 | switch ((AkGeometryType)primitive->type) { 25 | case AK_GEOMETRY_MESH: 26 | ak_bbox_mesh(ak_objGet(primitive)); 27 | break; 28 | case AK_GEOMETRY_SPLINE: /* TODO: */ 29 | case AK_GEOMETRY_BREP: /* TODO: */ 30 | break; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/bbox/mesh.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "bbox.h" 18 | 19 | void 20 | ak_bbox_mesh(struct AkMesh * __restrict mesh) { 21 | AkMeshPrimitive *prim; 22 | vec3 center; 23 | int32_t primcount; 24 | 25 | primcount = 0; 26 | prim = mesh->primitive; 27 | 28 | if (!mesh->bbox) 29 | mesh->bbox = ak_heap_calloc(ak_heap_getheap(prim), 30 | ak_objFrom(mesh), 31 | sizeof(*mesh->bbox)); 32 | 33 | ak_bbox_invalidate(mesh->bbox); 34 | 35 | while (prim) { 36 | ak_bbox_mesh_prim(prim); 37 | primcount++; 38 | prim = prim->next; 39 | } 40 | 41 | /* compute centroid */ 42 | 43 | if (!ak_opt_get(AK_OPT_COMPUTE_EXACT_CENTER)) { 44 | ak_bbox_center(mesh->bbox, mesh->center); 45 | } else { 46 | glm_vec3_zero(center); 47 | 48 | /* calculate exact center of primitive */ 49 | if (primcount > 0) { 50 | while (prim) { 51 | ak_bbox_mesh_prim(prim); 52 | 53 | glm_vec3_add(prim->center, center, center); 54 | primcount++; 55 | prim = prim->next; 56 | } 57 | glm_vec3_divs(center, (float)primcount, mesh->center); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/bitwise/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | bitwise.h 4 | ) 5 | -------------------------------------------------------------------------------- /src/bitwise/bitwise.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_bitwise_h 18 | #define ak_bitwise_h 19 | 20 | #include "../common.h" 21 | #include 22 | 23 | AK_INLINE 24 | uint32_t 25 | ak_bitw_ctz(uint32_t x) { 26 | #if __has_builtin(__builtin_ctz) 27 | return __builtin_ctz(x); 28 | #else 29 | uint32_t i; 30 | 31 | i = 0; 32 | while ((x >>= 1) > 0) 33 | i++; 34 | return i; 35 | #endif 36 | } 37 | 38 | AK_INLINE 39 | uint32_t 40 | ak_bitw_ffs(uint32_t x) { 41 | #if __has_builtin(__builtin_ffs) 42 | return __builtin_ffs(x); 43 | #else 44 | return ak_bitw_ctz(x) + 1; 45 | #endif 46 | } 47 | 48 | AK_INLINE 49 | uint32_t 50 | ak_bitw_clz(uint32_t x) { 51 | #if __has_builtin(__builtin_clz) 52 | return __builtin_clz(x); 53 | #else 54 | return sizeof(uint32_t) * CHAR_BIT - ak_bitw_ffs(x); 55 | #endif 56 | } 57 | 58 | #endif /* ak_bitwise_h */ 59 | -------------------------------------------------------------------------------- /src/camera/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | cam.c 4 | ) 5 | -------------------------------------------------------------------------------- /src/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common.h" 18 | #include 19 | 20 | 21 | AK_HIDE int 22 | ak_enumpair_cmp(const void * a, const void * b) { 23 | return strcmp(((const ak_enumpair *)a)->key, 24 | ((const ak_enumpair *)b)->key); 25 | } 26 | 27 | AK_HIDE int 28 | ak_enumpair_cmp2(const void * a, const void * b) { 29 | return strcmp(a, ((const ak_enumpair *)b)->key); 30 | } 31 | 32 | AK_HIDE int 33 | ak_enumpair_json_val_cmp(const void * a, const void * b) { 34 | const char *s; 35 | 36 | if (!(s = json_string(a))) 37 | return -1; 38 | 39 | return strncmp(s, ((const ak_enumpair *)b)->key, ((json_t *)a)->valsize); 40 | } 41 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c), Recep Aslantas. 3 | * 4 | * MIT License (MIT), http://opensource.org/licenses/MIT 5 | * Full license can be found in the LICENSE file 6 | */ 7 | 8 | #ifndef __libassetio__config__h_ 9 | #define __libassetio__config__h_ 10 | 11 | #if defined(_WIN32) || defined(WIN32) 12 | 13 | // Exclude rarely-used stuff from Windows headers 14 | # define WIN32_LEAN_AND_MEAN 15 | # include 16 | 17 | // Windows Header Files: 18 | # include 19 | 20 | #endif 21 | 22 | #endif /* __libassetio__config__h_ */ -------------------------------------------------------------------------------- /src/coord/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | camera.c 4 | common.h 5 | common.c 6 | doc.c 7 | geom.c 8 | mesh.c 9 | node.c 10 | scene.c 11 | transform.c 12 | transforms.c 13 | vector.c 14 | ) 15 | -------------------------------------------------------------------------------- /src/coord/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #include "../common.h" 19 | #include "common.h" 20 | #include 21 | 22 | void 23 | ak_coordAxisOri(AkCoordSys * __restrict coordSys, 24 | AkAxisOrientation axis, 25 | int ori[3]) { 26 | int axisOri[3]; 27 | int coord[3]; 28 | int i, j; 29 | 30 | ak_coordAxisToiVec3(axis, axisOri); 31 | ak_coordToiVec3(coordSys, coord); 32 | 33 | for (i = 0; i < 3; i++) { 34 | for (j = 0; j < 3; j++) 35 | if (axisOri[i] == coord[j]) 36 | ori[i] = (j + 1) * glm_sign(axisOri[j]); 37 | else if (abs(axisOri[i]) == abs(coord[j])) 38 | ori[i] = -(j + 1) * glm_sign(axisOri[j]); 39 | } 40 | } 41 | 42 | void 43 | ak_coordAxisOriAbs(AkCoordSys * __restrict coordSys, 44 | AkAxisOrientation axis, 45 | int newAxisOri[3]) { 46 | ak_coordAxisOri(coordSys, axis, newAxisOri); 47 | 48 | newAxisOri[0] = abs(newAxisOri[0]) - 1; 49 | newAxisOri[1] = abs(newAxisOri[1]) - 1; 50 | newAxisOri[2] = abs(newAxisOri[2]) - 1; 51 | } 52 | -------------------------------------------------------------------------------- /src/coord/doc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | 19 | AK_EXPORT 20 | void 21 | ak_changeCoordSys(AkDoc * __restrict doc, 22 | AkCoordSys * newCoordSys) { 23 | AkLibrary *libGeom; 24 | AkGeometry *geom; 25 | 26 | libGeom = doc->lib.geometries; 27 | 28 | while (libGeom) { 29 | geom = (void *)libGeom->chld; 30 | 31 | while (geom) { 32 | ak_changeCoordSysGeom(geom, newCoordSys); 33 | geom = (void *)geom->base.next; 34 | } 35 | 36 | libGeom = libGeom->next; 37 | } 38 | 39 | doc->coordSys = newCoordSys; 40 | } 41 | -------------------------------------------------------------------------------- /src/coord/geom.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | 19 | AK_EXPORT 20 | void 21 | ak_changeCoordSysGeom(AkGeometry * __restrict geom, 22 | AkCoordSys * newCoordSys) { 23 | AkObject *primitive; 24 | 25 | primitive = geom->gdata; 26 | switch ((AkGeometryType)primitive->type) { 27 | case AK_GEOMETRY_MESH: 28 | ak_changeCoordSysMesh(ak_objGet(primitive), newCoordSys); 29 | break; 30 | case AK_GEOMETRY_SPLINE: /* TODO: */ 31 | case AK_GEOMETRY_BREP: /* TODO: */ 32 | break; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/coord/scene.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | #include "../../include/ak/coord-util.h" 19 | #include "common.h" 20 | #include 21 | 22 | AK_EXPORT 23 | void 24 | ak_fixSceneCoordSys(struct AkVisualScene * __restrict scene) { 25 | AkHeap *heap; 26 | AkCoordSys *newCoordSys; 27 | AkNode *node; 28 | 29 | heap = ak_heap_getheap(scene); 30 | newCoordSys = (void *)ak_opt_get(AK_OPT_COORD); 31 | node = scene->node; 32 | while (node) { 33 | if (!node->transform) 34 | node->transform = ak_heap_calloc(heap, 35 | node, 36 | sizeof(*node->transform)); 37 | 38 | /* fixup transform[s] */ 39 | ak_coordFindTransform(node->transform, 40 | ak_getCoordSys(node), 41 | newCoordSys); 42 | 43 | node = node->next; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | semantic.h 4 | type.c 5 | type.h 6 | opt.c 7 | opt.h 8 | semantic.c 9 | material.c 10 | material.h 11 | id.c 12 | light.c 13 | light.h 14 | coord.c 15 | cmp.c 16 | cam.h 17 | cam.c 18 | ) 19 | -------------------------------------------------------------------------------- /src/default/cam.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "cam.h" 18 | #include 19 | 20 | AkPerspective ak_def_cam_tcommon = { 21 | .base = { 22 | .type = AK_PROJECTION_PERSPECTIVE, 23 | .tag = 0 24 | }, 25 | .yfov = (float)CGLM_PI_4, 26 | .xfov = (float)CGLM_PI_2, 27 | .aspectRatio = 0.5f, 28 | .znear = 0.01f, 29 | .zfar = 100.0f 30 | }; 31 | 32 | AkOptics ak_def_cam_optics = { 33 | .tcommon = &ak_def_cam_tcommon.base, 34 | .technique = NULL 35 | }; 36 | 37 | const AkCamera ak_def_cam = { 38 | .name = "default", 39 | .optics = &ak_def_cam_optics 40 | }; 41 | 42 | const AkCamera* 43 | ak_def_camera(void) { 44 | return &ak_def_cam; 45 | } 46 | -------------------------------------------------------------------------------- /src/default/cam.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_def_cam_h 18 | #define ak_def_cam_h 19 | 20 | #include "../common.h" 21 | 22 | const AkCamera* 23 | ak_def_camera(void); 24 | 25 | #endif /* ak_def_cam_h */ 26 | -------------------------------------------------------------------------------- /src/default/coord.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | #include "../coord/common.h" 19 | 20 | /* Right Hand (Default) */ 21 | AkCoordSys AK__Y_RH_VAL = {AK__Y_RH, AK_AXIS_ROT_DIR_RH, AK__Y_RH}; 22 | AkCoordSys *AK_YUP = &AK__Y_RH_VAL; 23 | AkCoordSys *AK_ZUP = AK_COORD(AK__Z_RH, AK_AXIS_ROT_DIR_RH, AK__Y_RH); 24 | AkCoordSys *AK_XUP = AK_COORD(AK__X_RH, AK_AXIS_ROT_DIR_RH, AK__Y_RH); 25 | 26 | /* Left Hand */ 27 | AkCoordSys *AK_ZUP_LH = AK_COORD(AK__Z_LH, AK_AXIS_ROT_DIR_LH, AK__Y_LH); 28 | AkCoordSys *AK_YUP_LH = AK_COORD(AK__Y_LH, AK_AXIS_ROT_DIR_LH, AK__Y_LH); 29 | AkCoordSys *AK_XUP_LH = AK_COORD(AK__X_LH, AK_AXIS_ROT_DIR_LH, AK__Y_LH); 30 | 31 | AkCoordSys *AK_DEFAULT_COORD = &AK__Y_RH_VAL; 32 | -------------------------------------------------------------------------------- /src/default/id.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | 19 | const char * AK_DEF_ID_PRFX = "id-"; 20 | -------------------------------------------------------------------------------- /src/default/light.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "light.h" 18 | 19 | AkDirectionalLight akdef_light_tcommon = { 20 | .direction = {0.0f, 0.0f, -1.0f}, 21 | .type = AK_LIGHT_TYPE_DIRECTIONAL, 22 | .color = { {1.0, 1.0, 1.0, 1.0} }, 23 | .ctype = 0 24 | }; 25 | 26 | AkLight akdef_light = { 27 | .name = "default", 28 | .tcommon = &akdef_light_tcommon, 29 | .technique = NULL, 30 | .extra = NULL, 31 | .next = NULL 32 | }; 33 | 34 | const AkLight* 35 | ak_def_light(void) { 36 | return &akdef_light; 37 | } 38 | -------------------------------------------------------------------------------- /src/default/light.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_def_light_h 18 | #define ak_def_light_h 19 | 20 | #include "../common.h" 21 | 22 | const AkLight* 23 | ak_def_light(void); 24 | 25 | #endif /* ak_def_light_h */ 26 | -------------------------------------------------------------------------------- /src/default/material.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "material.h" 18 | #include "../common.h" 19 | 20 | float ak__def_transpval = 1.0f; 21 | AkFloatOrParam ak__def_transparency = { 22 | .val = &ak__def_transpval, 23 | .param = NULL 24 | }; 25 | 26 | AkFloatOrParam* 27 | ak_def_transparency(void) { 28 | return &ak__def_transparency; 29 | } 30 | -------------------------------------------------------------------------------- /src/default/material.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_def_material_h 18 | #define ak_def_material_h 19 | 20 | #include "../common.h" 21 | 22 | AkFloatOrParam* 23 | ak_def_transparency(void); 24 | 25 | #endif /* ak_def_material_h */ 26 | -------------------------------------------------------------------------------- /src/default/opt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_def_opt_h 18 | #define ak_def_opt_h 19 | 20 | #include "../common.h" 21 | 22 | typedef struct AkOptionItem { 23 | AkEnum name; 24 | uintptr_t value; 25 | } AkOptionItem; 26 | 27 | #endif /* ak_def_opt_h */ 28 | -------------------------------------------------------------------------------- /src/default/semantic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_def_semantic_h 18 | #define ak_def_semantic_h 19 | 20 | #include "../common.h" 21 | 22 | typedef struct AkInputSemanticPair { 23 | uint32_t count; 24 | AkTypeDesc *type; 25 | char **params; 26 | } AkInputSemanticPair; 27 | 28 | const AkInputSemanticPair** 29 | ak_def_semantic(void); 30 | 31 | uint32_t 32 | ak_def_semanticc(void); 33 | 34 | #endif /* ak_def_semantic_h */ 35 | -------------------------------------------------------------------------------- /src/default/type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_def_type_h 18 | #define ak_def_type_h 19 | 20 | #include "../common.h" 21 | 22 | const AkTypeDesc* 23 | ak_def_typedesc(void); 24 | 25 | #endif /* ak_def_type_h */ 26 | -------------------------------------------------------------------------------- /src/find.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common.h" 18 | 19 | AK_EXPORT 20 | void * 21 | ak_getId(void * __restrict objptr) { 22 | return ak_mem_getId((void *)objptr); 23 | } 24 | 25 | AK_EXPORT 26 | AkResult 27 | ak_setId(void * __restrict objptr, 28 | const char * __restrict objectId) { 29 | ak_mem_setId(objptr, (void *)objectId); 30 | return AK_OK; 31 | } 32 | 33 | AK_EXPORT 34 | AkResult 35 | ak_moveId(void * __restrict objptrOld, 36 | void * __restrict objptrNew) { 37 | char *objectId; 38 | 39 | objectId = ak_getId(objptrOld); 40 | if (objectId) { 41 | ak_heap_setpm(objectId, 42 | objptrNew); 43 | 44 | ak_setId(objptrOld, NULL); 45 | ak_setId(objptrNew, objectId); 46 | } 47 | return AK_OK; 48 | } 49 | 50 | AK_EXPORT 51 | void * 52 | ak_getObjectById(AkDoc * __restrict doc, 53 | const char * __restrict objectId) { 54 | void *foundObject; 55 | 56 | ak_mem_getMemById(doc, 57 | (void *)objectId, 58 | &foundObject); 59 | 60 | return foundObject; 61 | } 62 | -------------------------------------------------------------------------------- /src/geom/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | mesh.c 4 | ) 5 | -------------------------------------------------------------------------------- /src/geom/mesh.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | 19 | AK_EXPORT 20 | uint32_t 21 | ak_meshInputCount(AkMesh * __restrict mesh) { 22 | AkMeshPrimitive *prim; 23 | uint32_t count; 24 | 25 | count = 0; 26 | prim = mesh->primitive; 27 | while (prim) { 28 | count += prim->inputCount; 29 | prim = prim->next; 30 | } 31 | 32 | return count; 33 | } 34 | -------------------------------------------------------------------------------- /src/id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_id_h 18 | #define ak_id_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | void 24 | ak_id_newheap(AkHeap * __restrict heap); 25 | 26 | AK_HIDE 27 | const char * 28 | ak_id_gen(AkHeap * __restrict heap, 29 | void * __restrict parentmem, 30 | const char * __restrict prefix); 31 | 32 | #endif /* ak_id_h */ 33 | -------------------------------------------------------------------------------- /src/image/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | image.c 4 | ) 5 | -------------------------------------------------------------------------------- /src/instance/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | inst.c 4 | list.c 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/3mf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | 7 | add_subdirectory(imp) 8 | -------------------------------------------------------------------------------- /src/io/3mf/README.md: -------------------------------------------------------------------------------- 1 | # AssetKit: 3mf Status 2 | 3 | - [ ] 3mf XML 4 | -------------------------------------------------------------------------------- /src/io/3mf/imp/3mf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _3mf_h 18 | #define _3mf_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | AkResult 24 | imp_3mf(AkDoc ** __restrict dest, const char * __restrict filepath); 25 | 26 | #endif /* _3mf_h */ 27 | -------------------------------------------------------------------------------- /src/io/3mf/imp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/3mf/imp/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _3mf_common_h 18 | #define _3mf_common_h 19 | 20 | #include "../../../../include/ak/assetkit.h" 21 | #include "../../../../include/ak/url.h" 22 | #include "../../../common.h" 23 | #include "../../../utils.h" 24 | #include "../../../xml.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | typedef AK_ALIGN(16) struct _3MFState { 32 | AkHeap *heap; 33 | void *tempmem; 34 | AkDoc *doc; 35 | bool stop; 36 | } _3MFState; 37 | 38 | #endif /* _3mf_common_h */ 39 | -------------------------------------------------------------------------------- /src/io/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(common) 2 | add_subdirectory(dae) 3 | add_subdirectory(gltf) 4 | add_subdirectory(obj) 5 | add_subdirectory(stl) 6 | add_subdirectory(ply) 7 | add_subdirectory(3mf) 8 | -------------------------------------------------------------------------------- /src/io/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/common/postscript.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ply_postscript_h 18 | #define ply_postscript_h 19 | 20 | #include "../../../include/ak/assetkit.h" 21 | 22 | AK_HIDE 23 | void 24 | io_postscript(AkDoc * __restrict doc); 25 | 26 | #endif /* ply_postscript_h */ 27 | -------------------------------------------------------------------------------- /src/io/dae/1.4/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/dae/1.4/image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_14_image_h 18 | #define ak_14_image_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | dae14_fxMigrateImg(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* ak_14_image_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/1.4/surface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_surface_h 18 | #define ak_surface_h 19 | 20 | #include "../common.h" 21 | #include "dae14.h" 22 | 23 | AK_HIDE 24 | AkDae14Surface* 25 | dae14_surface(DAEState * __restrict dst, 26 | xml_t * __restrict xml, 27 | void * __restrict memp); 28 | 29 | #endif /* ak_surface_h */ 30 | -------------------------------------------------------------------------------- /src/io/dae/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | 7 | add_subdirectory(core) 8 | add_subdirectory(fx) 9 | add_subdirectory(fixup) 10 | add_subdirectory(bugfix) 11 | add_subdirectory(1.4) 12 | add_subdirectory(brep) -------------------------------------------------------------------------------- /src/io/dae/README.md: -------------------------------------------------------------------------------- 1 | # AssetKit: COLLADA Status 2 | 3 | - [x] Single Interface for glTF and COLLADA 4 | - [x] COLLADA 1.4 / 1.4.1 5 | - [x] COLLADA 1.5 6 | - [x] Object-based Asset support 7 | - Resolving Asset support for an element 8 | - [x] Fix / Convert UP axis to any other 9 | - [x] ID resolving 10 | - [x] SID resolving 11 | - [x] Bugfix some DAE files 12 | - [x] Convert angles to Radians 13 | - [x] Convert Multi-Index indices to Single-Index indices by keeping primitive indices 14 | - [x] Options to Generate Mesh Normals 15 | - [x] Option to Triangulate Polygons 16 | - [x] Libraries support 17 | - [x] Geometries 18 | - [x] Meshes (Triangles, Polygons, Lines) 19 | - [x] Brep 20 | - Curves, Nurbs, Solids... 21 | - [x] Nodes 22 | - [x] Instances (instance Geometry, Light, Camera...) 23 | - [x] Simplified Controller mechanism into **node->morpher** and **node->skinner** 24 | - [x] Fix camera node transform 25 | - [x] **bind_material** and bind vertex input support to bind material dynamically 26 | - [x] Scenes 27 | - Active Scene 28 | - Visual Scenes 29 | - [x] Cameras 30 | - [x] Lights 31 | - [x] Materials 32 | - [x] Images 33 | - [x] Samplers 34 | - [x] Textures 35 | - [x] Common Profile 36 | - [x] Phong, Blinn, Lambert and Constant 37 | - ⚠️ Other profiles were supported, but currently they are removed. But multi profile is still supported. We can support other profiles in the future. 38 | - [x] Transparency (A_ONE, RGB_ONE, A_ZERO, RGB_ZERO) 39 | - [x] Skin 40 | - [x] Morph 41 | - [x] Animations 42 | - [x] Extra 43 | - [x] Load external DAE files and cache them 44 | - [ ] Parse MathML formulas 45 | - [ ] Physics 46 | - [ ] Kinematics 47 | - [ ] ZAE 48 | - [ ] More to work on... 49 | 50 | ### Trademarks 51 | 52 | glTF and COLLADA and their logos are trademarks of Khronos Group. 53 | -------------------------------------------------------------------------------- /src/io/dae/brep/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/dae/brep/brep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_brep_h 18 | #define dae_brep_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkObject* 24 | dae_brep(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | AkGeometry * __restrict geom); 27 | 28 | #endif /* dae_brep_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/brep/curve.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_brep_curve_h 18 | #define dae_brep_curve_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkCurve* 24 | dae_curve(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkCurves* 30 | dae_curves(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * __restrict memp); 33 | 34 | #endif /* dae_brep_curve_h */ 35 | -------------------------------------------------------------------------------- /src/io/dae/brep/nurb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_brep_nurbs_h 18 | #define dae_brep_nurbs_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkObject* 24 | dae_nurbs(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkObject* 30 | dae_nurbs_surface(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * __restrict memp); 33 | 34 | #endif /* dae_brep_nurbs_h */ 35 | -------------------------------------------------------------------------------- /src/io/dae/brep/surface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_brep_surface_h 18 | #define dae_brep_surface_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkSurface* 24 | dae_surface(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkSurfaces* 30 | dae_surfaces(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * __restrict memp); 33 | 34 | #endif /* dae_brep_surface_h */ 35 | -------------------------------------------------------------------------------- /src/io/dae/brep/topology.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_brep_topology_h 18 | #define dae_brep_topology_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE AkEdges* 23 | dae_edges(DAEState * __restrict dst, 24 | xml_t * __restrict xml, 25 | void * __restrict memp); 26 | 27 | AK_HIDE AkWires* 28 | dae_wires(DAEState * __restrict dst, 29 | xml_t * __restrict xml, 30 | void * __restrict memp); 31 | 32 | AK_HIDE AkFaces* 33 | dae_faces(DAEState * __restrict dst, 34 | xml_t * __restrict xml, 35 | void * __restrict memp); 36 | 37 | AK_HIDE AkPCurves* 38 | dae_pcurves(DAEState * __restrict dst, 39 | xml_t * __restrict xml, 40 | void * __restrict memp); 41 | 42 | AK_HIDE AkShells* 43 | dae_shells(DAEState * __restrict dst, 44 | xml_t * __restrict xml, 45 | void * __restrict memp); 46 | 47 | AK_HIDE AkSolids* 48 | dae_solids(DAEState * __restrict dst, 49 | xml_t * __restrict xml, 50 | void * __restrict memp); 51 | 52 | #endif /* dae_brep_topology_h */ 53 | -------------------------------------------------------------------------------- /src/io/dae/bugfix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/dae/bugfix/transp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "transp.h" 18 | #include 19 | #include 20 | 21 | AK_HIDE 22 | void 23 | dae_bugfix_transp(AkTransparent * __restrict transp) { 24 | AkContributor *contr; 25 | char *tool; 26 | 27 | if (!(contr = ak_getAssetInfo(transp, offsetof(AkAssetInf, contributor))) 28 | || !(tool = (char *)contr->authoringTool)) 29 | return; 30 | 31 | tool = ak_tolower(strdup(tool)); 32 | 33 | /* fix old SketchUp transparency bug */ 34 | if (strstr(tool, _s_dae_sketchup)) { 35 | int major, minor, patch; 36 | if(sscanf(tool, "%*[^0123456789]%d%*[. ]%d%*[. ]%d", 37 | &major, &minor, &patch)) { 38 | 39 | /* don't flip >= 7.1.1 */ 40 | if (major <= 7 && minor < 2 && patch < 1) { 41 | if (transp->amount->val) { 42 | *transp->amount->val = 1.0f - *transp->amount->val; 43 | } 44 | } 45 | } 46 | } /* _s_dae_sketchup */ 47 | 48 | free(tool); 49 | } 50 | -------------------------------------------------------------------------------- /src/io/dae/bugfix/transp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_bugfix_transp_h 18 | #define dae_bugfix_transp_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | dae_bugfix_transp(AkTransparent * __restrict transp); 25 | 26 | #endif /* dae_bugfix_transp_h */ 27 | -------------------------------------------------------------------------------- /src/io/dae/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/dae/core/anim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_anim_h 18 | #define dae_anim_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_anim(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkAnimSampler* 30 | dae_animSampler(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * __restrict memp); 33 | 34 | AK_HIDE 35 | AkChannel* 36 | dae_channel(DAEState * __restrict dst, 37 | void * __restrict xml, 38 | void * __restrict memp); 39 | 40 | #endif /* dae_anim_h */ 41 | -------------------------------------------------------------------------------- /src/io/dae/core/asset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_asset_h 18 | #define dae_asset_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkAssetInf* 24 | dae_asset(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp, 27 | AkAssetInf * __restrict pinf); 28 | 29 | #endif /* dae_asset_h */ 30 | -------------------------------------------------------------------------------- /src/io/dae/core/cam.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_camera_h 18 | #define dae_camera_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_cam(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_camera_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/core/color.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "color.h" 18 | 19 | AK_HIDE 20 | void 21 | dae_color(xml_t * __restrict xml, 22 | void * memparent, 23 | bool read_sid, 24 | bool stack, 25 | AkColor * dest) { 26 | AkHeap *heap; 27 | void *memp; 28 | unsigned long c; 29 | 30 | heap = ak_heap_getheap(memparent); 31 | memp = stack ? memparent : dest; 32 | 33 | if (read_sid) 34 | sid_set(xml, heap, memp); 35 | 36 | c = xml_strtof_fast(xml->val, dest->vec, 4); 37 | 38 | if (c > 4) 39 | c = 4; 40 | 41 | if (c > 0) { 42 | do { 43 | dest->vec[4 - c--] = 1.0f; 44 | } while (c > 0); 45 | } 46 | 47 | glm_vec4_clamp(dest->vec, 0.0f, 1.0f); 48 | } 49 | -------------------------------------------------------------------------------- /src/io/dae/core/color.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_color_h 18 | #define dae_color_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | dae_color(xml_t * __restrict xml, 25 | void * memparent, 26 | bool read_sid, 27 | bool stack, 28 | AkColor * dest); 29 | 30 | #endif /* dae_color_h */ 31 | -------------------------------------------------------------------------------- /src/io/dae/core/ctlr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "ctlr.h" 18 | #include "skin.h" 19 | #include "morph.h" 20 | #include "../core/asset.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_ctlr(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp) { 27 | AkHeap *heap; 28 | AkController *ctlr; 29 | 30 | heap = dst->heap; 31 | ctlr = ak_heap_calloc(heap, memp, sizeof(*ctlr)); 32 | ctlr->name = xmla_strdup_by(xml, heap, _s_dae_name, ctlr); 33 | 34 | xmla_setid(xml, heap, ctlr); 35 | ak_setypeid(ctlr, AKT_CONTROLLER); 36 | 37 | xml = xml->val; 38 | while (xml) { 39 | if (xml_tag_eq(xml, _s_dae_asset)) { 40 | (void)dae_asset(dst, xml, ctlr, NULL); 41 | } else if (xml_tag_eq(xml, _s_dae_skin)) { 42 | ctlr->data = dae_skin(dst, xml, ctlr); 43 | ctlr->type = AK_CONTROLLER_SKIN; 44 | } else if (xml_tag_eq(xml, _s_dae_morph)) { 45 | ctlr->data = dae_morph(dst, xml, ctlr); 46 | ctlr->type = AK_CONTROLLER_MORPH; 47 | } else if (xml_tag_eq(xml, _s_dae_extra)) { 48 | ctlr->extra = tree_fromxml(heap, ctlr, xml); 49 | } 50 | xml = xml->next; 51 | } 52 | 53 | return ctlr; 54 | } 55 | -------------------------------------------------------------------------------- /src/io/dae/core/ctlr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_controller_h 18 | #define dae_controller_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_ctlr(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_controller_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/core/enum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_enums_h 18 | #define dae_enums_h 19 | 20 | #include "../../../xml.h" 21 | 22 | AK_HIDE AkEnum 23 | dae_semantic(const char * name); 24 | 25 | AK_HIDE AkEnum 26 | dae_morphMethod(const xml_attr_t * __restrict xatt); 27 | 28 | AK_HIDE AkEnum 29 | dae_nodeType(const xml_attr_t * __restrict xatt); 30 | 31 | AK_HIDE AkEnum 32 | dae_animBehavior(const xml_attr_t * __restrict xatt); 33 | 34 | AK_HIDE AkEnum 35 | dae_animInterp(const char * name, size_t len); 36 | 37 | AK_HIDE AkEnum 38 | dae_wrap(const xml_t * __restrict xml); 39 | 40 | AK_HIDE AkEnum 41 | dae_minfilter(const xml_t * __restrict xml); 42 | 43 | AK_HIDE AkEnum 44 | dae_mipfilter(const xml_t * __restrict xml); 45 | 46 | AK_HIDE AkEnum 47 | dae_magfilter(const xml_t * __restrict xml); 48 | 49 | AK_HIDE AkEnum 50 | dae_face(const xml_attr_t * __restrict xatt); 51 | 52 | AK_HIDE AkEnum 53 | dae_opaque(const xml_attr_t * __restrict xatt); 54 | 55 | AK_HIDE AkEnum 56 | dae_enumChannel(const char *name, size_t len); 57 | 58 | AK_HIDE AkEnum 59 | dae_range(const char *name, size_t len); 60 | 61 | AK_HIDE AkEnum 62 | dae_precision(const char *name, size_t len); 63 | 64 | #endif /* dae_enums_h */ 65 | -------------------------------------------------------------------------------- /src/io/dae/core/geom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_geometry_h 18 | #define dae_geometry_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_geom(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_geometry_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/core/light.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_light_h 18 | #define dae_light_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_light(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_light_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/core/line.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_lines_h 18 | #define dae_lines_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkLines* 24 | dae_lines(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp, 27 | AkLineMode mode); 28 | 29 | #endif /* dae_lines_h */ 30 | -------------------------------------------------------------------------------- /src/io/dae/core/mesh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_mesh_h 18 | #define dae_mesh_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkObject* 24 | dae_mesh(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | AkGeometry * __restrict geom); 27 | 28 | #endif /* dae_mesh_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/core/morph.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_morph_h 18 | #define dae_morph_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkMorph* 24 | dae_morph(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_morph_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/core/node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_node_h 18 | #define dae_node_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_node2(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkNode* 30 | dae_node(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * memp, 33 | AkVisualScene * scene); 34 | 35 | #endif /* dae_node_h */ 36 | -------------------------------------------------------------------------------- /src/io/dae/core/param.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "param.h" 18 | #include "value.h" 19 | 20 | AK_HIDE 21 | AkNewParam* 22 | dae_newparam(DAEState * __restrict dst, 23 | xml_t * __restrict xml, 24 | void * __restrict memp) { 25 | AkNewParam *newparam; 26 | 27 | newparam = ak_heap_calloc(dst->heap, memp, sizeof(*newparam)); 28 | ak_setypeid(newparam, AKT_NEWPARAM); 29 | 30 | sid_set(xml, dst->heap, newparam); 31 | 32 | xml = xml->val; 33 | while (xml) { 34 | if (xml_tag_eq(xml, _s_dae_semantic)) { 35 | 36 | } else { 37 | /* load once */ 38 | if (!newparam->val) { 39 | newparam->val = dae_value(dst, xml, newparam); 40 | } 41 | } 42 | xml = xml->next; 43 | } 44 | 45 | return newparam; 46 | } 47 | 48 | AK_HIDE 49 | AkParam* 50 | dae_param(DAEState * __restrict dst, 51 | xml_t * __restrict xml, 52 | void * __restrict memp) { 53 | AkParam *param; 54 | 55 | param = ak_heap_calloc(dst->heap, memp, sizeof(*param)); 56 | ak_setypeid(param, AKT_PARAM); 57 | 58 | param->ref = xmla_strdup_by(xml, dst->heap, _s_dae_ref, param); 59 | 60 | return param; 61 | } 62 | -------------------------------------------------------------------------------- /src/io/dae/core/param.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_param_h 18 | #define dae_param_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkNewParam* 24 | dae_newparam(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkParam* 30 | dae_param(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * __restrict memp); 33 | 34 | #endif /* dae_param_h */ 35 | -------------------------------------------------------------------------------- /src/io/dae/core/poly.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_polygons_h 18 | #define dae_polygons_h 19 | 20 | #include "../common.h" 21 | 22 | typedef enum AkPolygonMode { 23 | AK_POLY_POLYLIST = 1, 24 | AK_POLY_POLYGONS = 2 25 | } AkPolygonMode; 26 | 27 | AK_HIDE 28 | AkPolygon* 29 | dae_poly(DAEState * __restrict dst, 30 | xml_t * __restrict xml, 31 | void * __restrict memp, 32 | AkPolygonMode mode); 33 | 34 | #endif /* dae_polygons_h */ 35 | -------------------------------------------------------------------------------- /src/io/dae/core/scene.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_scene_h 18 | #define dae_scene_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_vscene(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkInstanceBase* 30 | dae_instVisualScene(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * __restrict memp); 33 | 34 | AK_HIDE 35 | void 36 | dae_scene(DAEState * __restrict dst, 37 | xml_t * __restrict xml); 38 | 39 | #endif /* dae_scene_h */ 40 | -------------------------------------------------------------------------------- /src/io/dae/core/skin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_skin_h 18 | #define dae_skin_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkSkin* 24 | dae_skin(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_skin_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/core/source.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_source_h 18 | #define dae_source_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkSource* 24 | dae_source(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | AkEnum (*asEnum)(const char *name, size_t nameLen), 27 | AkTypeId enumType); 28 | 29 | #endif /* dae_source_h */ 30 | -------------------------------------------------------------------------------- /src/io/dae/core/spline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "spline.h" 18 | #include "source.h" 19 | #include "enum.h" 20 | #include "vert.h" 21 | 22 | AK_HIDE 23 | AkObject* 24 | dae_spline(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | AkGeometry * __restrict geom) { 27 | AkHeap *heap; 28 | AkObject *obj; 29 | AkSpline *spline; 30 | AkSource *source; 31 | 32 | heap = dst->heap; 33 | xml = xml->val; 34 | 35 | obj = ak_objAlloc(heap, geom, sizeof(*spline), AK_GEOMETRY_SPLINE, true); 36 | spline = ak_objGet(obj); 37 | 38 | spline->geom = geom; 39 | spline->closed = xmla_u32(xmla(xml, _s_dae_closed), 0); 40 | 41 | while (xml) { 42 | if (xml_tag_eq(xml, _s_dae_source)) { 43 | if ((source = dae_source(dst, xml, NULL, 0))) { 44 | source->next = spline->source; 45 | spline->source = source; 46 | } 47 | } else if (xml_tag_eq(xml, _s_dae_control_vertices)) { 48 | spline->cverts = dae_vert(dst, xml, obj); 49 | } else if (xml_tag_eq(xml, _s_dae_extra)) { 50 | spline->extra = tree_fromxml(heap, obj, xml); 51 | } 52 | 53 | xml = xml->next; 54 | } 55 | 56 | return obj; 57 | } 58 | -------------------------------------------------------------------------------- /src/io/dae/core/spline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_spline_h 18 | #define dae_spline_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkObject* 24 | dae_spline(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | AkGeometry * __restrict geom); 27 | 28 | #endif /* dae_spline_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/core/techn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "techn.h" 18 | #include "../common.h" 19 | 20 | AkTechnique* 21 | dae_techn(xml_t * __restrict xml, 22 | AkHeap * __restrict heap, 23 | void * __restrict memp) { 24 | AkTechnique *techn; 25 | 26 | techn = ak_heap_calloc(heap, memp, sizeof(*techn)); 27 | techn->profile = xmla_strdup_by(xml, heap, _s_dae_profile, techn); 28 | techn->xmlns = xmla_strdup_by(xml, heap, _s_dae_xmlns, techn); 29 | techn->chld = tree_fromxml(heap, techn, xml); 30 | 31 | return techn; 32 | } 33 | -------------------------------------------------------------------------------- /src/io/dae/core/techn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_technique_h 18 | #define dae_technique_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkTechnique* 24 | dae_techn(xml_t * __restrict xml, 25 | AkHeap * __restrict heap, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_technique_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/core/triangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_triangles_h 18 | #define dae_triangles_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkTriangles* 24 | dae_triangles(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp, 27 | AkTriangleMode mode); 28 | 29 | #endif /* dae_triangles_h */ 30 | -------------------------------------------------------------------------------- /src/io/dae/core/value.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_value_h 18 | #define dae_value_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkValue* 24 | dae_value(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | void 30 | dae_dtype(const char *typeName, AkTypeDesc *type); 31 | 32 | #endif /* dae_value_h */ 33 | -------------------------------------------------------------------------------- /src/io/dae/core/vert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_vertices_h 18 | #define dae_vertices_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkVertices* 24 | dae_vert(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_vertices_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/ctlr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common.h" 18 | 19 | AK_EXPORT 20 | AkGeometry* 21 | ak_baseGeometry(AkURL * __restrict baseurl) { 22 | void *found; 23 | AkController *ctlr; 24 | AkSkinDAE *skindae; 25 | AkTypeId foundType; 26 | 27 | if ((found = ak_getObjectByUrl(baseurl))) { 28 | foundType = ak_typeid(found); 29 | switch (foundType) { 30 | case AKT_GEOMETRY: 31 | return found; 32 | case AKT_CONTROLLER: { 33 | ctlr = found; 34 | if (ctlr->type == AK_CONTROLLER_SKIN 35 | && (skindae = ctlr->data)) { 36 | return ak_baseGeometry(&skindae->baseGeom); 37 | } 38 | } 39 | default: break; 40 | } 41 | } 42 | 43 | return NULL; 44 | } 45 | -------------------------------------------------------------------------------- /src/io/dae/dae.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_h 18 | #define dae_h 19 | 20 | #include "../../../include/ak/assetkit.h" 21 | 22 | #include 23 | 24 | AK_HIDE 25 | AkResult 26 | dae_doc(AkDoc ** __restrict dest, 27 | const char * __restrict filepath); 28 | 29 | #endif /* dae_h */ 30 | -------------------------------------------------------------------------------- /src/io/dae/fixup/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/dae/fixup/angle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_fixangle_h 18 | #define dae_fixangle_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | dae_fixAngles(DAEState * __restrict dst); 25 | 26 | AK_HIDE 27 | void 28 | dae_cvtAngles(AkAccessor * __restrict acc, 29 | AkBuffer * __restrict buff, 30 | const char * __restrict paramName); 31 | 32 | #endif /* dae_fixangle_h */ 33 | -------------------------------------------------------------------------------- /src/io/dae/fixup/ctlr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_ctlr_h 18 | #define dae_ctlr_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | dae_fixup_ctlr(DAEState * __restrict dst); 25 | 26 | AK_HIDE 27 | void 28 | dae_fixup_instctlr(DAEState * __restrict dst); 29 | 30 | #endif /* dae_ctlr_h */ 31 | -------------------------------------------------------------------------------- /src/io/dae/fixup/geom.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "geom.h" 18 | #include "mesh.h" 19 | 20 | AK_HIDE 21 | AkResult 22 | dae_geom_fixup_all(AkDoc * doc) { 23 | AkLibrary *geomLib; 24 | AkGeometry *geom; 25 | 26 | geomLib = doc->lib.geometries; 27 | while (geomLib) { 28 | geom = (void *)geomLib->chld; 29 | while (geom) { 30 | dae_geom_fixup(geom); 31 | geom = (AkGeometry *)geom->base.next; 32 | } 33 | 34 | geomLib = geomLib->next; 35 | } 36 | 37 | return AK_OK; 38 | } 39 | 40 | AK_HIDE 41 | AkResult 42 | dae_geom_fixup(AkGeometry * geom) { 43 | AkObject *primitive; 44 | 45 | primitive = geom->gdata; 46 | switch ((AkGeometryType)primitive->type) { 47 | case AK_GEOMETRY_MESH: 48 | dae_mesh_fixup(ak_objGet(primitive)); 49 | default: 50 | break; 51 | } 52 | 53 | return AK_OK; 54 | } 55 | -------------------------------------------------------------------------------- /src/io/dae/fixup/geom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_geom_fixup_h 18 | #define dae_geom_fixup_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkResult 24 | dae_geom_fixup(AkGeometry * geom); 25 | 26 | AK_HIDE 27 | AkResult 28 | dae_geom_fixup_all(AkDoc * doc); 29 | 30 | #endif /* dae_geom_fixup */ 31 | -------------------------------------------------------------------------------- /src/io/dae/fixup/mesh.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "mesh.h" 18 | #include "../../../mesh/index.h" 19 | 20 | AK_HIDE 21 | AkResult 22 | dae_mesh_fixup(AkMesh * mesh) { 23 | AkMeshEditHelper *edith; 24 | AkHeap *heap; 25 | AkDoc *doc; 26 | 27 | heap = ak_heap_getheap(mesh->geom); 28 | doc = ak_heap_data(heap); 29 | 30 | /* first fixup coord system because verts will be duplicated, 31 | reduce extra process */ 32 | if (ak_opt_get(AK_OPT_COORD_CONVERT_TYPE) == AK_COORD_CVT_ALL 33 | && (void *)ak_opt_get(AK_OPT_COORD) != doc->coordSys) 34 | ak_changeCoordSysMesh(mesh, (void *)ak_opt_get(AK_OPT_COORD)); 35 | 36 | if (!mesh->primitive) 37 | return AK_OK; 38 | 39 | ak_meshBeginEdit(mesh); 40 | 41 | edith = mesh->edith; 42 | edith->skipFixIndices = true; /* to do it once per mesh */ 43 | 44 | if (ak_opt_get(AK_OPT_TRIANGULATE)) 45 | ak_meshTriangulate(mesh); 46 | 47 | if (ak_opt_get(AK_OPT_GEN_NORMALS_IF_NEEDED)) 48 | if (ak_meshNeedsNormals(mesh)) 49 | ak_meshGenNormals(mesh); 50 | 51 | edith->skipFixIndices = false; 52 | ak_meshFixIndices(mesh); 53 | 54 | ak_meshEndEdit(mesh); 55 | 56 | if (ak_opt_get(AK_OPT_COMPUTE_BBOX)) 57 | ak_bbox_mesh(mesh); 58 | 59 | return AK_OK; 60 | } 61 | -------------------------------------------------------------------------------- /src/io/dae/fixup/mesh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_mesh_fixup_h 18 | #define dae_mesh_fixup_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkResult 24 | dae_mesh_fixup(AkMesh * mesh); 25 | 26 | #endif /* dae_mesh_fixup_h */ 27 | -------------------------------------------------------------------------------- /src/io/dae/fixup/node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_node_fixup_h 18 | #define dae_node_fixup_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | dae_nodeFixupFixedCoord(AkHeap * __restrict heap, 25 | AkNode * __restrict node); 26 | 27 | AK_HIDE 28 | void 29 | dae_nodeFixup(AkHeap * __restrict heap, 30 | AkNode* __restrict node); 31 | 32 | #endif /* dae_node_fixup_h */ 33 | -------------------------------------------------------------------------------- /src/io/dae/fixup/tex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_tex_fixup_h 18 | #define dae_tex_fixup_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | dae_fix_textures(DAEState * __restrict dst); 25 | 26 | #endif /* dae_tex_fixup_h */ 27 | -------------------------------------------------------------------------------- /src/io/dae/fx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/dae/fx/colortex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_colortex_h 18 | #define dae_colortex_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE AkColorDesc* 23 | dae_colorOrTex(DAEState * __restrict dst, 24 | xml_t * __restrict xml, 25 | void * __restrict memp); 26 | 27 | #endif /* dae_colortex_h */ 28 | -------------------------------------------------------------------------------- /src/io/dae/fx/effect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_fx_effect_h 18 | #define dae_fx_effect_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_effect(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkInstanceEffect* 30 | dae_instEffect(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * __restrict memp); 33 | 34 | #endif /* dae_fx_effect_h */ 35 | -------------------------------------------------------------------------------- /src/io/dae/fx/fltprm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "fltprm.h" 18 | #include "../core/param.h" 19 | 20 | AK_HIDE AkFloatOrParam* 21 | dae_floatOrParam(DAEState * __restrict dst, 22 | xml_t * __restrict xml, 23 | void * __restrict memp) { 24 | AkHeap *heap; 25 | AkFloatOrParam *flt; 26 | const xml_t *sval; 27 | 28 | heap = dst->heap; 29 | flt = ak_heap_calloc(heap, memp, sizeof(*flt)); 30 | 31 | xml = xml->val; 32 | while (xml) { 33 | if (xml_tag_eq(xml, _s_dae_float) && (sval = xmls(xml))) { 34 | float *valuef; 35 | 36 | valuef = ak_heap_calloc(heap, flt, sizeof(*valuef)); 37 | xml_strtof_fast(sval, valuef, 1); 38 | 39 | sid_set(xml, heap, valuef); 40 | 41 | flt->val = valuef; 42 | } else if (xml_tag_eq(xml, _s_dae_param)) { 43 | AkParam *param; 44 | 45 | if ((param = dae_param(dst, xml, flt))) { 46 | if (flt->param) 47 | flt->param->prev = param; 48 | 49 | param->next = flt->param; 50 | flt->param = param; 51 | } 52 | } 53 | xml = xml->next; 54 | } 55 | 56 | return flt; 57 | } 58 | -------------------------------------------------------------------------------- /src/io/dae/fx/fltprm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_fltprm_h 18 | #define dae_fltprm_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE AkFloatOrParam* 23 | dae_floatOrParam(DAEState * __restrict dst, 24 | xml_t * __restrict xml, 25 | void * __restrict memp); 26 | 27 | #endif /* dae_fltprm_h */ 28 | -------------------------------------------------------------------------------- /src/io/dae/fx/img.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_fx_img_h 18 | #define dae_fx_img_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_image(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkInstanceBase* 30 | dae_instImage(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * __restrict memp); 33 | 34 | #endif /* dae_fx_img_h */ 35 | -------------------------------------------------------------------------------- /src/io/dae/fx/mat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_fx_material_h 18 | #define dae_fx_material_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void* 24 | dae_material(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | AK_HIDE 29 | AkBindMaterial* 30 | dae_bindMaterial(DAEState * __restrict dst, 31 | xml_t * __restrict xml, 32 | void * __restrict memp); 33 | 34 | AK_HIDE 35 | AkInstanceMaterial* 36 | dae_instMaterial(DAEState * __restrict dst, 37 | xml_t * __restrict xml, 38 | void * __restrict memp); 39 | 40 | #endif /* dae_fx_material_h */ 41 | -------------------------------------------------------------------------------- /src/io/dae/fx/profile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_fx_profile_h 18 | #define dae_fx_profile_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkProfile* 24 | dae_profile(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_fx_profile_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/fx/samp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_fx_sampler_h 18 | #define dae_fx_sampler_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkSampler* 24 | dae_sampler(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_fx_sampler_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/fx/techn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_technique_fx_h 18 | #define dae_technique_fx_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkTechniqueFx* 24 | dae_techniqueFx(DAEState * __restrict dst, 25 | xml_t * __restrict xml, 26 | void * __restrict memp); 27 | 28 | #endif /* dae_technique_fx_h */ 29 | -------------------------------------------------------------------------------- /src/io/dae/postscript.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef dae_postscript_h 18 | #define dae_postscript_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | void 24 | dae_postscript(DAEState * __restrict dst); 25 | 26 | #endif /* dae_postscript_h */ 27 | -------------------------------------------------------------------------------- /src/io/gltf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | 7 | add_subdirectory(imp) -------------------------------------------------------------------------------- /src/io/gltf/README.md: -------------------------------------------------------------------------------- 1 | # AssetKit: glTF Status 2 | 3 | - [x] Single Interface for glTF and COLLADA 4 | - [x] glTF 2.0 5 | - [x] Options to Generate Mesh Normals 6 | - [x] Acessors, Buffers / BufferViews 7 | - [x] Geometries (Triangles, Polygons, Lines) 8 | - [x] Nodes 9 | - [x] Scenes 10 | - [x] Cameras 11 | - [x] Materials 12 | - [x] Images 13 | - [x] Samplers 14 | - [x] Textures 15 | - [x] PBR Materials 16 | - [x] Metallic Roughness 17 | - [x] Specular Glossiness Extension 18 | - [x] Other textures 19 | - [x] Occlusion map 20 | - [x] Emissive map 21 | - [x] Normal Map 22 | - [ ] other textures? 23 | - [x] alphaMode 24 | - [x] alphaCutoff 25 | - [x] doubleSided 26 | - [x] Skin 27 | - [x] Morph 28 | - [x] Animations 29 | - Extensions 30 | - [x] KHR_materials_pbrSpecularGlossiness 31 | - [ ] Lights (TODO) 32 | - [ ] Common materials (TODO) 33 | - [x] glTF-Separate 34 | - [x] glTF-Binary 35 | - [x] glTF-Embedded 36 | - [ ] Load glTF-Draco (TODO) 37 | 38 | ### Trademarks 39 | 40 | glTF and COLLADA and their logos are trademarks of Khronos Group. 41 | -------------------------------------------------------------------------------- /src/io/gltf/imp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | 7 | add_subdirectory(core) -------------------------------------------------------------------------------- /src/io/gltf/imp/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_commoh_h 18 | #define gltf_imp_commoh_h 19 | 20 | #include "../common.h" 21 | 22 | #endif /* gltf_imp_commoh_h */ 23 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/accessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_accesor_h 18 | #define gltf_imp_core_accesor_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_accessors(json_t * __restrict jbuffView, 25 | void * __restrict userdata); 26 | 27 | #endif /* gltf_imp_core_accesor_h */ 28 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/anim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_anim_h 18 | #define gltf_imp_core_anim_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_animations(json_t * __restrict janim, 25 | void * __restrict userdata); 26 | 27 | #endif /* gltf_imp_core_anim_h */ 28 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/asset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_asset_h 18 | #define gltf_imp_core_asset_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_asset(json_t * __restrict json, 25 | void * __restrict userdata); 26 | 27 | #endif /* gltf_imp_core_asset_h */ 28 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_buffer_h 18 | #define gltf_imp_core_buffer_h 19 | 20 | #include "../common.h" 21 | 22 | void 23 | gltf_buffers(json_t * __restrict json, 24 | void * __restrict userdata); 25 | 26 | void 27 | gltf_bufferViews(json_t * __restrict json, 28 | void * __restrict userdata); 29 | 30 | #endif /* gltf_imp_core_buffer_h */ 31 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/camera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_camera_h 18 | #define gltf_imp_core_camera_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_cameras(json_t * __restrict jcam, 25 | void * __restrict userdata); 26 | 27 | #endif /* gltf_imp_core_camera_h */ 28 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/enum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_enums_h 18 | #define gltf_imp_core_enums_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE AkEnum 23 | gltf_enumInputSemantic(const char *name); 24 | 25 | AK_HIDE AkEnum 26 | gltf_componentType(int type); 27 | 28 | AK_HIDE int 29 | gltf_componentLen(int type) ; 30 | 31 | AK_HIDE AkComponentSize 32 | gltf_type(const json_t * __restrict json); 33 | 34 | AK_HIDE AkEnum 35 | gltf_minFilter(int type); 36 | 37 | AK_HIDE AkEnum 38 | gltf_magFilter(int type); 39 | 40 | AK_HIDE AkEnum 41 | gltf_wrapMode(int type); 42 | 43 | AK_HIDE AkOpaque 44 | gltf_alphaMode(const json_t * __restrict json); 45 | 46 | AK_HIDE AkInterpolationType 47 | gltf_interp(const json_t * __restrict json); 48 | 49 | #endif /* gltf_imp_core_enums_h */ 50 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_image_h 18 | #define gltf_imp_core_image_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_images(json_t * __restrict jimage, 25 | void * __restrict userdata); 26 | 27 | #endif /* gltf_imp_core_image_h */ 28 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/material.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_material_h 18 | #define gltf_imp_core_material_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_materials(json_t * __restrict json, 25 | void * __restrict userdata); 26 | 27 | #endif /* gltf_imp_core_material_h */ 28 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/mesh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_mesh_h 18 | #define gltf_imp_core_mesh_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_meshes(json_t * __restrict json, 25 | void * __restrict userdata); 26 | 27 | AK_HIDE 28 | AkMeshPrimitive* 29 | gltf_allocPrim(AkHeap * __restrict heap, 30 | void * __restrict memParent, 31 | int mode); 32 | 33 | #endif /* gltf_imp_core_mesh_h */ 34 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_node_h 18 | #define gltf_imp_core_node_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_nodes(json_t * __restrict jnode, 25 | void * __restrict userdata); 26 | 27 | AK_HIDE 28 | AkNode* 29 | gltf_node(AkGLTFState * __restrict gst, 30 | void * __restrict memParent, 31 | json_t * __restrict jnode, 32 | AkNode ** __restrict nodechld); 33 | 34 | AK_HIDE 35 | void 36 | gltf_bindMaterials(AkGLTFState * __restrict gst, 37 | AkInstanceGeometry * __restrict instGeom, 38 | int32_t meshIndex); 39 | 40 | #endif /* gltf_imp_core_node_h */ 41 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/profile.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "profile.h" 18 | 19 | AK_HIDE 20 | AkProfileCommon* 21 | gltf_cmnEffect(AkGLTFState * __restrict gst) { 22 | AkLibrary *lib; 23 | AkEffect *effect; 24 | AkProfileCommon *profile; 25 | 26 | if (!(lib = gst->doc->lib.effects)) { 27 | lib = ak_heap_calloc(gst->heap, gst->doc, sizeof(*lib)); 28 | gst->doc->lib.effects = lib; 29 | } 30 | 31 | effect = ak_heap_calloc(gst->heap, lib, sizeof(*effect)); 32 | profile = ak_heap_calloc(gst->heap, effect, sizeof(*profile)); 33 | profile->type = AK_PROFILE_TYPE_COMMON; 34 | 35 | lib->count++; 36 | 37 | effect->profile = profile; 38 | effect->next = (void *)lib->chld; 39 | lib->chld = (void *)effect; 40 | 41 | ak_setypeid(profile, AKT_PROFILE); 42 | ak_setypeid(effect, AKT_EFFECT); 43 | 44 | return effect->profile; 45 | } 46 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/profile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_profile_h 18 | #define gltf_imp_core_profile_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkProfileCommon* 24 | gltf_cmnEffect(AkGLTFState * __restrict gst); 25 | 26 | #endif /* gltf_imp_core_profile_h */ 27 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/sampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_sampler_h 18 | #define gltf_imp_core_sampler_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_samplers(json_t * __restrict jsampler, 25 | void * __restrict userdata); 26 | 27 | #endif /* gltf_imp_core_sampler_h */ 28 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/scene.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_scene_h 18 | #define gltf_imp_core_scene_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_scenes(json_t * __restrict jscene, 25 | void * __restrict userdata); 26 | 27 | AK_HIDE 28 | void 29 | gltf_scene(json_t * __restrict jscene, 30 | void * __restrict userdata); 31 | 32 | #endif /* gltf_imp_core_scene_h */ 33 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/skin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_skin_h 18 | #define gltf_imp_core_skin_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_skin(json_t * __restrict jskin, 25 | void * __restrict userdata); 26 | 27 | #endif /* gltf_imp_core_skin_h */ 28 | -------------------------------------------------------------------------------- /src/io/gltf/imp/core/texture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_core_texture_h 18 | #define gltf_imp_core_texture_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkTextureRef* 24 | gltf_texref(AkGLTFState * __restrict gst, 25 | void * __restrict parent, 26 | json_t * __restrict jtexinfo); 27 | 28 | AK_HIDE 29 | void 30 | gltf_textures(json_t * __restrict jtex, 31 | void * __restrict userdata); 32 | 33 | #endif /* gltf_imp_core_texture_h */ 34 | -------------------------------------------------------------------------------- /src/io/gltf/imp/gltf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_h 18 | #define gltf_imp_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | AkResult 24 | gltf_gltf(AkDoc ** __restrict dest, 25 | const char * __restrict filepath); 26 | 27 | AK_HIDE 28 | AkResult 29 | gltf_glb(AkDoc ** __restrict dest, 30 | const char * __restrict filepath); 31 | 32 | #endif /* gltf_imp_h */ 33 | -------------------------------------------------------------------------------- /src/io/gltf/imp/mesh_fixup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_mesh_fixup_h 18 | #define gltf_imp_mesh_fixup_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_mesh_fixup(AkGLTFState * __restrict gst); 25 | 26 | #endif /* gltf_imp_mesh_fixup_h */ 27 | -------------------------------------------------------------------------------- /src/io/gltf/imp/postscript.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "postscript.h" 18 | #include "mesh_fixup.h" 19 | 20 | AK_HIDE 21 | void 22 | gltf_setskinners(RBTree *tree, RBNode *rbnode); 23 | 24 | AK_HIDE 25 | void 26 | gltf_postscript(AkGLTFState * __restrict gst) { 27 | gltf_mesh_fixup(gst); 28 | rb_walk(gst->skinBound, gltf_setskinners); 29 | } 30 | 31 | AK_HIDE 32 | void 33 | gltf_setskinners(RBTree *tree, RBNode *rbnode) { 34 | char skinid[16]; 35 | AkGLTFState *gst; 36 | AkInstanceSkin *skinner; 37 | AkNode *node; 38 | AkInstanceGeometry *instGeom; 39 | int32_t i32val; 40 | 41 | gst = tree->userData; 42 | node = rbnode->key; 43 | instGeom = node->geometry; 44 | i32val = (int32_t)(intptr_t)rbnode->val; 45 | 46 | sprintf(skinid, "%s%d", _s_gltf_skin, i32val); 47 | 48 | skinner = ak_heap_calloc(gst->heap, node, sizeof(*skinner)); 49 | skinner->skin = ak_getObjectById(gst->doc, skinid); 50 | instGeom->skinner = skinner; 51 | } 52 | -------------------------------------------------------------------------------- /src/io/gltf/imp/postscript.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef gltf_imp_postscript_h 18 | #define gltf_imp_postscript_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | void 24 | gltf_postscript(AkGLTFState * __restrict gst); 25 | 26 | #endif /* gltf_imp_postscript_h */ 27 | -------------------------------------------------------------------------------- /src/io/obj/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/obj/README.md: -------------------------------------------------------------------------------- 1 | # AssetKit: Wavefront Object Status 2 | 3 | - [x] v - Positions 4 | - [x] vt - Texture Coords 5 | - [x] vn - Normals 6 | - [x] f - Faces/Indices 7 | - [ ] Materials 8 | - [x] d - Dissolve 9 | - [x] Tr - Transparent (1 - d) 10 | - [x] Ka - Ambient 11 | - [x] Kd - Diffuse 12 | - [x] Ks - Specular 13 | - [x] Ke - Emission 14 | - [x] map_Ka - Ambient Texture 15 | - [x] map_Kd - Diffuse Texture 16 | - [x] map_Ks - Specular Texture 17 | - [x] map_Ke - Emission Texture 18 | - [x] Ns - Shininess/specular exponent 19 | - [x] Ni - Index of refraction 20 | - [x] bump - Bump/Normal map 21 | - [x] illum: Constant 22 | - [x] illum: Lambert 23 | - [x] illum: Blinn 24 | - [ ] illum: Others 25 | - [x] Convert Multi Indices to Single Index Buffer 26 | - [x] Group/Separate mesh primitives by usemtl 27 | - [ ] ... 28 | 29 | -------------------------------------------------------------------------------- /src/io/obj/group.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef wobj_group_h 18 | #define wobj_group_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | WOPrim* 24 | wobj_switchPrim(WOState * __restrict wst, const char * __restrict mtlname); 25 | 26 | AK_HIDE 27 | void 28 | wobj_finishObject(WOState * __restrict wst, WOObject * __restrict obj); 29 | 30 | AK_HIDE 31 | void 32 | wobj_finishObjects(WOState * __restrict wst); 33 | 34 | AK_HIDE 35 | void 36 | wobj_switchObject(WOState * __restrict wst); 37 | 38 | #endif /* wobj_group_h */ 39 | -------------------------------------------------------------------------------- /src/io/obj/mtl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef wobj_mtl_h 18 | #define wobj_mtl_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | WOMtlLib* 24 | wobj_mtl(WOState * __restrict wst, 25 | const char * __restrict name); 26 | 27 | #endif /* wobj_mtl_h */ 28 | -------------------------------------------------------------------------------- /src/io/obj/obj.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef wobj_h 18 | #define wobj_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | AkResult 24 | wobj_obj(AkDoc ** __restrict dest, 25 | const char * __restrict filepath); 26 | 27 | #endif /* wobj_h */ 28 | -------------------------------------------------------------------------------- /src/io/obj/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef wobj_util_h 18 | #define wobj_util_h 19 | 20 | #include "common.h" 21 | #include "../common/util.h" 22 | 23 | AK_HIDE 24 | AkAccessor* 25 | wobj_acc(WOState * __restrict wst, 26 | AkDataContext * __restrict dctx, 27 | AkComponentSize compSize, 28 | AkTypeId type); 29 | 30 | AK_HIDE 31 | AkInput* 32 | wobj_input(WOState * __restrict wst, 33 | AkMeshPrimitive * __restrict prim, 34 | AkAccessor * __restrict acc, 35 | AkInputSemantic sem, 36 | const char * __restrict semRaw, 37 | uint32_t offset); 38 | 39 | AK_HIDE 40 | void 41 | wobj_joinIndices(WOState * __restrict wst, 42 | WOPrim * __restrict wp, 43 | AkMeshPrimitive * __restrict prim); 44 | 45 | #endif /* wobj_util_h */ 46 | -------------------------------------------------------------------------------- /src/io/ply/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/ply/README.md: -------------------------------------------------------------------------------- 1 | # AssetKit: Polygon File Format (ply) Status 2 | 3 | - [x] ASCII 4 | - [x] Binary 5 | - [x] X, Y, Z 6 | - [x] NX, NY, NZ 7 | - [x] S, T, U, V 8 | - [x] R, G, B 9 | - [x] Stop loading is one of X, Y, Z property is missing 10 | - [x] Ignore tuple if one of them is not exist e.g. ignore normals if NY is missing 11 | -------------------------------------------------------------------------------- /src/io/ply/ply.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ply_h 18 | #define ply_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | AkResult 24 | ply_ply(AkDoc ** __restrict dest, const char * __restrict filepath); 25 | 26 | AK_HIDE 27 | void 28 | ply_ascii(char * __restrict src, PLYState * __restrict pst); 29 | 30 | AK_HIDE 31 | void 32 | ply_bin(char * __restrict src, PLYState * __restrict pst, bool le); 33 | 34 | AK_HIDE 35 | void 36 | ply_finish(PLYState * __restrict pst); 37 | 38 | #endif /* stl_h */ 39 | -------------------------------------------------------------------------------- /src/io/stl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/io/stl/README.md: -------------------------------------------------------------------------------- 1 | # AssetKit: Standard Tesselated Geometry File Format (stl) Status 2 | 3 | - [x] ASCII 4 | - [x] Binary 5 | -------------------------------------------------------------------------------- /src/io/stl/stl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef stl_h 18 | #define stl_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | AkResult 24 | stl_stl(AkDoc ** __restrict dest, 25 | const char * __restrict filepath); 26 | 27 | AK_HIDE 28 | void 29 | sst_finish(STLState * __restrict sst); 30 | 31 | AK_HIDE 32 | void 33 | stl_ascii(STLState * __restrict sst, char * __restrict p); 34 | 35 | AK_HIDE 36 | void 37 | stl_binary(STLState * __restrict sst, char * __restrict p); 38 | 39 | #endif /* stl_h */ 40 | -------------------------------------------------------------------------------- /src/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | geom.c 4 | lib.c 5 | ) 6 | -------------------------------------------------------------------------------- /src/lib/geom.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | 19 | AK_EXPORT 20 | AkGeometry * 21 | ak_libFirstGeom(AkDoc * __restrict doc) { 22 | if (!doc->lib.geometries) 23 | return NULL; 24 | 25 | return (void *)doc->lib.geometries->chld; 26 | } 27 | -------------------------------------------------------------------------------- /src/light/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(${PROJECT_NAME} 2 | PRIVATE 3 | light.c 4 | ) 5 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common.h" 18 | #include "mem/rb.h" 19 | #include "mem/lt.h" 20 | #include "trash.h" 21 | #include "sid.h" 22 | #include "profile.h" 23 | #include "type.h" 24 | #include "resc/resource.h" 25 | 26 | void 27 | AK_CONSTRUCTOR 28 | ak__init(void); 29 | 30 | void 31 | AK_DESTRUCTOR 32 | ak__cleanup(void); 33 | 34 | void 35 | AK_CONSTRUCTOR 36 | ak__init(void) { 37 | ak_mem_init(); 38 | ak_trash_init(); 39 | ak_resc_init(); 40 | ak_type_init(); 41 | ak_sid_init(); 42 | ak_profile_init(); 43 | } 44 | 45 | void 46 | AK_DESTRUCTOR 47 | ak__cleanup(void) { 48 | ak_profile_deinit(); 49 | ak_sid_deinit(); 50 | ak_type_deinit(); 51 | ak_resc_deinit(); 52 | ak_trash_deinit(); 53 | ak_mem_deinit(); 54 | } 55 | -------------------------------------------------------------------------------- /src/mem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/mem/intr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common.h" 18 | 19 | AK_HIDE 20 | void 21 | ak_dsSetAllocator(AkHeapAllocator * __restrict alc, 22 | DsAllocator * __restrict dsalc) { 23 | dsalc->calloc = alc->calloc; 24 | dsalc->free = alc->free; 25 | dsalc->malloc = alc->malloc; 26 | dsalc->memalign = alc->memalign; 27 | dsalc->realloc = alc->realloc; 28 | dsalc->size = alc->size; 29 | dsalc->strdup = alc->strdup; 30 | } 31 | -------------------------------------------------------------------------------- /src/mem/lt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_hashtable_h 18 | #define ak_hashtable_h 19 | 20 | #include "common.h" 21 | 22 | #define AK__LT_BUCKET_IS_FULL(X) (X->count == ak__heap_lt.bucketSize) 23 | 24 | typedef struct AkHeapBucketEntry { 25 | AkHeap *heap; 26 | uint32_t heapid; 27 | } AkHeapBucketEntry; 28 | 29 | typedef struct AkHeapBucket { 30 | struct AkHeapBucket *next; 31 | AkHeapBucketEntry *heapEntry; 32 | uint32_t bucketIndex; 33 | uint32_t count; 34 | uint32_t firstAvailEntry; 35 | } AkHeapBucket; 36 | 37 | typedef struct AkHeapLookupTable { 38 | AkHeapBucket *rootBucket; 39 | AkHeapBucket *lastBucket; 40 | AkHeapBucket *firstAvailBucket; 41 | AkHeapBucketEntry *lastUsedEntry; /* cache last */ 42 | size_t size; 43 | uint32_t bucketSize; /* default = 4 */ 44 | } AkHeapLookupTable; 45 | 46 | void 47 | ak_heap_lt_init(AkHeap * __restrict initialHeap); 48 | 49 | AkHeap * 50 | ak_heap_lt_find(uint32_t heapid); 51 | 52 | void 53 | ak_heap_lt_remove(uint32_t heapid); 54 | 55 | void 56 | ak_heap_lt_insert(AkHeap * __restrict heap); 57 | 58 | void 59 | ak_heap_lt_cleanup(void); 60 | 61 | #endif /* ak_hashtable_h */ 62 | -------------------------------------------------------------------------------- /src/mem/rb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_memory_redblack_h 18 | #define ak_memory_redblack_h 19 | 20 | #include "common.h" 21 | 22 | #define AK__RB_ISBLACK(X) !((AK__HEAPNODE(X)->flags & AK_HEAP_NODE_FLAGS_RED)) 23 | #define AK__RB_ISRED(X) (AK__HEAPNODE(X)->flags & AK_HEAP_NODE_FLAGS_RED) 24 | #define AK__RB_MKRED(X) AK__HEAPNODE(X)->flags |= AK_HEAP_NODE_FLAGS_RED 25 | #define AK__RB_MKBLACK(X) AK__HEAPNODE(X)->flags &= ~AK_HEAP_NODE_FLAGS_RED 26 | 27 | void 28 | ak_heap_rb_insert(AkHeapSrchCtx * __restrict srchctx, 29 | AkHeapSrchNode * __restrict srchNode); 30 | 31 | void 32 | ak_heap_rb_remove(AkHeapSrchCtx * __restrict srchctx, 33 | AkHeapSrchNode * __restrict srchNode); 34 | 35 | AkHeapSrchNode * 36 | ak_heap_rb_find(AkHeapSrchCtx * __restrict srchctx, 37 | void * __restrict key); 38 | 39 | int 40 | ak_heap_rb_parent(AkHeapSrchCtx * __restrict srchctx, 41 | void * __restrict key, 42 | AkHeapSrchNode ** dest); 43 | 44 | void 45 | ak_heap_rb_print(AkHeapSrchCtx * __restrict srchctx); 46 | 47 | int 48 | ak_heap_rb_assert(AkHeapSrchCtx * srchctx, 49 | AkHeapSrchNode * root); 50 | 51 | #endif /* ak_memory_redblack_h */ 52 | -------------------------------------------------------------------------------- /src/mesh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/mesh/edit_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_mesh_edit_common_h 18 | #define ak_mesh_edit_common_h 19 | 20 | #include "../common.h" 21 | 22 | typedef struct AkPrimProxy { 23 | struct AkPrimProxy *next; 24 | AkMeshPrimitive *orig; 25 | uint8_t *flg; 26 | AkUIntArray *ind; 27 | AkUIntArray *newind; 28 | AkInput *input; 29 | uint32_t *inpi; 30 | uint32_t chk_start; 31 | uint32_t chk_end; 32 | uint32_t vo; /* vertOffset */ 33 | uint32_t st; 34 | uint32_t count; 35 | uint32_t icount; 36 | uint32_t ccount; /* checked count */ 37 | } AkPrimProxy; 38 | 39 | typedef struct AkInputDesc { 40 | struct AkInputDesc *next; 41 | const char *semantic; 42 | AkURL *source; 43 | AkInput *input; 44 | AkPrimProxy *pp; 45 | uint32_t set; 46 | int32_t index; 47 | } AkInputDesc; 48 | 49 | void 50 | ak_meshFreeRsvBuff(RBTree *tree, RBNode *node); 51 | 52 | #endif /* ak_meh_edit_common_h */ 53 | -------------------------------------------------------------------------------- /src/mesh/index.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_mesh_index_h 18 | #define ak_mesh_index_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | AkResult 24 | ak_meshFixIndices(AkMesh *mesh); 25 | 26 | AK_HIDE 27 | AkResult 28 | ak_primFixIndices(AkMesh *mesh, 29 | AkMeshPrimitive *prim); 30 | 31 | AK_HIDE 32 | AkResult 33 | ak_meshFixIndicesDefault(AkMesh *mesh); 34 | 35 | AK_HIDE 36 | AkResult 37 | ak_movePositions(AkMesh *mesh, 38 | AkMeshPrimitive *prim, 39 | AkDuplicator *duplicator); 40 | 41 | #endif /* ak_mesh_index_h */ 42 | -------------------------------------------------------------------------------- /src/mesh/material.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | #include 19 | 20 | AK_EXPORT 21 | AkResult 22 | ak_meshSetMaterial(AkMeshPrimitive *prim, 23 | const char *material) { 24 | AkGeometry *geom; 25 | AkMap *map; 26 | 27 | geom = prim->mesh->geom; 28 | 29 | #ifdef DEBUG 30 | assert(geom && "set geometry for this primitive!"); 31 | assert(geom->materialMap && "set materialMap for this geom!"); 32 | #endif 33 | 34 | map = geom->materialMap; 35 | 36 | /* TODO: remove first */ 37 | ak_multimap_add(map, prim, (void *)material); 38 | 39 | prim->bindmaterial = material; 40 | return AK_OK; 41 | } 42 | -------------------------------------------------------------------------------- /src/miniz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/miniz/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013-2014 RAD Game Tools and Valve Software 2 | Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC 3 | 4 | All Rights Reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/morph/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/node/node.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | #include "../../include/ak/assetkit.h" 19 | #include "../../include/ak/node.h" 20 | #include "../../include/ak/coord-util.h" 21 | #include 22 | 23 | AK_EXPORT 24 | void 25 | ak_addSubNode(AkNode * __restrict parent, 26 | AkNode * __restrict subnode, 27 | bool fixCoordSys) { 28 | assert(parent != subnode); 29 | 30 | if (subnode->parent) { 31 | if (subnode->parent->chld == subnode) { 32 | if (subnode->next) 33 | subnode->parent->chld = subnode->next; 34 | else 35 | subnode->parent->chld = subnode->prev; 36 | } 37 | } 38 | 39 | if (subnode->next) 40 | subnode->next->prev = subnode->prev; 41 | 42 | if (subnode->prev) 43 | subnode->prev->next = subnode->next; 44 | 45 | if (parent->chld) 46 | parent->chld->prev = subnode; 47 | 48 | subnode->next = parent->chld; 49 | subnode->prev = NULL; 50 | subnode->parent = parent; 51 | parent->chld = subnode; 52 | 53 | /* fix node transforms after attached to new node */ 54 | if (fixCoordSys) 55 | ak_fixNodeCoordSys(subnode); 56 | } 57 | -------------------------------------------------------------------------------- /src/profile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_src_profile_h 18 | #define ak_src_profile_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | void 24 | ak_profile_init(void); 25 | 26 | AK_HIDE 27 | void 28 | ak_profile_deinit(void); 29 | 30 | #endif /* ak_src_profile_h */ 31 | -------------------------------------------------------------------------------- /src/resc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/resc/resource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_resource_h 18 | #define ak_resource_h 19 | 20 | #include "../common.h" 21 | #include 22 | 23 | typedef struct AkResource { 24 | AkDoc *doc; 25 | const char *url; 26 | const char *localurl; 27 | int64_t refc; 28 | time_t dwntime; 29 | bool isdwn; 30 | bool islocal; 31 | AkResult result; 32 | } AkResource; 33 | 34 | AK_HIDE 35 | void 36 | ak_resc_init(void); 37 | 38 | AK_HIDE 39 | void 40 | ak_resc_deinit(void); 41 | 42 | AkResource * 43 | ak_resc_ins(const char *url); 44 | 45 | void 46 | ak_resc_ref(AkResource *resc); 47 | 48 | int 49 | ak_resc_unref(AkResource *resc); 50 | 51 | int 52 | ak_resc_unref_url(const char *url); 53 | 54 | void 55 | ak_resc_print(void); 56 | 57 | #endif /* ak_resource_h */ 58 | -------------------------------------------------------------------------------- /src/skin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/skin/fix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_src_skin_index_h 18 | #define ak_src_skin_index_h 19 | 20 | #include "../common.h" 21 | 22 | AK_HIDE 23 | void 24 | ak_skinFixWeights(AkMesh * __restrict mesh); 25 | 26 | #endif /* ak_src_skin_index_h */ 27 | -------------------------------------------------------------------------------- /src/skin/skin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | 19 | AK_EXPORT 20 | size_t 21 | ak_skinInterleave(AkBoneWeights * __restrict source, 22 | uint32_t maxJoint, 23 | uint32_t itemCount, 24 | void ** __restrict buff) { 25 | AkBoneWeight *bw; 26 | char *tmp, *item; 27 | float *pWeight; 28 | uint32_t *pJoint; 29 | size_t size, szt, i, k; 30 | uint32_t iterCount; 31 | 32 | #ifdef DEBUG 33 | assert(buff); 34 | #endif 35 | 36 | szt = maxJoint * (sizeof(uint32_t) + sizeof(float)); 37 | size = source->nVertex * szt; 38 | 39 | if (!(tmp = *buff)) 40 | tmp = *buff = ak_calloc(NULL, size); 41 | 42 | for (i = 0; i < source->nVertex; i++) { 43 | iterCount = GLM_MIN(source->counts[i], GLM_MIN(maxJoint, itemCount)); 44 | item = tmp + szt * i; 45 | 46 | pJoint = (uint32_t *)item; 47 | pWeight = (float *)(void *)(item + sizeof(uint32_t) * itemCount); 48 | 49 | for (k = 0; k < iterCount; k++) { 50 | bw = &source->weights[source->indexes[i] + k]; 51 | pJoint[k] = bw->joint; 52 | pWeight[k] = bw->weight; 53 | } 54 | } 55 | 56 | return size; 57 | } 58 | -------------------------------------------------------------------------------- /src/strpool.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _AK_STRPOOL_ 18 | # define _AK_STRPOOL_ 19 | #endif 20 | 21 | #include "strpool.h" 22 | #include 23 | 24 | const char _s_ak_pool_0[] = 25 | "POSITION\0" 26 | "NORMAL\0" 27 | "TEXCOORD\0" 28 | "COLOR\0" 29 | ; 30 | 31 | #undef _AK_STRPOOL_ 32 | -------------------------------------------------------------------------------- /src/strpool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_strpool_h 18 | # define ak_strpool_h 19 | 20 | #ifndef AK_STRPOOL_ 21 | # define _AK_EXTERN extern 22 | #else 23 | # define _AK_EXTERN 24 | #endif 25 | 26 | _AK_EXTERN const char _s_ak_pool_0[]; 27 | 28 | #define _s_ak_0(x) (_s_ak_pool_0 + x) 29 | 30 | /* _s_ak_pool_0 */ 31 | #define _s_POSITION _s_ak_0(0) 32 | #define _s_NORMAL _s_ak_0(9) 33 | #define _s_TEXCOORD _s_ak_0(16) 34 | #define _s_COLOR _s_ak_0(25) 35 | 36 | #endif /* ak_strpool_h */ 37 | -------------------------------------------------------------------------------- /src/strpool.json: -------------------------------------------------------------------------------- 1 | { 2 | "POSITION": "POSITION", 3 | "NORMAL": "NORMAL", 4 | "TEXCOORD": "TEXCOORD", 5 | "COLOR": "COLOR" 6 | } 7 | -------------------------------------------------------------------------------- /src/transform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/transform/traverse.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../common.h" 18 | #include 19 | 20 | AK_EXPORT 21 | void 22 | ak_transformCombineWorld(AkNode * __restrict node, 23 | float * matrix) { 24 | AkNode *parentNode; 25 | mat4 mat; 26 | mat4 ptrans; 27 | 28 | ak_transformCombine(node, mat[0]); 29 | 30 | parentNode = node->parent; 31 | while (parentNode) { 32 | ak_transformCombine(parentNode, ptrans[0]); 33 | 34 | glm_mat4_mul(ptrans, mat, mat); 35 | parentNode = parentNode->parent; 36 | } 37 | 38 | glm_mat4_copy(mat, (vec4 *)matrix); 39 | } 40 | -------------------------------------------------------------------------------- /src/trash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_src_trash_h 18 | #define ak_src_trash_h 19 | 20 | #include "common.h" 21 | 22 | AK_HIDE 23 | void 24 | ak_trash_init(void); 25 | 26 | AK_HIDE 27 | void 28 | ak_trash_deinit(void); 29 | 30 | #endif /* ak_src_trash_h */ 31 | -------------------------------------------------------------------------------- /src/tree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_src_tree_h 18 | #define ak_src_tree_h 19 | 20 | #include "../include/ak/assetkit.h" 21 | #include 22 | /** 23 | * @brief load a tree from xml 24 | */ 25 | AK_HIDE 26 | AkTreeNode* 27 | tree_fromxml(AkHeap * __restrict heap, 28 | void * __restrict memParent, 29 | xml_t * __restrict xml); 30 | 31 | #endif /* ak_src_tree_h */ 32 | -------------------------------------------------------------------------------- /src/type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_src_type_h 18 | #define ak_src_type_h 19 | 20 | AK_HIDE 21 | void 22 | ak_type_init(void); 23 | 24 | AK_HIDE 25 | void 26 | ak_type_deinit(void); 27 | 28 | #endif /* ak_src_type_h */ 29 | -------------------------------------------------------------------------------- /src/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_src_utils_h 18 | #define ak_src_utils_h 19 | 20 | #include "../include/ak/assetkit.h" 21 | #include "../include/ak/util.h" 22 | 23 | AkResult 24 | ak_readfile(const char * __restrict file, 25 | void * __restrict parent, 26 | void ** __restrict dest, 27 | size_t * __restrict size); 28 | time_t 29 | ak_parse_date(const char * __restrict input, 30 | const char ** __restrict ret); 31 | AK_HIDE 32 | void 33 | ak_releasefile(void *file, size_t size); 34 | 35 | #endif /* ak_src_utils_h */ 36 | -------------------------------------------------------------------------------- /src/win32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB CSources *.h *.c) 2 | target_sources(${PROJECT_NAME} 3 | PRIVATE 4 | ${CSources} 5 | ) 6 | -------------------------------------------------------------------------------- /src/win32/dllmain.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../config.h" 18 | #include "../mem/common.h" 19 | 20 | void 21 | AK_CONSTRUCTOR 22 | ak__init(); 23 | 24 | void 25 | AK_DESTRUCTOR 26 | ak__cleanup(); 27 | 28 | BOOL APIENTRY DllMain(HMODULE hModule, 29 | DWORD ul_reason_for_call, 30 | LPVOID lpReserved); 31 | 32 | BOOL APIENTRY DllMain(HMODULE hModule, 33 | DWORD ul_reason_for_call, 34 | LPVOID lpReserved) 35 | { 36 | (void)hModule; 37 | (void)lpReserved; 38 | 39 | switch (ul_reason_for_call) { 40 | case DLL_PROCESS_ATTACH: 41 | ak__init(); 42 | break; 43 | case DLL_THREAD_ATTACH: 44 | break; 45 | case DLL_THREAD_DETACH: 46 | break; 47 | case DLL_PROCESS_DETACH: 48 | ak__cleanup(); 49 | break; 50 | } 51 | return TRUE; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /test/src/collada/test_dae_load.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../test_common.h" 18 | 19 | const char *dae_dir = "./test/sample-models/collada/files"; 20 | 21 | TEST_IMPL(dae_load_folder) { 22 | DIR *dir; 23 | struct dirent *ent; 24 | AkDoc *doc; 25 | 26 | chdir(dae_dir); 27 | 28 | if ((dir = opendir ("./")) != NULL) { 29 | while ((ent = readdir (dir)) != NULL) { 30 | size_t namelen; 31 | 32 | namelen = strlen(ent->d_name); 33 | 34 | if (*ent->d_name == '.') { 35 | if (namelen == 1 36 | || (namelen == 2 && ent->d_name[1] == '.') 37 | || strcmp(ent->d_name, ".DS_Store") == 0) 38 | continue; 39 | } 40 | 41 | ASSERT(ak_load(&doc, ent->d_name, NULL) == AK_OK); 42 | ak_free(doc); 43 | } 44 | 45 | closedir(dir); 46 | } 47 | 48 | TEST_SUCCESS 49 | } 50 | -------------------------------------------------------------------------------- /test/src/test_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ak_test_common_h 18 | #define ak_test_common_h 19 | 20 | #include "../include/common.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | #endif /* ak_test_common_h */ 37 | -------------------------------------------------------------------------------- /test/tests.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Recep Aslantas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef tests_h 18 | #define tests_h 19 | 20 | #include "include/common.h" 21 | 22 | /* 23 | * To register a test: 24 | * 1. use TEST_DECLARE() to forward declare test 25 | * 2. use TEST_ENTRY() to add test to list 26 | */ 27 | 28 | TEST_DECLARE(heap) 29 | TEST_DECLARE(heap_multiple) 30 | TEST_DECLARE(dae_load_folder) 31 | 32 | /*****************************************************************************/ 33 | 34 | TEST_LIST { 35 | TEST_ENTRY(heap) 36 | TEST_ENTRY(heap_multiple) 37 | TEST_ENTRY(dae_load_folder) 38 | }; 39 | 40 | #endif /* tests_h */ 41 | -------------------------------------------------------------------------------- /win/.gitignore: -------------------------------------------------------------------------------- 1 | !assetkit.sln 2 | !assetkit.vcxproj 3 | !assetkit.vcxproj.filters 4 | !packages.config 5 | -------------------------------------------------------------------------------- /win/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe 4 | for /f "usebackq tokens=1* delims=: " %%i in (`"%vswhere%" -latest -requires Microsoft.Component.MSBuild`) do ( 5 | if /i "%%i"=="installationPath" set InstallDir=%%j 6 | ) 7 | 8 | SET CUR_DR=%cd% 9 | 10 | cd .. 11 | 12 | git submodule -q update --init --recursive 2> $null 13 | 14 | echo. 15 | echo Build libds 16 | echo. 17 | 18 | cd %CUR_DR%\..\deps\ds\win 19 | call .\build.bat 20 | 21 | cd %CUR_DR% 22 | 23 | msbuild assetkit.vcxproj /p:Configuration=Debug 24 | -------------------------------------------------------------------------------- /win/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | --------------------------------------------------------------------------------