├── .gitignore ├── cinderblock.png ├── cinderblock.xml ├── proj └── cmake │ └── gltfConfig.cmake ├── samples ├── BasicAnimation │ ├── assets │ │ ├── BlenderTest.bin │ │ ├── BlenderTest.gltf │ │ ├── VC │ │ │ └── glTF │ │ │ │ ├── 001.jpg │ │ │ │ ├── 002.jpg │ │ │ │ ├── 11.jpg │ │ │ │ ├── 5.jpg │ │ │ │ ├── O21.jpg │ │ │ │ ├── VC.bin │ │ │ │ ├── VC.gltf │ │ │ │ ├── VC0FS.glsl │ │ │ │ ├── VC0VS.glsl │ │ │ │ ├── VC1FS.glsl │ │ │ │ ├── VC1VS.glsl │ │ │ │ ├── VC2FS.glsl │ │ │ │ ├── VC2VS.glsl │ │ │ │ ├── VC3FS.glsl │ │ │ │ ├── VC3VS.glsl │ │ │ │ ├── VC4FS.glsl │ │ │ │ ├── VC4VS.glsl │ │ │ │ ├── VC5FS.glsl │ │ │ │ ├── VC5VS.glsl │ │ │ │ ├── VC6FS.glsl │ │ │ │ ├── VC6VS.glsl │ │ │ │ ├── VC7FS.glsl │ │ │ │ ├── VC7VS.glsl │ │ │ │ ├── cockpit-map.jpg │ │ │ │ ├── f22.jpg │ │ │ │ ├── full.jpg │ │ │ │ ├── heli.jpg │ │ │ │ ├── lights.jpg │ │ │ │ ├── machine.jpg │ │ │ │ ├── prop128.png │ │ │ │ ├── s_01.jpg │ │ │ │ ├── s_02.jpg │ │ │ │ ├── s_03.jpg │ │ │ │ ├── s_04.jpg │ │ │ │ ├── s_05.jpg │ │ │ │ ├── s_06.jpg │ │ │ │ ├── s_07.jpg │ │ │ │ ├── s_08.jpg │ │ │ │ ├── scrapsurf03-red.jpg │ │ │ │ └── surface01.jpg │ │ ├── animationTest_01-1_c4d │ │ │ ├── animationTest_01-1_c4d.gltf │ │ │ └── buffer.bin │ │ ├── animationTest_01_c4d │ │ │ ├── animationTest_01_c4d.gltf │ │ │ └── buffer.bin │ │ ├── coins.gltf │ │ ├── glTF │ │ │ ├── BoxAnimated.bin │ │ │ ├── BoxAnimated.gltf │ │ │ ├── BoxAnimated0FS.glsl │ │ │ └── BoxAnimated0VS.glsl │ │ ├── kickingTires_c4d │ │ │ ├── buffer.bin │ │ │ └── kickingTires_c4d.gltf │ │ ├── program_0FS.glsl │ │ ├── program_0VS.glsl │ │ ├── test.gltf │ │ ├── testSceneForRyan │ │ │ ├── UV.png │ │ │ ├── buffer.bin │ │ │ ├── image1.png │ │ │ ├── image2.png │ │ │ ├── image3.png │ │ │ ├── image4.png │ │ │ ├── image5.png │ │ │ ├── image6.png │ │ │ ├── image7.png │ │ │ ├── image8.png │ │ │ └── testSceneForRyan.gltf │ │ └── test_small.gltf │ ├── include │ │ └── Resources.h │ ├── proj │ │ └── cmake │ │ │ └── CMakeLists.txt │ ├── resources │ │ ├── CinderApp.icns │ │ ├── CinderApp_ios.png │ │ └── cinder_app_icon.ico │ ├── src │ │ └── BasicAnimationApp.cpp │ ├── vc2013 │ │ ├── BasicAnimation.sln │ │ ├── BasicAnimation.vcxproj │ │ ├── BasicAnimation.vcxproj.filters │ │ └── Resources.rc │ ├── xcode │ │ ├── BasicAnimation.xcodeproj │ │ │ └── project.pbxproj │ │ ├── BasicAnimation_Prefix.pch │ │ └── Info.plist │ └── xcode_ios │ │ ├── BasicAnimation.xcodeproj │ │ └── project.pbxproj │ │ ├── BasicAnimation_Prefix.pch │ │ ├── Images.xcassets │ │ └── LaunchImage.launchimage │ │ │ ├── Contents.json │ │ │ ├── Default-568h@2x.png │ │ │ ├── Default-667@2x.png │ │ │ └── Default-736h@3x~iphone.png │ │ ├── Info.plist │ │ └── LaunchScreen.xib ├── BasicLoading │ ├── assets │ │ └── Duck │ │ │ ├── README.txt │ │ │ ├── collada │ │ │ ├── Duck.dae │ │ │ └── DuckCM.png │ │ │ ├── glTF-Binary │ │ │ └── Duck.glb │ │ │ ├── glTF-Embedded │ │ │ └── Duck.gltf │ │ │ ├── glTF-MaterialsCommon │ │ │ ├── Duck.bin │ │ │ ├── Duck.gltf │ │ │ └── DuckCM.png │ │ │ ├── glTF │ │ │ ├── Duck.bin │ │ │ ├── Duck.gltf │ │ │ ├── Duck0FS.glsl │ │ │ ├── Duck0VS.glsl │ │ │ └── DuckCM.png │ │ │ └── screenshot │ │ │ └── screenshot.png │ ├── include │ │ └── Resources.h │ ├── proj │ │ └── cmake │ │ │ └── CMakeLists.txt │ ├── resources │ │ ├── CinderApp.icns │ │ ├── CinderApp_ios.png │ │ └── cinder_app_icon.ico │ ├── src │ │ └── BasicLoadingApp.cpp │ ├── vc2013 │ │ ├── BasicLoading.sln │ │ ├── BasicLoading.vcxproj │ │ ├── BasicLoading.vcxproj.filters │ │ └── Resources.rc │ ├── xcode │ │ ├── BasicLoading.xcodeproj │ │ │ └── project.pbxproj │ │ ├── BasicLoading_Prefix.pch │ │ └── Info.plist │ └── xcode_ios │ │ ├── BasicLoading.xcodeproj │ │ └── project.pbxproj │ │ ├── BasicLoading_Prefix.pch │ │ ├── Images.xcassets │ │ └── LaunchImage.launchimage │ │ │ ├── Contents.json │ │ │ ├── Default-568h@2x.png │ │ │ ├── Default-667@2x.png │ │ │ └── Default-736h@3x~iphone.png │ │ ├── Info.plist │ │ └── LaunchScreen.xib └── SkeletalAnimation │ ├── assets │ ├── CesiumMan │ │ ├── README.txt │ │ ├── collada │ │ │ ├── CesiumMan.dae │ │ │ ├── CesiumMan.jpg │ │ │ ├── Cesium_Man.dae │ │ │ └── Cesium_Man.jpg │ │ ├── glTF-Binary │ │ │ ├── CesiumMan.glb │ │ │ └── Cesium_Man.glb │ │ ├── glTF-Embedded │ │ │ ├── CesiumMan.gltf │ │ │ └── Cesium_Man.gltf │ │ ├── glTF-MaterialsCommon │ │ │ ├── CesiumMan.bin │ │ │ ├── CesiumMan.gltf │ │ │ ├── CesiumMan.jpg │ │ │ ├── Cesium_Man.bin │ │ │ ├── Cesium_Man.gltf │ │ │ └── Cesium_Man.jpg │ │ ├── glTF │ │ │ ├── CesiumMan.bin │ │ │ ├── CesiumMan.gltf │ │ │ ├── CesiumMan.jpg │ │ │ ├── CesiumMan0FS.glsl │ │ │ ├── CesiumMan0VS.glsl │ │ │ ├── Cesium_Man.bin │ │ │ ├── Cesium_Man.gltf │ │ │ ├── Cesium_Man.jpg │ │ │ ├── Cesium_Man0FS.glsl │ │ │ └── Cesium_Man0VS.glsl │ │ └── screenshot │ │ │ ├── screenshot.gif │ │ │ └── screenshot.png │ ├── brainsteam │ │ ├── collada │ │ │ └── Brainsteam.dae │ │ ├── glTF-Binary │ │ │ └── Brainsteam.glb │ │ ├── glTF-Embedded │ │ │ └── Brainsteam.gltf │ │ ├── glTF-MaterialsCommon │ │ │ ├── Brainsteam.bin │ │ │ └── Brainsteam.gltf │ │ ├── glTF │ │ │ ├── Brainsteam.bin │ │ │ ├── Brainsteam.gltf │ │ │ ├── Brainsteam0FS.glsl │ │ │ └── Brainsteam0VS.glsl │ │ └── screenshot │ │ │ ├── screenshot.gif │ │ │ └── screenshot.png │ ├── monster │ │ ├── collada │ │ │ ├── Monster.jpg │ │ │ └── monster.dae │ │ ├── glTF-Binary │ │ │ └── Monster.glb │ │ ├── glTF-Embedded │ │ │ └── Monster.gltf │ │ ├── glTF-MaterialsCommon │ │ │ ├── Monster.bin │ │ │ ├── Monster.gltf │ │ │ └── Monster.jpg │ │ ├── glTF │ │ │ ├── Monster.bin │ │ │ ├── Monster.gltf │ │ │ ├── Monster.jpg │ │ │ ├── Monster0FS.glsl │ │ │ └── monster0VS.glsl │ │ ├── readme.txt │ │ └── screenshot │ │ │ ├── screenshot.gif │ │ │ └── screenshot.png │ ├── skeletal.frag │ └── skeletal.vert │ ├── include │ └── Resources.h │ ├── proj │ └── cmake │ │ └── CMakeLists.txt │ ├── resources │ ├── CinderApp.icns │ ├── CinderApp_ios.png │ └── cinder_app_icon.ico │ ├── src │ └── SkeletalAnimationApp.cpp │ ├── vc2013 │ ├── Resources.rc │ ├── SkeletalAnimation.sln │ ├── SkeletalAnimation.vcxproj │ └── SkeletalAnimation.vcxproj.filters │ ├── xcode │ ├── Info.plist │ ├── SkeletalAnimation.xcodeproj │ │ └── project.pbxproj │ └── SkeletalAnimation_Prefix.pch │ └── xcode_ios │ ├── Images.xcassets │ └── LaunchImage.launchimage │ │ ├── Contents.json │ │ ├── Default-568h@2x.png │ │ ├── Default-667@2x.png │ │ └── Default-736h@3x~iphone.png │ ├── Info.plist │ ├── LaunchScreen.xib │ ├── SkeletalAnimation.xcodeproj │ └── project.pbxproj │ └── SkeletalAnimation_Prefix.pch └── src └── cinder ├── Animation.h ├── Skeleton.cpp ├── Skeleton.h ├── dqconv.h └── gltf ├── File.cpp ├── File.h ├── MeshLoader.cpp ├── MeshLoader.h ├── SimpleScene.cpp ├── SimpleScene.h ├── Types.cpp └── Types.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS X cruft 2 | *.pbxuser 3 | *.mode1v3 4 | *.mode2v3 5 | *.user 6 | project.xcworkspace 7 | xcuserdata/ 8 | *.xccheckout 9 | .DS_Store 10 | 11 | build/ 12 | lib/libcinder*.a 13 | lib/msw/x86/cinder*.lib 14 | lib/msw/x64/cinder*.lib 15 | lib/msw/x86/cinder*.idb 16 | lib/msw/x64/cinder*.idb 17 | lib/msw/x86/cinder*.pdb 18 | lib/msw/x64/cinder*.pdb 19 | lib/winrt/x86/cinder*.lib 20 | lib/winrt/x64/cinder*.lib 21 | 22 | # Windows cruft 23 | *.suo 24 | *.ncb 25 | *.sdf 26 | *.opensdf 27 | *.VC.db 28 | Debug/ 29 | Release/ 30 | Debug_ANGLE/ 31 | Release_ANGLE/ 32 | ipch/ 33 | 34 | # doxygen generated files 35 | docs/html 36 | docs/doxygen/cinder.tag 37 | 38 | # CinderBlocks 39 | blocks/ 40 | !blocks/[__AppTemplates,Box2D,Cairo,FMOD,LocationManager,MotionManager,OSC,QuickTime,TUIO] 41 | 42 | -------------------------------------------------------------------------------- /cinderblock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/cinderblock.png -------------------------------------------------------------------------------- /cinderblock.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | src/cinder/*.cpp 12 | src/cinder/gltf/*.cpp 13 | src/cinder/*.h 14 | src/cinder/gltf/*.h 15 | src 16 | 17 | 18 | -------------------------------------------------------------------------------- /proj/cmake/gltfConfig.cmake: -------------------------------------------------------------------------------- 1 | if( NOT TARGET gltf ) 2 | 3 | get_filename_component( gltf_SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../src" ABSOLUTE ) 4 | get_filename_component( CINDER_PATH "${CMAKE_CURRENT_LIST_DIR}/../../../.." ABSOLUTE ) 5 | 6 | list( APPEND gltf_SOURCES 7 | "${gltf_SOURCE_PATH}/cinder/Skeleton.cpp" 8 | "${gltf_SOURCE_PATH}/cinder/gltf/Types.cpp" 9 | "${gltf_SOURCE_PATH}/cinder/gltf/SimpleScene.cpp" 10 | "${gltf_SOURCE_PATH}/cinder/gltf/MeshLoader.cpp" 11 | "${gltf_SOURCE_PATH}/cinder/gltf/File.cpp" ) 12 | 13 | add_library( gltf "${gltf_SOURCES}" ) 14 | 15 | target_include_directories( gltf PUBLIC "${gltf_SOURCE_PATH}" 16 | ) 17 | target_include_directories( gltf PRIVATE BEFORE "${CINDER_PATH}/include" ) 18 | 19 | target_compile_options( gltf PRIVATE "-std=c++11" ) 20 | 21 | if( NOT TARGET cinder ) 22 | include( "${CINDER_PATH}/proj/cmake/configure.cmake" ) 23 | find_package( cinder REQUIRED PATHS 24 | "${CINDER_PATH}/${CINDER_LIB_DIRECTORY}" 25 | "$ENV{CINDER_PATH}/${CINDER_LIB_DIRECTORY}" ) 26 | endif() 27 | 28 | target_link_libraries( gltf PRIVATE cinder ) 29 | 30 | endif() 31 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/BlenderTest.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/BlenderTest.bin -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/001.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/002.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/002.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/11.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/5.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/O21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/O21.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/VC.bin -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC0FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | uniform vec4 u_diffuse; 5 | uniform vec4 u_specular; 6 | uniform float u_shininess; 7 | uniform vec3 u_light0Color; 8 | varying vec3 v_light1Direction; 9 | varying vec3 v_position; 10 | uniform float u_light1ConstantAttenuation; 11 | uniform float u_light1LinearAttenuation; 12 | uniform float u_light1QuadraticAttenuation; 13 | uniform vec3 u_light1Color; 14 | varying vec3 v_light2Direction; 15 | uniform float u_light2ConstantAttenuation; 16 | uniform float u_light2LinearAttenuation; 17 | uniform float u_light2QuadraticAttenuation; 18 | uniform vec3 u_light2Color; 19 | void main(void) { 20 | vec3 normal = normalize(v_normal); 21 | vec4 color = vec4(0., 0., 0., 0.); 22 | vec4 diffuse = vec4(0., 0., 0., 1.); 23 | vec3 diffuseLight = vec3(0., 0., 0.); 24 | vec4 ambient; 25 | vec4 specular; 26 | ambient = u_ambient; 27 | diffuse = u_diffuse; 28 | specular = u_specular; 29 | vec3 specularLight = vec3(0., 0., 0.); 30 | vec3 ambientLight = vec3(0., 0., 0.); 31 | { 32 | ambientLight += u_light0Color; 33 | } 34 | { 35 | float specularIntensity = 0.; 36 | float attenuation = 1.0; 37 | float range = length(v_light1Direction); 38 | attenuation = 1.0 / ( u_light1ConstantAttenuation + (u_light1LinearAttenuation * range) + (u_light1QuadraticAttenuation * range * range) ) ; 39 | vec3 l = normalize(v_light1Direction); 40 | vec3 viewDir = -normalize(v_position); 41 | float phongTerm = max(0.0, dot(reflect(-l,normal), viewDir)); 42 | specularIntensity = max(0., pow(phongTerm , u_shininess)) * attenuation; 43 | specularLight += u_light1Color * specularIntensity; 44 | diffuseLight += u_light1Color * max(dot(normal,l), 0.) * attenuation; 45 | } 46 | { 47 | float specularIntensity = 0.; 48 | float attenuation = 1.0; 49 | float range = length(v_light2Direction); 50 | attenuation = 1.0 / ( u_light2ConstantAttenuation + (u_light2LinearAttenuation * range) + (u_light2QuadraticAttenuation * range * range) ) ; 51 | vec3 l = normalize(v_light2Direction); 52 | vec3 viewDir = -normalize(v_position); 53 | float phongTerm = max(0.0, dot(reflect(-l,normal), viewDir)); 54 | specularIntensity = max(0., pow(phongTerm , u_shininess)) * attenuation; 55 | specularLight += u_light2Color * specularIntensity; 56 | diffuseLight += u_light2Color * max(dot(normal,l), 0.) * attenuation; 57 | } 58 | ambient.xyz *= ambientLight; 59 | color.xyz += ambient.xyz; 60 | specular.xyz *= specularLight; 61 | color.xyz += specular.xyz; 62 | diffuse.xyz *= diffuseLight; 63 | color.xyz += diffuse.xyz; 64 | color = vec4(color.rgb * diffuse.a, diffuse.a); 65 | gl_FragColor = color; 66 | } 67 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC0VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | varying vec3 v_light1Direction; 9 | varying vec3 v_position; 10 | uniform mat4 u_light1Transform; 11 | varying vec3 v_light2Direction; 12 | uniform mat4 u_light2Transform; 13 | void main(void) { 14 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 15 | v_normal = u_normalMatrix * a_normal; 16 | v_position = pos.xyz; 17 | v_light1Direction = u_light1Transform[3].xyz - pos.xyz; 18 | v_light2Direction = u_light2Transform[3].xyz - pos.xyz; 19 | gl_Position = u_projectionMatrix * pos; 20 | } 21 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC1FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | varying vec2 v_texcoord0; 4 | uniform sampler2D u_ambient; 5 | uniform sampler2D u_diffuse; 6 | uniform vec4 u_emission; 7 | uniform vec4 u_specular; 8 | uniform float u_shininess; 9 | uniform vec3 u_light0Color; 10 | varying vec3 v_light1Direction; 11 | varying vec3 v_position; 12 | uniform float u_light1ConstantAttenuation; 13 | uniform float u_light1LinearAttenuation; 14 | uniform float u_light1QuadraticAttenuation; 15 | uniform vec3 u_light1Color; 16 | varying vec3 v_light2Direction; 17 | uniform float u_light2ConstantAttenuation; 18 | uniform float u_light2LinearAttenuation; 19 | uniform float u_light2QuadraticAttenuation; 20 | uniform vec3 u_light2Color; 21 | void main(void) { 22 | vec3 normal = normalize(v_normal); 23 | vec4 color = vec4(0., 0., 0., 0.); 24 | vec4 diffuse = vec4(0., 0., 0., 1.); 25 | vec3 diffuseLight = vec3(0., 0., 0.); 26 | vec4 emission; 27 | vec4 ambient; 28 | vec4 specular; 29 | ambient = texture2D(u_ambient, v_texcoord0); 30 | diffuse = texture2D(u_diffuse, v_texcoord0); 31 | emission = u_emission; 32 | specular = u_specular; 33 | vec3 specularLight = vec3(0., 0., 0.); 34 | vec3 ambientLight = vec3(0., 0., 0.); 35 | { 36 | ambientLight += u_light0Color; 37 | } 38 | { 39 | float specularIntensity = 0.; 40 | float attenuation = 1.0; 41 | float range = length(v_light1Direction); 42 | attenuation = 1.0 / ( u_light1ConstantAttenuation + (u_light1LinearAttenuation * range) + (u_light1QuadraticAttenuation * range * range) ) ; 43 | vec3 l = normalize(v_light1Direction); 44 | vec3 viewDir = -normalize(v_position); 45 | vec3 h = normalize(l+viewDir); 46 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 47 | specularLight += u_light1Color * specularIntensity; 48 | diffuseLight += u_light1Color * max(dot(normal,l), 0.) * attenuation; 49 | } 50 | { 51 | float specularIntensity = 0.; 52 | float attenuation = 1.0; 53 | float range = length(v_light2Direction); 54 | attenuation = 1.0 / ( u_light2ConstantAttenuation + (u_light2LinearAttenuation * range) + (u_light2QuadraticAttenuation * range * range) ) ; 55 | vec3 l = normalize(v_light2Direction); 56 | vec3 viewDir = -normalize(v_position); 57 | vec3 h = normalize(l+viewDir); 58 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 59 | specularLight += u_light2Color * specularIntensity; 60 | diffuseLight += u_light2Color * max(dot(normal,l), 0.) * attenuation; 61 | } 62 | ambient.xyz *= ambientLight; 63 | color.xyz += ambient.xyz; 64 | specular.xyz *= specularLight; 65 | color.xyz += specular.xyz; 66 | diffuse.xyz *= diffuseLight; 67 | color.xyz += diffuse.xyz; 68 | color.xyz += emission.xyz; 69 | color = vec4(color.rgb * diffuse.a, diffuse.a); 70 | gl_FragColor = color; 71 | } 72 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC1VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | attribute vec2 a_texcoord0; 9 | varying vec2 v_texcoord0; 10 | varying vec3 v_light1Direction; 11 | varying vec3 v_position; 12 | uniform mat4 u_light1Transform; 13 | varying vec3 v_light2Direction; 14 | uniform mat4 u_light2Transform; 15 | void main(void) { 16 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 17 | v_normal = u_normalMatrix * a_normal; 18 | v_texcoord0 = a_texcoord0; 19 | v_position = pos.xyz; 20 | v_light1Direction = u_light1Transform[3].xyz - pos.xyz; 21 | v_light2Direction = u_light2Transform[3].xyz - pos.xyz; 22 | gl_Position = u_projectionMatrix * pos; 23 | } 24 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC2FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | uniform vec4 u_diffuse; 5 | uniform vec4 u_emission; 6 | uniform vec4 u_specular; 7 | uniform float u_shininess; 8 | uniform vec3 u_light0Color; 9 | varying vec3 v_light1Direction; 10 | varying vec3 v_position; 11 | uniform float u_light1ConstantAttenuation; 12 | uniform float u_light1LinearAttenuation; 13 | uniform float u_light1QuadraticAttenuation; 14 | uniform vec3 u_light1Color; 15 | varying vec3 v_light2Direction; 16 | uniform float u_light2ConstantAttenuation; 17 | uniform float u_light2LinearAttenuation; 18 | uniform float u_light2QuadraticAttenuation; 19 | uniform vec3 u_light2Color; 20 | uniform float u_transparency; 21 | void main(void) { 22 | vec3 normal = normalize(v_normal); 23 | vec4 color = vec4(0., 0., 0., 0.); 24 | vec4 diffuse = vec4(0., 0., 0., 1.); 25 | vec3 diffuseLight = vec3(0., 0., 0.); 26 | vec4 emission; 27 | vec4 ambient; 28 | vec4 specular; 29 | ambient = u_ambient; 30 | diffuse = u_diffuse; 31 | emission = u_emission; 32 | specular = u_specular; 33 | vec3 specularLight = vec3(0., 0., 0.); 34 | vec3 ambientLight = vec3(0., 0., 0.); 35 | { 36 | ambientLight += u_light0Color; 37 | } 38 | { 39 | float specularIntensity = 0.; 40 | float attenuation = 1.0; 41 | float range = length(v_light1Direction); 42 | attenuation = 1.0 / ( u_light1ConstantAttenuation + (u_light1LinearAttenuation * range) + (u_light1QuadraticAttenuation * range * range) ) ; 43 | vec3 l = normalize(v_light1Direction); 44 | vec3 viewDir = -normalize(v_position); 45 | vec3 h = normalize(l+viewDir); 46 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 47 | specularLight += u_light1Color * specularIntensity; 48 | diffuseLight += u_light1Color * max(dot(normal,l), 0.) * attenuation; 49 | } 50 | { 51 | float specularIntensity = 0.; 52 | float attenuation = 1.0; 53 | float range = length(v_light2Direction); 54 | attenuation = 1.0 / ( u_light2ConstantAttenuation + (u_light2LinearAttenuation * range) + (u_light2QuadraticAttenuation * range * range) ) ; 55 | vec3 l = normalize(v_light2Direction); 56 | vec3 viewDir = -normalize(v_position); 57 | vec3 h = normalize(l+viewDir); 58 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 59 | specularLight += u_light2Color * specularIntensity; 60 | diffuseLight += u_light2Color * max(dot(normal,l), 0.) * attenuation; 61 | } 62 | ambient.xyz *= ambientLight; 63 | color.xyz += ambient.xyz; 64 | specular.xyz *= specularLight; 65 | color.xyz += specular.xyz; 66 | diffuse.xyz *= diffuseLight; 67 | color.xyz += diffuse.xyz; 68 | color.xyz += emission.xyz; 69 | color = vec4(color.rgb * diffuse.a, diffuse.a * u_transparency); 70 | gl_FragColor = color; 71 | } 72 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC2VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | varying vec3 v_light1Direction; 9 | varying vec3 v_position; 10 | uniform mat4 u_light1Transform; 11 | varying vec3 v_light2Direction; 12 | uniform mat4 u_light2Transform; 13 | void main(void) { 14 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 15 | v_normal = u_normalMatrix * a_normal; 16 | v_position = pos.xyz; 17 | v_light1Direction = u_light1Transform[3].xyz - pos.xyz; 18 | v_light2Direction = u_light2Transform[3].xyz - pos.xyz; 19 | gl_Position = u_projectionMatrix * pos; 20 | } 21 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC3FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | varying vec2 v_texcoord0; 4 | uniform sampler2D u_ambient; 5 | uniform sampler2D u_diffuse; 6 | uniform vec4 u_emission; 7 | varying vec2 v_texcoord1; 8 | uniform sampler2D u_reflective; 9 | uniform vec4 u_specular; 10 | uniform float u_shininess; 11 | uniform vec3 u_light0Color; 12 | varying vec3 v_light1Direction; 13 | varying vec3 v_position; 14 | uniform float u_light1ConstantAttenuation; 15 | uniform float u_light1LinearAttenuation; 16 | uniform float u_light1QuadraticAttenuation; 17 | uniform vec3 u_light1Color; 18 | varying vec3 v_light2Direction; 19 | uniform float u_light2ConstantAttenuation; 20 | uniform float u_light2LinearAttenuation; 21 | uniform float u_light2QuadraticAttenuation; 22 | uniform vec3 u_light2Color; 23 | void main(void) { 24 | vec3 normal = normalize(v_normal); 25 | vec4 color = vec4(0., 0., 0., 0.); 26 | vec4 diffuse = vec4(0., 0., 0., 1.); 27 | vec3 diffuseLight = vec3(0., 0., 0.); 28 | vec4 emission; 29 | vec4 reflective; 30 | vec4 ambient; 31 | vec4 specular; 32 | ambient = texture2D(u_ambient, v_texcoord0); 33 | diffuse = texture2D(u_diffuse, v_texcoord0); 34 | emission = u_emission; 35 | reflective = texture2D(u_reflective, v_texcoord1); 36 | specular = u_specular; 37 | vec3 specularLight = vec3(0., 0., 0.); 38 | vec3 ambientLight = vec3(0., 0., 0.); 39 | { 40 | ambientLight += u_light0Color; 41 | } 42 | { 43 | float specularIntensity = 0.; 44 | float attenuation = 1.0; 45 | float range = length(v_light1Direction); 46 | attenuation = 1.0 / ( u_light1ConstantAttenuation + (u_light1LinearAttenuation * range) + (u_light1QuadraticAttenuation * range * range) ) ; 47 | vec3 l = normalize(v_light1Direction); 48 | vec3 viewDir = -normalize(v_position); 49 | vec3 h = normalize(l+viewDir); 50 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 51 | specularLight += u_light1Color * specularIntensity; 52 | diffuseLight += u_light1Color * max(dot(normal,l), 0.) * attenuation; 53 | } 54 | { 55 | float specularIntensity = 0.; 56 | float attenuation = 1.0; 57 | float range = length(v_light2Direction); 58 | attenuation = 1.0 / ( u_light2ConstantAttenuation + (u_light2LinearAttenuation * range) + (u_light2QuadraticAttenuation * range * range) ) ; 59 | vec3 l = normalize(v_light2Direction); 60 | vec3 viewDir = -normalize(v_position); 61 | vec3 h = normalize(l+viewDir); 62 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 63 | specularLight += u_light2Color * specularIntensity; 64 | diffuseLight += u_light2Color * max(dot(normal,l), 0.) * attenuation; 65 | } 66 | diffuse.xyz += reflective.xyz; 67 | ambient.xyz *= ambientLight; 68 | color.xyz += ambient.xyz; 69 | specular.xyz *= specularLight; 70 | color.xyz += specular.xyz; 71 | diffuse.xyz *= diffuseLight; 72 | color.xyz += diffuse.xyz; 73 | color.xyz += emission.xyz; 74 | color = vec4(color.rgb * diffuse.a, diffuse.a); 75 | gl_FragColor = color; 76 | } 77 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC3VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | attribute vec2 a_texcoord0; 9 | varying vec2 v_texcoord0; 10 | varying vec2 v_texcoord1; 11 | varying vec3 v_light1Direction; 12 | varying vec3 v_position; 13 | uniform mat4 u_light1Transform; 14 | varying vec3 v_light2Direction; 15 | uniform mat4 u_light2Transform; 16 | void main(void) { 17 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 18 | v_normal = u_normalMatrix * a_normal; 19 | v_texcoord0 = a_texcoord0; 20 | vec3 normalizedVert = normalize(vec3(pos)); 21 | vec3 r = reflect(normalizedVert, v_normal); 22 | r.z += 1.0; 23 | float m = 2.0 * sqrt(dot(r,r)); 24 | v_texcoord1 = (r.xy / m) + 0.5; 25 | v_position = pos.xyz; 26 | v_light1Direction = u_light1Transform[3].xyz - pos.xyz; 27 | v_light2Direction = u_light2Transform[3].xyz - pos.xyz; 28 | gl_Position = u_projectionMatrix * pos; 29 | } 30 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC4FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | uniform vec4 u_diffuse; 5 | uniform vec4 u_emission; 6 | varying vec2 v_texcoord0; 7 | uniform sampler2D u_reflective; 8 | uniform vec4 u_specular; 9 | uniform float u_shininess; 10 | uniform vec3 u_light0Color; 11 | varying vec3 v_light1Direction; 12 | varying vec3 v_position; 13 | uniform float u_light1ConstantAttenuation; 14 | uniform float u_light1LinearAttenuation; 15 | uniform float u_light1QuadraticAttenuation; 16 | uniform vec3 u_light1Color; 17 | varying vec3 v_light2Direction; 18 | uniform float u_light2ConstantAttenuation; 19 | uniform float u_light2LinearAttenuation; 20 | uniform float u_light2QuadraticAttenuation; 21 | uniform vec3 u_light2Color; 22 | uniform float u_transparency; 23 | void main(void) { 24 | vec3 normal = normalize(v_normal); 25 | vec4 color = vec4(0., 0., 0., 0.); 26 | vec4 diffuse = vec4(0., 0., 0., 1.); 27 | vec3 diffuseLight = vec3(0., 0., 0.); 28 | vec4 emission; 29 | vec4 reflective; 30 | vec4 ambient; 31 | vec4 specular; 32 | ambient = u_ambient; 33 | diffuse = u_diffuse; 34 | emission = u_emission; 35 | reflective = texture2D(u_reflective, v_texcoord0); 36 | specular = u_specular; 37 | vec3 specularLight = vec3(0., 0., 0.); 38 | vec3 ambientLight = vec3(0., 0., 0.); 39 | { 40 | ambientLight += u_light0Color; 41 | } 42 | { 43 | float specularIntensity = 0.; 44 | float attenuation = 1.0; 45 | float range = length(v_light1Direction); 46 | attenuation = 1.0 / ( u_light1ConstantAttenuation + (u_light1LinearAttenuation * range) + (u_light1QuadraticAttenuation * range * range) ) ; 47 | vec3 l = normalize(v_light1Direction); 48 | vec3 viewDir = -normalize(v_position); 49 | vec3 h = normalize(l+viewDir); 50 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 51 | specularLight += u_light1Color * specularIntensity; 52 | diffuseLight += u_light1Color * max(dot(normal,l), 0.) * attenuation; 53 | } 54 | { 55 | float specularIntensity = 0.; 56 | float attenuation = 1.0; 57 | float range = length(v_light2Direction); 58 | attenuation = 1.0 / ( u_light2ConstantAttenuation + (u_light2LinearAttenuation * range) + (u_light2QuadraticAttenuation * range * range) ) ; 59 | vec3 l = normalize(v_light2Direction); 60 | vec3 viewDir = -normalize(v_position); 61 | vec3 h = normalize(l+viewDir); 62 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 63 | specularLight += u_light2Color * specularIntensity; 64 | diffuseLight += u_light2Color * max(dot(normal,l), 0.) * attenuation; 65 | } 66 | diffuse.xyz += reflective.xyz; 67 | ambient.xyz *= ambientLight; 68 | color.xyz += ambient.xyz; 69 | specular.xyz *= specularLight; 70 | color.xyz += specular.xyz; 71 | diffuse.xyz *= diffuseLight; 72 | color.xyz += diffuse.xyz; 73 | color.xyz += emission.xyz; 74 | color = vec4(color.rgb * diffuse.a, diffuse.a * u_transparency); 75 | gl_FragColor = color; 76 | } 77 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC4VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | varying vec2 v_texcoord0; 9 | varying vec3 v_light1Direction; 10 | varying vec3 v_position; 11 | uniform mat4 u_light1Transform; 12 | varying vec3 v_light2Direction; 13 | uniform mat4 u_light2Transform; 14 | void main(void) { 15 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 16 | v_normal = u_normalMatrix * a_normal; 17 | vec3 normalizedVert = normalize(vec3(pos)); 18 | vec3 r = reflect(normalizedVert, v_normal); 19 | r.z += 1.0; 20 | float m = 2.0 * sqrt(dot(r,r)); 21 | v_texcoord0 = (r.xy / m) + 0.5; 22 | v_position = pos.xyz; 23 | v_light1Direction = u_light1Transform[3].xyz - pos.xyz; 24 | v_light2Direction = u_light2Transform[3].xyz - pos.xyz; 25 | gl_Position = u_projectionMatrix * pos; 26 | } 27 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC5FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | varying vec2 v_texcoord0; 4 | uniform sampler2D u_ambient; 5 | uniform sampler2D u_diffuse; 6 | uniform vec4 u_emission; 7 | varying vec2 v_texcoord1; 8 | uniform sampler2D u_reflective; 9 | uniform vec4 u_specular; 10 | uniform float u_shininess; 11 | uniform vec3 u_light0Color; 12 | varying vec3 v_light1Direction; 13 | varying vec3 v_position; 14 | uniform float u_light1ConstantAttenuation; 15 | uniform float u_light1LinearAttenuation; 16 | uniform float u_light1QuadraticAttenuation; 17 | uniform vec3 u_light1Color; 18 | varying vec3 v_light2Direction; 19 | uniform float u_light2ConstantAttenuation; 20 | uniform float u_light2LinearAttenuation; 21 | uniform float u_light2QuadraticAttenuation; 22 | uniform vec3 u_light2Color; 23 | uniform float u_transparency; 24 | void main(void) { 25 | vec3 normal = normalize(v_normal); 26 | vec4 color = vec4(0., 0., 0., 0.); 27 | vec4 diffuse = vec4(0., 0., 0., 1.); 28 | vec3 diffuseLight = vec3(0., 0., 0.); 29 | vec4 emission; 30 | vec4 reflective; 31 | vec4 ambient; 32 | vec4 specular; 33 | ambient = texture2D(u_ambient, v_texcoord0); 34 | diffuse = texture2D(u_diffuse, v_texcoord0); 35 | emission = u_emission; 36 | reflective = texture2D(u_reflective, v_texcoord1); 37 | specular = u_specular; 38 | vec3 specularLight = vec3(0., 0., 0.); 39 | vec3 ambientLight = vec3(0., 0., 0.); 40 | { 41 | ambientLight += u_light0Color; 42 | } 43 | { 44 | float specularIntensity = 0.; 45 | float attenuation = 1.0; 46 | float range = length(v_light1Direction); 47 | attenuation = 1.0 / ( u_light1ConstantAttenuation + (u_light1LinearAttenuation * range) + (u_light1QuadraticAttenuation * range * range) ) ; 48 | vec3 l = normalize(v_light1Direction); 49 | vec3 viewDir = -normalize(v_position); 50 | vec3 h = normalize(l+viewDir); 51 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 52 | specularLight += u_light1Color * specularIntensity; 53 | diffuseLight += u_light1Color * max(dot(normal,l), 0.) * attenuation; 54 | } 55 | { 56 | float specularIntensity = 0.; 57 | float attenuation = 1.0; 58 | float range = length(v_light2Direction); 59 | attenuation = 1.0 / ( u_light2ConstantAttenuation + (u_light2LinearAttenuation * range) + (u_light2QuadraticAttenuation * range * range) ) ; 60 | vec3 l = normalize(v_light2Direction); 61 | vec3 viewDir = -normalize(v_position); 62 | vec3 h = normalize(l+viewDir); 63 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 64 | specularLight += u_light2Color * specularIntensity; 65 | diffuseLight += u_light2Color * max(dot(normal,l), 0.) * attenuation; 66 | } 67 | diffuse.xyz += reflective.xyz; 68 | ambient.xyz *= ambientLight; 69 | color.xyz += ambient.xyz; 70 | specular.xyz *= specularLight; 71 | color.xyz += specular.xyz; 72 | diffuse.xyz *= diffuseLight; 73 | color.xyz += diffuse.xyz; 74 | color.xyz += emission.xyz; 75 | color = vec4(color.rgb * diffuse.a, diffuse.a * u_transparency); 76 | gl_FragColor = color; 77 | } 78 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC5VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | attribute vec2 a_texcoord0; 9 | varying vec2 v_texcoord0; 10 | varying vec2 v_texcoord1; 11 | varying vec3 v_light1Direction; 12 | varying vec3 v_position; 13 | uniform mat4 u_light1Transform; 14 | varying vec3 v_light2Direction; 15 | uniform mat4 u_light2Transform; 16 | void main(void) { 17 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 18 | v_normal = u_normalMatrix * a_normal; 19 | v_texcoord0 = a_texcoord0; 20 | vec3 normalizedVert = normalize(vec3(pos)); 21 | vec3 r = reflect(normalizedVert, v_normal); 22 | r.z += 1.0; 23 | float m = 2.0 * sqrt(dot(r,r)); 24 | v_texcoord1 = (r.xy / m) + 0.5; 25 | v_position = pos.xyz; 26 | v_light1Direction = u_light1Transform[3].xyz - pos.xyz; 27 | v_light2Direction = u_light2Transform[3].xyz - pos.xyz; 28 | gl_Position = u_projectionMatrix * pos; 29 | } 30 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC6FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | uniform vec4 u_diffuse; 5 | uniform vec4 u_emission; 6 | uniform vec4 u_specular; 7 | uniform float u_shininess; 8 | uniform vec3 u_light0Color; 9 | varying vec3 v_light1Direction; 10 | varying vec3 v_position; 11 | uniform float u_light1ConstantAttenuation; 12 | uniform float u_light1LinearAttenuation; 13 | uniform float u_light1QuadraticAttenuation; 14 | uniform vec3 u_light1Color; 15 | varying vec3 v_light2Direction; 16 | uniform float u_light2ConstantAttenuation; 17 | uniform float u_light2LinearAttenuation; 18 | uniform float u_light2QuadraticAttenuation; 19 | uniform vec3 u_light2Color; 20 | void main(void) { 21 | vec3 normal = normalize(v_normal); 22 | vec4 color = vec4(0., 0., 0., 0.); 23 | vec4 diffuse = vec4(0., 0., 0., 1.); 24 | vec3 diffuseLight = vec3(0., 0., 0.); 25 | vec4 emission; 26 | vec4 ambient; 27 | vec4 specular; 28 | ambient = u_ambient; 29 | diffuse = u_diffuse; 30 | emission = u_emission; 31 | specular = u_specular; 32 | vec3 specularLight = vec3(0., 0., 0.); 33 | vec3 ambientLight = vec3(0., 0., 0.); 34 | { 35 | ambientLight += u_light0Color; 36 | } 37 | { 38 | float specularIntensity = 0.; 39 | float attenuation = 1.0; 40 | float range = length(v_light1Direction); 41 | attenuation = 1.0 / ( u_light1ConstantAttenuation + (u_light1LinearAttenuation * range) + (u_light1QuadraticAttenuation * range * range) ) ; 42 | vec3 l = normalize(v_light1Direction); 43 | vec3 viewDir = -normalize(v_position); 44 | vec3 h = normalize(l+viewDir); 45 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 46 | specularLight += u_light1Color * specularIntensity; 47 | diffuseLight += u_light1Color * max(dot(normal,l), 0.) * attenuation; 48 | } 49 | { 50 | float specularIntensity = 0.; 51 | float attenuation = 1.0; 52 | float range = length(v_light2Direction); 53 | attenuation = 1.0 / ( u_light2ConstantAttenuation + (u_light2LinearAttenuation * range) + (u_light2QuadraticAttenuation * range * range) ) ; 54 | vec3 l = normalize(v_light2Direction); 55 | vec3 viewDir = -normalize(v_position); 56 | vec3 h = normalize(l+viewDir); 57 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 58 | specularLight += u_light2Color * specularIntensity; 59 | diffuseLight += u_light2Color * max(dot(normal,l), 0.) * attenuation; 60 | } 61 | ambient.xyz *= ambientLight; 62 | color.xyz += ambient.xyz; 63 | specular.xyz *= specularLight; 64 | color.xyz += specular.xyz; 65 | diffuse.xyz *= diffuseLight; 66 | color.xyz += diffuse.xyz; 67 | color.xyz += emission.xyz; 68 | color = vec4(color.rgb * diffuse.a, diffuse.a); 69 | gl_FragColor = color; 70 | } 71 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC6VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | varying vec3 v_light1Direction; 9 | varying vec3 v_position; 10 | uniform mat4 u_light1Transform; 11 | varying vec3 v_light2Direction; 12 | uniform mat4 u_light2Transform; 13 | void main(void) { 14 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 15 | v_normal = u_normalMatrix * a_normal; 16 | v_position = pos.xyz; 17 | v_light1Direction = u_light1Transform[3].xyz - pos.xyz; 18 | v_light2Direction = u_light2Transform[3].xyz - pos.xyz; 19 | gl_Position = u_projectionMatrix * pos; 20 | } 21 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC7FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | uniform vec4 u_diffuse; 5 | uniform vec4 u_emission; 6 | uniform vec4 u_specular; 7 | uniform float u_shininess; 8 | uniform vec3 u_light0Color; 9 | varying vec3 v_light1Direction; 10 | varying vec3 v_position; 11 | uniform float u_light1ConstantAttenuation; 12 | uniform float u_light1LinearAttenuation; 13 | uniform float u_light1QuadraticAttenuation; 14 | uniform vec3 u_light1Color; 15 | varying vec3 v_light2Direction; 16 | uniform float u_light2ConstantAttenuation; 17 | uniform float u_light2LinearAttenuation; 18 | uniform float u_light2QuadraticAttenuation; 19 | uniform vec3 u_light2Color; 20 | void main(void) { 21 | vec3 normal = normalize(v_normal); 22 | vec4 color = vec4(0., 0., 0., 0.); 23 | vec4 diffuse = vec4(0., 0., 0., 1.); 24 | vec3 diffuseLight = vec3(0., 0., 0.); 25 | vec4 emission; 26 | vec4 ambient; 27 | vec4 specular; 28 | ambient = u_ambient; 29 | diffuse = u_diffuse; 30 | emission = u_emission; 31 | specular = u_specular; 32 | vec3 specularLight = vec3(0., 0., 0.); 33 | vec3 ambientLight = vec3(0., 0., 0.); 34 | { 35 | ambientLight += u_light0Color; 36 | } 37 | { 38 | float specularIntensity = 0.; 39 | float attenuation = 1.0; 40 | float range = length(v_light1Direction); 41 | attenuation = 1.0 / ( u_light1ConstantAttenuation + (u_light1LinearAttenuation * range) + (u_light1QuadraticAttenuation * range * range) ) ; 42 | vec3 l = normalize(v_light1Direction); 43 | vec3 viewDir = -normalize(v_position); 44 | vec3 h = normalize(l+viewDir); 45 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 46 | specularLight += u_light1Color * specularIntensity; 47 | diffuseLight += u_light1Color * max(dot(normal,l), 0.) * attenuation; 48 | } 49 | { 50 | float specularIntensity = 0.; 51 | float attenuation = 1.0; 52 | float range = length(v_light2Direction); 53 | attenuation = 1.0 / ( u_light2ConstantAttenuation + (u_light2LinearAttenuation * range) + (u_light2QuadraticAttenuation * range * range) ) ; 54 | vec3 l = normalize(v_light2Direction); 55 | vec3 viewDir = -normalize(v_position); 56 | vec3 h = normalize(l+viewDir); 57 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 58 | specularLight += u_light2Color * specularIntensity; 59 | diffuseLight += u_light2Color * max(dot(normal,l), 0.) * attenuation; 60 | } 61 | ambient.xyz *= ambientLight; 62 | color.xyz += ambient.xyz; 63 | specular.xyz *= specularLight; 64 | color.xyz += specular.xyz; 65 | diffuse.xyz *= diffuseLight; 66 | color.xyz += diffuse.xyz; 67 | color.xyz += emission.xyz; 68 | color = vec4(color.rgb * diffuse.a, diffuse.a); 69 | gl_FragColor = color; 70 | } 71 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/VC7VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | varying vec3 v_light1Direction; 9 | varying vec3 v_position; 10 | uniform mat4 u_light1Transform; 11 | varying vec3 v_light2Direction; 12 | uniform mat4 u_light2Transform; 13 | void main(void) { 14 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 15 | v_normal = u_normalMatrix * a_normal; 16 | v_position = pos.xyz; 17 | v_light1Direction = u_light1Transform[3].xyz - pos.xyz; 18 | v_light2Direction = u_light2Transform[3].xyz - pos.xyz; 19 | gl_Position = u_projectionMatrix * pos; 20 | } 21 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/cockpit-map.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/cockpit-map.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/f22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/f22.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/full.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/full.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/heli.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/heli.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/lights.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/lights.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/machine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/machine.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/prop128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/prop128.png -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/s_01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/s_01.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/s_02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/s_02.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/s_03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/s_03.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/s_04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/s_04.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/s_05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/s_05.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/s_06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/s_06.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/s_07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/s_07.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/s_08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/s_08.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/scrapsurf03-red.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/scrapsurf03-red.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/VC/glTF/surface01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/VC/glTF/surface01.jpg -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/animationTest_01-1_c4d/buffer.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/animationTest_01-1_c4d/buffer.bin -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/animationTest_01_c4d/buffer.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/animationTest_01_c4d/buffer.bin -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/glTF/BoxAnimated.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/glTF/BoxAnimated.bin -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/glTF/BoxAnimated0FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_diffuse; 4 | uniform vec4 u_specular; 5 | uniform float u_shininess; 6 | uniform vec3 u_light0Color; 7 | varying vec3 v_light1Direction; 8 | varying vec3 v_position; 9 | uniform vec3 u_light1Color; 10 | void main(void) { 11 | vec3 normal = normalize(v_normal); 12 | vec4 color = vec4(0., 0., 0., 0.); 13 | vec4 diffuse = vec4(0., 0., 0., 1.); 14 | vec3 diffuseLight = vec3(0., 0., 0.); 15 | vec4 specular; 16 | diffuse = u_diffuse; 17 | specular = u_specular; 18 | vec3 specularLight = vec3(0., 0., 0.); 19 | vec3 ambientLight = vec3(0., 0., 0.); 20 | { 21 | ambientLight += u_light0Color; 22 | } 23 | { 24 | float specularIntensity = 0.; 25 | float attenuation = 1.0; 26 | vec3 l = normalize(v_light1Direction); 27 | vec3 viewDir = -normalize(v_position); 28 | float phongTerm = max(0.0, dot(reflect(-l,normal), viewDir)); 29 | specularIntensity = max(0., pow(phongTerm , u_shininess)) * attenuation; 30 | specularLight += u_light1Color * specularIntensity; 31 | diffuseLight += u_light1Color * max(dot(normal,l), 0.) * attenuation; 32 | } 33 | specular.xyz *= specularLight; 34 | color.xyz += specular.xyz; 35 | diffuse.xyz *= diffuseLight; 36 | color.xyz += diffuse.xyz; 37 | color = vec4(color.rgb * diffuse.a, diffuse.a); 38 | gl_FragColor = color; 39 | } 40 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/glTF/BoxAnimated0VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | varying vec3 v_light1Direction; 9 | varying vec3 v_position; 10 | uniform mat4 u_light1Transform; 11 | void main(void) { 12 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 13 | v_normal = u_normalMatrix * a_normal; 14 | v_position = pos.xyz; 15 | v_light1Direction = mat3(u_light1Transform) * vec3(0.,0.,1.); 16 | gl_Position = u_projectionMatrix * pos; 17 | } 18 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/kickingTires_c4d/buffer.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/kickingTires_c4d/buffer.bin -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/program_0FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float ; 2 | uniform vec4 u_ambient ; 3 | uniform sampler2D u_diffuse ; 4 | uniform vec4 u_emission ; 5 | uniform vec3 u_light0Color ; 6 | varying vec3 v_normal ; 7 | varying vec3 v_position ; 8 | uniform vec4 u_reflective ; 9 | uniform float u_reflectivity ; 10 | uniform float u_shininess ; 11 | uniform vec4 u_specular ; 12 | varying vec2 v_texcoord0 ; 13 | uniform float u_transparency ; 14 | uniform vec4 u_transparent ; 15 | varying vec3 v_light0Direction ; 16 | void main (void) { 17 | vec3 normal =normalize (v_normal) ; 18 | vec4 color =vec4(0., 0., 0., 0.) ; 19 | vec4 diffuse =vec4(0., 0., 0., 1.) ; 20 | vec3 diffuseLight =vec3(0., 0., 0.) ; 21 | vec4 emission ; 22 | vec4 reflective ; 23 | vec4 ambient ; 24 | vec4 specular ; 25 | ambient =u_ambient ; 26 | diffuse =texture2D (u_diffuse, v_texcoord0) ; 27 | emission =u_emission ; 28 | reflective =u_reflective ; 29 | specular =u_specular ; 30 | vec3 specularLight =vec3(0., 0., 0.) ; 31 | { 32 | float specularIntensity =0. ; 33 | float attenuation =1.0 ; 34 | vec3 l =normalize (v_light0Direction) ; 35 | vec3 viewDir =-normalize (v_position) ; 36 | float phongTerm =max (0.0, dot (reflect (-l, normal), viewDir)) ; 37 | specularIntensity =max (0., pow (phongTerm , u_shininess)) * attenuation ; 38 | specularLight +=u_light0Color * specularIntensity ; 39 | diffuseLight +=u_light0Color * max (dot (normal, l), 0.) * attenuation ; 40 | } 41 | diffuse.xyz +=reflective.xyz ; 42 | specular.xyz *=specularLight ; 43 | color.xyz +=specular.xyz ; 44 | diffuse.xyz *=diffuseLight ; 45 | color.xyz +=diffuse.xyz ; 46 | color.xyz +=emission.xyz ; 47 | color =vec4(color.rgb * diffuse.a, diffuse.a * u_transparency) ; 48 | gl_FragColor =color ; 49 | } 50 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/program_0VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float ; 2 | uniform mat4 u_light0Transform ; 3 | uniform mat4 u_modelViewMatrix ; 4 | attribute vec3 a_normal ; 5 | varying vec3 v_normal ; 6 | uniform mat3 u_normalMatrix ; 7 | attribute vec3 a_position ; 8 | varying vec3 v_position ; 9 | uniform mat4 u_projectionMatrix ; 10 | attribute vec2 a_texcoord0 ; 11 | varying vec2 v_texcoord0 ; 12 | varying vec3 v_light0Direction ; 13 | void main (void) { 14 | vec4 pos =u_modelViewMatrix * vec4(a_position, 1.0) ; 15 | v_normal =u_normalMatrix * a_normal ; 16 | v_texcoord0 =a_texcoord0 ; 17 | v_position =pos.xyz ; 18 | v_light0Direction =mat3(u_light0Transform) * vec3(0., 0., 1.) ; 19 | gl_Position =u_projectionMatrix * pos ; 20 | } 21 | -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/UV.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/UV.png -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/buffer.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/buffer.bin -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/image1.png -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/image2.png -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/image3.png -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/image4.png -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/image5.png -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/image6.png -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/image7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/image7.png -------------------------------------------------------------------------------- /samples/BasicAnimation/assets/testSceneForRyan/image8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/assets/testSceneForRyan/image8.png -------------------------------------------------------------------------------- /samples/BasicAnimation/include/Resources.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "cinder/CinderResources.h" 3 | 4 | //#define RES_MY_RES CINDER_RESOURCE( ../resources/, image_name.png, 128, IMAGE ) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/BasicAnimation/proj/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.0 FATAL_ERROR ) 2 | set( CMAKE_VERBOSE_MAKEFILE ON ) 3 | 4 | project( BasicAnimation ) 5 | 6 | get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.." ABSOLUTE ) 7 | get_filename_component( SAMPLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE ) 8 | 9 | include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" ) 10 | 11 | ci_make_app( 12 | SOURCES ${SAMPLE_DIR}/src/BasicAnimationApp.cpp 13 | CINDER_PATH ${CINDER_PATH} 14 | BLOCKS gltf 15 | ) 16 | -------------------------------------------------------------------------------- /samples/BasicAnimation/resources/CinderApp.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/resources/CinderApp.icns -------------------------------------------------------------------------------- /samples/BasicAnimation/resources/CinderApp_ios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/resources/CinderApp_ios.png -------------------------------------------------------------------------------- /samples/BasicAnimation/resources/cinder_app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/resources/cinder_app_icon.ico -------------------------------------------------------------------------------- /samples/BasicAnimation/src/BasicAnimationApp.cpp: -------------------------------------------------------------------------------- 1 | #include "cinder/app/App.h" 2 | #include "cinder/app/RendererGl.h" 3 | #include "cinder/gl/gl.h" 4 | #include "cinder/CameraUi.h" 5 | 6 | #include "cinder/gltf/File.h" 7 | #include "cinder/gltf/MeshLoader.h" 8 | #include "cinder/gltf/SimpleScene.h" 9 | 10 | #include "cinder/Animation.h" 11 | 12 | using namespace ci; 13 | using namespace ci::app; 14 | using namespace std; 15 | 16 | class BasicAnimationApp : public App { 17 | public: 18 | void setup() override; 19 | void keyDown( KeyEvent event ) override; 20 | void update() override; 21 | void draw() override; 22 | 23 | gltf::FileRef mFile; 24 | shared_ptr mScene; 25 | 26 | ci::CameraPersp mCam; 27 | ci::CameraUi mCamUi; 28 | }; 29 | 30 | void BasicAnimationApp::setup() 31 | { 32 | auto kicking = "VC/glTF/VC.gltf"; 33 | mFile = gltf::File::create( loadAsset( kicking ) ); 34 | mScene = make_shared( mFile, &mFile->getDefaultScene() ); 35 | 36 | mCam.setPerspective( 60.0f, getWindowAspectRatio(), 0.01, 100000.0 ); 37 | mCam.lookAt( vec3( 0, 0, -6.0 ), vec3( 0 ) ); 38 | 39 | mCamUi.setCamera( &mCam ); 40 | mCamUi.connect( getWindow() ); 41 | } 42 | 43 | void BasicAnimationApp::keyDown( KeyEvent event ) 44 | { 45 | static uint32_t currentCamera = 0; 46 | bool chooseCamera = false; 47 | if( event.getCode() == KeyEvent::KEY_SPACE ) 48 | mScene->toggleAnimation(); 49 | else if( event.getCode() == KeyEvent::KEY_LEFT ) { 50 | int32_t camera = currentCamera; 51 | currentCamera = glm::clamp( --camera, 0, (int32_t)mScene->numCameras() - 1 ); 52 | chooseCamera = true; 53 | } 54 | else if( event.getCode() == KeyEvent::KEY_RIGHT ) { 55 | int32_t camera = currentCamera; 56 | currentCamera = glm::clamp( ++camera, 0, (int32_t)mScene->numCameras() - 1 ); 57 | chooseCamera = true; 58 | } 59 | 60 | if( chooseCamera ) 61 | mScene->selectCamera( currentCamera ); 62 | } 63 | 64 | void BasicAnimationApp::update() 65 | { 66 | mScene->update(); 67 | } 68 | 69 | void BasicAnimationApp::draw() 70 | { 71 | gl::clear( Color( 0, 0, 0 ) ); 72 | gl::setMatrices( mCam ); 73 | 74 | gl::ScopedDepth scopeDepth( true ); 75 | mScene->renderScene(); 76 | } 77 | 78 | CINDER_APP( BasicAnimationApp, RendererGl( RendererGl::Options().msaa( 16 ) ) ) 79 | -------------------------------------------------------------------------------- /samples/BasicAnimation/vc2013/BasicAnimation.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BasicAnimation", "BasicAnimation.vcxproj", "{A3BBEBAB-B584-406E-AF58-292BCFBBA551}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x64 = Debug|x64 9 | Release|x64 = Release|x64 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {A3BBEBAB-B584-406E-AF58-292BCFBBA551}.Debug|x64.ActiveCfg = Debug|x64 13 | {A3BBEBAB-B584-406E-AF58-292BCFBBA551}.Debug|x64.Build.0 = Debug|x64 14 | {A3BBEBAB-B584-406E-AF58-292BCFBBA551}.Release|x64.ActiveCfg = Release|x64 15 | {A3BBEBAB-B584-406E-AF58-292BCFBBA551}.Release|x64.Build.0 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /samples/BasicAnimation/vc2013/BasicAnimation.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x64 6 | 7 | 8 | Release 9 | x64 10 | 11 | 12 | 13 | {A3BBEBAB-B584-406E-AF58-292BCFBBA551} 14 | BasicAnimation 15 | Win32Proj 16 | 17 | 18 | 19 | Application 20 | false 21 | v120 22 | Unicode 23 | true 24 | 25 | 26 | Application 27 | true 28 | v120 29 | Unicode 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | <_ProjectFileVersion>10.0.30319.1 42 | true 43 | false 44 | 45 | 46 | 47 | Disabled 48 | ..\include;"..\..\..\..\..\include";..\..\..\src 49 | WIN32;_WIN32_WINNT=0x0601;_WINDOWS;NOMINMAX;_DEBUG;%(PreprocessorDefinitions) 50 | EnableFastChecks 51 | MultiThreadedDebug 52 | 53 | Level3 54 | ProgramDatabase 55 | true 56 | 57 | 58 | "..\..\..\..\..\include";..\include 59 | 60 | 61 | cinder-$(PlatformToolset)_d.lib;OpenGL32.lib;%(AdditionalDependencies) 62 | "..\..\..\..\..\lib\msw\$(PlatformTarget)" 63 | true 64 | Windows 65 | false 66 | 67 | LIBCMT;LIBCPMT 68 | 69 | 70 | 71 | 72 | ..\include;"..\..\..\..\..\include";..\..\..\src 73 | WIN32;_WIN32_WINNT=0x0601;_WINDOWS;NOMINMAX;NDEBUG;%(PreprocessorDefinitions) 74 | MultiThreaded 75 | 76 | Level3 77 | ProgramDatabase 78 | true 79 | 80 | 81 | true 82 | 83 | 84 | "..\..\..\..\..\include";..\include 85 | 86 | 87 | cinder-$(PlatformToolset).lib;OpenGL32.lib;%(AdditionalDependencies) 88 | "..\..\..\..\..\lib\msw\$(PlatformTarget)" 89 | false 90 | true 91 | Windows 92 | true 93 | 94 | false 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /samples/BasicAnimation/vc2013/BasicAnimation.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 6 | 7 | 8 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | 11 | 12 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 14 | 15 | 16 | {62203D88-4CC2-4831-A490-19E95B278294} 17 | 18 | 19 | {09606C4D-809B-4C97-B8B1-A2EF29A6487C} 20 | 21 | 22 | {61E02EC1-29ED-4D8B-A575-D5D1951FF106} 23 | 24 | 25 | {1990F553-6D7E-439E-9EF3-A137784A895B} 26 | 27 | 28 | {2535F82A-2673-4302-A549-3B8814481C03} 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Blocks\GLTF\src\cinder 43 | 44 | 45 | Blocks\GLTF\src\cinder\gltf 46 | 47 | 48 | Blocks\GLTF\src\cinder\gltf 49 | 50 | 51 | Blocks\GLTF\src\cinder\gltf 52 | 53 | 54 | Blocks\GLTF\src\cinder 55 | 56 | 57 | Blocks\GLTF\src\cinder 58 | 59 | 60 | Blocks\GLTF\src\cinder 61 | 62 | 63 | Blocks\GLTF\src\cinder\gltf 64 | 65 | 66 | Blocks\GLTF\src\cinder\gltf 67 | 68 | 69 | Blocks\GLTF\src\cinder\gltf 70 | 71 | 72 | 73 | 74 | Header Files 75 | 76 | 77 | 78 | 79 | Resource Files 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /samples/BasicAnimation/vc2013/Resources.rc: -------------------------------------------------------------------------------- 1 | #include "../include/Resources.h" 2 | 3 | 1 ICON "..\\resources\\cinder_app_icon.ico" 4 | -------------------------------------------------------------------------------- /samples/BasicAnimation/xcode/BasicAnimation_Prefix.pch: -------------------------------------------------------------------------------- 1 | #if defined( __cplusplus ) 2 | #include "cinder/Cinder.h" 3 | 4 | #include "cinder/app/App.h" 5 | 6 | #include "cinder/gl/gl.h" 7 | 8 | #include "cinder/CinderMath.h" 9 | #include "cinder/Matrix.h" 10 | #include "cinder/Vector.h" 11 | #include "cinder/Quaternion.h" 12 | #endif 13 | -------------------------------------------------------------------------------- /samples/BasicAnimation/xcode/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | CinderApp.icns 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2015 __MyCompanyName__. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /samples/BasicAnimation/xcode_ios/BasicAnimation_Prefix.pch: -------------------------------------------------------------------------------- 1 | #if defined( __cplusplus ) 2 | #include "cinder/Cinder.h" 3 | 4 | #include "cinder/app/App.h" 5 | 6 | #include "cinder/gl/gl.h" 7 | 8 | #include "cinder/CinderMath.h" 9 | #include "cinder/Matrix.h" 10 | #include "cinder/Vector.h" 11 | #include "cinder/Quaternion.h" 12 | #endif -------------------------------------------------------------------------------- /samples/BasicAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "8.0", 8 | "subtype" : "736h", 9 | "filename" : "Default-736h@3x~iphone.png", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "orientation" : "landscape", 14 | "idiom" : "iphone", 15 | "extent" : "full-screen", 16 | "minimum-system-version" : "8.0", 17 | "subtype" : "736h", 18 | "scale" : "3x" 19 | }, 20 | { 21 | "extent" : "full-screen", 22 | "idiom" : "iphone", 23 | "subtype" : "667h", 24 | "filename" : "Default-667@2x.png", 25 | "minimum-system-version" : "8.0", 26 | "orientation" : "portrait", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "orientation" : "portrait", 31 | "idiom" : "iphone", 32 | "extent" : "full-screen", 33 | "minimum-system-version" : "7.0", 34 | "scale" : "2x" 35 | }, 36 | { 37 | "extent" : "full-screen", 38 | "idiom" : "iphone", 39 | "subtype" : "retina4", 40 | "filename" : "Default-568h@2x.png", 41 | "minimum-system-version" : "7.0", 42 | "orientation" : "portrait", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "orientation" : "portrait", 47 | "idiom" : "ipad", 48 | "extent" : "full-screen", 49 | "minimum-system-version" : "7.0", 50 | "scale" : "1x" 51 | }, 52 | { 53 | "orientation" : "landscape", 54 | "idiom" : "ipad", 55 | "extent" : "full-screen", 56 | "minimum-system-version" : "7.0", 57 | "scale" : "1x" 58 | }, 59 | { 60 | "orientation" : "portrait", 61 | "idiom" : "ipad", 62 | "extent" : "full-screen", 63 | "minimum-system-version" : "7.0", 64 | "scale" : "2x" 65 | }, 66 | { 67 | "orientation" : "landscape", 68 | "idiom" : "ipad", 69 | "extent" : "full-screen", 70 | "minimum-system-version" : "7.0", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "orientation" : "portrait", 75 | "idiom" : "iphone", 76 | "extent" : "full-screen", 77 | "scale" : "1x" 78 | }, 79 | { 80 | "orientation" : "portrait", 81 | "idiom" : "iphone", 82 | "extent" : "full-screen", 83 | "scale" : "2x" 84 | }, 85 | { 86 | "orientation" : "portrait", 87 | "idiom" : "iphone", 88 | "extent" : "full-screen", 89 | "filename" : "Default-568h@2x.png", 90 | "subtype" : "retina4", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "orientation" : "portrait", 95 | "idiom" : "ipad", 96 | "extent" : "to-status-bar", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "orientation" : "portrait", 101 | "idiom" : "ipad", 102 | "extent" : "to-status-bar", 103 | "scale" : "2x" 104 | } 105 | ], 106 | "info" : { 107 | "version" : 1, 108 | "author" : "xcode" 109 | } 110 | } -------------------------------------------------------------------------------- /samples/BasicAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /samples/BasicAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-667@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-667@2x.png -------------------------------------------------------------------------------- /samples/BasicAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-736h@3x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-736h@3x~iphone.png -------------------------------------------------------------------------------- /samples/BasicAnimation/xcode_ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | UILaunchStoryboardName 8 | LaunchScreen.xib 9 | CFBundleDisplayName 10 | ${PRODUCT_NAME} 11 | CFBundleExecutable 12 | ${EXECUTABLE_NAME} 13 | CFBundleIconFile 14 | 15 | CFBundleIcons 16 | 17 | CFBundlePrimaryIcon 18 | 19 | CFBundleIconFiles 20 | 21 | 22 | CinderApp_ios.png 23 | 24 | UIPrerenderedIcon 25 | 26 | 27 | 28 | CFBundleIdentifier 29 | org.libcinder.${PRODUCT_NAME:rfc1034identifier} 30 | CFBundleInfoDictionaryVersion 31 | 6.0 32 | CFBundleName 33 | ${PRODUCT_NAME} 34 | CFBundlePackageType 35 | APPL 36 | CFBundleShortVersionString 37 | 1.0 38 | CFBundleSignature 39 | ???? 40 | CFBundleVersion 41 | 1 42 | LSRequiresIPhoneOS 43 | 44 | NSMainNibFile 45 | 46 | NSMainNibFile~ipad 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /samples/BasicAnimation/xcode_ios/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/README.txt: -------------------------------------------------------------------------------- 1 | Copyright 2006 Sony Computer Entertainment Inc. 2 | 3 | Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: 4 | 5 | http://research.scea.com/scea_shared_source_license.html 6 | 7 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/collada/DuckCM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/assets/Duck/collada/DuckCM.png -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/glTF-Binary/Duck.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/assets/Duck/glTF-Binary/Duck.glb -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/glTF-MaterialsCommon/Duck.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/assets/Duck/glTF-MaterialsCommon/Duck.bin -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/glTF-MaterialsCommon/Duck.gltf: -------------------------------------------------------------------------------- 1 | { 2 | "accessors": { 3 | "accessor_21": { 4 | "bufferView": "bufferView_29", 5 | "byteOffset": 0, 6 | "byteStride": 0, 7 | "componentType": 5123, 8 | "count": 12636, 9 | "type": "SCALAR" 10 | }, 11 | "accessor_23": { 12 | "bufferView": "bufferView_30", 13 | "byteOffset": 0, 14 | "byteStride": 12, 15 | "componentType": 5126, 16 | "count": 2399, 17 | "max": [ 18 | 0.961799, 19 | 1.6397, 20 | 0.539252 21 | ], 22 | "min": [ 23 | -0.692985, 24 | 0.0992937, 25 | -0.613282 26 | ], 27 | "type": "VEC3" 28 | }, 29 | "accessor_25": { 30 | "bufferView": "bufferView_30", 31 | "byteOffset": 28788, 32 | "byteStride": 12, 33 | "componentType": 5126, 34 | "count": 2399, 35 | "max": [ 36 | 0.999599, 37 | 0.999581, 38 | 0.998436 39 | ], 40 | "min": [ 41 | -0.999084, 42 | -1, 43 | -0.999832 44 | ], 45 | "type": "VEC3" 46 | }, 47 | "accessor_27": { 48 | "bufferView": "bufferView_30", 49 | "byteOffset": 57576, 50 | "byteStride": 8, 51 | "componentType": 5126, 52 | "count": 2399, 53 | "max": [ 54 | 0.983346, 55 | 0.980037 56 | ], 57 | "min": [ 58 | 0.026409, 59 | 0.019963 60 | ], 61 | "type": "VEC2" 62 | } 63 | }, 64 | "animations": {}, 65 | "asset": { 66 | "generator": "collada2gltf@027f74366341d569dea42e9a68b7104cc3892054", 67 | "premultipliedAlpha": true, 68 | "profile": { 69 | "api": "WebGL", 70 | "version": "1.0.2" 71 | }, 72 | "version": "1.0" 73 | }, 74 | "bufferViews": { 75 | "bufferView_29": { 76 | "buffer": "Duck", 77 | "byteLength": 25272, 78 | "byteOffset": 0, 79 | "target": 34963 80 | }, 81 | "bufferView_30": { 82 | "buffer": "Duck", 83 | "byteLength": 76768, 84 | "byteOffset": 25272, 85 | "target": 34962 86 | } 87 | }, 88 | "buffers": { 89 | "Duck": { 90 | "byteLength": 102040, 91 | "type": "arraybuffer", 92 | "uri": "Duck.bin" 93 | } 94 | }, 95 | "cameras": { 96 | "cameraShape1": { 97 | "name": "cameraShape1", 98 | "perspective": { 99 | "aspectRatio": 1.5, 100 | "yfov": 0.660593, 101 | "zfar": 100, 102 | "znear": 0.01 103 | }, 104 | "type": "perspective" 105 | } 106 | }, 107 | "extensions": { 108 | "KHR_materials_common": { 109 | "lights": { 110 | "directionalLightShape1-lib": { 111 | "directional": { 112 | "color": [ 113 | 1, 114 | 1, 115 | 1 116 | ] 117 | }, 118 | "name": "directionalLightShape1", 119 | "type": "directional" 120 | } 121 | } 122 | } 123 | }, 124 | "extensionsUsed": [ 125 | "KHR_materials_common" 126 | ], 127 | "images": { 128 | "file2": { 129 | "name": "file2", 130 | "uri": "DuckCM.png" 131 | } 132 | }, 133 | "materials": { 134 | "blinn3-fx": { 135 | "extensions": { 136 | "KHR_materials_common": { 137 | "doubleSided": false, 138 | "jointCount": 0, 139 | "technique": "BLINN", 140 | "transparent": false, 141 | "values": { 142 | "ambient": [ 143 | 0, 144 | 0, 145 | 0, 146 | 1 147 | ], 148 | "diffuse": "texture_file2", 149 | "emission": [ 150 | 0, 151 | 0, 152 | 0, 153 | 1 154 | ], 155 | "shininess": 38.4, 156 | "specular": [ 157 | 0, 158 | 0, 159 | 0, 160 | 1 161 | ] 162 | } 163 | } 164 | }, 165 | "name": "blinn3" 166 | } 167 | }, 168 | "meshes": { 169 | "LOD3spShape-lib": { 170 | "name": "LOD3spShape", 171 | "primitives": [ 172 | { 173 | "attributes": { 174 | "NORMAL": "accessor_25", 175 | "POSITION": "accessor_23", 176 | "TEXCOORD_0": "accessor_27" 177 | }, 178 | "indices": "accessor_21", 179 | "material": "blinn3-fx", 180 | "mode": 4 181 | } 182 | ] 183 | } 184 | }, 185 | "nodes": { 186 | "LOD3sp": { 187 | "children": [], 188 | "matrix": [ 189 | 1, 190 | 0, 191 | 0, 192 | 0, 193 | 0, 194 | 1, 195 | 0, 196 | 0, 197 | 0, 198 | 0, 199 | 1, 200 | 0, 201 | 0, 202 | 0, 203 | 0, 204 | 1 205 | ], 206 | "meshes": [ 207 | "LOD3spShape-lib" 208 | ], 209 | "name": "LOD3sp" 210 | }, 211 | "camera1": { 212 | "camera": "cameraShape1", 213 | "children": [], 214 | "matrix": [ 215 | -0.728969, 216 | 0, 217 | -0.684547, 218 | 0, 219 | -0.425205, 220 | 0.783693, 221 | 0.452797, 222 | 0, 223 | 0.536475, 224 | 0.621148, 225 | -0.571288, 226 | 0, 227 | 4.00113, 228 | 4.63264, 229 | -4.31078, 230 | 1 231 | ], 232 | "name": "camera1" 233 | }, 234 | "directionalLight1": { 235 | "children": [], 236 | "extensions": { 237 | "KHR_materials_common": { 238 | "light": "directionalLightShape1-lib" 239 | } 240 | }, 241 | "matrix": [ 242 | -0.954692, 243 | 0.218143, 244 | -0.202429, 245 | 0, 246 | 0.014672, 247 | 0.713885, 248 | 0.700109, 249 | 0, 250 | 0.297235, 251 | 0.665418, 252 | -0.684741, 253 | 0, 254 | 1.48654, 255 | 1.83672, 256 | -2.92179, 257 | 1 258 | ], 259 | "name": "directionalLight1" 260 | } 261 | }, 262 | "samplers": { 263 | "sampler_0": { 264 | "magFilter": 9729, 265 | "minFilter": 9987, 266 | "wrapS": 10497, 267 | "wrapT": 10497 268 | } 269 | }, 270 | "scene": "defaultScene", 271 | "scenes": { 272 | "defaultScene": { 273 | "nodes": [ 274 | "LOD3sp", 275 | "camera1", 276 | "directionalLight1" 277 | ] 278 | } 279 | }, 280 | "skins": {}, 281 | "textures": { 282 | "texture_file2": { 283 | "format": 6408, 284 | "internalFormat": 6408, 285 | "sampler": "sampler_0", 286 | "source": "file2", 287 | "target": 3553, 288 | "type": 5121 289 | } 290 | } 291 | } -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/glTF-MaterialsCommon/DuckCM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/assets/Duck/glTF-MaterialsCommon/DuckCM.png -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/glTF/Duck.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/assets/Duck/glTF/Duck.bin -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/glTF/Duck.gltf: -------------------------------------------------------------------------------- 1 | { 2 | "accessors": { 3 | "accessor_21": { 4 | "bufferView": "bufferView_29", 5 | "byteOffset": 0, 6 | "byteStride": 0, 7 | "componentType": 5123, 8 | "count": 12636, 9 | "type": "SCALAR" 10 | }, 11 | "accessor_23": { 12 | "bufferView": "bufferView_30", 13 | "byteOffset": 0, 14 | "byteStride": 12, 15 | "componentType": 5126, 16 | "count": 2399, 17 | "max": [ 18 | 0.961799, 19 | 1.6397, 20 | 0.539252 21 | ], 22 | "min": [ 23 | -0.692985, 24 | 0.0992937, 25 | -0.613282 26 | ], 27 | "type": "VEC3" 28 | }, 29 | "accessor_25": { 30 | "bufferView": "bufferView_30", 31 | "byteOffset": 28788, 32 | "byteStride": 12, 33 | "componentType": 5126, 34 | "count": 2399, 35 | "max": [ 36 | 0.999599, 37 | 0.999581, 38 | 0.998436 39 | ], 40 | "min": [ 41 | -0.999084, 42 | -1, 43 | -0.999832 44 | ], 45 | "type": "VEC3" 46 | }, 47 | "accessor_27": { 48 | "bufferView": "bufferView_30", 49 | "byteOffset": 57576, 50 | "byteStride": 8, 51 | "componentType": 5126, 52 | "count": 2399, 53 | "max": [ 54 | 0.983346, 55 | 0.980037 56 | ], 57 | "min": [ 58 | 0.026409, 59 | 0.019963 60 | ], 61 | "type": "VEC2" 62 | } 63 | }, 64 | "animations": {}, 65 | "asset": { 66 | "generator": "collada2gltf@027f74366341d569dea42e9a68b7104cc3892054", 67 | "premultipliedAlpha": true, 68 | "profile": { 69 | "api": "WebGL", 70 | "version": "1.0.2" 71 | }, 72 | "version": "1.0" 73 | }, 74 | "bufferViews": { 75 | "bufferView_29": { 76 | "buffer": "Duck", 77 | "byteLength": 25272, 78 | "byteOffset": 0, 79 | "target": 34963 80 | }, 81 | "bufferView_30": { 82 | "buffer": "Duck", 83 | "byteLength": 76768, 84 | "byteOffset": 25272, 85 | "target": 34962 86 | } 87 | }, 88 | "buffers": { 89 | "Duck": { 90 | "byteLength": 102040, 91 | "type": "arraybuffer", 92 | "uri": "Duck.bin" 93 | } 94 | }, 95 | "cameras": { 96 | "cameraShape1": { 97 | "name": "cameraShape1", 98 | "perspective": { 99 | "aspectRatio": 1.5, 100 | "yfov": 0.660593, 101 | "zfar": 100, 102 | "znear": 0.01 103 | }, 104 | "type": "perspective" 105 | } 106 | }, 107 | "images": { 108 | "file2": { 109 | "name": "file2", 110 | "uri": "DuckCM.png" 111 | } 112 | }, 113 | "materials": { 114 | "blinn3-fx": { 115 | "name": "blinn3", 116 | "technique": "technique0", 117 | "values": { 118 | "ambient": [ 119 | 0, 120 | 0, 121 | 0, 122 | 1 123 | ], 124 | "diffuse": "texture_file2", 125 | "emission": [ 126 | 0, 127 | 0, 128 | 0, 129 | 1 130 | ], 131 | "shininess": 38.4, 132 | "specular": [ 133 | 0, 134 | 0, 135 | 0, 136 | 1 137 | ] 138 | } 139 | } 140 | }, 141 | "meshes": { 142 | "LOD3spShape-lib": { 143 | "name": "LOD3spShape", 144 | "primitives": [ 145 | { 146 | "attributes": { 147 | "NORMAL": "accessor_25", 148 | "POSITION": "accessor_23", 149 | "TEXCOORD_0": "accessor_27" 150 | }, 151 | "indices": "accessor_21", 152 | "material": "blinn3-fx", 153 | "mode": 4 154 | } 155 | ] 156 | } 157 | }, 158 | "nodes": { 159 | "LOD3sp": { 160 | "children": [], 161 | "matrix": [ 162 | 1, 163 | 0, 164 | 0, 165 | 0, 166 | 0, 167 | 1, 168 | 0, 169 | 0, 170 | 0, 171 | 0, 172 | 1, 173 | 0, 174 | 0, 175 | 0, 176 | 0, 177 | 1 178 | ], 179 | "meshes": [ 180 | "LOD3spShape-lib" 181 | ], 182 | "name": "LOD3sp" 183 | }, 184 | "camera1": { 185 | "camera": "cameraShape1", 186 | "children": [], 187 | "matrix": [ 188 | -0.728969, 189 | 0, 190 | -0.684547, 191 | 0, 192 | -0.425205, 193 | 0.783693, 194 | 0.452797, 195 | 0, 196 | 0.536475, 197 | 0.621148, 198 | -0.571288, 199 | 0, 200 | 4.00113, 201 | 4.63264, 202 | -4.31078, 203 | 1 204 | ], 205 | "name": "camera1" 206 | }, 207 | "directionalLight1": { 208 | "children": [], 209 | "matrix": [ 210 | -0.954692, 211 | 0.218143, 212 | -0.202429, 213 | 0, 214 | 0.014672, 215 | 0.713885, 216 | 0.700109, 217 | 0, 218 | 0.297235, 219 | 0.665418, 220 | -0.684741, 221 | 0, 222 | 1.48654, 223 | 1.83672, 224 | -2.92179, 225 | 1 226 | ], 227 | "name": "directionalLight1" 228 | } 229 | }, 230 | "programs": { 231 | "program_0": { 232 | "attributes": [ 233 | "a_normal", 234 | "a_position", 235 | "a_texcoord0" 236 | ], 237 | "fragmentShader": "Duck0FS", 238 | "vertexShader": "Duck0VS" 239 | } 240 | }, 241 | "samplers": { 242 | "sampler_0": { 243 | "magFilter": 9729, 244 | "minFilter": 9987, 245 | "wrapS": 10497, 246 | "wrapT": 10497 247 | } 248 | }, 249 | "scene": "defaultScene", 250 | "scenes": { 251 | "defaultScene": { 252 | "nodes": [ 253 | "LOD3sp", 254 | "camera1", 255 | "directionalLight1" 256 | ] 257 | } 258 | }, 259 | "shaders": { 260 | "Duck0FS": { 261 | "type": 35632, 262 | "uri": "Duck0FS.glsl" 263 | }, 264 | "Duck0VS": { 265 | "type": 35633, 266 | "uri": "Duck0VS.glsl" 267 | } 268 | }, 269 | "skins": {}, 270 | "techniques": { 271 | "technique0": { 272 | "attributes": { 273 | "a_normal": "normal", 274 | "a_position": "position", 275 | "a_texcoord0": "texcoord0" 276 | }, 277 | "parameters": { 278 | "ambient": { 279 | "type": 35666 280 | }, 281 | "diffuse": { 282 | "type": 35678 283 | }, 284 | "emission": { 285 | "type": 35666 286 | }, 287 | "light0Color": { 288 | "type": 35665, 289 | "value": [ 290 | 1, 291 | 1, 292 | 1 293 | ] 294 | }, 295 | "light0Transform": { 296 | "node": "directionalLight1", 297 | "semantic": "MODELVIEW", 298 | "type": 35676 299 | }, 300 | "modelViewMatrix": { 301 | "semantic": "MODELVIEW", 302 | "type": 35676 303 | }, 304 | "normal": { 305 | "semantic": "NORMAL", 306 | "type": 35665 307 | }, 308 | "normalMatrix": { 309 | "semantic": "MODELVIEWINVERSETRANSPOSE", 310 | "type": 35675 311 | }, 312 | "position": { 313 | "semantic": "POSITION", 314 | "type": 35665 315 | }, 316 | "projectionMatrix": { 317 | "semantic": "PROJECTION", 318 | "type": 35676 319 | }, 320 | "shininess": { 321 | "type": 5126 322 | }, 323 | "specular": { 324 | "type": 35666 325 | }, 326 | "texcoord0": { 327 | "semantic": "TEXCOORD_0", 328 | "type": 35664 329 | } 330 | }, 331 | "program": "program_0", 332 | "states": { 333 | "enable": [ 334 | 2929, 335 | 2884 336 | ] 337 | }, 338 | "uniforms": { 339 | "u_ambient": "ambient", 340 | "u_diffuse": "diffuse", 341 | "u_emission": "emission", 342 | "u_light0Color": "light0Color", 343 | "u_light0Transform": "light0Transform", 344 | "u_modelViewMatrix": "modelViewMatrix", 345 | "u_normalMatrix": "normalMatrix", 346 | "u_projectionMatrix": "projectionMatrix", 347 | "u_shininess": "shininess", 348 | "u_specular": "specular" 349 | } 350 | } 351 | }, 352 | "textures": { 353 | "texture_file2": { 354 | "format": 6408, 355 | "internalFormat": 6408, 356 | "sampler": "sampler_0", 357 | "source": "file2", 358 | "target": 3553, 359 | "type": 5121 360 | } 361 | } 362 | } -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/glTF/Duck0FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | varying vec2 v_texcoord0; 5 | uniform sampler2D u_diffuse; 6 | uniform vec4 u_emission; 7 | uniform vec4 u_specular; 8 | uniform float u_shininess; 9 | varying vec3 v_light0Direction; 10 | varying vec3 v_position; 11 | uniform vec3 u_light0Color; 12 | void main(void) { 13 | vec3 normal = normalize(v_normal); 14 | vec4 color = vec4(0., 0., 0., 0.); 15 | vec4 diffuse = vec4(0., 0., 0., 1.); 16 | vec3 diffuseLight = vec3(0., 0., 0.); 17 | vec4 emission; 18 | vec4 ambient; 19 | vec4 specular; 20 | ambient = u_ambient; 21 | diffuse = texture2D(u_diffuse, v_texcoord0); 22 | emission = u_emission; 23 | specular = u_specular; 24 | vec3 specularLight = vec3(0., 0., 0.); 25 | { 26 | float specularIntensity = 0.; 27 | float attenuation = 1.0; 28 | vec3 l = normalize(v_light0Direction); 29 | vec3 viewDir = -normalize(v_position); 30 | vec3 h = normalize(l+viewDir); 31 | specularIntensity = max(0., pow(max(dot(normal,h), 0.) , u_shininess)) * attenuation; 32 | specularLight += u_light0Color * specularIntensity; 33 | diffuseLight += u_light0Color * max(dot(normal,l), 0.) * attenuation; 34 | } 35 | specular.xyz *= specularLight; 36 | color.xyz += specular.xyz; 37 | diffuse.xyz *= diffuseLight; 38 | color.xyz += diffuse.xyz; 39 | color.xyz += emission.xyz; 40 | color = vec4(color.rgb * diffuse.a, diffuse.a); 41 | gl_FragColor = color; 42 | } 43 | -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/glTF/Duck0VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | uniform mat3 u_normalMatrix; 6 | uniform mat4 u_modelViewMatrix; 7 | uniform mat4 u_projectionMatrix; 8 | attribute vec2 a_texcoord0; 9 | varying vec2 v_texcoord0; 10 | varying vec3 v_light0Direction; 11 | varying vec3 v_position; 12 | uniform mat4 u_light0Transform; 13 | void main(void) { 14 | vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); 15 | v_normal = u_normalMatrix * a_normal; 16 | v_texcoord0 = a_texcoord0; 17 | v_position = pos.xyz; 18 | v_light0Direction = mat3(u_light0Transform) * vec3(0.,0.,1.); 19 | gl_Position = u_projectionMatrix * pos; 20 | } 21 | -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/glTF/DuckCM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/assets/Duck/glTF/DuckCM.png -------------------------------------------------------------------------------- /samples/BasicLoading/assets/Duck/screenshot/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/assets/Duck/screenshot/screenshot.png -------------------------------------------------------------------------------- /samples/BasicLoading/include/Resources.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "cinder/CinderResources.h" 3 | 4 | //#define RES_MY_RES CINDER_RESOURCE( ../resources/, image_name.png, 128, IMAGE ) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/BasicLoading/proj/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.0 FATAL_ERROR ) 2 | set( CMAKE_VERBOSE_MAKEFILE ON ) 3 | 4 | project( BasicLoading ) 5 | 6 | get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.." ABSOLUTE ) 7 | get_filename_component( SAMPLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE ) 8 | 9 | include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" ) 10 | 11 | ci_make_app( 12 | SOURCES ${SAMPLE_DIR}/src/BasicLoadingApp.cpp 13 | CINDER_PATH ${CINDER_PATH} 14 | BLOCKS gltf 15 | ) 16 | -------------------------------------------------------------------------------- /samples/BasicLoading/resources/CinderApp.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/resources/CinderApp.icns -------------------------------------------------------------------------------- /samples/BasicLoading/resources/CinderApp_ios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/resources/CinderApp_ios.png -------------------------------------------------------------------------------- /samples/BasicLoading/resources/cinder_app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/resources/cinder_app_icon.ico -------------------------------------------------------------------------------- /samples/BasicLoading/src/BasicLoadingApp.cpp: -------------------------------------------------------------------------------- 1 | #include "cinder/app/App.h" 2 | #include "cinder/app/RendererGl.h" 3 | #include "cinder/gl/gl.h" 4 | 5 | #include "cinder/CameraUi.h" 6 | 7 | #include "cinder/gltf/File.h" 8 | #include "cinder/gltf/MeshLoader.h" 9 | 10 | using namespace ci; 11 | using namespace ci::app; 12 | using namespace std; 13 | 14 | class BasicLoadingApp : public App { 15 | public: 16 | void setup() override; 17 | void mouseDown( MouseEvent event ) override; 18 | void update() override; 19 | void draw() override; 20 | 21 | gltf::FileRef mFile; 22 | gl::BatchRef mBatch; 23 | gl::Texture2dRef mTex; 24 | 25 | ci::CameraPersp mCam; 26 | ci::CameraUi mCamUi; 27 | }; 28 | 29 | void BasicLoadingApp::setup() 30 | { 31 | mFile = gltf::File::create( loadAsset( "Duck/glTF/Duck.gltf" ) ); 32 | 33 | auto loader = gltf::MeshLoader( &mFile->getMeshInfo( "LOD3spShape-lib" ) ); 34 | mBatch = gl::Batch::create( loader, gl::getStockShader( gl::ShaderDef().color().texture() ) ); 35 | 36 | auto image = mFile->getImageInfo("file2").getImage(); 37 | mTex = gl::Texture2d::create( image, gl::Texture2d::Format().loadTopDown() ); 38 | 39 | mCam.setPerspective( 60.0f, getWindowAspectRatio(), 0.01f, 1000.0f ); 40 | mCam.lookAt( vec3( 0, 0, -5 ), vec3( 0 ) ); 41 | mCamUi.setCamera( &mCam ); 42 | mCamUi.connect( getWindow() ); 43 | } 44 | 45 | void BasicLoadingApp::mouseDown( MouseEvent event ) 46 | { 47 | } 48 | 49 | void BasicLoadingApp::update() 50 | { 51 | } 52 | 53 | void BasicLoadingApp::draw() 54 | { 55 | gl::clear( Color( 0, 0, 0 ) ); 56 | 57 | gl::setMatrices( mCam ); 58 | 59 | gl::ScopedDepth scopeDepth( true ); 60 | gl::ScopedTextureBind scopeTex( mTex ); 61 | 62 | mBatch->draw(); 63 | } 64 | 65 | CINDER_APP( BasicLoadingApp, RendererGl ) 66 | -------------------------------------------------------------------------------- /samples/BasicLoading/vc2013/BasicLoading.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BasicLoading", "BasicLoading.vcxproj", "{887F011F-8C6B-4664-9207-91548B453CD5}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x64 = Debug|x64 9 | Release|x64 = Release|x64 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {887F011F-8C6B-4664-9207-91548B453CD5}.Debug|x64.ActiveCfg = Debug|x64 13 | {887F011F-8C6B-4664-9207-91548B453CD5}.Debug|x64.Build.0 = Debug|x64 14 | {887F011F-8C6B-4664-9207-91548B453CD5}.Release|x64.ActiveCfg = Release|x64 15 | {887F011F-8C6B-4664-9207-91548B453CD5}.Release|x64.Build.0 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /samples/BasicLoading/vc2013/BasicLoading.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | {887F011F-8C6B-4664-9207-91548B453CD5} 15 | BasicLoading 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | false 22 | v120 23 | Unicode 24 | true 25 | 26 | 27 | Application 28 | true 29 | v120 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | <_ProjectFileVersion>10.0.30319.1 43 | true 44 | false 45 | 46 | 47 | 48 | Disabled 49 | ..\include;"..\..\..\..\..\include";..\..\..\src 50 | WIN32;_WIN32_WINNT=0x0601;_WINDOWS;NOMINMAX;_DEBUG;%(PreprocessorDefinitions) 51 | EnableFastChecks 52 | MultiThreadedDebug 53 | 54 | Level3 55 | ProgramDatabase 56 | true 57 | false 58 | 59 | 60 | "..\..\..\..\..\include";..\include 61 | 62 | 63 | cinder-$(PlatformToolset)_d.lib;OpenGL32.lib;%(AdditionalDependencies) 64 | "..\..\..\..\..\lib\msw\$(PlatformTarget)" 65 | true 66 | Windows 67 | false 68 | 69 | LIBCMT;LIBCPMT 70 | 71 | 72 | 73 | 74 | ..\include;"..\..\..\..\..\include";..\..\..\src 75 | WIN32;_WIN32_WINNT=0x0601;_WINDOWS;NOMINMAX;NDEBUG;%(PreprocessorDefinitions) 76 | MultiThreaded 77 | 78 | Level3 79 | ProgramDatabase 80 | true 81 | 82 | 83 | true 84 | 85 | 86 | "..\..\..\..\..\include";..\include 87 | 88 | 89 | cinder-$(PlatformToolset).lib;OpenGL32.lib;%(AdditionalDependencies) 90 | "..\..\..\..\..\lib\msw\$(PlatformTarget)" 91 | false 92 | true 93 | Windows 94 | true 95 | 96 | false 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /samples/BasicLoading/vc2013/BasicLoading.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 6 | 7 | 8 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | 11 | 12 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 14 | 15 | 16 | {C996A70F-A754-4C52-ADBB-0BBE396A4D0E} 17 | 18 | 19 | {219D8364-F3A6-4D66-A686-10097C63B7B6} 20 | 21 | 22 | {D4FE1EAC-E9AD-4E8A-A4EA-A70834B221B1} 23 | 24 | 25 | {6CCACBD6-0A29-4410-BC8B-A91A293164E4} 26 | 27 | 28 | {181C0E4D-9F93-4643-8A58-ED71E4FF8E4F} 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Blocks\GLTF\src\cinder 43 | 44 | 45 | Blocks\GLTF\src\cinder\gltf 46 | 47 | 48 | Blocks\GLTF\src\cinder\gltf 49 | 50 | 51 | Blocks\GLTF\src\cinder\gltf 52 | 53 | 54 | Blocks\GLTF\src\cinder 55 | 56 | 57 | Blocks\GLTF\src\cinder 58 | 59 | 60 | Blocks\GLTF\src\cinder 61 | 62 | 63 | Blocks\GLTF\src\cinder\gltf 64 | 65 | 66 | Blocks\GLTF\src\cinder\gltf 67 | 68 | 69 | Blocks\GLTF\src\cinder\gltf 70 | 71 | 72 | 73 | 74 | Header Files 75 | 76 | 77 | 78 | 79 | Resource Files 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /samples/BasicLoading/vc2013/Resources.rc: -------------------------------------------------------------------------------- 1 | #include "../include/Resources.h" 2 | 3 | 1 ICON "..\\resources\\cinder_app_icon.ico" 4 | -------------------------------------------------------------------------------- /samples/BasicLoading/xcode/BasicLoading_Prefix.pch: -------------------------------------------------------------------------------- 1 | #if defined( __cplusplus ) 2 | #include "cinder/Cinder.h" 3 | 4 | #include "cinder/app/App.h" 5 | 6 | #include "cinder/gl/gl.h" 7 | 8 | #include "cinder/CinderMath.h" 9 | #include "cinder/Matrix.h" 10 | #include "cinder/Vector.h" 11 | #include "cinder/Quaternion.h" 12 | #endif 13 | -------------------------------------------------------------------------------- /samples/BasicLoading/xcode/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | CinderApp.icns 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2015 __MyCompanyName__. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /samples/BasicLoading/xcode_ios/BasicLoading_Prefix.pch: -------------------------------------------------------------------------------- 1 | #if defined( __cplusplus ) 2 | #include "cinder/Cinder.h" 3 | 4 | #include "cinder/app/App.h" 5 | 6 | #include "cinder/gl/gl.h" 7 | 8 | #include "cinder/CinderMath.h" 9 | #include "cinder/Matrix.h" 10 | #include "cinder/Vector.h" 11 | #include "cinder/Quaternion.h" 12 | #endif -------------------------------------------------------------------------------- /samples/BasicLoading/xcode_ios/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "8.0", 8 | "subtype" : "736h", 9 | "filename" : "Default-736h@3x~iphone.png", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "orientation" : "landscape", 14 | "idiom" : "iphone", 15 | "extent" : "full-screen", 16 | "minimum-system-version" : "8.0", 17 | "subtype" : "736h", 18 | "scale" : "3x" 19 | }, 20 | { 21 | "extent" : "full-screen", 22 | "idiom" : "iphone", 23 | "subtype" : "667h", 24 | "filename" : "Default-667@2x.png", 25 | "minimum-system-version" : "8.0", 26 | "orientation" : "portrait", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "orientation" : "portrait", 31 | "idiom" : "iphone", 32 | "extent" : "full-screen", 33 | "minimum-system-version" : "7.0", 34 | "scale" : "2x" 35 | }, 36 | { 37 | "extent" : "full-screen", 38 | "idiom" : "iphone", 39 | "subtype" : "retina4", 40 | "filename" : "Default-568h@2x.png", 41 | "minimum-system-version" : "7.0", 42 | "orientation" : "portrait", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "orientation" : "portrait", 47 | "idiom" : "ipad", 48 | "extent" : "full-screen", 49 | "minimum-system-version" : "7.0", 50 | "scale" : "1x" 51 | }, 52 | { 53 | "orientation" : "landscape", 54 | "idiom" : "ipad", 55 | "extent" : "full-screen", 56 | "minimum-system-version" : "7.0", 57 | "scale" : "1x" 58 | }, 59 | { 60 | "orientation" : "portrait", 61 | "idiom" : "ipad", 62 | "extent" : "full-screen", 63 | "minimum-system-version" : "7.0", 64 | "scale" : "2x" 65 | }, 66 | { 67 | "orientation" : "landscape", 68 | "idiom" : "ipad", 69 | "extent" : "full-screen", 70 | "minimum-system-version" : "7.0", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "orientation" : "portrait", 75 | "idiom" : "iphone", 76 | "extent" : "full-screen", 77 | "scale" : "1x" 78 | }, 79 | { 80 | "orientation" : "portrait", 81 | "idiom" : "iphone", 82 | "extent" : "full-screen", 83 | "scale" : "2x" 84 | }, 85 | { 86 | "orientation" : "portrait", 87 | "idiom" : "iphone", 88 | "extent" : "full-screen", 89 | "filename" : "Default-568h@2x.png", 90 | "subtype" : "retina4", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "orientation" : "portrait", 95 | "idiom" : "ipad", 96 | "extent" : "to-status-bar", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "orientation" : "portrait", 101 | "idiom" : "ipad", 102 | "extent" : "to-status-bar", 103 | "scale" : "2x" 104 | } 105 | ], 106 | "info" : { 107 | "version" : 1, 108 | "author" : "xcode" 109 | } 110 | } -------------------------------------------------------------------------------- /samples/BasicLoading/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /samples/BasicLoading/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-667@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-667@2x.png -------------------------------------------------------------------------------- /samples/BasicLoading/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-736h@3x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/BasicLoading/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-736h@3x~iphone.png -------------------------------------------------------------------------------- /samples/BasicLoading/xcode_ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | UILaunchStoryboardName 8 | LaunchScreen.xib 9 | CFBundleDisplayName 10 | ${PRODUCT_NAME} 11 | CFBundleExecutable 12 | ${EXECUTABLE_NAME} 13 | CFBundleIconFile 14 | 15 | CFBundleIcons 16 | 17 | CFBundlePrimaryIcon 18 | 19 | CFBundleIconFiles 20 | 21 | 22 | CinderApp_ios.png 23 | 24 | UIPrerenderedIcon 25 | 26 | 27 | 28 | CFBundleIdentifier 29 | org.libcinder.${PRODUCT_NAME:rfc1034identifier} 30 | CFBundleInfoDictionaryVersion 31 | 6.0 32 | CFBundleName 33 | ${PRODUCT_NAME} 34 | CFBundlePackageType 35 | APPL 36 | CFBundleShortVersionString 37 | 1.0 38 | CFBundleSignature 39 | ???? 40 | CFBundleVersion 41 | 1 42 | LSRequiresIPhoneOS 43 | 44 | NSMainNibFile 45 | 46 | NSMainNibFile~ipad 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /samples/BasicLoading/xcode_ios/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/README.txt: -------------------------------------------------------------------------------- 1 | Donated by Cesium for glTF testing. Please follow the Cesium Trademark Terms and Conditions: https://github.com/AnalyticalGraphicsInc/cesium/wiki/CesiumTrademark.pdf -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/collada/CesiumMan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/collada/CesiumMan.jpg -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/collada/Cesium_Man.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/collada/Cesium_Man.jpg -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF-Binary/CesiumMan.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF-Binary/CesiumMan.glb -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF-Binary/Cesium_Man.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF-Binary/Cesium_Man.glb -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF-MaterialsCommon/CesiumMan.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF-MaterialsCommon/CesiumMan.bin -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF-MaterialsCommon/CesiumMan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF-MaterialsCommon/CesiumMan.jpg -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF-MaterialsCommon/Cesium_Man.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF-MaterialsCommon/Cesium_Man.bin -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF-MaterialsCommon/Cesium_Man.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF-MaterialsCommon/Cesium_Man.jpg -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF/CesiumMan.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF/CesiumMan.bin -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF/CesiumMan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF/CesiumMan.jpg -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF/CesiumMan0FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | varying vec2 v_texcoord0; 5 | uniform sampler2D u_diffuse; 6 | uniform vec4 u_emission; 7 | uniform vec4 u_specular; 8 | uniform float u_shininess; 9 | void main(void) { 10 | vec3 normal = normalize(v_normal); 11 | vec4 color = vec4(0., 0., 0., 0.); 12 | vec4 diffuse = vec4(0., 0., 0., 1.); 13 | vec4 emission; 14 | vec4 ambient; 15 | vec4 specular; 16 | ambient = u_ambient; 17 | diffuse = texture2D(u_diffuse, v_texcoord0); 18 | emission = u_emission; 19 | specular = u_specular; 20 | diffuse.xyz *= max(dot(normal,vec3(0.,0.,1.)), 0.); 21 | color.xyz += diffuse.xyz; 22 | color.xyz += emission.xyz; 23 | color = vec4(color.rgb * diffuse.a, diffuse.a); 24 | gl_FragColor = color; 25 | } 26 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF/CesiumMan0VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | attribute vec4 a_joint; 6 | attribute vec4 a_weight; 7 | uniform mat4 u_jointMat[19]; 8 | uniform mat3 u_normalMatrix; 9 | uniform mat4 u_modelViewMatrix; 10 | uniform mat4 u_projectionMatrix; 11 | attribute vec2 a_texcoord0; 12 | varying vec2 v_texcoord0; 13 | void main(void) { 14 | mat4 skinMat = a_weight.x * u_jointMat[int(a_joint.x)]; 15 | skinMat += a_weight.y * u_jointMat[int(a_joint.y)]; 16 | skinMat += a_weight.z * u_jointMat[int(a_joint.z)]; 17 | skinMat += a_weight.w * u_jointMat[int(a_joint.w)]; 18 | vec4 pos = u_modelViewMatrix * skinMat * vec4(a_position,1.0); 19 | v_normal = u_normalMatrix * mat3(skinMat)* a_normal; 20 | v_texcoord0 = a_texcoord0; 21 | gl_Position = u_projectionMatrix * pos; 22 | } 23 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF/Cesium_Man.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF/Cesium_Man.bin -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF/Cesium_Man.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/glTF/Cesium_Man.jpg -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF/Cesium_Man0FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | varying vec2 v_texcoord0; 5 | uniform sampler2D u_diffuse; 6 | uniform vec4 u_emission; 7 | uniform vec4 u_specular; 8 | uniform float u_shininess; 9 | void main(void) { 10 | vec3 normal = normalize(v_normal); 11 | vec4 color = vec4(0., 0., 0., 0.); 12 | vec4 diffuse = vec4(0., 0., 0., 1.); 13 | vec4 emission; 14 | vec4 ambient; 15 | vec4 specular; 16 | ambient = u_ambient; 17 | diffuse = texture2D(u_diffuse, v_texcoord0); 18 | emission = u_emission; 19 | specular = u_specular; 20 | diffuse.xyz *= max(dot(normal,vec3(0.,0.,1.)), 0.); 21 | color.xyz += diffuse.xyz; 22 | color.xyz += emission.xyz; 23 | color = vec4(color.rgb * diffuse.a, diffuse.a); 24 | gl_FragColor = color; 25 | } 26 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/glTF/Cesium_Man0VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | attribute vec4 a_joint; 6 | attribute vec4 a_weight; 7 | uniform mat4 u_jointMat[19]; 8 | uniform mat3 u_normalMatrix; 9 | uniform mat4 u_modelViewMatrix; 10 | uniform mat4 u_projectionMatrix; 11 | attribute vec2 a_texcoord0; 12 | varying vec2 v_texcoord0; 13 | void main(void) { 14 | mat4 skinMat = a_weight.x * u_jointMat[int(a_joint.x)]; 15 | skinMat += a_weight.y * u_jointMat[int(a_joint.y)]; 16 | skinMat += a_weight.z * u_jointMat[int(a_joint.z)]; 17 | skinMat += a_weight.w * u_jointMat[int(a_joint.w)]; 18 | vec4 pos = u_modelViewMatrix * skinMat * vec4(a_position,1.0); 19 | v_normal = u_normalMatrix * mat3(skinMat)* a_normal; 20 | v_texcoord0 = a_texcoord0; 21 | gl_Position = u_projectionMatrix * pos; 22 | } 23 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/screenshot/screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/screenshot/screenshot.gif -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/CesiumMan/screenshot/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/CesiumMan/screenshot/screenshot.png -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/brainsteam/glTF-Binary/Brainsteam.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/brainsteam/glTF-Binary/Brainsteam.glb -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/brainsteam/glTF-MaterialsCommon/Brainsteam.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/brainsteam/glTF-MaterialsCommon/Brainsteam.bin -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/brainsteam/glTF/Brainsteam.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/brainsteam/glTF/Brainsteam.bin -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/brainsteam/glTF/Brainsteam0FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | uniform vec4 u_diffuse; 5 | uniform vec4 u_emission; 6 | uniform vec4 u_specular; 7 | void main(void) { 8 | vec3 normal = normalize(v_normal); 9 | vec4 color = vec4(0., 0., 0., 0.); 10 | vec4 diffuse = vec4(0., 0., 0., 1.); 11 | vec4 emission; 12 | vec4 ambient; 13 | vec4 specular; 14 | ambient = u_ambient; 15 | diffuse = u_diffuse; 16 | emission = u_emission; 17 | specular = u_specular; 18 | diffuse.xyz *= max(dot(normal,vec3(0.,0.,1.)), 0.); 19 | color.xyz += diffuse.xyz; 20 | color.xyz += emission.xyz; 21 | color = vec4(color.rgb * diffuse.a, diffuse.a); 22 | gl_FragColor = color; 23 | } 24 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/brainsteam/glTF/Brainsteam0VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | attribute vec4 a_joint; 6 | attribute vec4 a_weight; 7 | uniform mat4 u_jointMat[18]; 8 | uniform mat3 u_normalMatrix; 9 | uniform mat4 u_modelViewMatrix; 10 | uniform mat4 u_projectionMatrix; 11 | void main(void) { 12 | mat4 skinMat = a_weight.x * u_jointMat[int(a_joint.x)]; 13 | skinMat += a_weight.y * u_jointMat[int(a_joint.y)]; 14 | skinMat += a_weight.z * u_jointMat[int(a_joint.z)]; 15 | skinMat += a_weight.w * u_jointMat[int(a_joint.w)]; 16 | vec4 pos = u_modelViewMatrix * skinMat * vec4(a_position,1.0); 17 | v_normal = u_normalMatrix * mat3(skinMat)* a_normal; 18 | gl_Position = u_projectionMatrix * pos; 19 | } 20 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/brainsteam/screenshot/screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/brainsteam/screenshot/screenshot.gif -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/brainsteam/screenshot/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/brainsteam/screenshot/screenshot.png -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/collada/Monster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/monster/collada/Monster.jpg -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/glTF-Binary/Monster.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/monster/glTF-Binary/Monster.glb -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/glTF-MaterialsCommon/Monster.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/monster/glTF-MaterialsCommon/Monster.bin -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/glTF-MaterialsCommon/Monster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/monster/glTF-MaterialsCommon/Monster.jpg -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/glTF/Monster.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/monster/glTF/Monster.bin -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/glTF/Monster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/monster/glTF/Monster.jpg -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/glTF/Monster0FS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | varying vec3 v_normal; 3 | uniform vec4 u_ambient; 4 | varying vec2 v_texcoord0; 5 | uniform sampler2D u_diffuse; 6 | uniform vec4 u_emission; 7 | uniform vec4 u_specular; 8 | uniform float u_shininess; 9 | void main(void) { 10 | vec3 normal = normalize(v_normal); 11 | vec4 color = vec4(0., 0., 0., 0.); 12 | vec4 diffuse = vec4(0., 0., 0., 1.); 13 | vec4 emission; 14 | vec4 ambient; 15 | vec4 specular; 16 | ambient = u_ambient; 17 | diffuse = texture2D(u_diffuse, v_texcoord0); 18 | emission = u_emission; 19 | specular = u_specular; 20 | diffuse.xyz *= max(dot(normal,vec3(0.,0.,1.)), 0.); 21 | color.xyz += diffuse.xyz; 22 | color.xyz += emission.xyz; 23 | color = vec4(color.rgb * diffuse.a, diffuse.a); 24 | gl_FragColor = color; 25 | } 26 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/glTF/monster0VS.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | attribute vec3 a_position; 3 | attribute vec3 a_normal; 4 | varying vec3 v_normal; 5 | attribute vec4 a_joint; 6 | attribute vec4 a_weight; 7 | uniform mat4 u_jointMat[32]; 8 | uniform mat3 u_normalMatrix; 9 | uniform mat4 u_modelViewMatrix; 10 | uniform mat4 u_projectionMatrix; 11 | attribute vec2 a_texcoord0; 12 | varying vec2 v_texcoord0; 13 | void main(void) { 14 | mat4 skinMat = a_weight.x * u_jointMat[int(a_joint.x)]; 15 | skinMat += a_weight.y * u_jointMat[int(a_joint.y)]; 16 | skinMat += a_weight.z * u_jointMat[int(a_joint.z)]; 17 | skinMat += a_weight.w * u_jointMat[int(a_joint.w)]; 18 | vec4 pos = u_modelViewMatrix * skinMat * vec4(a_position,1.0); 19 | v_normal = u_normalMatrix * mat3(skinMat)* a_normal; 20 | v_texcoord0 = a_texcoord0; 21 | gl_Position = u_projectionMatrix * pos; 22 | } 23 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/readme.txt: -------------------------------------------------------------------------------- 1 | Model from http://www.3drt.com/downloads.htm 2 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/screenshot/screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/monster/screenshot/screenshot.gif -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/monster/screenshot/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/assets/monster/screenshot/screenshot.png -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/skeletal.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec3 vNormal; 4 | 5 | out vec4 oColor; 6 | 7 | uniform vec4 u_ambient = vec4( 0.2, 0.2, 0.2, 1.0 ); 8 | uniform vec4 u_emission = vec4( .6, .3, .1, 1.0 ); 9 | uniform vec4 u_specular = vec4( 1.0, 1.0, 1.0, 1.0 ); 10 | uniform float u_shininess = 128.0; 11 | 12 | void main(void) { 13 | vec3 normal = normalize(vNormal); 14 | vec4 color = vec4(0., 0., 0., 0.); 15 | vec4 diffuse = vec4(.6, .6, .6, 1.); 16 | vec4 emission; 17 | vec4 ambient; 18 | vec4 specular; 19 | ambient = u_ambient; 20 | emission = u_emission; 21 | specular = u_specular; 22 | diffuse.xyz *= max(dot(normal,vec3(0.,0.,1.)), 0.); 23 | color.xyz += diffuse.xyz; 24 | color.xyz += emission.xyz; 25 | color = vec4(color.rgb * diffuse.a, diffuse.a); 26 | oColor = color; 27 | } 28 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/assets/skeletal.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec3 ciPosition; 4 | in vec3 ciNormal; 5 | in vec4 ciBoneIndex; 6 | in vec4 ciBoneWeight; 7 | 8 | uniform mat4 uJointMat[64]; 9 | uniform mat3 ciNormalMatrix; 10 | uniform mat4 ciModelViewProjection; 11 | 12 | out vec3 vNormal; 13 | 14 | void main(void) { 15 | mat4 skinMat = ciBoneWeight.x * uJointMat[int(ciBoneIndex.x)]; 16 | skinMat += ciBoneWeight.y * uJointMat[int(ciBoneIndex.y)]; 17 | skinMat += ciBoneWeight.z * uJointMat[int(ciBoneIndex.z)]; 18 | skinMat += ciBoneWeight.w * uJointMat[int(ciBoneIndex.w)]; 19 | gl_Position = ciModelViewProjection * skinMat * vec4(ciPosition,1.0); 20 | 21 | vNormal = ciNormalMatrix * mat3(skinMat)* ciNormal; 22 | } 23 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/include/Resources.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "cinder/CinderResources.h" 3 | 4 | //#define RES_MY_RES CINDER_RESOURCE( ../resources/, image_name.png, 128, IMAGE ) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/proj/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.0 FATAL_ERROR ) 2 | set( CMAKE_VERBOSE_MAKEFILE ON ) 3 | 4 | project( SkeletalAnimation ) 5 | 6 | get_filename_component( CINDER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.." ABSOLUTE ) 7 | get_filename_component( SAMPLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE ) 8 | 9 | include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" ) 10 | 11 | ci_make_app( 12 | SOURCES ${SAMPLE_DIR}/src/SkeletalAnimationApp.cpp 13 | CINDER_PATH ${CINDER_PATH} 14 | BLOCKS gltf 15 | ) 16 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/resources/CinderApp.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/resources/CinderApp.icns -------------------------------------------------------------------------------- /samples/SkeletalAnimation/resources/CinderApp_ios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/resources/CinderApp_ios.png -------------------------------------------------------------------------------- /samples/SkeletalAnimation/resources/cinder_app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/resources/cinder_app_icon.ico -------------------------------------------------------------------------------- /samples/SkeletalAnimation/src/SkeletalAnimationApp.cpp: -------------------------------------------------------------------------------- 1 | #include "cinder/app/App.h" 2 | #include "cinder/app/RendererGl.h" 3 | #include "cinder/gl/gl.h" 4 | #include "cinder/CameraUi.h" 5 | 6 | #include "cinder/gltf/File.h" 7 | #include "cinder/gltf/MeshLoader.h" 8 | #include "cinder/Skeleton.h" 9 | 10 | using namespace ci; 11 | using namespace ci::app; 12 | using namespace std; 13 | 14 | #define USE_SKELETON_ANIM 0 15 | 16 | class SkeletalAnimationApp : public App { 17 | public: 18 | void setup() override; 19 | void keyDown( KeyEvent event ) override; 20 | void update() override; 21 | void draw() override; 22 | 23 | void loadFromFile( const fs::path &path, const string &nodeName ); 24 | 25 | vector> gltf; 26 | 27 | CameraPersp mCam; 28 | CameraUi mCamUi; 29 | 30 | gl::BatchRef mBatch, mPose; 31 | gl::GlslProgRef mGlsl; 32 | 33 | mat4 mModelMatrix; 34 | 35 | SkeletonRef mSkeleton; 36 | Skeleton::AnimRef mSkeletonAnim; 37 | std::vector mSkeletonTransClip; 38 | std::vector localTransforms, offsetsSkel, offsetsRend; 39 | 40 | shared_ptr mSkelRend; 41 | 42 | bool mPause = false, mRenderMesh = true, 43 | mRenderSkel = false, mRenderPose = false; 44 | int32_t mGltfIndex = 0; 45 | }; 46 | 47 | void SkeletalAnimationApp::setup() 48 | { 49 | mSkelRend.reset( new SkeletonRenderer() ); 50 | 51 | mCam.setPerspective( 60.0f, getWindowAspectRatio(), .01f, 10000.0f ); 52 | mCam.lookAt( vec3( 0, 0, -5 ), vec3( 0 ) ); 53 | mCam.setPivotDistance( 5 ); 54 | mCamUi.setCamera( &mCam ); 55 | mCamUi.connect( getWindow() ); 56 | 57 | gl::enableDepthRead(); 58 | gl::enableDepthWrite(); 59 | 60 | mGlsl = gl::GlslProg::create( gl::GlslProg::Format() 61 | .vertex( loadAsset( "skeletal.vert" ) ) 62 | .fragment( loadAsset( "skeletal.frag" ) ) ); 63 | 64 | gltf.emplace_back( fs::path( "monster" ) / "glTF" / "Monster.gltf", "monster" ); 65 | gltf.emplace_back( fs::path( "CesiumMan" ) / "glTF" / "Cesium_Man.gltf", "Cesium_Man" ); 66 | gltf.emplace_back( fs::path( "brainsteam" ) / "glTF" / "Brainsteam.gltf", "Figure_2_node" ); 67 | 68 | auto &initial = gltf[0]; 69 | loadFromFile( initial.first, initial.second ); 70 | } 71 | 72 | void SkeletalAnimationApp::loadFromFile( const fs::path &path, const std::string &nodeName ) 73 | { 74 | auto fileAsset = loadAsset( path ); 75 | auto file = gltf::File::create( fileAsset ); 76 | 77 | auto &node = file->getNodeInfo( nodeName ); 78 | auto &meshes = node.meshes; 79 | 80 | const auto &skin = node.skin; 81 | mSkeleton = skin->createSkeleton(); 82 | mSkeletonTransClip = file->createSkeletonTransformClip( mSkeleton ); 83 | mSkeletonAnim = make_shared( mSkeletonTransClip ); 84 | 85 | geom::SourceMods geomCombo; 86 | ci::AxisAlignedBox aabb; 87 | for( auto mesh : meshes ) { 88 | auto geomSource = gltf::MeshLoader( mesh ); 89 | aabb.include( mesh->getPositionAABB() ); 90 | geomCombo &= geomSource; 91 | } 92 | 93 | mBatch = gl::Batch::create( geomCombo, mGlsl ); 94 | mPose = gl::Batch::create( geomCombo, gl::getStockShader( gl::ShaderDef() ) ); 95 | 96 | mModelMatrix = node.getHeirarchyTransform(); 97 | 98 | if( nodeName == "monster" ) 99 | mModelMatrix = mModelMatrix * (ci::translate( vec3( -1.0f, 0.0f, 0.3f ) ) * 100 | ci::scale( vec3( 0.001f ) ) ); 101 | else if( nodeName == "Figure_2_node" ) 102 | mModelMatrix = mat4(); 103 | } 104 | 105 | void SkeletalAnimationApp::keyDown( KeyEvent event ) 106 | { 107 | switch ( event.getCode() ) { 108 | case KeyEvent::KEY_SPACE: mPause = !mPause; return; 109 | case KeyEvent::KEY_RIGHT: mGltfIndex = (mGltfIndex + 1) % gltf.size(); break; 110 | case KeyEvent::KEY_LEFT: mGltfIndex = (mGltfIndex - 1) % gltf.size(); break; 111 | case KeyEvent::KEY_p: mRenderPose = !mRenderPose; return; 112 | case KeyEvent::KEY_m: mRenderMesh = !mRenderMesh; return; 113 | case KeyEvent::KEY_s: mRenderSkel = !mRenderSkel; return; 114 | case KeyEvent::KEY_r: mCam.lookAt( vec3( 0, 0, -10 ), vec3( 0 ) ); return; 115 | default: return; 116 | } 117 | 118 | const auto &next = gltf[mGltfIndex]; 119 | loadFromFile( next.first, next.second ); 120 | } 121 | 122 | void SkeletalAnimationApp::update() 123 | { 124 | localTransforms.clear(); 125 | #if USE_SKELETON_ANIM 126 | mSkeletonAnim->getLoopedLocal( getElapsedSeconds(), &localTransforms ); 127 | #else 128 | for( auto &transClip : mSkeletonTransClip ) 129 | localTransforms.emplace_back( transClip.getMatrixLooped( getElapsedSeconds() ) ); 130 | #endif 131 | 132 | mSkeleton->calcGlobalMatrices( localTransforms, &offsetsSkel ); 133 | mSkeleton->calcMatrixPaletteFromLocal( localTransforms, &offsetsRend ); 134 | } 135 | 136 | void SkeletalAnimationApp::draw() 137 | { 138 | gl::clear( Color( 0, 0, 0 ) ); 139 | 140 | gl::setMatrices( mCam ); 141 | 142 | gl::ScopedModelMatrix scopeModel; 143 | gl::setModelMatrix( mModelMatrix ); 144 | 145 | if( ! mRenderPose ) { 146 | if( mRenderMesh ) { 147 | auto &glsl = mBatch->getGlslProg(); 148 | glsl->uniform( "uJointMat", offsetsRend.data(), static_cast( offsetsRend.size() ) ); 149 | mBatch->draw(); 150 | } 151 | if( mRenderSkel ) 152 | mSkelRend->draw( *mSkeleton, offsetsSkel ); 153 | } 154 | else { 155 | if( mRenderMesh ) 156 | mPose->draw(); 157 | if( mRenderSkel ) 158 | mSkelRend->draw( *mSkeleton ); 159 | } 160 | } 161 | 162 | CINDER_APP( SkeletalAnimationApp, RendererGl ) 163 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/vc2013/Resources.rc: -------------------------------------------------------------------------------- 1 | #include "../include/Resources.h" 2 | 3 | 1 ICON "..\\resources\\cinder_app_icon.ico" 4 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/vc2013/SkeletalAnimation.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SkeletalAnimation", "SkeletalAnimation.vcxproj", "{933D2E9F-AD59-4F4B-B428-A9D7912B9F1F}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x64 = Debug|x64 9 | Release|x64 = Release|x64 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {933D2E9F-AD59-4F4B-B428-A9D7912B9F1F}.Debug|x64.ActiveCfg = Debug|x64 13 | {933D2E9F-AD59-4F4B-B428-A9D7912B9F1F}.Debug|x64.Build.0 = Debug|x64 14 | {933D2E9F-AD59-4F4B-B428-A9D7912B9F1F}.Release|x64.ActiveCfg = Release|x64 15 | {933D2E9F-AD59-4F4B-B428-A9D7912B9F1F}.Release|x64.Build.0 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/vc2013/SkeletalAnimation.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | {933D2E9F-AD59-4F4B-B428-A9D7912B9F1F} 15 | SkeletalAnimation 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | false 22 | v120 23 | Unicode 24 | true 25 | 26 | 27 | Application 28 | true 29 | v120 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | <_ProjectFileVersion>10.0.30319.1 43 | true 44 | false 45 | 46 | 47 | 48 | Disabled 49 | ..\include;"..\..\..\..\..\include";..\..\..\src 50 | WIN32;_WIN32_WINNT=0x0601;_WINDOWS;NOMINMAX;_DEBUG;%(PreprocessorDefinitions) 51 | EnableFastChecks 52 | MultiThreadedDebug 53 | 54 | Level3 55 | ProgramDatabase 56 | true 57 | false 58 | 59 | 60 | "..\..\..\..\..\include";..\include 61 | 62 | 63 | cinder-$(PlatformToolset)_d.lib;OpenGL32.lib;%(AdditionalDependencies) 64 | "..\..\..\..\..\lib\msw\$(PlatformTarget)" 65 | true 66 | Windows 67 | false 68 | 69 | LIBCMT;LIBCPMT 70 | 71 | 72 | 73 | 74 | ..\include;"..\..\..\..\..\include";..\..\..\src 75 | WIN32;_WIN32_WINNT=0x0601;_WINDOWS;NOMINMAX;NDEBUG;%(PreprocessorDefinitions) 76 | MultiThreaded 77 | 78 | Level3 79 | ProgramDatabase 80 | true 81 | 82 | 83 | true 84 | 85 | 86 | "..\..\..\..\..\include";..\include 87 | 88 | 89 | cinder-$(PlatformToolset).lib;OpenGL32.lib;%(AdditionalDependencies) 90 | "..\..\..\..\..\lib\msw\$(PlatformTarget)" 91 | false 92 | true 93 | Windows 94 | true 95 | 96 | false 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/vc2013/SkeletalAnimation.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 6 | 7 | 8 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | 11 | 12 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 14 | 15 | 16 | {FCBCF4AA-7C58-478A-A436-E97886AEBE0B} 17 | 18 | 19 | {841B3CD3-196A-4677-959C-3F92CEE4895B} 20 | 21 | 22 | {D9393E70-E13E-4453-814C-BDD4BF7EF03A} 23 | 24 | 25 | {59081770-A8EE-4FC6-AC9A-CA6C0956BAFD} 26 | 27 | 28 | {92EED9E1-BEF7-4815-BA56-D522A9414229} 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Blocks\GLTF\src\cinder 43 | 44 | 45 | Blocks\GLTF\src\cinder\gltf 46 | 47 | 48 | Blocks\GLTF\src\cinder\gltf 49 | 50 | 51 | Blocks\GLTF\src\cinder\gltf 52 | 53 | 54 | Blocks\GLTF\src\cinder 55 | 56 | 57 | Blocks\GLTF\src\cinder 58 | 59 | 60 | Blocks\GLTF\src\cinder 61 | 62 | 63 | Blocks\GLTF\src\cinder\gltf 64 | 65 | 66 | Blocks\GLTF\src\cinder\gltf 67 | 68 | 69 | Blocks\GLTF\src\cinder\gltf 70 | 71 | 72 | 73 | 74 | Header Files 75 | 76 | 77 | 78 | 79 | Resource Files 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/xcode/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | CinderApp.icns 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2015 __MyCompanyName__. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/xcode/SkeletalAnimation_Prefix.pch: -------------------------------------------------------------------------------- 1 | #if defined( __cplusplus ) 2 | #include "cinder/Cinder.h" 3 | 4 | #include "cinder/app/App.h" 5 | 6 | #include "cinder/gl/gl.h" 7 | 8 | #include "cinder/CinderMath.h" 9 | #include "cinder/Matrix.h" 10 | #include "cinder/Vector.h" 11 | #include "cinder/Quaternion.h" 12 | #endif 13 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "8.0", 8 | "subtype" : "736h", 9 | "filename" : "Default-736h@3x~iphone.png", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "orientation" : "landscape", 14 | "idiom" : "iphone", 15 | "extent" : "full-screen", 16 | "minimum-system-version" : "8.0", 17 | "subtype" : "736h", 18 | "scale" : "3x" 19 | }, 20 | { 21 | "extent" : "full-screen", 22 | "idiom" : "iphone", 23 | "subtype" : "667h", 24 | "filename" : "Default-667@2x.png", 25 | "minimum-system-version" : "8.0", 26 | "orientation" : "portrait", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "orientation" : "portrait", 31 | "idiom" : "iphone", 32 | "extent" : "full-screen", 33 | "minimum-system-version" : "7.0", 34 | "scale" : "2x" 35 | }, 36 | { 37 | "extent" : "full-screen", 38 | "idiom" : "iphone", 39 | "subtype" : "retina4", 40 | "filename" : "Default-568h@2x.png", 41 | "minimum-system-version" : "7.0", 42 | "orientation" : "portrait", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "orientation" : "portrait", 47 | "idiom" : "ipad", 48 | "extent" : "full-screen", 49 | "minimum-system-version" : "7.0", 50 | "scale" : "1x" 51 | }, 52 | { 53 | "orientation" : "landscape", 54 | "idiom" : "ipad", 55 | "extent" : "full-screen", 56 | "minimum-system-version" : "7.0", 57 | "scale" : "1x" 58 | }, 59 | { 60 | "orientation" : "portrait", 61 | "idiom" : "ipad", 62 | "extent" : "full-screen", 63 | "minimum-system-version" : "7.0", 64 | "scale" : "2x" 65 | }, 66 | { 67 | "orientation" : "landscape", 68 | "idiom" : "ipad", 69 | "extent" : "full-screen", 70 | "minimum-system-version" : "7.0", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "orientation" : "portrait", 75 | "idiom" : "iphone", 76 | "extent" : "full-screen", 77 | "scale" : "1x" 78 | }, 79 | { 80 | "orientation" : "portrait", 81 | "idiom" : "iphone", 82 | "extent" : "full-screen", 83 | "scale" : "2x" 84 | }, 85 | { 86 | "orientation" : "portrait", 87 | "idiom" : "iphone", 88 | "extent" : "full-screen", 89 | "filename" : "Default-568h@2x.png", 90 | "subtype" : "retina4", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "orientation" : "portrait", 95 | "idiom" : "ipad", 96 | "extent" : "to-status-bar", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "orientation" : "portrait", 101 | "idiom" : "ipad", 102 | "extent" : "to-status-bar", 103 | "scale" : "2x" 104 | } 105 | ], 106 | "info" : { 107 | "version" : 1, 108 | "author" : "xcode" 109 | } 110 | } -------------------------------------------------------------------------------- /samples/SkeletalAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /samples/SkeletalAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-667@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-667@2x.png -------------------------------------------------------------------------------- /samples/SkeletalAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-736h@3x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanbartley/gltf/8e41da87291876f8dccc71e7041a4cb3b73d1155/samples/SkeletalAnimation/xcode_ios/Images.xcassets/LaunchImage.launchimage/Default-736h@3x~iphone.png -------------------------------------------------------------------------------- /samples/SkeletalAnimation/xcode_ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | UILaunchStoryboardName 8 | LaunchScreen.xib 9 | CFBundleDisplayName 10 | ${PRODUCT_NAME} 11 | CFBundleExecutable 12 | ${EXECUTABLE_NAME} 13 | CFBundleIconFile 14 | 15 | CFBundleIcons 16 | 17 | CFBundlePrimaryIcon 18 | 19 | CFBundleIconFiles 20 | 21 | 22 | CinderApp_ios.png 23 | 24 | UIPrerenderedIcon 25 | 26 | 27 | 28 | CFBundleIdentifier 29 | org.libcinder.${PRODUCT_NAME:rfc1034identifier} 30 | CFBundleInfoDictionaryVersion 31 | 6.0 32 | CFBundleName 33 | ${PRODUCT_NAME} 34 | CFBundlePackageType 35 | APPL 36 | CFBundleShortVersionString 37 | 1.0 38 | CFBundleSignature 39 | ???? 40 | CFBundleVersion 41 | 1 42 | LSRequiresIPhoneOS 43 | 44 | NSMainNibFile 45 | 46 | NSMainNibFile~ipad 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/xcode_ios/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /samples/SkeletalAnimation/xcode_ios/SkeletalAnimation_Prefix.pch: -------------------------------------------------------------------------------- 1 | #if defined( __cplusplus ) 2 | #include "cinder/Cinder.h" 3 | 4 | #include "cinder/app/App.h" 5 | 6 | #include "cinder/gl/gl.h" 7 | 8 | #include "cinder/CinderMath.h" 9 | #include "cinder/Matrix.h" 10 | #include "cinder/Vector.h" 11 | #include "cinder/Quaternion.h" 12 | #endif -------------------------------------------------------------------------------- /src/cinder/dqconv.h: -------------------------------------------------------------------------------- 1 | /* dqconv.c 2 | 3 | Conversion routines between (regular quaternion, translation) and dual quaternion. 4 | 5 | Version 1.0.0, February 7th, 2007 6 | 7 | Copyright (C) 2006-2007 University of Dublin, Trinity College, All Rights 8 | Reserved 9 | 10 | This software is provided 'as-is', without any express or implied 11 | warranty. In no event will the author(s) be held liable for any damages 12 | arising from the use of this software. 13 | 14 | Permission is granted to anyone to use this software for any purpose, 15 | including commercial applications, and to alter it and redistribute it 16 | freely, subject to the following restrictions: 17 | 18 | 1. The origin of this software must not be misrepresented; you must not 19 | claim that you wrote the original software. If you use this software 20 | in a product, an acknowledgment in the product documentation would be 21 | appreciated but is not required. 22 | 2. Altered source versions must be plainly marked as such, and must not be 23 | misrepresented as being the original software. 24 | 3. This notice may not be removed or altered from any source distribution. 25 | 26 | Author: Ladislav Kavan, kavanl@cs.tcd.ie 27 | 28 | */ 29 | 30 | namespace dualquat { 31 | 32 | // input: unit quaternion 'q0', translation vector 't' 33 | // output: unit dual quaternion 'dq' 34 | inline void quatTrans2UDQ(const glm::quat &q0, const ci::vec3 &t, glm::quat dq[2] ) 35 | { 36 | // non-dual part (just copy q0): 37 | for (int i=0; i<4; i++) dq[0][i] = q0[i]; 38 | // dual part: 39 | dq[1][0] = -0.5*(t[0]*q0[1] + t[1]*q0[2] + t[2]*q0[3]); 40 | dq[1][1] = 0.5*( t[0]*q0[0] + t[1]*q0[3] - t[2]*q0[2]); 41 | dq[1][2] = 0.5*(-t[0]*q0[3] + t[1]*q0[0] + t[2]*q0[1]); 42 | dq[1][3] = 0.5*( t[0]*q0[2] - t[1]*q0[1] + t[2]*q0[0]); 43 | } 44 | 45 | // input: unit dual quaternion 'dq' 46 | // output: unit quaternion 'q0', translation vector 't' 47 | inline void UDQ2QuatTrans( const glm::quat dq[2], 48 | glm::quat &q0, ci::vec3 &t) 49 | { 50 | // regular quaternion (just copy the non-dual part): 51 | for (int i=0; i<4; i++) q0[i] = dq[0][i]; 52 | // translation vector: 53 | t[0] = 2.0*(-dq[1][0]*dq[0][1] + dq[1][1]*dq[0][0] - dq[1][2]*dq[0][3] + dq[1][3]*dq[0][2]); 54 | t[1] = 2.0*(-dq[1][0]*dq[0][2] + dq[1][1]*dq[0][3] + dq[1][2]*dq[0][0] - dq[1][3]*dq[0][1]); 55 | t[2] = 2.0*(-dq[1][0]*dq[0][3] - dq[1][1]*dq[0][2] + dq[1][2]*dq[0][1] + dq[1][3]*dq[0][0]); 56 | } 57 | 58 | // input: dual quat. 'dq' with non-zero non-dual part 59 | // output: unit quaternion 'q0', translation vector 't' 60 | inline void DQ2QuatTrans( const glm::quat dq[2], glm::quat &q0, ci::vec3 &t) 61 | { 62 | float len = 0.0; 63 | for (int i=0; i<4; i++) len += dq[0][i] * dq[0][i]; 64 | len = sqrt(len); 65 | for (int i=0; i<4; i++) q0[i] = dq[0][i] / len; 66 | t[0] = 2.0*(-dq[1][0]*dq[0][1] + dq[1][1]*dq[0][0] - dq[1][2]*dq[0][3] + dq[1][3]*dq[0][2]) / len; 67 | t[1] = 2.0*(-dq[1][0]*dq[0][2] + dq[1][1]*dq[0][3] + dq[1][2]*dq[0][0] - dq[1][3]*dq[0][1]) / len; 68 | t[2] = 2.0*(-dq[1][0]*dq[0][3] - dq[1][1]*dq[0][2] + dq[1][2]*dq[0][1] + dq[1][3]*dq[0][0]) / len; 69 | } 70 | 71 | } // namespace dq -------------------------------------------------------------------------------- /src/cinder/gltf/File.h: -------------------------------------------------------------------------------- 1 | // 2 | // GLTF.h 3 | // GLTFWork 4 | // 5 | // Created by Ryan Bartley on 6/19/14. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "jsoncpp/json.h" 16 | #include "cinder/Utilities.h" 17 | #include "cinder/gl/gl.h" 18 | #include "cinder/Skeleton.h" 19 | 20 | #include "cinder/gltf/Types.h" 21 | 22 | namespace cinder { 23 | namespace gltf { 24 | 25 | using FileRef = std::shared_ptr; 26 | 27 | class File { 28 | public: 29 | //! Creates a FileRef from /a gltfFile. 30 | static FileRef create( const ci::DataSourceRef &gltfFile ); 31 | ~File() = default; 32 | //! Returns a const ref to the fs::path of this gltf File. 33 | const ci::fs::path& getGltfPath() const { return mGltfPath; } 34 | //! Returns a const ref to the Json::Value of this gltf File. 35 | const Json::Value& getTree() const { return mGltfTree; } 36 | 37 | //! Returns whether or not this glTF File has /a extension. 38 | bool hasExtension( const std::string &extension ) const; 39 | //! Returns the list of glTF extensions associated with this glTF File. 40 | const std::vector& getExtensions() const { return mExtensions; } 41 | 42 | //! Templated helper which copies T 43 | template 44 | void get( const std::string &key, T &type ); 45 | template 46 | Json::Value getExtrasFrom( const std::string &key ); 47 | 48 | //! Returns the Asset info associated with this glTF File. 49 | const Asset& getAssetInfo() const; 50 | //! Returns a const ref to the default scene of this glTF File. 51 | const Scene& getDefaultScene() const; 52 | 53 | //! Returns a const ref to the Accessor associated with /a key. 54 | const Accessor& getAccessorInfo( const std::string &key ) const; 55 | //! Returns a const ref to the Animation associated with /a key. 56 | const Animation& getAnimationInfo( const std::string &key ) const; 57 | //! Returns a const ref to the Buffer associated with /a key. 58 | const gltf::Buffer& getBufferInfo( const std::string &key ) const; 59 | //! Returns a const ref to the BufferView associated with /a key. 60 | const BufferView& getBufferViewInfo( const std::string &key ) const; 61 | //! Returns a const ref to the Camera associated with /a key. 62 | const Camera& getCameraInfo( const std::string &key ) const; 63 | //! Returns a const ref to the Image associated with /a key. 64 | const Image& getImageInfo( const std::string &key ) const; 65 | //! Returns a const ref to the Light associated with /a key. 66 | const Light& getLightInfo( const std::string &key ) const; 67 | //! Returns a const ref to the Material associated with /a key. 68 | const Material& getMaterialInfo( const std::string &key ) const; 69 | //! Returns a const ref to the Mesh associated with /a key. 70 | const Mesh& getMeshInfo( const std::string &key ) const; 71 | //! Returns a const ref to the Node associated with /a key. 72 | const Node& getNodeInfo( const std::string &key ) const; 73 | //! Returns a const ref to the Program associated with /a key. 74 | const Program& getProgramInfo( const std::string &key ) const; 75 | //! Returns a const ref to the Sampler associated with /a key. 76 | const Sampler& getSamplerInfo( const std::string &key ) const; 77 | //! Returns a const ref to the Scene associated with /a key. 78 | const Scene& getSceneInfo( const std::string &key ) const; 79 | //! Returns a const ref to the Shader associated with /a key. 80 | const Shader& getShaderInfo( const std::string &key ) const; 81 | //! Returns a const ref to the Skin associated with /a key. 82 | const Skin& getSkinInfo( const std::string &key ) const; 83 | //! Returns a const ref to the Technique associated with /a key. 84 | const Technique& getTechniqueInfo( const std::string &key ) const; 85 | //! Returns a cons ref to the Texture associated with /a key. 86 | const Texture& getTextureInfo( const std::string &key ) const; 87 | 88 | //! Returns a const ref to the Collection of T, which can be any of the types listed above. 89 | template 90 | const std::map& getCollectionOf() const; 91 | //! Creates and returns a Skeleton::AnimRef based on /a skeleton. 92 | Skeleton::AnimRef createSkeletonAnim( const SkeletonRef &skeleton ) const; 93 | //! Creates and returns a vector of TransformClips based on /a skeleton. 94 | std::vector createSkeletonTransformClip( const SkeletonRef &skeleton ) const; 95 | 96 | TransformClip collectTransformClipFor( const Node *node ) const; 97 | 98 | private: 99 | //! Constructor. 100 | File( const ci::DataSourceRef &gltfFile ); 101 | //! Loads the glTF into this File. 102 | void load(); 103 | //! Loads the associated extionsions from this File. 104 | void loadExtensions(); 105 | //! Caches the Asset Info for this glTF file. 106 | void setAssetInfo( const Json::Value &val ); 107 | //! Verifies whether the glTF File is binary or regular json and loads it. 108 | void verifyFile( const ci::DataSourceRef &data, std::string &gltfJson ); 109 | //! Recursive function for adding nodes to a parent. Called after all nodes are loaded. 110 | void setParentForChildren( Node *parent, const std::string &childKey ); 111 | 112 | //! Appends Accessor Info associated with /a key. 113 | void addAccessorInfo( const std::string &key, const Json::Value &val ); 114 | //! Appends Animation Info associated with /a key. 115 | void addAnimationInfo( const std::string &key, const Json::Value &val ); 116 | //! Appends Buffer Info associated with /a key. 117 | void addBufferInfo( const std::string &key, const Json::Value &val ); 118 | //! Appends BufferView Info associated with /a key. 119 | void addBufferViewInfo( const std::string &key, const Json::Value &val ); 120 | //! Appends Camera Info associated with /a key. 121 | void addCameraInfo( const std::string &key, const Json::Value &val ); 122 | //! Appends Image Info associated with /a key. 123 | void addImageInfo( const std::string &key, const Json::Value &val ); 124 | //! Appends Light Info associated with /a key. 125 | void addLightInfo( const std::string &key, const Json::Value &val ); 126 | //! Appends Material Info associated with /a key. 127 | void addMaterialInfo( const std::string &key, const Json::Value &val ); 128 | //! Appends Mesh Info associated with /a key. 129 | void addMeshInfo( const std::string &key, const Json::Value &val ); 130 | //! Appends Node Info associated with /a key. 131 | void addNodeInfo( const std::string &key, const Json::Value &val ); 132 | //! Appends Program Info associated with /a key. 133 | void addProgramInfo( const std::string &key, const Json::Value &val ); 134 | //! Appends Sampler Info associated with /a key. 135 | void addSamplerInfo( const std::string &key, const Json::Value &val ); 136 | //! Appends Scene Info associated with /a key. 137 | void addSceneInfo( const std::string &key, const Json::Value &val ); 138 | //! Appends Shader Info associated with /a key. 139 | void addShaderInfo( const std::string &key, const Json::Value &val ); 140 | //! Appends Skin Info associated with /a key. 141 | void addSkinInfo( const std::string &key, const Json::Value &val ); 142 | //! Appends Technique Info associated with /a key. 143 | void addTechniqueInfo( const std::string &key, const Json::Value &val ); 144 | //! Appends Texture Info associated with /a key. 145 | void addTextureInfo( const std::string &key, const Json::Value &val ); 146 | //! Appends type T associated with /a key. 147 | template 148 | void add( const std::string &key, T type ); 149 | 150 | Json::Value mGltfTree; 151 | cinder::fs::path mGltfPath; 152 | 153 | std::vector mExtensions; 154 | 155 | Asset mAssetInfo; 156 | std::string mDefaultScene; 157 | 158 | std::map mAccessors; 159 | std::map mAnimations; 160 | std::map mBufferViews; 161 | std::map mBuffers; 162 | std::map mCameras; 163 | std::map mImages; 164 | std::map mLights; 165 | std::map mMaterials; 166 | std::map mMeshes; 167 | std::map mNodes; 168 | std::map mPrograms; 169 | std::map mSamplers; 170 | std::map mScenes; 171 | std::map mShaders; 172 | std::map mSkins; 173 | std::map mTechniques; 174 | std::map mTextures; 175 | 176 | ci::BufferRef mBuffer; 177 | 178 | friend std::ostream& operator<<( std::ostream &lhs, const File &rhs ); 179 | }; 180 | 181 | template<> inline const std::map& File::getCollectionOf() const { return mAnimations; } 182 | template<> inline const std::map& File::getCollectionOf() const { return mAccessors; } 183 | template<> inline const std::map& File::getCollectionOf() const { return mBufferViews; } 184 | template<> inline const std::map& File::getCollectionOf() const { return mBuffers; } 185 | template<> inline const std::map& File::getCollectionOf() const { return mCameras; } 186 | template<> inline const std::map& File::getCollectionOf() const { return mImages; } 187 | template<> inline const std::map& File::getCollectionOf() const { return mLights; } 188 | template<> inline const std::map& File::getCollectionOf() const { return mMaterials; } 189 | template<> inline const std::map& File::getCollectionOf() const { return mMeshes; } 190 | template<> inline const std::map& File::getCollectionOf() const { return mNodes; } 191 | template<> inline const std::map& File::getCollectionOf() const { return mPrograms; } 192 | template<> inline const std::map& File::getCollectionOf() const { return mSamplers; } 193 | template<> inline const std::map& File::getCollectionOf() const { return mScenes; } 194 | template<> inline const std::map& File::getCollectionOf() const { return mShaders; } 195 | template<> inline const std::map& File::getCollectionOf() const { return mSkins; } 196 | template<> inline const std::map& File::getCollectionOf() const { return mTechniques; } 197 | template<> inline const std::map& File::getCollectionOf() const { return mTextures; } 198 | 199 | } // namespace gltf 200 | } 201 | 202 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::File &rhs ); 203 | -------------------------------------------------------------------------------- /src/cinder/gltf/MeshLoader.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // GLTFLoader.cpp 3 | // GLTFWork 4 | // 5 | // Created by Ryan Bartley on 11/22/14. 6 | // 7 | // 8 | 9 | #include "MeshLoader.h" 10 | 11 | using namespace std; 12 | 13 | namespace cinder { 14 | namespace gltf { 15 | 16 | MeshLoader::MeshLoader( const Mesh *mesh ) 17 | : mMesh( mesh ), mNumIndices( 0 ), mNumVertices( 0 ), 18 | mPrimitive( ci::geom::Primitive::NUM_PRIMITIVES ) 19 | { 20 | bool primitiveSet = false; 21 | bool verticesSet = false; 22 | 23 | for( const auto &prim : mMesh->primitives ) { 24 | // Primitive Mode should be the same throughout. 25 | if( ! primitiveSet ) { 26 | mPrimitive = Mesh::convertToPrimitive( prim.primitive ); 27 | primitiveSet = true; 28 | } 29 | else 30 | CI_ASSERT( mPrimitive == Mesh::convertToPrimitive( prim.primitive ) ); 31 | 32 | // Go through the attributes 33 | for( const auto &attribAccessors : prim.attributes ) { 34 | const auto vertAccessor = attribAccessors.accessor; 35 | // The number of vertices should also be the same for each primitive 36 | if( ! verticesSet ) { 37 | mNumVertices = vertAccessor->count; 38 | verticesSet = true; 39 | } 40 | else 41 | CI_ASSERT( mNumVertices == vertAccessor->count ); 42 | 43 | if( prim.indices != nullptr ) { 44 | auto count = prim.indices->count; 45 | mIndexAccessors.emplace_back( prim.indices ); 46 | mMeshInstances.emplace_back( prim.material, static_cast(mNumIndices), count ); 47 | mNumIndices += count; 48 | } 49 | else { 50 | 51 | } 52 | 53 | auto emplaced = mAttribAccessors.emplace( attribAccessors.attrib, vertAccessor ); 54 | if( ! emplaced.second ) 55 | CI_ASSERT( emplaced.first->second == vertAccessor ); 56 | mAvailableAttribs.insert( attribAccessors.attrib ); 57 | } 58 | } 59 | verticesSet = true; 60 | } 61 | 62 | uint8_t MeshLoader::getAttribDims( ci::geom::Attrib attr ) const 63 | { 64 | auto found = mAttribAccessors.find( attr ); 65 | if( found != mAttribAccessors.end() ) 66 | return found->second->getNumComponents(); 67 | else 68 | return 0; 69 | } 70 | 71 | template 72 | void MeshLoader::copyIndices( std::vector &indices, const T *data, uint32_t count ) const 73 | { 74 | auto sizeOffset = static_cast( indices.size() ); 75 | indices.resize( sizeOffset + count ); 76 | for( uint32_t i = 0; i < count; i++ ) { 77 | indices[sizeOffset+i] = (*data++); 78 | } 79 | } 80 | 81 | void MeshLoader::loadInto( ci::geom::Target *target, const ci::geom::AttribSet &requestedAttribs ) const 82 | { 83 | for( auto & attrib : requestedAttribs ) { 84 | auto found = mAttribAccessors.find( attrib ); 85 | if( found != mAttribAccessors.end() ) { 86 | auto accessor = found->second; 87 | auto dims = accessor->getNumComponents(); 88 | auto count = accessor->count; 89 | auto dataPtr = reinterpret_cast(accessor->getDataPtr()); 90 | target->copyAttrib( found->first, dims, 0, dataPtr, count ); 91 | } 92 | } 93 | if( ! mIndexAccessors.empty() ) { 94 | std::vector indices; 95 | for( auto index : mIndexAccessors ) { 96 | auto byteLengthPerComponent = index->getNumBytesForComponentType(); 97 | auto dataPtr = reinterpret_cast(index->getDataPtr()); 98 | 99 | if( byteLengthPerComponent == 1 ) 100 | copyIndices( indices, dataPtr, index->count ); 101 | else if( byteLengthPerComponent == 2 ) 102 | copyIndices( indices, reinterpret_cast( dataPtr ), index->count ); 103 | else if( byteLengthPerComponent == 4 ) 104 | copyIndices( indices, reinterpret_cast( dataPtr ), index->count ); 105 | } 106 | 107 | size_t totalNumIndices = indices.size(); 108 | uint8_t bytesRequired = 0; 109 | if( totalNumIndices < std::numeric_limits::max() ) 110 | bytesRequired = sizeof( uint8_t ); 111 | else if( totalNumIndices < std::numeric_limits::max() ) 112 | bytesRequired = sizeof( uint16_t ); 113 | else if( totalNumIndices < std::numeric_limits::max() ) 114 | bytesRequired = sizeof( uint32_t ); 115 | else 116 | CI_ASSERT_MSG( totalNumIndices < std::numeric_limits::max(), "Can't exceed uint32_t max amount of indices." ); 117 | 118 | target->copyIndices( mPrimitive, indices.data(), totalNumIndices, bytesRequired ); 119 | } 120 | } 121 | 122 | } // namespace gltf 123 | } // namespace cinder -------------------------------------------------------------------------------- /src/cinder/gltf/MeshLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // GLTFLoader.h 3 | // GLTFWork 4 | // 5 | // Created by Ryan Bartley on 11/22/14. 6 | // 7 | // 8 | 9 | #include "cinder/GeomIo.h" 10 | #include "cinder/CinderAssert.h" 11 | #include "cinder/gltf/Types.h" 12 | 13 | namespace cinder { 14 | namespace gltf { 15 | 16 | //! Represents a Mesh Geom for gltf::Mesh(s). Note: gltf::File associated with Mesh used to build 17 | //! this, needs to outlive this loader. 18 | class MeshLoader : public ci::geom::Source { 19 | public: 20 | //! Constructor taking a gltf Mesh pointer. 21 | MeshLoader( const Mesh *mesh ); 22 | ~MeshLoader() = default; 23 | 24 | //! Returns the number of vertices contained within the Mesh. 25 | virtual size_t getNumVertices() const { return mNumVertices; } 26 | //! Returns the number of indices contained within the Mesh. 27 | virtual size_t getNumIndices() const { return mNumIndices; } 28 | //! Returns the geom::Primitive that this mesh will be represented as. 29 | virtual ci::geom::Primitive getPrimitive() const { return mPrimitive; } 30 | //! Returns the number of dimensions contained in this /a attr. 31 | virtual uint8_t getAttribDims( ci::geom::Attrib attr ) const; 32 | //! Loads attibutes into /a target. 33 | virtual void loadInto( ci::geom::Target *target, const ci::geom::AttribSet &requestedAttribs ) const; 34 | //! Returns the set of available attributes available in this mesh. 35 | virtual ci::geom::AttribSet getAvailableAttribs() const { return mAvailableAttribs; } 36 | //! Clones this source and returns a copy of this MeshLodader. 37 | virtual Source* clone() const { return new MeshLoader( *this ); } 38 | 39 | //! Represents a beginning and ending vert or index and the Material associated with this. 40 | struct MeshInstance { 41 | MeshInstance( Material *material, uint32_t first, uint32_t count ) 42 | : material( material ), first( first ), count( count ) {} 43 | Material *material; 44 | uint32_t first; 45 | uint32_t count; 46 | }; 47 | //! Returns Mesh Instance for this mesh. 48 | const std::vector& getMeshInstances() { return mMeshInstances; } 49 | 50 | private: 51 | template 52 | void copyIndices( std::vector &indices, const T* data, uint32_t count ) const; 53 | 54 | const Mesh *mMesh; 55 | ci::geom::AttribSet mAvailableAttribs; 56 | size_t mNumVertices, mNumIndices; 57 | ci::geom::Primitive mPrimitive; 58 | 59 | std::map mAttribAccessors; 60 | std::vector mIndexAccessors; 61 | std::vector mMeshInstances; 62 | 63 | }; 64 | 65 | } // namespace gltf 66 | } // namespace cinder -------------------------------------------------------------------------------- /src/cinder/gltf/SimpleScene.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleScene.cpp 3 | // BasicAnimation 4 | // 5 | // Created by Ryan Bartley on 8/27/16. 6 | // 7 | // 8 | 9 | #include "SimpleScene.h" 10 | #include "cinder/gltf/MeshLoader.h" 11 | #include "cinder/app/App.h" 12 | 13 | using namespace std; 14 | 15 | namespace cinder { namespace gltf { namespace simple { 16 | 17 | Scene::Scene( const gltf::FileRef &file, const gltf::Scene *scene ) 18 | : mFile( file ), mAnimate( false ), mCurrentCameraInfoId( 0 ), mUsingDebugCamera( false ) 19 | { 20 | mMeshes.reserve( 100 ); 21 | for ( auto &node : scene->nodes ) { 22 | mNodes.emplace_back( Scene::Node::create( node, nullptr, this ) ); 23 | } 24 | 25 | // setup camera 26 | if ( ! mCameras.empty() ) { 27 | auto &camInfo = mCameras[mCurrentCameraInfoId]; 28 | 29 | mCamera.setPerspective( 45.0f, ci::app::getWindowAspectRatio(), 0.01f, 100000.0f ); 30 | } 31 | else { 32 | mCamera.setPerspective( 45.0f, ci::app::getWindowAspectRatio(), 0.01f, 10000.0f ); 33 | mCamera.lookAt( vec3( 0, 10, -5 ), vec3( 0 ) ); 34 | } 35 | 36 | double begin = std::numeric_limits::max(), 37 | end = std::numeric_limits::min(); 38 | for ( auto & transformClip : mTransformClips ) { 39 | auto timeBounds = transformClip.getTimeBounds(); 40 | begin = glm::min( begin, timeBounds.first ); 41 | end = glm::max( end, timeBounds.second ); 42 | } 43 | mStartTime = begin; 44 | mDuration = end - begin; 45 | 46 | for( auto i = 0; i < mTransforms.size(); i++ ) { 47 | auto &trans = mTransforms[i]; 48 | if( trans.parentId != std::numeric_limits::max() ) 49 | trans.worldTransform = mTransforms[trans.parentId].worldTransform * trans.localTransform; 50 | else 51 | trans.worldTransform = trans.localTransform; 52 | } 53 | } 54 | 55 | void Scene::update() 56 | { 57 | if ( mTransformClips.empty() ) 58 | return; 59 | 60 | auto time = ci::app::getElapsedSeconds(); 61 | auto cyclicTime = glm::mod( time, mDuration ) + mStartTime; 62 | for ( auto &node : mNodes ) 63 | node->update( cyclicTime ); 64 | 65 | for( auto i = 0; i < mTransforms.size(); i++ ) { 66 | auto &trans = mTransforms[i]; 67 | if( trans.parentId != std::numeric_limits::max() ) 68 | trans.worldTransform = mTransforms[trans.parentId].worldTransform * trans.localTransform; 69 | else 70 | trans.worldTransform = trans.localTransform; 71 | } 72 | } 73 | 74 | void Scene::renderScene() 75 | { 76 | gl::ScopedMatrices scopeMat; 77 | if( ! mCameras.empty() ) { 78 | auto node = mCameras[mCurrentCameraInfoId].node; 79 | auto &worldTrans = getWorldTransform( node->getTransformIndex() ); 80 | gl::setMatrices( mCamera ); 81 | gl::setViewMatrix( glm::inverse( worldTrans ) ); 82 | } 83 | 84 | gl::ScopedDepth scopeDepth( true ); 85 | for( auto &mesh : mMeshes ) { 86 | auto ctx = gl::context(); 87 | auto &difTex = mesh.mDiffuseTex; 88 | if( difTex ) { 89 | gl::color( 1, 1, 1 ); 90 | ctx->pushTextureBinding( difTex->getTarget(), difTex->getId(), 0 ); 91 | } 92 | else 93 | gl::color( 1, 1, 1, 1 ); 94 | 95 | gl::setModelMatrix( getWorldTransform( mesh.node->getTransformIndex() ) ); 96 | mesh.mBatch->draw(); 97 | 98 | if( difTex ) 99 | ctx->popTextureBinding( difTex->getTarget(), 0 ); 100 | } 101 | } 102 | 103 | uint32_t Scene::setupTransform( uint32_t parentTransId, ci::mat4 localTransform ) 104 | { 105 | auto ret = mTransforms.size(); 106 | Transform trans; 107 | trans.parentId = parentTransId; 108 | trans.localTransform = localTransform; 109 | trans.worldTransform = localTransform; 110 | trans.dirty = false; 111 | mTransforms.emplace_back( trans ); 112 | return ret; 113 | } 114 | 115 | void Scene::selectCamera( uint32_t selection ) 116 | { 117 | mCurrentCameraInfoId = glm::clamp( selection, (uint32_t)0, numCameras() - 1 ); 118 | } 119 | 120 | void Scene::toggleDebugCamera() 121 | { 122 | 123 | } 124 | 125 | void Scene::updateTransform( uint32_t transId, ci::mat4 localTransform ) 126 | { 127 | CI_ASSERT( transId < mTransforms.size() ); 128 | mTransforms[transId].localTransform = localTransform; 129 | } 130 | 131 | ci::mat4& Scene::getWorldTransform( uint32_t transId ) 132 | { 133 | CI_ASSERT( transId < mTransforms.size() ); 134 | return mTransforms[transId].worldTransform; 135 | } 136 | 137 | ci::mat4& Scene::getLocalTransform( uint32_t transId ) 138 | { 139 | CI_ASSERT( transId < mTransforms.size() ); 140 | return mTransforms[transId].localTransform; 141 | } 142 | 143 | ci::mat4 Scene::getParentWorldTransform( uint32_t transId ) 144 | { 145 | CI_ASSERT( transId < mTransforms.size() ); 146 | auto &trans = mTransforms[transId]; 147 | if( trans.parentId != std::numeric_limits::max() ) 148 | return mTransforms[trans.parentId].worldTransform; 149 | 150 | return ci::mat4(); 151 | } 152 | 153 | int32_t Scene::addTransformClip( TransformClip clip ) 154 | { 155 | auto ret = mTransformClips.size(); 156 | mTransformClips.emplace_back( std::move( clip ) ); 157 | return ret; 158 | } 159 | 160 | void Scene::getClipComponentsAtTime( int32_t animationId, float globalTime, 161 | ci::vec3 *translation, ci::quat *rotation, ci::vec3 *scale ) 162 | { 163 | CI_ASSERT( animationId < mTransformClips.size() ); 164 | if ( ! mAnimate ) 165 | return; 166 | 167 | auto &transClip = mTransformClips[animationId]; 168 | if( ! transClip.getTranslationClip().empty() ) 169 | *translation = transClip.getTranslation( globalTime ); 170 | if( ! transClip.getRotationClip().empty() ) 171 | *rotation = transClip.getRotation( globalTime ); 172 | if( ! transClip.getScaleClip().empty() ) 173 | *scale = transClip.getScale( globalTime ); 174 | } 175 | 176 | using Node = Scene::Node; 177 | 178 | Node::Node( const gltf::Node *node, simple::Scene::Node *parent, Scene *scene ) 179 | : mScene( scene ), mParent( parent ), mAnimationIndex( -1 ), mKey( node->key ), mName( node->name ) 180 | { 181 | // Cache current node local model matrix 182 | //cout << "name: " << node->key << std::endl; 183 | ci::mat4 modelMatrix; 184 | // if it's a transform matrix 185 | if( ! node->transformMatrix.empty() ) { 186 | // grab it 187 | modelMatrix = node->getTransformMatrix(); 188 | } 189 | // otherwise, it's broken up into components 190 | else { 191 | // grab the components 192 | mOriginalTranslation = node->getTranslation(); 193 | mOriginalRotation = node->getRotation(); 194 | mOriginalScale = node->getScale(); 195 | // create the placeholder matrix 196 | modelMatrix *= glm::translate( mOriginalTranslation ); 197 | modelMatrix *= glm::toMat4( mOriginalRotation ); 198 | modelMatrix *= glm::scale( mOriginalScale ); 199 | // usually when it's broken up like this that means it's animated 200 | auto transformClip = mScene->mFile->collectTransformClipFor( node ); 201 | if( ! transformClip.empty() ) 202 | mAnimationIndex = mScene->addTransformClip( move( transformClip ) ); 203 | } 204 | //cout << "matrix: " << modelMatrix << endl; 205 | 206 | // get the parent index if there's a parent 207 | uint32_t parentIndex = std::numeric_limits::max(); 208 | if ( mParent ) 209 | parentIndex = mParent->getTransformIndex(); 210 | // cache the transform 211 | mTransformIndex = mScene->setupTransform( parentIndex, modelMatrix ); 212 | 213 | // cache the children 214 | for ( auto &children : node->children ) 215 | mChildren.emplace_back( Node::create( children, this, scene ) ); 216 | 217 | // check if there's meshes 218 | if( node->hasMeshes() ) { 219 | geom::SourceMods meshCombo; 220 | // there may be multiple meshes, so combine them for now 221 | gl::Texture2dRef diffuseTex; 222 | ci::ColorA diffuseCol; 223 | for( auto mesh : node->meshes ) { 224 | meshCombo &= gltf::MeshLoader( mesh ); 225 | // this is rough. 226 | auto &sources = mesh->primitives[0].material->sources; 227 | if( ! sources.empty() ) { 228 | if( sources[0].texture ) { 229 | auto image = sources[0].texture->image->getImage(); 230 | diffuseTex = gl::Texture2d::create( image, gl::Texture2d::Format().loadTopDown() ); 231 | } 232 | else 233 | diffuseCol = sources[0].color; 234 | } 235 | } 236 | // quick rendering decision 237 | gl::GlslProgRef glsl; 238 | if( diffuseTex ) 239 | glsl = gl::getStockShader( gl::ShaderDef().lambert().texture() ); 240 | else 241 | glsl = gl::getStockShader( gl::ShaderDef().color().lambert() ); 242 | // finally create the batch 243 | auto batch = gl::Batch::create( meshCombo, glsl ); 244 | mType = Type::MESH; 245 | mTypeId = mScene->mMeshes.size(); 246 | mScene->mMeshes.emplace_back( move( batch ), move( diffuseTex ), diffuseCol, this ); 247 | } 248 | else if( node->isCamera() ) { 249 | mType = Type::CAMERA; 250 | mTypeId = mScene->mCameras.size(); 251 | mScene->mCameras.emplace_back( node->camera->aspectRatio, node->camera->yfov, node->camera->znear, node->camera->zfar, this ); 252 | } 253 | } 254 | 255 | Scene::UniqueNode Node::create( const gltf::Node *node, simple::Scene::Node *parent, Scene *scene ) 256 | { 257 | return std::unique_ptr( new Node( node, parent, scene ) ); 258 | } 259 | 260 | void Node::update( float globalTime ) 261 | { 262 | for( auto &child : mChildren ) 263 | child->update( globalTime ); 264 | 265 | if ( mAnimationIndex < 0 ) 266 | return; 267 | 268 | // setup the defaults 269 | mCurrentTrans = mOriginalTranslation; 270 | mCurrentRot = mOriginalRotation; 271 | mCurrentScale = mOriginalScale; 272 | // get the clips animation values, if a certain component isn't animated than it's defaults remain 273 | mScene->getClipComponentsAtTime( mAnimationIndex, globalTime, &mCurrentTrans, &mCurrentRot, &mCurrentScale ); 274 | // create the modelMatrix 275 | ci::mat4 modelMatrix; 276 | modelMatrix *= glm::translate( mCurrentTrans ); 277 | modelMatrix *= glm::toMat4( mCurrentRot ); 278 | modelMatrix *= glm::scale( mCurrentScale ); 279 | //cout << "trans: " << mCurrentTrans << " rot: " << mCurrentRot << " scale: " << mCurrentScale << std::endl; 280 | // update the scene's modelmatrix 281 | mScene->updateTransform( mTransformIndex, modelMatrix ); 282 | } 283 | 284 | Scene::Mesh::Mesh( gl::BatchRef batch, gl::Texture2dRef difTex, ColorA difColor, Node *node ) 285 | : mBatch( std::move( batch ) ), mDiffuseTex( std::move( difTex ) ), 286 | mDiffuseColor( difColor ), node( node ) 287 | { 288 | } 289 | 290 | Scene::Mesh::Mesh( const Mesh & mesh ) 291 | : mBatch( mesh.mBatch ), mDiffuseTex( mesh.mDiffuseTex ), 292 | mDiffuseColor( mesh.mDiffuseColor ), node( mesh.node ) 293 | { 294 | } 295 | 296 | Scene::Mesh& Scene::Mesh::operator=( const Mesh & mesh ) 297 | { 298 | if( this != &mesh ) { 299 | mBatch = mesh.mBatch; 300 | mDiffuseTex = mesh.mDiffuseTex; 301 | mDiffuseColor = mesh.mDiffuseColor; 302 | node = mesh.node; 303 | } 304 | return *this; 305 | } 306 | 307 | Scene::Mesh::Mesh( Mesh &&mesh ) noexcept 308 | : mBatch( move( mesh.mBatch ) ), mDiffuseTex( move(mesh.mDiffuseTex ) ), 309 | mDiffuseColor( move(mesh.mDiffuseColor) ), node( mesh.node ) 310 | { 311 | } 312 | 313 | Scene::Mesh& Scene::Mesh::operator=( Mesh &&mesh ) noexcept 314 | { 315 | if( this != &mesh ) { 316 | mBatch = move(mesh.mBatch); 317 | mDiffuseTex = move(mesh.mDiffuseTex); 318 | mDiffuseColor = mesh.mDiffuseColor; 319 | node = mesh.node; 320 | } 321 | return *this; 322 | } 323 | 324 | Scene::CameraInfo::CameraInfo( float aspectRatio, float yfov, float znear, float zfar, Node *node ) 325 | : aspectRatio( aspectRatio ), yfov( yfov ), znear( znear ), zfar( zfar ), node( node ) 326 | { 327 | } 328 | 329 | Scene::CameraInfo::CameraInfo( const CameraInfo & info ) 330 | : aspectRatio( info.aspectRatio ), yfov( info.yfov ), znear( info.znear ), 331 | zfar( info.zfar ), node( info.node ) 332 | { 333 | } 334 | 335 | Scene::CameraInfo& Scene::CameraInfo::operator=( const CameraInfo &info ) 336 | { 337 | if( this != &info ) { 338 | aspectRatio = info.aspectRatio; 339 | yfov = info.yfov; 340 | znear = info.znear; 341 | zfar = info.zfar; 342 | node = info.node; 343 | } 344 | return *this; 345 | } 346 | 347 | Scene::CameraInfo::CameraInfo( CameraInfo &&info ) noexcept 348 | : aspectRatio( info.aspectRatio ), yfov( info.yfov ), znear( info.znear ), 349 | zfar( info.zfar ), node( info.node ) 350 | { 351 | } 352 | 353 | Scene::CameraInfo& Scene::CameraInfo::operator=( CameraInfo &&info ) noexcept 354 | { 355 | if( this != &info ) { 356 | aspectRatio = info.aspectRatio; 357 | yfov = info.yfov; 358 | znear = info.znear; 359 | zfar = info.zfar; 360 | node = info.node; 361 | } 362 | return *this; 363 | } 364 | 365 | 366 | }}} 367 | -------------------------------------------------------------------------------- /src/cinder/gltf/SimpleScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleScene.hpp 3 | // BasicAnimation 4 | // 5 | // Created by Ryan Bartley on 8/27/16. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "cinder/CameraUi.h" 12 | 13 | #include "cinder/gltf/Types.h" 14 | #include "cinder/gltf/File.h" 15 | 16 | namespace cinder { namespace gltf { namespace simple { 17 | 18 | class Scene { 19 | public: 20 | Scene( const gltf::FileRef &file, const gltf::Scene *scene ); 21 | 22 | void update(); 23 | void renderScene(); 24 | void toggleAnimation() { mAnimate = !mAnimate; } 25 | void toggleDebugCamera(); 26 | void selectCamera( uint32_t selection ); 27 | uint32_t numCameras() const { return mCameras.size(); } 28 | 29 | 30 | class Node { 31 | public: 32 | Node( const gltf::Node *node, simple::Scene::Node *parent, Scene *scene ); 33 | static std::unique_ptr create( const gltf::Node *node, 34 | simple::Scene::Node *parent, 35 | simple::Scene *scene ); 36 | Node* getParent() { return mParent; } 37 | void update( float globalTime ); 38 | 39 | const ci::vec3& getLocalTranslation() const { return mCurrentTrans; } 40 | const ci::vec3& getLocalScale() const { return mCurrentScale; } 41 | const ci::quat& getLocalRotation() const { return mCurrentRot; } 42 | 43 | uint32_t getTransformIndex() { return mTransformIndex; } 44 | int32_t getAnimationId() { return mAnimationIndex; } 45 | 46 | enum class Type { 47 | NODE, 48 | MESH, 49 | CAMERA 50 | }; 51 | 52 | Type getNodeType() const { return mType; } 53 | 54 | ci::vec3 mCurrentTrans, mCurrentScale; 55 | ci::quat mCurrentRot; 56 | 57 | private: 58 | Scene *mScene; 59 | Node *mParent; 60 | std::vector> mChildren; 61 | 62 | Type mType; 63 | uint32_t mTypeId; 64 | 65 | uint32_t mTransformIndex; 66 | int32_t mAnimationIndex; 67 | 68 | ci::vec3 mOriginalTranslation, mOriginalScale; 69 | ci::quat mOriginalRotation; 70 | 71 | 72 | std::string mKey, mName; 73 | }; 74 | 75 | using UniqueNode = std::unique_ptr; 76 | 77 | private: 78 | uint32_t setupTransform( uint32_t parentTransId, ci::mat4 localTransform ); 79 | void updateTransform( uint32_t transId, ci::mat4 localTransform ); 80 | ci::mat4& getWorldTransform( uint32_t transId ); 81 | ci::mat4& getLocalTransform( uint32_t transId ); 82 | ci::mat4 getParentWorldTransform( uint32_t transId ); 83 | 84 | int32_t addTransformClip( TransformClip clip ); 85 | void getClipComponentsAtTime( int32_t animationId, float globalTime, 86 | ci::vec3 *translation, ci::quat *rotation, ci::vec3 *scale ); 87 | 88 | gltf::FileRef mFile; 89 | std::vector mNodes; 90 | 91 | struct Transform { 92 | uint32_t parentId; 93 | bool dirty; 94 | ci::mat4 localTransform; 95 | ci::mat4 worldTransform; 96 | }; 97 | 98 | struct Mesh { 99 | Mesh( gl::BatchRef batch, gl::Texture2dRef difTex, ColorA difColor, Node *node ); 100 | Mesh( const Mesh &mesh ); 101 | Mesh& operator=( const Mesh &mesh ); 102 | Mesh( Mesh &&mesh ) noexcept; 103 | Mesh& operator=( Mesh &&mesh ) noexcept; 104 | 105 | gl::BatchRef mBatch; 106 | gl::Texture2dRef mDiffuseTex; 107 | ColorA mDiffuseColor; 108 | Node *node; 109 | }; 110 | 111 | struct CameraInfo { 112 | CameraInfo( float aspectRatio, float yfov, float znear, float zfar, Node *node ); 113 | CameraInfo( const CameraInfo &info ); 114 | CameraInfo& operator=( const CameraInfo &info ); 115 | CameraInfo( CameraInfo &&info ) noexcept; 116 | CameraInfo& operator=( CameraInfo &&info ) noexcept; 117 | 118 | float zfar, 119 | znear, 120 | yfov, 121 | aspectRatio; 122 | Node *node; 123 | }; 124 | 125 | ci::CameraPersp mCamera; 126 | ci::CameraUi mDebugCamera; 127 | bool mUsingDebugCamera; 128 | 129 | uint32_t mCurrentCameraInfoId; 130 | 131 | std::vector mMeshes; 132 | std::vector mCameras; 133 | std::vector mTransforms; 134 | std::vector mTransformClips; 135 | double mStartTime, mDuration; 136 | bool mAnimate; 137 | 138 | friend class Node; 139 | }; 140 | 141 | 142 | }}} 143 | -------------------------------------------------------------------------------- /src/cinder/gltf/Types.h: -------------------------------------------------------------------------------- 1 | // 2 | // Types.h 3 | // Test 4 | // 5 | // Created by Ryan Bartley on 8/8/16. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | // need this to define the GL constants, possibly figure out something else 14 | #include "cinder/gl/gl.h" 15 | // need this because of materials, possibly figure out something else 16 | #include "jsoncpp/json.h" 17 | 18 | namespace cinder { 19 | 20 | class TransformClip; 21 | template 22 | class Clip; 23 | using SkeletonRef = std::shared_ptr; 24 | 25 | namespace gltf { 26 | 27 | struct Accessor; 28 | struct Animation; 29 | struct BufferView; 30 | struct Buffer; 31 | struct Camera; 32 | struct Image; 33 | struct Light; 34 | struct Material; 35 | struct Mesh; 36 | struct Node; 37 | struct Program; 38 | struct Sampler; 39 | struct Scene; 40 | struct Shader; 41 | struct Skin; 42 | struct Technique; 43 | struct Texture; 44 | 45 | struct Asset { 46 | struct Profile { 47 | std::string api = "WebGL", version = "1.0.3"; 48 | }; 49 | std::string copyright, generator, version; 50 | Profile profile; 51 | bool premultipliedAlpha{false}; 52 | }; 53 | 54 | struct Scene { 55 | std::vector nodes; 56 | std::string name, key; 57 | }; 58 | 59 | //! An accessor defines a method for retrieving data as typed arrays from within a bufferView. 60 | struct Accessor { 61 | //! Possible Data types in the Accessor 62 | enum class Type { SCALAR, VEC2, VEC3, VEC4, MAT2, MAT3, MAT4 }; 63 | //! Possible data types of each component in the Accessor 64 | enum class ComponentType { 65 | BYTE = GL_BYTE, 66 | UNSIGNED_BYTE = GL_UNSIGNED_BYTE, 67 | SHORT = GL_SHORT, 68 | UNSIGNED_SHORT = GL_UNSIGNED_SHORT, 69 | FLOAT = GL_FLOAT 70 | }; 71 | //! Returns a void* to the beginning of the data for this accessor 72 | void* getDataPtr() const; 73 | //! Returns the number of components in the data type 74 | uint8_t getNumComponents() const; 75 | //! Returns the number of bytes per component of the data type 76 | uint8_t getNumBytesForComponentType() const; 77 | 78 | BufferView* bufferView{nullptr}; 79 | Type dataType; 80 | ComponentType componentType; 81 | uint32_t byteOffset, // Required 82 | byteStride{0}, 83 | count; 84 | std::vector min, max; 85 | std::string name, key; 86 | }; 87 | 88 | //! Stores key frame data in buffers and references them using accessors. 89 | struct Animation { 90 | 91 | //! Connects the output values of the key frame animation to a specific node in the hierarchy. 92 | struct Channel { 93 | std::string sampler, path; 94 | Node *target{nullptr}; 95 | std::string targetId; 96 | }; 97 | //! Animation type. Linear is the only defined type 98 | struct Sampler { 99 | enum class LerpType { LINEAR }; 100 | std::string input, output; 101 | LerpType type{LerpType::LINEAR}; 102 | }; 103 | //! Parameter data with associated accessor. 104 | struct Parameter { 105 | struct Data { 106 | std::string paramName; 107 | uint32_t numComponents; 108 | std::vector data; 109 | }; 110 | std::string parameter; 111 | Accessor* accessor{nullptr}; 112 | }; 113 | 114 | //! Returns a vector of Parameter data. 115 | std::vector getParameters() const; 116 | //! Returns a TransformClip with the information stored in /a paramData. 117 | static TransformClip createTransformClip( const std::vector ¶mData ); 118 | //! Returns a Clip representing the translation with the information stored in /a paramData. 119 | static Clip createTranslationClip( const std::vector ¶mData ); 120 | //! Returns a Clip representing the scale with the information stored in /a paramData. 121 | static Clip createScaleClip( const std::vector ¶mData ); 122 | //! Returns a Clip representing the rotation with the information stored in /a paramData. 123 | static Clip createRotationClip( const std::vector ¶mData ); 124 | 125 | std::string target; 126 | std::vector channels; 127 | std::vector samplers; 128 | Accessor *timeAccessor{nullptr}; 129 | std::vector parameters; 130 | std::string name, key; 131 | }; 132 | 133 | struct Buffer { 134 | 135 | ci::BufferRef getBuffer() const { return data; } 136 | 137 | uint32_t byteLength{0}; 138 | std::string uri; // path 139 | std::string type = "arrayBuffer"; 140 | std::string name, key; 141 | 142 | private: 143 | void cacheData() const; 144 | 145 | mutable ci::BufferRef data; 146 | friend class File; 147 | }; 148 | 149 | struct BufferView { 150 | enum class Target { 151 | ARRAY_BUFFER = GL_ARRAY_BUFFER, 152 | ELEMENT_ARRAY_BUFFER = GL_ELEMENT_ARRAY_BUFFER 153 | }; 154 | 155 | Buffer *buffer{nullptr}; // Pointer to buffer 156 | uint32_t byteLength{0}, 157 | byteOffset; 158 | Target target; 159 | std::string name, key; 160 | }; 161 | 162 | struct Camera { 163 | 164 | enum class Type { PERSPECTIVE, ORTHOGRAPHIC }; 165 | ci::CameraPersp getPerspCameraByName( const ci::mat4 &transformBake = ci::mat4() ); 166 | ci::CameraOrtho getOrthoCameraByName( const ci::mat4 &transformBack = ci::mat4() ); 167 | 168 | std::string name, key; 169 | Type type; 170 | Node *node; 171 | float zfar{0.0f}, 172 | znear{0.0f}, 173 | // only for perspective 174 | yfov{0.0f}, 175 | aspectRatio{0.0f}, 176 | // only for orthographic 177 | xmag{0.0f}, 178 | ymag{0.0f}; 179 | }; 180 | 181 | struct Image { 182 | ci::ImageSourceRef getImage() const { return imageSource; } 183 | 184 | std::string name, key; 185 | std::string uri; // path 186 | private: 187 | void cacheData() const; 188 | 189 | mutable ci::ImageSourceRef imageSource; 190 | friend class File; 191 | }; 192 | 193 | struct Light { 194 | //! Types of possible lights 195 | enum class Type { AMBIENT, DIRECTIONAL, POINT, SPOT }; 196 | 197 | ci::vec4 color{0.0f, 0.0f, 0.0f, 1.0f}; 198 | float distance{0.0f}, 199 | constantAttenuation{0.0f}, 200 | linearAttenuation{1.0f}, 201 | quadraticAttenuation{1.0f}, 202 | falloffAngle{float( M_PI ) / 2.0f}, 203 | falloffExponent{0.0f}; 204 | Type type; 205 | std::string name, key; 206 | }; 207 | 208 | struct Material { 209 | std::string name, key; 210 | Technique *technique = nullptr; 211 | 212 | struct Source { 213 | enum class Type { DIFFUSE, SPECULAR, EMISSION }; 214 | Type type; 215 | Texture *texture{nullptr}; 216 | ci::vec4 color{0.0f, 0.0f, 0.0f, 1.0f}; 217 | }; 218 | 219 | uint32_t jointCount = 0; 220 | ci::vec4 ambient{0.0f, 0.0f, 0.0f, 1.0f}; 221 | std::vector sources; 222 | float shininess{0.0f}, 223 | transparency{1.0f}; 224 | bool doubleSided{false}, 225 | transparent{false}; 226 | Json::Value values; 227 | }; 228 | 229 | struct Mesh { 230 | struct Primitive { 231 | struct AttribAccessor { 232 | ci::geom::Attrib attrib; 233 | Accessor *accessor{nullptr}; 234 | }; 235 | std::vector attributes; 236 | Accessor *indices{nullptr}; // Pointer to indices 237 | Material *material{nullptr}; // Pointer to material 238 | GLenum primitive{GL_TRIANGLES}; // ex. GL_TRIANGLES 239 | }; 240 | 241 | ci::AxisAlignedBox getPositionAABB(); 242 | static ci::geom::Attrib getAttribEnum( const std::string &attrib ); 243 | static ci::geom::Primitive convertToPrimitive( GLenum primitive ); 244 | 245 | std::string name, key; 246 | std::vector primitives; 247 | }; 248 | 249 | struct Node { 250 | 251 | size_t getNumChildren() const { return children.size(); } 252 | const Node* getChild( size_t index ) const; 253 | const Node* getChild( const std::string &nodeName ) const; 254 | const Node* getParent() const; 255 | 256 | ci::mat4 getHeirarchyTransform() const; 257 | ci::mat4 getTransformMatrix() const; 258 | ci::vec3 getTranslation() const; 259 | ci::quat getRotation() const; 260 | ci::vec3 getScale() const; 261 | 262 | bool isCamera() const { return camera != nullptr; } 263 | bool isLight() const { return light != nullptr; } 264 | bool hasMeshes() const { return ! meshes.empty(); } 265 | bool hasSkeletons() const { return ! skeletons.empty(); } 266 | bool hasSkin() const { return skin != nullptr; } 267 | bool isJoint() const { return ! jointName.empty(); } 268 | bool hasChildren() const { return ! children.empty(); } 269 | bool isRoot() const { return parent == nullptr; } 270 | 271 | void outputToConsole( std::ostream &os, uint8_t tabAmount ) const; 272 | 273 | Node *parent{nullptr}; 274 | Camera *camera{nullptr}; 275 | Skin *skin{nullptr}; 276 | Light *light{nullptr}; 277 | std::vector children, skeletons; 278 | std::vector meshes; 279 | std::string jointName; 280 | std::vector transformMatrix, // either 0 or 16 281 | rotation, // either 0 or 4 282 | translation, // either 0 or 3 283 | scale; // either 0 or 3 284 | 285 | std::string name, key; 286 | }; 287 | 288 | struct Program { 289 | Shader *frag{nullptr}, *vert{nullptr}; 290 | std::string name, key; 291 | std::vector attributes; 292 | }; 293 | 294 | struct Sampler { 295 | std::string name, key; 296 | GLenum magFilter{GL_LINEAR}, 297 | minFilter{GL_NEAREST_MIPMAP_LINEAR}, 298 | wrapS{GL_REPEAT}, 299 | wrapT{GL_REPEAT}; 300 | }; 301 | 302 | struct Shader { 303 | enum class Type { 304 | VERTEX = GL_VERTEX_SHADER, 305 | FRAGMENT = GL_FRAGMENT_SHADER 306 | }; 307 | 308 | const std::string& getSource() const; 309 | 310 | std::string name, key; 311 | std::string uri; // path 312 | Type type; 313 | 314 | private: 315 | void cacheData() const; 316 | 317 | mutable std::string source; 318 | friend class File; 319 | }; 320 | 321 | struct Skin { 322 | 323 | SkeletonRef createSkeleton() const; 324 | 325 | ci::mat4 bindShapeMatrix; 326 | Accessor *inverseBindMatrices{nullptr}; 327 | std::vector joints; 328 | std::string name, key; 329 | }; 330 | 331 | struct Technique { 332 | struct Parameter { 333 | std::string name; 334 | Node* node{nullptr}; 335 | std::string semantic; 336 | uint32_t count{0}; 337 | GLenum type; 338 | }; 339 | 340 | struct State { 341 | struct Functions { 342 | Functions(); 343 | std::array blendColor; 344 | std::array blendEquationSeparate; 345 | std::array blendFuncSeparate; 346 | std::array colorMask; 347 | std::array depthRange; 348 | std::array polygonOffset; 349 | std::array scissor; 350 | 351 | float lineWidth = 1.0f; 352 | GLenum cullFace = GL_BACK; 353 | GLenum depthFunc = GL_LESS; 354 | GLenum frontFace = GL_CCW; 355 | bool depthMask = true; 356 | }; 357 | std::vector enables; 358 | Functions functions; 359 | }; 360 | 361 | static ci::gl::UniformSemantic getUniformEnum( const std::string &uniform ); 362 | 363 | Program *program{nullptr}; 364 | std::string name, key; 365 | std::vector parameters; 366 | State states; 367 | std::vector> attributes, uniforms; 368 | }; 369 | 370 | struct Texture { 371 | Sampler *sampler{nullptr}; 372 | Image *image{nullptr}; 373 | GLenum format{GL_RGBA}, 374 | internalFormat{GL_RGBA}, 375 | target{GL_TEXTURE_2D}, 376 | type{GL_UNSIGNED_BYTE}; 377 | std::string name, key; 378 | }; 379 | 380 | } // gltf 381 | } // cinder 382 | 383 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Accessor &rhs ); 384 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Animation &rhs ); 385 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Asset &rhs ); 386 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::BufferView &rhs ); 387 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Buffer &rhs ); 388 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Camera &rhs ); 389 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Image &rhs ); 390 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Material &rhs ); 391 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Mesh &rhs ); 392 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Node &rhs ); 393 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Program &rhs ); 394 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Sampler &rhs ); 395 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Scene &rhs ); 396 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Shader &rhs ); 397 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Skin &rhs ); 398 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Technique &rhs ); 399 | std::ostream& operator<<( std::ostream &lhs, const ci::gltf::Texture &rhs ); 400 | 401 | --------------------------------------------------------------------------------