Package models at compile time

It would be inefficient if git only had access to the binary model files
instead of each image in it. This way, if one image gets updated, an
entire new model package doesn't need to be stored in git's objects.
This commit is contained in:
Epicalert 2021-06-07 18:40:59 +08:00
parent c509c665f9
commit 6038cb7870
No known key found for this signature in database
GPG key ID: CAA46F858D0979BD
18 changed files with 98 additions and 2 deletions

View file

@ -1,4 +1,16 @@
cmake_minimum_required( VERSION 3.0 )
function( pack_model model_name )
file( GLOB archive_files ${PROJECT_SOURCE_DIR}/models/${model_name}/* )
add_custom_command(
COMMAND
${CMAKE_COMMAND} -E tar "cf" "${PROJECT_BINARY_DIR}/models/${model_name}.fma" --format=zip ${archive_files}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/models/${model_name}
OUTPUT ${PROJECT_BINARY_DIR}/models/${model_name}.fma
DEPENDS ${archive_files}
)
add_custom_target( fc2d_model_${model_name} ALL DEPENDS ${PROJECT_BINARY_DIR}/models/${model_name}.fma )
endfunction()
cmake_minimum_required( VERSION 3.2 )
project( Facecam2D VERSION 0.1.0 )
set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
add_subdirectory( "libs/Boxer" )
@ -24,11 +36,13 @@ include_directories( ${PROJECT_SOURCE_DIR}/src )
configure_file( ${PROJECT_SOURCE_DIR}/src/config.hpp.in ${PROJECT_SOURCE_DIR}/src/config.hpp @ONLY )
file(
COPY
${PROJECT_SOURCE_DIR}/models
${PROJECT_SOURCE_DIR}/cvdata
DESTINATION
${PROJECT_BINARY_DIR} )
file( MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/models )
pack_model( "test" )
pack_model( "rms" )
if (APPLE)
file (
COPY

Binary file not shown.

BIN
models/rms/bg.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 KiB

BIN
models/rms/chest.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

BIN
models/rms/hair.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 KiB

BIN
models/rms/head.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

52
models/rms/model.toml Normal file
View file

@ -0,0 +1,52 @@
[format]
version_major = 0
version_minor = 2
[model_info]
name = "Richard Stallman"
version = "1.0"
[[part]]
texture = "bg.webp"
bind = "null"
rot_factor = 0.0
scale_factor = 0.0
[[part]]
texture = "chest.webp"
bind = "head"
rot_factor = 0.4
[[part]]
texture = "hair.webp"
bind = "head"
follow = "face"
factor = -0.5
[[part]]
texture = "head.webp"
bind = "head"
[[part]]
bind = "head"
follow = "face"
factor = 0.5
[[part.textures]]
file = "face-mouth-closed.webp"
[[part.textures]]
file = "face-mouth-open.webp"
trigger = "mouth-open"
[[part]]
texture = "nose.webp"
bind = "head"
follow = "face"
factor = 0.8
[[part]]
texture = "tripod.webp"
bind = "null"
rot_factor = 0.0
scale_factor = 0.0

BIN
models/rms/nose.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
models/rms/tripod.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
models/test/face-eyes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
models/test/head-base.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

30
models/test/model.toml Normal file
View file

@ -0,0 +1,30 @@
[format]
version_major = 0
version_minor = 1
[model_info]
name = "Test Model"
version = "1.0"
[[part]]
texture = "head-base.png"
bind = "head"
[[part]]
texture = "face-eyes.png"
bind = "head"
follow = "face"
factor = 0.85
[[part]]
bind = "head"
follow = "face"
factor = 1.0
[[part.textures]]
file = "face-mouth-closed.png"
[[part.textures]]
file = "face-mouth-open.png"
trigger = "mouth-open"