Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
i-saint committed Mar 10, 2021
0 parents commit f1e0c1b
Show file tree
Hide file tree
Showing 45 changed files with 7,151 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* text=auto
*.h text
*.c text
*.hpp text
*.cpp text

*.bat text eol=crlf
*.sln text eol=crlf
*.vcxproj text eol=crlf
*.vcxproj.filters text eol=crlf
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.user
*.png
*.fbx
*.abc
*.usd
*.usda
*.mqoz
*.wasm

.vs/
_out/
_tmp/
_dist/
_build_*
Externals/
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 i-saint

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
55 changes: 55 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(WebAlembicViewer)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE PATH "" FORCE)
endif()
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/_dist" CACHE PATH "" FORCE)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -std=c++17")
if (EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s FORCE_FILESYSTEM=1 -s ALLOW_MEMORY_GROWTH=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_GLFW=3 -s EXIT_RUNTIME=0")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --bind")

# download external libraries
set(EXTERNALS_URL "https://github.com/i-saint/WebAlembicViewer/releases/download/data/Externals.7z")
set(EXTERNALS_ARCHIVE "${CMAKE_SOURCE_DIR}/Externals/Externals.7z")
if(NOT EXISTS ${EXTERNALS_ARCHIVE})
file(DOWNLOAD ${EXTERNALS_URL} ${EXTERNALS_ARCHIVE} SHOW_PROGRESS)
execute_process(COMMAND 7za x -y -o${CMAKE_SOURCE_DIR}/Externals ${EXTERNALS_ARCHIVE})
endif()

set(ext_includes
${CMAKE_SOURCE_DIR}/Externals/include
${CMAKE_SOURCE_DIR}/Externals/include/OpenEXR
)
file(GLOB ext_libs ${CMAKE_SOURCE_DIR}/Externals/lib_emscripten/*.a)
else()
option(DISABLE_GL "disable OpenGL. mainly for benchmark test." OFF)
if(DISABLE_GL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DwabcDisableGL")
endif()

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
find_package(OpenEXR REQUIRED)
find_package(Alembic REQUIRED)
set(ext_includes ${ALEMBIC_INCLUDE_DIRS})
set(ext_libs ${ALEMBIC_LIBRARIES})
endif()

add_subdirectory(SmallFBX)

file(GLOB sources *.cpp *.h)
add_executable(WebAlembicViewer ${sources})
target_include_directories(WebAlembicViewer
PRIVATE
${CMAKE_SOURCE_DIR}
${ext_includes}
)
target_link_libraries(WebAlembicViewer
PRIVATE
SmallFBX
${ext_libs}
)
15 changes: 15 additions & 0 deletions src/SmallFBX.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include "SmallFBX/sfbxTypes.h"
#include "SmallFBX/sfbxProperty.h"
#include "SmallFBX/sfbxNode.h"
#include "SmallFBX/sfbxObject.h"
#include "SmallFBX/sfbxModel.h"
#include "SmallFBX/sfbxGeometry.h"
#include "SmallFBX/sfbxDeformer.h"
#include "SmallFBX/sfbxMaterial.h"
#include "SmallFBX/sfbxAnimation.h"
#include "SmallFBX/sfbxDocument.h"

#include "SmallFBX/sfbxMath.h"
#include "SmallFBX/sfbxUtil.h"
131 changes: 131 additions & 0 deletions src/SmallFBX.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SmallFBX\pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="SmallFBX\sfbxAnimation.cpp" />
<ClCompile Include="SmallFBX\sfbxDeformer.cpp" />
<ClCompile Include="SmallFBX\sfbxDocument.cpp" />
<ClCompile Include="SmallFBX\sfbxGeometry.cpp" />
<ClCompile Include="SmallFBX\sfbxMaterial.cpp" />
<ClCompile Include="SmallFBX\sfbxModel.cpp" />
<ClCompile Include="SmallFBX\sfbxNode.cpp" />
<ClCompile Include="SmallFBX\sfbxObject.cpp" />
<ClCompile Include="SmallFBX\sfbxProperty.cpp" />
<ClCompile Include="SmallFBX\sfbxUtils.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="SmallFBX.h" />
<ClInclude Include="SmallFBX\pch.h" />
<ClInclude Include="SmallFBX\sfbxAlgorithm.h" />
<ClInclude Include="SmallFBX\sfbxAnimation.h" />
<ClInclude Include="SmallFBX\sfbxDeformer.h" />
<ClInclude Include="SmallFBX\sfbxDocument.h" />
<ClInclude Include="SmallFBX\sfbxGeometry.h" />
<ClInclude Include="SmallFBX\sfbxInternal.h" />
<ClInclude Include="SmallFBX\sfbxMaterial.h" />
<ClInclude Include="SmallFBX\sfbxMath.h" />
<ClInclude Include="SmallFBX\sfbxMeta.h" />
<ClInclude Include="SmallFBX\sfbxModel.h" />
<ClInclude Include="SmallFBX\sfbxNode.h" />
<ClInclude Include="SmallFBX\sfbxObject.h" />
<ClInclude Include="SmallFBX\sfbxProperty.h" />
<ClInclude Include="SmallFBX\sfbxRawVector.h" />
<ClInclude Include="SmallFBX\sfbxTokens.h" />
<ClInclude Include="SmallFBX\sfbxTypes.h" />
<ClInclude Include="SmallFBX\sfbxUtil.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="setup.vcxproj">
<Project>{1c5de91b-7ae9-4304-9fa1-0de1aba8c02d}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Natvis Include="SmallFBX\sfbx.natvis" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3C7D88E0-B0D0-4E63-9F3F-75530B2DA797}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformToolset>v142</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<PlatformToolset>v142</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IncludePath>$(ProjectDir);$(ProjectDir)Externals\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)Externals\lib_win64;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
<OutDir>$(SolutionDir)_build_msvc\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)_build_msvc\obj\$(Platform)_$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalOptions>/Zo %(AdditionalOptions)</AdditionalOptions>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Full</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>false</OmitFramePointers>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<ControlFlowGuard>false</ControlFlowGuard>
<FunctionLevelLinking>true</FunctionLevelLinking>
<FloatingPointModel>Fast</FloatingPointModel>
<FloatingPointExceptions>false</FloatingPointExceptions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<GenerateMapFile>true</GenerateMapFile>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
9 changes: 9 additions & 0 deletions src/SmallFBX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
find_package(ZLIB REQUIRED)

file(GLOB sources *.h *.cpp)
add_library(SmallFBX STATIC ${sources})
target_include_directories(SmallFBX
PRIVATE
${CMAKE_SOURCE_DIR}
${ZLIB_INCLUDE_DIRS}
)
1 change: 1 addition & 0 deletions src/SmallFBX/pch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "pch.h"
19 changes: 19 additions & 0 deletions src/SmallFBX/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <cstdio>
#include <cstdint>
#include <cmath>
#include <ctime>

#include <string>
#include <string_view>
#include <vector>
#include <algorithm>
#include <functional>
#include <memory>
#include <fstream>
#include <type_traits>

#ifdef __cpp_lib_span
#include <span>
#endif
92 changes: 92 additions & 0 deletions src/SmallFBX/sfbx.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="sfbx::RawVector&lt;*&gt;">
<DisplayString>{{ size={m_size}</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple">m_size</Item>
<Item Name="[capacity]" ExcludeView="simple">m_capacity</Item>
<Item Name="[address]" ExcludeView="simple">m_data</Item>
<ArrayItems>
<Size>m_size</Size>
<ValuePointer>m_data</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<Type Name="sfbx::Property">
<DisplayString Condition="m_type==PropertyType::Bool">{{ value={m_scalar.b.value} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Int16">{{ value={m_scalar.i16} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Int32">{{ value={m_scalar.i32} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Int64">{{ value={m_scalar.i64} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Float32">{{ value={m_scalar.f32} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Float64">{{ value={m_scalar.f64} type={m_type} }}</DisplayString>

<DisplayString Condition="m_type==PropertyType::BoolArray">{{ size={m_data.m_size/1} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Int16Array">{{ size={m_data.m_size/2} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Int32Array">{{ size={m_data.m_size/4} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Int64Array">{{ size={m_data.m_size/8} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Int64Array">{{ size={m_data.m_size/8} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Float32Array">{{ size={m_data.m_size/4} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Float64Array">{{ size={m_data.m_size/8} type={m_type} }}</DisplayString>

<DisplayString Condition="m_type==PropertyType::String">{{ value={m_data.m_data,s} type={m_type} }}</DisplayString>
<DisplayString Condition="m_type==PropertyType::Blob">{{ value={m_data.m_data,s} type={m_type} }}</DisplayString>

<Expand>
<Item Name="value" Condition="m_type==PropertyType::Bool">m_scalar.b.value</Item>
<Item Name="value" Condition="m_type==PropertyType::Int16">m_scalar.i16</Item>
<Item Name="value" Condition="m_type==PropertyType::Int32">m_scalar.i32</Item>
<Item Name="value" Condition="m_type==PropertyType::Int64">m_scalar.i64</Item>
<Item Name="value" Condition="m_type==PropertyType::Float32">m_scalar.f32</Item>
<Item Name="value" Condition="m_type==PropertyType::Float64">m_scalar.f64</Item>

<Item Name="[size]" Condition="m_type==PropertyType::BoolArray">m_data.m_size</Item>
<ArrayItems Condition="m_type==PropertyType::BoolArray">
<Size>m_data.m_size</Size>
<ValuePointer>(sfbx::boolean*)m_data.m_data</ValuePointer>
</ArrayItems>

<Item Name="[size]" Condition="m_type==PropertyType::Int16Array">m_data.m_size/2</Item>
<ArrayItems Condition="m_type==PropertyType::Int16Array">
<Size>m_data.m_size/2</Size>
<ValuePointer>(int16*)m_data.m_data</ValuePointer>
</ArrayItems>

<Item Name="[size]" Condition="m_type==PropertyType::Int32Array">m_data.m_size/4</Item>
<ArrayItems Condition="m_type==PropertyType::Int32Array">
<Size>m_data.m_size/4</Size>
<ValuePointer>(int32*)m_data.m_data</ValuePointer>
</ArrayItems>

<Item Name="[size]" Condition="m_type==PropertyType::Int64Array">m_data.m_size/8</Item>
<ArrayItems Condition="m_type==PropertyType::Int64Array">
<Size>m_data.m_size/8</Size>
<ValuePointer>(int64*)m_data.m_data</ValuePointer>
</ArrayItems>

<Item Name="[size]" Condition="m_type==PropertyType::Float32Array">m_data.m_size/4</Item>
<ArrayItems Condition="m_type==PropertyType::Float32Array">
<Size>m_data.m_size/4</Size>
<ValuePointer>(float32*)m_data.m_data</ValuePointer>
</ArrayItems>

<Item Name="[size]" Condition="m_type==PropertyType::Float64Array">m_data.m_size/8</Item>
<ArrayItems Condition="m_type==PropertyType::Float64Array">
<Size>m_data.m_size/8</Size>
<ValuePointer>(float64*)m_data.m_data</ValuePointer>
</ArrayItems>

<Item Name="[size]" Condition="m_type==PropertyType::String">m_data.m_size</Item>
<ArrayItems Condition="m_type==PropertyType::String">
<Size>m_data.m_size</Size>
<ValuePointer>(char*)m_data.m_data</ValuePointer>
</ArrayItems>

<Item Name="[size]" Condition="m_type==PropertyType::Blob">m_data.m_size</Item>
<ArrayItems Condition="m_type==PropertyType::Blob">
<Size>m_data.m_size</Size>
<ValuePointer>(char*)m_data.m_data</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
Loading

0 comments on commit f1e0c1b

Please sign in to comment.