diff --git a/ExternalUtilities.meta b/ExternalUtilities.meta new file mode 100644 index 0000000..17608e5 --- /dev/null +++ b/ExternalUtilities.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce65e2e249b6c89499f485ffcf3091f8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software.meta b/ExternalUtilities/KTX-Software.meta new file mode 100644 index 0000000..f6b9e35 --- /dev/null +++ b/ExternalUtilities/KTX-Software.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ed9000fcac301514db1298f744af9ede +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/Uninstall.exe b/ExternalUtilities/KTX-Software/Uninstall.exe new file mode 100644 index 0000000..06d5447 Binary files /dev/null and b/ExternalUtilities/KTX-Software/Uninstall.exe differ diff --git a/ExternalUtilities/KTX-Software/Uninstall.exe.meta b/ExternalUtilities/KTX-Software/Uninstall.exe.meta new file mode 100644 index 0000000..03739c3 --- /dev/null +++ b/ExternalUtilities/KTX-Software/Uninstall.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9adcb89d9a25f09469deab87f945173f +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/bin.meta b/ExternalUtilities/KTX-Software/bin.meta new file mode 100644 index 0000000..6c6cd26 --- /dev/null +++ b/ExternalUtilities/KTX-Software/bin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf692e66ed1bbbc4d9dde8156da38401 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/bin/ktx.dll b/ExternalUtilities/KTX-Software/bin/ktx.dll new file mode 100644 index 0000000..617edbd Binary files /dev/null and b/ExternalUtilities/KTX-Software/bin/ktx.dll differ diff --git a/ExternalUtilities/KTX-Software/bin/ktx.dll.meta b/ExternalUtilities/KTX-Software/bin/ktx.dll.meta new file mode 100644 index 0000000..ce0ff1a --- /dev/null +++ b/ExternalUtilities/KTX-Software/bin/ktx.dll.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 7ff5105191d0fba4aa69819dc07b9d43 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/bin/ktx2check.exe b/ExternalUtilities/KTX-Software/bin/ktx2check.exe new file mode 100644 index 0000000..33f2c3e Binary files /dev/null and b/ExternalUtilities/KTX-Software/bin/ktx2check.exe differ diff --git a/ExternalUtilities/KTX-Software/bin/ktx2check.exe.meta b/ExternalUtilities/KTX-Software/bin/ktx2check.exe.meta new file mode 100644 index 0000000..483ec98 --- /dev/null +++ b/ExternalUtilities/KTX-Software/bin/ktx2check.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 52c28bdbc36abcc42ad471ed1d24589d +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/bin/ktx2ktx2.exe b/ExternalUtilities/KTX-Software/bin/ktx2ktx2.exe new file mode 100644 index 0000000..2efcf8d Binary files /dev/null and b/ExternalUtilities/KTX-Software/bin/ktx2ktx2.exe differ diff --git a/ExternalUtilities/KTX-Software/bin/ktx2ktx2.exe.meta b/ExternalUtilities/KTX-Software/bin/ktx2ktx2.exe.meta new file mode 100644 index 0000000..8863b74 --- /dev/null +++ b/ExternalUtilities/KTX-Software/bin/ktx2ktx2.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 165df6741644f274db9507ece3035eed +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/bin/ktxinfo.exe b/ExternalUtilities/KTX-Software/bin/ktxinfo.exe new file mode 100644 index 0000000..edfb70d Binary files /dev/null and b/ExternalUtilities/KTX-Software/bin/ktxinfo.exe differ diff --git a/ExternalUtilities/KTX-Software/bin/ktxinfo.exe.meta b/ExternalUtilities/KTX-Software/bin/ktxinfo.exe.meta new file mode 100644 index 0000000..466c43b --- /dev/null +++ b/ExternalUtilities/KTX-Software/bin/ktxinfo.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1760d73ddfe2fc3489049d825ddf20c6 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/bin/ktxsc.exe b/ExternalUtilities/KTX-Software/bin/ktxsc.exe new file mode 100644 index 0000000..75ee977 Binary files /dev/null and b/ExternalUtilities/KTX-Software/bin/ktxsc.exe differ diff --git a/ExternalUtilities/KTX-Software/bin/ktxsc.exe.meta b/ExternalUtilities/KTX-Software/bin/ktxsc.exe.meta new file mode 100644 index 0000000..06dc6cf --- /dev/null +++ b/ExternalUtilities/KTX-Software/bin/ktxsc.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f1b06f00d2fa5e64fb406a61d7bc52db +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/bin/toktx.exe b/ExternalUtilities/KTX-Software/bin/toktx.exe new file mode 100644 index 0000000..211a76f Binary files /dev/null and b/ExternalUtilities/KTX-Software/bin/toktx.exe differ diff --git a/ExternalUtilities/KTX-Software/bin/toktx.exe.meta b/ExternalUtilities/KTX-Software/bin/toktx.exe.meta new file mode 100644 index 0000000..b03a195 --- /dev/null +++ b/ExternalUtilities/KTX-Software/bin/toktx.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: cb7667a180fafbf4ba4803eba0f3d41c +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/lib.meta b/ExternalUtilities/KTX-Software/lib.meta new file mode 100644 index 0000000..aea3ee6 --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b693ff03b11e9bf4e8fbffcda5c6c86b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/lib/cmake.meta b/ExternalUtilities/KTX-Software/lib/cmake.meta new file mode 100644 index 0000000..65a41ff --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fb13c13a8bd33c741b7176c9e21b624d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/lib/cmake/ktx.meta b/ExternalUtilities/KTX-Software/lib/cmake/ktx.meta new file mode 100644 index 0000000..abdb2bf --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake/ktx.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4c8063d274a92e44cb3289355671ade6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfig.cmake b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfig.cmake new file mode 100644 index 0000000..6386ba2 --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfig.cmake @@ -0,0 +1,7 @@ +# Copyright 2015-2020 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 + +# include(CMakeFindDependencyMacro) +# find_dependency() + +include("${CMAKE_CURRENT_LIST_DIR}/KtxTargets.cmake") diff --git a/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfig.cmake.meta b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfig.cmake.meta new file mode 100644 index 0000000..e375eaf --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfig.cmake.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: dd8cc3eb2b9031649b1aee2687e2d36d +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfigVersion.cmake b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfigVersion.cmake new file mode 100644 index 0000000..dc97b44 --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfigVersion.cmake @@ -0,0 +1,67 @@ +# This is a basic version file for the Config-mode of find_package(). +# It is used by write_basic_package_version_file() as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, +# but only if the requested major version is the same as the current one. +# The variable CVF_VERSION must be set before calling configure_file(). + + +set(PACKAGE_VERSION "4.0.0") + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + + if("4.0.0" MATCHES "^([0-9]+)\\.") + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") + else() + set(CVF_VERSION_MAJOR "4.0.0") + endif() + + if(PACKAGE_FIND_VERSION_RANGE) + # both endpoints of the range must have the expected major version + math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1") + if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + else() + if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() + endif() +endif() + + +# if the installed project requested no architecture check, don't perform the check +if("FALSE") + return() +endif() + +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "") + return() +endif() + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8") + math(EXPR installedBits "8 * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfigVersion.cmake.meta b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfigVersion.cmake.meta new file mode 100644 index 0000000..c9c70de --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxConfigVersion.cmake.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: dcafdd46b8ba6534ab464036d66f83d9 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets-release.cmake b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets-release.cmake new file mode 100644 index 0000000..618aef4 --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets-release.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "KTX::ktx" for configuration "Release" +set_property(TARGET KTX::ktx APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(KTX::ktx PROPERTIES + IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/ktx.lib" + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/ktx.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS KTX::ktx ) +list(APPEND _IMPORT_CHECK_FILES_FOR_KTX::ktx "${_IMPORT_PREFIX}/lib/ktx.lib" "${_IMPORT_PREFIX}/bin/ktx.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets-release.cmake.meta b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets-release.cmake.meta new file mode 100644 index 0000000..9c56ffc --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets-release.cmake.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bf08966c01ec65f4c920a22e0503cfee +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets.cmake b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets.cmake new file mode 100644 index 0000000..0ac0894 --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets.cmake @@ -0,0 +1,96 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6...3.18) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget KTX::ktx) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target KTX::ktx +add_library(KTX::ktx SHARED IMPORTED) + +set_target_properties(KTX::ktx PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "\$<\$:_DEBUG;DEBUG>;BASISU_NO_ITERATOR_DEBUG_LEVEL;KTX_FEATURE_KTX1;KTX_FEATURE_KTX2;KTX_FEATURE_WRITE" + INTERFACE_COMPILE_FEATURES "c_std_99;cxx_std_11" + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" +) + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/KtxTargets-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets.cmake.meta b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets.cmake.meta new file mode 100644 index 0000000..7de3b2c --- /dev/null +++ b/ExternalUtilities/KTX-Software/lib/cmake/ktx/KtxTargets.cmake.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 93919488e10582b42b39b81ca876b1d7 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/share.meta b/ExternalUtilities/KTX-Software/share.meta new file mode 100644 index 0000000..7fb8b4f --- /dev/null +++ b/ExternalUtilities/KTX-Software/share.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f8cb1ce6c53c79946b6966c25b4eaa0e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/share/man.meta b/ExternalUtilities/KTX-Software/share/man.meta new file mode 100644 index 0000000..2cfc4c2 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6ad360380950d094e8a3aafc7cd6bf51 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/share/man/man1.meta b/ExternalUtilities/KTX-Software/share/man/man1.meta new file mode 100644 index 0000000..01a1b23 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d8f0a1f7febf9824586c78f5e9322253 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/share/man/man1/ktx2check.1 b/ExternalUtilities/KTX-Software/share/man/man1/ktx2check.1 new file mode 100644 index 0000000..99b8aa4 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/ktx2check.1 @@ -0,0 +1,42 @@ +.TH "ktx2check" 1 "Tue Apr 20 2021" "Version 4.0.0" "Khronos Texture Tools" \" -*- nroff -*- +.ad l +.nh +.SH NAME +ktx2check \- Check the validity of a KTX 2 file\&. +.SH "SYNOPSIS" +.PP +ktx2check [options] [\fIinfile\fP \&.\&.\&.] +.SH "DESCRIPTION" +.PP +\fBktx2check\fP validates Khronos texture format version 2 files (KTX2)\&. It reads each named \fIinfile\fP and validates it writing to stdout messages about any issues found\&. When \fBinfile\fP is not specified, it validates a single file from stdin\&. +.PP +The following options are available: +.IP "\fB-q, --quiet \fP" 1c +Validate silently\&. Indicate valid or invalid via exit code\&. +.IP "\fB-m , --max-issues \fP" 1c +Set the maximum number of issues to be reported per file provided -q is not set\&. +.IP "\fB-w, --warn-as-error \fP" 1c +Treat warnings as errors\&. Changes exit code from success to error\&. +.PP +.IP "\fB--help \fP" 1c +Print this usage message and exit\&. +.IP "\fB--version \fP" 1c +Print the version number of this program and exit\&. +.PP + +.SH "EXIT STATUS" +.PP +\fBtoktx\fP exits 0 on success, 1 on command line errors and 2 on validation errors\&. +.SH "HISTORY" +.PP +\fBVersion 4\&.0\fP +.RS 4 + +.IP "\(bu" 2 +Initial version\&. +.PP +.RE +.PP +.SH "AUTHOR" +.PP +Mark Callow, Edgewise Consulting www\&.edgewise-consulting\&.com diff --git a/ExternalUtilities/KTX-Software/share/man/man1/ktx2check.1.meta b/ExternalUtilities/KTX-Software/share/man/man1/ktx2check.1.meta new file mode 100644 index 0000000..516d80f --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/ktx2check.1.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e6dc3320db58986459b2f0e664e0d0ec +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/share/man/man1/ktx2ktx2.1 b/ExternalUtilities/KTX-Software/share/man/man1/ktx2ktx2.1 new file mode 100644 index 0000000..07487d6 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/ktx2ktx2.1 @@ -0,0 +1,41 @@ +.TH "ktx2ktx2" 1 "Tue Apr 20 2021" "Version 4.0.0" "Khronos Texture Tools" \" -*- nroff -*- +.ad l +.nh +.SH NAME +ktx2ktx2 \- Create a KTX 2 file from a KTX file\&. +.SH "SYNOPSIS" +.PP +ktx2ktx2 [options] [\fIinfile\fP \&.\&.\&.] +.SH "DESCRIPTION" +.PP +\fBktx2ktx2\fP creates Khronos texture format version 2 files (KTX2) from Khronos texture format version 1 files\&. \fBktx2ktx2\fP reads each named \fIinfile\fP\&. Output files have the same name as the input but with the extension changed to \fC\fP\&.ktx2\&. When \fBinfile\fP is not specified, a single file will be read from stdin and the output written to standard out\&. +.PP +If unrecognized metadata with keys beginning 'KTX' or 'ktx' is found in the input file, it is dropped and a warning is written to standard error\&. +.PP +The following options are available: +.IP "\fB-b, --rewritebado \fP" 1c +Rewrite bad orientation metadata\&. Some in-the-wild KTX files have orientation metadata with the key 'KTXOrientation' instead of KTXorientaion\&. This option will rewrite such bad metadata instead of dropping it\&. +.IP "\fB-o outfile, --output=outfile \fP" 1c +Name the output file \fIoutfile\fP\&. If \fIoutfile\fP is 'stdout', output will be written to stdout\&. If there is more than 1 input file, the command prints its usage message and exits\&. +.IP "\fB-d outdir, --output-dir=outdir \fP" 1c +Writes the output files to the directory \fIoutdir\fP\&. If both \fB--output\fP and \fB--output-dir\fP are specified, \fIoutfile\fP will be written in \fIoutdir\fP\&. If \fBinfile\fP is \fIstdin\fP or \fBoutfile\fP is \fIstdout\fP, the command prints its usage message and exits\&. +.IP "\fB-f, --force \fP" 1c +If the destination file already exists, remove it and create a new file, without prompting for confirmation regardless of its permissions\&. +.PP +.PP +.SH "EXIT STATUS" +.PP +\fBtoktx\fP exits 0 on success, 1 on command line errors and 2 on functional errors\&. +.SH "HISTORY" +.PP +\fBVersion 4\&.0\fP +.RS 4 + +.IP "\(bu" 2 +Initial version\&. +.PP +.RE +.PP +.SH "AUTHOR" +.PP +Mark Callow, Edgewise Consulting www\&.edgewise-consulting\&.com diff --git a/ExternalUtilities/KTX-Software/share/man/man1/ktx2ktx2.1.meta b/ExternalUtilities/KTX-Software/share/man/man1/ktx2ktx2.1.meta new file mode 100644 index 0000000..27f0d77 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/ktx2ktx2.1.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 51a492810566fcf408a5f35bd4e5f967 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/share/man/man1/ktxinfo.1 b/ExternalUtilities/KTX-Software/share/man/man1/ktxinfo.1 new file mode 100644 index 0000000..52e6c3a --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/ktxinfo.1 @@ -0,0 +1,39 @@ +.TH "ktxinfo" 1 "Tue Apr 20 2021" "Version 4.0.0" "Khronos Texture Tools" \" -*- nroff -*- +.ad l +.nh +.SH NAME +ktxinfo \- Print information about a KTX or KTX2 file\&. +.SH "SYNOPSIS" +.PP +ktxinfo [options] [\fIinfile\fP \&.\&.\&.] +.SH "DESCRIPTION" +.PP +\fBktxinfo\fP prints information about the KTX files provided as arguments\&. If no arguments are given, it prints information about a single file read from standard input\&. +.PP +\fBNote\fP +.RS 4 +\fBktxinfo\fP prints using UTF-8 encoding\&. If your console is not set for UTF-8 you will see incorrect characters in output of the file identifier on each side of the 'KTX nn'\&. +.RE +.PP +The following options are available: +.IP "\fB--help \fP" 1c +Print this usage message and exit\&. +.IP "\fB--version \fP" 1c +Print the version number of this program and exit\&. +.PP +.SH "EXIT STATUS" +.PP +\fBktxinfo\fP exits 0 on success, 1 on command line errors and 2 if one of the input files is not a KTX file\&. +.SH "HISTORY" +.PP +\fBVersion 4\&.0\fP +.RS 4 + +.IP "\(bu" 2 +Initial version +.PP +.RE +.PP +.SH "AUTHOR" +.PP +Mark Callow, Edgewise Consulting www\&.edgewise-consulting\&.com diff --git a/ExternalUtilities/KTX-Software/share/man/man1/ktxinfo.1.meta b/ExternalUtilities/KTX-Software/share/man/man1/ktxinfo.1.meta new file mode 100644 index 0000000..7418ba2 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/ktxinfo.1.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0e94a29e5becad945b3d74f28f86b2b1 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/share/man/man1/ktxsc.1 b/ExternalUtilities/KTX-Software/share/man/man1/ktxsc.1 new file mode 100644 index 0000000..1060027 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/ktxsc.1 @@ -0,0 +1,113 @@ +.TH "ktxsc" 1 "Tue Apr 20 2021" "Version 4.0.0" "Khronos Texture Tools" \" -*- nroff -*- +.ad l +.nh +.SH NAME +ktxsc \- Supercompress the images in a KTX2 file\&. +.SH "SYNOPSIS" +.PP +ktxsc [options] [\fIinfile\fP \&.\&.\&.] +.SH "DESCRIPTION" +.PP +\fBktxsc\fP can encode and supercompresses the images in Khronos texture format version 2 files (KTX2) \&. Uncompressed files, i\&.e those whose vkFormat name does not end in \fC_BLOCK\fP can be encoded to Basis Universal (encoded to ETC1S then supercompressed with an integrated LZ step), encoded to UASTC or supercompressed with Zstandard (zstd)\&. Any image format, except Basis Universal, can be supercompressed with zstd\&. For best results with UASTC, the data should be conditioned for zstd by using the \fI--uastc_rdo_q\fP and, optionally, \fI--uastc_rdo_d\fP options\&. +.PP +\fBktxsc\fP reads each named \fIinfile\fP and compresses it in place\&. When \fIinfile\fP is not specified, a single file will be read from \fIstdin\fP\&. and the output written to \fIstdout\fP\&. When one or more files is specified each will be compressed in place\&. +.PP +The following options are available: +.IP "\fB-o outfile, --output=outfile \fP" 1c +Write the output to \fIoutfile\fP\&. If \fIoutfile\fP is 'stdout', output will be written to stdout\&. If there is more than 1 \fIinfile\fP the command prints its usage message and exits\&. +.IP "\fB-f, --force \fP" 1c +If the destination file cannot be opened, remove it and create a new file, without prompting for confirmation regardless of its permissions\&. +.IP "\fB--t2 \fP" 1c +Output a KTX version2 file\&. Always true\&. +.PP +.IP "\fB--bcmp \fP" 1c +Supercompress the image data with ETC1S / BasisLZ\&. Implies \fB--t2\fP\&. RED images will become RGB with RED in each component\&. RG images will have R in the RGB part and G in the alpha part of the compressed texture\&. When set, the following BasisLZ-related options become valid otherwise they are ignored\&. +.IP "\fB--no_multithreading \fP" 1c +Disable multithreading\&. Deprecated\&. For backward compatibility only\&. Use \fB--threads\fP 1 instead\&. +.IP "\fB--threads \fP" 1c +Explicitly set the number of threads to use during compression\&. By default, ETC1S / BasisLZ compression will use the number of threads reported by \fCthread::hardware_concurrency\fP or 1 if value returned is 0\&. +.IP "\fB--clevel \fP" 1c +ETC1S / BasisLZ compression level, an encoding speed vs\&. quality tradeoff\&. Range is [0,5], default is 1\&. Higher values are slower, but give higher quality\&. +.IP "\fB--qlevel \fP" 1c +ETC1S / BasisLZ quality level\&. Range is [1,255]\&. Lower gives better compression/lower quality/faster\&. Higher gives less compression /higher quality/slower\&. \fB--qlevel\fP automatically determines values for \fB--max_endpoints\fP, \fB--max-selectors\fP, \fB--endpoint_rdo_threshold\fP and \fB--selector_rdo_threshold\fP for the target quality level\&. Setting these options overrides the values determined by \fB--qlevel\fP which defaults to 128 if neither it nor both of \fB--max_endpoints\fP and \fB--max_selectors\fP have been set\&. +.PP +\fBNote\fP +.RS 4 +Both of \fB--max_endpoints\fP and \fB--max_selectors\fP must be set for them to have any effect\&. If all three options are set, a warning will be issued that \fB--qlevel\fP will be ignored\&. +.PP +\fB--qlevel\fP will only determine values for \fB--endpoint_rdo_threshold\fP and \fB--selector_rdo_threshold\fP when its value exceeds 128, otherwise their defaults will be used\&. +.RE +.PP +.IP "\fB--max_endpoints \fP" 1c +Manually set the maximum number of color endpoint clusters\&. Range is [1,16128]\&. Default is 0, unset\&. If this is set, \fB--max_selectors\fP must also be set, otherwise the value will be ignored\&. +.IP "\fB--endpoint_rdo_threshold \fP" 1c +Set endpoint RDO quality threshold\&. The default is 1\&.25\&. Lower is higher quality but less quality per output bit (try [1\&.0,3\&.0])\&. This will override the value chosen by \fB--qlevel\fP\&. +.IP "\fB--max_selectors \fP" 1c +Manually set the maximum number of color selector clusters\&. Range is [1,16128]\&. Default is 0, unset\&. If this is set, \fB--max_selectors\fP must also be set, otherwise the value will be ignored\&. +.IP "\fB--selector_rdo_threshold \fP" 1c +Set selector RDO quality threshold\&. The default is 1\&.5\&. Lower is higher quality but less quality per output bit (try [1\&.0,3\&.0]\&. This will override the value chosen by \fB--qlevel\fP\&. +.IP "\fB--normal_map \fP" 1c +Tunes codec parameters for better quality on normal maps (no selector RDO, no endpoint RDO)\&. Only valid for linear textures\&. +.IP "\fB--separate_rg_to_color_alpha \fP" 1c +Separates the input R and G channels to RGB and A (for tangent space XY normal maps)\&. Only needed with 3 or 4 component input images\&. +.IP "\fB--no_endpoint_rdo \fP" 1c +Disable endpoint rate distortion optimizations\&. Slightly faster, less noisy output, but lower quality per output bit\&. Default is to do endpoint RDO\&. +.IP "\fB--no_selector_rdo \fP" 1c +Disable selector rate distortion optimizations\&. Slightly faster, less noisy output, but lower quality per output bit\&. Default is to do selector RDO\&. +.PP +.IP "\fB--uastc [] \fP" 1c +Create a texture in high-quality transcodable UASTC format\&. Implies \fB--t2\fP\&. The optional parameter \fIlevel\fP selects a speed vs quality tradeoff as shown in the following table: +.PP +Level Speed Quality 0 Fastest 43\&.45dB 1 Faster 46\&.49dB 2 Default 47\&.47dB 3 Slower 48\&.01dB 4 Very slow 48\&.24dB +.PP +You are strongly encouraged to also specify \fB--zcmp\fP to losslessly compress the UASTC data\&. This and any LZ-style compression can be made more effective by conditioning the UASTC texture data using the Rate Distortion Optimization (RDO) post-process stage\&. When \fB--uastc\fP is set the following options become available for controlling RDO: +.IP "\fB--uastc_rdo_l [] \fP" 1c +Enable UASTC RDO post-processing and optionally set UASTC RDO quality scalar (lambda) to \fIlambda\fP\&. Lower values yield higher quality/larger LZ compressed files, higher values yield lower quality/smaller LZ compressed files\&. A good range to try is [\&.25,10]\&. For normal maps a good range is [\&.25-\&.75]\&. The full range is [\&.001,10\&.0]\&. Default is 1\&.0\&. +.PP +\fBNote\fP +.RS 4 +Previous versions used the \fB--uastc_rdo_q\fP option which was removed because the RDO algorithm changed\&. +.RE +.PP +.IP "\fB--uastc_rdo_d \fP" 1c +Set UASTC RDO dictionary size in bytes\&. Default is 4096\&. Lower values=faster, but give less compression\&. Range is [64,65536]\&. +.IP "\fB--uastc_rdo_b \fP" 1c +Set UASTC RDO max smooth block error scale\&. Range is [1\&.0,300\&.0]\&. Default is 10\&.0, 1\&.0 is disabled\&. Larger values suppress more artifacts (and allocate more bits) on smooth blocks\&. +.IP "\fB--uastc_rdo_s \fP" 1c +Set UASTC RDO max smooth block standard deviation\&. Range is [\&.01,65536\&.0]\&. Default is 18\&.0\&. Larger values expand the range of blocks considered smooth\&. +.IP "\fB--uastc_rdo_f \fP" 1c +Do not favor simpler UASTC modes in RDO mode\&. +.IP "\fB--uastc_rdo_m \fP" 1c +Disable RDO multithreading (slightly higher compression, deterministic)\&. +.PP +.IP "\fB--no_sse \fP" 1c +Forbid use of the SSE instruction set\&. Ignored if CPU does not support SSE\&. Only the Basis Universal compressor uses SSE\&. +.IP "\fB--verbose \fP" 1c +Print encoder/compressor activity status to stdout\&. Currently only the Basis Universal compressor emits status\&. +.IP "\fB--zcmp [] \fP" 1c +Supercompress the data with Zstandard\&. Implies \fB--t2\fP\&. Can be used with data in any format except ETC1S / BasisLZ (\fB--bcmp\fP)\&. Most effective with RDO-conditioned UASTC or uncompressed formats\&. The optional \fIcompressionLevel\fP range is 1 - 22 and the default is 3\&. Lower values=faster but give less compression\&. Values above 20 should be used with caution as they require more memory\&. +.PP +.IP "\fB--help \fP" 1c +Print this usage message and exit\&. +.IP "\fB--version \fP" 1c +Print the version number of this program and exit\&. +.PP + In case of ambiguity, such as when the last option is one with an optional parameter, separate options from file names with ' -- '\&. +.PP +Any specified ETC1S / BasisLZ and supercompression options are recorded in the metadata item \fCKTXwriterScParams\fP in the output file\&. +.SH "EXIT STATUS" +.PP +\fBtoktx\fP exits 0 on success, 1 on command line errors and 2 on functional errors\&. +.SH "HISTORY" +.PP +\fBVersion 4\&.0\fP +.RS 4 + +.IP "\(bu" 2 +Initial version\&. +.PP +.RE +.PP +.SH "AUTHOR" +.PP +Mark Callow, Edgewise Consulting www\&.edgewise-consulting\&.com diff --git a/ExternalUtilities/KTX-Software/share/man/man1/ktxsc.1.meta b/ExternalUtilities/KTX-Software/share/man/man1/ktxsc.1.meta new file mode 100644 index 0000000..96042c1 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/ktxsc.1.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 050aea7d2991d6749abcea6f1907f364 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/KTX-Software/share/man/man1/toktx.1 b/ExternalUtilities/KTX-Software/share/man/man1/toktx.1 new file mode 100644 index 0000000..0c2f028 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/toktx.1 @@ -0,0 +1,227 @@ +.TH "toktx" 1 "Tue Apr 20 2021" "Version 4.0.0" "Khronos Texture Tools" \" -*- nroff -*- +.ad l +.nh +.SH NAME +toktx \- Create a KTX file from JPEG, PNG or netpbm format files\&. +.SH "SYNOPSIS" +.PP +toktx [options] \fIoutfile\fP [\fIinfile\fP\&.{pam,pgm,ppm} \&.\&.\&.] +.SH "DESCRIPTION" +.PP +Create a Khronos format texture file (KTX) from a set of JPEG (\&.jpg), PNG (\&.png) or Netpbm format (\&.pam, \&.pgm, \&.ppm) images\&. It writes the destination ktx file to \fIoutfile\fP, appending '\&.ktx{,2}' if necessary\&. If \fIoutfile\fP is '-' the output will be written to stdout\&. +.PP +\fBtoktx\fP reads each named \fIinfile\fP\&. which must be in \&.jpg, \&.png, \&.pam, \&.ppm or \&.pgm format\&. \fIinfiles\fP prefixed with '@' are read as text files listing actual file names to process with one file path per line\&. Paths must be absolute or relative to the current directory when \fBtoktx\fP is run\&. If '@@' is used instead, paths must be absolute or relative to the location of the list file\&. +.PP +The target texture type (number of components in the output texture) is chosen via \fB--target_type\fP\&. Swizzling of the components of the input file is specified with \fB--input_swizzle\fP and swizzzle metadata can be specified with \fB--swizzle\fP\&. Defaults, shown in the following table, are based on the components of the input file and whether the target texture format is uncompressed or block-compressed including the universal formats\&. Input components are arbitrarily labeled r, g, b & a\&. +.PP +Uncompressed Formats Block-compressed formats Input components 1 (greyscale) 2 (greyscale alpha) 3 4 1 2 3 4 Target type R RG RGB RGBA RGB RGBA RGB RGBA Input swizzle - - - - rrr1 rrrg - - Swizzle rrr1 rrrg - - - - - - +.PP +As can be seen from the table one- and two-component inputs are treated as luminance{,-alpha} in accordance with the JPEG and PNG specifications\&. For consistency Netpbm inputs are handled the same way\&. Use of R & RG types for uncompressed formats saves space but note that the sRGB versions of these formats are not widely supported so a warning will be issued prompting you to convert the input to linear\&. +.PP +The primaries, transfer function (OETF) and the texture's sRGB-ness is set based on the input file unless \fB--assign_oetf\fP linear or \fB--assign_oetf\fP srgb is specified\&. For \&.jpg files \fBtoktx\fP always sets BT709/sRGB primaries and the sRGB OETF in the output file and creates sRGB format textures\&. Netpbm files always use BT\&.709/sRGB primaries and the BT\&.709 OETF\&. \fBtoktx\fP tranforms these images to the sRGB OETF, sets BT709/sRGB primaries and the sRGB OETF in the output file and creates sRGB format textures\&. +.PP +For \&.png files the OETF is set as follows: +.PP +.IP "\fBNo color-info chunks or sRGB chunk present: \fP" 1c +primaries are set to BT\&.709 and OETF to sRGB\&. +.IP "\fBsRGB chunk present: \fP" 1c +primaries are set to BT\&.709 and OETF to sRGB\&. gAMA and cHRM chunks are ignored\&. +.IP "\fBiCCP chunk present: \fP" 1c +General ICC profiles are not yet supported by toktx or the KTX2 format\&. In future these images may be transformed to linear or sRGB OETF as appropriate for the profile\&. sRGB chunk must not be present\&. +.IP "\fBgAMA and/or cHRM chunks present without sRGB or iCCP: \fP" 1c +If gAMA is < 60000 the image is transformed to and the OETF is set to sRGB\&. otherwise the image is transformed to and the OETF is set to linear\&. The color primaries in cHRM are matched to one of the standard sets listed in the Khronos Data Format Specification (the KHR_DF_PRIMARIES values from khr_df\&.h) and the primaries field of the output file's DFD is set to the matched value\&. If no match is found the primaries field is set to UNSPECIFIED\&. +.PP +.PP +The following options are always available: +.IP "\fB--2d \fP" 1c +If the image height is 1, by default a KTX file for a 1D texture is created\&. With this option one for a 2D texture is created instead\&. +.IP "\fB--automipmap \fP" 1c +Causes the KTX file to be marked to request generation of a mipmap pyramid when the file is loaded\&. This option is mutually exclusive with \fB--genmipmap\fP, \fB--levels\fP and \fB--mipmap\fP\&. +.IP "\fB--cubemap \fP" 1c +KTX file is for a cubemap\&. At least 6 \fIinfiles\fP must be provided, more if \fB--mipmap\fP or \fB--layers\fP is also specified\&. Provide the images in the order +X, -X, +Y, -Y, +Z, -Z where the arrangement is a left-handed coordinate system with +Y up\&. So if you're facing +Z, -X will be on your left and +X on your right\&. If \fB--layers\fP > 1 is specified, provide the faces for layer 0 first then for layer 1, etc\&. Images must have an upper left origin so --lower_left_maps_to_s0t0 is ignored with this option\&. +.IP "\fB--depth \fP" 1c +KTX file is for a 3D texture with a depth of \fInumber\fP where \fInumber\fP > 1\&. Provide the file(s) for z=0 first then those for z=1, etc\&. It is an error to specify this together with \fB--layers\fP > 1 or \fB--cubemap\fP\&. +.IP "\fB--genmipmap \fP" 1c +Causes mipmaps to be generated for each input file\&. This option is mutually exclusive with \fB--automipmap\fP and \fB--mipmap\fP\&. When set, the following mipmap-generation related options become valid, otherwise they are ignored\&. +.IP "\fB--filter \fP" 1c +Specifies the filter to use when generating the mipmaps\&. \fIname\fP is a string\&. The default is \fIlanczos4\fP\&. The following names are recognized: \fIbox\fP, \fItent\fP, \fIbell\fP, \fIb-spline\fP, \fImitchell\fP, \fIlanczos3\fP, \fIlanczos4\fP, \fIlanczos6\fP, \fIlanczos12\fP, \fIblackman\fP, \fIkaiser\fP, \fIgaussian\fP, \fIcatmullrom\fP, \fIquadratic_interp\fP, \fIquadratic_approx\fP and \fIquadratic_mix\fP\&. +.IP "\fB--fscale \fP" 1c +The filter scale to use\&. The default is 1\&.0\&. +.IP "\fB--wmode \fP" 1c +Specify how to sample pixels near the image boundaries\&. Values are \fIwrap\fP, \fIreflect\fP and \fIclamp\fP\&. The default is \fIclamp\fP\&. +.PP +.IP "\fB--layers \fP" 1c +KTX file is for an array texture with \fInumber\fP of layers where \fInumber\fP > 1\&. Provide the file(s) for layer 0 first then those for layer 1, etc\&. It is an error to specify this together with \fB--depth\fP > 1\&. +.IP "\fB--levels \fP" 1c +KTX file is for a mipmap pyramid with \fInumber\fP of levels rather than a full pyramid\&. \fInumber\fP must be <= the maximum number of levels determined from the size of the base image\&. Provide the base level image first, if using \fB--mipmap\fP\&. This option is mutually exclusive with \fB--automipmap\fP\&. +.IP "\fB--mipmap \fP" 1c +KTX file is for a mipmap pyramid with one \fBinfile\fP being explicitly provided for each level\&. Provide the images in the order of layer then face or depth slice then level with the base-level image first then in order down to the 1x1 image or the level specified by \fB--levels\fP\&. +.PP +\fBNote\fP +.RS 4 +This ordering differs from that in the created texture as it is felt to be more user-friendly\&. +.RE +.PP +This option is mutually exclusive with \fB--automipmap\fP and \fB--genmipmap\fP\&. +.IP "\fB--nometadata \fP" 1c +Do not write KTXorientation metadata into the output file\&. Metadata is written by default\&. Use of this option is not recommended\&. +.IP "\fB--nowarn \fP" 1c +Silence warnings which are issued when certain transformations are performed on input images\&. +.IP "\fB--upper_left_maps_to_s0t0 \fP" 1c +Map the logical upper left corner of the image to s0,t0\&. Although opposite to the OpenGL convention, this is the DEFAULT BEHAVIOUR\&. netpbm and PNG files have an upper left origin so this option does not flip the input images\&. When this option is in effect, toktx writes a KTXorientation value of S=r,T=d into the output file to inform loaders of the logical orientation\&. If an OpenGL {,ES} loader ignores the orientation value, the image will appear upside down\&. +.IP "\fB--lower_left_maps_to_s0t0 \fP" 1c +Map the logical lower left corner of the image to s0,t0\&. This causes the input netpbm and PNG images to be flipped vertically to a lower-left origin\&. When this option is in effect, toktx writes a KTXorientation value of S=r,T=u into the output file to inform loaders of the logical orientation\&. If a Vulkan loader ignores the orientation value, the image will appear upside down\&. This option is ignored with \fB--cubemap\fP\&. +.IP "\fB--assign_oetf \fP" 1c +Force the created texture to have the specified transfer function\&. If this is specified, implicit or explicit color space information from the input file(s) will be ignored and no color transformation will be performed\&. USE WITH CAUTION preferably only when you know the file format information is wrong\&. +.IP "\fB--assign_primaries \fP" 1c +Force the created texture to have the specified primaries\&. If this is specified, implicit or explicit color space information from the input file(s) will be ignored and no color transformation will be performed\&. USE WITH CAUTION preferably only when you know the file format information is wrong\&. +.IP "\fB--convert_oetf \fP" 1c +Convert the input images to the specified transfer function, if the current transfer function is different\&. If both this and \fB--assign_oetf\fP are specified, conversion will be performed from the assigned transfer function to the transfer function specified by this option, if different\&. +.IP "\fB--linear \fP" 1c +Deprecated\&. Use \fB--assign_oetf\fP linear\&. +.IP "\fB--srgb \fP" 1c +Deprecated\&. Use \fB--assign_oetf\fP srgb\&. +.IP "\fB--resize x \fP" 1c +Resize images to \fIwidth\fP X \fIheight\fP\&. This should not be used with \fB--mipmap\fP as it would resize all the images to the same size\&. Resampler options can be set via \fB--filter\fP and \fB--fscale\fP\&. +.IP "\fB--scale \fP" 1c +Scale images by \fIvalue\fP as they are read\&. Resampler options can be set via \fB--filter\fP and \fB--fscale\fP\&. \&. +.IP "\fB--input_swizzle \fP" 1c +Swizzle the input components according to \fIswizzle\fP which is an alhpanumeric sequence matching the regular expression \fC^\fP[rgba01]{4}$\&. +.IP "\fB--swizzle \fP" 1c +Add swizzle metadata to the file being created\&. \fIswizzle\fP has the same syntax as the parameter for \fB--input_swizzle\fP\&. Not recommended for use with block-cmpressed textures, including Basis Universal formats, because something like \fCrabb\fP may yield drastically different error metrics if done after compression\&. +.IP "\fB--target_type \fP" 1c +Specify the number of components in the created texture\&. \fItype\fP is one of the following strings: \fCR\fP, \fCRG\fP, \fCRGB\fP or \fCRGBA\fP\&. Excess input components will be dropped\&. Output components with no mapping from the input will be set to 0 or, if the alpha component, 1\&.0\&. +.IP "\fB--t2 \fP" 1c +Output in KTX2 format\&. Default is KTX\&. +.PP +.IP "\fB--bcmp \fP" 1c +Supercompress the image data with ETC1S / BasisLZ\&. Implies \fB--t2\fP\&. RED images will become RGB with RED in each component\&. RG images will have R in the RGB part and G in the alpha part of the compressed texture\&. When set, the following BasisLZ-related options become valid otherwise they are ignored\&. +.IP "\fB--no_multithreading \fP" 1c +Disable multithreading\&. Deprecated\&. For backward compatibility only\&. Use \fB--threads\fP 1 instead\&. +.IP "\fB--threads \fP" 1c +Explicitly set the number of threads to use during compression\&. By default, ETC1S / BasisLZ compression will use the number of threads reported by \fCthread::hardware_concurrency\fP or 1 if value returned is 0\&. +.IP "\fB--clevel \fP" 1c +ETC1S / BasisLZ compression level, an encoding speed vs\&. quality tradeoff\&. Range is [0,5], default is 1\&. Higher values are slower, but give higher quality\&. +.IP "\fB--qlevel \fP" 1c +ETC1S / BasisLZ quality level\&. Range is [1,255]\&. Lower gives better compression/lower quality/faster\&. Higher gives less compression /higher quality/slower\&. \fB--qlevel\fP automatically determines values for \fB--max_endpoints\fP, \fB--max-selectors\fP, \fB--endpoint_rdo_threshold\fP and \fB--selector_rdo_threshold\fP for the target quality level\&. Setting these options overrides the values determined by \fB--qlevel\fP which defaults to 128 if neither it nor both of \fB--max_endpoints\fP and \fB--max_selectors\fP have been set\&. +.PP +\fBNote\fP +.RS 4 +Both of \fB--max_endpoints\fP and \fB--max_selectors\fP must be set for them to have any effect\&. If all three options are set, a warning will be issued that \fB--qlevel\fP will be ignored\&. +.PP +\fB--qlevel\fP will only determine values for \fB--endpoint_rdo_threshold\fP and \fB--selector_rdo_threshold\fP when its value exceeds 128, otherwise their defaults will be used\&. +.RE +.PP +.IP "\fB--max_endpoints \fP" 1c +Manually set the maximum number of color endpoint clusters\&. Range is [1,16128]\&. Default is 0, unset\&. If this is set, \fB--max_selectors\fP must also be set, otherwise the value will be ignored\&. +.IP "\fB--endpoint_rdo_threshold \fP" 1c +Set endpoint RDO quality threshold\&. The default is 1\&.25\&. Lower is higher quality but less quality per output bit (try [1\&.0,3\&.0])\&. This will override the value chosen by \fB--qlevel\fP\&. +.IP "\fB--max_selectors \fP" 1c +Manually set the maximum number of color selector clusters\&. Range is [1,16128]\&. Default is 0, unset\&. If this is set, \fB--max_selectors\fP must also be set, otherwise the value will be ignored\&. +.IP "\fB--selector_rdo_threshold \fP" 1c +Set selector RDO quality threshold\&. The default is 1\&.5\&. Lower is higher quality but less quality per output bit (try [1\&.0,3\&.0]\&. This will override the value chosen by \fB--qlevel\fP\&. +.IP "\fB--normal_map \fP" 1c +Tunes codec parameters for better quality on normal maps (no selector RDO, no endpoint RDO)\&. Only valid for linear textures\&. +.IP "\fB--separate_rg_to_color_alpha \fP" 1c +Separates the input R and G channels to RGB and A (for tangent space XY normal maps)\&. Only needed with 3 or 4 component input images\&. +.IP "\fB--no_endpoint_rdo \fP" 1c +Disable endpoint rate distortion optimizations\&. Slightly faster, less noisy output, but lower quality per output bit\&. Default is to do endpoint RDO\&. +.IP "\fB--no_selector_rdo \fP" 1c +Disable selector rate distortion optimizations\&. Slightly faster, less noisy output, but lower quality per output bit\&. Default is to do selector RDO\&. +.PP +.IP "\fB--uastc [] \fP" 1c +Create a texture in high-quality transcodable UASTC format\&. Implies \fB--t2\fP\&. The optional parameter \fIlevel\fP selects a speed vs quality tradeoff as shown in the following table: +.PP +Level Speed Quality 0 Fastest 43\&.45dB 1 Faster 46\&.49dB 2 Default 47\&.47dB 3 Slower 48\&.01dB 4 Very slow 48\&.24dB +.PP +You are strongly encouraged to also specify \fB--zcmp\fP to losslessly compress the UASTC data\&. This and any LZ-style compression can be made more effective by conditioning the UASTC texture data using the Rate Distortion Optimization (RDO) post-process stage\&. When \fB--uastc\fP is set the following options become available for controlling RDO: +.IP "\fB--uastc_rdo_l [] \fP" 1c +Enable UASTC RDO post-processing and optionally set UASTC RDO quality scalar (lambda) to \fIlambda\fP\&. Lower values yield higher quality/larger LZ compressed files, higher values yield lower quality/smaller LZ compressed files\&. A good range to try is [\&.25,10]\&. For normal maps a good range is [\&.25-\&.75]\&. The full range is [\&.001,10\&.0]\&. Default is 1\&.0\&. +.PP +\fBNote\fP +.RS 4 +Previous versions used the \fB--uastc_rdo_q\fP option which was removed because the RDO algorithm changed\&. +.RE +.PP +.IP "\fB--uastc_rdo_d \fP" 1c +Set UASTC RDO dictionary size in bytes\&. Default is 4096\&. Lower values=faster, but give less compression\&. Range is [64,65536]\&. +.IP "\fB--uastc_rdo_b \fP" 1c +Set UASTC RDO max smooth block error scale\&. Range is [1\&.0,300\&.0]\&. Default is 10\&.0, 1\&.0 is disabled\&. Larger values suppress more artifacts (and allocate more bits) on smooth blocks\&. +.IP "\fB--uastc_rdo_s \fP" 1c +Set UASTC RDO max smooth block standard deviation\&. Range is [\&.01,65536\&.0]\&. Default is 18\&.0\&. Larger values expand the range of blocks considered smooth\&. +.IP "\fB--uastc_rdo_f \fP" 1c +Do not favor simpler UASTC modes in RDO mode\&. +.IP "\fB--uastc_rdo_m \fP" 1c +Disable RDO multithreading (slightly higher compression, deterministic)\&. +.PP +.IP "\fB--no_sse \fP" 1c +Forbid use of the SSE instruction set\&. Ignored if CPU does not support SSE\&. Only the Basis Universal compressor uses SSE\&. +.IP "\fB--verbose \fP" 1c +Print encoder/compressor activity status to stdout\&. Currently only the Basis Universal compressor emits status\&. +.IP "\fB--zcmp [] \fP" 1c +Supercompress the data with Zstandard\&. Implies \fB--t2\fP\&. Can be used with data in any format except ETC1S / BasisLZ (\fB--bcmp\fP)\&. Most effective with RDO-conditioned UASTC or uncompressed formats\&. The optional \fIcompressionLevel\fP range is 1 - 22 and the default is 3\&. Lower values=faster but give less compression\&. Values above 20 should be used with caution as they require more memory\&. +.PP +.IP "\fB--help \fP" 1c +Print this usage message and exit\&. +.IP "\fB--version \fP" 1c +Print the version number of this program and exit\&. +.PP + In case of ambiguity, such as when the last option is one with an optional parameter, separate options from file names with ' -- '\&. +.PP +Any specified ETC1S / BasisLZ and supercompression options are recorded in the metadata item \fCKTXwriterScParams\fP in the output file\&. Options can also be set in the environment variable TOKTX_OPTIONS\&. TOKTX_OPTIONS is parsed first\&. If conflicting options appear in TOKTX_OPTIONS or the command line, the last one seen wins\&. However if both \fB--automipmap\fP and \fB--mipmap\fP are seen, it is always flagged as an error\&. You can, for example, set TOKTX_OPTIONS=--lower_left_maps_to_s0t0 to change the default mapping of the logical image origin to match the GL convention\&. +.SH "EXIT STATUS" +.PP +\fBtoktx\fP exits 0 on success, 1 on command line errors and 2 on functional errors\&. +.SH "HISTORY" +.PP +\fBVersion 4\&.0 (using new version numbering system)\fP +.RS 4 + +.IP "\(bu" 2 +Add KTX version 2 support including Basis Universal encoding\&. +.IP "\(bu" 2 +Add \&.png and \&.jpg readers\&. +.IP "\(bu" 2 +Transform NetPBM input files to sRGB OETF\&. +.IP "\(bu" 2 +Add mipmap generation\&. +.IP "\(bu" 2 +Remove legacy items\&. +.PP +.RE +.PP +\fBVersion 1\&.3\fP +.RS 4 + +.IP "\(bu" 2 +Switch to ktxTexture API\&. +.IP "\(bu" 2 +Add --levels option\&. +.IP "\(bu" 2 +Add --2d option\&. +.PP +.RE +.PP +\fBVersion 1\&.2\fP +.RS 4 + +.IP "\(bu" 2 +Remove --sized; always create sized format\&. +.IP "\(bu" 2 +Write metadata by default\&. +.IP "\(bu" 2 +Bug fixes\&. +.PP +.RE +.PP +\fBVersion 1\&.1\fP +.RS 4 + +.IP "\(bu" 2 +Moved --alpha and --luminance to legacy\&. +.PP +.RE +.PP +.SH "AUTHOR" +.PP +Mark Callow, Edgewise Consulting www\&.edgewise-consulting\&.com diff --git a/ExternalUtilities/KTX-Software/share/man/man1/toktx.1.meta b/ExternalUtilities/KTX-Software/share/man/man1/toktx.1.meta new file mode 100644 index 0000000..2687290 --- /dev/null +++ b/ExternalUtilities/KTX-Software/share/man/man1/toktx.1.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8ef6a4ffbad70a245a0185f117babaef +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/basis_universal.meta b/ExternalUtilities/basis_universal.meta new file mode 100644 index 0000000..ccf1682 --- /dev/null +++ b/ExternalUtilities/basis_universal.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b81290f6db184214d95982caa992afcf +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/basis_universal/bin.meta b/ExternalUtilities/basis_universal/bin.meta new file mode 100644 index 0000000..f0e3f6a --- /dev/null +++ b/ExternalUtilities/basis_universal/bin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 534276328f37a824c9daa971942bc008 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/basis_universal/bin/basisuD.exe b/ExternalUtilities/basis_universal/bin/basisuD.exe new file mode 100644 index 0000000..4a3fad0 Binary files /dev/null and b/ExternalUtilities/basis_universal/bin/basisuD.exe differ diff --git a/ExternalUtilities/basis_universal/bin/basisuD.exe.meta b/ExternalUtilities/basis_universal/bin/basisuD.exe.meta new file mode 100644 index 0000000..fb90dc8 --- /dev/null +++ b/ExternalUtilities/basis_universal/bin/basisuD.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 23870db99e71897429048ffa8a05afa8 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/basis_universal/bin/basisuD.ilk b/ExternalUtilities/basis_universal/bin/basisuD.ilk new file mode 100644 index 0000000..0b193fc Binary files /dev/null and b/ExternalUtilities/basis_universal/bin/basisuD.ilk differ diff --git a/ExternalUtilities/basis_universal/bin/basisuD.ilk.meta b/ExternalUtilities/basis_universal/bin/basisuD.ilk.meta new file mode 100644 index 0000000..32cfc1a --- /dev/null +++ b/ExternalUtilities/basis_universal/bin/basisuD.ilk.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9910c26fdf47e814a95f166561dae2dd +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/basis_universal/bin/basisuD.pdb b/ExternalUtilities/basis_universal/bin/basisuD.pdb new file mode 100644 index 0000000..64d6a4d Binary files /dev/null and b/ExternalUtilities/basis_universal/bin/basisuD.pdb differ diff --git a/ExternalUtilities/basis_universal/bin/basisuD.pdb.meta b/ExternalUtilities/basis_universal/bin/basisuD.pdb.meta new file mode 100644 index 0000000..1cd70e6 --- /dev/null +++ b/ExternalUtilities/basis_universal/bin/basisuD.pdb.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b232496059423f84da569ac872e8e21f +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/basis_universal/bin/img_0.basis b/ExternalUtilities/basis_universal/bin/img_0.basis new file mode 100644 index 0000000..7f7eac4 Binary files /dev/null and b/ExternalUtilities/basis_universal/bin/img_0.basis differ diff --git a/ExternalUtilities/basis_universal/bin/img_0.basis.meta b/ExternalUtilities/basis_universal/bin/img_0.basis.meta new file mode 100644 index 0000000..09512eb --- /dev/null +++ b/ExternalUtilities/basis_universal/bin/img_0.basis.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1e391acd11163814b94dfa81fe2c5a81 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/basis_universal/bin/img_0.ktx2 b/ExternalUtilities/basis_universal/bin/img_0.ktx2 new file mode 100644 index 0000000..d9f1502 Binary files /dev/null and b/ExternalUtilities/basis_universal/bin/img_0.ktx2 differ diff --git a/ExternalUtilities/basis_universal/bin/img_0.ktx2.meta b/ExternalUtilities/basis_universal/bin/img_0.ktx2.meta new file mode 100644 index 0000000..e813f31 --- /dev/null +++ b/ExternalUtilities/basis_universal/bin/img_0.ktx2.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: dfca006665b483a4c90213129a7edfcb +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/basis_universal/bin/readme.txt b/ExternalUtilities/basis_universal/bin/readme.txt new file mode 100644 index 0000000..caf4825 --- /dev/null +++ b/ExternalUtilities/basis_universal/bin/readme.txt @@ -0,0 +1 @@ +basisud -ktx2 -q 255 -comp_level 5 C:\Users\William\Desktop\GLTF\exports_overwrite\sdsd1\models\img_0.png \ No newline at end of file diff --git a/ExternalUtilities/basis_universal/bin/readme.txt.meta b/ExternalUtilities/basis_universal/bin/readme.txt.meta new file mode 100644 index 0000000..1033f46 --- /dev/null +++ b/ExternalUtilities/basis_universal/bin/readme.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3fd3c417c651bf84597483da166353b0 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2.meta b/ExternalUtilities/libwebp-1.2.meta new file mode 100644 index 0000000..88da1ae --- /dev/null +++ b/ExternalUtilities/libwebp-1.2.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 20f47bd579e7941468f99a001ed6b355 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/${file%.png}.webp b/ExternalUtilities/libwebp-1.2/${file%.png}.webp new file mode 100644 index 0000000..253aa29 Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/${file%.png}.webp differ diff --git a/ExternalUtilities/libwebp-1.2/${file%.png}.webp.meta b/ExternalUtilities/libwebp-1.2/${file%.png}.webp.meta new file mode 100644 index 0000000..2dc0921 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/${file%.png}.webp.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6f86b14f6b85c1f41a9f7cf909d71ed1 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/anim_diff.exe b/ExternalUtilities/libwebp-1.2/anim_diff.exe new file mode 100644 index 0000000..8362842 Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/anim_diff.exe differ diff --git a/ExternalUtilities/libwebp-1.2/anim_diff.exe.meta b/ExternalUtilities/libwebp-1.2/anim_diff.exe.meta new file mode 100644 index 0000000..d2809a0 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/anim_diff.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5266858696b34ef48a8809820e3bd507 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/anim_dump.exe b/ExternalUtilities/libwebp-1.2/anim_dump.exe new file mode 100644 index 0000000..35ce673 Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/anim_dump.exe differ diff --git a/ExternalUtilities/libwebp-1.2/anim_dump.exe.meta b/ExternalUtilities/libwebp-1.2/anim_dump.exe.meta new file mode 100644 index 0000000..3ab30f5 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/anim_dump.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 99d3bf77ecd54b844b9e66e3f0bf30fb +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/cwebp.exe b/ExternalUtilities/libwebp-1.2/cwebp.exe new file mode 100644 index 0000000..477b337 Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/cwebp.exe differ diff --git a/ExternalUtilities/libwebp-1.2/cwebp.exe.meta b/ExternalUtilities/libwebp-1.2/cwebp.exe.meta new file mode 100644 index 0000000..2c212c5 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/cwebp.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8463fd67d19320745979a948517f48b9 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/dwebp.exe b/ExternalUtilities/libwebp-1.2/dwebp.exe new file mode 100644 index 0000000..cab5e57 Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/dwebp.exe differ diff --git a/ExternalUtilities/libwebp-1.2/dwebp.exe.meta b/ExternalUtilities/libwebp-1.2/dwebp.exe.meta new file mode 100644 index 0000000..a929f06 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/dwebp.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d7ab74b5ee60b4c47ac50353ef8e4d3e +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/freeglut.dll b/ExternalUtilities/libwebp-1.2/freeglut.dll new file mode 100644 index 0000000..8624d4e Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/freeglut.dll differ diff --git a/ExternalUtilities/libwebp-1.2/freeglut.dll.meta b/ExternalUtilities/libwebp-1.2/freeglut.dll.meta new file mode 100644 index 0000000..1da1c87 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/freeglut.dll.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 81fa21514c4e178428adca1b7389ae1f +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/get_disto.exe b/ExternalUtilities/libwebp-1.2/get_disto.exe new file mode 100644 index 0000000..4b69b45 Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/get_disto.exe differ diff --git a/ExternalUtilities/libwebp-1.2/get_disto.exe.meta b/ExternalUtilities/libwebp-1.2/get_disto.exe.meta new file mode 100644 index 0000000..6a23a21 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/get_disto.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 205d87e8a586b044c806c0b7beeae670 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/gif2webp.exe b/ExternalUtilities/libwebp-1.2/gif2webp.exe new file mode 100644 index 0000000..94aebf8 Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/gif2webp.exe differ diff --git a/ExternalUtilities/libwebp-1.2/gif2webp.exe.meta b/ExternalUtilities/libwebp-1.2/gif2webp.exe.meta new file mode 100644 index 0000000..758d1d9 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/gif2webp.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 393785cce21ca4347b9f90d3f4fa553d +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/img2webp.exe b/ExternalUtilities/libwebp-1.2/img2webp.exe new file mode 100644 index 0000000..1e18ecd Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/img2webp.exe differ diff --git a/ExternalUtilities/libwebp-1.2/img2webp.exe.meta b/ExternalUtilities/libwebp-1.2/img2webp.exe.meta new file mode 100644 index 0000000..f627349 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/img2webp.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 38d3924d7724fc34894c6c1347b436d9 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/vwebp.exe b/ExternalUtilities/libwebp-1.2/vwebp.exe new file mode 100644 index 0000000..e99564b Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/vwebp.exe differ diff --git a/ExternalUtilities/libwebp-1.2/vwebp.exe.meta b/ExternalUtilities/libwebp-1.2/vwebp.exe.meta new file mode 100644 index 0000000..2ca6858 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/vwebp.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7e706916912f4a04783cba0eeca6873d +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/webp_quality.exe b/ExternalUtilities/libwebp-1.2/webp_quality.exe new file mode 100644 index 0000000..40b4580 Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/webp_quality.exe differ diff --git a/ExternalUtilities/libwebp-1.2/webp_quality.exe.meta b/ExternalUtilities/libwebp-1.2/webp_quality.exe.meta new file mode 100644 index 0000000..29f85c9 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/webp_quality.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 29e8aea2187abc742a9f00de6b0475c1 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/webpinfo.exe b/ExternalUtilities/libwebp-1.2/webpinfo.exe new file mode 100644 index 0000000..175c57e Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/webpinfo.exe differ diff --git a/ExternalUtilities/libwebp-1.2/webpinfo.exe.meta b/ExternalUtilities/libwebp-1.2/webpinfo.exe.meta new file mode 100644 index 0000000..1887832 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/webpinfo.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4dfc56b7c12d41448a3d826611128666 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ExternalUtilities/libwebp-1.2/webpmux.exe b/ExternalUtilities/libwebp-1.2/webpmux.exe new file mode 100644 index 0000000..7caef93 Binary files /dev/null and b/ExternalUtilities/libwebp-1.2/webpmux.exe differ diff --git a/ExternalUtilities/libwebp-1.2/webpmux.exe.meta b/ExternalUtilities/libwebp-1.2/webpmux.exe.meta new file mode 100644 index 0000000..31ba1e0 --- /dev/null +++ b/ExternalUtilities/libwebp-1.2/webpmux.exe.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 25e089c56aeb45f4bbe6a1baa4b99d08 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/LICENSE.meta b/LICENSE.meta new file mode 100644 index 0000000..673f979 --- /dev/null +++ b/LICENSE.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e54727b66d326b74c918caccad975fba +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models.meta b/Models.meta new file mode 100644 index 0000000..b800bdb --- /dev/null +++ b/Models.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0861279a89d620e438bc56261e91bee8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Utilities.meta b/Models/Utilities.meta new file mode 100644 index 0000000..3d18130 --- /dev/null +++ b/Models/Utilities.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 62a1fcaf30d0c4742adfae1d8cf07006 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Utilities/Spherical_01.fbx b/Models/Utilities/Spherical_01.fbx new file mode 100644 index 0000000..26aa695 Binary files /dev/null and b/Models/Utilities/Spherical_01.fbx differ diff --git a/Models/Utilities/Spherical_01.fbx.meta b/Models/Utilities/Spherical_01.fbx.meta new file mode 100644 index 0000000..03ad12d --- /dev/null +++ b/Models/Utilities/Spherical_01.fbx.meta @@ -0,0 +1,101 @@ +fileFormatVersion: 2 +guid: db446dca6aa430e47ac1d660389c9c20 +ModelImporter: + serializedVersion: 20101 + internalIDToNameTable: [] + externalObjects: {} + materials: + materialImportMode: 1 + materialName: 0 + materialSearch: 1 + materialLocation: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + importAnimatedCustomProperties: 0 + importConstraints: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + extraUserProperties: [] + clipAnimations: [] + isReadable: 0 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + useSRGBMaterialColor: 1 + sortHierarchyByName: 1 + importVisibility: 1 + importBlendShapes: 1 + importCameras: 1 + importLights: 1 + fileIdsGeneration: 1 + swapUVChannels: 0 + generateSecondaryUV: 1 + useFileUnits: 1 + keepQuads: 0 + weldVertices: 1 + bakeAxisConversion: 0 + preserveHierarchy: 0 + skinWeightsMode: 0 + maxBonesPerVertex: 4 + minBoneWeight: 0.001 + meshOptimizationFlags: -1 + indexFormat: 0 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVMarginMethod: 0 + secondaryUVMinLightmapResolution: 40 + secondaryUVMinObjectScale: 1 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + normalCalculationMode: 4 + legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 + blendShapeNormalImportMode: 1 + normalSmoothingSource: 0 + referencedClips: [] + importAnimation: 1 + humanDescription: + serializedVersion: 3 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + globalScale: 1 + rootMotionBoneName: + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + autoGenerateAvatarMappingIfUnspecified: 1 + animationType: 0 + humanoidOversampling: 1 + avatarSetup: 0 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Utilities/cubemap_threejs.fbx b/Models/Utilities/cubemap_threejs.fbx new file mode 100644 index 0000000..20f7d50 Binary files /dev/null and b/Models/Utilities/cubemap_threejs.fbx differ diff --git a/Models/Utilities/cubemap_threejs.fbx.meta b/Models/Utilities/cubemap_threejs.fbx.meta new file mode 100644 index 0000000..ce02be5 --- /dev/null +++ b/Models/Utilities/cubemap_threejs.fbx.meta @@ -0,0 +1,107 @@ +fileFormatVersion: 2 +guid: 4372e29d03b7c8d44a108bb5f516a95c +ModelImporter: + serializedVersion: 22102 + internalIDToNameTable: [] + externalObjects: {} + materials: + materialImportMode: 2 + materialName: 0 + materialSearch: 1 + materialLocation: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + removeConstantScaleCurves: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + importAnimatedCustomProperties: 0 + importConstraints: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + extraUserProperties: [] + clipAnimations: [] + isReadable: 0 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + useSRGBMaterialColor: 1 + sortHierarchyByName: 1 + importVisibility: 1 + importBlendShapes: 1 + importCameras: 1 + importLights: 1 + nodeNameCollisionStrategy: 1 + fileIdsGeneration: 2 + swapUVChannels: 0 + generateSecondaryUV: 1 + useFileUnits: 1 + keepQuads: 0 + weldVertices: 1 + bakeAxisConversion: 0 + preserveHierarchy: 0 + skinWeightsMode: 0 + maxBonesPerVertex: 4 + minBoneWeight: 0.001 + optimizeBones: 1 + meshOptimizationFlags: -1 + indexFormat: 0 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVMarginMethod: 1 + secondaryUVMinLightmapResolution: 40 + secondaryUVMinObjectScale: 1 + secondaryUVPackMargin: 4 + useFileScale: 1 + strictVertexDataChecks: 0 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + normalCalculationMode: 4 + legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 + blendShapeNormalImportMode: 1 + normalSmoothingSource: 0 + referencedClips: [] + importAnimation: 1 + humanDescription: + serializedVersion: 3 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + globalScale: 1 + rootMotionBoneName: + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + autoGenerateAvatarMappingIfUnspecified: 1 + animationType: 2 + humanoidOversampling: 1 + avatarSetup: 0 + addHumanoidExtraRootOnlyWhenUsingAvatar: 1 + importBlendShapeDeformPercent: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Utilities/cubemap_threejs.prefab b/Models/Utilities/cubemap_threejs.prefab new file mode 100644 index 0000000..754475f --- /dev/null +++ b/Models/Utilities/cubemap_threejs.prefab @@ -0,0 +1,569 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2541638880414932322 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 748852931452557088} + - component: {fileID: 207000343965678713} + - component: {fileID: 2500483753384411272} + m_Layer: 0 + m_Name: X_Neg_mesh + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &748852931452557088 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541638880414932322} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7694987565809704180} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &207000343965678713 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541638880414932322} + m_Mesh: {fileID: -1591285611372227671, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} +--- !u!23 &2500483753384411272 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2541638880414932322} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: -5656428143419000915, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!1 &3094214343184899610 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2430548663391749280} + m_Layer: 0 + m_Name: cubemap_threejs + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2430548663391749280 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3094214343184899610} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 7694987565809704180} + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &3154298848661469774 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3188246792823118890} + - component: {fileID: 5831354833180054633} + - component: {fileID: 7179283772417767364} + m_Layer: 0 + m_Name: Y_Neg_mesh + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3188246792823118890 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3154298848661469774} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7694987565809704180} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &5831354833180054633 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3154298848661469774} + m_Mesh: {fileID: -850066600256891862, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} +--- !u!23 &7179283772417767364 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3154298848661469774} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 8613551293824678482, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!1 &5116565271294113150 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3731587724034932502} + - component: {fileID: 1123882102888209122} + - component: {fileID: 8888543065855472601} + m_Layer: 0 + m_Name: Y_Pos_mesh + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3731587724034932502 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5116565271294113150} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7694987565809704180} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &1123882102888209122 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5116565271294113150} + m_Mesh: {fileID: 4042782667844284450, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} +--- !u!23 &8888543065855472601 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5116565271294113150} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 1421360659175608121, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!1 &6532143071780473241 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7694987565809704180} + m_Layer: 0 + m_Name: Cube_01 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7694987565809704180 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6532143071780473241} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 381539981147399679} + - {fileID: 748852931452557088} + - {fileID: 3188246792823118890} + - {fileID: 3731587724034932502} + - {fileID: 7804424015550414529} + - {fileID: 821728873672272950} + m_Father: {fileID: 2430548663391749280} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &7710656011642796216 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 381539981147399679} + - component: {fileID: 6443112452548789003} + - component: {fileID: 6926493537830370554} + m_Layer: 0 + m_Name: X_Pos_mesh + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &381539981147399679 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7710656011642796216} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7694987565809704180} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &6443112452548789003 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7710656011642796216} + m_Mesh: {fileID: -8001771963011113538, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} +--- !u!23 &6926493537830370554 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7710656011642796216} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 6392521391637457616, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!1 &8108523019404140406 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 821728873672272950} + - component: {fileID: 3346406803220753930} + - component: {fileID: 9032453726340768633} + m_Layer: 0 + m_Name: Z_Pos_mesh + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &821728873672272950 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8108523019404140406} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7694987565809704180} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &3346406803220753930 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8108523019404140406} + m_Mesh: {fileID: -5214297581383255720, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} +--- !u!23 &9032453726340768633 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8108523019404140406} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 3005711225127613967, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!1 &8624960473312814143 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7804424015550414529} + - component: {fileID: 6136267804210605899} + - component: {fileID: 4255185748431844026} + m_Layer: 0 + m_Name: Z_Neg_mesh + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7804424015550414529 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8624960473312814143} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7694987565809704180} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &6136267804210605899 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8624960473312814143} + m_Mesh: {fileID: 8850937559727750575, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} +--- !u!23 &4255185748431844026 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8624960473312814143} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 164909124964335570, guid: 4372e29d03b7c8d44a108bb5f516a95c, type: 3} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} diff --git a/Models/Utilities/cubemap_threejs.prefab.meta b/Models/Utilities/cubemap_threejs.prefab.meta new file mode 100644 index 0000000..6eea1f3 --- /dev/null +++ b/Models/Utilities/cubemap_threejs.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0a6ed77f982ebc44a8d4c5cf134a2879 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils.meta b/PrefabUtils.meta new file mode 100644 index 0000000..b860da4 --- /dev/null +++ b/PrefabUtils.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 292d8e3badb3fc946bf72f6e4209b4c9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor.meta b/PrefabUtils/MaterialEditor.meta new file mode 100644 index 0000000..da2a7b1 --- /dev/null +++ b/PrefabUtils/MaterialEditor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4339a86e20163014cbe2e72be2dd9739 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/Standard.meta b/PrefabUtils/MaterialEditor/Standard.meta new file mode 100644 index 0000000..74acf92 --- /dev/null +++ b/PrefabUtils/MaterialEditor/Standard.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ee4d9ad111c55024184f0037e59a8ef2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/Standard/BasicEditableMaterial.mat b/PrefabUtils/MaterialEditor/Standard/BasicEditableMaterial.mat new file mode 100644 index 0000000..a00f0cf --- /dev/null +++ b/PrefabUtils/MaterialEditor/Standard/BasicEditableMaterial.mat @@ -0,0 +1,105 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-1674471672947597241 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 639247ca83abc874e893eb93af2b5e44, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 0 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: BasicEditableMaterial + m_Shader: {fileID: -6465566751694194690, guid: ada9a97d8ba7b07489f574500fe50871, + type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: + - _BaseMap + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: f869e9f27de1c1e42b9c9736c9011ace, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BUILTIN_QueueControl: 0 + - _BUILTIN_QueueOffset: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _Saturation: 1 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/PrefabUtils/MaterialEditor/Standard/BasicEditableMaterial.mat.meta b/PrefabUtils/MaterialEditor/Standard/BasicEditableMaterial.mat.meta new file mode 100644 index 0000000..59b6f31 --- /dev/null +++ b/PrefabUtils/MaterialEditor/Standard/BasicEditableMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a230b5e9d43cd6c448dc7282bc34886c +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/Standard/BasicSimpleMaterial.mat b/PrefabUtils/MaterialEditor/Standard/BasicSimpleMaterial.mat new file mode 100644 index 0000000..7d6c089 --- /dev/null +++ b/PrefabUtils/MaterialEditor/Standard/BasicSimpleMaterial.mat @@ -0,0 +1,83 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: BasicSimpleMaterial + m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/PrefabUtils/MaterialEditor/Standard/BasicSimpleMaterial.mat.meta b/PrefabUtils/MaterialEditor/Standard/BasicSimpleMaterial.mat.meta new file mode 100644 index 0000000..7df4df3 --- /dev/null +++ b/PrefabUtils/MaterialEditor/Standard/BasicSimpleMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 152eaf944d2ba714dab574b3d765faba +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/Standard/HDRSimpleMaterial.mat b/PrefabUtils/MaterialEditor/Standard/HDRSimpleMaterial.mat new file mode 100644 index 0000000..1bb2e9e --- /dev/null +++ b/PrefabUtils/MaterialEditor/Standard/HDRSimpleMaterial.mat @@ -0,0 +1,107 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-6300464618718246476 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 639247ca83abc874e893eb93af2b5e44, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 0 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: HDRSimpleMaterial + m_Shader: {fileID: -6465566751694194690, guid: a93259c5ca498714192219246306c475, + type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 2800000, guid: cc1477d5bd671ed40805fad753ac3b75, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BUILTIN_QueueControl: 0 + - _BUILTIN_QueueOffset: 0 + - _BumpScale: 1 + - _Contrast: 2 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GetFactor256: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SaturateCompensation: 1 + - _ScaleFactor: 3.015625 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/PrefabUtils/MaterialEditor/Standard/HDRSimpleMaterial.mat.meta b/PrefabUtils/MaterialEditor/Standard/HDRSimpleMaterial.mat.meta new file mode 100644 index 0000000..ef82606 --- /dev/null +++ b/PrefabUtils/MaterialEditor/Standard/HDRSimpleMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 945e577d7bccd9949bf7c1bbdec5556f +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/Standard/NormalMapSimpleMaterial.mat b/PrefabUtils/MaterialEditor/Standard/NormalMapSimpleMaterial.mat new file mode 100644 index 0000000..7706a8e --- /dev/null +++ b/PrefabUtils/MaterialEditor/Standard/NormalMapSimpleMaterial.mat @@ -0,0 +1,103 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-8989242666841813729 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 639247ca83abc874e893eb93af2b5e44, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 0 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: NormalMapSimpleMaterial + m_Shader: {fileID: -6465566751694194690, guid: 2ce65382e5fc3874f8e71c0f7fb4f4ba, + type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalTextureMap: + m_Texture: {fileID: 2800000, guid: 55525501026530c428f2ae0d260dc051, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BUILTIN_QueueControl: 0 + - _BUILTIN_QueueOffset: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/PrefabUtils/MaterialEditor/Standard/NormalMapSimpleMaterial.mat.meta b/PrefabUtils/MaterialEditor/Standard/NormalMapSimpleMaterial.mat.meta new file mode 100644 index 0000000..78da0ae --- /dev/null +++ b/PrefabUtils/MaterialEditor/Standard/NormalMapSimpleMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5c44b0f4cd0751c469d1522978dff8b1 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/URP.meta b/PrefabUtils/MaterialEditor/URP.meta new file mode 100644 index 0000000..1746b0e --- /dev/null +++ b/PrefabUtils/MaterialEditor/URP.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8fffe95b3d5420f4aad8bb0c89beac95 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/URP/BasicEditableMaterial.mat b/PrefabUtils/MaterialEditor/URP/BasicEditableMaterial.mat new file mode 100644 index 0000000..2c18267 --- /dev/null +++ b/PrefabUtils/MaterialEditor/URP/BasicEditableMaterial.mat @@ -0,0 +1,112 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: BasicEditableMaterial + m_Shader: {fileID: -6465566751694194690, guid: d253068613d1be34d9b344767af78b81, + type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: + - _BaseMap + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 39883b0ddae185c4c8cf09dd8d97acd0, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _Blend: 0 + - _BumpScale: 1 + - _Cull: 2 + - _Cutoff: 0.5 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _QueueControl: 0 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _SampleGI: 0 + - _Saturation: 0.8 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] +--- !u!114 &130896006741679013 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 6 diff --git a/PrefabUtils/MaterialEditor/URP/BasicEditableMaterial.mat.meta b/PrefabUtils/MaterialEditor/URP/BasicEditableMaterial.mat.meta new file mode 100644 index 0000000..c44641e --- /dev/null +++ b/PrefabUtils/MaterialEditor/URP/BasicEditableMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0adc8c05bdd33854b8a1b243dcaad8c8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/URP/BasicSimpleMaterial.mat b/PrefabUtils/MaterialEditor/URP/BasicSimpleMaterial.mat new file mode 100644 index 0000000..9b73c79 --- /dev/null +++ b/PrefabUtils/MaterialEditor/URP/BasicSimpleMaterial.mat @@ -0,0 +1,100 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: BasicSimpleMaterial + m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: 2000 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 2800000, guid: 39883b0ddae185c4c8cf09dd8d97acd0, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 39883b0ddae185c4c8cf09dd8d97acd0, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _Blend: 0 + - _BlendOp: 0 + - _BumpScale: 1 + - _Cull: 2 + - _Cutoff: 0.5 + - _DstBlend: 0 + - _DstBlendAlpha: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _SampleGI: 0 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _SrcBlendAlpha: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] +--- !u!114 &130896006741679013 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 6 diff --git a/PrefabUtils/MaterialEditor/URP/BasicSimpleMaterial.mat.meta b/PrefabUtils/MaterialEditor/URP/BasicSimpleMaterial.mat.meta new file mode 100644 index 0000000..bbe2b45 --- /dev/null +++ b/PrefabUtils/MaterialEditor/URP/BasicSimpleMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0118935eb889c88439509f3f331decb0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/URP/HDRSimpleMaterial.mat b/PrefabUtils/MaterialEditor/URP/HDRSimpleMaterial.mat new file mode 100644 index 0000000..a063ad4 --- /dev/null +++ b/PrefabUtils/MaterialEditor/URP/HDRSimpleMaterial.mat @@ -0,0 +1,125 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-461343289072478602 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 6 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: HDRSimpleMaterial + m_Shader: {fileID: -6465566751694194690, guid: 828bed09d380cca488fb6d5d7dbf246c, + type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - LightmapTexture: + m_Texture: {fileID: 2800000, guid: 5e7d8c1397061664eb97353006608c4b, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 2800000, guid: 70c446e82647c8441a24d98f4715aff9, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 5e7d8c1397061664eb97353006608c4b, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - GetShadow: 1 + - LightDim: 1 + - ShadowMultiplier: 1 + - Vector1_46B4D00E: 1.3 + - _AlphaClip: 0 + - _Blend: 0 + - _BumpScale: 1 + - _Contrast: 1 + - _Cull: 2 + - _Cutoff: 0.5 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _GetFactor256: 0 + - _GetShadow: 0 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _LightDim: 1 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _QueueControl: 0 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _SampleGI: 0 + - _SaturateCompensation: 1 + - _ScaleFactor: 2.328125 + - _ShadowMultiplier: 1 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] diff --git a/PrefabUtils/MaterialEditor/URP/HDRSimpleMaterial.mat.meta b/PrefabUtils/MaterialEditor/URP/HDRSimpleMaterial.mat.meta new file mode 100644 index 0000000..c4da839 --- /dev/null +++ b/PrefabUtils/MaterialEditor/URP/HDRSimpleMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 48629282eaad4ae41a6692e7f542444f +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/MaterialEditor/URP/NormalMapSimpleMaterial.mat b/PrefabUtils/MaterialEditor/URP/NormalMapSimpleMaterial.mat new file mode 100644 index 0000000..a962236 --- /dev/null +++ b/PrefabUtils/MaterialEditor/URP/NormalMapSimpleMaterial.mat @@ -0,0 +1,117 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-415988806033386504 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 6 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: NormalMapSimpleMaterial + m_Shader: {fileID: -6465566751694194690, guid: e3caaa6034ff38243b863b67c3d264b4, + type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - Texture2D_C763EE30: + m_Texture: {fileID: 2800000, guid: b46a62e0ade980945a5718dbf40dab0f, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 2800000, guid: e67e52e62a656ec488cf0f4b1ff0e444, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalTextureMap: + m_Texture: {fileID: 2800000, guid: 8114e3c57297ed640abcf2a837fe6cc5, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _Blend: 0 + - _BumpScale: 1 + - _Cull: 2 + - _Cutoff: 0.5 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _QueueControl: 0 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] diff --git a/PrefabUtils/MaterialEditor/URP/NormalMapSimpleMaterial.mat.meta b/PrefabUtils/MaterialEditor/URP/NormalMapSimpleMaterial.mat.meta new file mode 100644 index 0000000..f5867a7 --- /dev/null +++ b/PrefabUtils/MaterialEditor/URP/NormalMapSimpleMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1219d324db6b423479df9e9a95c2296a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/RenderTextureHolder.prefab b/PrefabUtils/RenderTextureHolder.prefab new file mode 100644 index 0000000..433b69c --- /dev/null +++ b/PrefabUtils/RenderTextureHolder.prefab @@ -0,0 +1,185 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2973310228405718776 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1567167159393205461} + - component: {fileID: 6644389155909244555} + - component: {fileID: 3723282538961698698} + m_Layer: 0 + m_Name: RenderTextureHolder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1567167159393205461 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2973310228405718776} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2.577509, y: 0.11564636, z: -4.44} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 2827412796977414711} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &6644389155909244555 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2973310228405718776} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 26.991467 + orthographic: 1 + orthographic size: 3.0996 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 32 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_AllowMSAA: 0 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &3723282538961698698 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2973310228405718776} + m_Enabled: 1 +--- !u!1 &9050382379758613028 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2827412796977414711} + - component: {fileID: 5999564055282816422} + - component: {fileID: 7119643786327425561} + - component: {fileID: 2091057473953899282} + m_Layer: 5 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2827412796977414711 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9050382379758613028} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 4.568677} + m_LocalScale: {x: 6.1992, y: 6.1992, z: 6.1992} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1567167159393205461} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &5999564055282816422 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9050382379758613028} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &7119643786327425561 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9050382379758613028} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 48629282eaad4ae41a6692e7f542444f, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!64 &2091057473953899282 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9050382379758613028} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 4 + m_Convex: 0 + m_CookingOptions: 30 + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} diff --git a/PrefabUtils/RenderTextureHolder.prefab.meta b/PrefabUtils/RenderTextureHolder.prefab.meta new file mode 100644 index 0000000..f8527b3 --- /dev/null +++ b/PrefabUtils/RenderTextureHolder.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b04b4b54fb2cd814784637c19157dca8 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/SkyboxSimpleNeutral.mat b/PrefabUtils/SkyboxSimpleNeutral.mat new file mode 100644 index 0000000..3db136e --- /dev/null +++ b/PrefabUtils/SkyboxSimpleNeutral.mat @@ -0,0 +1,97 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: SkyboxSimpleNeutral + m_Shader: {fileID: 108, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _MAPPING_LATITUDE_LONGITUDE_LAYOUT + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _AlphaClip: 0 + - _Blend: 0 + - _BumpScale: 1 + - _Cull: 2 + - _Cutoff: 0.5 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _Exposure: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _ImageType: 0 + - _Layout: 0 + - _Mapping: 1 + - _Metallic: 0 + - _MirrorOnBack: 0 + - _OcclusionStrength: 1 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Rotation: 0 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + - _Tint: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 0.5} + m_BuildTextureStacks: [] +--- !u!114 &1749647606047853389 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 2 diff --git a/PrefabUtils/SkyboxSimpleNeutral.mat.meta b/PrefabUtils/SkyboxSimpleNeutral.mat.meta new file mode 100644 index 0000000..dd32eef --- /dev/null +++ b/PrefabUtils/SkyboxSimpleNeutral.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5945f16a079bd2d4b994ec5804c6673a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/SkyboxSimplePanorama.mat b/PrefabUtils/SkyboxSimplePanorama.mat new file mode 100644 index 0000000..2326bbb --- /dev/null +++ b/PrefabUtils/SkyboxSimplePanorama.mat @@ -0,0 +1,103 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: SkyboxSimplePanorama + m_Shader: {fileID: 108, guid: 0000000000000000f000000000000000, type: 0} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: + - _MAPPING_LATITUDE_LONGITUDE_LAYOUT + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: a591110956f075d49947b01ffb9e8ffd, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _Blend: 0 + - _BumpScale: 1 + - _Cull: 2 + - _Cutoff: 0.5 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _Exposure: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _ImageType: 0 + - _Layout: 0 + - _Mapping: 1 + - _Metallic: 0 + - _MirrorOnBack: 0 + - _OcclusionStrength: 1 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Rotation: 0 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + - _Tint: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 0.5} + m_BuildTextureStacks: [] +--- !u!114 &1749647606047853389 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 2 diff --git a/PrefabUtils/SkyboxSimplePanorama.mat.meta b/PrefabUtils/SkyboxSimplePanorama.mat.meta new file mode 100644 index 0000000..c2e999b --- /dev/null +++ b/PrefabUtils/SkyboxSimplePanorama.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3785d1fb508d6144796d8ed072446a9a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/Skybox_Converter.prefab b/PrefabUtils/Skybox_Converter.prefab new file mode 100644 index 0000000..47a2e50 --- /dev/null +++ b/PrefabUtils/Skybox_Converter.prefab @@ -0,0 +1,914 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &7684825398962264857 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825398962264854} + m_Layer: 0 + m_Name: Z- + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825398962264854 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825398962264857} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7684825399230358118} + m_Father: {fileID: 7684825400215714586} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &7684825399058864934 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825399058864935} + m_Layer: 0 + m_Name: X+ + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825399058864935 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399058864934} + m_LocalRotation: {x: 0.5, y: 0.5, z: 0.5, w: 0.5} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7684825399270094978} + m_Father: {fileID: 7684825400215714586} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 180, y: -90, z: -90} +--- !u!1 &7684825399230358121 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825399230358118} + - component: {fileID: 7684825399230358116} + - component: {fileID: 7684825399230358119} + - component: {fileID: 2441649272125265515} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825399230358118 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399230358121} + m_LocalRotation: {x: 0, y: 0, z: 1, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7684825398962264854} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180} +--- !u!20 &7684825399230358116 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399230358121} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &7684825399230358119 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399230358121} + m_Enabled: 1 +--- !u!114 &2441649272125265515 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399230358121} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 +--- !u!1 &7684825399270094981 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825399270094978} + - component: {fileID: 7684825399270094976} + - component: {fileID: 7684825399270094979} + - component: {fileID: 5879441316913273611} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825399270094978 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399270094981} + m_LocalRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7684825399058864935} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90} +--- !u!20 &7684825399270094976 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399270094981} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &7684825399270094979 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399270094981} + m_Enabled: 1 +--- !u!114 &5879441316913273611 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399270094981} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 +--- !u!1 &7684825399317753909 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825399317753906} + m_Layer: 0 + m_Name: Y- + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825399317753906 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399317753909} + m_LocalRotation: {x: 0, y: -0.7071068, z: 0.7071068, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7684825400817577159} + m_Father: {fileID: 7684825400215714586} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 180} +--- !u!1 &7684825399559553227 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825399559553224} + - component: {fileID: 7684825399559553222} + - component: {fileID: 7684825399559553225} + - component: {fileID: 8302059943132271860} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825399559553224 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399559553227} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7684825399931706417} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &7684825399559553222 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399559553227} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &7684825399559553225 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399559553227} + m_Enabled: 1 +--- !u!114 &8302059943132271860 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399559553227} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 +--- !u!1 &7684825399576058566 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825399576058567} + - component: {fileID: 7684825399576058565} + - component: {fileID: 7684825399576058564} + - component: {fileID: 2246504225209161286} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825399576058567 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399576058566} + m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7684825400797707308} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90} +--- !u!20 &7684825399576058565 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399576058566} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &7684825399576058564 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399576058566} + m_Enabled: 1 +--- !u!114 &2246504225209161286 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399576058566} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 +--- !u!1 &7684825399931706416 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825399931706417} + m_Layer: 0 + m_Name: Z+ + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825399931706417 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825399931706416} + m_LocalRotation: {x: 1, y: -0, z: -0, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7684825399559553224} + m_Father: {fileID: 7684825400215714586} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 180, y: 0, z: 0} +--- !u!1 &7684825400215714589 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825400215714586} + m_Layer: 0 + m_Name: Skybox_Converter + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825400215714586 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400215714589} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7684825399058864935} + - {fileID: 7684825400797707308} + - {fileID: 7684825400893524156} + - {fileID: 7684825399317753906} + - {fileID: 7684825399931706417} + - {fileID: 7684825398962264854} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &7684825400515520625 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825400515520590} + - component: {fileID: 7684825400515520588} + - component: {fileID: 7684825400515520591} + - component: {fileID: 2286887617940377465} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825400515520590 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400515520625} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7684825400893524156} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &7684825400515520588 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400515520625} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &7684825400515520591 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400515520625} + m_Enabled: 1 +--- !u!114 &2286887617940377465 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400515520625} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 +--- !u!1 &7684825400797707311 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825400797707308} + m_Layer: 0 + m_Name: X- + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825400797707308 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400797707311} + m_LocalRotation: {x: 0.5, y: -0.5, z: -0.5, w: 0.5} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7684825399576058567} + m_Father: {fileID: 7684825400215714586} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: -90, z: -90} +--- !u!1 &7684825400817577158 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825400817577159} + - component: {fileID: 7684825400817577157} + - component: {fileID: 7684825400817577156} + - component: {fileID: 9086042480645015292} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825400817577159 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400817577158} + m_LocalRotation: {x: 0, y: 0, z: 1, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7684825399317753906} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180} +--- !u!20 &7684825400817577157 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400817577158} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 0 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &7684825400817577156 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400817577158} + m_Enabled: 1 +--- !u!114 &9086042480645015292 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400817577158} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_RenderPostProcessing: 0 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 +--- !u!1 &7684825400893524159 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7684825400893524156} + m_Layer: 0 + m_Name: Y+ + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7684825400893524156 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7684825400893524159} + m_LocalRotation: {x: -0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7684825400515520590} + m_Father: {fileID: 7684825400215714586} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} diff --git a/PrefabUtils/Skybox_Converter.prefab.meta b/PrefabUtils/Skybox_Converter.prefab.meta new file mode 100644 index 0000000..f9ae795 --- /dev/null +++ b/PrefabUtils/Skybox_Converter.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 86c6a984beee05545ba1ecf2ed759305 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/SphericalPanoramaSimpleLit.mat b/PrefabUtils/SphericalPanoramaSimpleLit.mat new file mode 100644 index 0000000..4a49f00 --- /dev/null +++ b/PrefabUtils/SphericalPanoramaSimpleLit.mat @@ -0,0 +1,97 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: SphericalPanoramaSimpleLit + m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: + - _EMISSION + m_LightmapFlags: 2 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 2800000, guid: 0ed5fac5ab65d3e41a01712e9b7d37ff, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 2800000, guid: 0aacc1e368063a146bed8de6c866adcf, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 0ed5fac5ab65d3e41a01712e9b7d37ff, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _Blend: 0 + - _BumpScale: 1 + - _Cull: 2 + - _Cutoff: 0.5 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _SampleGI: 0 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1} + - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] +--- !u!114 &718566725986620973 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 2 diff --git a/PrefabUtils/SphericalPanoramaSimpleLit.mat.meta b/PrefabUtils/SphericalPanoramaSimpleLit.mat.meta new file mode 100644 index 0000000..0a18483 --- /dev/null +++ b/PrefabUtils/SphericalPanoramaSimpleLit.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 99c4481312a63c9438226c0bc65509e2 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/PrefabUtils/SphericalToCubemap_Converter.prefab b/PrefabUtils/SphericalToCubemap_Converter.prefab new file mode 100644 index 0000000..0f5e1ce --- /dev/null +++ b/PrefabUtils/SphericalToCubemap_Converter.prefab @@ -0,0 +1,818 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5833122207299085836 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122207299085835} + - component: {fileID: 5833122207299085833} + - component: {fileID: 5833122207299085834} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122207299085835 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207299085836} + m_LocalRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5833122207578457518} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90} +--- !u!20 &5833122207299085833 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207299085836} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 32 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &5833122207299085834 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207299085836} + m_Enabled: 1 +--- !u!1 &5833122207321976508 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122207321976507} + m_Layer: 0 + m_Name: Y- + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122207321976507 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207321976508} + m_LocalRotation: {x: 0, y: -0.7071068, z: 0.7071068, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5833122208972862030} + m_Father: {fileID: 5833122208500950419} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 180} +--- !u!1 &5833122207406226656 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122207406226671} + - component: {fileID: 5833122207406226669} + - component: {fileID: 5833122207406226670} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122207406226671 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207406226656} + m_LocalRotation: {x: 0, y: 0, z: 1, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5833122207675319711} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180} +--- !u!20 &5833122207406226669 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207406226656} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 32 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &5833122207406226670 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207406226656} + m_Enabled: 1 +--- !u!1 &5833122207578457519 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122207578457518} + m_Layer: 0 + m_Name: X+ + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122207578457518 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207578457519} + m_LocalRotation: {x: 0.5, y: 0.5, z: 0.5, w: 0.5} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5833122207299085835} + m_Father: {fileID: 5833122208500950419} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 180, y: -90, z: -90} +--- !u!1 &5833122207675319696 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122207675319711} + m_Layer: 0 + m_Name: Z- + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122207675319711 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207675319696} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5833122207406226671} + m_Father: {fileID: 5833122208500950419} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &5833122207780405945 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122207780405944} + m_Layer: 0 + m_Name: Z+ + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122207780405944 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122207780405945} + m_LocalRotation: {x: 1, y: -0, z: -0, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5833122208083353153} + m_Father: {fileID: 5833122208500950419} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 180, y: 0, z: 0} +--- !u!1 &5833122208083353154 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122208083353153} + - component: {fileID: 5833122208083353167} + - component: {fileID: 5833122208083353152} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122208083353153 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208083353154} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5833122207780405944} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &5833122208083353167 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208083353154} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 32 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &5833122208083353152 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208083353154} + m_Enabled: 1 +--- !u!1 &5833122208133989455 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122208133989454} + - component: {fileID: 5833122208133989452} + - component: {fileID: 5833122208133989453} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122208133989454 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208133989455} + m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5833122209062167205} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90} +--- !u!20 &5833122208133989452 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208133989455} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 32 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &5833122208133989453 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208133989455} + m_Enabled: 1 +--- !u!1 &5833122208268285688 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122208268285639} + - component: {fileID: 5833122208268285637} + - component: {fileID: 5833122208268285638} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122208268285639 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208268285688} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5833122208897947189} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!20 &5833122208268285637 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208268285688} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 32 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &5833122208268285638 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208268285688} + m_Enabled: 1 +--- !u!1 &5833122208500950420 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122208500950419} + m_Layer: 0 + m_Name: SphericalToCubemap_Converter + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122208500950419 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208500950420} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5833122207578457518} + - {fileID: 5833122209062167205} + - {fileID: 5833122208897947189} + - {fileID: 5833122207321976507} + - {fileID: 5833122207780405944} + - {fileID: 5833122207675319711} + - {fileID: 3564573825682163582} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &5833122208897947190 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122208897947189} + m_Layer: 0 + m_Name: Y+ + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122208897947189 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208897947190} + m_LocalRotation: {x: -0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5833122208268285639} + m_Father: {fileID: 5833122208500950419} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} +--- !u!1 &5833122208972862031 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122208972862030} + - component: {fileID: 5833122208972862028} + - component: {fileID: 5833122208972862029} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122208972862030 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208972862031} + m_LocalRotation: {x: 0, y: 0, z: 1, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5833122207321976507} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180} +--- !u!20 &5833122208972862028 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208972862031} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 20 + field of view: 90 + orthographic: 0 + orthographic size: 5.77 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 32 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 0 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!81 &5833122208972862029 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122208972862031} + m_Enabled: 1 +--- !u!1 &5833122209062167206 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5833122209062167205} + m_Layer: 0 + m_Name: X- + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5833122209062167205 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5833122209062167206} + m_LocalRotation: {x: 0.5, y: -0.5, z: -0.5, w: 0.5} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5833122208133989454} + m_Father: {fileID: 5833122208500950419} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: -90, z: -90} +--- !u!1001 &8362443216786123876 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 2 + m_TransformParent: {fileID: 5833122208500950419} + m_Modifications: + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalPosition.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -1504981713932161579, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: 99c4481312a63c9438226c0bc65509e2, type: 2} + - target: {fileID: -927199367670048503, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + propertyPath: m_Name + value: Spherical_01 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_AddedGameObjects: [] + m_SourcePrefab: {fileID: 100100000, guid: db446dca6aa430e47ac1d660389c9c20, type: 3} +--- !u!4 &3564573825682163582 stripped +Transform: + m_CorrespondingSourceObject: {fileID: -4216859302048453862, guid: db446dca6aa430e47ac1d660389c9c20, + type: 3} + m_PrefabInstance: {fileID: 8362443216786123876} + m_PrefabAsset: {fileID: 0} diff --git a/PrefabUtils/SphericalToCubemap_Converter.prefab.meta b/PrefabUtils/SphericalToCubemap_Converter.prefab.meta new file mode 100644 index 0000000..3468036 --- /dev/null +++ b/PrefabUtils/SphericalToCubemap_Converter.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 14c35cd2f558f1d4db94dc82385a6191 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/README.md b/README.md index 59e3f62..dd4d857 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ # Unity-GLTF-Exporter Export from unity to glTF + +Important Setup -> +1- Make sure to install "Shader Graph" package required to create Images for the exporter: + +Window -> PackageManager + +In Unity Registry section, search for shader grraph, and install it. + +2- Add Mono_Export To GLTF to the desired parent node to export + +3- set at least gltf name, model create folder and export location, and press gltf test build + diff --git a/README.md.meta b/README.md.meta new file mode 100644 index 0000000..83084a3 --- /dev/null +++ b/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 768cf1f2dd19f7b4eab4bea8d8dfcb28 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects.meta b/ScriptableObjects.meta new file mode 100644 index 0000000..d2c68f0 --- /dev/null +++ b/ScriptableObjects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f45ff46fb4a93264997962804e9db256 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions.meta b/ScriptableObjects/ExportGLTFOptions.meta new file mode 100644 index 0000000..15ad1d8 --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d255731b32970eb408c7567e5456961a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults.meta b/ScriptableObjects/ExportGLTFOptions/Defaults.meta new file mode 100644 index 0000000..03ae76e --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1e667ce5664ebf645912b92724c7c877 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-SmartObjects-KTX.asset b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-SmartObjects-KTX.asset new file mode 100644 index 0000000..d261eac --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-SmartObjects-KTX.asset @@ -0,0 +1,72 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b25f5645d64536f468fd3c03eece58ad, type: 3} + m_Name: SO_GLTF_Options-SmartObjects-KTX + m_EditorClassIdentifier: + exportGameObjectName: 1 + exportMaterialName: 0 + exportTexturesName: 0 + exportCameras: 0 + exportInactive: 1 + exportGameObjectsTag: 1 + exportGameObjectsLayer: 1 + exportBatching: 1 + exportNavMesh: 1 + blockLeafNodesCreation: 0 + exportAnimations: 1 + reduceGLTFChars: 0 + exportNormals: 1 + exportLightmapUVs: 1 + convertToGLB: 0 + createUVOffsetExtras: 0 + exportSubmeshesInExtra: 0 + colorTextureSaturation: 0.8 + metallicMultiplier: 0.8 + smoothnessMultiplier: 0.8 + exportSeparatedAlphaMap: 1 + exportTextureType: 2 + fallbackGLTFTexture: 0 + allImagesDivideFactor: 1 + overrideLightmapDivideFactor: -1 + overrideDefaultDivideFactor: -1 + overrideCubemapDivideFactor: -1 + overrideMetallicSmoothnessDivideFactor: -1 + overrideNormalDivideFactor: -1 + allImagesQuality: 75 + overrideLightmapQuality: 0 + overrideNormalQuality: 0 + overrideMetallicSmoothnessQuality: 0 + overrideCubemapQuality: 0 + overrideDefaultQuality: 0 + overrideLightmapExportTextureType: 0 + overrideNormalExportTextureType: -1 + overrideMetallicSmoothnessExportTextureType: -1 + overrideDefaultExportTextureType: -1 + overrideCubemapTextureType: 0 + maxLightmapClamp: 5 + saturationLightmap: 1 + whiteImageForNonStaticLightmaps: 1 + lightmapIntensityMultiplier: 1 + lightmapContrastCheat: 1 + quantizeGLTF: 1 + quantizeMainUVsTo: 1 + quantizeLightUVsTo: 1 + quantizeVerticesTo: 2 + quantizeNormalsTo: 0 + exportSceneSkyboxEnvironment: 1 + exportSceneSkyboxBackground: 1 + createCubeForSkybox: 1 + cubeSkyboxScale: 1 + exportSceneSkyboxBackgroundEvenDefault: 0 + exportSceneFog: 1 + overrideEnvironmentQuality: 0 + extraExportMainCameraInGLTF: 0 diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-SmartObjects-KTX.asset.meta b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-SmartObjects-KTX.asset.meta new file mode 100644 index 0000000..179f36a --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-SmartObjects-KTX.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d05550ef90c661d49b129f9f1124d85f +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures-KTX.asset b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures-KTX.asset new file mode 100644 index 0000000..bc4400c --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures-KTX.asset @@ -0,0 +1,72 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b25f5645d64536f468fd3c03eece58ad, type: 3} + m_Name: SO_GLTF_Options-Test-HalfTextures-KTX + m_EditorClassIdentifier: + exportGameObjectName: 1 + exportMaterialName: 1 + exportTexturesName: 0 + exportCameras: 1 + exportInactive: 1 + exportGameObjectsTag: 1 + exportGameObjectsLayer: 1 + exportBatching: 1 + exportNavMesh: 1 + blockLeafNodesCreation: 0 + exportAnimations: 1 + reduceGLTFChars: 0 + exportNormals: 1 + exportLightmapUVs: 1 + convertToGLB: 0 + createUVOffsetExtras: 0 + exportSubmeshesInExtra: 1 + colorTextureSaturation: 0.9 + metallicMultiplier: 0.8 + smoothnessMultiplier: 0.9 + exportSeparatedAlphaMap: 0 + exportTextureType: 1 + fallbackGLTFTexture: 0 + allImagesDivideFactor: 4 + overrideLightmapDivideFactor: 1 + overrideDefaultDivideFactor: -1 + overrideCubemapDivideFactor: 1 + overrideMetallicSmoothnessDivideFactor: 8 + overrideNormalDivideFactor: -1 + allImagesQuality: 75 + overrideLightmapQuality: 0 + overrideNormalQuality: 0 + overrideMetallicSmoothnessQuality: 0 + overrideCubemapQuality: 0 + overrideDefaultQuality: 0 + overrideLightmapExportTextureType: -1 + overrideNormalExportTextureType: -1 + overrideMetallicSmoothnessExportTextureType: -1 + overrideDefaultExportTextureType: -1 + overrideCubemapTextureType: 0 + maxLightmapClamp: 5 + saturationLightmap: 1 + whiteImageForNonStaticLightmaps: 1 + lightmapIntensityMultiplier: 1.5 + lightmapContrastCheat: 2 + quantizeGLTF: 1 + quantizeMainUVsTo: 1 + quantizeLightUVsTo: 1 + quantizeVerticesTo: 2 + quantizeNormalsTo: 0 + exportSceneSkyboxEnvironment: 0 + exportSceneSkyboxBackground: 0 + createCubeForSkybox: 0 + cubeSkyboxScale: 1 + exportSceneSkyboxBackgroundEvenDefault: 0 + exportSceneFog: 0 + overrideEnvironmentQuality: 0 + extraExportMainCameraInGLTF: 0 diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures-KTX.asset.meta b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures-KTX.asset.meta new file mode 100644 index 0000000..835ac84 --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures-KTX.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 18d0bbe5902a5e743be73fd617f7af4a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures.asset b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures.asset new file mode 100644 index 0000000..a620bda --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures.asset @@ -0,0 +1,72 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b25f5645d64536f468fd3c03eece58ad, type: 3} + m_Name: SO_GLTF_Options-Test-HalfTextures + m_EditorClassIdentifier: + exportGameObjectName: 1 + exportMaterialName: 1 + exportTexturesName: 0 + exportCameras: 1 + exportInactive: 1 + exportGameObjectsTag: 1 + exportGameObjectsLayer: 1 + exportBatching: 1 + exportNavMesh: 1 + blockLeafNodesCreation: 0 + exportAnimations: 1 + reduceGLTFChars: 0 + exportNormals: 1 + exportLightmapUVs: 1 + convertToGLB: 0 + createUVOffsetExtras: 0 + exportSubmeshesInExtra: 1 + colorTextureSaturation: 0.8 + metallicMultiplier: 0.85 + smoothnessMultiplier: 0.9 + exportSeparatedAlphaMap: 1 + exportTextureType: 0 + fallbackGLTFTexture: 0 + allImagesDivideFactor: 1 + overrideLightmapDivideFactor: 1 + overrideDefaultDivideFactor: -1 + overrideCubemapDivideFactor: -1 + overrideMetallicSmoothnessDivideFactor: -1 + overrideNormalDivideFactor: -1 + allImagesQuality: 100 + overrideLightmapQuality: 0 + overrideNormalQuality: 0 + overrideMetallicSmoothnessQuality: 0 + overrideCubemapQuality: 0 + overrideDefaultQuality: 0 + overrideLightmapExportTextureType: -1 + overrideNormalExportTextureType: -1 + overrideMetallicSmoothnessExportTextureType: -1 + overrideDefaultExportTextureType: -1 + overrideCubemapTextureType: 0 + maxLightmapClamp: 5 + saturationLightmap: 1 + whiteImageForNonStaticLightmaps: 1 + lightmapIntensityMultiplier: 1.5 + lightmapContrastCheat: 1 + quantizeGLTF: 1 + quantizeMainUVsTo: 1 + quantizeLightUVsTo: 1 + quantizeVerticesTo: 2 + quantizeNormalsTo: 0 + exportSceneSkyboxEnvironment: 1 + exportSceneSkyboxBackground: 1 + createCubeForSkybox: 0 + cubeSkyboxScale: 1 + exportSceneSkyboxBackgroundEvenDefault: 0 + exportSceneFog: 0 + overrideEnvironmentQuality: 0 + extraExportMainCameraInGLTF: 0 diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures.asset.meta b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures.asset.meta new file mode 100644 index 0000000..8b799eb --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Test-HalfTextures.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4c4e3a5a9bdb73f4cbba7df14d32962a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Threevox-Default.asset b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Threevox-Default.asset new file mode 100644 index 0000000..53c4604 --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Threevox-Default.asset @@ -0,0 +1,72 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b25f5645d64536f468fd3c03eece58ad, type: 3} + m_Name: SO_GLTF_Options-Threevox-Default + m_EditorClassIdentifier: + exportGameObjectName: 1 + exportMaterialName: 1 + exportTexturesName: 0 + exportCameras: 1 + exportInactive: 1 + exportGameObjectsTag: 1 + exportGameObjectsLayer: 1 + exportBatching: 1 + exportNavMesh: 1 + blockLeafNodesCreation: 0 + exportAnimations: 1 + reduceGLTFChars: 0 + exportNormals: 1 + exportLightmapUVs: 1 + convertToGLB: 0 + createUVOffsetExtras: 0 + exportSubmeshesInExtra: 1 + colorTextureSaturation: 0.8 + metallicMultiplier: 0.8 + smoothnessMultiplier: 0.8 + exportSeparatedAlphaMap: 1 + exportTextureType: 2 + fallbackGLTFTexture: 0 + allImagesDivideFactor: 1 + overrideLightmapDivideFactor: -1 + overrideDefaultDivideFactor: -1 + overrideCubemapDivideFactor: -1 + overrideMetallicSmoothnessDivideFactor: -1 + overrideNormalDivideFactor: -1 + allImagesQuality: 100 + overrideLightmapQuality: 0 + overrideNormalQuality: 0 + overrideMetallicSmoothnessQuality: 0 + overrideCubemapQuality: 0 + overrideDefaultQuality: 0 + overrideLightmapExportTextureType: -1 + overrideNormalExportTextureType: -1 + overrideMetallicSmoothnessExportTextureType: -1 + overrideDefaultExportTextureType: -1 + overrideCubemapTextureType: 0 + maxLightmapClamp: 5 + saturationLightmap: 1 + whiteImageForNonStaticLightmaps: 1 + lightmapIntensityMultiplier: 1 + lightmapContrastCheat: 1 + quantizeGLTF: 1 + quantizeMainUVsTo: 1 + quantizeLightUVsTo: 1 + quantizeVerticesTo: 2 + quantizeNormalsTo: 0 + exportSceneSkyboxEnvironment: 0 + exportSceneSkyboxBackground: 0 + createCubeForSkybox: 0 + cubeSkyboxScale: 1 + exportSceneSkyboxBackgroundEvenDefault: 0 + exportSceneFog: 0 + overrideEnvironmentQuality: 0 + extraExportMainCameraInGLTF: 0 diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Threevox-Default.asset.meta b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Threevox-Default.asset.meta new file mode 100644 index 0000000..b629f75 --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Threevox-Default.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac62142ed90819048a9eb1bca99eb96c +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Wonderland-default.asset b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Wonderland-default.asset new file mode 100644 index 0000000..7f3f25b --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Wonderland-default.asset @@ -0,0 +1,72 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b25f5645d64536f468fd3c03eece58ad, type: 3} + m_Name: SO_GLTF_Options-Wonderland-default + m_EditorClassIdentifier: + exportGameObjectName: 1 + exportMaterialName: 0 + exportTexturesName: 0 + exportCameras: 0 + exportInactive: 0 + exportGameObjectsTag: 0 + exportGameObjectsLayer: 0 + exportBatching: 0 + exportNavMesh: 0 + blockLeafNodesCreation: 1 + exportAnimations: 1 + reduceGLTFChars: 0 + exportNormals: 1 + exportLightmapUVs: 1 + convertToGLB: 0 + createUVOffsetExtras: 0 + exportSubmeshesInExtra: 0 + colorTextureSaturation: 0.8 + metallicMultiplier: 0.8 + smoothnessMultiplier: 0.8 + exportSeparatedAlphaMap: 1 + exportTextureType: 0 + fallbackGLTFTexture: 0 + allImagesDivideFactor: 1 + overrideLightmapDivideFactor: -1 + overrideDefaultDivideFactor: -1 + overrideCubemapDivideFactor: -1 + overrideMetallicSmoothnessDivideFactor: -1 + overrideNormalDivideFactor: -1 + allImagesQuality: 75 + overrideLightmapQuality: 0 + overrideNormalQuality: 0 + overrideMetallicSmoothnessQuality: 0 + overrideCubemapQuality: 0 + overrideDefaultQuality: 0 + overrideLightmapExportTextureType: 0 + overrideNormalExportTextureType: -1 + overrideMetallicSmoothnessExportTextureType: -1 + overrideDefaultExportTextureType: -1 + overrideCubemapTextureType: 0 + maxLightmapClamp: 5 + saturationLightmap: 1 + whiteImageForNonStaticLightmaps: 1 + lightmapIntensityMultiplier: 1 + lightmapContrastCheat: 1 + quantizeGLTF: 1 + quantizeMainUVsTo: 1 + quantizeLightUVsTo: 1 + quantizeVerticesTo: 2 + quantizeNormalsTo: 0 + exportSceneSkyboxEnvironment: 1 + exportSceneSkyboxBackground: 1 + createCubeForSkybox: 1 + cubeSkyboxScale: 1 + exportSceneSkyboxBackgroundEvenDefault: 0 + exportSceneFog: 1 + overrideEnvironmentQuality: 0 + extraExportMainCameraInGLTF: 0 diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Wonderland-default.asset.meta b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Wonderland-default.asset.meta new file mode 100644 index 0000000..518a00d --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options-Wonderland-default.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f75fc01825cc76948b4945e5dfe083a2 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options.asset b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options.asset new file mode 100644 index 0000000..d737e67 --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options.asset @@ -0,0 +1,72 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b25f5645d64536f468fd3c03eece58ad, type: 3} + m_Name: SO_GLTF_Options + m_EditorClassIdentifier: + exportGameObjectName: 1 + exportMaterialName: 0 + exportTexturesName: 0 + exportCameras: 0 + exportInactive: 1 + exportGameObjectsTag: 1 + exportGameObjectsLayer: 1 + exportBatching: 1 + exportNavMesh: 1 + blockLeafNodesCreation: 0 + exportAnimations: 1 + reduceGLTFChars: 0 + exportNormals: 1 + exportLightmapUVs: 1 + convertToGLB: 0 + createUVOffsetExtras: 0 + exportSubmeshesInExtra: 0 + colorTextureSaturation: 0.8 + metallicMultiplier: 0.8 + smoothnessMultiplier: 0.8 + exportSeparatedAlphaMap: 1 + exportTextureType: 2 + fallbackGLTFTexture: 0 + allImagesDivideFactor: 1 + overrideLightmapDivideFactor: -1 + overrideDefaultDivideFactor: -1 + overrideCubemapDivideFactor: -1 + overrideMetallicSmoothnessDivideFactor: -1 + overrideNormalDivideFactor: -1 + allImagesQuality: 75 + overrideLightmapQuality: 0 + overrideNormalQuality: 0 + overrideMetallicSmoothnessQuality: 0 + overrideCubemapQuality: 0 + overrideDefaultQuality: 0 + overrideLightmapExportTextureType: 0 + overrideNormalExportTextureType: -1 + overrideMetallicSmoothnessExportTextureType: -1 + overrideDefaultExportTextureType: -1 + overrideCubemapTextureType: 0 + maxLightmapClamp: 5 + saturationLightmap: 1 + whiteImageForNonStaticLightmaps: 1 + lightmapIntensityMultiplier: 1 + lightmapContrastCheat: 1 + quantizeGLTF: 1 + quantizeMainUVsTo: 1 + quantizeLightUVsTo: 1 + quantizeVerticesTo: 2 + quantizeNormalsTo: 0 + exportSceneSkyboxEnvironment: 1 + exportSceneSkyboxBackground: 1 + createCubeForSkybox: 1 + cubeSkyboxScale: 1 + exportSceneSkyboxBackgroundEvenDefault: 0 + exportSceneFog: 1 + overrideEnvironmentQuality: 0 + extraExportMainCameraInGLTF: 0 diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options.asset.meta b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options.asset.meta new file mode 100644 index 0000000..179baf6 --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a1a753e767a804f45bca064ba06658a0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options_omi_basic.asset b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options_omi_basic.asset new file mode 100644 index 0000000..ceffd88 --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options_omi_basic.asset @@ -0,0 +1,72 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b25f5645d64536f468fd3c03eece58ad, type: 3} + m_Name: SO_GLTF_Options_omi_basic + m_EditorClassIdentifier: + exportGameObjectName: 1 + exportMaterialName: 1 + exportTexturesName: 1 + exportCameras: 0 + exportInactive: 1 + exportGameObjectsTag: 1 + exportGameObjectsLayer: 1 + exportBatching: 1 + exportNavMesh: 1 + blockLeafNodesCreation: 1 + exportAnimations: 1 + reduceGLTFChars: 0 + exportNormals: 1 + exportLightmapUVs: 1 + convertToGLB: 0 + createUVOffsetExtras: 0 + exportSubmeshesInExtra: 0 + colorTextureSaturation: 1 + metallicMultiplier: 1 + smoothnessMultiplier: 1 + exportSeparatedAlphaMap: 0 + exportTextureType: 0 + fallbackGLTFTexture: 0 + allImagesDivideFactor: 1 + overrideLightmapDivideFactor: -1 + overrideDefaultDivideFactor: -1 + overrideCubemapDivideFactor: -1 + overrideMetallicSmoothnessDivideFactor: -1 + overrideNormalDivideFactor: -1 + allImagesQuality: 90 + overrideLightmapQuality: 0 + overrideNormalQuality: 0 + overrideMetallicSmoothnessQuality: 0 + overrideCubemapQuality: 0 + overrideDefaultQuality: 0 + overrideLightmapExportTextureType: 0 + overrideNormalExportTextureType: -1 + overrideMetallicSmoothnessExportTextureType: -1 + overrideDefaultExportTextureType: -1 + overrideCubemapTextureType: 0 + maxLightmapClamp: 5 + saturationLightmap: 1 + whiteImageForNonStaticLightmaps: 0 + lightmapIntensityMultiplier: 1 + lightmapContrastCheat: 1 + quantizeGLTF: 0 + quantizeMainUVsTo: 1 + quantizeLightUVsTo: 1 + quantizeVerticesTo: 2 + quantizeNormalsTo: 0 + exportSceneSkyboxEnvironment: 0 + exportSceneSkyboxBackground: 0 + createCubeForSkybox: 0 + cubeSkyboxScale: 1 + exportSceneSkyboxBackgroundEvenDefault: 0 + exportSceneFog: 0 + overrideEnvironmentQuality: 0 + extraExportMainCameraInGLTF: 0 diff --git a/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options_omi_basic.asset.meta b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options_omi_basic.asset.meta new file mode 100644 index 0000000..09cc91e --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Defaults/SO_GLTF_Options_omi_basic.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 686768641beee804785485911f106710 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/ExportGLTFOptions/Threevox-Custom.asset b/ScriptableObjects/ExportGLTFOptions/Threevox-Custom.asset new file mode 100644 index 0000000..504777b --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Threevox-Custom.asset @@ -0,0 +1,72 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b25f5645d64536f468fd3c03eece58ad, type: 3} + m_Name: Threevox-Custom + m_EditorClassIdentifier: + exportGameObjectName: 1 + exportMaterialName: 1 + exportTexturesName: 0 + exportCameras: 1 + exportInactive: 1 + exportGameObjectsTag: 1 + exportGameObjectsLayer: 1 + exportBatching: 1 + exportNavMesh: 1 + blockLeafNodesCreation: 0 + exportAnimations: 1 + reduceGLTFChars: 0 + exportNormals: 1 + exportLightmapUVs: 1 + convertToGLB: 0 + createUVOffsetExtras: 0 + exportSubmeshesInExtra: 1 + colorTextureSaturation: 0.8 + metallicMultiplier: 0.8 + smoothnessMultiplier: 0.8 + exportSeparatedAlphaMap: 1 + exportTextureType: 1 + fallbackGLTFTexture: 0 + allImagesDivideFactor: 1 + overrideLightmapDivideFactor: -1 + overrideDefaultDivideFactor: -1 + overrideCubemapDivideFactor: -1 + overrideMetallicSmoothnessDivideFactor: -1 + overrideNormalDivideFactor: -1 + allImagesQuality: 100 + overrideLightmapQuality: 0 + overrideNormalQuality: 0 + overrideMetallicSmoothnessQuality: 0 + overrideCubemapQuality: 0 + overrideDefaultQuality: 0 + overrideLightmapExportTextureType: -1 + overrideNormalExportTextureType: -1 + overrideMetallicSmoothnessExportTextureType: -1 + overrideDefaultExportTextureType: -1 + overrideCubemapTextureType: 0 + maxLightmapClamp: 5 + saturationLightmap: 1 + whiteImageForNonStaticLightmaps: 1 + lightmapIntensityMultiplier: 1.5 + lightmapContrastCheat: 1 + quantizeGLTF: 1 + quantizeMainUVsTo: 1 + quantizeLightUVsTo: 1 + quantizeVerticesTo: 2 + quantizeNormalsTo: 0 + exportSceneSkyboxEnvironment: 0 + exportSceneSkyboxBackground: 0 + createCubeForSkybox: 0 + cubeSkyboxScale: 1 + exportSceneSkyboxBackgroundEvenDefault: 0 + exportSceneFog: 0 + overrideEnvironmentQuality: 0 + extraExportMainCameraInGLTF: 0 diff --git a/ScriptableObjects/ExportGLTFOptions/Threevox-Custom.asset.meta b/ScriptableObjects/ExportGLTFOptions/Threevox-Custom.asset.meta new file mode 100644 index 0000000..1007363 --- /dev/null +++ b/ScriptableObjects/ExportGLTFOptions/Threevox-Custom.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a33efdced735e1a48ab2a5a0dee6f4dd +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts.meta b/Scripts.meta new file mode 100644 index 0000000..4c97d42 --- /dev/null +++ b/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 992e5e5a09cd7ee498c6e1e8d182644f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor.meta b/Scripts/Editor.meta new file mode 100644 index 0000000..0b5721c --- /dev/null +++ b/Scripts/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 44d24a3a72b20044f8b80298b4db627d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu.meta b/Scripts/Editor/EditorWindowAndMenu.meta new file mode 100644 index 0000000..88fa9d3 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 90b29ec0e67f8574cac30ffb07ed4f32 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/AskUserInputWindow.cs b/Scripts/Editor/EditorWindowAndMenu/AskUserInputWindow.cs new file mode 100644 index 0000000..a1c64ed --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/AskUserInputWindow.cs @@ -0,0 +1,67 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + public class AskUserInputWindow : EditorWindow + { + public delegate void SetString(string st); + protected SetString callbackFunction; + protected string titleWindow; + protected string descriptionWindow; + protected string okButton; + protected string cancelButton; + + string _value; + public static AskUserInputWindow CreateInstance(string title_window, string description_window, SetString callback_function, string cancel_button = "Cancel", string ok_button = "Ok") + { + + AskUserInputWindow o = CreateInstance(); + + // Then directly set the values + o.descriptionWindow = description_window; + o.titleWindow = title_window; + o.callbackFunction = callback_function; + o.okButton = ok_button; + o.cancelButton = cancel_button; + + o.minSize = new Vector2(300f, 120f); + o.maxSize = o.minSize; + o.titleContent = new GUIContent(o.titleWindow); + + var position = o.position; + position.center = new Rect(0f, 0f, Screen.currentResolution.width, Screen.currentResolution.height).center; + o.position = position; + o.Show(); + /* .... */ + + return o; + } + + private void OnGUI() + { + GUILayout.BeginArea(new Rect(new Vector2(20f, 0f), new Vector2(260f, 400f))); + EditorGUILayout.LabelField(descriptionWindow, EditorStyles.boldLabel, GUILayout.Height(50f)); + + GUILayout.EndArea(); + GUILayout.BeginArea(new Rect(new Vector2(20f, 45f), new Vector2(260f, 400f))); + _value = EditorGUILayout.TextField(_value,GUILayout.Height(20f)); + GUILayout.EndArea(); + + //EditorGUILayout.BeginHorizontal(); + GUILayout.BeginArea(new Rect(new Vector2(50f,80f),new Vector2(400f, 200f))); + if (GUILayout.Button(cancelButton, GUILayout.Width (90f), GUILayout.Height(30f))) + Close(); + GUILayout.EndArea(); + GUILayout.BeginArea(new Rect(new Vector2(150f, 80f), new Vector2(400f, 200f))); + if (GUILayout.Button(okButton, GUILayout.Width(90f), GUILayout.Height(30f))) + { + callbackFunction(_value); + Close(); + } + GUILayout.EndArea(); + //EditorGUILayout.EndHorizontal(); + } + } +} diff --git a/Scripts/Editor/EditorWindowAndMenu/AskUserInputWindow.cs.meta b/Scripts/Editor/EditorWindowAndMenu/AskUserInputWindow.cs.meta new file mode 100644 index 0000000..def3cd3 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/AskUserInputWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a6ff6b06ad7d6d84a87f6bf6e0442efe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/ChangeSelectedObjectsMaterialWindow.cs b/Scripts/Editor/EditorWindowAndMenu/ChangeSelectedObjectsMaterialWindow.cs new file mode 100644 index 0000000..11408f9 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/ChangeSelectedObjectsMaterialWindow.cs @@ -0,0 +1,76 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER +{ + public class ChangeSelectedObjectsMaterialWindow : EditorWindow + { + public static Material targetMaterial; + public bool changeMaterialToChilds = true; + + public static void ShowWindow() + { + GetPlayerPrefs(); + EditorWindow.GetWindow(typeof(ChangeSelectedObjectsMaterialWindow)); + } + private void OnGUI() + { + GUILayout.Label("Target Material", EditorStyles.boldLabel); + targetMaterial = (Material)EditorGUILayout.ObjectField("Target Material", targetMaterial, (typeof(Material))); + changeMaterialToChilds = EditorGUILayout.Toggle("Change childs materials",changeMaterialToChilds); + if (GUILayout.Button("Assign Material to selection", GUILayout.Height(80f))) + { + AssignMaterialToSelectedAssets(); + } + if (GUILayout.Button("Save to prefs", GUILayout.Height(80f))) + { + SavePlayerPrefs(); + } + } + public void AssignMaterialToSelectedAssets() + { + if (targetMaterial != null) + { + foreach (GameObject go in Selection.gameObjects) + { + if (changeMaterialToChilds) + { + MeshRenderer[] allMeshRend = go.GetComponentsInChildren(true); + foreach (MeshRenderer mr in allMeshRend) + { + mr.sharedMaterial = targetMaterial; + } + } + else + { + MeshRenderer mr = go.GetComponent(); + if (mr != null) + { + mr.sharedMaterial = targetMaterial; + } + } + } + } + else + { + Debug.LogWarning("NO MATERIAL SELECTED, please assign material before setting material to selection"); + } + } + public void SavePlayerPrefs() + { + if (targetMaterial != null) + { + PlayerPrefs.SetString("ChangeSelectedObjectsMaterial_Material", AssetDatabase.GetAssetPath(targetMaterial)); + } + } + public static void GetPlayerPrefs() + { + if (targetMaterial == null) + { + targetMaterial = (Material)AssetDatabase.LoadAssetAtPath(PlayerPrefs.GetString("ChangeSelectedObjectsMaterial_Material"),typeof (Material)); + } + } + } +} diff --git a/Scripts/Editor/EditorWindowAndMenu/ChangeSelectedObjectsMaterialWindow.cs.meta b/Scripts/Editor/EditorWindowAndMenu/ChangeSelectedObjectsMaterialWindow.cs.meta new file mode 100644 index 0000000..3958a64 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/ChangeSelectedObjectsMaterialWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 25c1015ba72ac4b43a6945b5604c0ad2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/ExportGLTFOptionsWindow.cs b/Scripts/Editor/EditorWindowAndMenu/ExportGLTFOptionsWindow.cs new file mode 100644 index 0000000..2497215 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/ExportGLTFOptionsWindow.cs @@ -0,0 +1,167 @@ +using UnityEditor; +using UnityEngine; +namespace WEBGL_EXPORTER.GLTF +{ + public class ExportGLTFOptionsWindow : EditorWindow + { + private enum SEL_MENU { textures, lightmap,options,quantization,scene } + private enum SEL_COMP_TYPE { BYTE = 5121, SHORT = 5123, FLOAT = 5126 } + //private enum SEL_SIGNED_COMP_TYPE { BYTE = 5120, SHORT = 5122, FLOAT = 5126 } + private SEL_MENU curMenu = SEL_MENU.options; + const float width = 400f; + const float height = 520f; + const float margin = 20f; + + public float finalWidth; + public float optionsButtonsSize; + + public ExportGLTFOptions opt; + + public static ExportGLTFOptionsWindow CreateInstance() + { + ExportGLTFOptionsWindow o = CreateInstance(); + + o.titleContent = new GUIContent("GLTF options"); + + o.minSize = new Vector2(width, height); + o.maxSize = o.minSize; + + var position = o.position; + position.center = new Rect(0f, 0f, Screen.currentResolution.width, Screen.currentResolution.height).center; + o.position = position; + o.Show(); + + o.finalWidth = width - (margin * 2); + o.optionsButtonsSize = ((width - (margin * 2)) / 4)-1f; + o.opt = new ExportGLTFOptions(); + o.opt.GetPrefsValues(); + + return o; + } + + + private void OnGUI() + { + if (opt == null) + this.Close(); + + EditorGUI.BeginChangeCheck(); + GUILayout.BeginArea(new Rect(new Vector2(margin-2f, 20f), new Vector2(finalWidth+10f, 60f))); + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Options", GUILayout.Height(30f), GUILayout.Width(optionsButtonsSize))) + curMenu = SEL_MENU.options; + if (GUILayout.Button("Textures", GUILayout.Height(30f), GUILayout.Width(optionsButtonsSize))) + curMenu = SEL_MENU.textures; + if (GUILayout.Button("Lightmaps", GUILayout.Height(30f), GUILayout.Width(optionsButtonsSize))) + curMenu = SEL_MENU.lightmap; + if (GUILayout.Button("Quantization", GUILayout.Height(30f), GUILayout.Width(optionsButtonsSize))) + curMenu = SEL_MENU.quantization; + EditorGUILayout.EndHorizontal(); + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Scene", GUILayout.Height(30f), GUILayout.Width(optionsButtonsSize))) + curMenu = SEL_MENU.scene; + EditorGUILayout.EndHorizontal(); + GUILayout.EndArea(); + GUILayout.BeginArea(new Rect(new Vector2(margin-2f, 100f), new Vector2(finalWidth, 420f))); + + switch (curMenu) + { + //==GENERAL OPTIONS==// + case SEL_MENU.options: + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.BeginVertical(); + opt.exportGameObjectName = EditorGUILayout.Toggle("Export GameObject Names", opt.exportGameObjectName); + opt.exportMaterialName = EditorGUILayout.Toggle("Export Material Names", opt.exportMaterialName); + opt.exportTexturesName = EditorGUILayout.Toggle("Export Texture Names", opt.exportTexturesName); + opt.exportCameras = EditorGUILayout.Toggle("Export Cameras", opt.exportCameras); + opt.exportInactive = EditorGUILayout.Toggle("Export Inactive GameObjects", opt.exportInactive); + opt.exportGameObjectsTag = EditorGUILayout.Toggle("Export Tag", opt.exportGameObjectsTag); + opt.exportGameObjectsLayer = EditorGUILayout.Toggle("Export Layer", opt.exportGameObjectsLayer); + opt.exportBatching = EditorGUILayout.Toggle("Export 'batching' flag", opt.exportBatching); + opt.exportNavMesh = EditorGUILayout.Toggle("Export navMesh", opt.exportNavMesh); + EditorGUILayout.EndVertical(); + EditorGUILayout.BeginVertical(); + opt.exportSubmeshesInExtra = EditorGUILayout.Toggle("Export Submeshes in extra", opt.exportSubmeshesInExtra); + opt.reduceGLTFChars = EditorGUILayout.Toggle("Reduce GLTF Code", opt.reduceGLTFChars); + opt.exportNormals = EditorGUILayout.Toggle("Export Mesh Normals", opt.exportNormals); + + GUI.enabled = false; + opt.exportLightmapUVs = EditorGUILayout.Toggle("Export Lightmap UVs", opt.exportLightmapUVs); + opt.convertToGLB = EditorGUILayout.Toggle("Convert to GLB", opt.convertToGLB); + opt.createUVOffsetExtras = EditorGUILayout.Toggle("Save Offset Scale in Extras", opt.createUVOffsetExtras); + GUI.enabled = true; + EditorGUILayout.EndVertical(); + EditorGUILayout.EndHorizontal(); + break; + //==TEXTURES QUALITY==// + case SEL_MENU.textures: + opt.colorTextureSaturation = EditorGUILayout.Slider("Color Texture Saturation", opt.colorTextureSaturation, 0f, 1f); + opt.exportSeparatedAlphaMap = EditorGUILayout.Toggle("Export alfa in extra map", opt.exportSeparatedAlphaMap); + + opt.allImagesQuality = EditorGUILayout.IntSlider("All Images Quality", opt.allImagesQuality, 1, 100); + EditorGUILayout.LabelField("Quality Overrides"); + opt.overrideLightmapQuality = EditorGUILayout.IntSlider("Lightmap Quality", opt.overrideLightmapQuality, 0, 100); + opt.overrideNormalQuality = EditorGUILayout.IntSlider("Normal Quality", opt.overrideNormalQuality, 0, 100); + opt.overrideMetallicSmoothnessQuality = EditorGUILayout.IntSlider("Metallic Smoothness Quality", opt.overrideMetallicSmoothnessQuality, 0, 100); + opt.overrideCubemapQuality = EditorGUILayout.IntSlider("Cubemap Quality", opt.overrideCubemapQuality, 0, 100); + opt.overrideDefaultQuality = EditorGUILayout.IntSlider("Default Quality", opt.overrideDefaultQuality, 0, 100); + + opt.exportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Export Texture Type: ", opt.exportTextureType); + + if (opt.exportTextureType == TextureExportType.DEFAULT) + GUI.enabled = false; + opt.fallbackGLTFTexture = EditorGUILayout.Toggle("Fallback to jpeg", opt.fallbackGLTFTexture); + EditorGUILayout.LabelField("Export Overrides: (suggested DEFAULT in lightmap)"); + opt.overrideNormalExportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Normal Type: ", opt.overrideNormalExportTextureType); + opt.overrideDefaultExportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Default Type: ", opt.overrideDefaultExportTextureType); + opt.overrideMetallicSmoothnessExportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Smnoothness Type: ", opt.overrideMetallicSmoothnessExportTextureType); + opt.overrideLightmapExportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Lightmap Type: ", opt.overrideLightmapExportTextureType); + opt.overrideCubemapTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Cubemap Type: ", opt.overrideCubemapTextureType); + GUI.enabled = true; + break; + //==LIGHTMAPS==// + case SEL_MENU.lightmap: + opt.maxLightmapClamp = EditorGUILayout.FloatField("Max Clamp", opt.maxLightmapClamp); + opt.saturationLightmap = EditorGUILayout.FloatField("Saturation Compensation", opt.saturationLightmap); + opt.lightmapIntensityMultiplier = EditorGUILayout.FloatField("Intensity Multiplier*", opt.lightmapIntensityMultiplier); + opt.lightmapContrastCheat = EditorGUILayout.FloatField("lightmap Contrast Cheat*", opt.lightmapContrastCheat); + opt.whiteImageForNonStaticLightmaps = EditorGUILayout.Toggle("White Image on non static", opt.whiteImageForNonStaticLightmaps); + break; + + + //==QUANTIZATION==// + case SEL_MENU.quantization: + opt.quantizeGLTF = EditorGUILayout.Toggle("Quantize values", opt.quantizeGLTF); + if (!opt.quantizeGLTF) + GUI.enabled = false; + opt.quantizeMainUVsTo = (ComponentTypeSelected)EditorGUILayout.EnumPopup("Main UVs: ", opt.quantizeMainUVsTo); + opt.quantizeLightUVsTo = (ComponentTypeSelected)EditorGUILayout.EnumPopup("Lightmap UVs: ", opt.quantizeLightUVsTo); + opt.quantizeVerticesTo = (ComponentTypeSelected)EditorGUILayout.EnumPopup("Vertices: ", opt.quantizeVerticesTo); + opt.quantizeNormalsTo = (ComponentTypeSelected)EditorGUILayout.EnumPopup("Normals: ", opt.quantizeNormalsTo); + GUI.enabled = true; + break; + case SEL_MENU.scene: + opt.exportSceneSkyboxEnvironment = EditorGUILayout.Toggle("Export Skybox Environment", opt.exportSceneSkyboxEnvironment); + opt.exportSceneSkyboxBackground = EditorGUILayout.Toggle("Export Skybox Background", opt.exportSceneSkyboxBackground); + opt.exportSceneSkyboxBackgroundEvenDefault = EditorGUILayout.Toggle("Consider Default Skybox", opt.exportSceneSkyboxBackgroundEvenDefault); + opt.createCubeForSkybox = EditorGUILayout.Toggle("Create Cubemap Mesh", opt.createCubeForSkybox); + opt.exportSceneFog = EditorGUILayout.Toggle("Export Fog if active", opt.exportSceneFog); + break; + } + GUILayout.EndArea(); + GUILayout.BeginArea(new Rect(new Vector2(margin - 2f, 460f), new Vector2(finalWidth, 40f))); + if (GUILayout.Button("SAVE CHANGES", GUILayout.Height(30f))) + { + opt.SetPrefsValues(); + Debug.Log("CHANGES SUCCESFULLY SAVED"); + this.Close(); + } + GUILayout.EndArea(); + if (EditorGUI.EndChangeCheck()) + { + if (opt.exportTextureType == TextureExportType.NONE_SET) + opt.exportTextureType = TextureExportType.DEFAULT; + } + } + } +} diff --git a/Scripts/Editor/EditorWindowAndMenu/ExportGLTFOptionsWindow.cs.meta b/Scripts/Editor/EditorWindowAndMenu/ExportGLTFOptionsWindow.cs.meta new file mode 100644 index 0000000..849621d --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/ExportGLTFOptionsWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 63299aec8f351764399a87cef8925c69 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/ImageTextureSelectionWindow.cs b/Scripts/Editor/EditorWindowAndMenu/ImageTextureSelectionWindow.cs new file mode 100644 index 0000000..2297579 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/ImageTextureSelectionWindow.cs @@ -0,0 +1,69 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER +{ + public class ImageTextureSelectionWindow : EditorWindow + { + public delegate void SetImage(Texture2D texture2D); + protected SetImage callbackFunction; + + //public string targetFolder = ""; + public List previewTextures; + public List imageFileList; + public Vector2 buttonSize; + public int buttonsRow; + + public Vector2 scrollPosition = Vector2.zero; + + public ImageTextureSelectionWindow(string relativeFolderLocation, SetImage callback, int buttons_row, Vector2 button_size, Vector2 min_window_size, string window_title,bool getSubdirectories = false) + { + previewTextures = new List(); + imageFileList = new List(); + scrollPosition = Vector2.zero; + callbackFunction = callback; + buttonSize = button_size; + buttonsRow = buttons_row; + string[] allFiles = StringUtilities.GetFilesPathFromFolder("Assets/" + relativeFolderLocation, true, "", true, getSubdirectories); + + foreach (string st in allFiles) + { + if (st.EndsWith(".png") || st.EndsWith(".jpg") || st.EndsWith(".jpeg") || st.EndsWith(".psd") || st.EndsWith(".tga")) + { + // GET ALL THE PREVIEW IMAGES FROM THE REALITVE FOLDER LOCATION + imageFileList.Add(st); + //previewTextures.Add(AssetPreview.GetAssetPreview(AssetDatabase.LoadAssetAtPath(st, typeof(Texture2D)))); + previewTextures.Add(AssetPreview.GetMiniThumbnail(AssetDatabase.LoadAssetAtPath(st, typeof(Texture2D)))); + } + + } + ImageTextureSelectionWindow window = (ImageTextureSelectionWindow)EditorWindow.GetWindow(typeof(ImageTextureSelectionWindow), true, window_title); + window.minSize = min_window_size; + window.title = window_title; + } + + // callback function: will call the function send to this window, and return the selected texture + + private void OnGUI() + { + scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); + for (int i = 0; i < previewTextures.Count; i++) + { + if (i % buttonsRow == 0) + EditorGUILayout.BeginHorizontal(); + + if (GUILayout.Button(previewTextures[i], GUILayout.Height(buttonSize.y), GUILayout.Width(buttonSize.x))) + { + Texture2D selectedImage = AssetDatabase.LoadAssetAtPath(imageFileList[i], typeof(Texture2D)) as Texture2D; + callbackFunction(selectedImage); + } + + if (i == previewTextures.Count - 1 || i % buttonsRow == buttonsRow - 1) // IF ITS THE LAST ELEMENT, OR IF IT IS THE LAST IN THE ROW + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndScrollView(); + } + } +} diff --git a/Scripts/Editor/EditorWindowAndMenu/ImageTextureSelectionWindow.cs.meta b/Scripts/Editor/EditorWindowAndMenu/ImageTextureSelectionWindow.cs.meta new file mode 100644 index 0000000..30be3b9 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/ImageTextureSelectionWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 52379a6828cf9d54cb4bf566a4771dbd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/MaterialThumbGenWindow.cs b/Scripts/Editor/EditorWindowAndMenu/MaterialThumbGenWindow.cs new file mode 100644 index 0000000..723c54b --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/MaterialThumbGenWindow.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER +{ + public class MaterialThumbGenWindow : EditorWindow + { + Object targetFolder; + bool getMaterials = false; + bool getPrefabs = false; + bool overwriteExistingThumbs = true; + + + // Add menu item named "My Window" to the Window menu + public static void ShowWindow() + { + EditorWindow.GetWindow(typeof(MaterialThumbGenWindow)); + } + + void OnGUI() + { + GUILayout.Label("Folder Location", EditorStyles.boldLabel); + targetFolder = (Object)EditorGUILayout.ObjectField("Parent folder", targetFolder, (typeof(Object))); + overwriteExistingThumbs = EditorGUILayout.Toggle("Overwrite if exists?", overwriteExistingThumbs); + getMaterials = EditorGUILayout.Toggle("Get Materials", getMaterials); + getPrefabs = EditorGUILayout.Toggle("Get Prefabs", getPrefabs); + if (GUILayout.Button("Create Thumbnails", GUILayout.Height(80f))) + { + + //CreateThumbImages.CreateMaterialThumbnailsFromFolderObject(targetFolder,overwriteExistingThumbs); + if (getMaterials) + { + CreateThumbImages.CreateThumbnailsFromFolderObject(targetFolder, "mat", typeof(Material), overwriteExistingThumbs); + } + if (getPrefabs) + { + CreateThumbImages.CreateThumbnailsFromFolderObject(targetFolder, "prefab", typeof(GameObject), overwriteExistingThumbs); + } + } + } + } +} diff --git a/Scripts/Editor/EditorWindowAndMenu/MaterialThumbGenWindow.cs.meta b/Scripts/Editor/EditorWindowAndMenu/MaterialThumbGenWindow.cs.meta new file mode 100644 index 0000000..2e4ca56 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/MaterialThumbGenWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b7cd9028719e7044096bb37c66148c73 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/PrefabSelectionWindow.cs b/Scripts/Editor/EditorWindowAndMenu/PrefabSelectionWindow.cs new file mode 100644 index 0000000..da12c8a --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/PrefabSelectionWindow.cs @@ -0,0 +1,203 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.Threading; + +namespace WEBGL_EXPORTER +{ + public class PrefabSelectionWindow : EditorWindow + { + public delegate void SetPrefab(GameObject selectedObject); + protected SetPrefab callbackFunction; + + public List previewPrefabs; + public List prefabFileList; + public List prefabName; + + public List filterPrefabFileList; + public List filterPrefabName; + public List filterPreviewPrefabs; + + public List filterOptions; + + public string currentPrefabName; + //public string currentPrefabFile; + public Texture2D currentPreviewPrefab; + public GameObject selectedPrefab; + + public Vector2 buttonSize; + public int buttonsRow; + + public string searchOption = ""; + + public Vector2 scrollPosition = Vector2.zero; + + public static Texture2D GetAssetPreviewTexture(GameObject go) + { + //Debug.Log(go.name); + Texture2D result = AssetPreview.GetAssetPreview(go); + while (result == null) + { + + result = AssetPreview.GetAssetPreview(go); + + Thread.Sleep(5); + } + return AssetPreview.GetAssetPreview(go); ; + + } + public PrefabSelectionWindow(string relativeFolderLocation, SetPrefab callback, int buttons_row, Vector2 button_size, Vector2 min_window_size, string window_title,bool getSubdirectories = false, bool getFromThumbImage = false, string mustStartWith = "") + { + previewPrefabs = new List(); + prefabFileList = new List(); + prefabName = new List(); + + filterOptions = new List(); + + selectedPrefab = null; + + scrollPosition = Vector2.zero; + callbackFunction = callback; + buttonSize = button_size; + buttonsRow = buttons_row; + string[] allFiles = StringUtilities.GetFilesPathFromFolder("Assets/" + relativeFolderLocation, true, "", true, getSubdirectories); + foreach (string st in allFiles) + { + + if (st.EndsWith(".prefab")) + { + if (StringUtilities.GetFileNameFromPath(st).StartsWith(mustStartWith)) // IF THE FILE STARTS WITH THE STRING PROVIDED, ADD IT TO THE LIST + { + // GET ALL THE PREVIEW IMAGES FROM THE REALITVE FOLDER LOCATION + prefabFileList.Add(st); + prefabName.Add(StringUtilities.GetFileNameFromPath(st)); + Texture2D txt; + if (!getFromThumbImage) + { + txt = GetAssetPreviewTexture((GameObject)AssetDatabase.LoadAssetAtPath(st, typeof(GameObject)) as GameObject); + } + else + { + string thumbFile = StringUtilities.RemoveExtensionFromFile(st)+"_thumb.png"; + txt = AssetDatabase.LoadAssetAtPath(thumbFile, typeof(Texture2D)) as Texture2D; + } + previewPrefabs.Add(txt); + + filterPreviewPrefabs = new List(previewPrefabs); + filterPrefabFileList = new List(prefabFileList); + filterPrefabName = new List(prefabName); + } + + } + + } + //while (AssetPreview.IsLoadingAssetPreviews()) { } + + PrefabSelectionWindow window = (PrefabSelectionWindow)EditorWindow.GetWindow(typeof(PrefabSelectionWindow), true, window_title); + window.minSize = min_window_size; + window.title = window_title; + } + public void FilterOption(List searchFilter, string searchOption = "") + { + filterPrefabFileList.Clear(); + filterPreviewPrefabs.Clear(); + filterPrefabName.Clear(); + + string[] splitSearch = searchOption.Split(' '); + for (int i = 0; i < prefabName.Count; i ++) + { + bool add = true; + foreach (string stFilter in searchFilter) // check if prefab name has the name filters + { + + if (!prefabName[i].ToLower().Contains (stFilter.ToLower())) { // if it does not contain at least 1 of the filters in the list, break and dont add it + add = false; + break; + } + } + + + if (add) + { + foreach (string stSearch in splitSearch) + { + if (!prefabName[i].ToLower().Contains(stSearch)) // if prefab name does not contains the searchoption string, dont add it to the list + { + add = false; + } + } + } + + if (add) + { + filterPrefabFileList.Add(prefabFileList[i]); + filterPrefabName.Add(prefabName[i]); + filterPreviewPrefabs.Add(previewPrefabs[i]); + } + } + } + + public virtual void OnGUI() + { + /* GuiLayoutExtras.CenterLabel("Select Room",30); + GuiLayoutExtras.CenterLabel("", 10);*/ + + GuiLayoutExtras.CenterLabel("", 10); + EditorGUILayout.BeginHorizontal(); + + EditorGUI.BeginChangeCheck(); + GUILayout.Label(" Search option:",GUILayout.Height(25f)); + searchOption = EditorGUILayout.TextField(searchOption, GUILayout.Height(25f)); + + if (EditorGUI.EndChangeCheck()) + FilterOption(filterOptions, searchOption); +/* if (GUILayout.Button("Search", GUILayout.Height(25f))) + { + FilterOption(filterOptions,searchOption); + }*/ + EditorGUILayout.EndHorizontal(); + + GuiLayoutExtras.CenterLabel("", 10); + + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button(currentPreviewPrefab, GUILayout.Height(buttonSize.y), GUILayout.Width(buttonSize.x))) + { + + if (selectedPrefab != null) + { + callbackFunction(selectedPrefab); + } + } + GUILayout.Label(currentPrefabName,GUILayout.Height(buttonSize.y), GUILayout.Width(buttonSize.x*2)); + EditorGUILayout.EndHorizontal(); + + GuiLayoutExtras.CenterLabel("", 10); + + scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); + + for (int i = 0; i < filterPreviewPrefabs.Count; i++) + { + if (i % buttonsRow == 0) + EditorGUILayout.BeginHorizontal(); + + EditorGUILayout.BeginVertical(); + if (GUILayout.Button(filterPreviewPrefabs[i], GUILayout.Height(buttonSize.y), GUILayout.Width(buttonSize.x))) + { + selectedPrefab = AssetDatabase.LoadAssetAtPath(filterPrefabFileList[i], typeof(GameObject)) as GameObject; + currentPrefabName = filterPrefabName[i]; + //currentPrefabFile = filterPrefabFileList[i]; + currentPreviewPrefab = filterPreviewPrefabs[i]; + callbackFunction(selectedPrefab); + } + //EditorGUILayout.LabelField(filterPrefabName[i], GUILayout.Width(buttonSize.x), GUILayout.Height(50)); + // GUILayout.LabelField + EditorGUILayout.EndVertical(); + + if (i == filterPreviewPrefabs.Count - 1 || i % buttonsRow == buttonsRow - 1) // IF ITS THE LAST ELEMENT, OR IF IT IS THE LAST IN THE ROW + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndScrollView(); + } + } +} diff --git a/Scripts/Editor/EditorWindowAndMenu/PrefabSelectionWindow.cs.meta b/Scripts/Editor/EditorWindowAndMenu/PrefabSelectionWindow.cs.meta new file mode 100644 index 0000000..30ba3bd --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/PrefabSelectionWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 33da4a1dc64db7e4ead9c4e2787cb230 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/ReadPixelTestWindow.cs b/Scripts/Editor/EditorWindowAndMenu/ReadPixelTestWindow.cs new file mode 100644 index 0000000..d5b55bb --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/ReadPixelTestWindow.cs @@ -0,0 +1,34 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + public class ReadPixelTestWindow:EditorWindow + { + Texture2D tarTextureToRead; + public static void ShowWindow() + { + EditorWindow.GetWindow(typeof(ReadPixelTestWindow)); + } + + private void OnGUI() + { + tarTextureToRead = (Texture2D)EditorGUILayout.ObjectField("Target Texture", tarTextureToRead, (typeof(Object)), false); + if (tarTextureToRead != null) + { + if (GUILayout.Button("ReadTexture", GUILayout.Height(80f))) + { + ReadPixelsFromTexture(tarTextureToRead); + } + } + } + static void ReadPixelsFromTexture(Texture2D tarTexture) + { + + FileExporter.ExportToEXR(tarTexture, "testing_nocompression_4_2048", "L:/Archivos usuario/Documentos_L/Images",Texture2D.EXRFlags.CompressZIP); + + + } + } +} diff --git a/Scripts/Editor/EditorWindowAndMenu/ReadPixelTestWindow.cs.meta b/Scripts/Editor/EditorWindowAndMenu/ReadPixelTestWindow.cs.meta new file mode 100644 index 0000000..540aa3e --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/ReadPixelTestWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 338f9ecea262b1d4f812c1fd9b757afd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject.meta b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject.meta new file mode 100644 index 0000000..d2de336 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2313a96159a549245a2a90ec6927562f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOOptions.cs b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOOptions.cs new file mode 100644 index 0000000..55637bb --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOOptions.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.IO; +using System.Threading; +namespace WEBGL_EXPORTER +{ + public class PrefabSOOptions : ScriptableObject // SO STANDS FOR SCRIPTABLE OBJECT + { + public List previewPrefabs; + public List prefabFileList; + public List prefabName; + + public static void CreatePrefabSOOptions(string relativeFolder,string assetName, bool getSubdirectories) + { + // MAKE SURE IS A VALID RELATIVE FOLDER, MUST START WITH ASSETS/ + string validRelativeFolder = relativeFolder; + if (!validRelativeFolder.StartsWith("Assets/")) + validRelativeFolder = "Assets/" + validRelativeFolder; + + // MAKE SURE DIRECTORY EXISTS, IF NOT, SKIP ALL AND MAKE A WARNING + if (Directory.Exists(StringUtilities.GetFullPathFromLocalPath(validRelativeFolder))) + { + + // CREATE THE SCRIPTABLE OBJECT + PrefabSOOptions asset = ScriptableObject.CreateInstance(); + + // ASSIGN VARIABLE VALUES + asset.previewPrefabs = new List(); + asset.prefabFileList = new List(); + asset.prefabName = new List(); + string[] allFiles = StringUtilities.GetFilesPathFromFolder(validRelativeFolder, true, "", true, getSubdirectories); + foreach (string st in allFiles) + { + + if (st.EndsWith(".prefab")) + { + asset.prefabFileList.Add(st); + asset.prefabName.Add(StringUtilities.GetFileNameFromPath(st)); + + // THUMBNAIL MUST EXISTS ALREADY + string thumbFile = StringUtilities.RemoveExtensionFromFile(st) + "_thumb.png"; + asset.previewPrefabs.Add(AssetDatabase.LoadAssetAtPath(thumbFile, typeof(Texture2D)) as Texture2D); + //asset.previewPrefabs.Add(CreateThumbImages.GetAssetPreviewTexture((GameObject)AssetDatabase.LoadAssetAtPath(st, typeof(GameObject)) as GameObject)); + } + + } + + // FINISH ASSET CREATION + AssetDatabase.CreateAsset(asset, validRelativeFolder + assetName + ".asset"); + AssetDatabase.SaveAssets(); + EditorUtility.FocusProjectWindow(); + Selection.activeObject = asset; + } + else + { + Debug.LogError("directory: " + validRelativeFolder + " could not be found, skipping asset creation"); + } + } + } +} diff --git a/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOOptions.cs.meta b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOOptions.cs.meta new file mode 100644 index 0000000..725cca2 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOOptions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 45abeb86eb2c8b242bb7f6ba3288bf13 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOWindow.cs b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOWindow.cs new file mode 100644 index 0000000..c9de47e --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOWindow.cs @@ -0,0 +1,148 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System; + +namespace WEBGL_EXPORTER +{ + public class PrefabSOWindow : EditorWindow + { + // CALLBACK FUNCTION + public delegate void SetPrefab(GameObject selectedObject); + protected SetPrefab callbackFunction; + + // SCRIPTABLE OBJECT SAVE TEXTURE OPTIONS + public PrefabSOOptions options; + + // DISPLAY WINDOW SETUP + public Vector2 buttonSize; + public Vector2 minWindowSize; + public int buttonsRow; + public Vector2 scrollPosition; + string windowTitle; + string mustStartWith = ""; + + // USER DEFINED ACTIONS ON INTERACTION + public string searchOption; + public List filterListValues; + public List filterOptions; + public int currentPrefabIndex; + public GameObject selectedPrefab; + + + public void UpdateOptions(PrefabSOOptions prefabOptions, SetPrefab callback, Vector2 button_size, Vector2 min_window_size, string window_title, int buttons_row,string must_start_with = "", string existingFilter = "",int currentIndex = 0) + { + options = prefabOptions; + /* if (existingFilterList != null) + filterListValues = existingFilterList; + else + filterListValues = new List();*/ + filterListValues = new List(); + mustStartWith = must_start_with; + currentPrefabIndex = currentIndex; + buttonSize = button_size; + buttonsRow = buttons_row; + callbackFunction = callback; + minWindowSize = min_window_size; + windowTitle = window_title; + searchOption = existingFilter; + } + public void ShowWindow() + { + PrefabSOWindow window = (PrefabSOWindow)EditorWindow.GetWindow(typeof(PrefabSOWindow),true,windowTitle); + if (filterOptions == null) + filterOptions = new List(); + FilterOption(mustStartWith,searchOption); + window.minSize = minWindowSize; + window.title = windowTitle; + + } + private void OnGUI() + { + + + GuiLayoutExtras.CenterLabel("", 10); + EditorGUILayout.BeginHorizontal(); + + EditorGUI.BeginChangeCheck(); + GUILayout.Label(" Search option:", GUILayout.Height(25f)); + searchOption = EditorGUILayout.TextField(searchOption, GUILayout.Height(25f)); + + if (EditorGUI.EndChangeCheck()) + FilterOption(mustStartWith, searchOption); + + EditorGUILayout.EndHorizontal(); + + GuiLayoutExtras.CenterLabel("", 10); + + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button(options.previewPrefabs[currentPrefabIndex], GUILayout.Height(buttonSize.y), GUILayout.Width(buttonSize.x))) + { + callbackFunction(AssetDatabase.LoadAssetAtPath(options.prefabFileList[currentPrefabIndex], typeof(GameObject)) as GameObject); + } + GUILayout.Label(options.prefabName[currentPrefabIndex], GUILayout.Height(buttonSize.y), GUILayout.Width(buttonSize.x * 2)); + EditorGUILayout.EndHorizontal(); + + GuiLayoutExtras.CenterLabel("", 10); + + scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); + + for (int i = 0; i < filterListValues.Count; i++) + { + // START ROW SECTION + if (i % buttonsRow == 0) + EditorGUILayout.BeginHorizontal(); + + // GET THE VALUE OF THE SAVED INDEX IN FILTER LIST VALUES + int index = filterListValues[i]; + + // BUTTONS SECTION + if (GUILayout.Button(options.previewPrefabs[index], GUILayout.Height(buttonSize.y), GUILayout.Width(buttonSize.x))) + { + selectedPrefab = AssetDatabase.LoadAssetAtPath(options.prefabFileList[index], typeof(GameObject)) as GameObject; + Debug.Log(selectedPrefab); + currentPrefabIndex = index; + callbackFunction(selectedPrefab); + + } + + // BREAK ROW SECTION + if (i == filterListValues.Count - 1 || i % buttonsRow == buttonsRow - 1) // IF ITS THE LAST ELEMENT, OR IF IT IS THE LAST IN THE ROW + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndScrollView(); + } + + public void FilterOption(string startWith, string searchOption = "") + { + filterListValues.Clear(); // WE WILL ONLY SAVE THE POSITION OF THE VALUE THAT NEEDS TO BE DISPLAYED + + string[] splitSearch = searchOption.Split(' '); + for (int i = 0; i < options.prefabName.Count; i++) + { + bool add = true; + if (!options.prefabName[i].ToLower().StartsWith(mustStartWith.ToLower())) + add = false; + + + if (add) + { + foreach (string stSearch in splitSearch) + { + if (!options.prefabName[i].ToLower().Contains(stSearch)) // if prefab name does not contains the searchoption string, dont add it to the list + { + add = false; + } + } + } + + if (add) + { + filterListValues.Add(i); // SAVE THE POSITION OF THE FILTERES OBJECTS + } + } + } + + } +} diff --git a/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOWindow.cs.meta b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOWindow.cs.meta new file mode 100644 index 0000000..23502e9 --- /dev/null +++ b/Scripts/Editor/EditorWindowAndMenu/WindowWithScriptableObject/PrefabSOWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 095970021a286024a87f1b770e118b62 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter.meta b/Scripts/Editor/GLTFExporter.meta new file mode 100644 index 0000000..00d5c12 --- /dev/null +++ b/Scripts/Editor/GLTFExporter.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f584c218b168b2a4586fe885e2a2ff72 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/GLTFMenus.meta b/Scripts/Editor/GLTFExporter/GLTFMenus.meta new file mode 100644 index 0000000..c5ccd23 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/GLTFMenus.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6cb32d733c289f647983f04ba57916a9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/GLTFMenus/SO_ExportGLTFOptions_Editor.cs b/Scripts/Editor/GLTFExporter/GLTFMenus/SO_ExportGLTFOptions_Editor.cs new file mode 100644 index 0000000..408beda --- /dev/null +++ b/Scripts/Editor/GLTFExporter/GLTFMenus/SO_ExportGLTFOptions_Editor.cs @@ -0,0 +1,250 @@ +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER.GLTF +{ + [CustomEditor (typeof(SO_ExportGLTFOptions))] + public class SO_ExportGLTFOptions_Editor : Editor + { + private enum SEL_MENU { textures, lightmap, options, quantization, scene } + + private SEL_MENU curMenu = SEL_MENU.options; + SO_ExportGLTFOptions myScript; + + //bool edit = false; + + public void OnEnable() + { + myScript = (SO_ExportGLTFOptions)target; + SetDefaults(); + //edit = false; + } + + public override void OnInspectorGUI() + { + //GUILayout.Label("",GUILayout.Height(10f)); + //EditorGUILayout.BeginHorizontal(); + //{ + // GUILayout.FlexibleSpace(); + // { + // if (GUILayout.Button("Edit Properties", GUILayout.Width(160f), GUILayout.Height(40f))) + // edit = true; + // } + // GUILayout.FlexibleSpace(); + //} + //EditorGUILayout.EndHorizontal(); + //GUILayout.Label("", GUILayout.Height(10f)); + + EditorGUI.BeginChangeCheck(); + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Options", GUILayout.Height(30f), GUILayout.Height(30f))) + curMenu = SEL_MENU.options; + if (GUILayout.Button("Textures", GUILayout.Height(30f), GUILayout.Height(30f))) + curMenu = SEL_MENU.textures; + if (GUILayout.Button("Lightmaps", GUILayout.Height(30f), GUILayout.Height(30f))) + curMenu = SEL_MENU.lightmap; + if (GUILayout.Button("Quantization", GUILayout.Height(30f), GUILayout.Height(30f))) + curMenu = SEL_MENU.quantization; + EditorGUILayout.EndHorizontal(); + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Scene", GUILayout.Height(30f), GUILayout.Height(30f))) + curMenu = SEL_MENU.scene; + EditorGUILayout.EndHorizontal(); + //if (!edit) + // GUI.enabled = false; + switch (curMenu) + { + //==GENERAL OPTIONS==// + case SEL_MENU.options: + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.BeginVertical(); + myScript.exportGameObjectName = EditorGUILayout.Toggle("Export GameObject Names", myScript.exportGameObjectName); + myScript.exportMaterialName = EditorGUILayout.Toggle("Export Material Names", myScript.exportMaterialName); + myScript.exportTexturesName = EditorGUILayout.Toggle("Export Texture Names", myScript.exportTexturesName); + myScript.exportCameras = EditorGUILayout.Toggle("Export Cameras", myScript.exportCameras); + myScript.exportInactive = EditorGUILayout.Toggle("Export Inactive GameObjects", myScript.exportInactive); + myScript.exportGameObjectsTag = EditorGUILayout.Toggle("Export Tag", myScript.exportGameObjectsTag); + myScript.exportGameObjectsLayer = EditorGUILayout.Toggle("Export Layer", myScript.exportGameObjectsLayer); + myScript.exportBatching = EditorGUILayout.Toggle("Export 'batching' flag", myScript.exportBatching); + myScript.exportNavMesh = EditorGUILayout.Toggle("Export navMesh", myScript.exportNavMesh); + EditorGUILayout.EndVertical(); + EditorGUILayout.BeginVertical(); + myScript.blockLeafNodesCreation = EditorGUILayout.Toggle("Block Leaf Nodes", myScript.blockLeafNodesCreation); + myScript.exportSubmeshesInExtra = EditorGUILayout.Toggle("Export Submeshes in extra", myScript.exportSubmeshesInExtra); + myScript.reduceGLTFChars = EditorGUILayout.Toggle("Reduce GLTF Code", myScript.reduceGLTFChars); + myScript.exportNormals = EditorGUILayout.Toggle("Export Mesh Normals", myScript.exportNormals); + + GUI.enabled = false; + myScript.exportLightmapUVs = EditorGUILayout.Toggle("Export Lightmap UVs", myScript.exportLightmapUVs); + myScript.convertToGLB = EditorGUILayout.Toggle("Convert to GLB", myScript.convertToGLB); + myScript.createUVOffsetExtras = EditorGUILayout.Toggle("Save Offset Scale in Extras", myScript.createUVOffsetExtras); + //myScript.exportLightmapUVs = true; + //myScript.convertToGLB = false; + //myScript.createUVOffsetExtras = false; + //if (edit) + GUI.enabled = true; + EditorGUILayout.EndVertical(); + EditorGUILayout.EndHorizontal(); + break; + //==TEXTURES QUALITY==// + case SEL_MENU.textures: + + //myScript.colorTextureSaturation = EditorGUILayout.Slider("Color Texture Saturation", myScript.colorTextureSaturation, 0f, 2f); + myScript.colorTextureSaturation = EditorGUILayout.FloatField("Color Texture Saturation", myScript.colorTextureSaturation); + myScript.metallicMultiplier = EditorGUILayout.Slider("Metallic Max Multiplier", myScript.metallicMultiplier, 0f, 1f); + myScript.smoothnessMultiplier = EditorGUILayout.Slider("Smoothness Max Multiplier", myScript.smoothnessMultiplier, 0f, 1f); + myScript.exportSeparatedAlphaMap = EditorGUILayout.Toggle("Export alfa in extra map", myScript.exportSeparatedAlphaMap); + + EditorGUILayout.LabelField("Quality"); + myScript.allImagesQuality = EditorGUILayout.IntSlider("All Images Quality", myScript.allImagesQuality, 1, 100); + EditorGUILayout.LabelField("Quality Overrides"); + myScript.overrideLightmapQuality = EditorGUILayout.IntSlider("Lightmap Override", myScript.overrideLightmapQuality, 0, 100); + myScript.overrideNormalQuality = EditorGUILayout.IntSlider("Normal Override", myScript.overrideNormalQuality, 0, 100); + myScript.overrideMetallicSmoothnessQuality = EditorGUILayout.IntSlider("Metallic Smoothness Override", myScript.overrideMetallicSmoothnessQuality, 0, 100); + myScript.overrideCubemapQuality = EditorGUILayout.IntSlider("Cubemap Override", myScript.overrideCubemapQuality, 0, 100); + myScript.overrideDefaultQuality = EditorGUILayout.IntSlider("Default Override", myScript.overrideDefaultQuality, 0, 100); + + EditorGUILayout.LabelField("Divide Factor"); + myScript.allImagesDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Divide Texture Size: ", myScript.allImagesDivideFactor); + if (myScript.allImagesDivideFactor == TextureDivideFactor.NONE_SET) + myScript.allImagesDivideFactor = TextureDivideFactor.FULL; + EditorGUILayout.LabelField("Divide Factor Overrides"); + myScript.overrideLightmapDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Lightmap Override: ", myScript.overrideLightmapDivideFactor); + myScript.overrideNormalDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Normal Override: ", myScript.overrideNormalDivideFactor); + myScript.overrideMetallicSmoothnessDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Metallic Smoothness Override: ", myScript.overrideMetallicSmoothnessDivideFactor); + myScript.overrideCubemapDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Cubemap Override: ", myScript.overrideCubemapDivideFactor); + myScript.overrideDefaultDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Default Override ", myScript.overrideDefaultDivideFactor); + + EditorGUILayout.LabelField("Export type of texture"); + myScript.exportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Export Texture Type: ", myScript.exportTextureType); + if (myScript.exportTextureType == TextureExportType.NONE_SET) + myScript.exportTextureType = TextureExportType.DEFAULT; + + if (myScript.exportTextureType == TextureExportType.DEFAULT) + GUI.enabled = false; + myScript.fallbackGLTFTexture = EditorGUILayout.Toggle("Fallback to jpeg", myScript.fallbackGLTFTexture); + EditorGUILayout.LabelField("Export Overrides: (suggested DEFAULT in lightmap)"); + myScript.overrideNormalExportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Normal Type: ", myScript.overrideNormalExportTextureType); + myScript.overrideDefaultExportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Default Type: ", myScript.overrideDefaultExportTextureType); + myScript.overrideMetallicSmoothnessExportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Smnoothness Type: ", myScript.overrideMetallicSmoothnessExportTextureType); + myScript.overrideLightmapExportTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Lightmap Type: ", myScript.overrideLightmapExportTextureType); + myScript.overrideCubemapTextureType = (TextureExportType)EditorGUILayout.EnumPopup("Cubemap Type: ", myScript.overrideCubemapTextureType); + //if (edit) + GUI.enabled = true; + break; + //==LIGHTMAPS==// + case SEL_MENU.lightmap: + myScript.maxLightmapClamp = EditorGUILayout.FloatField("Max Clamp", myScript.maxLightmapClamp); + myScript.saturationLightmap = EditorGUILayout.FloatField("Saturation Compensation", myScript.saturationLightmap); + myScript.lightmapIntensityMultiplier = EditorGUILayout.FloatField("Intensity Multiplier*", myScript.lightmapIntensityMultiplier); + myScript.lightmapContrastCheat = EditorGUILayout.FloatField("lightmap Contrast Cheat*", myScript.lightmapContrastCheat); + myScript.whiteImageForNonStaticLightmaps = EditorGUILayout.Toggle("White Image on non static", myScript.whiteImageForNonStaticLightmaps); + break; + + + //==QUANTIZATION==// + case SEL_MENU.quantization: + if (myScript.blockLeafNodesCreation == true) { + GUI.enabled = false; + GUILayout.Label("\"Block Leaf Nodes Creation\" is set to true"); + GUILayout.Label("Quantization will always be false"); + } + + myScript.quantizeGLTF = EditorGUILayout.Toggle("Quantize values", myScript.quantizeGLTF); + if (!myScript.quantizeGLTF) + GUI.enabled = false; + myScript.quantizeMainUVsTo = (ComponentTypeSelected)EditorGUILayout.EnumPopup("Main UVs: ", myScript.quantizeMainUVsTo); + myScript.quantizeLightUVsTo = (ComponentTypeSelected)EditorGUILayout.EnumPopup("Lightmap UVs: ", myScript.quantizeLightUVsTo); + myScript.quantizeVerticesTo = (ComponentTypeSelected)EditorGUILayout.EnumPopup("Vertices: ", myScript.quantizeVerticesTo); + myScript.quantizeNormalsTo = (ComponentTypeSelected)EditorGUILayout.EnumPopup("Normals: ", myScript.quantizeNormalsTo); + //if (edit) + GUI.enabled = true; + break; + case SEL_MENU.scene: + myScript.exportSceneSkyboxEnvironment = EditorGUILayout.Toggle("Export Skybox Environment", myScript.exportSceneSkyboxEnvironment); + myScript.exportSceneSkyboxBackground = EditorGUILayout.Toggle("Export Skybox Background", myScript.exportSceneSkyboxBackground); + myScript.exportSceneSkyboxBackgroundEvenDefault = EditorGUILayout.Toggle("Consider Default Skybox", myScript.exportSceneSkyboxBackgroundEvenDefault); + myScript.createCubeForSkybox = EditorGUILayout.Toggle("Create Cubemap Mesh", myScript.createCubeForSkybox); + myScript.exportSceneFog = EditorGUILayout.Toggle("Export Fog if active", myScript.exportSceneFog); + break; + } + + if (EditorGUI.EndChangeCheck()) + { + EditorUtility.SetDirty(myScript); + Debug.Log("changed"); + } + + ////ANIMATIONS + //public bool exportAnimations = true; + + ////MESH OPTIONS + //public bool reduceGLTFChars; + //public bool exportNormals; + //public bool exportLightmapUVs; // NOT WORKING YET, RIGHT NOW IT WILL ALWAYS EXPORT LIGHTMAP UVS + //public bool convertToGLB; // NOT WORKING YET. + //public bool createUVOffsetExtras; // NOT WORKING YET: IF SET TO TRUE, FINAL SIZE WILL BE REDUCED, UVS WILL BE SAVED ONCE, AND OFFSET/SCALE WILL BE SAVED IN GLTF "EXTRAS" CODE FOR THREE JS GLTF IMPORTER TO USE + //public bool exportSubmeshesInExtra; // SUBMESHES ARE EXPORTED SEPARATED IN CLASSIC GLTF, SHOULD BE EXPORTED COMBINED AND SAVE GROUPED POSITIONS + + ////TEXTURES QUALITY + //public float colorTextureSaturation; + //public bool exportSeparatedAlphaMap; + //public TextureExportType exportTextureType; + //public bool fallbackGLTFTexture; // NEW 7/22/2021 + //public int allImagesQuality; + //public int overrideLightmapQuality; // SET 0 TO NOT OVERRIDE + //public int overrideNormalQuality; + //public int overrideMetallicSmoothnessQuality; + //public int overrideCubemapQuality; + //public int overrideDefaultQuality; + //public TextureExportType overrideLightmapExportTextureType = TextureExportType.DEFAULT; + //public TextureExportType overrideNormalExportTextureType = TextureExportType.NONE_SET; + //public TextureExportType overrideMetallicSmoothnessExportTextureType = TextureExportType.NONE_SET; + //public TextureExportType overrideDefaultExportTextureType = TextureExportType.NONE_SET; + //public TextureExportType overrideCubemapTextureType = TextureExportType.NONE_SET; + + ////LIGHTMAP OPTIONS + //public float maxLightmapClamp; + //public float saturationLightmap; + //public bool whiteImageForNonStaticLightmaps; + //public float lightmapIntensityMultiplier; + //public float lightmapContrastCheat; + + ////QUANTIZATION + //public bool quantizeGLTF; + //public ComponentTypeSelected quantizeMainUVsTo; + //public ComponentTypeSelected quantizeLightUVsTo; + //public ComponentTypeSelected quantizeVerticesTo; + //public ComponentTypeSelected quantizeNormalsTo; + + //// SCENE + //public bool exportSceneSkyboxEnvironment; + //public bool exportSceneSkyboxBackground; + //public bool createCubeForSkybox = true; // + //public GameObject cubeSkybox = null; + //public int cubeSkyboxScale = 1; //1 = 1000 + //public bool exportSceneSkyboxBackgroundEvenDefault; + //public bool exportSceneFog; + //public Cubemap computedEnvironmentCubemap; + //public Cubemap computedBackgroundCubemap; + + //public int overrideEnvironmentQuality = 0; + + ////SET MAIN CAMERA + //public bool extraExportMainCameraInGLTF = false; + //public int extraCameraIndex = -1; + EditorUtility.SetDirty(myScript); + + } + + private void SetDefaults() + { + Debug.Log(myScript.overrideLightmapDivideFactor); + //myScript.overrideLightmapDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Lightmap Override: ", myScript.overrideLightmapDivideFactor); + //myScript.overrideNormalDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Normal Override: ", myScript.overrideNormalDivideFactor); + //myScript.overrideMetallicSmoothnessDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Metallic Smoothness Override: ", myScript.overrideMetallicSmoothnessDivideFactor); + //myScript.overrideCubemapDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Cubemap Override: ", myScript.overrideCubemapDivideFactor); + //myScript.overrideDefaultDivideFactor = (TextureDivideFactor)EditorGUILayout.EnumPopup("Default Override ", myScript.overrideDefaultDivideFactor); + } + } +} diff --git a/Scripts/Editor/GLTFExporter/GLTFMenus/SO_ExportGLTFOptions_Editor.cs.meta b/Scripts/Editor/GLTFExporter/GLTFMenus/SO_ExportGLTFOptions_Editor.cs.meta new file mode 100644 index 0000000..a483a6a --- /dev/null +++ b/Scripts/Editor/GLTFExporter/GLTFMenus/SO_ExportGLTFOptions_Editor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dc624689ddecb764a8e60e5962583910 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/Mono_ExportToGLTF_Editor.cs b/Scripts/Editor/GLTFExporter/Mono_ExportToGLTF_Editor.cs new file mode 100644 index 0000000..cd16009 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/Mono_ExportToGLTF_Editor.cs @@ -0,0 +1,122 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System; + + +namespace WEBGL_EXPORTER.GLTF +{ + [CustomEditor(typeof(Mono_ExportToGLTF),true)] + public class Mono_ExportToGLTF_Editor : Editor + { + Mono_ExportToGLTF myScript; + string idValueTemp = ""; + + private void OnEnable() + { + myScript = (Mono_ExportToGLTF)target; + } + public override void OnInspectorGUI() + { + myScript.gltfCustomOptions = (SO_ExportGLTFOptions)EditorGUILayout.ObjectField("GLTF Custom Options: ", myScript.gltfCustomOptions, typeof(SO_ExportGLTFOptions), true); + if (myScript.gltfCustomOptions == null) + { + //EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Edit Options", GUILayout.Height(50f))) + { + ExportGLTFOptionsWindow gltfOptionsWindow = ExportGLTFOptionsWindow.CreateInstance(); + } + } + myScript.targetParent = (Transform)EditorGUILayout.ObjectField("Target Parent: ", myScript.targetParent, typeof(Transform),true); + myScript.startPosition = (Transform)EditorGUILayout.ObjectField("Start Position: ", myScript.startPosition, typeof(Transform),true); + myScript.optionalEnvironmentReflections = (ReflectionProbe)EditorGUILayout.ObjectField("reflection probe: ", myScript.optionalEnvironmentReflections, typeof (ReflectionProbe),true); + myScript.gltfName = EditorGUILayout.TextField("gltf name: ", myScript.gltfName); + //myScript.exportForNFT = EditorGUILayout.Toggle("NFT Export", myScript.exportForNFT); + + + EditorGUI.BeginChangeCheck(); + if (idValueTemp != "") + { + myScript.modelId = idValueTemp; + idValueTemp = ""; + } + + myScript.modelId = EditorGUILayout.TextField("model create folder: ", myScript.modelId); + myScript.exportLocation = EditorGUILayout.TextField("export location: ", myScript.exportLocation); + myScript.curBuild = EditorGUILayout.IntField("Current Build: ", myScript.curBuild); + + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Export GLTF TestBuild", GUILayout.Height(50f))) + { + if (myScript.modelId == "") + { + AskUserInputWindow inputWindow = AskUserInputWindow.CreateInstance("Name Required", "ID name", ValidateCallExport, "Cancel", "Save"); + } + else + { + if (myScript.exportLocation == "") + { + myScript.exportLocation = EditorUtility.SaveFolderPanel( + "Save To", + "", + ""); + if (myScript.exportLocation != "") + { + ExportGLTFModel(true); + } + } + else + { + ExportGLTFModel(true); + } + } + + } + if (GUILayout.Button("Export GLTF Final", GUILayout.Height(50f))) + { + if (myScript.exportLocation == "") + { + myScript.exportLocation = EditorUtility.SaveFolderPanel( + "Save To", + "", + ""); + if (myScript.exportLocation != "") + { + ExportGLTFModel(false); + } + } + else + { + ExportGLTFModel(false); + } + + } + EditorGUILayout.EndHorizontal(); + //base.OnInspectorGUI(); + } + private void ValidateCallExport(string value) + { + if (value != "") + { + idValueTemp = value; + } + + } + + private void ExportGLTFModel(bool test_build) + { + + if (FileExporter.DirectoryExists(myScript.exportLocation)) + { + myScript.ExportGLTF(myScript.exportLocation,test_build); + Debug.Log("Exported to: " + myScript.exportLocation); + } + else + { + Debug.LogWarning("export location does not exists"); + myScript.exportLocation = ""; + } + } + } +} diff --git a/Scripts/Editor/GLTFExporter/Mono_ExportToGLTF_Editor.cs.meta b/Scripts/Editor/GLTFExporter/Mono_ExportToGLTF_Editor.cs.meta new file mode 100644 index 0000000..2fed200 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/Mono_ExportToGLTF_Editor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 86415d5fd3d14924493355c6e353e7f3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/NodeExtras.meta b/Scripts/Editor/GLTFExporter/NodeExtras.meta new file mode 100644 index 0000000..86bf2b3 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/NodeExtras.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5e82da2fd472ad14a826e6254867d106 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/NodeExtras/ObjectNodeMirror_Editor.cs b/Scripts/Editor/GLTFExporter/NodeExtras/ObjectNodeMirror_Editor.cs new file mode 100644 index 0000000..f2d57b7 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/NodeExtras/ObjectNodeMirror_Editor.cs @@ -0,0 +1,51 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER.GLTF +{ + [CustomEditor(typeof(ObjectNodeMirror),true)] + public class ObjectNodeMirror_Editor : Editor + { + ObjectNodeMirror myScript; + private void OnEnable() + { + myScript = (ObjectNodeMirror)target; + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + if (myScript.tooltip != "") + { + GUILayout.Box(myScript.tooltip, GUILayout.Width(GuiLayoutExtras.GetCenteredLabelWidth(50f))); + } + if (myScript.mirrorReflectionProbe == null) + { + if (GUILayout.Button("Create Reflection Probe", GUILayout.Height(50f))) + { + myScript.mirrorReflectionProbe = CreateReflectionProbe(myScript.transform); + Selection.activeGameObject = myScript.mirrorReflectionProbe.gameObject; + } + } + } + + private ReflectionProbe CreateReflectionProbe(Transform parent) + { + GameObject refProbeObject = new GameObject(); + refProbeObject.transform.parent = parent; + refProbeObject.transform.localPosition = Vector3.zero; + refProbeObject.transform.localScale = Vector3.one; + + ReflectionProbe refProbe = refProbeObject.AddComponent(); + refProbe.hdr = false; + refProbe.resolution = 512; + refProbe.transform.parent = parent; + + return refProbe; + + } + } + + +} diff --git a/Scripts/Editor/GLTFExporter/NodeExtras/ObjectNodeMirror_Editor.cs.meta b/Scripts/Editor/GLTFExporter/NodeExtras/ObjectNodeMirror_Editor.cs.meta new file mode 100644 index 0000000..1d70d7b --- /dev/null +++ b/Scripts/Editor/GLTFExporter/NodeExtras/ObjectNodeMirror_Editor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 961eba4901be7ea4083ae94d6a759dac +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/ObjectMasterUserExtrasMono_Editor.cs b/Scripts/Editor/GLTFExporter/ObjectMasterUserExtrasMono_Editor.cs new file mode 100644 index 0000000..764a9a5 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/ObjectMasterUserExtrasMono_Editor.cs @@ -0,0 +1,239 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER.GLTF +{ + [CustomEditor(typeof(ObjectMasterUserExtrasMono))] + public class ObjectMasterUserExtrasMono_Editor : Editor + { + ObjectMasterUserExtrasMono myScript; + MonoScript script; + + bool boolVal; + int intVal; + float floatVal; + Color colorVal; + Vector2 vector2Val; + Vector3 vector3Val; + string stringVal; + GameObject gameObjectVal; + + SerializedProperty floatArr; + SerializedProperty intArr; + SerializedProperty stringArr; + + + string propName; + + public enum property { NONE, BOOL, INT, FLOAT, FLOAT_TO_RAD, STRING, COLOR, VECTOR2, VECTOR3, STRING_ARRAY, INT_ARRAY, FLOAT_ARRAY, GAMEOBJECT, GAMEOBJECT_ARRAY } + property selectedProperty; + private void OnEnable() + { + myScript = (ObjectMasterUserExtrasMono)target; + script = MonoScript.FromMonoBehaviour(myScript); + selectedProperty = property.NONE; + + myScript.floatArrayVal = new float[0]; + myScript.intArrayVal = new int[0]; + myScript.stringArrayVal = new string[0]; + myScript.gameObjectArrayVal = new GameObject[0]; + + + } + public override void OnInspectorGUI() + { + EditorGUILayout.ObjectField("Script: ", script, typeof(MonoScript), false); + + serializedObject.Update(); + SerializedProperty floatArr = serializedObject.FindProperty("floatArrayVal"); + SerializedProperty intArr = serializedObject.FindProperty("intArrayVal"); + SerializedProperty stringArr = serializedObject.FindProperty("stringArrayVal"); + SerializedProperty gameObjectArr = serializedObject.FindProperty("gameObjectArrayVal"); + + EditorGUI.BeginChangeCheck(); + + selectedProperty = (property)EditorGUILayout.EnumPopup(selectedProperty, GUILayout.Height(20f)); + if (selectedProperty != property.NONE) + propName = EditorGUILayout.TextField("Property Name", propName); + + + switch (selectedProperty) + { + case property.BOOL: + boolVal = EditorGUILayout.Toggle("bool", boolVal); + break; + case property.INT: + intVal = EditorGUILayout.IntField("int", intVal); + break; + case property.FLOAT: + floatVal = EditorGUILayout.FloatField("float", floatVal); + break; + case property.FLOAT_TO_RAD: + floatVal = EditorGUILayout.FloatField("float to rad", floatVal); + break; + case property.STRING: + stringVal = EditorGUILayout.TextField("string", stringVal); + break; + case property.VECTOR2: + vector2Val = EditorGUILayout.Vector2Field("vector2", vector2Val); + break; + case property.VECTOR3: + vector3Val = EditorGUILayout.Vector3Field("vector3", vector3Val); + break; + case property.COLOR: + colorVal = EditorGUILayout.ColorField("color", colorVal); + break; + case property.STRING_ARRAY: + EditorGUILayout.PropertyField(stringArr, true); + break; + case property.FLOAT_ARRAY: + EditorGUILayout.PropertyField(floatArr, true); + break; + case property.INT_ARRAY: + EditorGUILayout.PropertyField(intArr, true); + break; + case property.GAMEOBJECT: + gameObjectVal = (GameObject)EditorGUILayout.ObjectField("Game Object", gameObjectVal, typeof(GameObject), true); + break; + case property.GAMEOBJECT_ARRAY: + EditorGUILayout.PropertyField(gameObjectArr, true); + break; + // ARRAY CASES + } + if (EditorGUI.EndChangeCheck()) + serializedObject.ApplyModifiedProperties(); + + if (propName != "" && selectedProperty != property.NONE) + { + if (GUILayout.Button("Add", GUILayout.Height(20f))) + { + bool reset_values = true; + Undo.RecordObject(myScript, "Add Property"); + switch (selectedProperty) + { + case property.BOOL: + myScript.AddProperty(new ObjectProperty(propName, boolVal)); + boolVal = false; + break; + case property.INT: + myScript.AddProperty(new ObjectProperty(propName, intVal)); + intVal = 0; + break; + case property.FLOAT: + myScript.AddProperty(new ObjectProperty(propName, floatVal)); + floatVal = 0; + break; + case property.FLOAT_TO_RAD: + myScript.AddProperty(new ObjectProperty(propName, floatVal * (Mathf.PI / 180))); + floatVal = 0; + break; + case property.STRING: + myScript.AddProperty(new ObjectProperty(propName, stringVal)); + stringVal = ""; + break; + case property.VECTOR2: + myScript.AddProperty(new ObjectProperty(propName, vector2Val)); + vector2Val = Vector2.zero; + break; + case property.VECTOR3: + myScript.AddProperty(new ObjectProperty(propName, vector3Val)); + vector3Val = Vector3.zero; + break; + case property.COLOR: + myScript.AddProperty(new ObjectProperty(propName, colorVal)); + break; + case property.GAMEOBJECT: + myScript.AddProperty(new ObjectProperty(propName, gameObjectVal)); + break; + case property.STRING_ARRAY: + if (myScript.stringArrayVal.Length == 0) + { + Debug.LogWarning("ADD AT LEAST 1 STRING VALUE"); + reset_values = false; + } + else + myScript.AddProperty(new ObjectProperty(propName, myScript.stringArrayVal)); + break; + case property.FLOAT_ARRAY: + if (myScript.floatArrayVal.Length == 0) + { + Debug.LogWarning("ADD AT LEAST 1 FLOAT VALUE"); + reset_values = false; + } + else + myScript.AddProperty(new ObjectProperty(propName, myScript.floatArrayVal)); + break; + case property.INT_ARRAY: + if (myScript.intArrayVal.Length == 0) + { + Debug.LogWarning("ADD AT LEAST 1 INT VALUE"); + reset_values = false; + } + else + myScript.AddProperty(new ObjectProperty(propName, myScript.intArrayVal)); + break; + case property.GAMEOBJECT_ARRAY: + if (myScript.gameObjectArrayVal.Length == 0) + { + Debug.LogWarning("ADD AT LEAST 1 INT VALUE"); + reset_values = false; + } + else + myScript.AddProperty(new ObjectProperty(propName, myScript.gameObjectArrayVal)); + break; + } + if (reset_values) + { + propName = ""; + myScript.intArrayVal = new int[0]; + myScript.floatArrayVal = new float[0]; + myScript.stringArrayVal = new string[0]; + } + } + } + else + { + GUILayout.Label("", GUILayout.Height(20f)); ; + } + // == show values here == // + + if (myScript.properties != null) + { + for (int i = 0; i < myScript.properties.Count; i++) + { + EditorGUILayout.BeginHorizontal(); + GUILayout.Label(myScript.properties[i].propertyType.ToString(), GUILayout.Width(80f)); + string label = myScript.properties[i].GetPropertyGLTF(); + if (myScript.properties[i].propertyType == ObjectProperty.PropertyType.GameObject) + if (myScript.properties[i].propertyGameObject != null) + label += " (" + myScript.properties[i].propertyGameObject.name + ")"; + if (myScript.properties[i].propertyType == ObjectProperty.PropertyType.GameObjectArray) + { + if (myScript.properties[i].propertyGameObjectArray != null) + { + label += " ("; + foreach (GameObject go in myScript.properties[i].propertyGameObjectArray) + { + if (go != null) + { + label += go.name + ","; + } + } + label = StringUtilities.RemoveCharacterFromString(label, 1, false); + label += ")"; + } + } + GUILayout.Label(label,GUILayout.MaxWidth(300f)); + if (GUILayout.Button("X", GUILayout.Width(40f))) + { + Undo.RecordObject(myScript, "Remove Property"); + myScript.properties.RemoveAt(i); + } + EditorGUILayout.EndHorizontal(); + } + } + } + } +} diff --git a/Scripts/Editor/GLTFExporter/ObjectMasterUserExtrasMono_Editor.cs.meta b/Scripts/Editor/GLTFExporter/ObjectMasterUserExtrasMono_Editor.cs.meta new file mode 100644 index 0000000..88994dc --- /dev/null +++ b/Scripts/Editor/GLTFExporter/ObjectMasterUserExtrasMono_Editor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cd96e3993769f484c949a8b93f3e5d94 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/ObjectNodeUserExtrasMono_Editor.cs b/Scripts/Editor/GLTFExporter/ObjectNodeUserExtrasMono_Editor.cs new file mode 100644 index 0000000..06a8845 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/ObjectNodeUserExtrasMono_Editor.cs @@ -0,0 +1,403 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER.GLTF +{ + [CustomEditor (typeof(ObjectNodeUserExtrasMono),true)] + public class ObjectNodeUserExtrasMono_Editor : Editor + { + ObjectNodeUserExtrasMono myScript; + MonoScript script; + + bool boolVal; + int intVal; + float floatVal; + Color colorVal; + Vector2 vector2Val; + Vector3 vector3Val; + string stringVal; + GameObject gameObjectVal; + + bool convertedToRad = false; + + ObjectProperty editingProperty; + int editPropertyIndex; + + string propName; + + + public enum property {NONE, BOOL, INT, FLOAT, STRING, COLOR, VECTOR2, VECTOR3, STRING_ARRAY, INT_ARRAY, FLOAT_ARRAY ,GAMEOBJECT, GAMEOBJECT_ARRAY } + property selectedProperty; + private void OnEnable() + { + myScript = (ObjectNodeUserExtrasMono)target; + script = MonoScript.FromMonoBehaviour(myScript); + selectedProperty = property.NONE; + + myScript.floatArrayVal = new float[0]; + myScript.intArrayVal = new int[0]; + myScript.stringArrayVal = new string[0]; + myScript.gameObjectArrayVal = new GameObject[0]; + } + private void OnDisable() + { + if (editingProperty != null) + { + if (editingProperty.propertyType != ObjectProperty.PropertyType.EmptyHolder) + { + myScript.userProperties.Insert(editPropertyIndex, editingProperty); + editingProperty = null; + editPropertyIndex = -1; + } + } + } + public override void OnInspectorGUI() + { + + base.OnInspectorGUI(); + if (myScript.tooltip != "") + { + GUILayout.Box(myScript.tooltip,GUILayout.Width(GuiLayoutExtras.GetCenteredLabelWidth(50f))); + } + if (myScript.displayOptions) + { + //EditorGUILayout.ObjectField("Script: ", script, typeof(MonoScript), false); + serializedObject.Update(); + SerializedProperty gameObjectArr = serializedObject.FindProperty("gameObjectArrVal"); + SerializedProperty floatArr = serializedObject.FindProperty("floatArrayVal"); + SerializedProperty intArr = serializedObject.FindProperty("intArrayVal"); + SerializedProperty stringArr = serializedObject.FindProperty("stringArrayVal"); + + + EditorGUI.BeginChangeCheck(); + string _extrasName = myScript.extrasName; + _extrasName = EditorGUILayout.TextField("Extras Name", myScript.extrasName); + + if (_extrasName != "") + { + selectedProperty = (property)EditorGUILayout.EnumPopup(selectedProperty, GUILayout.Height(20f)); + if (selectedProperty != property.NONE) + propName = EditorGUILayout.TextField("Property Name", propName); + + + switch (selectedProperty) + { + case property.BOOL: + boolVal = EditorGUILayout.Toggle("bool", boolVal); + break; + case property.INT: + intVal = EditorGUILayout.IntField("int", intVal); + break; + case property.FLOAT: + floatVal = EditorGUILayout.FloatField("float", floatVal); + break; + //case property.FLOAT_TO_RAD: + // floatVal = EditorGUILayout.FloatField("float to rad", floatVal); + // break; + case property.STRING: + stringVal = EditorGUILayout.TextField("string", stringVal); + break; + case property.VECTOR2: + vector2Val = EditorGUILayout.Vector2Field("vector2", vector2Val); + break; + case property.VECTOR3: + vector3Val = EditorGUILayout.Vector3Field("vector3", vector3Val); + break; + case property.COLOR: + colorVal = EditorGUILayout.ColorField("color", colorVal); + break; + case property.INT_ARRAY: + EditorGUILayout.PropertyField(intArr, true); + break; + case property.STRING_ARRAY: + EditorGUILayout.PropertyField(stringArr, true); + break; + case property.FLOAT_ARRAY: + EditorGUILayout.PropertyField(floatArr, true); + break; + case property.GAMEOBJECT: + gameObjectVal = (GameObject)EditorGUILayout.ObjectField("Game Object", gameObjectVal, typeof(GameObject), true); + break; + case property.GAMEOBJECT_ARRAY: + EditorGUILayout.PropertyField(gameObjectArr, true); + break; + } + + if (propName != "" && selectedProperty != property.NONE && propName != null) + { + if (selectedProperty == property.FLOAT || selectedProperty == property.VECTOR2 || selectedProperty == property.VECTOR3) + { + + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Degree to Rad", GUILayout.Height(20f))) + { + EditorGUI.FocusTextInControl(null); + Undo.RecordObject(myScript, "Degree to Rad"); + switch (selectedProperty) + { + case property.FLOAT: + floatVal = floatVal * (Mathf.PI / 180); + break; + case property.VECTOR2: + vector2Val = vector2Val * (Mathf.PI / 180); + break; + case property.VECTOR3: + vector3Val = vector3Val * (Mathf.PI / 180); + break; + } + } + if (GUILayout.Button("Rad to Degree", GUILayout.Height(20f))) + { + EditorGUI.FocusTextInControl(null); + Undo.RecordObject(myScript, "Rad to Degree"); + switch (selectedProperty) + { + case property.FLOAT: + floatVal = floatVal * (180 / Mathf.PI); + break; + case property.VECTOR2: + vector2Val = vector2Val * (180 / Mathf.PI); + break; + case property.VECTOR3: + vector3Val = vector3Val * (180 / Mathf.PI); + break; + } + + } + EditorGUILayout.EndHorizontal(); + } + //EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Add", GUILayout.Height(20f))) + { + EditorGUI.FocusTextInControl(null); + bool reset_values = true; + Undo.RecordObject(myScript, "Add Property"); + switch (selectedProperty) + { + case property.BOOL: + myScript.AddProperty(new ObjectProperty(propName, boolVal),false, editPropertyIndex); + boolVal = false; + break; + case property.INT: + myScript.AddProperty(new ObjectProperty(propName, intVal), false, editPropertyIndex); + intVal = 0; + break; + case property.FLOAT: + myScript.AddProperty(new ObjectProperty(propName, floatVal), false, editPropertyIndex); + floatVal = 0; + break; + //case property.FLOAT_TO_RAD: + // myScript.AddProperty(new ObjectProperty(propName, floatVal * (Mathf.PI / 180)), false, editPropertyIndex); + // floatVal = 0; + // break; + case property.STRING: + myScript.AddProperty(new ObjectProperty(propName, stringVal), false, editPropertyIndex); + stringVal = ""; + break; + case property.VECTOR2: + myScript.AddProperty(new ObjectProperty(propName, vector2Val), false, editPropertyIndex); + vector2Val = Vector2.zero; + break; + case property.VECTOR3: + myScript.AddProperty(new ObjectProperty(propName, vector3Val), false, editPropertyIndex); + vector3Val = Vector3.zero; + break; + case property.COLOR: + myScript.AddProperty(new ObjectProperty(propName, colorVal), false, editPropertyIndex); + break; + case property.GAMEOBJECT: + myScript.AddProperty(new ObjectProperty(propName, gameObjectVal), false, editPropertyIndex); + break; + case property.GAMEOBJECT_ARRAY: + if (myScript.gameObjectArrayVal.Length == 0) + { + Debug.LogWarning("ADD AT LEAST 1 GAMEOBJECT VALUE"); + reset_values = false; + break; + } + myScript.AddProperty(new ObjectProperty(propName, myScript.gameObjectArrayVal), false, editPropertyIndex); + break; + case property.INT_ARRAY: + if (myScript.intArrayVal.Length == 0) + { + Debug.LogWarning("ADD AT LEAST 1 INT VALUE"); + reset_values = false; + break; + } + myScript.AddProperty(new ObjectProperty(propName, myScript.intArrayVal), false, editPropertyIndex); + break; + case property.FLOAT_ARRAY: + if (myScript.floatArrayVal.Length == 0) + { + Debug.LogWarning("ADD AT LEAST 1 FLOAT VALUE"); + reset_values = false; + break; + } + myScript.AddProperty(new ObjectProperty(propName, myScript.floatArrayVal), false, editPropertyIndex); + break; + case property.STRING_ARRAY: + if (myScript.stringArrayVal.Length == 0) + { + Debug.LogWarning("ADD AT LEAST 1 STRING VALUE"); + reset_values = false; + break; + } + myScript.AddProperty(new ObjectProperty(propName, myScript.stringArrayVal), false, editPropertyIndex); + break; + } + editPropertyIndex = -1; + editingProperty = null; + if (reset_values) + propName = ""; + } + + } + else + { + GUILayout.Label("", GUILayout.Height(20f)); ; + } + // == show values here == // + + if (myScript.userProperties != null) + { + for (int i = 0; i < myScript.userProperties.Count; i++) + { + EditorGUILayout.BeginHorizontal(); + GUILayout.Label(myScript.userProperties[i].propertyType.ToString(), GUILayout.Width(80f)); + string label = myScript.userProperties[i].GetPropertyGLTF(); + if (myScript.userProperties[i].propertyType == ObjectProperty.PropertyType.GameObject) + if (myScript.userProperties[i].propertyGameObject != null) + label += " (" + myScript.userProperties[i].propertyGameObject.name + ")"; + if (myScript.userProperties[i].propertyType == ObjectProperty.PropertyType.GameObjectArray) + { + if (myScript.userProperties[i].propertyGameObjectArray != null) + { + label += " ("; + foreach (GameObject go in myScript.userProperties[i].propertyGameObjectArray) + { + if (go != null) + { + label += go.name + ","; + } + } + //te + Debug.Log(label); + if (label.EndsWith(",")) + label = StringUtilities.RemoveCharacterFromString(label, 1, false); + label += ")"; + } + } + GUILayout.Label(label, GUILayout.MaxWidth(300f)); + if (GUILayout.Button("E", GUILayout.Width(20f))) + { + //Undo.RegisterCompleteObjectUndo(myScript, "Edit Property"); + //Undo.RecordObject(myScript, "Edit Property"); + editingProperty = myScript.userProperties[i]; + editPropertyIndex = i; + selectedProperty = GetPropertyType(myScript.userProperties[i].propertyType); + SetPropertyValue(editingProperty); + propName = myScript.userProperties[i].propertyName; + myScript.userProperties.RemoveAt(i); + } + if (GUILayout.Button("X", GUILayout.Width(20f))) + { + Undo.RecordObject(myScript, "Remove Property"); + myScript.userProperties.RemoveAt(i); + } + EditorGUILayout.EndHorizontal(); + } + } + + } + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(myScript, "Assign Extras Values"); + serializedObject.ApplyModifiedProperties(); + myScript.extrasName = _extrasName; + } + } + } + private void SetPropertyValue(ObjectProperty prop) + { + switch (prop.propertyType) + { + case ObjectProperty.PropertyType.Bool: + boolVal = prop.propertyBool; + break; + case ObjectProperty.PropertyType.Int: + intVal = prop.propertyInt; + break; + case ObjectProperty.PropertyType.Float: + floatVal = prop.propertyFloat; + break; + case ObjectProperty.PropertyType.String: + stringVal = prop.propertyString; + break; + case ObjectProperty.PropertyType.Vector2: + vector2Val = prop.propertyVector2; + break; + case ObjectProperty.PropertyType.Vector3: + vector3Val = prop.propertyVector3; + break; + case ObjectProperty.PropertyType.ColorRGBA: + case ObjectProperty.PropertyType.ColorRGB: + colorVal = prop.propertyColor; + break; + case ObjectProperty.PropertyType.IntArray: + //intArray = prop.propertyIntArray; + break; + case ObjectProperty.PropertyType.StringArray: + //stringarray = prop.propertyStringArray; + break; + case ObjectProperty.PropertyType.FloatArray: + //floatarray = prop.propertyFloatArray; + break; + case ObjectProperty.PropertyType.GameObject: + gameObjectVal = prop.propertyGameObject; + break; + case ObjectProperty.PropertyType.GameObjectArray: + //gameObjectArray = prop.propertyGameObjectArray; + break; + default: + //return property.NONE; + break; + } + } + private property GetPropertyType(ObjectProperty.PropertyType propType) + { + switch (propType) + { + case ObjectProperty.PropertyType.Bool: + return property.BOOL; + case ObjectProperty.PropertyType.Int: + return property.INT; + case ObjectProperty.PropertyType.Float: + return property.FLOAT; + case ObjectProperty.PropertyType.String: + return property.STRING; + case ObjectProperty.PropertyType.Vector2: + return property.VECTOR2; + case ObjectProperty.PropertyType.Vector3: + return property.VECTOR3; + case ObjectProperty.PropertyType.ColorRGBA: + case ObjectProperty.PropertyType.ColorRGB: + return property.COLOR; + case ObjectProperty.PropertyType.IntArray: + return property.INT_ARRAY; + case ObjectProperty.PropertyType.StringArray: + return property.STRING_ARRAY; + case ObjectProperty.PropertyType.FloatArray: + return property.FLOAT_ARRAY; + case ObjectProperty.PropertyType.GameObject: + return property.GAMEOBJECT; + case ObjectProperty.PropertyType.GameObjectArray: + return property.GAMEOBJECT_ARRAY; + default: + return property.NONE; + + } + } + } +} diff --git a/Scripts/Editor/GLTFExporter/ObjectNodeUserExtrasMono_Editor.cs.meta b/Scripts/Editor/GLTFExporter/ObjectNodeUserExtrasMono_Editor.cs.meta new file mode 100644 index 0000000..fbf15a2 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/ObjectNodeUserExtrasMono_Editor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a822bf24e68c04b4a8fdbd0383351e8b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects.meta b/Scripts/Editor/GLTFExporter/SmartObjects.meta new file mode 100644 index 0000000..481a222 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 262569d39dc91ef419328f69a80e251d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/Menus_SmartObject.cs b/Scripts/Editor/GLTFExporter/SmartObjects/Menus_SmartObject.cs new file mode 100644 index 0000000..6d2d605 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/Menus_SmartObject.cs @@ -0,0 +1,67 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.IO; + +namespace WEBGL_EXPORTER.GLTF.SMART +{ + public class Menus_SmartObjects : Editor + { + //private string + [MenuItem("Assets/Create/Smart Script", false, 70)] + private static void CreateNewAsset() + { + //string filePath = AssetDatabase.GenerateUniqueAssetPath(GetSelectedPathOrFallback() + "NewFile.ext"); + //ProjectWindowUtil.CreateAssetWithContent(filePath, filePath); + //EditorApplication.projectWindowItemOnGUI += ProjectWindowItemCallback; + //AskUserInputWindow.CreateInstance("Class Name", "Class Name", callStr); + ProjectWindowUtil.CreateAssetWithContent( + "Default Name.js", + string.Empty); + + //ProjectWindowUtil.CreateScriptAssetFromTemplateFile() + } + private static void ProjectWindowItemCallback(string guid, Rect selectionRect) + { + Debug.Log("called"); + bool keepgoing = true; + float curTime = 0f; + while (keepgoing && curTime < 10f) + { + curTime += Time.deltaTime; + //Debug.Log(curTime); + //Debug.Log("called2"); + Debug.Log(Event.current); + } + //yield return null; + + //if (Event.current.type == EventType.MouseDrag) + //{ + // Event.current.Use(); + //} + } + //static IEnumerator checkevent() + //{ + + //} + static void callStr(string str) + { + Debug.Log(str); + } + public static string GetSelectedPathOrFallback() + { + string path = "Assets"; + foreach (Object obj in Selection.GetFiltered(typeof(Object), SelectionMode.Assets)) + { + path = AssetDatabase.GetAssetPath(obj); + if (!string.IsNullOrEmpty(path) && File.Exists(path)) + { + path = Path.GetDirectoryName(path); + break; + } + } + return path + "/"; + } + } +} diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/Menus_SmartObject.cs.meta b/Scripts/Editor/GLTFExporter/SmartObjects/Menus_SmartObject.cs.meta new file mode 100644 index 0000000..e68876d --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/Menus_SmartObject.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 012016fb3bb00e447bbd052be64f869d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/Mono_ExportToGLTF_SmartObject_Editor.cs b/Scripts/Editor/GLTFExporter/SmartObjects/Mono_ExportToGLTF_SmartObject_Editor.cs new file mode 100644 index 0000000..df88165 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/Mono_ExportToGLTF_SmartObject_Editor.cs @@ -0,0 +1,152 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER.GLTF.SMART +{ + [CustomEditor (typeof(Mono_ExportToGLTF_SmartObject),true)] + public class Mono_ExportToGLTF_SmartObject_Editor : Editor + { + Mono_ExportToGLTF_SmartObject myScript; + string idValueTemp = ""; + private void OnEnable() + { + myScript = (Mono_ExportToGLTF_SmartObject)target; + } + public override void OnInspectorGUI() + { + + GUILayout.Box("SmartObjects may override defined GLTF Custom Options values depending on the Smart Object Type, please use export to GLTF if you want to keep GLTF Custom Options as they are.", GUILayout.Width(GuiLayoutExtras.GetCenteredLabelWidth(50f))); + base.OnInspectorGUI(); + + EditorGUI.BeginChangeCheck(); + if (idValueTemp != "") + { + myScript.modelId = idValueTemp; + idValueTemp = ""; + } + + if (myScript.displayClassName) + { + myScript.smartType = (SmartType)EditorGUILayout.EnumPopup("Smart Type", myScript.smartType); + myScript.smartObjectClassName = EditorGUILayout.TextField("Class Name: ", myScript.smartObjectClassName); + + + } + if (myScript.smartType == SmartType.space) + { + myScript.exportFog = EditorGUILayout.Toggle("Export Fog: ", myScript.exportFog); + myScript.optionalReflectionProbe = (ReflectionProbe)EditorGUILayout.ObjectField("Optional Reflection Probe: ", myScript.optionalReflectionProbe, typeof(ReflectionProbe), true); + myScript.startPosition = (GameObject)EditorGUILayout.ObjectField("Start Position: ", myScript.startPosition, typeof(GameObject), true); + if (myScript.startPosition != null) + { + if (myScript.startPosition.transform.IsChildOf(myScript.transform)) + { + myScript.AddStartPositionToArray(myScript.startPosition); + } + else + { + Debug.LogError("GameObject must be a child of Smart Object"); + } + myScript.startPosition = null; + } + if (myScript.startPositionList != null) + { + if (myScript.startPositionList.Count > 0) + { + + for (int i = 0; i < myScript.startPositionList.Count; i++) + { + EditorGUILayout.BeginHorizontal(); + GUI.enabled = false; + GameObject go = (GameObject)EditorGUILayout.ObjectField(myScript.startPositionList[i], typeof(GameObject), true); + GUI.enabled = true; + if (GUILayout.Button("X", GUILayout.Width(20f), GUILayout.Height(20f))) + { + myScript.startPositionList.RemoveAt(i); + } + EditorGUILayout.EndHorizontal(); + } + + } + } + } + myScript.modelId = EditorGUILayout.TextField("model create folder: ", myScript.modelId); + myScript.exportLocation = EditorGUILayout.TextField("export location: ", myScript.exportLocation); + myScript.curBuild = EditorGUILayout.IntField("Current Build: ", myScript.curBuild); + + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Export GLTF TestBuild", GUILayout.Height(50f))) + { + if (myScript.modelId == "") + { + AskUserInputWindow inputWindow = AskUserInputWindow.CreateInstance("Name Required", "ID name", ValidateCallExport, "Cancel", "Save"); + } + else + { + if (myScript.exportLocation == "") + { + myScript.exportLocation = EditorUtility.SaveFolderPanel( + "Save To", + "", + ""); + if (myScript.exportLocation != "") + { + ExportGLTFModel(true); + } + } + else + { + ExportGLTFModel(true); + } + } + + } + if (GUILayout.Button("Export GLTF Final", GUILayout.Height(50f))) + { + if (myScript.exportLocation == "") + { + myScript.exportLocation = EditorUtility.SaveFolderPanel( + "Save To", + "", + ""); + if (myScript.exportLocation != "") + { + ExportGLTFModel(false); + } + } + else + { + ExportGLTFModel(false); + } + + } + EditorGUILayout.EndHorizontal(); + + + } + private void ValidateCallExport(string value) + { + if (value != "") + { + idValueTemp = value; + } + + } + private void ExportGLTFModel(bool test_build) + { + + if (FileExporter.DirectoryExists(myScript.exportLocation)) + { + myScript.ExportGLTF(myScript.exportLocation, test_build); + Debug.Log("Exported to: " + myScript.exportLocation); + } + else + { + Debug.LogWarning("export location does not exists"); + myScript.exportLocation = ""; + } + } + } +} diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/Mono_ExportToGLTF_SmartObject_Editor.cs.meta b/Scripts/Editor/GLTFExporter/SmartObjects/Mono_ExportToGLTF_SmartObject_Editor.cs.meta new file mode 100644 index 0000000..9532c37 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/Mono_ExportToGLTF_SmartObject_Editor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8c9087c6a6b1fd544b9a4fa8b5a957c7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/SmartObjectBehaviour_Editor.cs b/Scripts/Editor/GLTFExporter/SmartObjects/SmartObjectBehaviour_Editor.cs new file mode 100644 index 0000000..b673f2d --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/SmartObjectBehaviour_Editor.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER.GLTF +{ + [CustomEditor(typeof(SmartObjectBehaviour),true)] + public class SmartObjectBehaviour_Editor : Editor + { + SmartObjectBehaviour myScript; + private void OnEnable() + { + myScript = (SmartObjectBehaviour)target; + } + public override void OnInspectorGUI() + { + //GUI.enabled = false; + myScript.javascript = (TextAsset)EditorGUILayout.ObjectField("Javascript",myScript.javascript,typeof(TextAsset), false); + //GUI.enabled = true; + } + } +} diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/SmartObjectBehaviour_Editor.cs.meta b/Scripts/Editor/GLTFExporter/SmartObjects/SmartObjectBehaviour_Editor.cs.meta new file mode 100644 index 0000000..981e352 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/SmartObjectBehaviour_Editor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c5f1dec321114514abc3ed8af0c19336 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/TestScript.extension b/Scripts/Editor/GLTFExporter/SmartObjects/TestScript.extension new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/TestScript.extension @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/TestScript.extension.meta b/Scripts/Editor/GLTFExporter/SmartObjects/TestScript.extension.meta new file mode 100644 index 0000000..4284b47 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/TestScript.extension.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 37b5642062153934cb41c53bdc34fb96 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test.meta new file mode 100644 index 0000000..a109df9 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 524bba2adc9bc85418e33bbafd84a6fb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/Default Name.js b/Scripts/Editor/GLTFExporter/SmartObjects/test/Default Name.js new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/Default Name.js @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/Default Name.js.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test/Default Name.js.meta new file mode 100644 index 0000000..bfdc623 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/Default Name.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f87494cc043ac594292e516f4dcad354 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/SmartComponentCreator.cs b/Scripts/Editor/GLTFExporter/SmartObjects/test/SmartComponentCreator.cs new file mode 100644 index 0000000..aa77690 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/SmartComponentCreator.cs @@ -0,0 +1,203 @@ +using UnityEditor; +using UnityEngine; +using System.Collections.Generic; +// makes sure that the static constructor is always called in the editor. +namespace WEBGL_EXPORTER.GLTF +{ + public class MouseEvent : Editor + { + private void OnSceneGUI() + { + Debug.Log("asdkljn"); + } + } + [InitializeOnLoad] + public class SmartComponentCreator : Editor + { + static SmartComponentCreator() + { + //EditorApplication. + // Adds a callback for when the hierarchy window processes GUI events + // for every GameObject in the heirarchy. + //EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowItemCallback; + EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowItemCallbackExist; + //EditorApplication.projectWindowItemOnGUI += ProjectWindowItemCallback; + + + EditorApplication.update += te; + + //EditorApplication. + } + static void testFunction(GenericMenu menu, SerializedProperty property) + { + + Debug.Log("ttttt"); + } + void OnSceneGUI() + { + + Debug.Log("tes new"); + //if (Event.current.type == EventType.MouseDown) + //{ + // Ray ray = Camera.main.ScreenPointToRay(Event.current.mousePosition); + // RaycastHit hit = new RaycastHit(); + // if (Physics.Raycast(ray, out hit, 1000.0f)) + // { + // Debug.Log(Event.current.mousePosition); + // Vector3 newTilePosition = hit.point; + // Instantiate(newTile, newTilePosition, Quaternion.identity); + // } + //} + } + static void te() + { + //if (Input.GetMouseButtonDown(0)) + //{ + // Debug.Log("kmk"); + //} + //Debug.Log(Event.current); + //Debug.Log("changa"); + } + static void ProjectWindowItemCallback(string guid, Rect selectionRect) + { + //Debug.Log("ON PROJECT!"); + if (Event.current.type == EventType.MouseDrag) + { + //Debug.Log("yahoo"); + + //TextAsset dragData = new CustomDragData(); + //dragData.originalIndex = somethingYouGotFromYourProperty; + //dragData.originalList = this.targetList; + TextAsset receivedDragData = new TextAsset(); + DragAndDrop.SetGenericData("text", receivedDragData); + receivedDragData = DragAndDrop.GetGenericData("text") as TextAsset; + Debug.Log(receivedDragData); + DragAndDrop.AcceptDrag(); + //var selectedObjects = new List(); + foreach (var objectRef in DragAndDrop.objectReferences) + { + Debug.Log(objectRef); + // if the object is the particular asset type... + if (objectRef is TextAsset) + { + Debug.Log("test"); + // we create a new GameObject using the asset's name. + var gameObject = new GameObject(objectRef.name); + // we attach component X, associated with asset X. + var componentX = gameObject.AddComponent(); + // we place asset X within component X. + componentX.javascript = objectRef as TextAsset; + // add to the list of selected objects. + //selectedObjects.Add(gameObject); + } + } + } + if (Event.current.type == EventType.DragPerform) + { + Debug.Log("WOOO!"); + } + } + static void HierarchyWindowItemCallbackExist(int instanceID, Rect pRect) + { + + // happens when an acceptable item is released over the GUI window + if (Event.current.type == EventType.DragExited && pRect.Contains(Event.current.mousePosition)) + { + // get all the drag and drop information ready for processing. + DragAndDrop.AcceptDrag(); + + GameObject gameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject; + + if (gameObject == null) return; + + gameObject = PrefabUtility.GetPrefabType(gameObject) == PrefabType.PrefabInstance ? PrefabUtility.GetPrefabParent(gameObject) as GameObject : gameObject; + + + if (gameObject != null) + // run through each object that was dragged in. + foreach (var objectRef in DragAndDrop.objectReferences) + { + // if the object is the particular asset type... + if (objectRef is TextAsset) + { + string p = AssetDatabase.GetAssetPath(objectRef); + if (p.EndsWith(".js")) + { + // we attach component X, associated with asset X. + var smartBehaviour = gameObject.AddComponent(); + // we place asset X within component X. + smartBehaviour.javascript = objectRef as TextAsset; + } + + } + + + } + + + Event.current.Use(); + + + } + } + static void HierarchyWindowItemCallback(int pID, Rect pRect) + { + // Debug.Log("DOIN SOMTHIN"); + // happens when an acceptable item is released over the GUI window + if (Event.current.type == EventType.DragPerform) + { + + DragAndDrop.AcceptDrag(); + foreach (var objectRef in DragAndDrop.objectReferences) + { + if (objectRef is TextAsset) + { + Debug.Log("knjkj"); + Debug.Log(pID); + Debug.Log("pus"); + //// we create a new GameObject using the asset's name. + //var gameObject = new GameObject(objectRef.name); + //// we attach component X, associated with asset X. + //var componentX = gameObject.AddComponent(); + //// we place asset X within component X. + //componentX.javascript = objectRef as TextAsset; + //// add to the list of selected objects. + //selectedObjects.Add(gameObject); + } + } + } + if (Event.current.type == EventType.DragPerform) + { + Debug.Log("DOIN SOMTHIN2"); + // get all the drag and drop information ready for processing. + DragAndDrop.AcceptDrag(); + // used to emulate selection of new objects. + var selectedObjects = new List(); + // run through each object that was dragged in. + foreach (var objectRef in DragAndDrop.objectReferences) + { + // if the object is the particular asset type... + if (objectRef is TextAsset) + { + Debug.Log("pus"); + //// we create a new GameObject using the asset's name. + //var gameObject = new GameObject(objectRef.name); + //// we attach component X, associated with asset X. + //var componentX = gameObject.AddComponent(); + //// we place asset X within component X. + //componentX.javascript = objectRef as TextAsset; + //// add to the list of selected objects. + //selectedObjects.Add(gameObject); + } + } + // we didn't drag any assets of type AssetX, so do nothing. + if (selectedObjects.Count == 0) return; + // emulate selection of newly created objects. + Selection.objects = selectedObjects.ToArray(); + + // make sure this call is the only one that processes the event. + Event.current.Use(); + } + } + } +} \ No newline at end of file diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/SmartComponentCreator.cs.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test/SmartComponentCreator.cs.meta new file mode 100644 index 0000000..464ad01 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/SmartComponentCreator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 25b58d34cb19aaa49bb5c1f8aed45661 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/WeekdaysDropdown.cs b/Scripts/Editor/GLTFExporter/SmartObjects/test/WeekdaysDropdown.cs new file mode 100644 index 0000000..8e22490 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/WeekdaysDropdown.cs @@ -0,0 +1,46 @@ +using UnityEditor; +using UnityEngine; +using UnityEditor.IMGUI.Controls; + +class WeekdaysDropdown : AdvancedDropdown +{ + public WeekdaysDropdown(AdvancedDropdownState state) : base(state) + { + } + + protected override AdvancedDropdownItem BuildRoot() + { + var root = new AdvancedDropdownItem("Weekdays"); + + var firstHalf = new AdvancedDropdownItem("First half"); + var secondHalf = new AdvancedDropdownItem("Second half"); + var weekend = new AdvancedDropdownItem("Weekend"); + + firstHalf.AddChild(new AdvancedDropdownItem("Monday")); + firstHalf.AddChild(new AdvancedDropdownItem("Tuesday")); + secondHalf.AddChild(new AdvancedDropdownItem("Wednesday")); + secondHalf.AddChild(new AdvancedDropdownItem("Thursday")); + weekend.AddChild(new AdvancedDropdownItem("Friday")); + weekend.AddChild(new AdvancedDropdownItem("Saturday")); + weekend.AddChild(new AdvancedDropdownItem("Sunday")); + + root.AddChild(firstHalf); + root.AddChild(secondHalf); + root.AddChild(weekend); + + return root; + } +} + +public class AdvancedDropdownTestWindow : EditorWindow +{ + void OnGUI() + { + var rect = GUILayoutUtility.GetRect(new GUIContent("Show"), EditorStyles.toolbarButton); + if (GUI.Button(rect, new GUIContent("Show"), EditorStyles.toolbarButton)) + { + var dropdown = new WeekdaysDropdown(new AdvancedDropdownState()); + dropdown.Show(rect); + } + } +} diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/WeekdaysDropdown.cs.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test/WeekdaysDropdown.cs.meta new file mode 100644 index 0000000..b222c49 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/WeekdaysDropdown.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ccd9bddda926ec4f93a4ad784f08936 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/older.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test/older.meta new file mode 100644 index 0000000..b46c90b --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/older.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d2289d2196ffd1746b76573c43f492a1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDrop.cs b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDrop.cs new file mode 100644 index 0000000..a87c65f --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDrop.cs @@ -0,0 +1,55 @@ +using UnityEngine; +using System.Collections; + +using UnityEditor; + +namespace WEBGL_EXPORTER.GLTF +{ + //[CustomEditor(typeof(Component),true)] + public class Inspector_SmartObject_DragDrop : Editor + { + + private SerializedObject obj; + + public void OnEnable() + { + obj = new SerializedObject(target); + } + + public override void OnInspectorGUI() + { + //DrawDefaultInspector(); + EditorGUILayout.Space(); + DropAreaGUI(); + } + + public void DropAreaGUI() + { + Event evt = Event.current; + Rect drop_area = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true)); + GUI.Box(drop_area, "Add Trigger"); + + switch (evt.type) + { + case EventType.DragUpdated: + case EventType.DragPerform: + if (!drop_area.Contains(evt.mousePosition)) + return; + + DragAndDrop.visualMode = DragAndDropVisualMode.Copy; + + if (evt.type == EventType.DragPerform) + { + DragAndDrop.AcceptDrag(); + + foreach (Object dragged_object in DragAndDrop.objectReferences) + { + Debug.Log("test"); + // Do On Drag Stuff here + } + } + break; + } + } + } +} \ No newline at end of file diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDrop.cs.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDrop.cs.meta new file mode 100644 index 0000000..bc901fb --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDrop.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 977e537608fc0d6428fdafdc12d6bdc2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDropv2.cs b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDropv2.cs new file mode 100644 index 0000000..82c1c76 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDropv2.cs @@ -0,0 +1,100 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +public class Inspector_SmartObject_DragDropv2 : MonoBehaviour +{ + public class CustomDragData + { + public int originalIndex; + public IList originalList; + } + private void OnGUI() + { + if (Event.current.type == EventType.MouseDrag) + { + // Clear out drag data + DragAndDrop.PrepareStartDrag(); + Debug.Log("test"); + + // Set up what we want to drag + DragAndDrop.paths[0] = "/Users/joe/myPath.txt"; + + // Start the actual drag + DragAndDrop.StartDrag("Dragging title"); + + // Make sure no one uses the event after us + Event.current.Use(); + } + } + //protected void ExampleDragDropGUI(Rect dropArea, SerializedProperty property) + //{ + // // Cache References: + // Event currentEvent = Event.current; + // EventType currentEventType = currentEvent.type; + + // // The DragExited event does not have the same mouse position data as the other events, + // // so it must be checked now: + // if (currentEventType == EventType.DragExited) DragAndDrop.PrepareStartDrag();// Clear generic data when user pressed escape. (Unfortunately, DragExited is also called when the mouse leaves the drag area) + + // if (!dropArea.Contains(currentEvent.mousePosition)) return; + + // switch (currentEventType) + // { + // case EventType.MouseDown: + // DragAndDrop.PrepareStartDrag();// reset data + // Debug.Log("start mouse drag"); + // CustomDragData dragData = new CustomDragData(); + // dragData.originalIndex = somethingYouGotFromYourProperty; + // dragData.originalList = this.targetList; + + // DragAndDrop.SetGenericData(dragDropIdentifier, dragData); + + // Object[] objectReferences = new Object[1] { property.objectReferenceValue };// Careful, null values cause exceptions in existing editor code. + // DragAndDrop.objectReferences = objectReferences;// Note: this object won't be 'get'-able until the next GUI event. + + // currentEvent.Use(); + + // break; + // case EventType.MouseDrag: + // // If drag was started here: + // CustomDragData existingDragData = DragAndDrop.GetGenericData(dragDropIdentifier) as CustomDragData; + + // if (existingDragData != null) + // { + // DragAndDrop.StartDrag("Dragging List ELement"); + // currentEvent.Use(); + // } + + // break; + // case EventType.DragUpdated: + // if (IsDragTargetValid()) DragAndDrop.visualMode = DragAndDropVisualMode.Link; + // else DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; + + // currentEvent.Use(); + // break; + // case EventType.Repaint: + // if ( + // DragAndDrop.visualMode == DragAndDropVisualMode.None || + // DragAndDrop.visualMode == DragAndDropVisualMode.Rejected) break; + + // EditorGUI.DrawRect(dropArea, Color.grey); + // break; + // case EventType.DragPerform: + // DragAndDrop.AcceptDrag(); + + // CustomDragData receivedDragData = DragAndDrop.GetGenericData(dragDropIdentifier) as CustomDragData; + + // if (receivedDragData != null receivedDragData.originalList == this.targetList) ReorderObject(); + // else AddDraggedObjectsToList(); + + // currentEvent.Use(); + // break; + // case EventType.MouseUp: + // // Clean up, in case MouseDrag never occurred: + // DragAndDrop.PrepareStartDrag(); + // break; + // } + + //} +} diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDropv2.cs.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDropv2.cs.meta new file mode 100644 index 0000000..7844255 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/Inspector_SmartObject_DragDropv2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 828755f988ccf4646ad0bdb0c37dc57e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/older/helloworld.extension b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/helloworld.extension new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/helloworld.extension @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/older/helloworld.extension.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/helloworld.extension.meta new file mode 100644 index 0000000..ea49418 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/older/helloworld.extension.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: cdb6ca64c8ad9274e86a1ea83f494eae +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/quickSearch.ext b/Scripts/Editor/GLTFExporter/SmartObjects/test/quickSearch.ext new file mode 100644 index 0000000..9c7a72c --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/quickSearch.ext @@ -0,0 +1 @@ +Assets/unity-to-threejs/Scripts/Editor/Admin/GLTFExporter/SmartObjects/test/NewFile.ext \ No newline at end of file diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/quickSearch.ext.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test/quickSearch.ext.meta new file mode 100644 index 0000000..a8650b5 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/quickSearch.ext.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4a2838f6eac05024d8c43bdde8779452 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/sad.js b/Scripts/Editor/GLTFExporter/SmartObjects/test/sad.js new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/sad.js @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Scripts/Editor/GLTFExporter/SmartObjects/test/sad.js.meta b/Scripts/Editor/GLTFExporter/SmartObjects/test/sad.js.meta new file mode 100644 index 0000000..e0f4d1f --- /dev/null +++ b/Scripts/Editor/GLTFExporter/SmartObjects/test/sad.js.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7a93adaf189e36145874ad8862c88fdc +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/ModifyUVs.meta b/Scripts/Editor/ModifyUVs.meta new file mode 100644 index 0000000..28986ea --- /dev/null +++ b/Scripts/Editor/ModifyUVs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: efae015aaf9601e4d988031aaa5116b0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/ModifyUVs/OffsetChildOffsetUVsEditor.cs b/Scripts/Editor/ModifyUVs/OffsetChildOffsetUVsEditor.cs new file mode 100644 index 0000000..1628c57 --- /dev/null +++ b/Scripts/Editor/ModifyUVs/OffsetChildOffsetUVsEditor.cs @@ -0,0 +1,43 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + [CustomEditor(typeof(OffsetChildOffsetUVs))] + public class OffsetChildOffsetUVsEditor : Editor + { + + public override void OnInspectorGUI() + { + OffsetChildOffsetUVs myScript = (OffsetChildOffsetUVs)target; + base.OnInspectorGUI(); + GUILayout.BeginHorizontal("box"); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.SetOffset(0); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.SetOffset(1); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.SetOffset(2); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal("box"); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.SetOffset(3); + if (GUILayout.Button("", GUILayout.Height(30))) + Debug.Log("peekaboo"); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.SetOffset(5); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal("box"); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.SetOffset(6); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.SetOffset(7); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.SetOffset(8); + GUILayout.EndHorizontal(); + } + } +} diff --git a/Scripts/Editor/ModifyUVs/OffsetChildOffsetUVsEditor.cs.meta b/Scripts/Editor/ModifyUVs/OffsetChildOffsetUVsEditor.cs.meta new file mode 100644 index 0000000..081ee6a --- /dev/null +++ b/Scripts/Editor/ModifyUVs/OffsetChildOffsetUVsEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6c593dcd014e368468f5fedc4e9963a8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/ModifyUVs/OffsetUVsEditor.cs b/Scripts/Editor/ModifyUVs/OffsetUVsEditor.cs new file mode 100644 index 0000000..9d66d64 --- /dev/null +++ b/Scripts/Editor/ModifyUVs/OffsetUVsEditor.cs @@ -0,0 +1,70 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + [CustomEditor(typeof(OffsetUVs), true), CanEditMultipleObjects] + public class OffsetUVsEditor : Editor + { + // Start is called before the first frame update + public override void OnInspectorGUI() + { + OffsetUVs myScript = (OffsetUVs)target; + + Undo.RecordObject(myScript, "offset uv values"); + Undo.RecordObject(myScript.meshFilter, "offset uv values"); + //Undo.RecordObject(myScript.ori); + + base.OnInspectorGUI(); + GUILayout.BeginHorizontal("box"); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.OffsetAllUVs(0); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.OffsetAllUVs(1); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.OffsetAllUVs(2); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal("box"); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.OffsetAllUVs(3); + if (GUILayout.Button("", GUILayout.Height(30))) + { + myScript.SetOriginalMesh(); + //myScript.ResetOriginalMesh(); + myScript.DebugClick(); + } + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.OffsetAllUVs(5); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal("box"); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.OffsetAllUVs(6); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.OffsetAllUVs(7); + if (GUILayout.Button("", GUILayout.Height(30))) + myScript.OffsetAllUVs(8); + GUILayout.EndHorizontal(); + + if (!myScript.uvsFromLightmapUvs) + { + if (GUILayout.Button("Set Uv from lightmap uvs", GUILayout.Height(30))) + myScript.SetLightmapUvsAsMainUvs(true); + } + else + { + if (GUILayout.Button("Get Original uvs", GUILayout.Height(30))) + myScript.SetLightmapUvsAsMainUvs(false); + } + + GUILayout.BeginHorizontal("box"); + if (GUILayout.Button("Set All To Original UVs", GUILayout.Height(30))) + OffsetUVs.SetAllToOriginalMesh(true); + if (GUILayout.Button("Set All To Edited UVs", GUILayout.Height(30))) + OffsetUVs.SetAllToOriginalMesh(false); + GUILayout.EndHorizontal(); + } + } +} diff --git a/Scripts/Editor/ModifyUVs/OffsetUVsEditor.cs.meta b/Scripts/Editor/ModifyUVs/OffsetUVsEditor.cs.meta new file mode 100644 index 0000000..9671a1a --- /dev/null +++ b/Scripts/Editor/ModifyUVs/OffsetUVsEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8b560e188c2d84e45b3d4e00f80c3097 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/ModifyUVs/OffsetUVsTemporaryResetEditor.cs b/Scripts/Editor/ModifyUVs/OffsetUVsTemporaryResetEditor.cs new file mode 100644 index 0000000..1b63f72 --- /dev/null +++ b/Scripts/Editor/ModifyUVs/OffsetUVsTemporaryResetEditor.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + [CustomEditor(typeof(OffsetUVsTemporaryReset))] + public class OffsetUVsTemporaryResetEditor : Editor + { + public override void OnInspectorGUI() + { + + base.OnInspectorGUI(); + OffsetUVsTemporaryReset myScript = (OffsetUVsTemporaryReset)target; + + if (GUILayout.Button("Set Original Materials", GUILayout.Height(100))) + { + myScript.SetOriginalMesh(); + } + if (GUILayout.Button("Set Edited Materials", GUILayout.Height(100))) + { + myScript.SetEditedMesh(); + } + } + } +} diff --git a/Scripts/Editor/ModifyUVs/OffsetUVsTemporaryResetEditor.cs.meta b/Scripts/Editor/ModifyUVs/OffsetUVsTemporaryResetEditor.cs.meta new file mode 100644 index 0000000..820d9e2 --- /dev/null +++ b/Scripts/Editor/ModifyUVs/OffsetUVsTemporaryResetEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9a7d57cf002254a4dbf1362138a740bb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/MonoEnhanceWeb.meta b/Scripts/Editor/MonoEnhanceWeb.meta new file mode 100644 index 0000000..3558fa2 --- /dev/null +++ b/Scripts/Editor/MonoEnhanceWeb.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9f3f61dc6f8ada14eaa747a90b933dda +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/MonoEnhanceWeb/WebPositionalAudioSource_Editor.cs b/Scripts/Editor/MonoEnhanceWeb/WebPositionalAudioSource_Editor.cs new file mode 100644 index 0000000..87b83f0 --- /dev/null +++ b/Scripts/Editor/MonoEnhanceWeb/WebPositionalAudioSource_Editor.cs @@ -0,0 +1,178 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER.GLTF { + + [CustomEditor(typeof(WebPositionalAudioSource))] + public class WebPositionalAudioSource_Editor : Editor + { + WebPositionalAudioSource myScript; + MonoScript script; + + string emitterName; + float gain; //volume + bool loop; + bool playing; + + //bool editPitchSpeedSeparatedly; + float speed; //pitch + float pitch; //check if its not the same as speed? + + float coneInnerAngleDegree; + float coneOuterAngleDegree; + float coneOuterGain; + WebPositionalAudioSource.Distance distance; + + //only works when distance model is set to linear + float maxDistance; + float refDistance; + //whens set to linear max value is one, otherwise max value can go higher + float rollOffFactor = 1f; + float rollOffFactorLinear = 1f; + + AudioClip audioClip; + + private void OnEnable() + { + myScript = (WebPositionalAudioSource)target; + script = MonoScript.FromMonoBehaviour((WebPositionalAudioSource)target); + + //if (!myScript.setupCreated) + //{ + // myScript.setupCreated = true; + // UnityEditorInternal.ComponentUtility.MoveComponentUp(myScript); + //} + } + + public override void OnInspectorGUI() + { + GUI.enabled = false; + EditorGUILayout.ObjectField("Script: ", script, typeof(MonoScript), false); + //myScript.audioSource = (AudioSource)EditorGUILayout.ObjectField("Audio Clip: ", audioSource, typeof(AudioClip), false); + GUI.enabled = true; + EditorGUI.BeginChangeCheck(); + + emitterName = EditorGUILayout.TextField("Emitter Name (optional): ", myScript.emitterName); + audioClip = (AudioClip)EditorGUILayout.ObjectField("Audio Clip: ", myScript.clip, typeof(AudioClip), false); + gain = EditorGUILayout.FloatField("Gain: ", myScript.gain); + + EditorGUILayout.Space(); + speed = EditorGUILayout.FloatField("Speed: ", myScript.speed); + pitch = EditorGUILayout.FloatField("Pitch: ", myScript.pitch); + + EditorGUILayout.BeginHorizontal(); + loop = EditorGUILayout.Toggle("Loop: ", myScript.loop); + playing = EditorGUILayout.Toggle("Playing: ", myScript.playing); + EditorGUILayout.EndHorizontal(); + + + if (!myScript.isGlobalAudio) + { + if (GUILayout.Button("Change To Global Audio", GUILayout.Height(40f))) + { + myScript.isGlobalAudio = true; + } + GuiLayoutExtras.CenterLabel("Cone angles in degrees", 20); + EditorGUILayout.Space(); + coneInnerAngleDegree = EditorGUILayout.FloatField("Cone Inner Angle (red): ", myScript.coneInnerAngleDegree); + coneOuterAngleDegree = EditorGUILayout.FloatField("Cone Outer Angle (blue): ", myScript.coneOuterAngleDegree); + coneOuterGain = EditorGUILayout.FloatField("Cone Outer Gain: ", myScript.coneOuterGain); + distance = (WebPositionalAudioSource.Distance)EditorGUILayout.EnumPopup("Distance: ", myScript.distance); + + EditorGUILayout.Space(); + if (myScript.distance == WebPositionalAudioSource.Distance.linear) + { + maxDistance = EditorGUILayout.FloatField("Max Distance: ", myScript.maxDistance); + } + else + { + maxDistance = myScript.maxDistance; + } + + + refDistance = EditorGUILayout.FloatField("Ref Distance: ", myScript.refDistance); + if (myScript.distance == WebPositionalAudioSource.Distance.linear) + { + rollOffFactorLinear = EditorGUILayout.Slider("Roll Off Factor: ", myScript.rollOffFactorLinear, 0f, 1f); + rollOffFactor = myScript.rollOffFactor; + } + else + { + rollOffFactor = EditorGUILayout.FloatField("Roll Off Factor: ", myScript.rollOffFactor); + rollOffFactorLinear = myScript.rollOffFactorLinear; + } + } + else + { + if (GUILayout.Button("Change To Positional Audio", GUILayout.Height(40f))) + { + myScript.isGlobalAudio = false; + } + } + + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(myScript,"edit web audio"); + SaveChanges(); + } + //base.OnInspectorGUI(); + } + + private void SaveChanges() + { + if (myScript.clip != audioClip) + { + Debug.Log("clip changed"); + string extension = StringUtilities.GetExtensionFromObjectAsset(audioClip).ToLower(); + if (extension == "mp3" || extension == "wav") + { + myScript.clip = audioClip; + } + else + { + Debug.LogError("Only .mp3 or .wav format is supported. Skipping"); + } + } + myScript.emitterName = emitterName; + myScript.gain = gain; + + myScript.speed = speed; + myScript.loop = loop; + myScript.playing = playing; + myScript.pitch = pitch; + + myScript.coneInnerAngleDegree = coneInnerAngleDegree; + myScript.coneOuterAngleDegree = coneOuterAngleDegree; + myScript.coneOuterGain = coneOuterGain; + myScript.distance = distance; + + myScript.maxDistance = maxDistance; + myScript.refDistance = refDistance; + myScript.rollOffFactor = rollOffFactor; + myScript.rollOffFactorLinear = rollOffFactorLinear; + } + + private void OnSceneGUI() + { + if (myScript.enabled) + { + Handles.color = Color.yellow; + Handles.DrawLine(myScript.transform.position, myScript.transform.position + (myScript.transform.TransformDirection(Vector3.back) * 3f)); + + Handles.color = Color.red; + Vector3 inner_1 = Quaternion.Euler(0, myScript.coneInnerAngleDegree / 2, 0) * myScript.transform.TransformDirection(Vector3.back); + Vector3 inner_2 = Quaternion.Euler(0, -myScript.coneInnerAngleDegree / 2, 0) * myScript.transform.TransformDirection(Vector3.back); + Handles.DrawLine(myScript.transform.position, myScript.transform.position + (inner_1 * 3f)); + Handles.DrawLine(myScript.transform.position, myScript.transform.position + (inner_2 * 3f)); + + Handles.color = Color.blue; + Vector3 outer_1 = Quaternion.Euler(0, myScript.coneOuterAngleDegree / 2, 0) * myScript.transform.TransformDirection(Vector3.back); + Vector3 outer_2 = Quaternion.Euler(0, -myScript.coneOuterAngleDegree / 2, 0) * myScript.transform.TransformDirection(Vector3.back); + Handles.DrawLine(myScript.transform.position, myScript.transform.position + (outer_1 * 3f)); + Handles.DrawLine(myScript.transform.position, myScript.transform.position + (outer_2 * 3f)); + } + } + } +} diff --git a/Scripts/Editor/MonoEnhanceWeb/WebPositionalAudioSource_Editor.cs.meta b/Scripts/Editor/MonoEnhanceWeb/WebPositionalAudioSource_Editor.cs.meta new file mode 100644 index 0000000..905019b --- /dev/null +++ b/Scripts/Editor/MonoEnhanceWeb/WebPositionalAudioSource_Editor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e71cd17cbcb0021448a5b52ba384688e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/SceneModifiers.meta b/Scripts/Editor/SceneModifiers.meta new file mode 100644 index 0000000..42b26e4 --- /dev/null +++ b/Scripts/Editor/SceneModifiers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4851d3a79fe530c48bdf6ecb6c138d66 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/SceneModifiers/BakerMoveEditor.cs b/Scripts/Editor/SceneModifiers/BakerMoveEditor.cs new file mode 100644 index 0000000..c109a03 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/BakerMoveEditor.cs @@ -0,0 +1,57 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + [CustomEditor(typeof(BakerMover), true)] + public class BakerMoveEditor : Editor + { + public override void OnInspectorGUI() + { + BakerMover myScript = (BakerMover)target; + + if (myScript.firstTime == false) + { + GUILayout.BeginHorizontal("box"); + + if (GUILayout.Button("Move To Saved Position", GUILayout.Height(100))) + { + myScript.MoveToSavedPosition(); + } + if (GUILayout.Button("Save Current Position", GUILayout.Height(100))) + { + if (EditorUtility.DisplayDialog("Confirm reset", "Are you sure you want to reset position", "ok", "cancel")) + { + myScript.GetObjectPosition(); + } + } + GUILayout.EndHorizontal(); + GUILayout.BeginHorizontal("box"); + if (GUILayout.Button("Move To Test Position", GUILayout.Height(80))) + { + myScript.MoveToOutsidePosition(); + } + if (GUILayout.Button("Save Test Position", GUILayout.Height(80))) + { + + myScript.GetObjectTestPosition(); + + } + GUILayout.EndHorizontal(); + + + } + else + { + if (GUILayout.Button("Save Current Position", GUILayout.Height(100))) + { + myScript.GetObjectPosition(); + myScript.firstTime = false; + } + + } + base.OnInspectorGUI(); + } + } +} diff --git a/Scripts/Editor/SceneModifiers/BakerMoveEditor.cs.meta b/Scripts/Editor/SceneModifiers/BakerMoveEditor.cs.meta new file mode 100644 index 0000000..20fe2d2 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/BakerMoveEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e5fdd9f0d3ae7d141a2bf924d272017f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/SceneModifiers/ChangeChildNameEditor.cs b/Scripts/Editor/SceneModifiers/ChangeChildNameEditor.cs new file mode 100644 index 0000000..206fbf5 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/ChangeChildNameEditor.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + [CustomEditor(typeof(ChangeChildName))] + public class ChangeChildNameEditor : Editor + { + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + ChangeChildName myScript = (ChangeChildName)target; + if (GUILayout.Button("Change First Child Names", GUILayout.Height(100))) + { + myScript.ChangeFirstChildNames(); + } + if (GUILayout.Button("Change All Child Names", GUILayout.Height(100))) + { + myScript.ChangeAllChildNames(); + } + } + + } +} diff --git a/Scripts/Editor/SceneModifiers/ChangeChildNameEditor.cs.meta b/Scripts/Editor/SceneModifiers/ChangeChildNameEditor.cs.meta new file mode 100644 index 0000000..7add390 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/ChangeChildNameEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6cf3460ef3039b14fbf9cebbc6b8d953 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/SceneModifiers/CreateMeshColliderOnChildsEditor.cs b/Scripts/Editor/SceneModifiers/CreateMeshColliderOnChildsEditor.cs new file mode 100644 index 0000000..4c61836 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/CreateMeshColliderOnChildsEditor.cs @@ -0,0 +1,39 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER +{ + [CustomEditor(typeof(CreateMeshColliderOnChilds))] + public class CreateMeshColliderOnChildsEditor : Editor + { + MonoScript script; + private void OnEnable() + { + script = MonoScript.FromMonoBehaviour((CreateMeshColliderOnChilds)target); + } + public override void OnInspectorGUI() + { + CreateMeshColliderOnChilds myScript = (CreateMeshColliderOnChilds)target; + + script = EditorGUILayout.ObjectField("Script: ", script, (typeof(MonoScript)), false) as MonoScript; + + if (myScript.displayButtons) + { + if (GUILayout.Button("Add Mesh Colliders to Childs", GUILayout.Height(80f))) + { + myScript.CreateMeshColliders(); + } + if (myScript.createdsColliders) + { + if (GUILayout.Button("Revert as initial mode", GUILayout.Height(80f))) + { + myScript.RevertMeshColliders(); + } + } + } + + } + } +} diff --git a/Scripts/Editor/SceneModifiers/CreateMeshColliderOnChildsEditor.cs.meta b/Scripts/Editor/SceneModifiers/CreateMeshColliderOnChildsEditor.cs.meta new file mode 100644 index 0000000..94b5867 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/CreateMeshColliderOnChildsEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4017b7ffc44050e4f8fb272b4593f70b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/SceneModifiers/EditorImportModifiers.meta b/Scripts/Editor/SceneModifiers/EditorImportModifiers.meta new file mode 100644 index 0000000..e007104 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/EditorImportModifiers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 822c93546ded9394aa01bbb7c9e1166a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/SceneModifiers/EditorImportModifiers/ModelImportOptions.cs b/Scripts/Editor/SceneModifiers/EditorImportModifiers/ModelImportOptions.cs new file mode 100644 index 0000000..95cff68 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/EditorImportModifiers/ModelImportOptions.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + public class ModelImportOptions : AssetPostprocessor + { + public void OnPreprocessModel() + { + ModelImporter modelImporter = (ModelImporter)assetImporter; + + modelImporter.generateSecondaryUV = true; + } + } +} \ No newline at end of file diff --git a/Scripts/Editor/SceneModifiers/EditorImportModifiers/ModelImportOptions.cs.meta b/Scripts/Editor/SceneModifiers/EditorImportModifiers/ModelImportOptions.cs.meta new file mode 100644 index 0000000..1b64976 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/EditorImportModifiers/ModelImportOptions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 22eb6447ac4533246abcc02e3f3e76ae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/SceneModifiers/MaterialOptionsEditor.cs b/Scripts/Editor/SceneModifiers/MaterialOptionsEditor.cs new file mode 100644 index 0000000..8c9eba3 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/MaterialOptionsEditor.cs @@ -0,0 +1,74 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER +{ + [CustomEditor(typeof(MaterialOptions))] + public class MaterialOptionsEditor : Editor + { + MonoScript script; + private void OnEnable() + { + script = MonoScript.FromMonoBehaviour((MaterialOptions)target); + } + public override void OnInspectorGUI() + { + MaterialOptions myScript = (MaterialOptions)target; + script = EditorGUILayout.ObjectField("Script: ", script, typeof(MonoScript), false) as MonoScript; + Undo.RecordObject( myScript, "material option"); + if (myScript.changeMesh != null) + { + foreach (MeshRenderer mr in myScript.changeMesh) + { + Undo.RecordObject(mr, "material option"); + } + } + + + + if (myScript.gameObject.activeInHierarchy) + { + if (myScript.displayOptions) + { + base.OnInspectorGUI(); + if (myScript.canOffset) + { + EditorGUILayout.LabelField("Offset Columns"); + myScript.offsetColumns = EditorGUILayout.IntSlider(myScript.offsetColumns, 1,10); + EditorGUILayout.LabelField("Offset Rows"); + myScript.offsetRows = EditorGUILayout.IntSlider(myScript.offsetRows, 1,10); + + } + } + else + { + if (GUILayout.Button("display options", GUILayout.Height(30))) myScript.displayOptions = true; + GUILayout.BeginHorizontal(); + if (GUILayout.Button("last Material", GUILayout.Height(30))) myScript.ChangeMaterial(false); + if (GUILayout.Button("next Material", GUILayout.Height(30))) myScript.ChangeMaterial(true); + GUILayout.EndHorizontal(); + if (myScript.canOffset) + { + GuiLayoutExtras.CenterLabel("Column: " + myScript.curColumn + " === Row: " + myScript.curRow, 25); + GuiLayoutExtras.CenterLabel("",5); + //GUILayout.Label("Columns: " + myScript.offsetColumns + "=== Rows: " + myScript.offsetRows); + GUILayout.BeginHorizontal(); + if (GUILayout.Button("<", GUILayout.Height(50))) myScript.SelectOffset(1); + GUILayout.BeginVertical(); + if (GUILayout.Button("^", GUILayout.Height(25))) myScript.SelectOffset(0); + if (GUILayout.Button("v", GUILayout.Height(25))) myScript.SelectOffset(3); + GUILayout.EndVertical(); + if (GUILayout.Button(">", GUILayout.Height(50))) myScript.SelectOffset(2); + GUILayout.EndHorizontal(); + } + } + } + + + + + } + } +} diff --git a/Scripts/Editor/SceneModifiers/MaterialOptionsEditor.cs.meta b/Scripts/Editor/SceneModifiers/MaterialOptionsEditor.cs.meta new file mode 100644 index 0000000..06907d0 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/MaterialOptionsEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8c6cd8935c54e60468d721ff3dfb984e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/SceneModifiers/SwitchChildMaterialsEditor.cs b/Scripts/Editor/SceneModifiers/SwitchChildMaterialsEditor.cs new file mode 100644 index 0000000..4963ecb --- /dev/null +++ b/Scripts/Editor/SceneModifiers/SwitchChildMaterialsEditor.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + [CustomEditor(typeof(SwitchChildMaterials), true)] + public class SwitchChildMaterialsEditor : Editor + { + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + GUILayout.BeginHorizontal("box"); + SwitchChildMaterials myScript = (SwitchChildMaterials)target; + if (GUILayout.Button("Set To Original Material", GUILayout.Height(30))) + { + myScript.SwitchToOriginalMaterial(); + } + if (GUILayout.Button("Set To Target Material", GUILayout.Height(30))) + { + myScript.SwitchToTargetMaterial(); + } + GUILayout.EndHorizontal(); + } + } +} diff --git a/Scripts/Editor/SceneModifiers/SwitchChildMaterialsEditor.cs.meta b/Scripts/Editor/SceneModifiers/SwitchChildMaterialsEditor.cs.meta new file mode 100644 index 0000000..7b45140 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/SwitchChildMaterialsEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7aff8e7143973e844a37ef6af62fb5c0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Editor/SceneModifiers/TurnChildGameObjectVisibilityEditor.cs b/Scripts/Editor/SceneModifiers/TurnChildGameObjectVisibilityEditor.cs new file mode 100644 index 0000000..f4caa33 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/TurnChildGameObjectVisibilityEditor.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + [CustomEditor(typeof(TurnChildGameObjectVisibility))] + public class TurnChildGameObjectVisibilityEditor : Editor + { + public override void OnInspectorGUI() + { + TurnChildGameObjectVisibility myScript = (TurnChildGameObjectVisibility) target; + //base.OnInspectorGUI(); + if (GUILayout.Button("Get Child GameObjects")) + myScript.GetFirstChildObjects(); + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Last Object")) + myScript.TurnNextObject(false); + if (GUILayout.Button("Next Object")) + myScript.TurnNextObject(true); + EditorGUILayout.EndHorizontal(); + } + } +} diff --git a/Scripts/Editor/SceneModifiers/TurnChildGameObjectVisibilityEditor.cs.meta b/Scripts/Editor/SceneModifiers/TurnChildGameObjectVisibilityEditor.cs.meta new file mode 100644 index 0000000..35a15a7 --- /dev/null +++ b/Scripts/Editor/SceneModifiers/TurnChildGameObjectVisibilityEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b4a5ea8f25f6dc344a3f7526b818e35b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter.meta b/Scripts/GLTFExporter.meta new file mode 100644 index 0000000..2212004 --- /dev/null +++ b/Scripts/GLTFExporter.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 50b329cf30b5a274288e6b12fcf2996f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/Examples.meta b/Scripts/GLTFExporter/Examples.meta new file mode 100644 index 0000000..cffaea7 --- /dev/null +++ b/Scripts/GLTFExporter/Examples.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1243a34347c83fa469723c92bec195e2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/Examples/simpleTriangle.bin b/Scripts/GLTFExporter/Examples/simpleTriangle.bin new file mode 100644 index 0000000..d642500 Binary files /dev/null and b/Scripts/GLTFExporter/Examples/simpleTriangle.bin differ diff --git a/Scripts/GLTFExporter/Examples/simpleTriangle.bin.meta b/Scripts/GLTFExporter/Examples/simpleTriangle.bin.meta new file mode 100644 index 0000000..ab61491 --- /dev/null +++ b/Scripts/GLTFExporter/Examples/simpleTriangle.bin.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: fb3956e773b233e4aa5d4cc23ec0d38d +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/Examples/simpleTriangle.gltf b/Scripts/GLTFExporter/Examples/simpleTriangle.gltf new file mode 100644 index 0000000..fe2c809 --- /dev/null +++ b/Scripts/GLTFExporter/Examples/simpleTriangle.gltf @@ -0,0 +1,74 @@ +{ + + + + + + + "buffers" : [ + { + "uri" : "simpleTriangle.bin", + "byteLength" : 44 + } + ], + "bufferViews" : [ + { + "buffer" : 0, + "byteOffset" : 0, + "byteLength" : 6, + "target" : 34963 + }, + { + "buffer" : 0, + "byteOffset" : 8, + "byteLength" : 36, + "target" : 34962 + } + ], + "accessors" : [ + { + "bufferView" : 0, + "byteOffset" : 0, + "componentType" : 5123, + "count" : 3, + "type" : "SCALAR", + "max" : [ 2 ], + "min" : [ 0 ] + }, + { + "bufferView" : 1, + "byteOffset" : 0, + "componentType" : 5126, + "count" : 3, + "type" : "VEC3", + "max" : [ 1.0, 1.0, 0.0 ], + "min" : [ 0.0, 0.0, 0.0 ] + } + ], + "meshes" : [ + { + "primitives" : [ + { + "attributes" : { + "POSITION" : 1 + }, + "indices" : 0 + } + ] + } + ], + "nodes" : [ + { + "mesh" : 0 + } + ], + "scene" : 0, + "scenes" : [ + { + "nodes" : [ 0 ] + } + ], + "asset" : { + "version" : "2.0" + } +} \ No newline at end of file diff --git a/Scripts/GLTFExporter/Examples/simpleTriangle.gltf.meta b/Scripts/GLTFExporter/Examples/simpleTriangle.gltf.meta new file mode 100644 index 0000000..cea3e14 --- /dev/null +++ b/Scripts/GLTFExporter/Examples/simpleTriangle.gltf.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bb27791f58bfb034c9be7608a98db7ef +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/Examples/simpleTriangle.json b/Scripts/GLTFExporter/Examples/simpleTriangle.json new file mode 100644 index 0000000..d947992 --- /dev/null +++ b/Scripts/GLTFExporter/Examples/simpleTriangle.json @@ -0,0 +1,68 @@ +{ + "buffers" : [ + { + "uri" : "simpleTriangle.bin", + "byteLength" : 44 + } + ], + "bufferViews" : [ + { + "buffer" : 0, + "byteOffset" : 0, + "byteLength" : 6, + "target" : 34963 + }, + { + "buffer" : 0, + "byteOffset" : 8, + "byteLength" : 36, + "target" : 34962 + } + ], + "accessors" : [ + { + "bufferView" : 0, + "byteOffset" : 0, + "componentType" : 5123, + "count" : 3, + "type" : "SCALAR", + "max" : [ 2 ], + "min" : [ 0 ] + }, + { + "bufferView" : 1, + "byteOffset" : 0, + "componentType" : 5126, + "count" : 3, + "type" : "VEC3", + "max" : [ 1.0, 1.0, 0.0 ], + "min" : [ 0.0, 0.0, 0.0 ] + } + ], + "meshes" : [ + { + "primitives" : [ + { + "attributes" : { + "POSITION" : 1 + }, + "indices" : 0 + } + ] + } + ], + "nodes" : [ + { + "mesh" : 0 + } + ], + "scene" : 0, + "scenes" : [ + { + "nodes" : [ 0 ] + } + ], + "asset" : { + "version" : "2.0" + } +} \ No newline at end of file diff --git a/Scripts/GLTFExporter/Examples/simpleTriangle.json.meta b/Scripts/GLTFExporter/Examples/simpleTriangle.json.meta new file mode 100644 index 0000000..d84bb6d --- /dev/null +++ b/Scripts/GLTFExporter/Examples/simpleTriangle.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e1ea94cc3db46e3408f474d75993017e +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/Examples/simpleTriangleUnderstand.bin b/Scripts/GLTFExporter/Examples/simpleTriangleUnderstand.bin new file mode 100644 index 0000000..281f02d --- /dev/null +++ b/Scripts/GLTFExporter/Examples/simpleTriangleUnderstand.bin @@ -0,0 +1,3 @@ +0000 0100 0200 indices (3 int indices) 0000 spacing 0000 0000 float x 0000 0000 float y +0000 0000 float z 0000 803f 0000 0000 0000 0000 +0000 0000 0000 803f 0000 0000 \ No newline at end of file diff --git a/Scripts/GLTFExporter/Examples/simpleTriangleUnderstand.bin.meta b/Scripts/GLTFExporter/Examples/simpleTriangleUnderstand.bin.meta new file mode 100644 index 0000000..194b4be --- /dev/null +++ b/Scripts/GLTFExporter/Examples/simpleTriangleUnderstand.bin.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 014897907664ba74d8bccd9f95e4bf52 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator.meta b/Scripts/GLTFExporter/GLTFGenerator.meta new file mode 100644 index 0000000..cd99ce6 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5b74ee731bf274c4ab6b2097ff84ff21 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/ExportOptions.meta b/Scripts/GLTFExporter/GLTFGenerator/ExportOptions.meta new file mode 100644 index 0000000..b5a99c8 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/ExportOptions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1299caa7b2edfd94b9af74febfad130f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/ExportOptions/SO_ExportGLTFOptions.cs b/Scripts/GLTFExporter/GLTFGenerator/ExportOptions/SO_ExportGLTFOptions.cs new file mode 100644 index 0000000..e0b05a4 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/ExportOptions/SO_ExportGLTFOptions.cs @@ -0,0 +1,91 @@ +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + [CreateAssetMenu(fileName = "gltf options", menuName = "ScriptableObjects/gltf options", order = 1)] + public class SO_ExportGLTFOptions : ScriptableObject + { + // GENERIC EXTRAS + // NODES - OPTIONS + public bool exportGameObjectName = true; + public bool exportMaterialName = true; + public bool exportTexturesName =true; + public bool exportCameras = true; + public bool exportInactive = true; + public bool exportGameObjectsTag =true; + public bool exportGameObjectsLayer = true; + public bool exportBatching = true; + public bool exportNavMesh = true; + public bool blockLeafNodesCreation = false; + + //ANIMATIONS + public bool exportAnimations = true; + + //MESH OPTIONS + public bool reduceGLTFChars = false; + public bool exportNormals =true; + public bool exportLightmapUVs = true; // NOT WORKING YET, RIGHT NOW IT WILL ALWAYS EXPORT LIGHTMAP UVS + public bool convertToGLB = false; // NOT WORKING YET. + public bool createUVOffsetExtras = false; // NOT WORKING YET: IF SET TO TRUE, FINAL SIZE WILL BE REDUCED, UVS WILL BE SAVED ONCE, AND OFFSET/SCALE WILL BE SAVED IN GLTF "EXTRAS" CODE FOR THREE JS GLTF IMPORTER TO USE + public bool exportSubmeshesInExtra = true; // SUBMESHES ARE EXPORTED SEPARATED IN CLASSIC GLTF, SHOULD BE EXPORTED COMBINED AND SAVE GROUPED POSITIONS + + //TEXTURES QUALITY + public float colorTextureSaturation = 0.8f; + public float metallicMultiplier = 0.8f; + public float smoothnessMultiplier = 0.8f; + public bool exportSeparatedAlphaMap = true; + public TextureExportType exportTextureType = TextureExportType.DEFAULT; + public bool fallbackGLTFTexture = false; // NEW 7/22/2021 + + public TextureDivideFactor allImagesDivideFactor = TextureDivideFactor.FULL; + public TextureDivideFactor overrideLightmapDivideFactor = TextureDivideFactor.NONE_SET; + public TextureDivideFactor overrideDefaultDivideFactor = TextureDivideFactor.NONE_SET; + public TextureDivideFactor overrideCubemapDivideFactor = TextureDivideFactor.NONE_SET; + public TextureDivideFactor overrideMetallicSmoothnessDivideFactor = TextureDivideFactor.NONE_SET; + public TextureDivideFactor overrideNormalDivideFactor = TextureDivideFactor.NONE_SET; + + public int allImagesQuality = 100; + public int overrideLightmapQuality; // SET 0 TO NOT OVERRIDE + public int overrideNormalQuality; + public int overrideMetallicSmoothnessQuality; + public int overrideCubemapQuality; + public int overrideDefaultQuality; + public TextureExportType overrideLightmapExportTextureType = TextureExportType.DEFAULT; + public TextureExportType overrideNormalExportTextureType = TextureExportType.NONE_SET; + public TextureExportType overrideMetallicSmoothnessExportTextureType = TextureExportType.NONE_SET; + public TextureExportType overrideDefaultExportTextureType = TextureExportType.NONE_SET; + public TextureExportType overrideCubemapTextureType = TextureExportType.NONE_SET; + + //LIGHTMAP OPTIONS + public float maxLightmapClamp = 5f; + public float saturationLightmap = 1f; + public bool whiteImageForNonStaticLightmaps = true; + public float lightmapIntensityMultiplier = 1f; + public float lightmapContrastCheat = 1f; + + //QUANTIZATION + public bool quantizeGLTF = false; + public ComponentTypeSelected quantizeMainUVsTo; + public ComponentTypeSelected quantizeLightUVsTo; + public ComponentTypeSelected quantizeVerticesTo; + public ComponentTypeSelected quantizeNormalsTo; + + // SCENE + public bool exportSceneSkyboxEnvironment = true; + public bool exportSceneSkyboxBackground = true; + public bool createCubeForSkybox = true; //will get deleted + //public GameObject cubeSkybox = null; + public int cubeSkyboxScale = 1; //1 = 1000 + public bool exportSceneSkyboxBackgroundEvenDefault = false; + public bool exportSceneFog = true; + //public Cubemap computedEnvironmentCubemap; + //public Cubemap computedBackgroundCubemap; + + public int overrideEnvironmentQuality = 0; + + //SET MAIN CAMERA + public bool extraExportMainCameraInGLTF = false; + //public int extraCameraIndex = -1; + + } +} \ No newline at end of file diff --git a/Scripts/GLTFExporter/GLTFGenerator/ExportOptions/SO_ExportGLTFOptions.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/ExportOptions/SO_ExportGLTFOptions.cs.meta new file mode 100644 index 0000000..69948bb --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/ExportOptions/SO_ExportGLTFOptions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b25f5645d64536f468fd3c03eece58ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/ExportToGLTF.cs b/Scripts/GLTFExporter/GLTFGenerator/ExportToGLTF.cs new file mode 100644 index 0000000..a6c8962 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/ExportToGLTF.cs @@ -0,0 +1,230 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using WEBGL_EXPORTER; +using WEBGL_EXPORTER.GLTF; +using UnityEditor; + +namespace WEBGL_EXPORTER.GLTF +{ + [ExecuteAlways] + public class ExportToGLTF + { + + public static CMDGenerator cmd; + public static ExportGLTFOptions options; + + public static void CallExportGLTF(string location, string gltfName, Transform transform_parent, ExportGLTFOptions export_options = null, bool resetLists= true, string optionalFolderCreateName = "", bool open_after_build = false) + { + RearrangeCameras(transform_parent); //cameras are rearranged in the final nodes to be the last siblings, not modifying them from here, results in having an offset in every object after the camera + if (resetLists) //USED IN AUTO CODE GENERATOR + ClearListsAndReset(); + cmd = new CMDGenerator(); + if (export_options != null) + options = export_options; + if (options == null) + options = new ExportGLTFOptions(); + + options.SetupTextureOverrides(); //MAKE SURE TO KNOW OVERRIDE OF EACH TEXTURE TYPE + + + + if (location == "") + location = Application.dataPath; + + string original_location = location; + if (optionalFolderCreateName != "") + location = FileExporter.CreateFolder(location + "/" + optionalFolderCreateName); + + options.exportLocation = location; + + //CUBE SKYBOX MAYBE IT WONT BE USED + if (options.createCubeForSkybox) + { + //BREAK IT FOR NOW, IT MIGHT NO LONGER BE USED + //CreateCubeSybox(transform_parent); + } + + //NODES + bool export_inactive = options.exportInactive; + Transform[] transform_childs = transform_parent.GetComponentsInChildren(export_inactive); + + for (int i = 0; i < transform_childs.Length; i++) + { + ObjectNodeMono _node = transform_childs[i].GetComponent(); + if (_node == null) + _node = transform_childs[i].gameObject.AddComponent(); + + if (!transform_childs[i].gameObject.activeSelf) + _node.SetupNode(false); // EXPORT HIDDEN OBJECTS + else + _node.SetupNode(); // EVERYTHING HAPPENS HERE + } + + + //SCENE + ObjectScene.SetupScene(); + + //ALL EXTRAS USED IN MONO + ObjectNodeUserExtrasMono[] extras_childs = transform_parent.GetComponentsInChildren(export_inactive); + for (int i =0; i < extras_childs.Length; i++) + { + ObjectNodeUserExtrasMono _node_extras = extras_childs[i]; + _node_extras.ResetComputedProperties(); + _node_extras.SetGLTFComputedData(); + _node_extras.CombineProperties(); + } + + //GENERATE NAVMESH HERE + if (options.exportNavMesh) + { + ObjectNodeMono.SetupNavMesh(transform_parent); + if (ObjectNodeMono.navMeshNode != -1) + { + ObjectMasterExtras.Add(new ObjectProperty("navMesh", ObjectNodeMono.navMeshNode)); + } + } + + // USER DEFINED MASTER EXTRAS + ObjectMasterUserExtrasMono user_extras_master = transform_parent.GetComponentInChildren(); + if (user_extras_master != null) + user_extras_master.AddPropertiesToMaster(); + ObjectMasterComputedExtrasMono computed_extras_master = transform_parent.GetComponentInChildren(); + if (computed_extras_master != null) + computed_extras_master.AddPropertiesToMaster(); + + // QUANTIZATION + if (options.quantizeGLTF && options.blockLeafNodesCreation == false) + CreateKHR_mesh_quantization(); + + if (location == "") + Debug.LogError("gltf folder already exists"); + else + SaveFiles(gltfName, location, open_after_build, original_location); + + if (options.cubeSkybox != null) + GameObject.DestroyImmediate(options.cubeSkybox); + } + + private static ObjectExtension CreateKHR_mesh_quantization() + { + ObjectExtension khr_mesh_quantization = new ObjectExtension("KHR_mesh_quantization", new List(), true); + return khr_mesh_quantization; + } + private static void CreateCubeSybox(Transform parent) + { + if (options.cubeSkybox == null) + options.cubeSkybox = (GameObject)GameObject.Instantiate(AssetDatabase.LoadAssetAtPath(PathPreferences.cubemapModelFBXRelativePath, typeof(GameObject))); + + options.cubeSkybox.transform.parent = parent; + options.cubeSkybox.name = "custom_skybox"; + options.cubeSkybox.transform.localScale = new Vector3(0.00001f, 0.00001f, 0.00001f); + } + private static void SaveFiles(string file_name, string file_location, bool open_after_build, string original_location) + { + ObjectAccessors.WriteToBinary(file_name, file_location); + WriteToGLTF(file_name, file_location); + if (open_after_build) + { + Application.OpenURL(file_location); + } + ExecuteCMD(file_name, file_location, open_after_build, original_location); + } + private static void RearrangeCameras(Transform targetTransform) + { + Camera [] childCams = targetTransform.GetComponentsInChildren(); + for (int i =0; i < childCams.Length; i++) + { + childCams[i].transform.SetAsLastSibling(); + } + } + public static void ExecuteCMD(string file_name, string file_location, bool open_after_build, string original_location) + { + // if export glb + // cmd.AddLine() gltf-pipeline -i C:/wamp64/www/web_models_3/3dmodels_3/casa_club_4/models/gltf.gltf -o C:/wamp64/www/web_models_3/3dmodels_3/casa_club_4/models/gltf.glb + + string explorer_location = ""; + string local_page_location = ""; + string model_id = ""; + string disc_route = ""; + if (open_after_build) + { + explorer_location = PathPreferences.chromeLocation; + disc_route = PathPreferences.localServerLocation.Split(':')[0] + ":\n"; + local_page_location = "localhost/" + original_location.Replace(PathPreferences.localServerLocation, "") + "/"; + model_id = StringUtilities.GetFolderNameFromSubfolder(file_location); + } + + string cmdLine = cmd.GetCommand(true, explorer_location, local_page_location, disc_route, model_id); + Debug.Log(cmdLine); + if (cmdLine != "") + { + //cmdLine = "TIMEOUT /T 1\n" + cmdLine; + string cmd_location = FileExporter.ExportToText(cmdLine, file_name, file_location, "cmd"); + Debug.Log(cmd_location); + Application.OpenURL(cmd_location); + } + } + private static void WriteToGLTF(string file_name, string file_location) + { + string result = "{\n"; + result += ObjectExtension.GetGLTFHeaderExtensionData(); + result += ObjectBuffer.GetGLTFData(file_name); + result += ObjectBufferView.GetGLTFData(); + result += ObjectAccessors.GetGLTFData(); + result += ObjectMesh.GetGLTFData(); + result += ObjectMaterial.GetGLTFData(); + result += ObjectSampler.GetGLTFData(); + result += ObjectTexture.GetGLTFData(); + ObjectExtrasCubeTextures.AddGLTFDataToExtras(); + result += ObjectImage.GetGLTFData(); + result += ObjectNodeMono.GetGLTFData(); + result += ObjectScene.GetGLTFData(); + result += ObjectCamera.GetGLTFData();//new + result += ObjectSkin.GetGLTFData(); + ObjectExtrasAnimationClip.AddGLTFDataToExtras(); + ObjectExtrasAnimationController.AddGLTFDataToExtras(); + ObjectExtensionOmiAudio.AddGLTFDataToExtensions(); + //OmiCollider is only present in nodes + result += ObjectMasterExtras.GetGLTFData();//new + result += ObjectExtension.GetGLTFData();//new + result += ObjectAsset.GetGLTFData(false) + "\n"; + result += "}"; + + if (options.reduceGLTFChars) + result = StringUtilities.RemoveExtraChars(result); + + FileExporter.ExportToText(result, file_name, file_location, "gltf"); + + List images_quality = options.GetImagesQuality(); + ObjectImage.ExportAllImages(file_location, images_quality[0], images_quality[1], images_quality[2], images_quality[3]); + ObjectExtensionOmiAudio.ExportAllAudios(file_location); + } + + + public static void ClearListsAndReset() + { + ObjectBuffer.Reset(); + ObjectBufferView.Reset(); + ObjectAccessors.Reset(); + ObjectMaterial.Reset(); + ObjectTexture.Reset(); + ObjectExtrasCubeTextures.Reset(); + ObjectSampler.Reset(); + ObjectImage.Reset(); + ObjectMesh.Reset(); + MeshHolder.Reset(); + UVVariant.Reset(); + ObjectSkin.Reset(); + ObjectScene.Reset(); + ObjectCamera.Reset();//new + ObjectExtrasAnimationClip.Reset(); + ObjectExtrasAnimationController.Reset(); + ObjectExtensionOmiAudio.Reset(); + ObjectMasterExtras.Reset();//new + ObjectExtension.Reset();//new + ObjectNodeMono.ResetValues(); + + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/ExportToGLTF.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/ExportToGLTF.cs.meta new file mode 100644 index 0000000..b338bbb --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/ExportToGLTF.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b85978170a532524e81428ed74e3e44c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects.meta new file mode 100644 index 0000000..a3e2c3c --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 63bd687d10cc8384cb8a5cc4b593273b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/CMDGenerator.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/CMDGenerator.cs new file mode 100644 index 0000000..2fc2004 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/CMDGenerator.cs @@ -0,0 +1,39 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class CMDGenerator + { + string command = ""; + string endCommand = ""; + public CMDGenerator() + { + + } + public void AddLine(string code) + { + command += code; + } + public void AddEndLine(string code) + { + endCommand += code; + } + public string GetCommand(bool delete_after = true, string explorer_location = "", string local_page_location = "", string disc_route = "", string model_id = "") + { + string result = command + endCommand; + + if (explorer_location != "") + { + result += disc_route + "\n"; + result += "cd \"" + StringUtilities.GetFolderNameFromFile(explorer_location) + "\"\n"; + result += StringUtilities.GetFileNameFromPath(explorer_location) + " " + local_page_location + "?id=" + model_id + "\n"; + } + if (delete_after) + result += "(goto) 2>nul & del \"%~f0\"\n"; + + return result; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/CMDGenerator.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/CMDGenerator.cs.meta new file mode 100644 index 0000000..c208a5d --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/CMDGenerator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 716c9d7683d07384893ee5328fcd6e13 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/GLTFEnums.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/GLTFEnums.cs new file mode 100644 index 0000000..0d33232 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/GLTFEnums.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public enum Target { NONE_SET = 0, ARRAY_BUFFER = 34962, ELEMENT_ARRAY_BUFFER = 34963 } + public enum ComponentType { NONE_SET = 0, BYTE = 5120, UNSIGNED_BYTE = 5121, SHORT = 5122, UNSIGNED_SHORT = 5123, UNSIGNED_INT = 5125, FLOAT = 5126 , BEST_INT = 1} + public enum ComponentTypeSelected {BYTE = 0, SHORT = 1 , FLOAT = 2 } + public enum Type { GET_FROM_BUFFER_VIEW, SCALAR, VEC2, VEC3, VEC4, MAT2, MAT3, MAT4 } + public enum TextureExportType {NONE_SET = -1,DEFAULT = 0, WEBP = 1, KTX2 =2} + public enum TextureType {DEFAULT = 0, NORMAL = 1, METALLIC_SMOOTHNESS = 2, LIGHTMAP = 3 , CUBEMAP = 4} + public enum SmartType { basic = 0, character = 1, space = 2, ui = 3 } + + public enum TextureDivideFactor { NONE_SET = -1, FULL = 1, HALF = 2, QUARTER = 4, EIGHT = 8, SIXTEENTH = 16 } + + //public enum ExportCubemapType { CUBEMAP = 0, REFLECTION_PROBE =1} + + +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/GLTFEnums.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/GLTFEnums.cs.meta new file mode 100644 index 0000000..b8032ae --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/GLTFEnums.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e6d9fe62bc1a1314cacdf8cc2bb672e7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/MeshHolder.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/MeshHolder.cs new file mode 100644 index 0000000..21107cc --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/MeshHolder.cs @@ -0,0 +1,268 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class MeshHolder + { + // consts + public bool supportsTransformExtension = false; + + // statics + public static List allMeshHolders; + + // vars + public Mesh baseMesh; + public List uv1Variant; // THE VARIANTS FOR THIS MESH, STORED IN A CUSTOM CLASS + public List uv2Variant; + + public bool hasUVs1; // DOES IT HAS PRIMARY UVS? + public bool hasUVs2; // DOES IT HAS LIGHTMAP UVS? + + public Vector2[] uvs; // PRIMARY UVS INFORMATION IN CASE THEY EXIST + public Vector2[] uvs2; // LIGHTMAP UVS INFORMATION IN CASE THEY EXIST + + public int subMeshCount; //HOW MANY SUBMESHES THIS MESH HAS? + + // FOR CUSTOM EXTRAS (COMBINED MESHES) + public int[] subMeshStart; + public int[] subMeshSize; + + + // BASE INFORMATION OF THE MESH, THIS INFORMATION FOR NOW, IS CONSTANT + public List accessorIndices; + public ObjectAccessors accessorNormals; + public ObjectAccessors accessorVertices; + + // FOR SKINNED MESH ONLY + public ObjectAccessors accessorWeights; + public ObjectAccessors accessorJoints; + + // SAVE ONLY IF EXTENSION IS SUPPORTED + public ObjectAccessors accessorUVs1; + public ObjectAccessors accessorUVs2; + + + public static void Reset() + { + allMeshHolders = new List(); + } + public static MeshHolder GetMeshHolder(Mesh mesh, bool is_skinned = false) + { + foreach (MeshHolder mh in allMeshHolders) + { + if (mh.baseMesh == mesh) + return mh; + } + // IF NO MESH HOLDER WAS FOUND, ADD A NEW ONE TO THE LIST + MeshHolder _newMeshHolder = new MeshHolder(mesh, is_skinned); + allMeshHolders.Add(_newMeshHolder); + return _newMeshHolder; + } + + public MeshHolder(Mesh mesh, bool is_skinned) + { + subMeshCount = mesh.subMeshCount; + baseMesh = mesh; + // IMPORTANT, THESE LISTS ARE STORED IN OBJECT MESH WITH GETUVSLOCALINDEX() ~ MAIN UVS OR ADDUVSAUTO()~LIGHTMAP UVS + uv1Variant = new List(); + uv2Variant = new List(); + + accessorIndices = new List(); + //SUBMESH GLTF SEPARATED (CLASSIC MODE) + if (!ExportToGLTF.options.exportSubmeshesInExtra) + { + for (int i = 0; i < baseMesh.subMeshCount; i++) + { + int[] _indices = baseMesh.GetIndices(i); + int[] _inv_indices = new int[_indices.Length]; + for (int j = 0; j < _inv_indices.Length; j++) + { + _inv_indices[j] = _indices[_inv_indices.Length - j - 1]; + } + accessorIndices.Add(new ObjectAccessors(_inv_indices, true, true, "indices")); + } + } + //END SUBMESH GLTF SEPARATED (CLASSIC MODE) + //SUBMESH COMBINED GLTF (CUSTOM EXTRA MODE) + else + { + if (baseMesh.subMeshCount > 1) + { + subMeshStart = new int[baseMesh.subMeshCount]; + subMeshSize = new int[baseMesh.subMeshCount]; + } + + List _indices = new List(); + int counter = 0; + for (int i = 0; i < baseMesh.subMeshCount; i++) + { + if (baseMesh.subMeshCount > 1) //SINCE WE ARE INVERTING INDICES, THIS ONE HAS TO BE ALSO INVERTED + { + subMeshStart[i] = counter; + int submesh_size = baseMesh.GetIndices(baseMesh.subMeshCount - 1 - i).Length; + subMeshSize[i] = submesh_size; + counter += submesh_size; + } + _indices.AddRange(baseMesh.GetIndices(i)); + + } + int[] _inv_indices = new int[_indices.Count]; + for (int i = 0; i < _inv_indices.Length; i++) + { + _inv_indices[i] = _indices[_inv_indices.Length - i - 1]; + } + accessorIndices.Add(new ObjectAccessors(_inv_indices, true, true, "indices")); + } + //END SUBMESH COMBINED GLTF (CUSTOM EXTRA MODE) + if (is_skinned) + { + accessorJoints = new ObjectAccessors(GetBoneIndexArray(baseMesh.boneWeights),"joints"); + accessorWeights = new ObjectAccessors(GetBoneWeightArray(baseMesh.boneWeights), new Vector4(1f, 1f, 1f, 1f), false, "weights",ComponentType.FLOAT,false); + } + if (!ExportToGLTF.options.quantizeGLTF) + { + accessorVertices = new ObjectAccessors(baseMesh.vertices, new Vector3(1,1,-1), true, "vertices"); + + if (baseMesh.normals.Length > 0 && ExportToGLTF.options.exportNormals) + accessorNormals = new ObjectAccessors(baseMesh.normals, new Vector3(1, 1, -1), false, "normals"); + } + else + { + accessorVertices = new ObjectAccessors(baseMesh.vertices, new Vector3(1, 1, -1), true, "vertices", ExportGLTFOptions.GetComponentType(ExportToGLTF.options.quantizeVerticesTo), true); + + if (baseMesh.normals.Length > 0 && ExportToGLTF.options.exportNormals) + accessorNormals = new ObjectAccessors(baseMesh.normals, new Vector3(1, 1, -1), false, "normals", ExportGLTFOptions.GetComponentType(ExportToGLTF.options.quantizeNormalsTo,true), false); + } + + if (mesh.uv.Length > 0) + { + hasUVs1 = true; + uvs = mesh.uv; + if (ExportToGLTF.options.createUVOffsetExtras) + accessorUVs1 = CreateUVsBasicAccessor(uvs,"uvs_1"); + //accessorUVs1 = new ObjectAccessors(uvs,false,false,"uvs_1"); + } + else + { + Debug.Log("has no uvs"); + hasUVs1 = false; + } + + if (mesh.uv2.Length > 0) + { + hasUVs2 = true; + uvs2 = mesh.uv2; + if (ExportToGLTF.options.createUVOffsetExtras) + accessorUVs2 = CreateUVsBasicAccessor(uvs2, "uvs_2"); + //accessorUVs2 = new ObjectAccessors(uvs2,false,false,"uvs_2"); + } + else + { + hasUVs2 = false; + } + } + + private Vector4[] GetBoneIndexArray(BoneWeight[] bones_weights) + { + Vector4[] result = new Vector4[bones_weights.Length]; + for (int i = 0; i < result.Length; i++) + { + result[i] = new Vector4(bones_weights[i].boneIndex0, + bones_weights[i].boneIndex1, + bones_weights[i].boneIndex2, + bones_weights[i].boneIndex3); + } + return result; + } + private Vector4[] GetBoneWeightArray(BoneWeight[] bones_weights) + { + Vector4[] result = new Vector4[bones_weights.Length]; + + for (int i =0; i < result.Length; i++) + { + //Debug.Log("new"); + result[i] = new Vector4(bones_weights[i].weight0, + bones_weights[i].weight1, + bones_weights[i].weight2, + bones_weights[i].weight3); + } + return result; + } + + public ObjectAccessors CreateUVsBasicAccessor(Vector2[] uvs, string optional_identifier = "") //FUNCTION WILL BE USED WHEN MESH TRANSFORM EXSTRAS IS SUPPORTED + { + + if (!ExportToGLTF.options.quantizeGLTF) + { + return new ObjectAccessors(uvs, false, optional_identifier); + } + else + { + if (optional_identifier == "uvs_2") + return new ObjectAccessors(uvs, false, optional_identifier, ExportGLTFOptions.GetComponentType(ExportToGLTF.options.quantizeLightUVsTo), false); + return new ObjectAccessors(uvs, false, optional_identifier, ExportGLTFOptions.GetComponentType(ExportToGLTF.options.quantizeMainUVsTo) , false); + } + } + + public UVVariant GetUVsLocalIndex(Vector2 offsetUVs, Vector2 scale_uvs) // FOR MAIN UVS ONLY + { + if (hasUVs1) // CHECK IF WE HAVE MAIN UVS!, IF NOT RETURN NULL!! + { + for (int i = 0; i < uv1Variant.Count; i++) + { + if (uv1Variant[i].offsetUVs == offsetUVs && uv1Variant[i].scaleUVs == scale_uvs) + { + return uv1Variant[i]; + } + } + // IF NO SAME UVVARIANT WAS FOUND, RETURN A NEW UVVARIANT + UVVariant newVariant = new UVVariant(offsetUVs, scale_uvs); + uv1Variant.Add(newVariant); + if (!ExportToGLTF.options.createUVOffsetExtras && hasUVs1) // IF WE CANT TRANSFORM VERTICES WITH CODE IN GLTF, WE MUST STORE NEW ACCESSORS + newVariant.CreateObjectAccessor(uvs, true, "uvs_1"); // IF NO UVS ARE FOUND, WE DONT SAVE THE ACCESSOR + + return newVariant; + } + else + { + return null; + } + } + public UVVariant AddUVsAuto(Vector2 offsetUVs, Vector2 scale_uvs, Vector2? offset_orig = null, Vector2? scale_orig = null) // FOR LIGHTMAPS ONLY + { + + if (!hasUVs2 && hasUVs1 && offset_orig != null && scale_orig != null) + { + //Debug.Log(offset_orig.Value.x); + //offsetUVs = new Vector2((offsetUVs.x - offset_orig.Value.x),(offsetUVs.y - offset_orig.Value.y)); + //scale_uvs = new Vector2((scale_uvs.x * scale_orig.Value.x), (scale_uvs.y * scale_orig.Value.y)); + } + UVVariant newVariant = new UVVariant(offsetUVs, scale_uvs); + uv2Variant.Add(newVariant); + if (!ExportToGLTF.options.createUVOffsetExtras) // IF WE CANT TRANSFORM VERTICES WITH CODE IN GLTF, WE MUST STORE NEW ACCESSORS + { + if (hasUVs2) + { + newVariant.CreateObjectAccessor(uvs2, true, "uvs_2"); + } + else if (hasUVs1) + { + Debug.Log("no uvs 2 taking uvs 1"); + newVariant.CreateObjectAccessor(uvs, true, "uvs_2", offset_orig, scale_orig); //IF WE DONT HAVE SECONDARY UVS, UNITY USES THE MAIN UVS AS LIGHTMAP UVS + } + } + + return newVariant; + } + public static bool IsSameUVs(UVVariant uvvar, Vector2 offset_uvs, Vector2 scale_uvs) + { + if (uvvar.offsetUVs == offset_uvs && uvvar.scaleUVs == scale_uvs) + return true; + return false; + } + + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/MeshHolder.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/MeshHolder.cs.meta new file mode 100644 index 0000000..a634723 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/MeshHolder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7ad0da33b9ac54e41be59eb351f2acce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras.meta new file mode 100644 index 0000000..a1bb116 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 649857167d52f8f4e96c5073f7440735 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeKeepMat.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeKeepMat.cs new file mode 100644 index 0000000..99f241d --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeKeepMat.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectNodeKeepMat : ObjectNodeUserExtrasMono + { + // Start is called before the first frame update + public bool changeChilds = true; + private void OnEnable() + { + displayOptions = false; + extrasName = "keepMat"; + tooltip = "keepMat will tell three js which materials are more important than others.\n\nWhen optimizing a scene in web, materials will be reduced to basic materials, except those selected with this component"; + } + + public override void SetGLTFComputedData() + { + if (!changeChilds) + { + AddProperty(new ObjectProperty("changeChilds", changeChilds)); + } + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeKeepMat.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeKeepMat.cs.meta new file mode 100644 index 0000000..9658852 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeKeepMat.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0fda4b98d525bde4b9290df9f092bd36 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMergeChilds.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMergeChilds.cs new file mode 100644 index 0000000..5f674d3 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMergeChilds.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + + public class ObjectNodeMergeChilds : ObjectNodeUserExtrasMono + { + private void OnEnable() + { + displayOptions = false; + extrasName = "mergeChilds"; + tooltip = "mergeChilds will always merge the children that share the same material and that are marked as static. \n\nThis helps reduce drawcalls and optimize web performance \n\nWarning: combining childs will remove any object/action from any of its childs"; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMergeChilds.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMergeChilds.cs.meta new file mode 100644 index 0000000..d17ab12 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMergeChilds.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1e60bd4bcb15f7246a4efa5f151bee80 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMirror.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMirror.cs new file mode 100644 index 0000000..44a8c9b --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMirror.cs @@ -0,0 +1,52 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectNodeMirror : ObjectNodeUserExtrasMono + { + public ReflectionProbe mirrorReflectionProbe; + public int mirrorQuality = 70; + const string texturePreName = "mirr_"; + + private void Reset() + { + displayOptions = false; + extrasName = "mirror"; + if (mirrorReflectionProbe != null) + { + //this.AddProperty(); + } + + tooltip = "Mirror will reflect objects in front of this mesh, make sure red line is facing forward, and that this object is assigned to an object with mesh component. \n\nMirrors are expensive, dont use many"; + } + public override void SetGLTFComputedData() + { + //if (optionalIdentifier == -1) // FIRST TIME ONLY, ASSIGN MIRRORS ID + //{ + // int counter = 0; + // ObjectNodeMirror[] mirrors = transform.root.GetComponentsInChildren(); + // foreach (ObjectNodeMirror om in mirrors) + // { + // om.optionalIdentifier = counter; + // counter++; + // } + //} + if (mirrorReflectionProbe != null) + { + int _cubemap_index = ObjectExtrasCubeTextures.GetCubemapIndex(mirrorReflectionProbe.bakedTexture as Cubemap, mirrorQuality); + AddProperty(new ObjectProperty("envMap", _cubemap_index)); + } + } + void OnDrawGizmos() + { + + // Draws a blue line from this transform to the target + Gizmos.color = Color.red; + Vector3 direction = transform.TransformDirection(Vector3.forward) * -2; + Gizmos.DrawRay(transform.position, direction); + + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMirror.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMirror.cs.meta new file mode 100644 index 0000000..52de68b --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeMirror.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: da76ffc7bb7d3964daf1f46d2d198496 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTeleport.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTeleport.cs new file mode 100644 index 0000000..ab97e75 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTeleport.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectNodeTeleport : ObjectNodeUserExtrasMono + { + // Start is called before the first frame update + private void OnEnable() + { + displayOptions = false; + extrasName = "teleport"; + tooltip = "Teleports user on VR click"; + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTeleport.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTeleport.cs.meta new file mode 100644 index 0000000..7aa94be --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTeleport.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3d6afae564abc02449ad94f583cf4976 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTextContainer.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTextContainer.cs new file mode 100644 index 0000000..c771810 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTextContainer.cs @@ -0,0 +1,94 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectNodeTextContainer : ObjectNodeUserExtrasMono + { + public enum JustifyContent { center = 0, start = 1, end = 2} + public enum AlignContent { center = 0, right = 1 , left = 2} + + public JustifyContent justifyContent = JustifyContent.center; + public AlignContent alignContent = AlignContent.left; + + public float padding = 0.02f; + public float width = 0.1f; + public float height = 0.1f; + + public float fontSize = 0.075f; + + public string textContent = ""; + private void Reset() + { + displayOptions = false; + extrasName = "textContainer"; + + tooltip = "text container will ignore the mesh, width and height must be provided to get the desired size, dor now default font will be used"; + } + + public override void SetGLTFComputedData() + { + Debug.Log(width); + AddProperty(new ObjectProperty("width", width)); + AddProperty(new ObjectProperty("height", height)); + AddProperty(new ObjectProperty("padding", padding)); + AddProperty(new ObjectProperty("justifyContent", justifyContent.ToString())); + AddProperty(new ObjectProperty("alignContent", alignContent.ToString())); + AddProperty(new ObjectProperty("fontSize", fontSize)); + AddProperty(new ObjectProperty("textContent", textContent)); + } + + void OnDrawGizmos() + { + + // Square + Gizmos.color = Color.red; + Vector3 direction = transform.TransformDirection(Vector3.forward) * -.1f; + + Gizmos.DrawLine(new Vector3(transform.position.x - width / 2f, transform.position.y - height / 2f, transform.position.z), + new Vector3(transform.position.x - width / 2f, transform.position.y + height / 2f, transform.position.z)); + + Gizmos.DrawLine(new Vector3(transform.position.x + width / 2f, transform.position.y - height / 2f, transform.position.z), + new Vector3(transform.position.x + width / 2f, transform.position.y + height / 2f, transform.position.z)); + + Gizmos.DrawLine(new Vector3(transform.position.x - width / 2f, transform.position.y + height / 2f, transform.position.z), + new Vector3(transform.position.x + width / 2f, transform.position.y + height / 2f, transform.position.z)); + + Gizmos.DrawLine(new Vector3(transform.position.x - width / 2f, transform.position.y - height / 2f, transform.position.z), + new Vector3(transform.position.x + width / 2f, transform.position.y - height / 2f, transform.position.z)); + + // Direction + Gizmos.color = Color.yellow; + Gizmos.DrawRay(transform.position, direction); + + // Font Size + Gizmos.color = Color.blue; + float xMove = 0f; + switch (alignContent) + { + case AlignContent.left: + xMove = -(width / 2)+padding; + break; + case AlignContent.right: + xMove = (width / 2)-padding; + break; + } + float yMove = 0f; + switch (justifyContent) + { + case JustifyContent.start: + //yMove = (height / 2) - fontSize; + yMove = (height/2) - (fontSize/2)-padding; + break; + case JustifyContent.end: + yMove = -(height / 2) + (fontSize / 2) + padding; + break; + } + + Gizmos.DrawLine(new Vector3(transform.position.x + xMove, (transform.position.y + fontSize / 2f) + yMove, transform.position.z), + new Vector3(transform.position.x + xMove, (transform.position.y - fontSize / 2f) + yMove, transform.position.z)); + + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTextContainer.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTextContainer.cs.meta new file mode 100644 index 0000000..c6eab31 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/NodeExtras/ObjectNodeTextContainer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c9ad988ee9bc5754d8aa83c35d93bda6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAccessors.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAccessors.cs new file mode 100644 index 0000000..7d7bafc --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAccessors.cs @@ -0,0 +1,946 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectAccessors + { + //statics + public static int globalIndex = -1; + public static List allUniqueAccessors; + public static List sortedAccessorsList; + public static bool sortedElements = false; + + //vars + //on creation + public int start_index = -1; + public ComponentType componentType; + public Type type; + public Min_Max min_max; + //public Min_Max min_max_quantization; + public float[] quantization_scale; + public float[] quantization_offset; + public bool isQuantized = false; + string optionaIdentifier = ""; + + //type of information + int[] scalarInt; + float[] scalarFloat; + Vector2[] vector2Info; + Vector3[] vector3Info; + Vector4[] vector4Info; + + Matrix4x4[] matrix4Info; + + public int export_index = -1; + public ObjectBufferView bufferView; + public int byteSize; + public int byteOffset; + + public bool normalized = false; + public int accessorCount = 0; + + //sparse not supported atm + + public static void Reset() + { + globalIndex = 0; + allUniqueAccessors = new List(); + sortedAccessorsList = new List(); + sortedElements = false; + } + + // ACCESSORS CREATION + public ObjectAccessors(int[] int_values, bool req_min_max = false, bool unsigned = true, string optional_identifier = "") + {// + start_index = globalIndex; + scalarInt = int_values; + + + Min_Max min_max_info = new Min_Max(int_values); + type = Type.SCALAR; + if (req_min_max) + min_max = min_max_info; + + if (Mathf.RoundToInt(min_max_info.max[0]) < 255) + { + byteSize = int_values.Length; // UNSIGNED BYTES REQUIRE 1 BYTES EACH + if (unsigned) + componentType = ComponentType.UNSIGNED_BYTE; + else + componentType = ComponentType.BYTE; + } + else if (Mathf.RoundToInt(min_max_info.max[0]) < 65535) + { + byteSize = int_values.Length * 2; // UNSIGNED SHORT REQUIRE 2 BYTES EACH + if (unsigned) + componentType = ComponentType.UNSIGNED_SHORT; + else + componentType = ComponentType.SHORT; + } + else + { + Debug.LogError("Mesh indices are above 65535, errors will occur, please reduce mesh size in 3d application"); + byteSize = int_values.Length * 4; // UNSIGNED INT REQUIRE 4 BYTES EACH + if (unsigned) + componentType = ComponentType.UNSIGNED_INT; + else + componentType = ComponentType.FLOAT; + } + + optionaIdentifier = optional_identifier; + accessorCount = int_values.Length; + + allUniqueAccessors.Add(this); + globalIndex++; + } + public ObjectAccessors(float[] float_values, bool req_min_max = false, string optional_identifier = "") + { + start_index = globalIndex; + scalarFloat = float_values; + byteSize = float_values.Length * 4; // FLOAT REQUIRE 4 BYTES + + componentType = ComponentType.FLOAT; + type = Type.SCALAR; + if (req_min_max) + min_max = new Min_Max(float_values); + optionaIdentifier = optional_identifier; + normalized = false; + accessorCount = float_values.Length; + + allUniqueAccessors.Add(this); + globalIndex++; + } + public ObjectAccessors(Vector2[] v2_values, bool req_min_max = false, string optional_identifier = "", ComponentType quantize_type = ComponentType.NONE_SET, bool quantize_change_values = true) + { + start_index = globalIndex; + Min_Max min_max_quantization = new Min_Max(v2_values); + vector2Info = new Vector2[v2_values.Length]; + bool _saved = false; + + if (quantize_type != ComponentType.NONE_SET && quantize_type != ComponentType.FLOAT) + { + // VALUES IN QUANTIZATION MUTS BE NORMALIZED + if (quantize_change_values == true) + { + // DO IT NO MATTER ANYTHING + componentType = quantize_type; + for (int i = 0; i < vector2Info.Length; i++) + { + vector2Info[i] = new Vector2(GetQuantizeVal(v2_values[i].x, min_max_quantization.min[0], min_max_quantization.max[0], quantize_type, true), + GetQuantizeVal(v2_values[i].y, min_max_quantization.min[1], min_max_quantization.max[1], quantize_type, true)); + } + // SAVE THE SCALE AND OFFSET VALUES FOR DECOMPRESSION + quantization_scale = min_max_quantization.GetQuantizationScale(); + quantization_offset = min_max_quantization.GetQuantizationOffset(); + _saved = true; + } + // IF VALUES HAVENT BEEN SAVED THEN: + if (!_saved) + { + // IF COMPONENT TYPE IS USHORT/UBYTE, MAKE SURE MAX RANGE VALUE IS 1 + if (quantize_type == ComponentType.UNSIGNED_BYTE || quantize_type == ComponentType.UNSIGNED_SHORT) + { + if (min_max_quantization.GetQuantizationScale()[0] <= 1 && min_max_quantization.GetQuantizationScale()[1] <= 1) + { + for (int i = 0; i < vector2Info.Length; i++) //SAVE IT AS GIVEN NORMALIZED FROM 0 TO 1 + { + float _xval = v2_values[i].x - Mathf.FloorToInt(min_max_quantization.GetQuantizationOffset()[0]); // MAKE SURE VALUE GO FROM 0 TO 1 + float _yval = v2_values[i].y - Mathf.FloorToInt(min_max_quantization.GetQuantizationOffset()[1]); + vector2Info[i] = new Vector2(GetQuantizeVal(_xval, 0, 1, quantize_type, false), + GetQuantizeVal(_yval, 0, 1, quantize_type, false)); + + } + + _saved = true; + } + } + + // IF COMPONENT TYPE IS SHORT/BYTE, MAKE SURE MAX RANGE VALUE IS 2 + if (quantize_type == ComponentType.BYTE || quantize_type == ComponentType.SHORT) + { + if (min_max_quantization.GetQuantizationScale()[0] <= 2 && min_max_quantization.GetQuantizationScale()[1] <= 2) + { + // TO DO... SAVE VALUES FROM -1 TO 1 + } + } + + } + + if (_saved) // IF UP TO HERE, VALUES WERE SAVED, STORE THE ADDITIONAL QUANTIZATION DATA NEEDED. + { + //BYTE SIZE IS SAVED LIKE THIS, SINCE NO 4 BOUNDARIES IN VECTOR2 IS NECESSARY + if (quantize_type == ComponentType.UNSIGNED_BYTE) + byteSize = v2_values.Length * 2; + if (quantize_type == ComponentType.UNSIGNED_SHORT) + byteSize = v2_values.Length * 4; + + componentType = quantize_type; + normalized = true; + isQuantized = true; + } + } + + if (!_saved) // IF UP TO HERE NO DATA WAS SAVED, THEN STORE FLOAT VECTOR2 + { + vector2Info = v2_values; + byteSize = v2_values.Length * 8; // VECTOR 2 REQUIRE 2 FLOAT (4 BYTES EACH) 2*4=8 + componentType = ComponentType.FLOAT; + normalized = false; + + } + + if (req_min_max) + min_max = new Min_Max(vector2Info); + type = Type.VEC2; + optionaIdentifier = optional_identifier; + accessorCount = v2_values.Length; + allUniqueAccessors.Add(this); + globalIndex++; + } + + public ObjectAccessors(Vector3[] v3_values, Vector3 v3_modifier, bool req_min_max = false, string optional_identifier = "", ComponentType quantize_type = ComponentType.NONE_SET, bool quantize_change_values = true) + { + start_index = globalIndex; + Min_Max min_max_quantization = new Min_Max(v3_values, v3_modifier); + vector3Info = new Vector3[v3_values.Length]; + bool _saved = false; + + if (quantize_type != ComponentType.NONE_SET && quantize_type != ComponentType.FLOAT) + { + if (quantize_change_values) + { + for (int i = 0; i < vector3Info.Length; i++) + { + vector3Info[i] = new Vector3(GetQuantizeVal(v3_values[i].x * v3_modifier.x, min_max_quantization.min[0], min_max_quantization.max[0], quantize_type, true), + GetQuantizeVal(v3_values[i].y * v3_modifier.y, min_max_quantization.min[1], min_max_quantization.max[1], quantize_type, true), + GetQuantizeVal(v3_values[i].z * v3_modifier.z, min_max_quantization.min[2], min_max_quantization.max[2], quantize_type, true)); + } + // SAVE THE SCALE AND OFFSET VALUES FOR DECOMPRESSION + quantization_scale = min_max_quantization.GetQuantizationScale(); + quantization_offset = min_max_quantization.GetQuantizationOffset(); + _saved = true; + } + + if (!_saved) + { + // IF COMPONENT TYPE IS USHORT/UBYTE, MAKE SURE MAX RANGE VALUE IS 1 + if (quantize_type == ComponentType.UNSIGNED_BYTE || quantize_type == ComponentType.UNSIGNED_SHORT) + { + if (min_max_quantization.GetQuantizationScale()[0] <= 1 && min_max_quantization.GetQuantizationScale()[1] <= 1) + { + for (int i = 0; i < vector3Info.Length; i++) //SAVE IT AS GIVEN NORMALIZED FROM 0 TO 1 + { + float _xval = (v3_values[i].x * v3_modifier.x) - Mathf.FloorToInt(min_max_quantization.GetQuantizationOffset()[0]); // MAKE SURE VALUE GO FROM 0 TO 1 + float _yval = (v3_values[i].y * v3_modifier.y) - Mathf.FloorToInt(min_max_quantization.GetQuantizationOffset()[1]); + float _zval = (v3_values[i].z * v3_modifier.z) - Mathf.FloorToInt(min_max_quantization.GetQuantizationOffset()[2]); + vector3Info[i] = new Vector3(GetQuantizeVal(_xval, 0, 1, quantize_type, false), + GetQuantizeVal(_yval, 0, 1, quantize_type, false), + GetQuantizeVal(_zval, 0, 1, quantize_type, false)); + + } + _saved = true; + } + } + + // IF COMPONENT TYPE IS SHORT/BYTE, MAKE SURE MAX RANGE VALUE IS 2 + if (quantize_type == ComponentType.BYTE || quantize_type == ComponentType.SHORT) + { + //if (min_max_quantization.GetQuantizationScale()[0] <= 2 && min_max_quantization.GetQuantizationScale()[1] <= 2) + //{ + for (int i = 0; i < vector3Info.Length; i++) //SAVE IT AS GIVEN NORMALIZED FROM 0 TO 1 + { + // TO DO... CHECK IF VALUES ARE FROM -1 TO 1 + vector3Info[i] = new Vector3(GetQuantizeVal(v3_values[i].x * v3_modifier.x, 0, 1, quantize_type, false), + GetQuantizeVal(v3_values[i].y * v3_modifier.y, 0, 1, quantize_type, false), + GetQuantizeVal(v3_values[i].z * v3_modifier.z, 0, 1, quantize_type, false)); + } + _saved = true; + //} + } + } + if (_saved) // IF UP TO HERE, VALUES WERE SAVED, STORE THE ADDITIONAL QUANTIZATION DATA NEEDED. + { + componentType = quantize_type; + byteSize = v3_values.Length * GetByteSize(quantize_type, 3); + normalized = true; + isQuantized = true; + } + } + + if (!_saved) + { + for (int i =0; i < vector3Info.Length; i++) + { + vector3Info[i] = new Vector3(v3_values[i].x * v3_modifier.x, v3_values[i].y * v3_modifier.y, v3_values[i].z * v3_modifier.z); + } + byteSize = v3_values.Length * 12; // VECTOR 3 REQUIRE 3 FLOAT (4 BYTES EACH) 3*4=12 + componentType = ComponentType.FLOAT; + normalized = false; + } + + + if (req_min_max) + min_max = new Min_Max(vector3Info, new Vector3(1,1,1)); // it no longer requires modifier, their values were modified previously + + type = Type.VEC3; + optionaIdentifier = optional_identifier; + accessorCount = v3_values.Length; + allUniqueAccessors.Add(this); + globalIndex++; + + //if (quantize_type == ComponentType.NONE_SET || quantize_type == ComponentType.FLOAT) + //{ // NON QUANTIZED VALUES + // vector3Info = v3_values; + // byteSize = v3_values.Length * 12; // VECTOR 3 REQUIRE 3 FLOAT (4 BYTES EACH) 3*4=12 + // componentType = ComponentType.FLOAT; + // normalized = false; + //} + //else + //{ // QUANTIZED VALUES + // vector3Info = new Vector3[v3_values.Length]; + // Min_Max min_max_quantization = new Min_Max(v3_values); // SAVE ORIGINAL VALUES + // for (int i =0; i < vector3Info.Length; i++) + // { + // vector3Info[i] = new Vector3(GetQuantizeVal(v3_values[i].x, min_max_quantization.min[0], min_max_quantization.max[0], quantize_type, quantize_change_values), + // GetQuantizeVal(v3_values[i].y, min_max_quantization.min[1], min_max_quantization.max[1], quantize_type, quantize_change_values), + // GetQuantizeVal(v3_values[i].z, min_max_quantization.min[2], min_max_quantization.max[2], quantize_type, quantize_change_values)); + // } + // if (quantize_change_values) + // { + // quantization_scale = min_max_quantization.GetQuantizationScale(); + // quantization_offset = min_max_quantization.GetQuantizationOffset(); + // } + // byteSize = v3_values.Length * GetByteSize(quantize_type, 3); + // componentType = quantize_type; + // normalized = true; + // isQuantized = true; + //} + //if (req_min_max) + // min_max = new Min_Max(vector3Info); + //type = Type.VEC3; + + //optionaIdentifier = optional_identifier; + + //accessorCount = v3_values.Length; + + //allUniqueAccessors.Add(this); + //globalIndex++; + } + //END ACCESSOR CREATION + // VECTOR 4 AS INT + public ObjectAccessors(Vector4[] v4_values, string optional_identifier = "", ComponentType component_type = ComponentType.BEST_INT) + { + start_index = globalIndex; + Min_Max min_max = new Min_Max(v4_values, new Vector4(1f, 1f, 1f, 1f)); + vector4Info = new Vector4[v4_values.Length]; + + + // SAVE VALUE AS IT IS! + if (IsIntType(component_type)) + { + Debug.Log("alskjndlkas"); + for (int i = 0; i < v4_values.Length; i++) + { + + vector4Info[i] = new Vector4(v4_values[i].x, + v4_values[i].y, + v4_values[i].z, + v4_values[i].w); + Debug.Log(vector4Info[i].x); + //Debug.Log(vector4Info[i]); + } + + if (component_type == ComponentType.BEST_INT) componentType = GetBestInt(min_max.GetMinValueFromVectors(), min_max.GetMaxValueFromVectors()); + else componentType = component_type; + + //Debug.Log(componentType); + byteSize = v4_values.Length * GetByteSize(componentType, 4); + normalized = false; + isQuantized = false; + + } + + type = Type.VEC4; + optionaIdentifier = optional_identifier; + accessorCount = v4_values.Length; + allUniqueAccessors.Add(this); + globalIndex++; + + } + // VECTOR 4 AS FLOAT + public ObjectAccessors(Vector4[] v4_values, Vector4 v4_modifier, bool req_min_max = false, string optional_identifier = "", ComponentType quantize_type = ComponentType.NONE_SET, bool quantize_change_values = true) + { + start_index = globalIndex; + Min_Max min_max_quantization = new Min_Max(v4_values, v4_modifier); + vector4Info = new Vector4[v4_values.Length]; + bool _saved = false; + + if (quantize_type != ComponentType.NONE_SET && quantize_type != ComponentType.FLOAT) + { + if (quantize_change_values) + { + for (int i = 0; i < vector4Info.Length; i++) + { + vector4Info[i] = new Vector4(GetQuantizeVal(v4_values[i].x * v4_modifier.x, min_max_quantization.min[0], min_max_quantization.max[0], quantize_type, true), + GetQuantizeVal(v4_values[i].y * v4_modifier.y, min_max_quantization.min[1], min_max_quantization.max[1], quantize_type, true), + GetQuantizeVal(v4_values[i].z * v4_modifier.z, min_max_quantization.min[2], min_max_quantization.max[2], quantize_type, true), + GetQuantizeVal(v4_values[i].w * v4_modifier.w, min_max_quantization.min[2], min_max_quantization.max[2], quantize_type, true)); + } + // SAVE THE SCALE AND OFFSET VALUES FOR DECOMPRESSION + quantization_scale = min_max_quantization.GetQuantizationScale(); + quantization_offset = min_max_quantization.GetQuantizationOffset(); + _saved = true; + } + + if (!_saved) + { + // IF COMPONENT TYPE IS USHORT/UBYTE, MAKE SURE MAX RANGE VALUE IS 1 + if (quantize_type == ComponentType.UNSIGNED_BYTE || quantize_type == ComponentType.UNSIGNED_SHORT) + { + + if (min_max_quantization.GetQuantizationScale()[0] <= 1 && min_max_quantization.GetQuantizationScale()[1] <= 1) + { + int quantVal = quantize_type == ComponentType.UNSIGNED_BYTE ? 256 : 65536; + for (int i = 0; i < vector4Info.Length; i++) //SAVE IT AS GIVEN NORMALIZED FROM 0 TO 1 + { + float _xval = (v4_values[i].x * v4_modifier.x) - Mathf.FloorToInt(min_max_quantization.GetQuantizationOffset()[0]); // MAKE SURE VALUE GO FROM 0 TO 1 + float _yval = (v4_values[i].y * v4_modifier.y) - Mathf.FloorToInt(min_max_quantization.GetQuantizationOffset()[1]); + float _zval = (v4_values[i].z * v4_modifier.z) - Mathf.FloorToInt(min_max_quantization.GetQuantizationOffset()[2]); + float _wval = (v4_values[i].w * v4_modifier.w) - Mathf.FloorToInt(min_max_quantization.GetQuantizationOffset()[3]); + vector4Info[i] = new Vector4(GetQuantizeVal(_xval, 0, 1, quantize_type, false), + GetQuantizeVal(_yval, 0, 1, quantize_type, false), + GetQuantizeVal(_zval, 0, 1, quantize_type, false), + GetQuantizeVal(_wval, 0, 1, quantize_type, false)); + //-vector4Info[i].x - vector4Info[i].y - vector4Info[i].z + quantVal); + + } + _saved = true; + } + } + + // IF COMPONENT TYPE IS SHORT/BYTE, MAKE SURE MAX RANGE VALUE IS 2 + if (quantize_type == ComponentType.BYTE || quantize_type == ComponentType.SHORT) + { + //if (min_max_quantization.GetQuantizationScale()[0] <= 2 && min_max_quantization.GetQuantizationScale()[1] <= 2) + //{ + for (int i = 0; i < vector4Info.Length; i++) //SAVE IT AS GIVEN NORMALIZED FROM 0 TO 1 + { + // TO DO... CHECK IF VALUES ARE FROM -1 TO 1 + vector4Info[i] = new Vector4(GetQuantizeVal(v4_values[i].x * v4_modifier.x, 0, 1, quantize_type, false), + GetQuantizeVal(v4_values[i].y * v4_modifier.y, 0, 1, quantize_type, false), + GetQuantizeVal(v4_values[i].z * v4_modifier.z, 0, 1, quantize_type, false), + GetQuantizeVal(v4_values[i].w * v4_modifier.w, 0, 1, quantize_type, false)); + } + _saved = true; + //} + } + } + if (_saved) // IF UP TO HERE, VALUES WERE SAVED, STORE THE ADDITIONAL QUANTIZATION DATA NEEDED. + { + componentType = quantize_type; + byteSize = v4_values.Length * GetByteSize(quantize_type, 4); + normalized = true; + isQuantized = true; + } + } + + if (!_saved) + { + for (int i = 0; i < vector4Info.Length; i++) + { + vector4Info[i] = new Vector4(v4_values[i].x * v4_modifier.x, v4_values[i].y * v4_modifier.y, v4_values[i].z * v4_modifier.z, v4_values[i].w * v4_modifier.w); + } + byteSize = v4_values.Length * 16; // VECTOR 4 REQUIRE 4 FLOAT (4 BYTES EACH) 4*4=16 + componentType = ComponentType.FLOAT; + normalized = false; + } + + Debug.LogWarning("weights"); + //for (int i = 0; i < vector4Info.Length; i++) + //{ + // Debug.Log(vector4Info[i] + " = " + v4_values[i].x +"," + v4_values[i].y + "," + v4_values[i].z + "," + v4_values[i].w); + //} + + if (req_min_max) + min_max = new Min_Max(vector4Info, new Vector3(1, 1, 1)); // it no longer requires modifier, their values were modified previously + + type = Type.VEC4; + optionaIdentifier = optional_identifier; + accessorCount = v4_values.Length; + allUniqueAccessors.Add(this); + globalIndex++; + } + private ComponentType GetBestInt(float min, float max) + { + if (min < 0) + { + //signed int + if (min > -127 && max < 127) + { + return ComponentType.BYTE; + } + if (min > -32767 && max < 32767) + { + return ComponentType.SHORT; + } + return ComponentType.FLOAT; + + } + else + { + //unsigned + if (max < 255) + { + return ComponentType.UNSIGNED_BYTE; + } + if (max < 65535) + { + return ComponentType.UNSIGNED_SHORT; + } + return ComponentType.UNSIGNED_INT; + } + } + + private bool IsIntType(ComponentType comp_type) + { + if (comp_type == ComponentType.BEST_INT || + comp_type == ComponentType.BYTE || + comp_type == ComponentType.UNSIGNED_BYTE || + comp_type == ComponentType.SHORT || + comp_type == ComponentType.UNSIGNED_SHORT || + comp_type == ComponentType.UNSIGNED_INT) + return true; + return false; + } + + + + public ObjectAccessors(Matrix4x4[] matrix_4_values, string optional_identifier = "") + { + start_index = globalIndex; + matrix4Info = matrix_4_values; + + byteSize = matrix_4_values.Length * 64; // 4X4 MATRIX REQQUIRES 16 FLOATS(4) TOTAL OF 16X4=64 + componentType = ComponentType.FLOAT; + normalized = false; + + type = Type.MAT4; + optionaIdentifier = optional_identifier; + accessorCount = matrix_4_values.Length; + allUniqueAccessors.Add(this); + globalIndex++; + } + + private int GetByteSize(ComponentType component_type, int _values) + { + int result = _values; + if (component_type == ComponentType.BYTE || component_type == ComponentType.UNSIGNED_BYTE) + { + result *= 1; + } + if (component_type == ComponentType.UNSIGNED_SHORT || component_type == ComponentType.SHORT) + { + result *= 2; + } + if (component_type == ComponentType.FLOAT || component_type == ComponentType.UNSIGNED_INT) + { + result *= 4; + } + + int _mod = result % 4; + if (_mod != 0) + { + result += (4-_mod); + } + return result; + //Debug.LogWarning("INCORRECT COMPONENT TYPE, PLEASE FIX"); + } + + + private int GetQuantizeVal(float _val, float _min, float _max, ComponentType component_type, bool normalize_val) + { + // DOCS: https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_mesh_quantization/README.md + + if (normalize_val && _min != _max) // WE MUST MAKE SURE MIN AND MAX ARE DIFFERENT, ELSE WE WILL GET 0 + { + if (component_type == ComponentType.UNSIGNED_BYTE || component_type == ComponentType.UNSIGNED_SHORT) + _val = Min_Max.Normalize(_val, _min, _max); // VALUE WILL GO FROM 0 TO 1 + if (component_type == ComponentType.BYTE || component_type == ComponentType.SHORT) + _val = Min_Max.Normalize(_val, _min, _max,true); // VALUE WILL GO FROM -1 TO 1 + } + if (normalize_val && _min == _max) + { + _val = 0; + } + + switch (component_type) + { + case ComponentType.BYTE: + return Mathf.RoundToInt(_val * 127.0f); + case ComponentType.UNSIGNED_BYTE: + return Mathf.RoundToInt(_val * 255.0f); + case ComponentType.SHORT: + return Mathf.RoundToInt(_val * 32767.0f); + case ComponentType.UNSIGNED_SHORT: + return Mathf.RoundToInt(_val * 65535.0f); + } + Debug.LogWarning("WRONG COMPONENT TYPE IN QUANTIZATION VALUE, PLEASE FIX"); + return Mathf.RoundToInt(_val); + + } + + + //WHEN WRITING TO BINARY WE WILL SORT ELEMENTS TOO, THIS FUNCTION MUST BE CALLED BEFORE ANYTHING ELSE + public static void WriteToBinary(string file_name, string file_location) + { + WriteToBinaryUtilities.OpenNewBinaryFile(file_name, file_location); + WriteToBinaryByType(); + WriteToBinaryUtilities.CloseBinaryFile(); + } + public static string GetGLTFData(bool add_end_comma = true) + { + string result = "\"accessors\": ["; + if (sortedAccessorsList != null) + { + foreach (ObjectAccessors accessors in sortedAccessorsList) + { + result += accessors.GetAccessorData() + ",\n"; + } + } + result = StringUtilities.RemoveCharacterFromString(result, 2, false); + result += "]"; + if (add_end_comma) + result += ",\n"; + return result; + } + private static void WriteToBinaryByType() + { + List scalars_byte = new List(); + List scalars_short = new List(); + List scalars_float = new List(); + List scalars_int = new List(); + List vertices = new List(); + List joints = new List(); + List weights = new List(); + List matrix4 = new List(); + List normals = new List(); + List uvs_float = new List(); + List uvs_short = new List(); + List uvs_byte = new List(); + + for (int i = 0; i < allUniqueAccessors.Count; i++) + { + ObjectAccessors oa = allUniqueAccessors[i]; + if (oa.type == Type.SCALAR) + { + switch (oa.componentType) + { + case ComponentType.BYTE: + case ComponentType.UNSIGNED_BYTE: + scalars_byte.Add(oa); + break; + case ComponentType.SHORT: + case ComponentType.UNSIGNED_SHORT: + scalars_short.Add(oa); + break; + case ComponentType.UNSIGNED_INT: + scalars_int.Add(oa); + break; + case ComponentType.FLOAT: + scalars_float.Add(oa); + break; + } + continue; + } + if (oa.type == Type.VEC2) + { + if (oa.componentType == ComponentType.UNSIGNED_BYTE || oa.componentType == ComponentType.BYTE) + uvs_byte.Add(oa); + else if (oa.componentType == ComponentType.UNSIGNED_SHORT || oa.componentType == ComponentType.SHORT) + uvs_short.Add(oa); + else + uvs_float.Add(oa); + continue; + } + if (oa.type == Type.VEC3) + { + if (oa.min_max != null) + { + vertices.Add(oa); + continue; + } + else + { + normals.Add(oa); + continue; + } + } + if (oa.type == Type.VEC4) + { + if (oa.optionaIdentifier == "joints") + { + Debug.Log("============ joints ==========="); + joints.Add(oa); + continue; + } + if (oa.optionaIdentifier == "weights") + { + Debug.Log("============ weights ==========="); + weights.Add(oa); + continue; + } + } + if (oa.type == Type.MAT4) + { + matrix4.Add(oa); + continue; + } + } + + + //SCALARS + ObjectBufferView bv; + if (scalars_byte.Count > 0) + { + Debug.Log("scalar byte"); + bv=new ObjectBufferView(); + + for (int i =0; i < scalars_byte.Count;i++) + { + scalars_byte[i].bufferView = bv; + scalars_byte[i].byteOffset = bv.GetCurrentAndAddDataToBufferView(scalars_byte[i].byteSize); + AddToSortedList(scalars_byte[i]); + WriteToBinaryUtilities.WriteUnsignedBytes(scalars_byte[i].scalarInt); + ObjectBuffer.AddByteSize(scalars_byte[i].byteSize); + } + if (!ObjectBufferView.HasFourthAmountOfBytes(bv.byteSize)) + { + int offset_buffer = 4 - (bv.byteSize % 4); + WriteToBinaryUtilities.WriteEmptySingle(offset_buffer); + ObjectBuffer.AddByteSize(offset_buffer); + } + } + + if (scalars_short.Count > 0) + { + bv = new ObjectBufferView(); + + for (int i = 0; i < scalars_short.Count; i++) + { + scalars_short[i].bufferView = bv; + scalars_short[i].byteOffset = bv.GetCurrentAndAddDataToBufferView(scalars_short[i].byteSize); + AddToSortedList(scalars_short[i]); + WriteToBinaryUtilities.WriteUnsignedShorts(scalars_short[i].scalarInt); + ObjectBuffer.AddByteSize(scalars_short[i].byteSize); + } + if (!ObjectBufferView.HasFourthAmountOfBytes(bv.byteSize)) + { + int offset_buffer = 4 - (bv.byteSize % 4); + WriteToBinaryUtilities.WriteEmptySingle(offset_buffer); + ObjectBuffer.AddByteSize(offset_buffer); + } + } + //FULL INTS + if (scalars_int.Count > 0) + { + bv = new ObjectBufferView(); + + for (int i = 0; i < scalars_int.Count; i++) + { + scalars_int[i].bufferView = bv; + scalars_int[i].byteOffset = bv.GetCurrentAndAddDataToBufferView(scalars_int[i].byteSize); + AddToSortedList(scalars_int[i]); + WriteToBinaryUtilities.WriteInts(scalars_int[i].scalarInt); + ObjectBuffer.AddByteSize(scalars_int[i].byteSize); + } + } + //FLOATS + if (scalars_float.Count > 0) + { + bv = new ObjectBufferView(); + + for (int i = 0; i < scalars_float.Count; i++) + { + scalars_float[i].bufferView = bv; + scalars_float[i].byteOffset = bv.GetCurrentAndAddDataToBufferView(scalars_float[i].byteSize); + AddToSortedList(scalars_float[i]); + WriteToBinaryUtilities.WriteFloats(scalars_float[i].scalarFloat); + ObjectBuffer.AddByteSize(scalars_float[i].byteSize); + } + } + //VERTICES + if (vertices.Count > 0) + { + bv = new ObjectBufferView(); + if (ExportToGLTF.options.quantizeGLTF) + bv.byteStride = vertices[0].GetByteSize(vertices[0].componentType, 3); + + foreach (ObjectAccessors oa in vertices) + { + oa.bufferView = bv; + oa.byteOffset = bv.GetCurrentAndAddDataToBufferView(oa.byteSize); + AddToSortedList(oa); + //oa.componentType + WriteToBinaryUtilities.WriteVector3(oa.vector3Info, oa.componentType); + ObjectBuffer.AddByteSize(oa.byteSize); + } + } + + //NORMALS + if (normals.Count > 0) + { + bv = new ObjectBufferView(); + if (ExportToGLTF.options.quantizeGLTF) + bv.byteStride = normals[0].GetByteSize(normals[0].componentType, 3); + + foreach (ObjectAccessors oa in normals) + { + oa.bufferView = bv; + oa.byteOffset = bv.GetCurrentAndAddDataToBufferView(oa.byteSize); + AddToSortedList(oa); + WriteToBinaryUtilities.WriteVector3(oa.vector3Info, oa.componentType); + ObjectBuffer.AddByteSize(oa.byteSize); + } + } + //JOINTS + if (joints.Count > 0) + { + bv = new ObjectBufferView(); + Debug.Log("checkType joints"); + Debug.Log("check if byteStride is not necessary"); + + foreach (ObjectAccessors oa in joints) + { + oa.bufferView = bv; + oa.byteOffset = bv.GetCurrentAndAddDataToBufferView(oa.byteSize); + AddToSortedList(oa); + WriteToBinaryUtilities.WriteVector4(oa.vector4Info, oa.componentType); + ObjectBuffer.AddByteSize(oa.byteSize); + } + + } + // WEIGHTS + if (weights.Count > 0) + { + bv = new ObjectBufferView(); + Debug.Log("checkType weights"); + Debug.Log("check if byteStride is not necessary"); + + foreach (ObjectAccessors oa in weights) + { + oa.bufferView = bv; + oa.byteOffset = bv.GetCurrentAndAddDataToBufferView(oa.byteSize); + AddToSortedList(oa); + WriteToBinaryUtilities.WriteVector4(oa.vector4Info, oa.componentType); + ObjectBuffer.AddByteSize(oa.byteSize); + } + + } + // MATRIX 4X4 + if (matrix4.Count > 0) + { + bv = new ObjectBufferView(); + Debug.Log("check matrix4"); + + foreach (ObjectAccessors oa in matrix4) + { + oa.bufferView = bv; + oa.byteOffset = bv.GetCurrentAndAddDataToBufferView(oa.byteSize); + AddToSortedList(oa); + WriteToBinaryUtilities.WriteMatrix4(oa.matrix4Info); + ObjectBuffer.AddByteSize(oa.byteSize); + } + } + //UVS + //BYTES + if (uvs_byte.Count > 0) + { + bv = new ObjectBufferView(); + //if (ExportToGLTF.options.quantizeGLTF) + //bv.byteStride = uvs_byte[0].GetByteSize(uvs_byte[0].componentType, 2); + + foreach (ObjectAccessors oa in uvs_byte) + { + oa.bufferView = bv; + oa.byteOffset = bv.GetCurrentAndAddDataToBufferView(oa.byteSize); + AddToSortedList(oa); + WriteToBinaryUtilities.WriteVector2(oa.vector2Info, oa.componentType); + ObjectBuffer.AddByteSize(oa.byteSize); + } + if (!ObjectBufferView.HasFourthAmountOfBytes(bv.byteSize)) + { + int offset_buffer = 4 - (bv.byteSize % 4); + WriteToBinaryUtilities.WriteEmptySingle(offset_buffer); + ObjectBuffer.AddByteSize(offset_buffer); + } + } + //SHORTS + if (uvs_short.Count > 0) + { + Debug.Log("test short"); + bv = new ObjectBufferView(); + //if (ExportToGLTF.options.quantizeGLTF) + //bv.byteStride = uvs_short[0].GetByteSize(uvs_short[0].componentType, 2); + + foreach (ObjectAccessors oa in uvs_short) + { + oa.bufferView = bv; + oa.byteOffset = bv.GetCurrentAndAddDataToBufferView(oa.byteSize); + AddToSortedList(oa); + WriteToBinaryUtilities.WriteVector2(oa.vector2Info, oa.componentType); + ObjectBuffer.AddByteSize(oa.byteSize); + } + } + //FLOATS + if (uvs_float.Count > 0) + { + bv = new ObjectBufferView(); + //if (ExportToGLTF.options.quantizeGLTF) + //bv.byteStride = uvs_float[0].GetByteSize(uvs_float[0].componentType, 2); + + foreach (ObjectAccessors oa in uvs_float) + { + oa.bufferView = bv; + oa.byteOffset = bv.GetCurrentAndAddDataToBufferView(oa.byteSize); + AddToSortedList(oa); + WriteToBinaryUtilities.WriteVector2(oa.vector2Info, oa.componentType); + ObjectBuffer.AddByteSize(oa.byteSize); + } + } + } + private static void AddToSortedList(ObjectAccessors oa) + { + oa.export_index = sortedAccessorsList.Count; + sortedAccessorsList.Add(oa); + } + + private string GetAccessorData() + { + bool min_max_as_int = false; + if (componentType == ComponentType.UNSIGNED_SHORT || componentType == ComponentType.SHORT || componentType == ComponentType.UNSIGNED_INT) + min_max_as_int = true; + + + string result = ""; + result += "{\n" + + "\"bufferView\" : " + bufferView.bufferIndex + ",\n" + + "\"byteOffset\" : " + byteOffset + ",\n" + + "\"componentType\" : " + (int)componentType + ",\n" + + "\"count\" : " + accessorCount + ",\n"; + if (normalized) + { + result += "\"normalized\" : true,\n"; + } + if (min_max != null) { + result += "\"max\" : [" + min_max.GetValues(false, min_max_as_int) + "],\n"; + result += "\"min\" : [" + min_max.GetValues(true, min_max_as_int) + "],\n"; + } + result += "\"type\" : \"" + type + "\"\n" + + "}"; + // sparse not supported atm + return result; + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAccessors.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAccessors.cs.meta new file mode 100644 index 0000000..e439b56 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAccessors.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae10371f1f966374a865fe739e1325e0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAsset.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAsset.cs new file mode 100644 index 0000000..2397662 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAsset.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectAsset + { + const string version = "2.0"; + const string generator = "ola k ase"; + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + result += "\"asset\": {\n" + + "\"version\": \"" + version + "\",\n" + + "\"generator\": \"" + generator + "\"\n" + + "}"; + if (add_end_comma) + result += ",\n"; + return result; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAsset.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAsset.cs.meta new file mode 100644 index 0000000..107ebc5 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectAsset.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a5213d7e51c0b544aa580fcef0b0cf2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBuffer.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBuffer.cs new file mode 100644 index 0000000..5ebd703 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBuffer.cs @@ -0,0 +1,33 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectBuffer + { + public static int byteSize = 0; + + public static void Reset() + { + byteSize = 0; + } + public static void AddByteSize(int byte_size) + { + byteSize += byte_size; + } + public static string GetGLTFData(string bufferName, bool add_end_comma = true) + { + string result = "\"buffers\" : [\n" + + "{\n" + + "\"uri\" : \"" + bufferName + ".bin\",\n" + + "\"byteLength\" : " + byteSize + "\n" + + "}\n" + + "]"; // independent values, must not have comma at the end + if (add_end_comma) + result += ",\n"; + return result; + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBuffer.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBuffer.cs.meta new file mode 100644 index 0000000..f254abd --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 540fb854faeaab949965ff45a33091dc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBufferView.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBufferView.cs new file mode 100644 index 0000000..9e6bf30 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBufferView.cs @@ -0,0 +1,121 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectBufferView + { + //statics + public static int globalIndex = -1; + public static List allUniqueBuffers; + + //vars + public int buffer = 0; // FOR NOW, ITS ALWAYS 0, SINCE IT REFERES TO THE BINARY + public int byteSize; + public int byteStart; + public int byteStride = -1; + public int bufferIndex = -1; + + public static void Reset() + { + allUniqueBuffers = new List(); + globalIndex = 0; + } + + //public static int GetBufferViewIndex(BufferViewType buffer_type, int byte_size) + //{ + // if (allUniqueBuffers == null) + // { + // allUniqueBuffers = new List(); + // allUniqueBuffers.Add(new ObjectBufferView(buffer_type, byte_size)); + + // return allUniqueBuffers.Count - 1; + // } + // else { + // foreach (ObjectBufferView obv in allUniqueBuffers) + // { + // if (obv.bufferType == buffer_type) + // { + // //IF FOUND WE MUST ADD BYTE SIZE + // obv.byteSize += byte_size; + // return obv.bufferIndex; + // } + // } + // allUniqueBuffers.Add(new ObjectBufferView(buffer_type, byte_size)); + // return allUniqueBuffers.Count - 1; + // } + //} + + public ObjectBufferView(int byte_start = 0, int byte_stride = -1) + { + bufferIndex = globalIndex; + byteSize = 0; + byteStart = byte_start; + byteStride = byte_stride; + allUniqueBuffers.Add(this); + globalIndex++; + } + public int GetCurrentAndAddDataToBufferView(int byte_size) + { + int initialSize = byteSize; + byteSize += byte_size; + return initialSize; + } + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + if (allUniqueBuffers != null) + { + if (allUniqueBuffers.Count > 0) { + int byteOffset = 0; + result += "\"bufferViews\":["; + for (int i =0; i < allUniqueBuffers.Count;i++) + { + result += allUniqueBuffers[i].GetBufferData(byteOffset) +",\n"; + byteOffset += allUniqueBuffers[i].byteSize; + // IF WE DONT HAVE FOURTHS AMOUNT OF BYTES ADD 2 BYTES + if (!HasFourthAmountOfBytes(byteOffset)) + { + byteOffset += (4 - (byteOffset % 4)); + } + } + result = StringUtilities.RemoveCharacterFromString (result,2,false) +"]"; + if (add_end_comma) + result += ",\n"; + } + } + return result; + } + + public string GetBufferData(int byte_offset) + { + string result = ""; + string _stride = ""; + if (byteStride != -1) + { + _stride = "\"byteStride\" : " + byteStride + ",\n"; + } + result += "{\n" + + "\"buffer\" : " + buffer + ",\n" + + "\"byteOffset\" : " + byte_offset + ",\n" + + _stride + + "\"byteLength\" : " + byteSize + "\n" + + "}"; + return result; + } + + public static bool HasFourthAmountOfBytes(int target_bytes) + { + if (target_bytes % 4 == 0) // IF TOTAL INDICES ARE UNPAIR NUMBER ADD AN OFFSET OF 2 ADDITIONAL BYTES AT THE END + { + return true; + } + else + { + return false; + } + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBufferView.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBufferView.cs.meta new file mode 100644 index 0000000..6726e9d --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectBufferView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8db7355f03bd2814e876d28d56851245 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectCamera.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectCamera.cs new file mode 100644 index 0000000..9682cb9 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectCamera.cs @@ -0,0 +1,124 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectCamera + { + + //statics + public static int globalIndex = -1; + public static List allUniqueCameras; + + //vars + public int index = -1; + + public List cameraProperties; + + public static void Reset() + { + globalIndex = 0; + allUniqueCameras = new List(); + } + /// + /// Get Index of Perspective Camera + /// + /// + /// + /// + /// + /// + public static int GetCameraIndex(float aspect_ratio, float y_fov, float z_far, float z_near, string _tag = "", int layer_mask = -1) + { + ObjectCamera object_camera = new ObjectCamera(aspect_ratio,y_fov,z_far,z_near,_tag,layer_mask); + allUniqueCameras.Add(object_camera); + return object_camera.index; + } + /// + /// Get Index of Ortographic Camera + /// + /// + /// + /// + /// + public static int GetCameraIndex(Vector2 mag_scale, float z_far, float z_near, string _tag = "", int layer_mask = -1) + { + ObjectCamera object_camera = new ObjectCamera(mag_scale, z_far, z_near,_tag, layer_mask); + allUniqueCameras.Add(object_camera); + return object_camera.index; + } + // Perspective Camera + public ObjectCamera(float aspect_ratio, float y_fov, float z_far, float z_near,string _tag = "", int layer_mask = -1) + { + cameraProperties = new List(); + cameraProperties.Add(new ObjectProperty("type", "perspective")); + List _perspProperties = new List(); + _perspProperties.Add(new ObjectProperty("aspectRatio",aspect_ratio)); + _perspProperties.Add(new ObjectProperty("yfov", y_fov)); + _perspProperties.Add(new ObjectProperty("zfar", z_far)); + _perspProperties.Add(new ObjectProperty("znear", z_near)); + cameraProperties.Add(new ObjectProperty("perspective",_perspProperties)); + ObjectExtraProperties _extras = new ObjectExtraProperties(); + if (layer_mask != -1) + _extras.Add(new ObjectProperty("layerMask",layer_mask)); + if (_tag != "") + _extras.Add(new ObjectProperty("tag",_tag)); + if (_extras.extrasProperties.Count > 0) + cameraProperties.Add(new ObjectProperty(_extras)); + + index = globalIndex; + if (_tag == "MainCamera") + if (ExportToGLTF.options.extraExportMainCameraInGLTF) + if (ExportToGLTF.options.extraCameraIndex == -1) + ExportToGLTF.options.extraCameraIndex = index; + globalIndex++; + } + // Ortographic Camera + public ObjectCamera(Vector2 mag_scale, float z_far, float z_near,string _tag = "", int layer_mask = -1) + { + cameraProperties = new List(); + cameraProperties.Add(new ObjectProperty("type", "ortographic")); + List _perspProperties = new List(); + _perspProperties.Add(new ObjectProperty("xmag", mag_scale.x)); + _perspProperties.Add(new ObjectProperty("ymag", mag_scale.y)); + _perspProperties.Add(new ObjectProperty("zfar", z_far)); + _perspProperties.Add(new ObjectProperty("znear", z_near)); + cameraProperties.Add(new ObjectProperty("ortographic", _perspProperties)); + + ObjectExtraProperties _extras = new ObjectExtraProperties(); + if (layer_mask != -1) + _extras.Add(new ObjectProperty("layerMask", layer_mask)); + if (_tag != "") + _extras.Add(new ObjectProperty("tag", _tag)); + if (_extras.extrasProperties.Count > 0) + cameraProperties.Add(new ObjectProperty(_extras)); + + index = globalIndex; + if (_tag == "MainCamera") + if (ExportToGLTF.options.extraExportMainCameraInGLTF) + if (ExportToGLTF.options.extraCameraIndex == -1) + ExportToGLTF.options.extraCameraIndex = index; + globalIndex++; + } + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + if (allUniqueCameras.Count > 0) + { + result += "\"cameras\" : [\n"; + for (int i = 0; i < allUniqueCameras.Count; i++) + { + result += ObjectProperty.GetObjectProperties(allUniqueCameras[i].cameraProperties); + if (i < allUniqueCameras.Count - 1) + result += ",\n"; + } + result += "]"; + if (add_end_comma) + result += ",\n"; + } + return result; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectCamera.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectCamera.cs.meta new file mode 100644 index 0000000..5b9d201 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectCamera.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a34b4bf72a8932845be188d5eeb991f9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtension.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtension.cs new file mode 100644 index 0000000..24b5d9b --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtension.cs @@ -0,0 +1,118 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectExtension + { + public static List extensionsUsedList; + public static List extensionsRequiredList; + public static List globalProperties; + + public string name; + public List properties; + public static void Reset() + { + extensionsUsedList = new List(); + extensionsRequiredList = new List(); + globalProperties = new List(); + } + public static void Add(ObjectProperty object_property) + { + globalProperties.Add(object_property); + } + public ObjectExtension(string extension_name, List properties_list, bool isRequired, bool ExportInGLTF = true) + { + name = extension_name; + AddToExtensionsUsed(); + if (isRequired) + AddToExtensionRequired(); + properties = properties_list; + } + public static string GetGLTFHeaderExtensionData(bool add_end_comma = true) + { + string result = ""; + if (extensionsUsedList.Count > 0) + { + //result += "{\n"; + result += "\"extensionsUsed\" : [\n"; + for (int i = 0; i < extensionsUsedList.Count; i++) + { + result += "\""+ extensionsUsedList[i] + "\""; + if (i < extensionsUsedList.Count - 1) + result += ","; + } + result += "\n]"; + if (extensionsRequiredList.Count > 0) + { + result += ",\n"; + result += "\"extensionsRequired\" : [\n"; + for (int i = 0; i < extensionsRequiredList.Count; i++) + { + result += "\"" + extensionsRequiredList[i] + "\""; + if (i < extensionsRequiredList.Count - 1) + result += ",\n"; + } + result += "\n]"; + } + //result += "}"; + if (add_end_comma) + result += ",\n"; + } + return result; + } + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + if (globalProperties.Count > 0) + { + result += "\"extensions\" : {\n"; + for (int i = 0; i < globalProperties.Count; i++) + { + result += globalProperties[i].GetPropertyGLTF(); + } + result += "\n}"; + if (add_end_comma) + result += ",\n"; + } + return result; + } + + + public void AddToExtensionsUsed() + { + bool isNewExtension = true; + foreach (string st in extensionsUsedList) + { + if (name == st) + { + isNewExtension = false; + break; + } + } + if (isNewExtension) + extensionsUsedList.Add(name); + } + + public void AddToExtensionRequired() + { + bool isNewExtension = true; + foreach (string st in extensionsRequiredList) + { + if (name == st) + { + isNewExtension = false; + break; + } + } + if (isNewExtension) + extensionsRequiredList.Add(name); + + } + + + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtension.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtension.cs.meta new file mode 100644 index 0000000..a3d87a8 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d82fc268bc2d09645bd1af1b96c0b225 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiAudio.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiAudio.cs new file mode 100644 index 0000000..6085985 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiAudio.cs @@ -0,0 +1,213 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectExtensionOmiAudio + { + //consts + public const string exportPreName = "aud_"; + + //statics + public static int globalIndex = -1; + public static List allUniqueAudioEmitter; + public static List allUniqueAudioClips; + + //vars + public int index = -1; //the index of the audio emitter + public List emitterProperties; + + + public static void Reset() + { + globalIndex = 0; + allUniqueAudioEmitter = new List(); + allUniqueAudioClips = new List(); + } + public static int GetAudioEmitterIndex(AudioSource audio_source) + { + if (audio_source.clip == null) + return -1; + + foreach(ObjectExtensionOmiAudio emitter in allUniqueAudioEmitter) + { + if (isSameAudioEmitter(audio_source)) + { + return emitter.index; + } + } + allUniqueAudioEmitter.Add( new ObjectExtensionOmiAudio(audio_source)); + return allUniqueAudioEmitter.Count - 1; + // + + } + public static int GetAudioEmitterIndex(WebPositionalAudioSource web_audio_source) + { + if (web_audio_source.clip == null) + return -1; + + foreach (ObjectExtensionOmiAudio emitter in allUniqueAudioEmitter) + { + if (isSameAudioEmitter(web_audio_source)) + { + return emitter.index; + } + } + allUniqueAudioEmitter.Add(new ObjectExtensionOmiAudio(web_audio_source)); + return allUniqueAudioEmitter.Count - 1; + // + + } + private static bool isSameAudioEmitter(AudioSource audio_source) + { + // FOR NOW WE WILL ALWAYS CREATE NEW AUDIO EMITTERS + return false; + } + private static bool isSameAudioEmitter(WebPositionalAudioSource web_audio_source) + { + // FOR NOW WE WILL ALWAYS CREATE NEW AUDIO EMITTERS + return false; + } + + public ObjectExtensionOmiAudio(AudioSource audio_source) + { + index = globalIndex; + + emitterProperties = GetEmitterProperties(audio_source); + + globalIndex++; + } + + public ObjectExtensionOmiAudio(WebPositionalAudioSource web_audio_source) + { + index = globalIndex; + + emitterProperties = GetEmitterProperties(web_audio_source); + + globalIndex++; + } + + private List GetEmitterProperties(AudioSource audio_source) + { + List props = new List(); + props.Add(new ObjectProperty("name", audio_source.clip.name)); + // is this one required? + props.Add(new ObjectProperty("type", "global")); + props.Add(new ObjectProperty("gain", audio_source.volume)); + props.Add(new ObjectProperty("loop", audio_source.loop)); + props.Add(new ObjectProperty("playing", audio_source.playOnAwake)); + props.Add(new ObjectProperty("source", GetAudioClipindex(audio_source.clip))); + + // add pitch in extras (detune in three js) + // playback rate (speed) + // offset start + + + return props; + } + private List GetEmitterProperties(WebPositionalAudioSource web_audio_source) + { + //missing check defaults + + List props = new List(); + if (web_audio_source.name != "") + props.Add(new ObjectProperty("name", web_audio_source.name)); + props.Add(new ObjectProperty("source", GetAudioClipindex(web_audio_source.clip))); + + bool isGlobalAudio = web_audio_source.isGlobalAudio; + // is this one required? + props.Add(new ObjectProperty("type", isGlobalAudio == true ? "global":"positional")); + props.Add(new ObjectProperty("gain", web_audio_source.gain)); + // props.Add(new ObjectProperty("speed", web_audio_source.speed)); + // props.Add(new ObjectProperty("pitch", web_audio_source.pitch)); + // offset start property missing + props.Add(new ObjectProperty("loop", web_audio_source.loop)); + props.Add(new ObjectProperty("playing", web_audio_source.playing)); + + + if (!isGlobalAudio) + { + List _positional = new List(); + + _positional.Add(new ObjectProperty("coneInnerAngle", Mathf.Deg2Rad * web_audio_source.coneInnerAngleDegree)); + _positional.Add(new ObjectProperty("coneOuterAngle", Mathf.Deg2Rad * web_audio_source.coneOuterAngleDegree)); + _positional.Add(new ObjectProperty("coneOuterGain", web_audio_source.coneOuterGain)); + _positional.Add(new ObjectProperty("distanceModel", web_audio_source.distance.ToString())); + + _positional.Add(new ObjectProperty("refDistance", web_audio_source.refDistance)); + if (web_audio_source.distance == WebPositionalAudioSource.Distance.linear) + { + _positional.Add(new ObjectProperty("maxDistance", web_audio_source.maxDistance)); + _positional.Add(new ObjectProperty("rolloffFactor", web_audio_source.rollOffFactorLinear)); + } + else + { + _positional.Add(new ObjectProperty("rolloffFactor", web_audio_source.rollOffFactor)); + } + + if (_positional.Count > 0) + { + props.Add(new ObjectProperty("positional", _positional)); + } + } + + + + return props; + } + + + private static int GetAudioClipindex(AudioClip audio_clip) + { + foreach (AudioClip clip in allUniqueAudioClips) + { + if (audio_clip == clip) + { + return allUniqueAudioClips.IndexOf(clip); + } + } + // IF NO COINCIDENCE WAS FOUND ADD THE NEW AUDIO TO THE LIST AND RETURN THE INDEX OF IT + allUniqueAudioClips.Add(audio_clip); + return allUniqueAudioClips.Count - 1; + } + + public static void AddGLTFDataToExtensions() + { + if (allUniqueAudioEmitter.Count > 0) + { + List _KHR_audio = new List(); + + List _emitters = new List(); + List _sources = new List(); + + foreach (ObjectExtensionOmiAudio ae in allUniqueAudioEmitter) + { + _emitters.Add(new ObjectProperty("", ae.emitterProperties)); + } + foreach (AudioClip clip in allUniqueAudioClips) + { + List _sources_single = new List(); + _sources_single.Add(new ObjectProperty("name", clip.name)); + _sources_single.Add(new ObjectProperty("uri", "aud_"+ allUniqueAudioClips.IndexOf(clip) + "." +StringUtilities.GetExtensionFromObjectAsset(clip))); + + _sources.Add(new ObjectProperty("", _sources_single)); + } + + _KHR_audio.Add(new ObjectProperty("sources", _sources, true)); + _KHR_audio.Add(new ObjectProperty("emitters", _emitters,true)); + + ObjectExtension.Add(new ObjectProperty("KHR_audio", _KHR_audio)); + } + + } + public static void ExportAllAudios(string location) + { + for (int i = 0; i < allUniqueAudioClips.Count; i++) + { + FileExporter.CopyFileFromAsset(allUniqueAudioClips[i],location,exportPreName + i); + } + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiAudio.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiAudio.cs.meta new file mode 100644 index 0000000..6f2903f --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiAudio.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9ce4ebee4a205f8438eb6edf88ac6784 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiCollider.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiCollider.cs new file mode 100644 index 0000000..146e507 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiCollider.cs @@ -0,0 +1,278 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + //https://github.com/omigroup/gltf-extensions/pull/63/files + public class ObjectExtensionOmiCollider + { + //statics + //public static int globalIndex = -1; + //public static List allUniqueColliders; + + //vars + //public int index = -1; //the index of the audio emitter + public List colliderProperties; + + //public static void Reset() + //{ + // globalIndex = 0; + // allUniqueColliders = new List(); + //} + //public static int GetColliderIndex(Collider collider_source) + //{ + // if (collider_source == null) + // return -1; + + // allUniqueColliders.Add(new ObjectExtensionOmiCollider(collider_source)); + + // return allUniqueColliders.Count - 1; + + //} + + //public ObjectExtensionOmiCollider(Collider collider) + //{ + // index = globalIndex; + + // colliderProperties = GetColliderProperties(collider); + + // globalIndex++; + //} + + public static List GetColliderProperties(Collider collider, Rigidbody rigidBody) + { + if (collider == null) + return null; + List _props = new List(); + + switch (collider.GetType().Name) + { + case "MeshCollider": + MeshRenderer mr = collider.transform.GetComponent(); + ObjectNodeMono node = collider.transform.GetComponent(); + if (mr != null) + { + int connectedMesh = node.connectedMesh; + MeshCollider mc = collider as MeshCollider; + if (mc.convex) + { + _props.Add(new ObjectProperty("type", "hull")); //hull and mesh will point towards the mesh, in the case of hull, every engine must be responsible for the convex hull creation + _props.Add(new ObjectProperty("mesh", connectedMesh)); + + } + else + { + _props.Add(new ObjectProperty("type", "mesh")); + _props.Add(new ObjectProperty("mesh", connectedMesh)); + } + } + break; + + case "SphereCollider": + SphereCollider sc = collider as SphereCollider; + _props.Add(new ObjectProperty("type", "sphere")); + _props.Add(new ObjectProperty("radius", sc.radius)); + _props.Add(new ObjectProperty("center", sc.center)); //check if negative z + break; + + case "BoxCollider": + BoxCollider bc = collider as BoxCollider; + _props.Add(new ObjectProperty("type", "box")); + _props.Add(new ObjectProperty("extents", bc.size,false)); + _props.Add(new ObjectProperty("center", bc.center)); + + break; + + case "CapsuleCollider": + CapsuleCollider cc = collider as CapsuleCollider; + _props.Add(new ObjectProperty("type", "capsule")); + _props.Add(new ObjectProperty("radius", cc.radius)); + _props.Add(new ObjectProperty("height", cc.height)); + _props.Add(new ObjectProperty("center", cc.center)); //check if negative z + break; + //compound?? + + } + if (collider.isTrigger) + _props.Add(new ObjectProperty("sensor", true)); + + if (collider.sharedMaterial != null){ + PhysicMaterial mat = collider.sharedMaterial; + List _material = new List(); + _material.Add(new ObjectProperty("friction", mat.dynamicFriction)); + _material.Add(new ObjectProperty("restitution", mat.bounciness)); + _material.Add(new ObjectProperty("combineFriction", GetPhysicsMaterialCombineString(mat.frictionCombine))); + _material.Add(new ObjectProperty("combineRestitution", GetPhysicsMaterialCombineString(mat.bounceCombine))); + _props.Add(new ObjectProperty("material", _material)); + } + + + + //collider.bounds + if (rigidBody != null) + { + WebColliderEnhance _enh = rigidBody.transform.GetComponent(); + List _rigidBodyProps = new List(); + //save current mass + Vector3 _bounds = new Vector3(collider.bounds.extents.x * 2, collider.bounds.extents.y * 2, collider.bounds.extents.z * 2); + float _volume = _bounds.x * _bounds.y * _bounds.z; + float _density = rigidBody.mass/_volume; //= calc volume / rigidBody.mass; + float _gravity = rigidBody.useGravity == true ? 1 : 0; + if (_enh != null) + { + if (!_enh.setMassFromRigidBody) { + _density = _enh.density; + } + _gravity *= _enh.gravityMultiplier; + //if (_enh.friction != 0) + // _rigidBodyProps.Add(new ObjectProperty("friction", _enh.friction)); + //if (_enh.restitution != 0) + // _rigidBodyProps.Add(new ObjectProperty("restitution", _enh.restitution)); + + } + + if (rigidBody.isKinematic) + _rigidBodyProps.Add(new ObjectProperty("isKinematic", true)); + if (_gravity != 1) + _rigidBodyProps.Add(new ObjectProperty("gravity", _gravity)); + if (_density != 1) + _rigidBodyProps.Add(new ObjectProperty("density", _density)); + + if (rigidBody.drag != 0) + _rigidBodyProps.Add(new ObjectProperty("damp", rigidBody.drag)); + if (rigidBody.angularDrag != 0) + _rigidBodyProps.Add(new ObjectProperty("angularDamp", rigidBody.angularDrag)); + + + bool[] _constraints = GetConstraints((int)rigidBody.constraints); + + if (_constraints[0] || _constraints[1] || _constraints[2]) + { + List _positionLock = new List(); + _positionLock.Add(new ObjectProperty("x", _constraints[0])); + _positionLock.Add(new ObjectProperty("y", _constraints[1])); + _positionLock.Add(new ObjectProperty("z", _constraints[2])); + _rigidBodyProps.Add(new ObjectProperty("positionLock", _positionLock)); + } + if (_constraints[0] || _constraints[1] || _constraints[2]) + { + List _rotationLock = new List(); + _rotationLock.Add(new ObjectProperty("x", _constraints[3])); + _rotationLock.Add(new ObjectProperty("y", _constraints[4])); + _rotationLock.Add(new ObjectProperty("z", _constraints[5])); + _rigidBodyProps.Add(new ObjectProperty("rotationLock", _rotationLock)); + } + + if (rigidBody.collisionDetectionMode != CollisionDetectionMode.Discrete) + { + _rigidBodyProps.Add(new ObjectProperty("ccd", true)); + } + _props.Add(new ObjectProperty("rigidBody", _rigidBodyProps)); + } + + return _props; + } + private static string GetPhysicsMaterialCombineString(PhysicMaterialCombine matCombine) + { + switch (matCombine) + { + case PhysicMaterialCombine.Average: + return "average"; + case PhysicMaterialCombine.Minimum: + return "min"; + case PhysicMaterialCombine.Maximum: + return "max"; + case PhysicMaterialCombine.Multiply: + return "multiply"; + } + return ""; + } + private static bool[] GetConstraints(int enumVal) + { + bool[] _constraints = new bool[6]; + for (int i = 0; i < _constraints.Length; i++) + _constraints[i] = false; + if (enumVal == 0 || enumVal == 14 || enumVal == 112 || enumVal == 126) + { + switch (enumVal) + { + case 0: + break; + case 14: + _constraints[0] = _constraints[1] = _constraints[2] = true; + break; + case 112: + _constraints[3] = _constraints[4] = _constraints[5] = true; + break; + case 126: + _constraints[0] = _constraints[1] = _constraints[2] = _constraints[3] = _constraints[4] = _constraints[5] = true; + break; + } + } + else + { + + getActiveConstrain(ref _constraints, enumVal); + + } + + return _constraints; + } + + private static void getActiveConstrain(ref bool[] constrains, int val) + { + if (val >= 64) + { + constrains[5] = true; + val -= 64; + } + + if (val >= 32) + { + constrains[4] = true; + val -= 32; + } + + if (val >= 16) + { + constrains[3] = true; + val -= 16; + } + + if (val >= 8) + { + constrains[2] = true; + val -= 8; + } + + if (val >= 4) + { + constrains[1] = true; + val -= 4; + } + + if (val >= 2) + { + constrains[0] = true; + } + + } + //public static void AddGLTFDataToExtensions() //global section of extension! + // { + //if (allUniqueColliders.Count > 0) + //{ + // List _OMI_collider = new List(); + + // List _emitters = new List(); + + // foreach (ObjectExtensionOmiCollider oc in allUniqueColliders) + // { + // _OMI_collider.Add(new ObjectProperty("",oc.colliderProperties)); + // } + + // ObjectExtension.Add(new ObjectProperty("OMI_collider", _OMI_collider)); + //} + // } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiCollider.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiCollider.cs.meta new file mode 100644 index 0000000..a524414 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtensionOmiCollider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 32441b7e36108b842beb017f4042d364 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtraProperties.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtraProperties.cs new file mode 100644 index 0000000..1ea4161 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtraProperties.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectExtraProperties + { + public List extrasProperties; + + public ObjectExtraProperties(List existing_properties = null) + { + if (existing_properties == null) + extrasProperties = new List(); + else + extrasProperties = existing_properties; + } + public void Add(ObjectProperty object_property) + { + if (object_property != null) + extrasProperties.Add(object_property); + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtraProperties.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtraProperties.cs.meta new file mode 100644 index 0000000..fe4f653 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtraProperties.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e9e5ef8adfbdf1341a9d163302f70cff +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationClip.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationClip.cs new file mode 100644 index 0000000..6450efd --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationClip.cs @@ -0,0 +1,237 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectExtrasAnimationClip + { + //statics + public static int globalIndex = -1; + public static List allUniqueAnimationClips; + + //vars + public int index = -1; + + public AnimationClip animationClip; + public List animationProperties; + + public List trackNames; + public List keyTimes; + public List keyValues; + public List keyWeights; + public List keyTangents; + public static void Reset() + { + globalIndex = 0; + allUniqueAnimationClips = new List(); + } + + public static int GetAnimationIndex(AnimationClip animation_clip) + { + if (animation_clip == null) + return -1; + + if (allUniqueAnimationClips == null) + { + allUniqueAnimationClips = new List(); + + allUniqueAnimationClips.Add(new ObjectExtrasAnimationClip(animation_clip)); + + return allUniqueAnimationClips.Count - 1; + } + else + { + foreach (ObjectExtrasAnimationClip oa in allUniqueAnimationClips) + { + if (oa.isSameAnimationClip(animation_clip)) + { + return oa.index; + } + } + // IF NO EXISTING ANIMATION CLIP WAS FOUND CREATE A NEW ANIMATION CLIP + + allUniqueAnimationClips.Add(new ObjectExtrasAnimationClip(animation_clip)); + return allUniqueAnimationClips.Count - 1; + } + } + private bool isSameAnimationClip(AnimationClip animation_clip) + { + if (animation_clip == animationClip) + return true; + return false; + } + + public ObjectExtrasAnimationClip(AnimationClip animation_clip) + { + animationClip = animation_clip; + index = globalIndex; + + animationProperties = new List();//get data at the end + trackNames = new List(); + keyTimes = new List(); + keyValues = new List(); + keyWeights= new List(); + keyTangents = new List(); + + float duration = animationClip.averageDuration; + + EditorCurveBinding[] animation_curves = AnimationUtility.GetCurveBindings(animation_clip); + + for (int i = 0; i < animation_curves.Length; i++) + { + + EditorCurveBinding curve = animation_curves[i]; + + string trackName = GetTrackName(curve); + if (trackName != "") + { + float mult = 1; + if (trackName.Contains(".rotation")) + { + mult = Mathf.Deg2Rad; + if (!trackName.Contains("[z]")) + mult *= -1; + } + if (trackName.Contains(".position[z]")) + { + mult *= -1; + } + + + + Keyframe[] keys = AnimationUtility.GetEditorCurve(animation_clip, curve).keys; + + + int lastItemArray = 0; + int firstItemArray = 0; + + + // IF LAST KEYFRAME IS NOT ATE THE END OF THE OVERALL ANIMATION DURATION, ADD A KEYFRAME + if (keys[keys.Length - 1].time < duration) + lastItemArray = 1; + + // IF FIRST KEY IS NOT IN TIME 0, ADD A KEYFRAME AT VALUE 0 + if (keys[0].time != 0f) + firstItemArray = 1; + + + + float[] key_times = new float[keys.Length + lastItemArray + firstItemArray]; + float[] key_values = new float[keys.Length + lastItemArray + firstItemArray]; + Vector2[] key_weight = new Vector2[keys.Length + lastItemArray + firstItemArray]; + Vector2[] key_tangents = new Vector2[keys.Length + lastItemArray + firstItemArray]; + + for (int j = 0; j < keys.Length; j++) + { + + key_times[j + firstItemArray] = keys[j].time; + key_values[j + firstItemArray] = keys[j].value * mult; // VALUES IN ROTATION MUST BE IN RAD + key_weight[j + firstItemArray] = new Vector2(keys[j].inWeight , keys[j].outWeight); + key_tangents[j + firstItemArray] = new Vector2(keys[j].inTangent > 1000 ? 0: keys[j].inTangent * mult // VALIDATE IS NOT INFINITY + , keys[j].outTangent > 1000 ? 0 : keys[j].outTangent * mult); // VALIDATE IS NOT INFINITY + } + + if (firstItemArray > 0) + { + key_times[0] = 0f; + key_values[0] = key_values[1]; + key_weight[0] = new Vector2(0.3f, 0.3f); + key_tangents[0] = new Vector2(key_values[1], key_values[1]); + } + + if (lastItemArray > 0) + { + key_times[key_times.Length - 1] = duration; + key_values[key_values.Length - 1] = key_values[key_values.Length - 2]; + + key_weight[key_weight.Length - 1] = new Vector2(0.3f,0.3f); + key_tangents[key_tangents.Length - 1] = new Vector2(key_values[key_values.Length - 1], key_values[key_values.Length - 1]); + + } + + trackNames.Add(trackName); + + keyTimes.Add(new ObjectAccessors(key_times)); + keyValues.Add(new ObjectAccessors(key_values)); + keyWeights.Add(new ObjectAccessors(key_weight)); + keyTangents.Add(new ObjectAccessors(key_tangents)); + } + + } + index = globalIndex; + globalIndex++; + } + private static string GetTrackName(EditorCurveBinding curve) + { + string result = ""; + bool saved = false; + if (curve.type == typeof(Transform)) + { + saved = true; + result += curve.path; + if (curve.propertyName.Contains("Position")) + result += ".position[" + curve.propertyName.Split('.')[1] + "]"; + if (curve.propertyName.Contains("Scale")) + result += ".scale[" + curve.propertyName.Split('.')[1] + "]"; + if (curve.propertyName.Contains("Euler")) + result += ".rotation[" + curve.propertyName.Split('.')[1] + "]"; + } + if (!saved && curve.type == typeof(Material)) + { + saved = true; + result += curve.path; + string[] matProps = curve.propertyName.Split('.'); + result += ".material." + matProps[0]; + if (matProps.Length > 0) + result += "[" + matProps[1] + "]"; + + } + if (!saved) + { + + } + + return result; + } + public static void AddGLTFDataToExtras() + { + if (allUniqueAnimationClips.Count > 0) + { + if (ExportToGLTF.options.exportAnimations) + { + List _animationClips = new List(); + + foreach (ObjectExtrasAnimationClip oa in allUniqueAnimationClips) + { + List _animationClip_single = new List(); + _animationClip_single.Add(new ObjectProperty("name", oa.animationClip.name)); + _animationClip_single.Add(new ObjectProperty("loop", oa.animationClip.isLooping)); + + + List _keyframeTracks = new List(); + for (int i = 0; i < oa.keyTimes.Count; i++) { + List _keyframeTracks_single = new List(); + _keyframeTracks_single.Add(new ObjectProperty("trackName", oa.trackNames[i])); + _keyframeTracks_single.Add(new ObjectProperty("TIME", oa.keyTimes[i].export_index)); + _keyframeTracks_single.Add(new ObjectProperty("VALUE", oa.keyValues[i].export_index)); + _keyframeTracks_single.Add(new ObjectProperty("WEIGHT", oa.keyWeights[i].export_index)); + _keyframeTracks_single.Add(new ObjectProperty("TANGENT", oa.keyTangents[i].export_index)); + _keyframeTracks.Add(new ObjectProperty("", _keyframeTracks_single)); + } + _animationClip_single.Add(new ObjectProperty("keyframeTracks", _keyframeTracks,true)); + _animationClips.Add(new ObjectProperty("", _animationClip_single)); + } + ObjectMasterExtras.Add(new ObjectProperty("animationClips", _animationClips,true)); + } + } + } + + } +} + + + + + diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationClip.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationClip.cs.meta new file mode 100644 index 0000000..5f554ec --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationClip.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 915cd09e05b0dd24ead3907a337d72e4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationController.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationController.cs new file mode 100644 index 0000000..c1c6b3b --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationController.cs @@ -0,0 +1,501 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using UnityEditor.Animations; +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectExtrasAnimationController + { + //statics + public static int globalIndex = -1; + public static List allUniqueAnimationControllers; + + //vars + public int index = -1; + + //public Animator animator; + public AnimatorController animatorController; + + //public List animationClipIndices; + public List connectedNodeIndices; + public float timeScale; + public List animLayers; + public List parameters; + + + //used to know copies of states and triggers + public List animatorParameters; + //private List animatorStates;//cant go here + + public static void Reset() + { + globalIndex = 0; + allUniqueAnimationControllers = new List(); + } + public static int GetAnimatorIndex(Animator _animator, int _mono_node) + { + if (_animator == null) + return -1; + + AnimatorController animator_controller = null; + if (_animator.runtimeAnimatorController != null) + { + animator_controller = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(_animator.runtimeAnimatorController)); + } + if (animator_controller == null) + return -1; + + if (allUniqueAnimationControllers == null) + { + allUniqueAnimationControllers = new List(); + + allUniqueAnimationControllers.Add(new ObjectExtrasAnimationController(animator_controller,_animator, _mono_node)); + + return allUniqueAnimationControllers.Count - 1; + } + else + { + foreach (ObjectExtrasAnimationController oam in allUniqueAnimationControllers) + { + if (oam.isSameAnimationMixer(animator_controller)) + { + + oam.connectedNodeIndices.Add(_mono_node); + return oam.index; + } + } + allUniqueAnimationControllers.Add(new ObjectExtrasAnimationController(animator_controller, _animator, _mono_node)); + return allUniqueAnimationControllers.Count - 1; + } + } + + private bool isSameAnimationMixer(AnimatorController animator_controller) + { + if (animator_controller == animatorController) + return true; + return false; + } + + private List getConditions(AnimatorCondition[] _conditions, List existing_list = null) + { + if (existing_list == null) + existing_list = new List(); + foreach (AnimatorCondition condition in _conditions) + { + List _single_condition = new List(); + for (int j = 0; j < animatorParameters.Count; j++) + { + if (animatorParameters[j].name == condition.parameter) + { + _single_condition.Add(new ObjectProperty("param", j)); + _single_condition.Add(new ObjectProperty("cond", GetConditionModeString(condition.mode))); + switch (animatorParameters[j].type) + { + case AnimatorControllerParameterType.Bool: + case AnimatorControllerParameterType.Trigger: + _single_condition.Add(new ObjectProperty("value", true)); // must only be compared to true, condition.mode will decide wether its true or false + break; + case AnimatorControllerParameterType.Float: + case AnimatorControllerParameterType.Int: + _single_condition.Add(new ObjectProperty("value", condition.threshold)); + break; + } + } + } + + existing_list.Add(new ObjectProperty("", _single_condition)); + } + return existing_list; + } + + private ObjectProperty getTransition(int from, int to, AnimatorTransition transition = null) + { + List _single_transition = new List(); + _single_transition.Add(new ObjectProperty("from", from)); + // GET TARGET STATE + _single_transition.Add(new ObjectProperty("to", to)); + + if (transition != null) //in default mode is null + { + List _conditions = getConditions(transition.conditions); + if (_conditions.Count > 0) + _single_transition.Add(new ObjectProperty("conditions", _conditions, true)); + } + return new ObjectProperty("", _single_transition); + } + + private ObjectProperty getStateTransition(int from, int to, AnimatorStateTransition transition) + { + List _single_transition = new List(); + List _params = new List(); + _single_transition.Add(new ObjectProperty("from", from)); + // GET TARGET STATE + _single_transition.Add(new ObjectProperty("to", to)); + + List _conditions = getConditions(transition.conditions); + if (_conditions.Count > 0) + _single_transition.Add(new ObjectProperty("conditions", _conditions, true)); + + if (transition.hasExitTime) + _params.Add(new ObjectProperty("exitTime", transition.exitTime)); + if (transition.offset != 0) + _params.Add(new ObjectProperty("offset",transition.offset)); + + if (transition.interruptionSource != TransitionInterruptionSource.None) + { + switch (transition.interruptionSource) + { + case TransitionInterruptionSource.Source: + _params.Add(new ObjectProperty("fromBreaks",true)); + if (!transition.orderedInterruption) _params.Add(new ObjectProperty("orderedBreak", false)); + break; + case TransitionInterruptionSource.Destination: + _params.Add(new ObjectProperty("toBreaks", true)); + // Ordered break doesnt work here + break; + case TransitionInterruptionSource.SourceThenDestination: + _params.Add(new ObjectProperty("fromBreaks", true)); + _params.Add(new ObjectProperty("toBreaks", true)); + if (!transition.orderedInterruption) _params.Add(new ObjectProperty("orderedBreak", false)); + break; + case TransitionInterruptionSource.DestinationThenSource: + _params.Add(new ObjectProperty("fromBreaks", true)); + _params.Add(new ObjectProperty("toBreaks", true)); + _params.Add(new ObjectProperty("fromPriority",false)); + if (!transition.orderedInterruption) _params.Add(new ObjectProperty("orderedBreak", false)); + break; + } + } + + _params.Add(new ObjectProperty("duration", transition.duration)); + _params.Add(new ObjectProperty("fixedDuration", transition.hasFixedDuration)); + + if (_params.Count > 0) + _single_transition.Add(new ObjectProperty("params", _params)); + //interruption source? + return new ObjectProperty("", _single_transition); + } + + private ObjectProperty getDualTransition(int from, int to, AnimatorTransition transition, AnimatorStateTransition state_transition) + { + List _single_transition = new List(); + List _params = new List(); + _single_transition.Add(new ObjectProperty("from", from)); + // GET TARGET STATE + _single_transition.Add(new ObjectProperty("to", to)); + + List _conditions = getConditions(transition.conditions); + _conditions = getConditions(state_transition.conditions, _conditions); + if (_conditions.Count > 0) + _single_transition.Add(new ObjectProperty("conditions", _conditions, true)); + + if (state_transition.hasExitTime) + _params.Add(new ObjectProperty("exitTime", state_transition.exitTime)); + if (state_transition.offset != 0) + _params.Add(new ObjectProperty("offset", state_transition.offset)); + + _params.Add(new ObjectProperty("duration", state_transition.duration)); + _params.Add(new ObjectProperty("fixedDuration", state_transition.hasFixedDuration)); + + if (_params.Count > 0) + _single_transition.Add(new ObjectProperty("params", _params)); + + return new ObjectProperty("", _single_transition); + } + + private void GetAllAnimatorStates(ref List animatorStateList, AnimatorStateMachine stateMachine) + { + // Get all simple states + foreach (ChildAnimatorState state in stateMachine.states) + { + animatorStateList.Add(state.state); + } + + // Get All state machines states + foreach (ChildAnimatorStateMachine subStateMachine in stateMachine.stateMachines) + { + GetAllAnimatorStates(ref animatorStateList, subStateMachine.stateMachine); + } + } + + public ObjectExtrasAnimationController(AnimatorController animator_controller, Animator _animator, int _mono_node) + { + connectedNodeIndices = new List(); + connectedNodeIndices.Add(_mono_node); + animLayers = new List(); + parameters = new List(); + timeScale = _animator.speed; + + animatorController = animator_controller; + + animatorParameters = new List(); + foreach (AnimatorControllerParameter param in animatorController.parameters) + { + List _single_param = new List(); + switch (param.type) + { + case AnimatorControllerParameterType.Bool: + parameters.Add(new ObjectProperty("", new ObjectProperty(param.name, param.defaultBool))); + break; + case AnimatorControllerParameterType.Float: + parameters.Add(new ObjectProperty("",new ObjectProperty(param.name, param.defaultFloat))); + break; + case AnimatorControllerParameterType.Int: + parameters.Add(new ObjectProperty("", new ObjectProperty(param.name, param.defaultInt))); + break; + case AnimatorControllerParameterType.Trigger: + List triggerProperty = new List(); + triggerProperty.Add(new ObjectProperty("value", param.defaultBool)); + _single_param.Add(new ObjectProperty(param.name, triggerProperty)); + parameters.Add(new ObjectProperty("", _single_param)); + break; + } + + animatorParameters.Add(param); + } + + for (int l = 0; l < animatorController.layers.Length; l++) + { + AnimatorControllerLayer animLayer = animatorController.layers[l]; + + List _single_layer = new List(); + List _states = new List(); + List _transitions = new List(); + + List _animator_states = new List(); + + // LAYER BASIC PROERTIES + _single_layer.Add(new ObjectProperty("name", animLayer.name)); + _single_layer.Add(new ObjectProperty("blendMode", animLayer.blendingMode.ToString().ToLower())); + if (l!= 0) _single_layer.Add(new ObjectProperty("weight", animLayer.defaultWeight)); + // SAVE SYNCED DATA + if (animLayer.syncedLayerIndex != -1) + { + Debug.Log(animLayer.name); + Debug.Log(animLayer.stateMachine.stateMachines.Length); + Debug.Log(animLayer.stateMachine.states.Length); + // GET THE "FULL" LIST OF ALL ANIMATOR STATES IN SYNCED LAYER + AnimatorControllerLayer syncLayer = animatorController.layers[animLayer.syncedLayerIndex]; + GetAllAnimatorStates(ref _animator_states, syncLayer.stateMachine); + //GetAllAnimatorStates(ref _animator_states, animLayer.stateMachine); + //animLayer. + + List _syncedClips = new List(); + // SYNCED LAYERS WILL HAVE ONLY THE INDEX OF THE CLIPS + Debug.Log(_animator_states.Count); + foreach (AnimatorState st in _animator_states) + { + if (st.motion != null) + { + if (st.motion.GetType() == typeof(AnimationClip)) + _syncedClips.Add(ObjectExtrasAnimationClip.GetAnimationIndex(animLayer.GetOverrideMotion(st) as AnimationClip)); + else + { + // BLEND TREE SECTION + } + } + else + { + _syncedClips.Add(ObjectExtrasAnimationClip.GetAnimationIndex(animLayer.GetOverrideMotion(st) as AnimationClip)); + } + } + + _single_layer.Add(new ObjectProperty("sync", animLayer.syncedLayerIndex)); + if (animLayer.syncedLayerAffectsTiming) _single_layer.Add(new ObjectProperty("timing", true)); + _single_layer.Add(new ObjectProperty("syncedClips", _syncedClips)); + } + // SAVE ALL DATA + else + { + // GET THE "FULL" LIST OF ALL ANIMATOR STATES IN THIS LAYER + GetAllAnimatorStates(ref _animator_states, animatorController.layers[l].stateMachine); + + // DEFAULT STATE TRANSITION, IF ITS INSIDE A SUBSTATE MACHINE, IT WILL TAKE IT NO MATTER + int defaultStateIndex = _animator_states.IndexOf(animLayer.stateMachine.defaultState); + if (animLayer.stateMachine.defaultState != null) + _single_layer.Add(new ObjectProperty("initialState", defaultStateIndex)); + + AddStateMachine(animLayer.stateMachine, ref _animator_states, ref _states, ref _transitions); + + // DEFAULT TRANSITIONS GETS WRITTEN AT THE END, BECAUSE IF NO OTHER VALIDATION SUCCEEDS, DEFAULT IS TAKEN + if (defaultStateIndex != -1) + _transitions.Add(getTransition(-1, defaultStateIndex, null)); + + // FINALLY ADD THE MODIFIED LISTS TO THE LAYER LIST + _single_layer.Add(new ObjectProperty("states", _states, true)); + _single_layer.Add(new ObjectProperty("transitions", _transitions, true)); + } + + // AND THE LAYER TO THE LAYERS ARRAY + animLayers.Add(new ObjectProperty("", _single_layer)); + + } + //objectProperties.Add(new ObjectProperty("timeScale", animator_controller.speed)); + + index = globalIndex; + globalIndex++; + + } + // == FIRST STEP == GET THE STATE MACHINE + private void AddStateMachine(AnimatorStateMachine state_machine, ref List animator_states, ref List _states, ref List _transitions) + { + foreach (ChildAnimatorState child_states in state_machine.states) + { + //.. get each state data + AddStateData(child_states.state, ref animator_states, ref _states, ref _transitions); + } + foreach (ChildAnimatorStateMachine child_state_machines in state_machine.stateMachines) + { + //.. call this function again + AddStateMachine(child_state_machines.stateMachine, ref animator_states, ref _states, ref _transitions); + } + + + // ONLY IN SUBMACHINES WE CHECK "ENTRY STATE"... + foreach (AnimatorTransition transition in state_machine.entryTransitions) + { + int destinationState = animator_states.IndexOf(transition.destinationState); + if (destinationState != -1) + _transitions.Add(getTransition(-1, destinationState, transition)); + } + // ... AND "ANY STATE" TRANSITIONS + foreach (AnimatorStateTransition transition in state_machine.anyStateTransitions) + { + // CHECK FOR AT LEAST 1 CONDITION, ELSE, SKIP OR ERRORS WILL OCCUR + if (transition.conditions.Length != 0) + { + int destinationState = animator_states.IndexOf(transition.destinationState); + _transitions.Add(getStateTransition(-2, destinationState, transition)); + } + } + + } + private int GetParamID(string param_name) + { + for (int i = 0; i < animatorParameters.Count; i++) + { + if (animatorParameters[i].name == param_name) + { + return i; + } + } + return -1; + } + // == SECOND STEP == SAVE THE STATES DATA + private void AddStateData(AnimatorState _state, ref List animator_states, ref List _states, ref List _transitions) + { + List _single_state = new List(); + + // BASIC STATE DATA SUCH AS NAME, CLIP AND SPEED + _single_state.Add(new ObjectProperty("name", _state.name)); + if (_state.speedParameterActive) + _single_state.Add(new ObjectProperty("multParam", GetParamID(_state.speedParameter))); + + if (_state.timeParameterActive) + _single_state.Add(new ObjectProperty("motionParam", GetParamID(_state.timeParameter))); + + if (_state.cycleOffsetParameterActive) + _single_state.Add(new ObjectProperty("offsetParam", GetParamID(_state.cycleOffsetParameter))); + else + if (_state.cycleOffset != 0f) + _single_state.Add(new ObjectProperty("offset", _state.cycleOffset)); + + + + // ANIMATION CLIP / BLEND TREE PROPERTIES + if (_state.motion != null) // CAN BE AN EMPTY STATE + { + if (_state.motion.GetType() == typeof(AnimationClip)) //might be BlendTree + { + _single_state.Add(new ObjectProperty("clip", ObjectExtrasAnimationClip.GetAnimationIndex(_state.motion as AnimationClip))); + if (_state.speed != 1) _single_state.Add(new ObjectProperty("speed", _state.speed)); + } + else + { + //blend tree type + } + } + + // STATE TRANSITIONS DATA, MIGHT HAVE MORE THAN 1 + int state_index = animator_states.IndexOf(_state); + if (_state.transitions.Length > 0) + { + // ADD INVERSED TO KEEP PTRIORITIES + for (int i = _state.transitions.Length - 1; i >= 0; i--) + { + if (_state.transitions[i].conditions.Length > 0 || _state.transitions[i].hasExitTime) + AddTransition(state_index, _state.transitions[i], ref animator_states, ref _transitions); + } + } + + // SAVE TO THE LIST OF ALL STATES IN THE REFERENCED LIST + _states.Add(new ObjectProperty("", _single_state)); + } + + // == THIRD STEP == SAVE TRANSITIONS DATA + private void AddTransition(int from_id, AnimatorStateTransition transition, ref List animator_states, ref List transitions_list) + { + if (transition.destinationState != null) + { + // ADD IT NORMALLY, TRANSITION ENDS HERE + int destinationState = animator_states.IndexOf(transition.destinationState); + transitions_list.Add(getStateTransition(from_id, destinationState, transition)); + } + else if (transition.destinationStateMachine != null) + { + // GET THE MACHINE STATE, AND GET ALL TRANSITIONS FROM WITHIN + AddTransitionsFromStateMachine(from_id, transition, transition.destinationStateMachine, ref animator_states, ref transitions_list); + } + + } + + // == FOURTH STEP == VALIDATE TRANSITIONS FROM STATE MACHINES + private void AddTransitionsFromStateMachine(int from_id, AnimatorStateTransition last_transition , AnimatorStateMachine state_machine, ref List animator_states, ref List transitions_list) + { + + int default_index = animator_states.IndexOf(state_machine.defaultState); + + // CHECK "ENTRY TRANSITIONS", THEY WILL BE CONNECTED TO THE STATE ID PROVIDED FROM BEFORE + foreach (AnimatorTransition transition in state_machine.entryTransitions) + { + int destinationState = animator_states.IndexOf(transition.destinationState); + if (destinationState != default_index) + { // DEFAULT TRANSITION MUST BE ADDED THE END + transitions_list.Add(getDualTransition(from_id, destinationState,transition,last_transition)); + } + } + // IN "DEFAULT" CASE, THERE IS NO CONDITION, SO WE TAKE THE CONDITION FROM PREVIOUS LAYER + transitions_list.Add(getStateTransition(from_id, default_index, last_transition)); + } + + private string GetConditionModeString(AnimatorConditionMode mode) + { + return mode.ToString().ToLower(); + } + public static void AddGLTFDataToExtras() + { + if (allUniqueAnimationControllers.Count > 0) + { + if (ExportToGLTF.options.exportAnimations) + { + List _animationControllers = new List(); + foreach (ObjectExtrasAnimationController oac in allUniqueAnimationControllers) + { + List _anim_controller = new List(); + _anim_controller.Add(new ObjectProperty("name", oac.animatorController.name)); + _anim_controller.Add(new ObjectProperty("nodes", oac.connectedNodeIndices)); + if (oac.timeScale != 1f) _anim_controller.Add(new ObjectProperty("timeScale",oac.timeScale)); + if (oac.parameters.Count > 0) _anim_controller.Add(new ObjectProperty("parameters", oac.parameters, true)); + _anim_controller.Add(new ObjectProperty("layers", oac.animLayers,true)); + + _animationControllers.Add(new ObjectProperty("", _anim_controller)); + + } + ObjectMasterExtras.Add(new ObjectProperty("animationControllers", _animationControllers,true)); + } + } + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationController.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationController.cs.meta new file mode 100644 index 0000000..c916d94 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasAnimationController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8e40a16994593134bac8723ae1f5dd03 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasCubeTextures.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasCubeTextures.cs new file mode 100644 index 0000000..d4fc90e --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasCubeTextures.cs @@ -0,0 +1,199 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectExtrasCubeTextures + { + //consts + const string exportPreName = "cbm_"; + const bool exportPropertyName = false; + + //statics + public static int globalIndex = -1; + public static List allUniqueCubemaps; + public static int environmentCubemap = -1; + + //vars + public int index = -1; + + public Cubemap cubemap; + public CubemapExtra cubemapExtra; + public List cubemapProperties; + public int quality = 0; + + string exportName; + public static void Reset() + { + globalIndex = 0; + allUniqueCubemaps = new List(); + } + + public static int GetCubemapIndex(Cubemap _cubemap, int _quality = 0) + { + if (_cubemap == null) + return -1; + if (allUniqueCubemaps == null) + { + allUniqueCubemaps = new List(); + + allUniqueCubemaps.Add(new ObjectExtrasCubeTextures(_cubemap,_quality)); + + return allUniqueCubemaps.Count - 1; + } + else + { + foreach (ObjectExtrasCubeTextures oc in allUniqueCubemaps) + { + if (oc.isSameCubemap(_cubemap)) + { + return oc.index; + } + } + // IF NO EXISTING ANIMATION CLIP WAS FOUND CREATE A NEW ANIMATION CLIP + + allUniqueCubemaps.Add(new ObjectExtrasCubeTextures(_cubemap,_quality)); + return allUniqueCubemaps.Count - 1; + } + } + + private bool isSameCubemap(Cubemap _cubemap) + { + if (_cubemap == cubemap) + return true; + return false; + } + + public ObjectExtrasCubeTextures(Cubemap _cubemap, int _quality = 0) + { + cubemap = _cubemap; + quality = _quality; + if (quality > 100) quality = 100; + if (quality < 0) quality = 0; + index = globalIndex; + exportName = exportPreName + globalIndex; + cubemapExtra = new CubemapExtra(_cubemap, exportName); + cubemapProperties = GetTextureProperties(_cubemap, cubemapExtra, _quality); + index = globalIndex; + globalIndex++; + } + public List GetTextureProperties(Cubemap _cubemap, CubemapExtra _cubemapExtra, int _quality = 0) + { + bool _exportFallback = ExportToGLTF.options.SaveFallback(TextureType.CUBEMAP); + + List _texture_properties = new List(); + string _name = exportName; + int _sampler = ObjectSampler.GeSamplerIndex(_cubemap); + int[] _source = new int[6]; + Texture2D[] _cubemapTextures = _cubemapExtra.GetCubemapTextures(); + + for (int i =0; i < _cubemapTextures.Length;i++) + { + _source[i] = ObjectImage.GetImageIndex(_cubemapTextures[i], TextureType.CUBEMAP, false, false, false, _exportFallback, _quality); + } + if (exportPropertyName) _texture_properties.Add(new ObjectProperty("name", _name)); + _texture_properties.Add(new ObjectProperty("sampler", _sampler)); + + TextureExportType _export_type = ExportToGLTF.options.GetExportTextureType(TextureType.CUBEMAP); + + // WEBP OR NON WEBP SECTION + if (_export_type == TextureExportType.DEFAULT || _exportFallback) // IF FALLBACK SAVE HERE SOURCE TOO + { + _texture_properties.Add(new ObjectProperty("source", _source)); + } + if (_export_type != TextureExportType.DEFAULT) + { + int[] _source_default = new int[6]; + for (int i = 0; i < _source.Length; i++) + _source_default[i] = _source[i]; + + if (ExportToGLTF.options.fallbackGLTFTexture) + { + for (int i =0; i < _source.Length; i++) + { + _source_default[i]+=1; // IF WE HAVE FALLBACK ON TOP, WE MUST ADD 6 TO THE SOURCE, SINCE THE ORIGINAL IMAGES COMES AFTER THE FALLBACK IMAGES (SOURCE) + } + } + bool _requiredExtensions = _exportFallback ? false:true; // IF WE HAVE FALLBACK, WE DONT NECESSARY REQUIRE THE EXTENSION + + ObjectProperty _extensions = new ObjectProperty(); // CREATE AN EMPTY OBJECT THAT WILL HOLD THE EXTENSION + if (_export_type == TextureExportType.WEBP) + _extensions.AddExtensionObject(CreateEXT_texture_webp(_source_default, _requiredExtensions)); + if (_export_type == TextureExportType.KTX2) + _extensions.AddExtensionObject(CreateKHR_texture_basisu(_source_default, _requiredExtensions)); + _texture_properties.Add(_extensions); + } + + return _texture_properties; + + + } + + public ObjectExtension CreateEXT_texture_webp(int[] source, bool is_required) + { + List _properties = new List(); + if (source.Length > 0) + { + _properties.Add(new ObjectProperty("source", source)); + ObjectExtension ext_texture_webp = new ObjectExtension("EXT_texture_webp", _properties, is_required); + return ext_texture_webp; + } + return null; + } + + public ObjectExtension CreateKHR_texture_basisu(int[] source, bool is_required) + { + List _properties = new List(); + if (source.Length > 0) + { + _properties.Add(new ObjectProperty("source", source)); + ObjectExtension ext_texture_webp = new ObjectExtension("KHR_texture_basisu", _properties, is_required); + return ext_texture_webp; + } + return null; + } + + public static void AddGLTFDataToExtras() + { + //if (ExportToGLTF.options.extraExportEnviromentCubemapInGLTF) + //GetEnviromentData(ExportToGLTF.options.computedEnvironmentCubemap); + + if (allUniqueCubemaps.Count > 0) + { + List _cubemaps = new List(); + + foreach (ObjectExtrasCubeTextures oc in allUniqueCubemaps) + { + _cubemaps.Add(new ObjectProperty("", oc.cubemapProperties)); + } + ObjectMasterExtras.Add(new ObjectProperty("cubeTextures", _cubemaps, true)); + } + } + //public static void GetEnviromentData(Cubemap _cubemap) + //{ + // environmentCubemap = GetCubemapIndex(_cubemap); + // if (environmentCubemap != -1) + // { + // ObjectMasterExtras.Add(new ObjectProperty("environment", environmentCubemap)); + // } + //} + + //public static void GetEnviromentData(Cubemap cubemap_extra, string export_location) + //{ + // if (cubemap_extra == null) + // Debug.LogWarning("NULL enviroment cubemap, a default texture will be created"); + // if (cubemap_extra == null) + // cubemap_extra = new CubemapExtra(new Color(0.2f, 0.2f, 0.2f), "env"); + + // Texture2D[] refProbeTextures = cubemap_extra.GetCubemapTextures(); + // string[] textureNames = new string[6]; + // for (int i = 0; i < refProbeTextures.Length; i++) + // { + // FileExporter.ExportToJPEG(refProbeTextures[i], cubemap_extra.name + i, export_location, 75); + // textureNames[i] = cubep_extra.name + i + ".jpg"; + // } + // properties.Add(new ObjectProperty("environment", textureNames)); + //} + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasCubeTextures.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasCubeTextures.cs.meta new file mode 100644 index 0000000..aa783e9 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectExtrasCubeTextures.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d82e10d619093d34fb198863db73f79f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectImage.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectImage.cs new file mode 100644 index 0000000..0792c8b --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectImage.cs @@ -0,0 +1,475 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectImage + { + //consts + public const string exportPreName = "img_"; + //public const bool exportInWebp = false; //NOT IMPLEMENTED IN TRUE YET + + //statics + public static int globalIndex = -1; + public static List allUniqueImages; + + //vars + public int index = -1; + + TextureType textureType; + public bool checkedAlpha = false; + public bool hasAlpha = false; + public bool usesAlpha = false; + public bool isAlpha = false; + + public float smooth = 1; + public float metal = 1; + + public Texture2D image; + public bool metalSmoothMap = false; // METAL SMOOTH MAP MUST BE CREATED INSTEAD OF JUST COPIED, SO TEXTURE MIGHT BE THE SAME, BUT IF THE SAME TEXTURE IS USED IN METAL SMOOTHNESS MAP, A NEW TEXTURE MUST BE SAVED + public List imageProperties; + public string exportName; + public string originalName; + + public bool isFallback = false; + + public int quality = 0; + public static void Reset() + { + globalIndex = 0; + allUniqueImages = new List(); + } + + public static int GetImageIndex(Texture2D texture_2D, TextureType texture_type, bool metal_smooth_map, bool check_for_alpha, bool is_alpha = false, bool save_fallback = false, int _quality = 0, float _smoothnessMult = 1, float _metallicMult = 1) + { + if (allUniqueImages == null) + { + allUniqueImages = new List(); + allUniqueImages.Add(new ObjectImage(texture_2D, texture_type, metal_smooth_map, check_for_alpha, is_alpha, save_fallback,_quality, _smoothnessMult, _metallicMult)); + if (save_fallback) + { + ObjectImage nonFallbackImage = new ObjectImage(texture_2D, texture_type, metal_smooth_map, check_for_alpha, is_alpha, false,_quality, _smoothnessMult, _metallicMult); + allUniqueImages.Add(nonFallbackImage); // STORE THE MAIN IMAGE + return allUniqueImages.Count - 2; // RETURN JPEG FALLBACK IMAGE + } + + return allUniqueImages.Count - 1; + } + else + { + foreach (ObjectImage oi in allUniqueImages) + { + if (oi.IsSameImage(texture_2D, is_alpha)) + { + if (check_for_alpha) + oi.CheckHasAlpha(); + return oi.index; + } + } + // IF IMAGE IS NOT IN LIST, ADD IT TO THE LIST + + + allUniqueImages.Add(new ObjectImage(texture_2D, texture_type, metal_smooth_map,check_for_alpha,is_alpha,save_fallback,_quality, _smoothnessMult, _metallicMult)); // FIRST SAVED TEXTURE IS NOT ALPHA + if (save_fallback) + { + ObjectImage nonFallbackImage = new ObjectImage(texture_2D, texture_type, metal_smooth_map, check_for_alpha, is_alpha,false,_quality, _smoothnessMult, _metallicMult); + allUniqueImages.Add(nonFallbackImage); // STORE THE MAIN IMAGE + return allUniqueImages.Count - 2; // RETURN JPEG FALLBACK IMAGE + } + return allUniqueImages.Count - 1; + } + } + private void CheckHasAlpha() + { + if (!checkedAlpha) + { + hasAlpha = ImageGenerator.HasAlphaInformation(image); + checkedAlpha = true; + } + if (hasAlpha) + { + usesAlpha = true; + UpdateListToPNG(); + } + + } + private bool IsSameImage(Texture2D texture_2D, bool is_alpha = false) + { + if (texture_2D == image && isAlpha == is_alpha) + { + + return true; + } + return false; + } + + public ObjectImage(Texture2D texture_2D, TextureType texture_type, bool metal_smooth_map, bool check_for_alpha, bool is_alpha, bool is_fallback, int _quality = 0, float _smoothnessMult = 1f, float _metallicMult = 1f) + { + + image = texture_2D; + quality = _quality; + metal = _metallicMult; + smooth = _smoothnessMult; + if (quality > 100) quality = 100; + if (quality < 0) quality = 0; //if value is 0, program will take value from main gltf options + textureType = texture_type; + isFallback = is_fallback; + metalSmoothMap = metal_smooth_map; + isAlpha = is_alpha; + index = globalIndex; + exportName = exportPreName + globalIndex; + originalName = texture_2D.name; + if (check_for_alpha) + CheckHasAlpha(); + + imageProperties = GetImageProperties(texture_2D); + if (usesAlpha) + UpdateListToPNG(); + + + globalIndex++; + } + + public List GetImageProperties(Texture2D texture_2D) + { + // IF METAL SMOOTH MAP, A NEW TEXTURE MUST BE CREATED!! + List _image_properties = new List(); + string _uri = exportName + ".jpg"; + string _name = originalName; + string _mimeType = "image/jpeg"; + + //if (isFallback) + //Debug.Log("isFallback"); + TextureExportType export_type = ExportToGLTF.options.GetExportTextureType(textureType); + if (export_type == TextureExportType.WEBP && !isFallback) + { + _mimeType = "image/webp"; + _uri = exportName + ".webp"; + // edit cmd + } + if (export_type == TextureExportType.KTX2 && !isFallback) + { + _mimeType = "image/ktx2"; + _uri = exportName + ".ktx2"; + } + + + _image_properties.Add(new ObjectProperty("uri", _uri)); + _image_properties.Add(new ObjectProperty("mimeType", _mimeType)); + if (_name != "" && ExportToGLTF.options.exportTexturesName) + _image_properties.Add(new ObjectProperty("name",_name)); + + return _image_properties; + } + public void UpdateListToPNG() + { + if (imageProperties != null) + { + if (ExportToGLTF.options.exportTextureType == TextureExportType.DEFAULT) + { + if (!ExportToGLTF.options.ExportSeparatedAlphaMap()) + { + imageProperties[0].propertyString = exportName + ".png"; + imageProperties[1].propertyString = "image/png"; + } + } + } + } + public static void ExportAllImages(string location, int hdr_quality = 75, int normal_quality = 75, int metalRough_quality = 75, int default_quality = 75) + { + AddCMDDeleteLine(location); // START CMD LINES END LINES + RenderTextureImageConverter.InitializeRenderTexture(); + + ConvertToEditableTextures(); + foreach (ObjectImage oi in allUniqueImages) + { + oi.ExportImage(location, hdr_quality, normal_quality, metalRough_quality, default_quality, oi.isFallback); + } + RenderTextureImageConverter.TerminateRenderTexture(); ; + + } + + + public void ExportImage(string location, int hdr_quality=75, int normal_quality =75, int metalRough_quality = 75, int default_quality = 75, bool is_fallback = false) + { + //Debug.Log(exportName + " " + textureType); + if (quality != 0) + hdr_quality = normal_quality = metalRough_quality = default_quality = quality; + + int _divideFactor = 1; + + if (metalSmoothMap) + { + + _divideFactor = ExportToGLTF.options.GetImagesDivideFactor("metallicSmoothness"); + AddCMDStartLine(ExportToGLTF.options.overrideMetallicSmoothnessExportTextureType); + float metallicMultiplier = ExportToGLTF.options.metallicMultiplier; + float smoothnessMultiplier = ExportToGLTF.options.smoothnessMultiplier; + + if (ExportToGLTF.options.overrideMetallicSmoothnessExportTextureType == TextureExportType.WEBP && !is_fallback) + { + AddCMDWebpLine(exportName, location, "jpg", metalRough_quality); + Texture2D metalMap = ImageGenerator.CreateGLTFMetallicRoughness(image, metallicMultiplier * metal, smoothnessMultiplier * smooth); + FileExporter.ExportToJPEG(TextureScaler.scaled(metalMap, image.width / _divideFactor, image.height / _divideFactor, FilterMode.Bilinear), exportName, location, 100); + + } + if (ExportToGLTF.options.overrideMetallicSmoothnessExportTextureType == TextureExportType.KTX2 && !is_fallback) + { + AddCMDKTXLine(exportName, location, "jpg", metalRough_quality); + Texture2D metalMap = ImageGenerator.CreateGLTFMetallicRoughness(image, metallicMultiplier * metal, smoothnessMultiplier * smooth,true); + FileExporter.ExportToJPEG(TextureScaler.scaled(metalMap, image.width / _divideFactor, image.height / _divideFactor, FilterMode.Bilinear), exportName, location, 100); + + } + if (ExportToGLTF.options.overrideMetallicSmoothnessExportTextureType == TextureExportType.DEFAULT || is_fallback) + { + Texture2D metalMap = ImageGenerator.CreateGLTFMetallicRoughness(image, metallicMultiplier * metal, smoothnessMultiplier * smooth); + FileExporter.ExportToJPEG(TextureScaler.scaled(metalMap, image.width/_divideFactor, image.height/_divideFactor,FilterMode.Bilinear), exportName, location, metalRough_quality); + + } + } + else + { + //switch (ImageGenerator.GetImageImportType(image)) + switch (textureType) + { + case TextureType.CUBEMAP: + _divideFactor = ExportToGLTF.options.GetImagesDivideFactor("cubemap"); + AddCMDStartLine(ExportToGLTF.options.overrideCubemapTextureType); + if (ExportToGLTF.options.overrideCubemapTextureType == TextureExportType.WEBP && !isFallback) + { + AddCMDWebpLine(exportName, location, "jpg", default_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.basic, 100, ExportToGLTF.options.colorTextureSaturation, _divideFactor); + //FileExporter.ExportToJPEG(image, exportName, location, 100); + } + if (ExportToGLTF.options.overrideCubemapTextureType == TextureExportType.KTX2 && !isFallback) + { + AddCMDKTXLine(exportName, location, "jpg", default_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.basic, 100, ExportToGLTF.options.colorTextureSaturation, _divideFactor); + //FileExporter.ExportToJPEG(image, exportName, location, default_quality); + } + if (ExportToGLTF.options.overrideCubemapTextureType == TextureExportType.DEFAULT || isFallback) + { + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.basic, default_quality, ExportToGLTF.options.colorTextureSaturation, _divideFactor); + //FileExporter.ExportToJPEG(image, exportName, location, default_quality); + } + break; + case TextureType.LIGHTMAP: + _divideFactor = ExportToGLTF.options.GetImagesDivideFactor("lightmap"); + AddCMDStartLine(ExportToGLTF.options.overrideLightmapExportTextureType); + if (ExportToGLTF.options.overrideLightmapExportTextureType == TextureExportType.WEBP && !is_fallback) + { + AddCMDWebpLine(exportName, location, "jpg", hdr_quality); + RenderTextureImageConverter.CreateNormalizedHDR(image, exportName, location, 100, true, ExportToGLTF.options.saturationLightmap,ExportToGLTF.options.maxLightmapClamp, ExportToGLTF.options.lightmapContrastCheat, _divideFactor); + } + if (ExportToGLTF.options.overrideLightmapExportTextureType == TextureExportType.KTX2 && !is_fallback) + { + AddCMDKTXLine(exportName, location, "jpg", hdr_quality); + RenderTextureImageConverter.CreateNormalizedHDR(image, exportName, location, 100, true, ExportToGLTF.options.saturationLightmap, ExportToGLTF.options.maxLightmapClamp, ExportToGLTF.options.lightmapContrastCheat, _divideFactor); + } + if (ExportToGLTF.options.overrideLightmapExportTextureType == TextureExportType.DEFAULT || is_fallback) // IF IS A FALLBACK TEXTURE, MAKE SURE TO ALSO EXPORT IT AS A JPEG + { + RenderTextureImageConverter.CreateNormalizedHDR(image, exportName, location, hdr_quality, true, ExportToGLTF.options.saturationLightmap, ExportToGLTF.options.maxLightmapClamp, ExportToGLTF.options.lightmapContrastCheat, _divideFactor); + } + break; + case TextureType.NORMAL: + _divideFactor = ExportToGLTF.options.GetImagesDivideFactor("normal"); + AddCMDStartLine(ExportToGLTF.options.overrideNormalExportTextureType); + if (ExportToGLTF.options.overrideNormalExportTextureType == TextureExportType.WEBP && !is_fallback) + { + AddCMDWebpLine(exportName, location, "jpg", normal_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.normal, 100,1, _divideFactor); + } + if (ExportToGLTF.options.overrideNormalExportTextureType == TextureExportType.KTX2 && !is_fallback) + { + AddCMDKTXLine(exportName, location, "jpg", normal_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.normal, 100, 1, _divideFactor); + } + if (ExportToGLTF.options.overrideNormalExportTextureType == TextureExportType.DEFAULT || is_fallback) + { + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.normal, normal_quality, 1, _divideFactor); + } + break; + default: + _divideFactor = ExportToGLTF.options.GetImagesDivideFactor("default"); + AddCMDStartLine(ExportToGLTF.options.overrideDefaultExportTextureType); + if (usesAlpha) + { + if (ExportToGLTF.options.ExportSeparatedAlphaMap()) + { + if (!isAlpha) + { // EXPORTS COLOR MAP FOR EACH TEXTURE TYPE == color map section == + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.WEBP && !is_fallback) + { + AddCMDWebpLine(exportName, location, "jpg", default_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName,location,RenderTextureImageConverter.MaterialType.basic,100, ExportToGLTF.options.colorTextureSaturation, _divideFactor); + //FileExporter.ExportToJPEG(image, exportName, location ,100); + } + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.KTX2 && !is_fallback) + { + AddCMDKTXLine(exportName, location, "jpg", default_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.basic, 100, ExportToGLTF.options.colorTextureSaturation, _divideFactor); + //FileExporter.ExportToJPEG(image, exportName, location,100); + } + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.DEFAULT || is_fallback) + { + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.basic, default_quality, ExportToGLTF.options.colorTextureSaturation, _divideFactor); + //FileExporter.ExportToJPEG(image, exportName, location, default_quality); + } + } + else + { // EXPORTS SEPARATED ALPHA MAP FOR EACH TEXTURE TYPE == alpha map section == + Texture2D alphaTexture = ImageGenerator.GetTextureFromAlpha(image, false); + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.WEBP && !is_fallback) + { + AddCMDWebpLine(exportName, location, "jpg", default_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(alphaTexture, exportName, location, RenderTextureImageConverter.MaterialType.basic, 100, 1, _divideFactor); + //FileExporter.ExportToJPEG(alphaTexture, exportName, location, 100); + } + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.KTX2 && !is_fallback) + { + AddCMDKTXLine(exportName, location, "jpg", default_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(alphaTexture, exportName, location, RenderTextureImageConverter.MaterialType.basic, 100, 1, _divideFactor); + //FileExporter.ExportToJPEG(alphaTexture, exportName, location, 100); + } + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.DEFAULT || is_fallback) + { + RenderTextureImageConverter.CreateTextureWithRenderTexture(alphaTexture, exportName, location, RenderTextureImageConverter.MaterialType.basic, default_quality, 1, _divideFactor); + //FileExporter.ExportToJPEG(alphaTexture, exportName, location, default_quality); + } + } + } + else + { // IF ALPHA MAP IS NOT SEPARATED == color map + alpha map section == + // MISSING!!, MATERIAL DESATURATION ExportToGLTF.options.colorDesaturation + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.WEBP && !is_fallback) + { + AddCMDWebpLine(exportName, location, "png", default_quality); + FileExporter.ExportToPNG(image, exportName, location); + } + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.KTX2 && !is_fallback) + { + AddCMDKTXLine(exportName, location, "png", default_quality); + FileExporter.ExportToPNG(image, exportName, location); + } + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.DEFAULT || is_fallback) + { + FileExporter.ExportToPNG(image, exportName, location); + } + } + } + else + { //IF IT DOESNT USE ALPHA, EXPORT NORMALLY + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.WEBP && !isFallback) + { + AddCMDWebpLine(exportName, location, "jpg", default_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.basic, 100, ExportToGLTF.options.colorTextureSaturation,_divideFactor); + //FileExporter.ExportToJPEG(image, exportName, location, 100); + } + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.KTX2 && !isFallback) + { + AddCMDKTXLine(exportName, location, "jpg", default_quality); + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.basic, 100, ExportToGLTF.options.colorTextureSaturation, _divideFactor); + //FileExporter.ExportToJPEG(image, exportName, location, default_quality); + } + if (ExportToGLTF.options.overrideDefaultExportTextureType == TextureExportType.DEFAULT || isFallback) + { + RenderTextureImageConverter.CreateTextureWithRenderTexture(image, exportName, location, RenderTextureImageConverter.MaterialType.basic, default_quality, ExportToGLTF.options.colorTextureSaturation, _divideFactor); + //FileExporter.ExportToJPEG(image, exportName, location, default_quality); + } + //Debug.Log("dont use alpha"); + } + break; + } + } + } + private static void ConvertToEditableTextures() + { + // MAKE SURE TO MAKE ALL TEXTURES DEFAULT FIRST + //List normalsHdrTexturesList = new List(); + List allTexturesList = new List(); + foreach (ObjectImage oi in allUniqueImages) + { + allTexturesList.Add(oi.image); + string img_type = ImageGenerator.GetImageImportType(oi.image); + //if (img_type == "lightmap" || img_type == "normal") // ONLY CHANGE LIGHTMAPS AND NORMALS, + //{ + //normalsHdrTexturesList.Add(oi.image); + //} + } + ImageGenerator.MakeReadableTexture(allTexturesList, false); + //ImageGenerator.MakeTextureTypeDefault(normalsHdrTexturesList, false); + ImageGenerator.RefreshDatabase(); + // END TEXTURE DEFINITION + } + private static void AddCMDStartLine(TextureExportType texture_type) // MOVE TO CWEBP LOCATION + { + if (texture_type != TextureExportType.DEFAULT) + { + string converter_path = ""; + if (ExportToGLTF.options.exportTextureType == TextureExportType.WEBP) + converter_path = StringUtilities.GetFullPathFromLocalPath(PathPreferences.webpConverterLocalPath); + if (ExportToGLTF.options.exportTextureType == TextureExportType.KTX2) + converter_path = StringUtilities.GetFullPathFromLocalPath(PathPreferences.ktx2ConverterLocalPath); + string result = converter_path.Split(':')[0] + ":\n"; + result += "cd " + converter_path + "\n"; + ExportToGLTF.cmd.AddLine(result); + } + } + public void AddCMDWebpLine(string name, string location, string extension, int img_quality) + { + string result = "cwebp -q "+ img_quality +" " + location + "/" + name + "." + extension + " -o " + location + "/" + name + ".webp\n"; + string endResult = "del " + location + "/" + name + "." + extension + "\n"; + endResult = endResult.Replace("/", "\\"); + // DELETE OLD TEXTURE? + ExportToGLTF.cmd.AddLine(result); + ExportToGLTF.cmd.AddEndLine(endResult); + } + public void AddCMDKTXLine(string name, string location, string extension, int img_quality) + { + string result = "toktx --t2 --bcmp --genmipmap --filter box --assign_oetf linear " + location + "/" + name + ".ktx2 " + location + "/" + name + "." + extension + "\n"; + string endResult = "del " + location + "/" + name + "." + extension + "\n"; + endResult = endResult.Replace("/", "\\"); + //string result = "toktx --t2 --bcmp --qlevel " + (Mathf.RoundToInt(img_quality * 2.54f) + 1) + " --genmipmap --filter box " + location + "/" + name + ".ktx2 " + location + "/" + name + "." + extension + "\n"; + //string result = "toktx --t2 --uastc 1 --genmipmap --filter box --zcmp 10 --uastc_rdo_l 1 --uastc_rdo_d 4096 --uastc_rdo_b 10 --uastc_rdo_f --uastc_rdo_m " + location + "/" + name + ".ktx2 " + location + "/" + name + "." + extension + "\n"; + + + //result += "ktxsc --bcmp --qlevel " + (Mathf.RoundToInt(img_quality * 2.54f) + 1) + " --genmipmap " + location + "/" + name + ".ktx2 " + location + "/" + name + "." + extension + "\n"; + //string result = "toktx --t2 --uastc 0 --zcmp 20 --genmipmap " + location + "/" + name + ".ktx2 " + location + "/" + name + "." + extension + "\n"; + // DELETE OLD TEXTURE? + ExportToGLTF.cmd.AddLine(result); + ExportToGLTF.cmd.AddEndLine(endResult); + } + + private static void AddCMDDeleteLine(string images_location) // MOVE TO CWEBP LOCATION + { + if (ExportToGLTF.options.exportTextureType != TextureExportType.DEFAULT) + { + string result = images_location.Split(':')[0] + ":\n"; + //result += "cd " + images_location + "/\n"; + //result += "del " + "*.jpg\n"; + //result += "del " + "*.png\n"; + ExportToGLTF.cmd.AddEndLine(result); + } + } + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + if (allUniqueImages.Count > 0) + { + result += "\"images\" : [\n"; + for (int i = 0; i < allUniqueImages.Count; i++) + { + result += ObjectProperty.GetObjectProperties(allUniqueImages[i].imageProperties); + if (i < allUniqueImages.Count - 1) + result += ",\n"; + } + result += "]"; + if (add_end_comma) + result += ",\n"; + } + return result; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectImage.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectImage.cs.meta new file mode 100644 index 0000000..0352561 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectImage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 50739348394c4344b85fcfef9e93cacd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterComputedExtrasMono.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterComputedExtrasMono.cs new file mode 100644 index 0000000..aaa8ef7 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterComputedExtrasMono.cs @@ -0,0 +1,28 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace WEBGL_EXPORTER.GLTF +{ + [ExecuteAlways] + public class ObjectMasterComputedExtrasMono : MonoBehaviour + { + public List properties; + + public void AddProperty(ObjectProperty object_property) + { + if (properties == null) + properties = new List(); + + properties.Add(object_property); + } + public void AddPropertiesToMaster() + { + if (properties != null) + ObjectMasterExtras.AddList(properties); + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterComputedExtrasMono.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterComputedExtrasMono.cs.meta new file mode 100644 index 0000000..8630bd6 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterComputedExtrasMono.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d16b58876017af04d846db84a56b7bbe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterExtras.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterExtras.cs new file mode 100644 index 0000000..1344dee --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterExtras.cs @@ -0,0 +1,79 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectMasterExtras + { + //public static ObjectExtraProperties extra_properties; + public static List properties; + public static List lightmapTextures; + public static void Reset() + { + //extra_properties = new ObjectExtraProperties(); + properties = new List(); + lightmapTextures = new List(); + } + public static void Add(ObjectProperty object_property) + { + properties.Add(object_property); + } + public static void AddList(List object_porperties) + { + properties.AddRange(object_porperties); + } + public static string GetGLTFData(bool add_end_comma = true) + { + GetGenericExtras(); + string result = ""; + if (properties.Count > 0) + { + result += "\"extras\":"; + result += ObjectProperty.GetObjectProperties(properties); + if (add_end_comma) + result += ",\n"; + } + return result; + //return ObjectProperty.GetObjectProperties(new ObjectProperty(extra_properties)) + _comma; + } + public static void GetGenericExtras() + { + GetLightmapData(); + + if (ExportToGLTF.options.extraExportMainCameraInGLTF) + { + if (ExportToGLTF.options.exportCameras) + { + if (ExportToGLTF.options.extraCameraIndex == -1) + { + Debug.LogWarning("NO CAMERA WITH MAIN CAMERA TAG FOUND, WILL BE USING FIRST IN CAMERAS ARRAY"); + ExportToGLTF.options.extraCameraIndex = 0; + } + GetMainCameraData(ExportToGLTF.options.extraCameraIndex); + } + } + } + + public static void GetMainCameraData(int camera_index) + { + properties.Add(new ObjectProperty("mainCamera",camera_index)); + } + public static void AddLightmapTexture(int lightmap_index, int lightmap_texture ) + { + List lightmaps_properties = new List(); + lightmaps_properties.Add(new ObjectProperty("lightmapIndex", lightmap_index)); + lightmaps_properties.Add(new ObjectProperty("textureIndex", lightmap_texture)); + lightmapTextures.Add(new ObjectProperty("", lightmaps_properties)); + } + + public static void GetLightmapData() + { + if (lightmapTextures.Count > 0) + { + properties.Add(new ObjectProperty("lightmapTextures", lightmapTextures,true)); + } + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterExtras.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterExtras.cs.meta new file mode 100644 index 0000000..52ccb2a --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterExtras.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c351c6b7ca562bd478ee9a0565971081 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterUserExtrasMono.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterUserExtrasMono.cs new file mode 100644 index 0000000..ced6a8d --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterUserExtrasMono.cs @@ -0,0 +1,59 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace WEBGL_EXPORTER.GLTF +{ + [ExecuteAlways] + public class ObjectMasterUserExtrasMono : MonoBehaviour + { + [SerializeField] + public List properties; + + public GameObject[] gameObjectArrayVal; + public float[] floatArrayVal; + public int[] intArrayVal; + public string[] stringArrayVal; + + public bool checkedDuplicate = false; + + private void OnEnable() + { + if (!checkedDuplicate) + { + ObjectMasterUserExtrasMono[] _oms = transform.root.GetComponentsInChildren(); + if (_oms.Length > 1) + { + Debug.LogWarning("MASTER USER DEFINED EXTRAS ALREADY EXIST, REMOVING AND SELECTING EXISTING"); +#if UNITY_EDITOR + if (_oms[0] == this) + Selection.activeGameObject = _oms[1].gameObject; + else + Selection.activeGameObject = _oms[0].gameObject; + DestroyImmediate(this); +#endif + } + else + { + checkedDuplicate = true; + } + } + + } + public void AddProperty(ObjectProperty object_property) + { + if (properties == null) + properties = new List(); + + properties.Add(object_property); + } + public void AddPropertiesToMaster() + { + if (properties != null) + ObjectMasterExtras.AddList(properties); + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterUserExtrasMono.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterUserExtrasMono.cs.meta new file mode 100644 index 0000000..e88ba80 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMasterUserExtrasMono.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 792ee6b108a90bc499ef776b7054f528 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMaterial.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMaterial.cs new file mode 100644 index 0000000..1c6a00a --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMaterial.cs @@ -0,0 +1,241 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectMaterial + { + //consts + //public const string exportPreName = "mat_"; + + //statics + public static int globalIndex = -1; + public static List allUniqueMaterials; + public static Texture2D lightmapWhite; + + //vars + public int index = -1; + + public Material material; + public int lightmapIndex = -1; //necessary to compare values with other materials + public List materialProperties; + public List materialExtensions; + + public string exportName; + + public static void Reset() + { + globalIndex = 0; + allUniqueMaterials = new List(); + lightmapWhite = null; + } + public static int GetMaterialIndex(Material tarMaterial, Renderer meshRenderer) + { + if (tarMaterial == null) + return -1; + + if (allUniqueMaterials == null) + { + allUniqueMaterials = new List(); + + int lightIndex = -1; + if (meshRenderer != null) + lightIndex = meshRenderer.lightmapIndex == 65534 ? -1 : meshRenderer.lightmapIndex; + + allUniqueMaterials.Add(new ObjectMaterial(tarMaterial, lightIndex)); + + return allUniqueMaterials.Count - 1; + } + else + { + foreach (ObjectMaterial om in allUniqueMaterials) + { + if (om.IsSameMaterial(tarMaterial, meshRenderer)) + { + return om.index; + } + } // IF NO EXISTING MATERIAL WAS FOUND CREATE A NEW OBJECT MATERIAL + + int lightIndex = -1; + if (meshRenderer != null) + lightIndex = meshRenderer.lightmapIndex == 65534 ? -1 : meshRenderer.lightmapIndex; + + allUniqueMaterials.Add(new ObjectMaterial(tarMaterial, lightIndex)); + return allUniqueMaterials.Count - 1; + } + } + private bool IsSameMaterial(Material tarMaterial, Renderer meshRenderer) + { + int lightIndex = -1; + if (meshRenderer != null) lightIndex = meshRenderer.lightmapIndex == 65534 ? -1 : meshRenderer.lightmapIndex; + + if (tarMaterial == material) + { + if (lightIndex == lightmapIndex) + { + return true; + } + } + return false; + } + + public ObjectMaterial(Material mat, int lightmap_index) + { + // REMEMBER IT ALSO SAVES NULL VALUE, FOR NULL VALUE WE WILL HAVE TO CREATE A DEFAULT MATERIAL IN EXPORT + material = mat; + lightmapIndex = lightmap_index; + index = globalIndex; + exportName = mat.name; + //exportName = exportPreName + globalIndex; + materialExtensions = new List(); + materialProperties = GetMaterialProperties(mat,lightmap_index); + globalIndex++; + } + + private List GetMaterialProperties(Material tarMat, int lightmap_index) + { + List material_Properties = new List(); + string _name = exportName; + //name + if (ExportToGLTF.options.exportMaterialName) + material_Properties.Add(new ObjectProperty("name", _name)); + + + + // MATERIAL MAY BE NULL, BUT IT ALSO MAY HAVE A LIGHTMAP + if (tarMat != null) + { + switch (tarMat.shader.name) + { + case "Standard": + material_Properties.AddRange(PropertiesStandardMaterial.GetMaterialProperties(tarMat)); + break; + case "Universal Render Pipeline/Lit": + material_Properties.AddRange(PropertiesUniversalRenderPipeline.GetMaterialProperties(tarMat)); + break; + } + + } + + //extras + //commonConstant (lightmap) + if (lightmap_index != -1 || ExportToGLTF.options.whiteImageForNonStaticLightmaps) + { + Texture2D TXRLightmapTexture = null; + if (lightmap_index != -1) + { + //Debug.Log(lightmap_index); + TXRLightmapTexture = LightmapSettings.lightmaps[lightmap_index].lightmapColor; + } + else + { + if (ExportToGLTF.options.whiteImageForNonStaticLightmaps) + TXRLightmapTexture = GetLightmapWhite(); + } + + bool moz_lightmap = true; + + if (TXRLightmapTexture != null) + { + + int _lightmapTexture_index = GetIntFromTexture(TXRLightmapTexture, TextureType.LIGHTMAP, false, false, false, lightmap_index); + int _lightmapTexture_texCoord = 1; + float _lightmapIntensity = ImageUtilities.GetImageMaxPixelFloatValue(TXRLightmapTexture, ExportToGLTF.options.maxLightmapClamp); + _lightmapIntensity *= ExportToGLTF.options.lightmapIntensityMultiplier; + + if (!moz_lightmap) + { + List _lightmapTexture = new List(); + _lightmapTexture.Add(new ObjectProperty("index", _lightmapTexture_index)); + _lightmapTexture.Add(new ObjectProperty("texCoord", _lightmapTexture_texCoord)); + + + ObjectExtraProperties _extra = new ObjectExtraProperties(); + _extra.Add(new ObjectProperty("lightmapTexture", _lightmapTexture)); + + if (_lightmapIntensity != 1) + _extra.Add(new ObjectProperty("lightmapIntensity", _lightmapIntensity)); + material_Properties.Add(new ObjectProperty(_extra)); + } + else + { + ObjectExtension moz_lightamp_ext = CreateMOZ_Lightmap(_lightmapTexture_index, _lightmapTexture_texCoord, _lightmapIntensity); + if (moz_lightamp_ext != null) + materialExtensions.Add(moz_lightamp_ext); + } + } + + //_commonConstant.Add(new ObjectProperty("")); + } + + + return material_Properties; + } + + public static ObjectExtension CreateKHR_texture_transform(Vector2 scale_v2, Vector2 offset_v2) + { + List _properties = new List(); + if (offset_v2 != Vector2.zero) + _properties.Add(new ObjectProperty("offset", offset_v2)); + if (scale_v2 != Vector2.one) + _properties.Add(new ObjectProperty("scale", scale_v2)); + + if (_properties.Count > 0) + { + ObjectExtension khr_texture_transform = new ObjectExtension("KHR_texture_transform", _properties, true); + return khr_texture_transform; + } + return null; + } + + public static ObjectExtension CreateMOZ_Lightmap(int imageIndex, int texCoord, float intensity) + { + if (imageIndex == -1) + return null; + List _properties = new List(); + _properties.Add(new ObjectProperty("index", imageIndex)); + _properties.Add(new ObjectProperty("texCoord", texCoord)); + + if (intensity != 1) + _properties.Add(new ObjectProperty("intensity", intensity)); + + + if (_properties.Count > 0) + { + ObjectExtension moz_lightmap = new ObjectExtension("MOZ_lightmap", _properties,false); + return moz_lightmap; + } + return null; + } + private Texture2D GetLightmapWhite() + { + if (lightmapWhite == null) + lightmapWhite = ImageGenerator.CreateSimpleTexture(new Color(0.75f, 0.75f, 0.75f)); + return lightmapWhite; + } + + public static int GetIntFromTexture(Texture2D texture_2D, TextureType texture_type, bool metal_smooth_map = false, bool uses_alpha = false, bool save_alpha_map = false, int lightmap_index = -1, float _smoothnessMult = 1, float _metallicMult = 1) + { + if (texture_2D != null) + return ObjectTexture.GetTextureIndex(texture_2D, texture_type, metal_smooth_map, uses_alpha, save_alpha_map, lightmap_index, _smoothnessMult,_metallicMult); + else + return -1; // NO TEXTURE FOUND + } + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = "\"materials\" : [\n"; + for (int i = 0; i < allUniqueMaterials.Count; i++) + { + result += ObjectProperty.GetObjectProperties(allUniqueMaterials[i].materialProperties, allUniqueMaterials[i].materialExtensions); + if (i < allUniqueMaterials.Count - 1) + result += ",\n"; + } + result += "]"; + if (add_end_comma) + result += ",\n"; + return result; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMaterial.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMaterial.cs.meta new file mode 100644 index 0000000..ea8584e --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMaterial.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f97e7ac2154eccf40941724aae81cb74 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMesh.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMesh.cs new file mode 100644 index 0000000..7c58be2 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMesh.cs @@ -0,0 +1,412 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectMesh + { + //consts + public const string exportPreName = "msh_"; + //public const bool offsetExtension = false; // IF WE HAVE AN EXTENSION THAT CAN OFFSET THE UVS TAKEN FROM THE ORIGINAL MAPS, THEN WE ONLY NEED TO SAVE UVS ONCE, OTHERWISE WE MUST SAVE THE UVS AGAIN + + //statics + public static int globalIndex = -1; + public static List allUniqueMeshes; + + //vars + public int index = -1; + public MeshHolder meshHolder; + public UVVariant uv1var; // LOCAL VALUE FROM MESH HOLDER TO KNOW WHICH VALUE OF THE LIST IS CONNECTED TO + public UVVariant uv2var; + public List materials; + public List meshProperties; + public List primitivesExtraProperties; + public List meshExtraProperties; + + public List materialsInt; //USED TO KNOW THE CONNECTION OF THE MATERIAL; + + public int lightmapIndex = -1; //necessary to compare values with other materials + //public List materialProperties; + + public string exportName; + + public static void Reset() + { + globalIndex = 0; + allUniqueMeshes = new List(); + } + public static int GetMeshIndex(SkinnedMeshRenderer skinned_mesh, OffsetUVs offset_uvs) + { + if (skinned_mesh != null) + { + MeshHolder _meshHolder = MeshHolder.GetMeshHolder(skinned_mesh.sharedMesh,true); + + foreach (ObjectMesh om in allUniqueMeshes) + { + if (om.IsSameMesh(_meshHolder, offset_uvs, skinned_mesh)) + { + return om.index; + } + } + allUniqueMeshes.Add(new ObjectMesh(_meshHolder, offset_uvs, skinned_mesh)); + return allUniqueMeshes.Count - 1; + } + return -1; // WILL RETURN -1, MEANS IT HAS NO MESH + } + public static int GetMeshIndex(Mesh mesh, OffsetUVs offset_uvs, MeshRenderer mesh_renderer) + { + if (mesh != null) + { + MeshHolder _meshHolder = MeshHolder.GetMeshHolder(mesh); + + foreach (ObjectMesh om in allUniqueMeshes) + { + if (om.IsSameMesh(_meshHolder, offset_uvs, mesh_renderer)) + { + return om.index; + } + } + allUniqueMeshes.Add(new ObjectMesh(_meshHolder, offset_uvs, mesh_renderer)); + return allUniqueMeshes.Count - 1; + } + return -1; // WILL RETURN -1, MEANS IT HAS NO MESH + } + + private bool IsSameMesh(MeshHolder mesh_holder, OffsetUVs offset_uvs, Renderer mesh_renderer) + { + if (mesh_renderer == null) + { + return false; + } + if (lightmapIndex != -1 || mesh_renderer.lightmapIndex != -1) //IF THE MESH WE ARE COMPARING TO, OR RHIS MESH, HAS LIGHTMAP, THE MESH IS UNIQUE, SO RETURN FALSE + { + return false; + } + if (meshHolder == mesh_holder) + { + if (uv1var != null && offset_uvs != null) // CHECK FOR UVS 1 + { + if (!MeshHolder.IsSameUVs(uv1var, offset_uvs.offsetUVs, offset_uvs.scaleUVS)) + { + return false; + } + } + // ALSO CHECK MATERIALS + if (!HasSameMaterials(mesh_renderer.sharedMaterials, meshHolder.subMeshCount)) + { + return false; + } + + return true; // IF UVS ARE THE SAME, AND LIGHTMAP IS NOT NEEDED, THEN WE HAVE THE SAME VALUES + } + return false; + } + private bool HasSameMaterials(Material[] mesh_materials, int submesh_count) + { + if (meshHolder.subMeshCount != submesh_count) + return false; + + for (int i =0; i < submesh_count; i++) // MUST CHECK ONLY FOR THE QUANTITY OF SUBMESHES, NOT THE QUANTITIY OF MATERIALS + { + if (i < mesh_materials.Length) // IF MESH RENDERER HAD MORE MATERIALS THAN NEEDED IT WILL STOP TO GET ONLY THE ONES NEEDED + { + + if (mesh_materials[i] != materials[i]) + return false; + } + else // IF WERE OUT OF RANGE, COMPARE A NULL VALUE + { + if (null != materials[i]) + return false; + } + } + return true; + } + public ObjectMesh(MeshHolder mesh_holder, OffsetUVs offset_uvs, Renderer mesh_renderer) + { + meshHolder = mesh_holder; + primitivesExtraProperties = new List(); + meshExtraProperties = new List(); + meshProperties = new List(); + + materials = new List(); + for (int i = 0; i< meshHolder.subMeshCount; i++) + { + if (mesh_renderer == null) + { + materials.Add(null); + } + else + { + if (i < mesh_renderer.sharedMaterials.Length) // ADD THE MATERIALS BASED ON SUBMESHES, NO ON HOW MANY MATERIALS THERE ARE + { + materials.Add(mesh_renderer.sharedMaterials[i]); + } + else // IF WERE OUT OF RANGE, ADD A NULL VALUES (PLACEHOLDER, A DEFAULT MATERIAL WILL BE USED INT NULLS) + { + materials.Add(null); + } + } + } + + // GET MATERIALS + materialsInt = new List(); + foreach (Material mat in materials) + { + materialsInt.Add(ObjectMaterial.GetMaterialIndex(mat, mesh_renderer)); + } + + // GET UVS + Vector2 _offsetCompareValue = new Vector2(0, 0); + Vector2 _scaleCompareValue = new Vector2(1, 1); + if (offset_uvs != null) + { + _offsetCompareValue = offset_uvs.offsetUVs; + _scaleCompareValue = offset_uvs.scaleUVS; + } + uv1var = meshHolder.GetUVsLocalIndex(_offsetCompareValue, _scaleCompareValue); + + lightmapIndex = -1; + if (mesh_renderer != null) lightmapIndex = mesh_renderer.lightmapIndex; + + if (lightmapIndex != -1) + { + if (offset_uvs == null) + uv2var = meshHolder.AddUVsAuto(new Vector2(mesh_renderer.lightmapScaleOffset.z, mesh_renderer.lightmapScaleOffset.w), new Vector2 (mesh_renderer.lightmapScaleOffset.x, mesh_renderer.lightmapScaleOffset.y)); + else + uv2var = meshHolder.AddUVsAuto(new Vector2(mesh_renderer.lightmapScaleOffset.z, mesh_renderer.lightmapScaleOffset.w), new Vector2 (mesh_renderer.lightmapScaleOffset.x, mesh_renderer.lightmapScaleOffset.y), offset_uvs.offsetUVs, offset_uvs.scaleUVS); + } + + index = globalIndex; + globalIndex++; + } + + + + + + // FINAL STEP: GET DATA + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + if (allUniqueMeshes.Count > 0) + { + result += "\"meshes\":["; + foreach (ObjectMesh om in allUniqueMeshes) + { + //result += "{\n"; + //"\"primitives\" : [\n"; + List _primitives = new List(); + //SUBMESH GLTF SEPARATED (CLASSIC MODE) + if (!ExportToGLTF.options.exportSubmeshesInExtra) + { + for (int i = 0; i < om.meshHolder.accessorIndices.Count; i++) + { + + List _attributes = new List(); + _attributes.Add(new ObjectProperty("POSITION", om.meshHolder.accessorVertices.export_index)); + if (om.meshHolder.accessorNormals != null) _attributes.Add(new ObjectProperty("NORMAL", om.meshHolder.accessorNormals.export_index)); + + if (om.meshHolder.accessorWeights != null) + { + _attributes.Add(new ObjectProperty("WEIGHTS_0", om.meshHolder.accessorWeights.export_index)); + _attributes.Add(new ObjectProperty("JOINTS_0", om.meshHolder.accessorJoints.export_index)); + } + if (!ExportToGLTF.options.createUVOffsetExtras) + { + if (om.uv1var != null) _attributes.Add(new ObjectProperty("TEXCOORD_0", om.uv1var.GetObjectAccessorExportInt())); + if (om.uv2var != null) _attributes.Add(new ObjectProperty("TEXCOORD_1", om.uv2var.GetObjectAccessorExportInt())); + } + else + { + // IF WE CAN OFFSET WITH CODE, WE ONLY NEED TO GET OM.MESHHOLDER.ACCESSORUVS1 AND MULTIPLY IT BY OM.UV1VAR OFFSET/SCALE + if (om.meshHolder.accessorUVs1 != null) _attributes.Add(new ObjectProperty("TEXCOORD_0", om.meshHolder.accessorUVs1.export_index)); + if (om.meshHolder.accessorUVs2 != null) _attributes.Add(new ObjectProperty("TEXCOORD_1", om.meshHolder.accessorUVs2.export_index)); + // SCALE OFFSET WILL BE ADDED IN GETMESHEXTRAS() + } + List _primi = new List(); + _primi.Add(new ObjectProperty("attributes", _attributes)); + _primi.Add(new ObjectProperty("indices", om.meshHolder.accessorIndices[i].export_index)); + if (om.materialsInt[i] != -1) _primi.Add(new ObjectProperty("material", om.materialsInt[i])); + _primitives.Add(new ObjectProperty("", _primi)); + + // RENDER MODE CAN GO HERE + } + } + //END SUBMESH GLTF SEPARATED (CLASSIC MODE) + //SUBMESH COMBINED GLTF (CUSTOM EXTRA MODE) + else + { + List _attributes = new List(); + _attributes.Add(new ObjectProperty("POSITION", om.meshHolder.accessorVertices.export_index)); + if (om.meshHolder.accessorNormals != null) _attributes.Add(new ObjectProperty("NORMAL", om.meshHolder.accessorNormals.export_index)); + if (om.meshHolder.accessorWeights != null) + { + _attributes.Add(new ObjectProperty("WEIGHTS_0", om.meshHolder.accessorWeights.export_index)); + _attributes.Add(new ObjectProperty("JOINTS_0", om.meshHolder.accessorJoints.export_index)); + } + + if (!ExportToGLTF.options.createUVOffsetExtras) + { + if (om.uv1var != null) _attributes.Add(new ObjectProperty("TEXCOORD_0",om.uv1var.GetObjectAccessorExportInt())); + if (om.uv2var != null) _attributes.Add(new ObjectProperty("TEXCOORD_1",om.uv2var.GetObjectAccessorExportInt())); + } + else + { + // IF WE CAN OFFSET WITH CODE, WE ONLY NEED TO GET OM.MESHHOLDER.ACCESSORUVS1 AND MULTIPLY IT BY OM.UV1VAR OFFSET/SCALE + if (om.meshHolder.accessorUVs1 != null) _attributes.Add(new ObjectProperty("TEXCOORD_0", om.meshHolder.accessorUVs1.export_index)); + if (om.meshHolder.accessorUVs2 != null) _attributes.Add(new ObjectProperty("TEXCOORD_1", om.meshHolder.accessorUVs2.export_index)); + // SCALE OFFSET WILL BE ADDED IN GETMESHEXTRAS() + } + if (om.meshHolder.subMeshCount > 1) + { + // THIS VALUES WILL BE ADDED LATER IN EXTRAS! + List _submeshes = new List(); + for (int i = 0; i < om.meshHolder.subMeshCount; i++) + { + List _submesh = new List(); + _submesh.Add(new ObjectProperty("start", om.meshHolder.subMeshStart[i])); + _submesh.Add(new ObjectProperty("count", om.meshHolder.subMeshSize[i])); + _submesh.Add(new ObjectProperty("material", om.materialsInt[om.meshHolder.subMeshCount - i -1])); // INDICES ARE INVERTED AND SO ARE MATERIALS + _submeshes.Add(new ObjectProperty("",_submesh)); + } + om.meshExtraProperties.Add(new ObjectProperty("submeshes", _submeshes,true)); + } + List _primi = new List(); + _primi.Add(new ObjectProperty("attributes", _attributes)); + _primi.Add(new ObjectProperty("indices", om.meshHolder.accessorIndices[0].export_index)); + if (om.materialsInt[0] != -1) _primi.Add(new ObjectProperty("material", om.materialsInt[0])); + _primitives.Add(new ObjectProperty("",_primi)); + + } + om.meshProperties.Add(new ObjectProperty("primitives",_primitives, true)); + ObjectProperty _extras = om.GetExtras(); + if (_extras != null) + om.meshProperties.Add(_extras); + + //END SUBMESH COMBINED GLTF (CUSTOM EXTRA MODE) + result += ObjectProperty.GetObjectProperties(om.meshProperties) + ",\n"; + //result += "]"; + + //result += om.GetMeshExtrasProperties(); + //result += "},\n"; + + } + + //if (ExportToGLTF.options.exportNavMesh) + //{ + + //} + + if (allUniqueMeshes.Count > 0) + result = StringUtilities.RemoveCharacterFromString(result, 2, false); + result += "]"; + if (add_end_comma) + result += ",\n"; + } + return result; + } + + public ObjectProperty GetExtras() + { + if (lightmapIndex != -1) + meshExtraProperties.Add(new ObjectProperty("lightmap_index", lightmapIndex)); + + if (meshExtraProperties.Count > 0) + { + ObjectExtraProperties _extra = new ObjectExtraProperties(meshExtraProperties); + return new ObjectProperty(_extra); + } + return null; + } + //public string GetMeshExtrasProperties(bool add_comma = false) + //{ + // string result = ""; + // if (lightmapIndex != -1) + // meshExtraProperties.Add(new ObjectProperty("lightmap_index", lightmapIndex)); + + // if (meshExtraProperties.Count > 0) + // { + // ObjectExtraProperties _extra = new ObjectExtraProperties(meshExtraProperties); + // ObjectProperty final_extras = new ObjectProperty(_extra); + // result += final_extras.GetPropertyGLTF(); + // } + // if (result != "" && add_comma) + // result += ",\n"; + // if (result != "") + // result = ",\n" + result; + // return result; + //} + public string GetPrimitivesExtrasProperties(bool add_comma = false) + { + string result = ""; + + if (!ExportToGLTF.options.createUVOffsetExtras) + { + if (uv1var != null) + { + if (uv1var.optionalObjectAccessor != null) + { + List texcoord_0_props = new List(); + if (uv1var.optionalObjectAccessor.isQuantized) + { + //if (ValidateFloatArrayUse(uv1var.optionalObjectAccessor.quantization_scale, 1)) + //texcoord_0_props.Add(new ObjectProperty("scale", uv1var.optionalObjectAccessor.quantization_scale)); //WRONG WAY. BUT SAVED, THIS VALUE IS NOT IMPORTANT, BUIT ITS IMPORTANT TO KNOW THE VALUE IS QUANTIZED + //if (ValidateFloatArrayUse(uv1var.optionalObjectAccessor.quantization_offset, 0)) + //texcoord_0_props.Add(new ObjectProperty("offset", uv1var.optionalObjectAccessor.quantization_offset));//WRONG + } + if (texcoord_0_props.Count > 0) + primitivesExtraProperties.Add(new ObjectProperty("TEXCOORD_0", texcoord_0_props)); + } + } + if (uv2var != null) + { + List texcoord_1_props = new List(); + if (uv2var.optionalObjectAccessor.isQuantized) + { + //if (ValidateFloatArrayUse(uv2var.optionalObjectAccessor.quantization_scale, 1)) + //texcoord_1_props.Add(new ObjectProperty("scale", uv2var.optionalObjectAccessor.quantization_scale)); //WRONG, TAKE VALUE FROM OFFSET_UVS CODE TRANSFORMED TO QUANTIZED VALUE AND UNITIZED + //if (ValidateFloatArrayUse(uv2var.optionalObjectAccessor.quantization_offset, 0)) + //texcoord_1_props.Add(new ObjectProperty("offset", uv2var.optionalObjectAccessor.quantization_offset)); + } + if (texcoord_1_props.Count > 0) + primitivesExtraProperties.Add(new ObjectProperty("TEXCOORD_1", texcoord_1_props)); + } + } + if (primitivesExtraProperties.Count > 0) + { + ObjectExtraProperties _extra = new ObjectExtraProperties(primitivesExtraProperties); + ObjectProperty final_extras = new ObjectProperty(_extra); + result += final_extras.GetPropertyGLTF(); + } + if (result != "" && add_comma) + result += ",\n"; + + //if (result != "") + //{ + // result = StringUtilities.RemoveCharacterFromString(result, 2, false) + "\n"; + // result = "\"extras\":{\n" + + // "\"mesh_transform\":{\n" + + // result + + // "}\n" + + // "},\n"; + //} + + return result; + + } + + private bool ValidateFloatArrayUse(float[] _floats, float compare_value) + { + if (_floats == null) // WE DONT NEED THE ARRAY SINCE THERE IS NO ARRAY + return false; + foreach(float f in _floats) + { + if (f != compare_value) + return true; // IF THERES A DIFFERENTE VALUE, IT MEANS WE REQUIRE THEM + } + return false; // IF ALL VALUES ARE SAME AS COMPARE VALUE, WE DONT NEED THE ARRAY + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMesh.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMesh.cs.meta new file mode 100644 index 0000000..fc38574 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectMesh.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2f685ba94ad4d254fb541296ad9a9d95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeComputedExtrasMono.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeComputedExtrasMono.cs new file mode 100644 index 0000000..93c2592 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeComputedExtrasMono.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectNodeComputedExtrasMono : ObjectNodeUserExtrasMono + { + public override void ResetComputedProperties() + { + // dont reset list + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeComputedExtrasMono.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeComputedExtrasMono.cs.meta new file mode 100644 index 0000000..b2970bd --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeComputedExtrasMono.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 97e0e39cc3627f943a2e3c6e769b5186 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeMono.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeMono.cs new file mode 100644 index 0000000..df098bc --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeMono.cs @@ -0,0 +1,508 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.AI; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectNodeMono : MonoBehaviour + { + //statics + public static int nodeCounter = -1; + public static List allUniqueNodes; + public static List sceneNodes; + + public static Mesh navMesh; + public static int navMeshNode = -1; + public static int navMeshConnectedMesh = -1; + + public static int totalMeshes = -1; + //public static int totalSkinnedMeshes = -1; + + //vars + public int connectedMesh = -1; // MESH HAS THE MATERIAL CONNECTIONS! + + public int connectedSkinnedMesh = -1; + public int connectedSkin = -1; //IN CASE ITS A SKINNED MESH + public int connectedCamera = -1; // IN CASE WE HAVE A CONNECTED CAMERA TO THIS NODE + + //public bool batching = false; + public int node = -1; + public List nodeChilds; // all node childs ints + public int nodeParent = -1; // node parent -1 means is in scene + public List extraProperties; + public ObjectProperty extensions; + + public static void ResetValues() + { + nodeCounter = 0; + allUniqueNodes = new List(); + sceneNodes = new List(); + + navMesh = null; + navMeshNode = -1; + navMeshConnectedMesh = -1; + + + totalMeshes = 0; + //totalSkinnedMeshes = 0; + } + public static void SetupNavMesh(Transform parent) + { + // NAV MESH NODE + + NavMeshTriangulation nav = NavMesh.CalculateTriangulation(); + if (nav.indices.Length > 0) + { + navMesh = new Mesh(); + navMesh.SetVertices(nav.vertices); + navMesh.SetIndices(nav.indices,MeshTopology.Triangles,0); + navMeshNode = nodeCounter + totalMeshes; + + navMeshConnectedMesh = ObjectMesh.GetMeshIndex(navMesh, null, null); + + ObjectNodeMono node_parent = parent.GetComponent(); + node_parent.nodeChilds.Add(navMeshNode); + + totalMeshes++; + nodeCounter++; + } + + } + private void ResetInstance() + { + connectedMesh = -1; + connectedSkin = -1; + connectedCamera = -1; + connectedSkinnedMesh = -1; + + } + public void SetupNode(bool is_active = true) + { + // RESET ALSO THIS NODE IN CASE IT ALREADY EXISTED + ResetInstance(); + GetConnectedMesh(); + GetConnectedCamera(); + + allUniqueNodes.Add(this); + node = nodeCounter; + nodeChilds = new List(); + extraProperties = new List(); + extensions = new ObjectProperty(); + + GetConnectedAnimator(); + + GetConnectedAudio(); + + GetConnectedColliders(); + + if (ExportToGLTF.options != null) { + if (!is_active) + { + extraProperties.Add(new ObjectProperty("visible",false)); + } + if (ExportToGLTF.options.exportGameObjectsTag) + { + if (transform.tag != "Untagged") + extraProperties.Add(new ObjectProperty("tag", transform.tag)); + } + if (ExportToGLTF.options.exportGameObjectsLayer) + { + if (gameObject.layer != 0) + extraProperties.Add(new ObjectProperty("layer", gameObject.layer)); + } + if (ExportToGLTF.options.exportBatching) + { +#if UNITY_EDITOR + if (GameObjectUtility.GetStaticEditorFlags(gameObject).HasFlag(StaticEditorFlags.BatchingStatic)) + { + extraProperties.Add(new ObjectProperty("batching", true)); + } + #endif + } + } + + Transform parent = transform.parent; + if (nodeCounter == 0) + { + ObjectScene.AddNodeToScene(node); + } + else + { + ObjectNodeMono node_parent = transform.parent.GetComponent(); + nodeParent = node_parent.node; + node_parent.nodeChilds.Add(node); + + } + nodeCounter++; + + } + public void GetConnectedCamera() + { + if (ExportToGLTF.options.exportCameras) + { + Camera _cam = transform.GetComponent(); + string _tag = ""; + if (transform.tag == "MainCamera") + _tag = transform.tag; + + if (_cam != null) + { + if (!_cam.orthographic) + connectedCamera = ObjectCamera.GetCameraIndex(1.0f, _cam.fieldOfView * Mathf.Deg2Rad, _cam.farClipPlane, _cam.nearClipPlane, _tag, _cam.cullingMask); + else + connectedCamera = ObjectCamera.GetCameraIndex(new Vector2(_cam.orthographicSize, _cam.orthographicSize), _cam.farClipPlane, _cam.nearClipPlane, _tag, _cam.cullingMask); + } + } + else + { + connectedCamera = -1; + } + } + public void GetConnectedMesh() + { + MeshFilter _mf= transform.GetComponent(); + MeshRenderer _mr = transform.GetComponent(); + + //new + SkinnedMeshRenderer _smr = transform.GetComponent(); + + if (_smr != null) + { + if (_smr.sharedMesh != null) + { + if (_smr.sharedMesh.GetIndices(0).Length != 0) + { + //ObjectNodeMono targetRootJoint = _smr.rootBone.GetComponent(); + //Mesh _mesh = _smr.sharedMesh; + + OffsetUVs _ou = null; + //pending + //OffsetUVs _ou = transform.GetComponent(); + + //if (_ou != null) + //_mesh = transform.GetComponent().originalMesh; + + connectedSkinnedMesh = ObjectMesh.GetMeshIndex(_smr,_ou); + Debug.LogWarning("connectedSkinnedMesh: " + connectedSkinnedMesh); + connectedSkin = ObjectSkin.GetSkinIndex(_smr); + totalMeshes++; + //rootNodeSkin = _smr.rootBone; + + // WE WILL NOT SAVE IT IN THE OBJECT THAT HOLDS THE COMPONENT, BUT IN THE ROOT OF THE JOINS + //if (targetRootJoint.connectedMesh == -1) + //{ + // targetRootJoint.connectedSkinnedMesh = ObjectMesh.GetMeshIndex(_smr, _ou); + // targetRootJoint.connectedSkin = ObjectSkin.GetSkinIndex(_smr.bones, _smr.rootBone); + // totalSkinnedMeshes++; + //} + //else + //{ + // Debug.LogWarning("MORE THAN 2 MESHES IN ROOT JOINT IN SKIN"); + //} + } + } + else + { + Debug.LogWarning("missing skinned mesh in " + _smr.gameObject.name); + } + } + if (_mf!= null && _mr != null) + { + if (_mf.sharedMesh != null) + { + if (_mf.sharedMesh.GetIndices(0).Length != 0) + { + + Mesh _mesh = _mf.sharedMesh; + OffsetUVs _ou = transform.GetComponent(); + + if (_ou != null) + _mesh = transform.GetComponent().originalMesh; + + connectedMesh = ObjectMesh.GetMeshIndex(_mesh, _ou, _mr); + + totalMeshes++; + } + } + else + { + Debug.LogWarning("missing mesh in " + _mf.gameObject.name); + } + } + } + public void GetConnectedAnimator() + { + Animator _animator = GetComponent(); + if (_animator != null) + { + ObjectExtrasAnimationController.GetAnimatorIndex(_animator, node); + } + } + + public void GetConnectedAudio() + { + WebPositionalAudioSource _webAudioSource = GetComponent(); + if (_webAudioSource != null) + { + int index = ObjectExtensionOmiAudio.GetAudioEmitterIndex(_webAudioSource); + extensions.AddExtensionObject(CreateKHR_audio(index)); + } + else + { + AudioSource _audioSource = GetComponent(); + if (_audioSource != null) + { + int index = ObjectExtensionOmiAudio.GetAudioEmitterIndex(_webAudioSource); + extensions.AddExtensionObject(CreateKHR_audio(index)); + } + } + } + + public void GetConnectedColliders() + { + + Collider _collider = GetComponent(); + if (_collider!= null) + { + Rigidbody _rigidBody = GetComponent(); + List properties = ObjectExtensionOmiCollider.GetColliderProperties(_collider, _rigidBody); + extensions.AddExtensionObject(CreateOMI_collider(properties)); + //int index = ObjectExtensionOmiCollider.GetColliderIndex(_collider); + } + } + public static ObjectExtension CreateKHR_audio(int index) + { + List _properties = new List(); + if (index >= 0) + { + _properties.Add(new ObjectProperty("emitter", index)); + ObjectExtension khr_audio = new ObjectExtension("KHR_audio", _properties, false); + return khr_audio; + } + return null; + } + public static ObjectExtension CreateOMI_collider(List properties) + { + + if (properties.Count > 0) + { + ObjectExtension omi_collider = new ObjectExtension("OMI_collider", properties, false); + return omi_collider; + } + return null; + } + public static int leafNodesCounter; + public static string GetGLTFData(bool add_end_comma = true) + { + // FOR QUANTIZATION + leafNodesCounter = allUniqueNodes.Count; + List leaf_node_meshes = new List(); + List leaf_node_names = new List(); + + List root_skin_nodes = new List(); + + Quaternion defaultQuaternion = new Quaternion(0, 0, 0, 1); + + string result = "\"nodes\":["; + List _allNodes = new List(); + foreach (ObjectNodeMono onm in allUniqueNodes) + { + //DECLARATION + List _node = new List(); + if (ExportToGLTF.options.exportGameObjectName) + _node.Add(new ObjectProperty("name", StringUtilities.GetStringJsonLegal(onm.gameObject.name))); + + //CAMERA + if (onm.connectedCamera != -1) _node.Add(new ObjectProperty("camera", onm.connectedCamera)); + + //CHILDS + if (onm.connectedMesh != -1) + { + + if (ExportToGLTF.options.blockLeafNodesCreation == false) + { + onm.nodeChilds.Add(leafNodesCounter); + leafNodesCounter++; + leaf_node_meshes.Add(onm.connectedMesh); + leaf_node_names.Add(StringUtilities.GetStringJsonLegal(onm.gameObject.name)); + root_skin_nodes.Add(-1); + } + else + { + _node.Add(new ObjectProperty("mesh", onm.connectedMesh)); + // place the information here + } + + } + if (onm.connectedSkinnedMesh != -1) + { + //root.Add(leafNodesCounter); + Debug.Log("jahsbd"); + Debug.Log(onm.connectedSkin); + if (ExportToGLTF.options.blockLeafNodesCreation == false) + { + leafNodesCounter++; + leaf_node_meshes.Add(onm.connectedSkinnedMesh); + leaf_node_names.Add(StringUtilities.GetStringJsonLegal(onm.gameObject.name)); + root_skin_nodes.Add(onm.connectedSkin); + } + else + { + _node.Add(new ObjectProperty("mesh", onm.connectedSkinnedMesh)); + ObjectScene.AddNodeToScene(onm.connectedSkin); + _node.Add(new ObjectProperty("skin", onm.connectedSkin)); + } + + //Debug.LogWarning("skinned mesh is " + onm.connectedSkinnedMesh); + //_node.Add(new ObjectProperty("mesh", onm.connectedSkinnedMesh)); + //_node.Add(new ObjectProperty("skin", onm.connectedSkin)); + + } + + if (onm.nodeChilds.Count > 0) _node.Add(new ObjectProperty("children", onm.nodeChilds)); + + //TRANSFORM + Quaternion final_rotation = onm.transform.localRotation; + final_rotation = Quaternion.Euler(-onm.transform.localEulerAngles.x, -onm.transform.localEulerAngles.y, onm.transform.localEulerAngles.z); + if (onm.transform.localPosition != Vector3.zero) + _node.Add(new ObjectProperty("translation", onm.transform.localPosition)); ; + if (final_rotation != defaultQuaternion) + _node.Add(new ObjectProperty("rotation", final_rotation)); + if (onm.transform.localScale != Vector3.one) + _node.Add(new ObjectProperty("scale", onm.transform.localScale,false)); + + //EXTENSIONS + if (onm.extensions.extensionObjects != null) + if (onm.extensions.extensionObjects.Count > 0) + _node.Add(onm.extensions); + + //EXTRAS + ObjectProperty extras = onm.GetNodeExtraObjectGLTFData(); + if (extras != null) + _node.Add(extras); + + _allNodes.Add(new ObjectProperty("",_node)); + } + + // LEAF NODES + for (int i = 0; i < leaf_node_meshes.Count; i++) + { + //result += CreateLeafNode(leaf_node_names[i], leaf_node_meshes[i]); + //Debug.LogWarning(nodeCounter); + if (ExportToGLTF.options.blockLeafNodesCreation == false) + { + List _node = CreateLeafNode(leaf_node_names[i], leaf_node_meshes[i], root_skin_nodes[i], nodeCounter + i); + _allNodes.Add(new ObjectProperty("", _node)); + } + } + + //// NAV MESH NODE + if (navMeshNode != -1) + { + List _node = new List(); + if (ExportToGLTF.options.exportGameObjectName) + _node.Add(new ObjectProperty("name", "_navMesh_")); + _node.Add(new ObjectProperty("mesh", navMeshConnectedMesh)); + + List extraProperties = new List(); + extraProperties.Add(new ObjectProperty("visible", false)); + + ObjectExtraProperties _extras = new ObjectExtraProperties(extraProperties); + _node.Add(new ObjectProperty(_extras)); + + _allNodes.Add(new ObjectProperty("", _node)); + + } + result += ObjectProperty.GetObjectProperties(_allNodes,null,true); + + //result = StringUtilities.RemoveCharacterFromString(result,2,false); + result += "]"; + if (add_end_comma) + result += ",\n"; + + return result; + } + + + private static List CreateLeafNode(string _name,int mesh_int, int skin_int, int node_id) + { + + List _node = new List(); + if (ExportToGLTF.options.exportGameObjectName) + _node.Add(new ObjectProperty("name", "_geom_"+_name)); + _node.Add(new ObjectProperty("mesh",mesh_int)); + if (skin_int != -1) + { + ObjectScene.AddNodeToScene(node_id); + _node.Add(new ObjectProperty("skin", skin_int)); + } + if (ExportToGLTF.options.quantizeGLTF && ExportToGLTF.options.blockLeafNodesCreation == false) + { + if (ObjectMesh.allUniqueMeshes[mesh_int].meshHolder.accessorVertices.quantization_offset != null) + { + float[] _offset = new float[3]; + _offset[0] = ObjectMesh.allUniqueMeshes[mesh_int].meshHolder.accessorVertices.quantization_offset[0]; + _offset[1] = ObjectMesh.allUniqueMeshes[mesh_int].meshHolder.accessorVertices.quantization_offset[1]; + _offset[2] = ObjectMesh.allUniqueMeshes[mesh_int].meshHolder.accessorVertices.quantization_offset[2]; + + _node.Add(new ObjectProperty("translation", new Vector3(_offset[0], _offset[1], _offset[2]))); + } + if (ObjectMesh.allUniqueMeshes[mesh_int].meshHolder.accessorVertices.quantization_scale != null) + { + float[] _scale = new float[3]; + + _scale[0] = ObjectMesh.allUniqueMeshes[mesh_int].meshHolder.accessorVertices.quantization_scale[0]; + _scale[1] = ObjectMesh.allUniqueMeshes[mesh_int].meshHolder.accessorVertices.quantization_scale[1]; + _scale[2] = ObjectMesh.allUniqueMeshes[mesh_int].meshHolder.accessorVertices.quantization_scale[2]; + + _node.Add(new ObjectProperty("scale", new Vector3(_scale[0], _scale[1], _scale[2]))); + } + } + return _node; + + } + + + private ObjectProperty GetNodeExtraObjectGLTFData() + { + + ObjectNodeUserExtrasMono[] user_extras = transform.GetComponents(); + foreach (ObjectNodeUserExtrasMono ue in user_extras) + { + ue.optionalIdentifier = -1; + } + for (int i = 0; i < user_extras.Length; i++) + { + if (user_extras[i].extrasName != "") + { + bool saved = false; + + //user_extras[i].SetGLTFLastData(); + if (user_extras[i].computedProperties != null) + { + if (user_extras[i].computedProperties.Count > 0) + { + extraProperties.Add(new ObjectProperty(user_extras[i].extrasName, user_extras[i].computedProperties)); + saved = true; + } + } + if (!saved) + extraProperties.Add(new ObjectProperty(user_extras[i].extrasName)); + } + } + + if (extraProperties.Count > 0) + { + ObjectExtraProperties _extra = new ObjectExtraProperties(extraProperties); + return new ObjectProperty(_extra); + } + return null; + + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeMono.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeMono.cs.meta new file mode 100644 index 0000000..5610597 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeMono.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7ad89703e5fb8fe4695b4d6b87479008 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeUserExtrasMono.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeUserExtrasMono.cs new file mode 100644 index 0000000..d1b0647 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeUserExtrasMono.cs @@ -0,0 +1,75 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + [ExecuteAlways] + public class ObjectNodeUserExtrasMono : MonoBehaviour + { + [HideInInspector] + public string tooltip = ""; + + [HideInInspector] + public string extrasName; + [SerializeField,HideInInspector] + public List computedProperties; + [SerializeField, HideInInspector] + public List userProperties; + + [HideInInspector] + public GameObject[] gameObjectArrayVal; + [HideInInspector] + public float[] floatArrayVal; + [HideInInspector] + public int[] intArrayVal; + [HideInInspector] + public string[] stringArrayVal; + + [HideInInspector] + public bool displayOptions = true; + + [HideInInspector] + public int optionalIdentifier = -1; + + public virtual void ResetComputedProperties() + { + computedProperties = new List(); + } + public void AddProperty(ObjectProperty object_property, bool computed = true, int index = 0) + { + if (index < 0) + index = 0; + if (computed) + { + if (computedProperties == null) + computedProperties = new List(); + computedProperties.Insert(index, object_property); + } + else + { + if (userProperties == null) + userProperties = new List(); + + userProperties.Insert(index,object_property); + } + } + public void CombineProperties() + { + if (computedProperties == null) + computedProperties = new List(); + if (userProperties != null) + computedProperties.AddRange(userProperties); + } + public virtual void SetGLTFComputedData() // Called before creating gltf file + { + // add property... + // set always computed to true, only user interaction will set it to false to avoid deletion + } + //public virtual void SetGLTFLastData() + //{ + // // not used yet, its called before saving gltf data + //} + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeUserExtrasMono.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeUserExtrasMono.cs.meta new file mode 100644 index 0000000..441a4ae --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectNodeUserExtrasMono.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 759afd54344d785438c8d2a22d94d6b8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectProperty.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectProperty.cs new file mode 100644 index 0000000..bbf9868 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectProperty.cs @@ -0,0 +1,380 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + [Serializable] + public class ObjectProperty + { + public enum PropertyType {Float,ColorRGBA,ColorRGB,Bool,String,StringArray,StringList,IntArray, IntList,FloatArray,Object, ObjectProperty, Array,EmptyHolder,EmptyObject,Int, GameObject, GameObjectArray, GameObjectList, Vector2,Vector3,Quaternion,Extension,Extra} + public PropertyType propertyType; + public string propertyName; + //public ObjectTextureOld parameterTexture; + public float propertyFloat; + public string propertyString; + public string[] propertyStringArray; + public List propertyStringList; + public int[] propertyIntArray; + public List propertyIntList; + public float[] propertyFloatArray; + public Color propertyColor; + public bool propertyBool; + public Vector2 propertyVector2; + public Vector3 propertyVector3; + public Quaternion propertyQuaternion; + public int propertyInt; + public GameObject propertyGameObject; + public GameObject[] propertyGameObjectArray; + public List propertyGameObjectList; + public ObjectExtension objectExtension; + public ObjectExtraProperties propertyExtra; + public ObjectProperty propertyObject; + public List propertyObjects; + public List extensionObjects; + + public bool exportInGLTF; + + + public void AddExtensionObject(ObjectExtension object_extension) + { + if (object_extension != null) + { + if (extensionObjects == null) + extensionObjects = new List(); + + extensionObjects.Add(object_extension); + } + } + public ObjectProperty(string property_name) // USED TO STORE AT THE ROOT OF AN OBJECT, EXAMPLE: IN TEXTURES + { + propertyName = property_name; + propertyType = PropertyType.EmptyObject; + } + public ObjectProperty(string property_name, Vector2 property_vector2, bool ExportInGLTF = true) + { + propertyName = property_name; + propertyVector2 = property_vector2; + propertyType = PropertyType.Vector2; + } + public ObjectProperty(string property_name, Vector3 property_vector3, bool negativeZ = true) + { + propertyName = property_name; + if (negativeZ) + propertyVector3 = new Vector3(property_vector3.x, property_vector3.y, -property_vector3.z); + else + propertyVector3 = property_vector3; + propertyType = PropertyType.Vector3; + } + public ObjectProperty(string property_name, Quaternion property_quaternion) + { + propertyName = property_name; + propertyQuaternion = property_quaternion; + propertyType = PropertyType.Quaternion; + } + public ObjectProperty(string property_name, List property_object, bool isArray = false) + { + propertyName = property_name; + propertyObjects = property_object; + if (!isArray) + propertyType = PropertyType.Object; + else + propertyType = PropertyType.Array; + } + public ObjectProperty(string property_name, ObjectProperty property_object) + { + propertyName = property_name; + propertyObject = property_object; + propertyType = PropertyType.ObjectProperty; + + } + + public ObjectProperty(ObjectExtraProperties property_extra) + { + propertyName = "extras"; + propertyExtra = property_extra; + propertyType = PropertyType.Extra; + } + public ObjectProperty(string property_name, GameObject property_game_object) + { + propertyName = property_name; + propertyGameObject = property_game_object; + propertyType = PropertyType.GameObject; + } + public ObjectProperty(string property_name, int property_int) + { + propertyName = property_name; + propertyInt = property_int; + propertyType = PropertyType.Int; + } + public ObjectProperty(string property_name, GameObject[] property_game_object_array) + { + propertyName = property_name; + propertyGameObjectArray = property_game_object_array; + propertyType = PropertyType.GameObjectArray; + } + public ObjectProperty(string property_name, List property_game_object_list) + { + propertyName = property_name; + propertyGameObjectList = property_game_object_list; + propertyType = PropertyType.GameObjectList; + } + public ObjectProperty(string property_name, int[] property_int_array) + { + propertyName = property_name; + propertyIntArray = property_int_array; + propertyType = PropertyType.IntArray; + } + public ObjectProperty(string property_name, List property_int_list) + { + propertyName = property_name; + propertyIntList = property_int_list; + propertyType = PropertyType.IntList; + } + public ObjectProperty(string property_name, string property_string, bool ExportInGLTF =true) + { + propertyName = property_name; + propertyString = property_string; + propertyType = PropertyType.String; + } + public ObjectProperty(string property_name, string[] property_string_array) + { + propertyName = property_name; + propertyStringArray = property_string_array; + propertyType = PropertyType.StringArray; + } + public ObjectProperty(string property_name, List property_string_list) + { + propertyName = property_name; + propertyStringList = property_string_list; + propertyType = PropertyType.StringList; + } + public ObjectProperty(string property_name, float property_float, bool exportInGLTF =true) + { + propertyName = property_name; + propertyFloat = property_float; + propertyType = PropertyType.Float; + } + public ObjectProperty(string property_name, float[] property_float_array) + { + propertyName = property_name; + propertyFloatArray = property_float_array; + propertyType = PropertyType.FloatArray; + } + public ObjectProperty(string property_name, Color property_color, bool saveOnlyRGB = false, bool exportInGLTF=true) + { + propertyName = property_name; + propertyColor = property_color; + if (!saveOnlyRGB) + propertyType = PropertyType.ColorRGBA; + else + propertyType = PropertyType.ColorRGB; + } + public ObjectProperty(string property_name, bool property_bool, bool exportInGLTF = true) + { + propertyName = property_name; + propertyBool = property_bool; + propertyType = PropertyType.Bool; + } + public ObjectProperty() // USED TO STORE AT THE ROOT OF AN OBJECT, EXAMPLE: IN TEXTURES + { + propertyType = PropertyType.EmptyHolder; + } + //nuevo + + public string GetPropertyGLTF() + { + string result = ""; // FOR ARRAYS WITH UNNAMED OBJECTS + if (propertyName != "") + result += "\"" + propertyName + "\": "; + switch (propertyType) + { + case PropertyType.EmptyObject: + return result + "{}"; + case PropertyType.String: + return result + "\"" + StringUtilities.GetSafeChars(propertyString) + "\""; + case PropertyType.StringArray: + for (int i =0; i < propertyStringArray.Length; i++) + propertyStringArray[i] = StringUtilities.GetSafeChars(propertyStringArray[i]); + return result + "[" + StringUtilities.ArrayToString(propertyStringArray) + "]"; + case PropertyType.StringList: + for (int i = 0; i < propertyStringList.Count; i++) + propertyStringList[i] = StringUtilities.GetSafeChars(propertyStringList[i]); + return result + "[" + StringUtilities.ArrayToString(propertyStringList) + "]"; + case PropertyType.Float: + return result + propertyFloat; + case PropertyType.FloatArray: + return result + "[" + StringUtilities.ArrayToString(propertyFloatArray) + "]"; + case PropertyType.ColorRGBA: + return result + "["+ propertyColor.r +","+ propertyColor.g + "," + propertyColor.b + "," + propertyColor.a + "]"; + case PropertyType.ColorRGB: + return result + "[" + propertyColor.r + "," + propertyColor.g + "," + propertyColor.b + "]"; + case PropertyType.Bool: + return result + propertyBool.ToString().ToLower(); + case PropertyType.ObjectProperty: + return result + "{" + propertyObject.GetPropertyGLTF() + "}"; + case PropertyType.Object: + return result + GetObjectProperties(propertyObjects,extensionObjects); + case PropertyType.Array: + return result + "[" + GetObjectProperties(propertyObjects, extensionObjects,true) + "]"; + case PropertyType.Extra: + return result + GetObjectProperties(propertyExtra.extrasProperties); + case PropertyType.Int: + return result + propertyInt; + case PropertyType.GameObject: + return result + GetGameObjectIndex(propertyGameObject); + case PropertyType.GameObjectArray: + return result + "[" + GetGameObjectArrayIndex() +"]"; + case PropertyType.GameObjectList: + return result + "[" + GetGameObjectListIndex() +"]"; + case PropertyType.IntArray: + return result + "[" + StringUtilities.ArrayToString(propertyIntArray) + "]"; + case PropertyType.IntList: + return result + "[" + StringUtilities.ArrayToString(propertyIntList) + "]"; + case PropertyType.Vector2: + return result + "["+ StringUtilities.Vector2ToString(propertyVector2,false) +"]"; + case PropertyType.Vector3: + return result + "[" + StringUtilities.Vector3ToString(propertyVector3, false) + "]"; + case PropertyType.Quaternion: + return result + "[" + StringUtilities.QuaternionToString(propertyQuaternion,false) + "]"; + case PropertyType.EmptyHolder: + result = GetExtensionPropertyGLTF(extensionObjects); + result = StringUtilities.RemoveCharacterFromString(result, 2, false); + return result; + default: + return ""; + } + } + + private string GetGameObjectArrayIndex() + { + string result = ""; + if (propertyGameObjectArray != null) { + if (propertyGameObjectArray.Length == 0) + return ""; + else + { + foreach (GameObject go in propertyGameObjectArray) + { + result += GetGameObjectIndex(go) + ","; + } + result = StringUtilities.RemoveCharacterFromString(result,1,false); + } + } + return result; + } + private string GetGameObjectListIndex() + { + string result = ""; + if (propertyGameObjectList != null) + { + if (propertyGameObjectList.Count == 0) + return ""; + else + { + foreach (GameObject go in propertyGameObjectList) + { + result += GetGameObjectIndex(go) + ","; + } + result = StringUtilities.RemoveCharacterFromString(result, 1, false); + } + } + return result; + } + private string GetGameObjectIndex(GameObject tarObject) + { + if (tarObject != null) + { + ObjectNodeMono onm = tarObject.GetComponent(); + if (onm != null) + return onm.node.ToString(); + } + + return "-1"; + } + public static string GetExtensionPropertyGLTF(List object_extensions) + { + string result = ""; + if (object_extensions != null) + { + if (object_extensions.Count > 0) + { + result += "\"extensions\":{\n"; + for (int i = 0; i < object_extensions.Count; i++) + { + result += "\"" + object_extensions[i].name + "\":"; + result += GetObjectProperties(object_extensions[i].properties); + result += ",\n"; + } + result = StringUtilities.RemoveCharacterFromString(result, 2, false); + result += "},\n"; // ADDED HERE TO PREVENT ERRORS LATER, THIS ONES GETS ALWAYS REMOVED, BUT MUST BE ADDED TO AVOID ERRORS AND GO WITH THE FLOW OF GETTING OBJECT PROPERTIES + } + } + return result; + } + public static string GetObjectProperties(List object_properties, List object_extensions = null, bool isArray =false) + { + string result = ""; + if (object_properties != null) + { + + if (object_properties.Count > 0) + { + if (!isArray) + result += "{\n"; + for (int i = 0; i < object_properties.Count; i++) + { + result += object_properties[i].GetPropertyGLTF(); + result += ",\n"; + } + result += GetExtensionPropertyGLTF(object_extensions); + result = StringUtilities.RemoveCharacterFromString(result, 2, false); + if (!isArray) + result += "\n}"; + + + } + else + { + result += "{}\n"; + } + } + return result; + } + public static string GetObjectProperties(ObjectProperty object_property) + { + string result = ""; + if (object_property != null) + { + result += "{\n"; + result += object_property.GetPropertyGLTF(); + result += "\n}"; + } + return result; + } + + + // PENDING TO SEE IF WE WILL USE IT + //public string GetMaterialPropertyTHREEJS() + //{ + + // string result = parameterName + ": "; + // switch (propertyType) + // { + // case PropertyType.Texture: + // return result + parameterTexture.exportName; + // case PropertyType.Float: + // return result + propertyFloat; + // case PropertyType.ColorRGBA: + // return result + "0x" + ColorUtility.ToHtmlStringRGBA(propertyColor); + // case PropertyType.ColorRGB: + // return result + "0x" + ColorUtility.ToHtmlStringRGB(propertyColor); + // case PropertyType.Bool: + // return result + propertyBool.ToString().ToLower(); + // default: + // return ""; + // } + //} + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectProperty.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectProperty.cs.meta new file mode 100644 index 0000000..4d86a0f --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectProperty.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cecd7360df696f04d84d6f30e82a5b6d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSampler.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSampler.cs new file mode 100644 index 0000000..a275254 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSampler.cs @@ -0,0 +1,148 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectSampler + { + //statics + public static int globalIndex = -1; + public static List allUniqueSamplers; + + //vars + public int index = -1; + + public List samplerProperties; + + public TextureWrapMode _wrapModeU; + public TextureWrapMode _wrapModeV; + + public static void Reset() + { + globalIndex = 0; + allUniqueSamplers = new List(); + } + + public static int GeSamplerIndex(Texture _texture) + { + if (allUniqueSamplers == null) + { + allUniqueSamplers = new List(); + allUniqueSamplers.Add(new ObjectSampler(_texture)); + + return allUniqueSamplers.Count - 1; + } + else + { + foreach (ObjectSampler os in allUniqueSamplers) + { + if (os.isSameSampler(_texture)) + { + return os.index; + } + } + allUniqueSamplers.Add(new ObjectSampler(_texture)); + return allUniqueSamplers.Count - 1; + } + } + public bool isSameSampler(Texture _texture) + { + //missing filter mode + TextureWrapMode wrap_u = _texture.wrapModeU; + TextureWrapMode wrap_v = _texture.wrapModeV; + + if (wrap_u == TextureWrapMode.MirrorOnce) + wrap_u = TextureWrapMode.Mirror; + if (wrap_v == TextureWrapMode.MirrorOnce) + wrap_v = TextureWrapMode.Mirror; + + if (wrap_u == _wrapModeU && wrap_v == _wrapModeV) + { + return true; + } + + return false; + } + + public ObjectSampler(Texture _texture) + { + _wrapModeU = _texture.wrapModeU; + if (_wrapModeU == TextureWrapMode.MirrorOnce) + _wrapModeU = TextureWrapMode.Mirror; + + _wrapModeV = _texture.wrapModeV; + if (_wrapModeV == TextureWrapMode.MirrorOnce) + _wrapModeV = TextureWrapMode.Mirror; + + index = globalIndex; + samplerProperties = GetSampleProperties(_wrapModeU, _wrapModeV); + + globalIndex++; + } + + + + //NOTES: + //WE WILL BE USING DEFAULT VALUES FOR MAG FILTER AND MIN FILTER, THE ONE THAT MAY CHANGE IS WRAPS WRAPT + + //MAG FILTER: POSSIBLE VALUES: + //9728 - "NEAREST", 9279 - "LINEAR"(DEFAULT) + + //MIN FILTER + //9728 - "NEAREST", 9279 - "LINEAR", 9984 - "NEAREST_MIPMAP_NEAREST" + //9986 - 9985 - "LINEAR_MIPMAP_NEAREST", 9986 - "NEAREST_MIPMAP_LINEAR" (default), 9987 - "LINEAR_MIPMAP_LINEAR" + + //WRAPS / WRAPT + //33071 - "CLAMP_TO_EDGE", 33648 - "MIRRORED_REPEAT", 10497 - "REPEAT" (default) + private List GetSampleProperties(TextureWrapMode wrap_u, TextureWrapMode wrap_v) + { + List sampler_Properties = new List(); + //FOR NOW WE WILL SET DEFAULT VALUES, THE SAME DEFAULTS AS GLOTF FORMAT + int _magFilter = 9729; // LINEAR + int _minFilter = 9986; // NEAREST_MIPMAP_LINEAR + int _wrapS = GetWrapModeInt(wrap_u); + int _wrapT = GetWrapModeInt(wrap_v); + + sampler_Properties.Add(new ObjectProperty("magFilter", _magFilter)); + sampler_Properties.Add(new ObjectProperty("minFilter", _minFilter)); + sampler_Properties.Add(new ObjectProperty("wrapS",_wrapS)); + sampler_Properties.Add(new ObjectProperty("wrapT", _wrapT)); + + return sampler_Properties; + } + + private int GetWrapModeInt(TextureWrapMode wrap) + { + switch (wrap) + { + case TextureWrapMode.Repeat: + return 10497; + case TextureWrapMode.Mirror: + return 33648; + case TextureWrapMode.Clamp: + return 33071; + } + return 10497; + } + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + if (allUniqueSamplers.Count > 0) + { + result += "\"samplers\" : [\n"; + for (int i = 0; i < allUniqueSamplers.Count; i++) + { + result += ObjectProperty.GetObjectProperties(allUniqueSamplers[i].samplerProperties); + if (i < allUniqueSamplers.Count - 1) + result += ",\n"; + } + result += "]"; + if (add_end_comma) + result += ",\n"; + } + return result; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSampler.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSampler.cs.meta new file mode 100644 index 0000000..69ccd3c --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSampler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 694f01758ba7bfd41aa426c0e90b2624 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectScene.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectScene.cs new file mode 100644 index 0000000..9770f6c --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectScene.cs @@ -0,0 +1,162 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectScene + { + public static List nodesList; + public static List extraProperties; + public static List properties; + + private static Cubemap environment; + private static Cubemap background; + + private static GameObject cubeSkybox; + public static void Reset() + { + nodesList = new List(); + extraProperties = new List(); + properties = new List(); + environment = null; + background = null; + } + + public static void AddNodeToScene(int node) + { + nodesList.Add(node); + } + + public static void SetupScene() + { + List _scenes = new List(); + + + + List _scene = new List(); + _scene.Add(new ObjectProperty("nodes", nodesList)); + ObjectExtraProperties _extra = AddExtraDataToScene(); + if (_extra != null) + _scene.Add(new ObjectProperty(_extra)); + + _scenes.Add(new ObjectProperty("",_scene)); + + properties.Add(new ObjectProperty("scenes", _scenes, true)); + + } + public static ObjectExtraProperties AddExtraDataToScene() + { + //FOG + if (RenderSettings.fog) + { + List _fog = new List(); + _fog.Add(new ObjectProperty("color", RenderSettings.fogColor)); + _fog.Add(new ObjectProperty("mode", RenderSettings.fogMode.ToString())); + _fog.Add(new ObjectProperty("near", RenderSettings.fogStartDistance)); + _fog.Add(new ObjectProperty("far", RenderSettings.fogEndDistance)); + extraProperties.Add(new ObjectProperty("fog", _fog)); + } + + // BACKGROUND + Cubemap scene_background = null; + if (ExportToGLTF.options.computedBackgroundCubemap != null) // if this was set, it is more iomportant, so override it + background = ExportToGLTF.options.computedBackgroundCubemap; + else + { + if (ExportToGLTF.options.exportSceneSkyboxBackground) + { + if (RenderSettings.skybox != null) + { + if (AssetDatabase.GetAssetPath(RenderSettings.skybox) != "Resources/unity_builtin_extra" || ExportToGLTF.options.exportSceneSkyboxBackgroundEvenDefault) + { + scene_background = SphericalPanoramaToCubemapConverter.GetCubemapFromSceneSkybox(); + background = scene_background; + cubeSkybox = ExportToGLTF.options.cubeSkybox; + } + } + } + } + + //ENVIRONMENT + if (ExportToGLTF.options.computedEnvironmentCubemap != null) // if this was set, it is more iomportant, so override it + environment = ExportToGLTF.options.computedEnvironmentCubemap; + else + { + if (ExportToGLTF.options.exportSceneSkyboxEnvironment) + { + if (RenderSettings.defaultReflectionMode == UnityEngine.Rendering.DefaultReflectionMode.Skybox && scene_background != null) + { + environment = scene_background; + } + if (RenderSettings.defaultReflectionMode == UnityEngine.Rendering.DefaultReflectionMode.Custom) + { + environment = RenderSettings.customReflection; + } + } + + } + + + + + + + if (environment != null) { + int _environment = ObjectExtrasCubeTextures.GetCubemapIndex(environment); + if (_environment != -1) + extraProperties.Add(new ObjectProperty("environment",_environment)); + } + + //BACKGROUND + if (background != null) + { + List _background = new List(); + + + int _backgroundCubeTexture = ObjectExtrasCubeTextures.GetCubemapIndex(background); + if (_backgroundCubeTexture != -1) + { + List _cubeTexture = new List(); + _cubeTexture.Add(new ObjectProperty("index", _backgroundCubeTexture)); + if (cubeSkybox != null) + { + _cubeTexture.Add(new ObjectProperty("node", ExportToGLTF.options.cubeSkybox)); + _cubeTexture.Add(new ObjectProperty("scale", ExportToGLTF.options.cubeSkyboxScale)); + + } + _background.Add(new ObjectProperty("cubeTexture", _cubeTexture)); + + + } + + if (_background.Count > 0) + { + extraProperties.Add(new ObjectProperty("background", _background)); + } + } + //BACKGROUND CUSTOM SKYBOX + + //SAVE ALL + if (extraProperties.Count > 0) + { + return new ObjectExtraProperties(extraProperties); + } + return null; + } + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + result += "\"scene\": 0,\n"; + for (int i = 0; i < properties.Count; i++) + { + result += properties[i].GetPropertyGLTF(); + } + if (add_end_comma) + result += ",\n"; + + return result; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectScene.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectScene.cs.meta new file mode 100644 index 0000000..0b336fb --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectScene.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ade22da866fc3da49a03ad49df3419c1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSkin.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSkin.cs new file mode 100644 index 0000000..df0642c --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSkin.cs @@ -0,0 +1,141 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectSkin + { + //statics + public static int globalIndex = -1; + public static List allUniqueSkins; + + //vars + public int index = -1; + + public ObjectAccessors accessorInverseBindMatrix; + public Transform [] bones; + public SkinnedMeshRenderer skinMesh; + //public int[] connectedJointIndices; + public static void Reset() + { + globalIndex = 0; + allUniqueSkins = new List(); + } + + public static int GetSkinIndex(SkinnedMeshRenderer _smr) + { + //if (_bones == null) + //Debug.Log("NULL BONES"); + if (_smr.rootBone == null) + return -1; + if (allUniqueSkins == null) + { + allUniqueSkins = new List(); + allUniqueSkins.Add(new ObjectSkin(_smr)); + + return allUniqueSkins.Count - 1; + } + else + { + foreach (ObjectSkin os in allUniqueSkins) + { + if (os.isSameSkin(_smr.bones)) + { + return os.index; + } + } + + allUniqueSkins.Add(new ObjectSkin( _smr)); + return allUniqueSkins.Count - 1; + } + } + public bool isSameSkin(Transform[] _bones) + { + if (_bones == null) + { + Debug.LogError("null bones"); + return false; + } + if (_bones.Length != bones.Length) + return false; + else + { + for (int i = 0; i < _bones.Length; i++) + { + if (bones[i] != _bones[i]) + return false; + } + } + return true; + } + public ObjectSkin(SkinnedMeshRenderer _smr) + { + index = globalIndex; + skinMesh = _smr; + bones = _smr.bones; + Debug.LogWarning("called here"); + Debug.Log(_smr); + for (int i =0; i < _smr.bones.Length; i++) + { + Debug.LogWarning("new!!"); + Debug.Log(_smr.sharedMesh.bindposes[i]); + Debug.Log("compare below"); + Debug.Log(_smr.bones[i].localToWorldMatrix); + Debug.Log(_smr.bones[i].localToWorldMatrix.inverse); + } + + + accessorInverseBindMatrix = new ObjectAccessors(GetInverseBonesMatrix4x4(_smr)); + globalIndex++; + } + public Matrix4x4[] GetInverseBonesMatrix4x4(SkinnedMeshRenderer _smr) + { + Matrix4x4[] result = new Matrix4x4[_smr.bones.Length]; + + for (int i =0; i < _smr.bones.Length; i++) + { + + result[i] = TransformUtilities.GetGLTFMatrix(_smr.sharedMesh.bindposes[i]); + } + + return result; + } + + private int[] GetTransformIndices() + { + int[] result = new int[bones.Length]; + for (int i =0; i < bones.Length; i++) + { + result[i] = bones[i].GetComponent().node; + } + return result; + } + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + if (allUniqueSkins.Count > 0) + { + result += "\"skins\" : [\n"; + //List _skins = new List(); + foreach (ObjectSkin os in allUniqueSkins) { + List _skin_single = new List(); + _skin_single.Add(new ObjectProperty("inverseBindMatrices", os.accessorInverseBindMatrix.export_index)); + _skin_single.Add(new ObjectProperty("joints", os.GetTransformIndices())); + result += ObjectProperty.GetObjectProperties(_skin_single) + ",\n"; + + } + if (allUniqueSkins.Count > 0) + result = StringUtilities.RemoveCharacterFromString(result, 2, false); + result += "]"; + if (add_end_comma) + result += ",\n"; + } + return result; + } + } +} + + diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSkin.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSkin.cs.meta new file mode 100644 index 0000000..d0fbe95 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectSkin.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 37eb84977915fbd4796673f2e0a65f63 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectTexture.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectTexture.cs new file mode 100644 index 0000000..db1b0d6 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectTexture.cs @@ -0,0 +1,173 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ObjectTexture + { + //consts + public string exportPreName = "txr_"; + public bool exportPropertyName = false; + + //statics + public static int globalIndex = -1; + public static List allUniqueTextures; + + //vars + public int index = -1; + public TextureType textureType; + + public List textureProperties; + public ObjectImage objectImage; + string exportName; + + public static void Reset() + { + globalIndex = 0; + allUniqueTextures = new List(); + } + public static int GetTextureIndex(Texture2D texture_2D, TextureType texture_type, bool metal_smooth_map, bool uses_alpha, bool save_alpha_map = false,int lightmap_index = -1, float _smoothnessMult = 1, float _metallicMult = 1) + { + if (texture_2D == null) + return -1; + if (allUniqueTextures == null) + { + allUniqueTextures = new List(); + allUniqueTextures.Add(new ObjectTexture(texture_2D, texture_type, metal_smooth_map, uses_alpha,false,lightmap_index, _smoothnessMult, _metallicMult)); + if (uses_alpha && save_alpha_map) + { + allUniqueTextures.Add(new ObjectTexture(texture_2D, texture_type, metal_smooth_map, uses_alpha, true,lightmap_index, _smoothnessMult, _metallicMult)); // SAVE THE SAME TEXTURE TWICE, THIS WAY WE SAVE THE SPOT FOR THE ALPHA VALUE + return allUniqueTextures.Count - 2; // AND RETURN THE POSITION OF THE FIRST ONE + } + return allUniqueTextures.Count - 1; + + + } + else + { + foreach (ObjectTexture ot in allUniqueTextures) + { + if (ot.IsSameTexture(texture_2D, metal_smooth_map)) + { + return ot.index; + } + } + allUniqueTextures.Add(new ObjectTexture(texture_2D, texture_type, metal_smooth_map, uses_alpha,false,lightmap_index, _smoothnessMult, _metallicMult)); + if (uses_alpha && save_alpha_map) + { + allUniqueTextures.Add(new ObjectTexture(texture_2D,texture_type, metal_smooth_map, uses_alpha, true,lightmap_index, _smoothnessMult, _metallicMult)); // SAVE THE SAME TEXTURE TWICE, THIS WAY WE SAVE THE SPOT FOR THE ALPHA VALUE + return allUniqueTextures.Count - 2; // AND RETURN THE POSITION OF THE FIRST ONE + } + return allUniqueTextures.Count - 1; + + } + } + private bool IsSameTexture(Texture2D texture_2D, bool metal_smooth_map) + { + if (texture_2D == objectImage.image && metal_smooth_map == objectImage.metalSmoothMap) + { + return true; + } + return false; + } + public ObjectTexture(Texture2D texture_2D, TextureType texture_type, bool metal_smooth_map, bool uses_alpha, bool is_alpha = false, int lightmap_index = -1, float _smoothnessMult = 1, float _metallicMult = 1) + { + index = globalIndex; + exportName = exportPreName + globalIndex; + textureType = texture_type; + textureProperties = GetTextureProperties(texture_2D, metal_smooth_map, uses_alpha, is_alpha, lightmap_index, _smoothnessMult, _metallicMult); + globalIndex++; + } + public List GetTextureProperties(Texture2D texture_2D, bool metal_smooth_map, bool uses_alpha, bool is_alpha = false, int lightmap_index = -1, float _smoothnessMult=1, float _metallicMult = 1) + { + //bool _exportFallback = ExportToGLTF.options.fallbackGLTFTexture; + bool _exportFallback = ExportToGLTF.options.SaveFallback(textureType); + + List _texture_properties = new List(); + string _name = exportName; + int _sampler = ObjectSampler.GeSamplerIndex(texture_2D); + int _source = ObjectImage.GetImageIndex(texture_2D, textureType, metal_smooth_map, uses_alpha, is_alpha, _exportFallback,0, _smoothnessMult, _metallicMult); + + + if (exportPropertyName) _texture_properties.Add(new ObjectProperty("name",_name)); + _texture_properties.Add(new ObjectProperty("sampler", _sampler)); + + TextureExportType _export_type = ExportToGLTF.options.GetExportTextureType(textureType); + + // WEBP OR NON WEBP SECTION + if (_export_type == TextureExportType.DEFAULT || _exportFallback) // IF FALLBACK SAVE HERE SOURCE TOO + { + _texture_properties.Add(new ObjectProperty("source", _source)); + } + if (_export_type != TextureExportType.DEFAULT) + { + if (ExportToGLTF.options.fallbackGLTFTexture) // IF WE HAVE FALLBACK ON TOP, WE MUST ADD 1 TO THE SOURCE, SINCE THE ORIGINAL IMAGE COMES AFTER THE FALLBACK IMAGE (SOURCE) + _source += 1; + + bool _requiredExtensions = true; + if (_exportFallback) // IF WE HAVE FALLBACK, WE DONT NECESSARY REQUIRE THE EXTENSION + _requiredExtensions = false; + + ObjectProperty _extensions = new ObjectProperty(); // CREATE AN EMPTY OBJECT THAT WILL HOLD THE EXTENSION + if (_export_type == TextureExportType.WEBP) + _extensions.AddExtensionObject(CreateEXT_texture_webp(_source, _requiredExtensions)); + if (_export_type == TextureExportType.KTX2) + _extensions.AddExtensionObject(CreateKHR_texture_basisu(_source,_requiredExtensions)); + _texture_properties.Add(_extensions); + } + if (textureType == TextureType.LIGHTMAP) + { + ObjectMasterExtras.AddLightmapTexture(lightmap_index, index); + } + + // save the objectimage for comparison + objectImage = ObjectImage.allUniqueImages[_source]; + + return _texture_properties; + + + } + private ObjectExtension CreateKHR_texture_basisu(int source, bool is_required) + { + List _properties = new List(); + if (source >= 0) + { + _properties.Add(new ObjectProperty("source", source)); + ObjectExtension ext_texture_webp = new ObjectExtension("KHR_texture_basisu", _properties, is_required); + return ext_texture_webp; + } + return null; + } + private ObjectExtension CreateEXT_texture_webp(int source, bool is_required) + { + List _properties = new List(); + if (source >= 0) + { + _properties.Add(new ObjectProperty("source", source)); + ObjectExtension ext_texture_webp = new ObjectExtension("EXT_texture_webp", _properties, is_required); + return ext_texture_webp; + } + return null; + } + + public static string GetGLTFData(bool add_end_comma = true) + { + string result = ""; + if (allUniqueTextures.Count > 0) + { + result += "\"textures\" : [\n"; + for (int i = 0; i < allUniqueTextures.Count; i++) + { + result += ObjectProperty.GetObjectProperties(allUniqueTextures[i].textureProperties); + if (i < allUniqueTextures.Count - 1) + result += ",\n"; + } + result += "]"; + if (add_end_comma) + result += ",\n"; + } + return result; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectTexture.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectTexture.cs.meta new file mode 100644 index 0000000..4454b85 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/ObjectTexture.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0942aa5887e9194489256e2ea8dea08e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/UVVariant.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/UVVariant.cs new file mode 100644 index 0000000..5818334 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/UVVariant.cs @@ -0,0 +1,130 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class UVVariant + { + //public MeshFilter baseMesh; // BASE MESH, WITHOUT MODIFICATIONS FROM CODE + public static List allUVs; + public static int globalIndex = -1; + + //vars + public int index =-1; + public Vector2 offsetUVs; + public Vector2 scaleUVs; + + public ObjectAccessors optionalObjectAccessor; + + public int baseAccessorInt; + + public static void Reset() + { + allUVs = new List(); + globalIndex = 0; + } + + public UVVariant(Vector2 offset_uvs, Vector2 scale_uvs) + { + offsetUVs = offset_uvs; + scaleUVs = scale_uvs; + + index = globalIndex; + + allUVs.Add(this); + globalIndex++; + } + + public ObjectAccessors CreateObjectAccessor(Vector2[] uvs, bool modify_values = true, string optional_identifier = "", Vector2? offset_orig = null, Vector2? scale_orig = null) + { + Vector2[] final_uvs = new Vector2[uvs.Length]; + //if (optional_identifier == "uvs_2") + //{ + // Debug.LogWarning("ENAB"); + // foreach (Vector2 v in uvs) + // { + // //if (v.x < 0.000001f) + // // { + // Debug.Log(v.x); + // //} + // } + //} + + Vector2 mult = Vector2.one; + Vector2 offset = Vector2.zero; + if (modify_values) + { + mult = scaleUVs; + offset = offsetUVs; + } + //if (optional_identifier == "uvs_2") { + // Debug.Log(scaleUVs.x + " " + scaleUVs.y); + // Debug.Log(offsetUVs.x + " " + offsetUVs.y); + //} + for (int i =0; i < final_uvs.Length; i++) + { + float valx = uvs[i].x; + float valy = uvs[i].y; + if (offset_orig != null) + { + valx = (valx * scale_orig.Value.x) + offset_orig.Value.x; + valy = (valy * scale_orig.Value.y) + offset_orig.Value.y; + } + + + valx = (valx * mult.x) + offset.x; + valy = (-(valy * mult.y) - offset.y) + 1; // IN GLTF UVS IN Y AR INVERSED, THEY GO FROM LEFT TOP CORNER TO BOTTOM RIGHT CORNER, Y MUST BE INVERSED + + + if (optional_identifier == "uvs_2") + { + if (valx < 0.000001f) valx = 0f; + if (valy < 0.000001f) valy = 0f; + } + + + final_uvs[i] = new Vector2(valx, valy); + //final_uvs[i] = new Vector2( + //(uvs[i].x * mult.x) + offset.x, + //(-(uvs[i].y * mult.y) - offset.y) + 1 + //); + + } + //DEBUGGINGR EMOVE LATER + + //if (optional_identifier == "uvs_2") + //{ + // Debug.LogWarning("STARTS"); + // foreach (Vector2 v in final_uvs) + // { + // //if (v.x < 0.000001f) + // // { + // Debug.Log(v.x); + // //} + // } + //} + + if (!ExportToGLTF.options.quantizeGLTF) + { + optionalObjectAccessor = new ObjectAccessors(final_uvs, false, optional_identifier); + } + else + { + optionalObjectAccessor = new ObjectAccessors(final_uvs, false, optional_identifier, ExportGLTFOptions.GetComponentType(ExportToGLTF.options.quantizeMainUVsTo), false); + } + return optionalObjectAccessor; + } + + public int GetObjectAccessorExportInt() + { + if (optionalObjectAccessor != null) + return optionalObjectAccessor.export_index; + else + { + Debug.LogError("Object accessor is required in uvs but not present!, returning -1"); + return -1; + } + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/UVVariant.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/UVVariant.cs.meta new file mode 100644 index 0000000..abdb683 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/UVVariant.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e685b30cfc118804fab42a6b10a831e7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes.meta new file mode 100644 index 0000000..e50e609 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8ab3c3c59dd591c4abb6941ea6eeec93 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesStandardMaterial.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesStandardMaterial.cs new file mode 100644 index 0000000..971315f --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesStandardMaterial.cs @@ -0,0 +1,243 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class PropertiesStandardMaterial + { + public static List GetMaterialProperties(Material _standardMaterial) + { + List material_Properties = new List(); + + //extensions + + // MATERIAL MAY BE NULL, BUT IT ALSO MAY HAVE A LIGHTMAP + if (_standardMaterial != null) + { + + ObjectExtension _khr_texture_transform_ext = null; + + //GET ALPHA NOW AND SAVE IT LATER (SOME PROPERTIES ARE REQUIRE TO KNOW IF IT USES ALPHA, BUT IN ORDER ALPHA IN SCHEMA IS LATER) + #region GET ALPHA + // //alphamode -- added first to know if material requires transparency in main texture + string _alphaMode = "OPAQUE"; + + if (_standardMaterial.GetFloat("_Mode") == 1) + { + // CUTOUT = 1 + _alphaMode = "MASK"; + } + if (_standardMaterial.GetFloat("_Mode") == 2 || _standardMaterial.GetFloat("_Mode") == 3) + { + // FADE = 2 AND TRANSPARENT = 3 // Check later in three js for different types of blends https://threejs.org/docs/#api/en/constants/CustomBlendingEquations + _alphaMode = "BLEND"; + } + bool _usesAlpha = _alphaMode != "OPAQUE" ? true : false; + #endregion + + #region PBR METALLIC ROUGHNESS SECTION + List _pbrMetallicRoughness = new List(); + + Texture2D TXRBaseColorTexture = _standardMaterial.GetTexture("_MainTex") as Texture2D; + if (TXRBaseColorTexture == null) TXRBaseColorTexture = _standardMaterial.mainTexture as Texture2D; // SOMETIMES _MainTex RETURNS NULL, BUT .mainTexture returns the texture, happens only in instantiated materials, to solve it, were double checking + + Vector2 _t_scale = _standardMaterial.GetTextureScale("_MainTex"); + Vector2 _t_offset = _standardMaterial.GetTextureOffset("_MainTex"); + _t_offset = new Vector2(_t_offset.x, _t_offset.y + (1f - _t_scale.y)); + _khr_texture_transform_ext = ObjectMaterial.CreateKHR_texture_transform(_t_scale, _t_offset); + // WILL RETURN NULL IF OFFSET IS VECTOR2.ZERO AND SCALE IS VECTOR2.ONE + + // SAVE COLOR? ONLY IF ITS WHITE, ALSO SAVE IT AS LINEAR + Color _baseColorFactor = _standardMaterial.GetColor("_Color"); + if (_baseColorFactor != Color.white) _pbrMetallicRoughness.Add(new ObjectProperty("baseColorFactor", _baseColorFactor.linear)); + + //SAVE ALPHA MAP? + bool export_separated_alpha = ExportToGLTF.options.ExportSeparatedAlphaMap(); + + //METALLIC - ROUGHNESS (1-SMOOTHNESS) + float _smoothness = _standardMaterial.GetFloat("_Glossiness"); + float _smoothnessScale= _standardMaterial.GetFloat("_GlossMapScale"); + if (_smoothnessScale != 1) + Debug.Log(_standardMaterial.name + " " + _smoothnessScale); + float _metallicMultiplier = ExportToGLTF.options.metallicMultiplier; + float _smoothnessMultiplier = ExportToGLTF.options.smoothnessMultiplier; + float _metallicFactor = _standardMaterial.GetFloat("_Metallic") * _metallicMultiplier; + float _roughnessFactor = 1f - (_smoothness * _smoothnessMultiplier); + int _metallicRoughnessTexture_index = ObjectMaterial.GetIntFromTexture(_standardMaterial.GetTexture("_MetallicGlossMap") as Texture2D, TextureType.METALLIC_SMOOTHNESS, true,false,false,-1, _smoothnessScale, 1); + + int _baseColorTexture_index = ObjectMaterial.GetIntFromTexture(TXRBaseColorTexture, TextureType.DEFAULT, false, _usesAlpha, export_separated_alpha); + + //IF TEXTURE EXISTS, ADD IT AS A TEXTURE INFO + if (_baseColorTexture_index != -1) + { + List _baseColorTextureProperties = new List(); + _baseColorTextureProperties.Add(new ObjectProperty("index", _baseColorTexture_index)); + //MOVED BELOW CHECK AND DELETE + //ObjectProperty _baseColorTexture = new ObjectProperty("baseColorTexture", _baseColorTextureProperties); + //_baseColorTexture.AddExtensionObject(_khr_texture_transform_ext); //EXTENSION KHR TRANSFORM + if (export_separated_alpha && _usesAlpha) + { + ObjectExtraProperties _extra = new ObjectExtraProperties(); + List _alphaMapTexture = new List(); + _alphaMapTexture.Add(new ObjectProperty("index", _baseColorTexture_index + 1)); + _extra.Add(new ObjectProperty("alphaMapTexture", _alphaMapTexture)); + _baseColorTextureProperties.Add(new ObjectProperty(_extra)); + } + ObjectProperty _baseColorTexture = new ObjectProperty("baseColorTexture", _baseColorTextureProperties); + _baseColorTexture.AddExtensionObject(_khr_texture_transform_ext); //EXTENSION KHR TRANSFORM + _pbrMetallicRoughness.Add(_baseColorTexture); + + } + + if (_metallicFactor != 1f && _metallicRoughnessTexture_index == -1) _pbrMetallicRoughness.Add(new ObjectProperty("metallicFactor", _metallicFactor)); + //PENDING TO CHECK: IN UNITY YOU CAN MODIFY THE SMOOTHNESS FACTOR WHILE STILL HAVING A TEXTURE, CHECK IF IT CAN HAPPEN SAME IN THREE JS + if (_roughnessFactor != 1f && _metallicRoughnessTexture_index == -1) _pbrMetallicRoughness.Add(new ObjectProperty("roughnessFactor", _roughnessFactor)); + + //IF METALLIC SMOOTHNESS TEXTURE EXISTS, ADD IT AS A TEXTURE INFO + if (_metallicRoughnessTexture_index != -1) + { + //float _mult = _standardMaterial.GetFloat("_GlossMapScale"); + + List _metallicRoughnessTextureProperties = new List(); + _metallicRoughnessTextureProperties.Add(new ObjectProperty("index", _metallicRoughnessTexture_index)); + ObjectProperty _metallicRoughnessTexture = new ObjectProperty("metallicRoughnessTexture", _metallicRoughnessTextureProperties); + // MUST BE DONE THIS WAY, EVEN IF ITS GLOSSINESS ITS CONDIERED AS "MULTIPLIED", SO GLOSSINESS AND ROUGNESS INTENSITY ARE THE SAME WHEN AN IMAGE IS PROVIDED + //if (_mult != 1f) + //_pbrMetallicRoughness.Add(new ObjectProperty("roughnessFactor", _mult)); + + _metallicRoughnessTexture.AddExtensionObject(_khr_texture_transform_ext); //EXTENSION KHR TRANSFORM + + _pbrMetallicRoughness.Add(_metallicRoughnessTexture); + } + + if (_pbrMetallicRoughness.Count > 0) + material_Properties.Add(new ObjectProperty("pbrMetallicRoughness", _pbrMetallicRoughness)); + #endregion + + #region NORMAL MAP SECTION + Texture2D TXRNormalTexture = _standardMaterial.GetTexture("_BumpMap") as Texture2D; + if (TXRNormalTexture != null) + { + List _normalTextureProperties = new List(); + + int _normalTexture_index = ObjectMaterial.GetIntFromTexture(TXRNormalTexture, TextureType.NORMAL); + float _normalTexture_scale = _standardMaterial.GetFloat("_BumpScale"); + + _normalTextureProperties.Add(new ObjectProperty("index", _normalTexture_index)); + if (_normalTexture_scale != 1f) _normalTextureProperties.Add(new ObjectProperty("scale", _normalTexture_scale)); + ObjectProperty _normalTexture = new ObjectProperty("normalTexture", _normalTextureProperties); + _normalTexture.AddExtensionObject(_khr_texture_transform_ext); //EXTENSION KHR TRANSFORM + + material_Properties.Add(_normalTexture); + } + #endregion + + #region OCLUSION MAP SECTION + Texture2D TXROcclusionTexture = _standardMaterial.GetTexture("_OcclusionMap") as Texture2D; + if (TXROcclusionTexture != null) + { + List _occlusionTextureProperties = new List(); + + int _occlusionTexture_index = ObjectMaterial.GetIntFromTexture(TXROcclusionTexture, TextureType.DEFAULT); + float _occlusionTexture_strength = _standardMaterial.GetFloat("_OcclusionStrength"); + + _occlusionTextureProperties.Add(new ObjectProperty("index", _occlusionTexture_index)); + if (_occlusionTexture_strength != 1f) _occlusionTextureProperties.Add(new ObjectProperty("strength", _occlusionTexture_strength)); + ObjectProperty _occlusionTexture = new ObjectProperty("occlusionTexture", _occlusionTextureProperties); + + //EXTENSION KHR TRANSFORM + _occlusionTexture.AddExtensionObject(_khr_texture_transform_ext); + + material_Properties.Add(_occlusionTexture); + } + #endregion + + #region EMISSION MAP AND FACTOR + if (_standardMaterial.IsKeywordEnabled("_EMISSION")) + { + //emission texture + Texture2D TXREmissiveTexture = _standardMaterial.GetTexture("_EmissionMap") as Texture2D; + if (TXREmissiveTexture != null) + { + List _emissiveTextureProperties = new List(); + + int _emissiveTexture_index = ObjectMaterial.GetIntFromTexture(TXREmissiveTexture, TextureType.DEFAULT); + + _emissiveTextureProperties.Add(new ObjectProperty("index", _emissiveTexture_index)); + ObjectProperty _emissiveTexture = new ObjectProperty("emissiveTexture", _emissiveTextureProperties); + _emissiveTexture.AddExtensionObject(_khr_texture_transform_ext); + + material_Properties.Add(_emissiveTexture); + } + + //emission factor + Color _emissiveFactor = _standardMaterial.GetColor("_EmissionColor"); + if (_emissiveFactor != Color.black) + material_Properties.Add(new ObjectProperty("emissiveFactor", _emissiveFactor, true)); + + } + #endregion + + #region ADD ALPHA + if (_alphaMode != "OPAQUE") material_Properties.Add(new ObjectProperty("alphaMode", _alphaMode)); + + if (_alphaMode == "MASK") + { + float _alphaCutoff = _standardMaterial.GetFloat("_Cutoff"); + if (_alphaCutoff != 0.5f) + { + material_Properties.Add(new ObjectProperty("alphaCutoff", _alphaCutoff)); + } + } + #endregion + + } + return material_Properties; + + + + + + ////extras + ////commonConstant (lightmap) + //if (lightmap_index != -1 || ExportToGLTF.options.whiteImageForNonStaticLightmaps) + //{ + // Texture2D TXRLightmapTexture = null; + // if (lightmap_index != -1) + // { + // TXRLightmapTexture = LightmapSettings.lightmaps[lightmap_index].lightmapColor; + // } + // else + // { + // if (ExportToGLTF.options.whiteImageForNonStaticLightmaps) + // TXRLightmapTexture = GetLightmapWhite(); + // } + + // if (TXRLightmapTexture != null) + // { + // List _lightmapTexture = new List(); + + // int _lightmapTexture_index = GetIntFromTexture(TXRLightmapTexture, TextureType.LIGHTMAP, false, false, false, lightmap_index); + // int _lightmapTexture_texCoord = 1; + // float _lightmapIntensity = ImageUtilities.GetImageMaxPixelFloatValue(TXRLightmapTexture, ExportToGLTF.options.maxLightmapClamp); + + // _lightmapTexture.Add(new ObjectProperty("index", _lightmapTexture_index)); + // _lightmapTexture.Add(new ObjectProperty("texCoord", _lightmapTexture_texCoord)); + + + // ObjectExtraProperties _extra = new ObjectExtraProperties(); + // _extra.Add(new ObjectProperty("lightmapTexture", _lightmapTexture)); + // _lightmapIntensity *= ExportToGLTF.options.lightmapIntensityMultiplier; + // if (_lightmapIntensity != 1) + // _extra.Add(new ObjectProperty("lightmapIntensity", _lightmapIntensity)); + + // material_Properties.Add(new ObjectProperty(_extra)); + // } + // //_commonConstant.Add(new ObjectProperty("")); + //} + + + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesStandardMaterial.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesStandardMaterial.cs.meta new file mode 100644 index 0000000..7b70975 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesStandardMaterial.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 79d2990a6fb96374bad86c244965df31 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesUniversalRenderPipeline.cs b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesUniversalRenderPipeline.cs new file mode 100644 index 0000000..3acc3f4 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesUniversalRenderPipeline.cs @@ -0,0 +1,202 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class PropertiesUniversalRenderPipeline + { + public static List GetMaterialProperties(Material _material) + { + List material_Properties = new List(); + + //extensions + + // MATERIAL MAY BE NULL, BUT IT ALSO MAY HAVE A LIGHTMAP + if (_material != null) + { + + ObjectExtension _khr_texture_transform_ext = null; + + //GET ALPHA NOW AND SAVE IT LATER (SOME PROPERTIES ARE REQUIRE TO KNOW IF IT USES ALPHA, BUT IN ORDER ALPHA IN SCHEMA IS LATER) + #region GET ALPHA + // //alphamode -- added first to know if material requires transparency in main texture + string _alphaMode = "OPAQUE"; + + if (_material.GetFloat("_Surface") == 1) + { + // CUTOUT = 1 + _alphaMode = "BLEND"; + } + else + { + if (_material.GetFloat("_AlphaClip") == 1) + { + _alphaMode = "MASK"; + } + } + bool _usesAlpha = _alphaMode != "OPAQUE" ? true : false; + + #endregion + + + + #region PBR METALLIC ROUGHNESS SECTION + List _pbrMetallicRoughness = new List(); + + Texture2D TXRBaseColorTexture = _material.GetTexture("_MainTex") as Texture2D; + if (TXRBaseColorTexture == null) TXRBaseColorTexture = _material.mainTexture as Texture2D; // SOMETIMES _MainTex RETURNS NULL, BUT .mainTexture returns the texture, happens only in instantiated materials, to solve it, were double checking + + Vector2 _t_scale = _material.GetTextureScale("_MainTex"); + Vector2 _t_offset = _material.GetTextureOffset("_MainTex"); + _t_offset = new Vector2(_t_offset.x, _t_offset.y + (1f - _t_scale.y)); + _khr_texture_transform_ext = ObjectMaterial.CreateKHR_texture_transform(_t_scale, _t_offset); + // WILL RETURN NULL IF OFFSET IS VECTOR2.ZERO AND SCALE IS VECTOR2.ONE + + // SAVE COLOR? ONLY IF ITS WHITE, ALSO SAVE IT AS LINEAR + Color _baseColorFactor = _material.GetColor("_BaseColor"); + if (_baseColorFactor != Color.white) _pbrMetallicRoughness.Add(new ObjectProperty("baseColorFactor", _baseColorFactor.linear)); + + //SAVE ALPHA MAP? + bool export_separated_alpha = ExportToGLTF.options.ExportSeparatedAlphaMap(); + + //METALLIC - ROUGHNESS (1-SMOOTHNESS) + float _smoothness = _material.GetFloat("_Smoothness"); + + float _metallicMultiplier = ExportToGLTF.options.metallicMultiplier; + float _smoothnessMultiplier = ExportToGLTF.options.smoothnessMultiplier; + float _metallicFactor = _material.GetFloat("_Metallic") * _metallicMultiplier; + float _roughnessFactor = 1f - (_smoothness * _smoothnessMultiplier); + int _metallicRoughnessTexture_index = ObjectMaterial.GetIntFromTexture(_material.GetTexture("_MetallicGlossMap") as Texture2D, TextureType.METALLIC_SMOOTHNESS, true, false, false, -1, _smoothness, 1); + + int _baseColorTexture_index = ObjectMaterial.GetIntFromTexture(TXRBaseColorTexture, TextureType.DEFAULT, false, _usesAlpha, export_separated_alpha); + + //IF TEXTURE EXISTS, ADD IT AS A TEXTURE INFO + if (_baseColorTexture_index != -1) + { + List _baseColorTextureProperties = new List(); + _baseColorTextureProperties.Add(new ObjectProperty("index", _baseColorTexture_index)); + //MOVED BELOW CHECK AND DELETE + //ObjectProperty _baseColorTexture = new ObjectProperty("baseColorTexture", _baseColorTextureProperties); + //_baseColorTexture.AddExtensionObject(_khr_texture_transform_ext); //EXTENSION KHR TRANSFORM + if (export_separated_alpha && _usesAlpha) + { + ObjectExtraProperties _extra = new ObjectExtraProperties(); + List _alphaMapTexture = new List(); + _alphaMapTexture.Add(new ObjectProperty("index", _baseColorTexture_index + 1)); + _extra.Add(new ObjectProperty("alphaMapTexture", _alphaMapTexture)); + _baseColorTextureProperties.Add(new ObjectProperty(_extra)); + } + ObjectProperty _baseColorTexture = new ObjectProperty("baseColorTexture", _baseColorTextureProperties); + _baseColorTexture.AddExtensionObject(_khr_texture_transform_ext); //EXTENSION KHR TRANSFORM + _pbrMetallicRoughness.Add(_baseColorTexture); + + } + + if (_metallicFactor != 1f && _metallicRoughnessTexture_index == -1) _pbrMetallicRoughness.Add(new ObjectProperty("metallicFactor", _metallicFactor)); + //PENDING TO CHECK: IN UNITY YOU CAN MODIFY THE SMOOTHNESS FACTOR WHILE STILL HAVING A TEXTURE, CHECK IF IT CAN HAPPEN SAME IN THREE JS + if (_roughnessFactor != 1f && _metallicRoughnessTexture_index == -1) _pbrMetallicRoughness.Add(new ObjectProperty("roughnessFactor", _roughnessFactor)); + + //IF METALLIC SMOOTHNESS TEXTURE EXISTS, ADD IT AS A TEXTURE INFO + if (_metallicRoughnessTexture_index != -1) + { + //float _mult = _standardMaterial.GetFloat("_GlossMapScale"); + + List _metallicRoughnessTextureProperties = new List(); + _metallicRoughnessTextureProperties.Add(new ObjectProperty("index", _metallicRoughnessTexture_index)); + ObjectProperty _metallicRoughnessTexture = new ObjectProperty("metallicRoughnessTexture", _metallicRoughnessTextureProperties); + // MUST BE DONE THIS WAY, EVEN IF ITS GLOSSINESS ITS CONDIERED AS "MULTIPLIED", SO GLOSSINESS AND ROUGNESS INTENSITY ARE THE SAME WHEN AN IMAGE IS PROVIDED + //if (_mult != 1f) + //_pbrMetallicRoughness.Add(new ObjectProperty("roughnessFactor", _mult)); + + _metallicRoughnessTexture.AddExtensionObject(_khr_texture_transform_ext); //EXTENSION KHR TRANSFORM + + _pbrMetallicRoughness.Add(_metallicRoughnessTexture); + } + + if (_pbrMetallicRoughness.Count > 0) + material_Properties.Add(new ObjectProperty("pbrMetallicRoughness", _pbrMetallicRoughness)); + #endregion + + #region NORMAL MAP SECTION + Texture2D TXRNormalTexture = _material.GetTexture("_BumpMap") as Texture2D; + if (TXRNormalTexture != null) + { + List _normalTextureProperties = new List(); + + int _normalTexture_index = ObjectMaterial.GetIntFromTexture(TXRNormalTexture, TextureType.NORMAL); + float _normalTexture_scale = _material.GetFloat("_BumpScale"); + + _normalTextureProperties.Add(new ObjectProperty("index", _normalTexture_index)); + if (_normalTexture_scale != 1f) _normalTextureProperties.Add(new ObjectProperty("scale", _normalTexture_scale)); + ObjectProperty _normalTexture = new ObjectProperty("normalTexture", _normalTextureProperties); + _normalTexture.AddExtensionObject(_khr_texture_transform_ext); //EXTENSION KHR TRANSFORM + + material_Properties.Add(_normalTexture); + } + #endregion + + #region OCLUSION MAP SECTION + Texture2D TXROcclusionTexture = _material.GetTexture("_OcclusionMap") as Texture2D; + if (TXROcclusionTexture != null) + { + List _occlusionTextureProperties = new List(); + + int _occlusionTexture_index = ObjectMaterial.GetIntFromTexture(TXROcclusionTexture, TextureType.DEFAULT); + float _occlusionTexture_strength = _material.GetFloat("_OcclusionStrength"); + + _occlusionTextureProperties.Add(new ObjectProperty("index", _occlusionTexture_index)); + if (_occlusionTexture_strength != 1f) _occlusionTextureProperties.Add(new ObjectProperty("strength", _occlusionTexture_strength)); + ObjectProperty _occlusionTexture = new ObjectProperty("occlusionTexture", _occlusionTextureProperties); + + //EXTENSION KHR TRANSFORM + _occlusionTexture.AddExtensionObject(_khr_texture_transform_ext); + + material_Properties.Add(_occlusionTexture); + } + #endregion + + #region EMISSION MAP AND FACTOR + if (_material.IsKeywordEnabled("_EMISSION")) + { + //emission texture + Texture2D TXREmissiveTexture = _material.GetTexture("_EmissionMap") as Texture2D; + if (TXREmissiveTexture != null) + { + List _emissiveTextureProperties = new List(); + + int _emissiveTexture_index = ObjectMaterial.GetIntFromTexture(TXREmissiveTexture, TextureType.DEFAULT); + + _emissiveTextureProperties.Add(new ObjectProperty("index", _emissiveTexture_index)); + ObjectProperty _emissiveTexture = new ObjectProperty("emissiveTexture", _emissiveTextureProperties); + _emissiveTexture.AddExtensionObject(_khr_texture_transform_ext); + + material_Properties.Add(_emissiveTexture); + } + + //emission factor + Color _emissiveFactor = _material.GetColor("_EmissionColor"); + if (_emissiveFactor != Color.black) + material_Properties.Add(new ObjectProperty("emissiveFactor", _emissiveFactor, true)); + + } + #endregion + + #region ADD ALPHA + if (_alphaMode != "OPAQUE") material_Properties.Add(new ObjectProperty("alphaMode", _alphaMode)); + + if (_alphaMode == "MASK") + { + float _alphaCutoff = _material.GetFloat("_Cutoff"); + if (_alphaCutoff != 0.5f) + { + material_Properties.Add(new ObjectProperty("alphaCutoff", _alphaCutoff)); + } + } + #endregion + + } + return material_Properties; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesUniversalRenderPipeline.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesUniversalRenderPipeline.cs.meta new file mode 100644 index 0000000..f619759 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/GLTFObjects/materialTypes/PropertiesUniversalRenderPipeline.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 49eda6b48edc91044b6972786aaa5d71 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects.meta new file mode 100644 index 0000000..4b549ec --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a3dc2a2f500993a40bea00577f140e6d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/Mono_ExportToGLTF_SmartObject.cs b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/Mono_ExportToGLTF_SmartObject.cs new file mode 100644 index 0000000..dc01e2e --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/Mono_ExportToGLTF_SmartObject.cs @@ -0,0 +1,187 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF.SMART { + + [ExecuteAlways] + public class Mono_ExportToGLTF_SmartObject : MonoBehaviour + { + public SO_ExportGLTFOptions gltfCustomOptions; + public string nameIdentifier; + [HideInInspector] + public SmartType smartType = SmartType.basic; + [HideInInspector] + public bool displayClassName = true; + [HideInInspector] + public string smartObjectClassName; + [HideInInspector] + public string modelId; + [HideInInspector] + public string exportLocation; + [HideInInspector] + public int curBuild; + + //scene extras + [HideInInspector] + public ReflectionProbe optionalReflectionProbe; + [HideInInspector] + public bool exportFog; + + [HideInInspector] + public GameObject startPosition; + [HideInInspector] + public List startPositionList; + + private List _smartObject; + public virtual void ExportGLTF(string location, bool test_build) + { + + string finalModelID = test_build ? modelId + "_" + curBuild.ToString() : modelId; + + SetupExtrasData(); + + ExportGLTFOptions export_options = GetExportOptions(); + + ExportToGLTF.CallExportGLTF(location, "gltf", transform, export_options, true, finalModelID, true); + + if (test_build) curBuild++; + + ClearExtrasComputedData(); + } + public void SetupExtrasData() + { + ObjectMasterComputedExtrasMono _masterExtras = transform.gameObject.AddComponent(); + + //if (smartObjectClassName != "") { + _smartObject = new List(); + _smartObject.Add(new ObjectProperty("name", nameIdentifier)); + if (smartObjectClassName != "") _smartObject.Add(new ObjectProperty("class", smartObjectClassName)); + _smartObject.Add(new ObjectProperty("smartType", smartType.ToString())); + _smartObject.AddRange(SetupCustomExtrasData()); + _masterExtras.AddProperty(new ObjectProperty("smartObject", _smartObject)); + if (smartType == SmartType.space) + { + if (startPositionList != null) + { + if (startPositionList.Count > 0) + { + Debug.Log("additnob"); + startPositionList = GameObjectUtilities.RemoveNullObjects(startPositionList); + _smartObject.Add(new ObjectProperty("startPosition", startPositionList)); + } + } + } + } + public virtual List SetupCustomExtrasData() + { + return new List(); + } + public virtual void ClearExtrasComputedData() + { + ObjectNodeComputedExtrasMono[] computed_nodes = transform.GetComponentsInChildren(true); + ObjectMasterComputedExtrasMono[] computed_master = transform.GetComponentsInChildren(true); + for (int i = 0; i < computed_nodes.Length; i++) + GameObject.DestroyImmediate(computed_nodes[i]); + for (int i = 0; i < computed_master.Length; i++) + GameObject.DestroyImmediate(computed_master[i]); + } + public virtual ExportGLTFOptions GetExportOptions() + { + ExportGLTFOptions options; + if (gltfCustomOptions != null) + options = new ExportGLTFOptions(gltfCustomOptions); + else + { + options = new ExportGLTFOptions(); + + // NODES - OPTIONS + options.exportGameObjectName = true; + options.exportMaterialName = false; + options.exportTexturesName = false; + options.exportInactive = true; + options.exportGameObjectsTag = true; + options.exportGameObjectsLayer = true; + options.exportBatching = true; + options.exportNavMesh = true; + + //MESH OPTIONS + options.reduceGLTFChars = false; + options.exportNormals = true; + options.exportLightmapUVs = true; + options.convertToGLB = true; // pendig + options.createUVOffsetExtras = false; //pending + options.exportSubmeshesInExtra = false; + + //TEXTURES QUALITY + options.colorTextureSaturation = 0.8f; + options.exportSeparatedAlphaMap = true; + options.exportTextureType = TextureExportType.WEBP; + options.fallbackGLTFTexture = false; + options.allImagesQuality = 75; + options.overrideLightmapQuality = 90; + options.overrideNormalQuality = 0; + options.overrideMetallicSmoothnessQuality = 0; + options.overrideDefaultQuality = 0; + options.overrideCubemapQuality = 0; + + options.overrideLightmapExportTextureType = TextureExportType.DEFAULT; + options.overrideMetallicSmoothnessExportTextureType = TextureExportType.WEBP; + options.overrideNormalExportTextureType = TextureExportType.WEBP; + options.overrideDefaultExportTextureType = TextureExportType.WEBP; + options.overrideCubemapTextureType = TextureExportType.WEBP; + + //LIGHTMAP OPTIONS + options.maxLightmapClamp = 5f; + options.saturationLightmap = 1f; + options.lightmapIntensityMultiplier = 2.5f; + options.lightmapContrastCheat = 1f; + options.whiteImageForNonStaticLightmaps = true; + + //QUANTIZATION + options.quantizeGLTF = true; + options.quantizeMainUVsTo = ComponentTypeSelected.SHORT; + options.quantizeLightUVsTo = ComponentTypeSelected.SHORT; + options.quantizeVerticesTo = ComponentTypeSelected.FLOAT; + options.quantizeNormalsTo = ComponentTypeSelected.BYTE; + + + + options.overrideEnvironmentQuality = 0; + options.extraExportMainCameraInGLTF = false; + } + + options.exportCameras = false; + // MUST BE IN BOTH CASES TO OVERRIDE VALUES FROM USER. SMART OBJECT SPACES REQUIRE ENVIRONEMNT DEFINITION + if (smartType == SmartType.space) + { + options.exportSceneSkyboxBackground = true; + options.exportSceneSkyboxEnvironment = true; + //options.createCubeForSkybox = true; + if (exportFog) + options.exportSceneFog = true; + if (optionalReflectionProbe != null) + options.computedEnvironmentCubemap = optionalReflectionProbe.bakedTexture as Cubemap; + } + else + { + options.exportSceneSkyboxBackground = false; + options.exportSceneSkyboxEnvironment = false; + //options.createCubeForSkybox = false; + options.exportSceneSkyboxBackgroundEvenDefault = false; + options.exportSceneFog = false; + } + return options; + } + + public void AddStartPositionToArray(GameObject obj) + { + if (startPositionList == null) + startPositionList = new List(); + + startPositionList.Insert(0,obj); + } + } + +} + diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/Mono_ExportToGLTF_SmartObject.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/Mono_ExportToGLTF_SmartObject.cs.meta new file mode 100644 index 0000000..72791f0 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/Mono_ExportToGLTF_SmartObject.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e007c6500c3f23740aec6c5c382c20cd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard.meta new file mode 100644 index 0000000..f74fcd7 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7f93135fb0962d946902e54d672ebc1b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components.meta new file mode 100644 index 0000000..26afb86 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: debbb68359eed0b4881367cfb382dff8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/InputField.cs b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/InputField.cs new file mode 100644 index 0000000..64b2f4e --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/InputField.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF.SMART.meme_SmartKeyboard +{ + [RequireComponent(typeof(ObjectNodeTextContainer))] + public class InputField : ObjectNodeUserExtrasMono + { + // Start is called before the first frame update + private void Reset() + { + displayOptions = false; + extrasName = "inputField"; + + tooltip = "Input for smart keyboard"; + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/InputField.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/InputField.cs.meta new file mode 100644 index 0000000..5dabf84 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/InputField.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 06b6351ceef13e54ba7df5c3396503d1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/keyPad.cs b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/keyPad.cs new file mode 100644 index 0000000..2fdee22 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/keyPad.cs @@ -0,0 +1,85 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace WEBGL_EXPORTER.GLTF.SMART.meme_SmartKeyboard +{ + public class keyPad : ObjectNodeUserExtrasMono + { + public enum KeyType { key = 0, submit = 1, switcher = 2, delete = 3, supreme = 4, close = 5, home = 6 , exitvr= 7} + public KeyType keyType = KeyType.key; + public string value = ""; + public GameObject[] turnOff; + public GameObject[] turnOn; + private void Reset() + { + displayOptions = false; + extrasName = "keyPad"; + + tooltip = "Choose the type of keys, and if required, the additional data"; + } + public override void SetGLTFComputedData() + { + AddProperty(new ObjectProperty("keyType", keyType.ToString())); + if (keyType == KeyType.key) + { + AddProperty(new ObjectProperty("value", value)); + } + if (keyType == KeyType.switcher) + { + foreach(GameObject go in turnOff) + { + Debug.Log(go.GetComponent()); + } + foreach (GameObject go in turnOn) + { + Debug.Log(go.GetComponent()); + } + + AddProperty(new ObjectProperty("enable", turnOn)); + AddProperty(new ObjectProperty("disable", turnOff)); + + } + } + } +#if UNITY_EDITOR + [CustomEditor(typeof(keyPad), true)] + public class keyPadEditor : Editor + { + keyPad myScript; + MonoScript script; + + private void OnEnable() + { + myScript = (keyPad)target; + script = MonoScript.FromMonoBehaviour((keyPad)target); + + } + public override void OnInspectorGUI() + { + EditorGUILayout.ObjectField("Script: ", script, typeof(MonoScript), false); + //base.OnInspectorGUI(); + myScript.keyType = (keyPad.KeyType)EditorGUILayout.EnumPopup("Key Type", myScript.keyType); + if (myScript.keyType == keyPad.KeyType.key) + myScript.value = EditorGUILayout.TextField("Value: ", myScript.value); + + if (myScript.keyType == keyPad.KeyType.switcher) + { + serializedObject.Update(); + var turnOff = serializedObject.FindProperty("turnOff"); + var turnOn = serializedObject.FindProperty("turnOn"); + + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(turnOn, true); + EditorGUILayout.PropertyField(turnOff, true); + if (EditorGUI.EndChangeCheck()) + serializedObject.ApplyModifiedProperties(); + } + } + } +#endif +} + diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/keyPad.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/keyPad.cs.meta new file mode 100644 index 0000000..5913008 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/keyPad.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 78a46e1e27b3cda4dad3452c92918b2a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/matStickers.cs b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/matStickers.cs new file mode 100644 index 0000000..2d1f85c --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/matStickers.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF.SMART.meme_SmartKeyboard +{ + public class matStickers : ObjectNodeUserExtrasMono + { + private void Reset() + { + displayOptions = false; + extrasName = "matStickers"; + + tooltip = "Add this to the key labels, must have the mesh renderer"; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/matStickers.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/matStickers.cs.meta new file mode 100644 index 0000000..018c49f --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/components/matStickers.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d223f71babbef1e4698e85aa491d0252 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/meme_SmartKeyboard.cs b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/meme_SmartKeyboard.cs new file mode 100644 index 0000000..5cd70e6 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/meme_SmartKeyboard.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF.SMART.meme_SmartKeyboard +{ + public class meme_SmartKeyboard : Mono_ExportToGLTF_SmartObject + { + public InputField targetinputField; + private void Reset() + { + displayClassName = false; + smartObjectClassName = "meme_SmartKeyboard"; + smartType = SmartType.ui; + } + public override List SetupCustomExtrasData() + { + List customData = new List(); + if (targetinputField != null) + { + customData.Add(new ObjectProperty("targetInputField", targetinputField.gameObject)); + } + return customData; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/meme_SmartKeyboard.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/meme_SmartKeyboard.cs.meta new file mode 100644 index 0000000..f7805eb --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartKeyboard/meme_SmartKeyboard.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dcec1734f93caa549a3b11379f3abb8c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectBehaviour.cs b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectBehaviour.cs new file mode 100644 index 0000000..757490c --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectBehaviour.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class SmartObjectBehaviour : MonoBehaviour + { + public TextAsset javascript; + private void Start() + { + // do nothing, just need the checkbox + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectBehaviour.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectBehaviour.cs.meta new file mode 100644 index 0000000..7793411 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3d17c09c87776444fa719ec461f91aa2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectsReadme.txt b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectsReadme.txt new file mode 100644 index 0000000..794fa09 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectsReadme.txt @@ -0,0 +1,6 @@ +SmartObjects are GLTF files with extra information + +Each smart object must contain its own folder, with its own folder components +On Top of them, a readme file +SmartObjects must extend SmartObjectClass +SmartObject Components must extend from a custom SmartObject Component class named as the smart object \ No newline at end of file diff --git a/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectsReadme.txt.meta b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectsReadme.txt.meta new file mode 100644 index 0000000..168638f --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/SmartObjects/SmartObjectsReadme.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f48ca19aeee2c6e44b0a5e132d4f6dfc +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/Utilities.meta b/Scripts/GLTFExporter/GLTFGenerator/Utilities.meta new file mode 100644 index 0000000..487037f --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/Utilities.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fcf5469f218963142a35f39ba3d13679 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/Utilities/CubemapExtra.cs b/Scripts/GLTFExporter/GLTFGenerator/Utilities/CubemapExtra.cs new file mode 100644 index 0000000..942e4f3 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/Utilities/CubemapExtra.cs @@ -0,0 +1,116 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +namespace WEBGL_EXPORTER +{ + public class CubemapExtra + { + + public Texture2D posx; + public Texture2D negx; + + public Texture2D posy; + public Texture2D negy; + + public Texture2D posz; + public Texture2D negz; + + + public string name; + //public bool reverse = false; + + public CubemapExtra(ReflectionProbe refProbe, string cubemapName = ""/*, bool _reverse = false*/) + { + if (refProbe != null) + { + Cubemap _cubemap = refProbe.bakedTexture as Cubemap; + if (_cubemap != null) + { + GetCubemapImages(_cubemap/*, _reverse*/); + } + else + { + negx = posx = negy = posy = negz = posz = ImageGenerator.CreateSimpleTexture(new Color(0.2f, 0.2f, 0.2f)); + } + + } + else + { + negx = posx = negy = posy = negz = posz = ImageGenerator.CreateSimpleTexture(new Color(0.2f, 0.2f, 0.2f)); + } + // reverse = _reverse; + name = cubemapName; + } + public CubemapExtra(Color _cubemap_color, string _cubemapName = "") + { + negx = posx = negy = posy = negz = posz = ImageGenerator.CreateSimpleTexture(_cubemap_color); + name = _cubemapName; + } + public CubemapExtra(Cubemap _cubemap, string _cubemapName = ""/*, bool _reverse = false*/) + { + //reverse = _reverse; + name = _cubemapName; + if (_cubemap != null) + { + GetCubemapImages(_cubemap/*, _reverse*/); + } + else + { + negx = posx = negy = posy = negz = posz = ImageGenerator.CreateSimpleTexture(new Color(0.2f, 0.2f, 0.2f)); + } + } + + private void GetCubemapImages(Cubemap _cubemap/*, bool _reverse = false*/) + { + ImageGenerator.MakeReadableCubemap(_cubemap); + int textureSize = (int)(Mathf.Sqrt(_cubemap.GetPixels(CubemapFace.NegativeX).Length)); + + negx = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.NegativeX), textureSize, textureSize, false, true); + posx = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.PositiveX), textureSize, textureSize, false, true); + + negy = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.NegativeY), textureSize, textureSize, true, false); + posy = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.PositiveY), textureSize, textureSize, true, false); + + negz = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.NegativeZ), textureSize, textureSize, false, true); + posz = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.PositiveZ), textureSize, textureSize, false, true); + } + + public Texture2D[] GetCubemapTextures() + { + Texture2D[] result = new Texture2D[6]; + result[0] = negx; //negx and posx are inverted in three js + result[1] = posx; + + result[2] = posy; + result[3] = negy; + + result[4] = negz; //negz and posz are inverted in three js + result[5] = posz; + + return result; + } + + public static Texture2D[] CreateCubemapTextures(Cubemap _cubemap) + { + if (_cubemap != null) + { + ImageGenerator.MakeReadableCubemap(_cubemap); + int textureSize = (int)(Mathf.Sqrt(_cubemap.GetPixels(CubemapFace.NegativeX).Length)); + + Texture2D[] result = new Texture2D[6]; + + result[0] = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.NegativeX), textureSize, textureSize, false, true); //negx in three js + result[1] = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.PositiveX), textureSize, textureSize, false, true); //posx in three js + + result[2] = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.PositiveY), textureSize, textureSize, false, true); //posy in three js + result[3] = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.NegativeY), textureSize, textureSize, false, true); //negy in three js + + result[4] = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.PositiveZ), textureSize, textureSize, false, true); //posz in three js + result[5] = ImageGenerator.GetTextureFromPixels(_cubemap.GetPixels(CubemapFace.NegativeZ), textureSize, textureSize, false, true); //negz in three js + + return result; + } + return null; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/Utilities/CubemapExtra.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/Utilities/CubemapExtra.cs.meta new file mode 100644 index 0000000..1e7bc79 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/Utilities/CubemapExtra.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0e41718533dfb014e9309d2261b5b8b4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/Utilities/ExportGLTFOptions.cs b/Scripts/GLTFExporter/GLTFGenerator/Utilities/ExportGLTFOptions.cs new file mode 100644 index 0000000..9ac0e78 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/Utilities/ExportGLTFOptions.cs @@ -0,0 +1,474 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class ExportGLTFOptions + { + + // LOCATION + public string exportLocation = ""; // SET ONCE EXPORT TO GLTF IS CALLED + + // GENERIC EXTRAS + // NODES - OPTIONS + public bool exportGameObjectName; + public bool exportMaterialName; + public bool exportTexturesName; + public bool exportCameras; + public bool exportInactive; + public bool exportGameObjectsTag; + public bool exportGameObjectsLayer; + public bool exportBatching; + public bool exportNavMesh; + public bool blockLeafNodesCreation; + + //ANIMATIONS + public bool exportAnimations = true; + + //MESH OPTIONS + public bool reduceGLTFChars; + public bool exportNormals; + public bool exportLightmapUVs; // NOT WORKING YET, RIGHT NOW IT WILL ALWAYS EXPORT LIGHTMAP UVS + public bool convertToGLB; // NOT WORKING YET. + public bool createUVOffsetExtras; // NOT WORKING YET: IF SET TO TRUE, FINAL SIZE WILL BE REDUCED, UVS WILL BE SAVED ONCE, AND OFFSET/SCALE WILL BE SAVED IN GLTF "EXTRAS" CODE FOR THREE JS GLTF IMPORTER TO USE + public bool exportSubmeshesInExtra; // SUBMESHES ARE EXPORTED SEPARATED IN CLASSIC GLTF, SHOULD BE EXPORTED COMBINED AND SAVE GROUPED POSITIONS + + //TEXTURES QUALITY + public float colorTextureSaturation; + public float metallicMultiplier; + public float smoothnessMultiplier; + public bool exportSeparatedAlphaMap; + public TextureExportType exportTextureType; + public bool fallbackGLTFTexture; + + public TextureDivideFactor allImagesDivideFactor= TextureDivideFactor.FULL; + public TextureDivideFactor overrideLightmapDivideFactor= TextureDivideFactor.NONE_SET; + public TextureDivideFactor overrideNormalDivideFactor= TextureDivideFactor.NONE_SET; + public TextureDivideFactor overrideMetallicSmoothnessDivideFactor= TextureDivideFactor.NONE_SET; + public TextureDivideFactor overrideCubemapDivideFactor= TextureDivideFactor.NONE_SET; + public TextureDivideFactor overrideDefaultDivideFactor = TextureDivideFactor.NONE_SET; + // public int + + public int allImagesQuality; + public int overrideLightmapQuality; // SET 0 TO NOT OVERRIDE + public int overrideNormalQuality; + public int overrideMetallicSmoothnessQuality; + public int overrideCubemapQuality; + public int overrideDefaultQuality; + + public TextureExportType overrideLightmapExportTextureType = TextureExportType.DEFAULT; + public TextureExportType overrideNormalExportTextureType = TextureExportType.NONE_SET; + public TextureExportType overrideMetallicSmoothnessExportTextureType = TextureExportType.NONE_SET; + public TextureExportType overrideDefaultExportTextureType = TextureExportType.NONE_SET; + public TextureExportType overrideCubemapTextureType = TextureExportType.NONE_SET; + + //LIGHTMAP OPTIONS + public float maxLightmapClamp; + public float saturationLightmap; + public bool whiteImageForNonStaticLightmaps; + public float lightmapIntensityMultiplier; + public float lightmapContrastCheat; + + //QUANTIZATION + public bool quantizeGLTF; + public ComponentTypeSelected quantizeMainUVsTo; + public ComponentTypeSelected quantizeLightUVsTo; + public ComponentTypeSelected quantizeVerticesTo; + public ComponentTypeSelected quantizeNormalsTo; + + // SCENE + public bool exportSceneSkyboxEnvironment; + public bool exportSceneSkyboxBackground; + public bool createCubeForSkybox = true; // + public GameObject cubeSkybox = null; + public int cubeSkyboxScale = 1; //1 = 1000 + public bool exportSceneSkyboxBackgroundEvenDefault; + public bool exportSceneFog; + public Cubemap computedEnvironmentCubemap; + public Cubemap computedBackgroundCubemap; + + public int overrideEnvironmentQuality = 0; + + //SET MAIN CAMERA + public bool extraExportMainCameraInGLTF = false; + public int extraCameraIndex = -1; + + //(AUTO CODE SECTION, NOT GLTF) + // BASIC VARS NAMES + public string varCamName = "_camera"; + public string varRendererName = "_renderer"; + public string varContainerName = "_container"; + public string varGLTFName = "_gltf"; + public string varSceneName = "_scene"; + + public ExportGLTFOptions() + { + GetPrefsValues(); + SetupTextureOverrides(); + } + public ExportGLTFOptions(SO_ExportGLTFOptions user_options) + { + GetUserValues(user_options); + SetupTextureOverrides(); + } + public bool SaveFallback(TextureType texture_type) + { + if (!fallbackGLTFTexture) + return false; + + TextureExportType exportType = exportTextureType; + + switch (texture_type) + { + case TextureType.DEFAULT: + exportType = overrideDefaultExportTextureType == TextureExportType.NONE_SET ? exportType : overrideDefaultExportTextureType; + break; + case TextureType.LIGHTMAP: + exportType = overrideLightmapExportTextureType == TextureExportType.NONE_SET ? exportType : overrideLightmapExportTextureType; + break; + case TextureType.METALLIC_SMOOTHNESS: + exportType = overrideMetallicSmoothnessExportTextureType == TextureExportType.NONE_SET ? exportType : overrideMetallicSmoothnessExportTextureType; + break; + case TextureType.NORMAL: + exportType = overrideNormalExportTextureType == TextureExportType.NONE_SET ? exportType : overrideNormalExportTextureType; + break; + case TextureType.CUBEMAP: + exportType = overrideCubemapTextureType == TextureExportType.NONE_SET ? exportType : overrideCubemapTextureType; + break; + } + + if (exportType != TextureExportType.DEFAULT) + return true; + return false; + } + public TextureExportType GetExportTextureType(TextureType texture_type) + { + switch (texture_type) + { + case TextureType.DEFAULT: + return overrideDefaultExportTextureType; + case TextureType.LIGHTMAP: + return overrideLightmapExportTextureType; + case TextureType.METALLIC_SMOOTHNESS: + return overrideMetallicSmoothnessExportTextureType; + case TextureType.NORMAL: + return overrideNormalExportTextureType; + case TextureType.CUBEMAP: + return overrideCubemapTextureType; + } + return TextureExportType.DEFAULT; + } + //public bool + public bool ExportSeparatedAlphaMap() + { + if (exportSeparatedAlphaMap) + { + if (exportTextureType == TextureExportType.DEFAULT || fallbackGLTFTexture) // MAKE SURE TO ALSE SAVE SEPARATED ALPHA IF WE HAVE FALLBACK TEXTURE + { + return true; + } + } + return false; + } + /// + /// order in list: Lightmaps = 0, Normal = 1; MetallicSmoothness = 2, Default = 3; + /// + /// + public List GetImagesQuality() + { + List result = new List(); + if (overrideLightmapQuality != 0) result.Add(overrideLightmapQuality); else result.Add(allImagesQuality); + if (overrideNormalQuality != 0) result.Add(overrideNormalQuality); else result.Add(allImagesQuality); + if (overrideMetallicSmoothnessQuality != 0) result.Add(overrideMetallicSmoothnessQuality); else result.Add(allImagesQuality); + if (overrideCubemapQuality != 0) result.Add(overrideCubemapQuality); else result.Add(allImagesQuality); + if (overrideDefaultQuality != 0) result.Add(overrideDefaultQuality); else result.Add(allImagesQuality); + + return result; + } + + public int GetImagesDivideFactor(string imageType) + { + int _allImagesFactor = (int)allImagesDivideFactor >= 1 ? (int)allImagesDivideFactor : 1; + switch (imageType) + { + case "lightmap": + return (int)overrideLightmapDivideFactor != -1 ? (int)overrideLightmapDivideFactor : _allImagesFactor; + case "normal": + return (int)overrideNormalDivideFactor != -1 ? (int)overrideNormalDivideFactor : _allImagesFactor; + case "metallicSmoothness": + return (int)overrideMetallicSmoothnessDivideFactor != -1 ? (int)overrideMetallicSmoothnessDivideFactor : _allImagesFactor; + case "cubemap": + return (int)overrideCubemapDivideFactor != -1 ? (int)overrideCubemapDivideFactor : _allImagesFactor; + case "default": + return (int)overrideDefaultDivideFactor != -1 ? (int)overrideDefaultDivideFactor : _allImagesFactor; + } + return _allImagesFactor; + } + public void SetupTextureOverrides() + { + if (exportTextureType == TextureExportType.DEFAULT) + { + overrideLightmapExportTextureType = exportTextureType; + overrideNormalExportTextureType = exportTextureType; + overrideMetallicSmoothnessExportTextureType = exportTextureType; + overrideDefaultExportTextureType = exportTextureType; + overrideCubemapTextureType = exportTextureType; + } + else + { + if (overrideLightmapExportTextureType == TextureExportType.NONE_SET) overrideLightmapExportTextureType = exportTextureType; + if (overrideNormalExportTextureType == TextureExportType.NONE_SET) overrideNormalExportTextureType = exportTextureType; + if (overrideMetallicSmoothnessExportTextureType == TextureExportType.NONE_SET) overrideMetallicSmoothnessExportTextureType = exportTextureType; + if (overrideDefaultExportTextureType == TextureExportType.NONE_SET) overrideDefaultExportTextureType = exportTextureType; + if (overrideCubemapTextureType == TextureExportType.NONE_SET) overrideCubemapTextureType = exportTextureType; + } + } + public bool RequiresKTX2() + { + if (exportTextureType == TextureExportType.KTX2) + return true; + return false; + } + + public ExportGLTFOptions(string cam_name, string renderer_name, string container_name, string gltf_name, string scene_name) + { + varCamName = cam_name; + GetPrefsValues(); + if (exportTextureType == TextureExportType.DEFAULT) + fallbackGLTFTexture = false; + + } + + public void GetPrefsValues() + { + //TEXTURE QUALITY + colorTextureSaturation = PlayerPrefs.GetFloat("gltf_o_colorTextureSaturation", 1f); + metallicMultiplier = PlayerPrefs.GetFloat("gltf_o_metallicMultiplier", 0.8f); + smoothnessMultiplier = PlayerPrefs.GetFloat("gltf_o_smoothnessMultiplier", 0.8f); + exportSeparatedAlphaMap = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportSeparatedAlphaMap", 0)); + exportTextureType = (TextureExportType)PlayerPrefs.GetInt("gltf_o_exportTextureType", (int)TextureExportType.DEFAULT); + fallbackGLTFTexture = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_fallbackGLTFTexture", 0)); + allImagesQuality = PlayerPrefs.GetInt("gltf_o_allImagesQuality", 90); + overrideLightmapQuality = PlayerPrefs.GetInt("gltf_o_overrideLightmapQuality", 0); + allImagesDivideFactor = (TextureDivideFactor)PlayerPrefs.GetInt("gltf_o_allImagesDivideFactor", 0); + overrideNormalQuality = PlayerPrefs.GetInt("gltf_o_overrideNormalQuality", 0); + overrideMetallicSmoothnessQuality = PlayerPrefs.GetInt("gltf_o_overrideMetallicSmoothnessQuality", 0); + overrideCubemapQuality = PlayerPrefs.GetInt("gltf_o_overrideCubemapQuality", 0); + overrideDefaultQuality = PlayerPrefs.GetInt("gltf_o_overrideDefaultQuality", 0); + + overrideDefaultExportTextureType = (TextureExportType)PlayerPrefs.GetInt("gltf_o_overrideDefaultExportTextureType", (int)TextureExportType.NONE_SET); + overrideLightmapExportTextureType = (TextureExportType)PlayerPrefs.GetInt("gltf_o_overrideLightmapExportTextureType", (int)TextureExportType.NONE_SET); + overrideMetallicSmoothnessExportTextureType = (TextureExportType)PlayerPrefs.GetInt("gltf_o_overrideMetallicSmoothnessExportTextureType", (int)TextureExportType.NONE_SET); + overrideNormalExportTextureType = (TextureExportType)PlayerPrefs.GetInt("gltf_o_overrideNormalExportTextureType", (int)TextureExportType.NONE_SET); + overrideCubemapTextureType = (TextureExportType)PlayerPrefs.GetInt("gltf_o_overrideCubemapTextureType", (int)TextureExportType.NONE_SET); + + //LIGHTMAP + maxLightmapClamp = PlayerPrefs.GetFloat("gltf_o_quantizeMainUVsTo", 5f); + saturationLightmap = PlayerPrefs.GetFloat("gltf_o_saturationLightmap", 1f); + lightmapIntensityMultiplier = PlayerPrefs.GetFloat("gltf_o_lightmapIntensityMultiplier", 1f); + lightmapContrastCheat = PlayerPrefs.GetFloat("gltf_o_lightmapContrastCheat", 1f); + whiteImageForNonStaticLightmaps = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_whiteImageForNonStaticLightmaps", 0)); + + //QUANTIZATION + quantizeGLTF = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_quantizeGLTF", 0)); + quantizeMainUVsTo = (ComponentTypeSelected)PlayerPrefs.GetInt("gltf_o_quantizeMainUVsTo", (int)ComponentTypeSelected.FLOAT); + quantizeLightUVsTo = (ComponentTypeSelected)PlayerPrefs.GetInt("gltf_o_quantizeLightUVsTo", (int)ComponentTypeSelected.FLOAT); + quantizeVerticesTo = (ComponentTypeSelected)PlayerPrefs.GetInt("gltf_o_quantizeVerticesTo", (int)ComponentTypeSelected.FLOAT); + quantizeNormalsTo = (ComponentTypeSelected)PlayerPrefs.GetInt("gltf_o_quantizeNormalsTo", (int)ComponentTypeSelected.FLOAT); + + // OTHER OPTIONS + exportGameObjectName = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportGameObjectName", 1)); + exportMaterialName = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportMaterialName", 1)); + exportTexturesName = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportTexturesName", 1)); + exportCameras = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportCameras", 1)); + exportInactive = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportInactive", 0)); + exportGameObjectsTag = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportGameObjectsTag", 0)); + exportGameObjectsLayer = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportGameObjectsLayer", 0)); + exportBatching = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportBatching", 0)); + exportNavMesh = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportNavMesh", 0)); + exportSubmeshesInExtra = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportSubmeshesInExtra", 0)); + reduceGLTFChars = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_reduceGLTFChars", 0)); + exportNormals = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportNormals", 1)); + exportLightmapUVs = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportLightmapUVs", 1)); + convertToGLB = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_convertToGLB", 0)); + createUVOffsetExtras = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_createUVOffsetExtras", 0)); + + //SCENE EXTRAS + exportSceneSkyboxEnvironment = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportSceneSkyboxEnvironment", 0)); + exportSceneSkyboxBackground = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_createCubeForSkybox", 0)); + createCubeForSkybox = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportSceneSkyboxBackground", 0)); + exportSceneSkyboxBackgroundEvenDefault = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportSceneSkyboxBackgroundEvenDefault", 0)); + exportSceneFog = GetBoolFromInt(PlayerPrefs.GetInt("gltf_o_exportSceneFog", 0)); + + + } + private void GetUserValues(SO_ExportGLTFOptions user_options) + { + //TEXTURE QUALITY + colorTextureSaturation = user_options.colorTextureSaturation; + metallicMultiplier = user_options.metallicMultiplier; + smoothnessMultiplier = user_options.smoothnessMultiplier; + exportSeparatedAlphaMap = user_options.exportSeparatedAlphaMap; + exportTextureType = user_options.exportTextureType; + fallbackGLTFTexture = user_options.fallbackGLTFTexture; + allImagesQuality = user_options.allImagesQuality; + + overrideLightmapQuality = user_options.overrideLightmapQuality; + overrideNormalQuality = user_options.overrideNormalQuality; + overrideMetallicSmoothnessQuality = user_options.overrideMetallicSmoothnessQuality; + overrideCubemapQuality = user_options.overrideCubemapQuality; + overrideDefaultQuality = user_options.overrideDefaultQuality; + + allImagesDivideFactor = user_options.allImagesDivideFactor; + overrideLightmapDivideFactor = user_options.overrideLightmapDivideFactor; + overrideDefaultDivideFactor = user_options.overrideDefaultDivideFactor; + overrideCubemapDivideFactor = user_options.overrideCubemapDivideFactor; + overrideMetallicSmoothnessDivideFactor = user_options.overrideMetallicSmoothnessDivideFactor; + overrideNormalDivideFactor = user_options.overrideNormalDivideFactor; + + overrideDefaultExportTextureType = user_options.overrideDefaultExportTextureType; + overrideLightmapExportTextureType = user_options.overrideLightmapExportTextureType; + overrideMetallicSmoothnessExportTextureType = user_options.overrideMetallicSmoothnessExportTextureType; + overrideNormalExportTextureType = user_options.overrideNormalExportTextureType; + overrideCubemapTextureType = user_options.overrideCubemapTextureType; + + //LIGHTMAP + maxLightmapClamp = user_options.maxLightmapClamp; + saturationLightmap = user_options.saturationLightmap; + lightmapIntensityMultiplier = user_options.lightmapIntensityMultiplier; + lightmapContrastCheat = user_options.lightmapContrastCheat; + whiteImageForNonStaticLightmaps = user_options.whiteImageForNonStaticLightmaps; + + //QUANTIZATION + quantizeGLTF = user_options.quantizeGLTF; + quantizeMainUVsTo = user_options.quantizeMainUVsTo; + quantizeLightUVsTo = user_options.quantizeLightUVsTo; + quantizeVerticesTo = user_options.quantizeVerticesTo; + quantizeNormalsTo = user_options.quantizeNormalsTo; + + // OTHER OPTIONS + exportGameObjectName = user_options.exportGameObjectName; + exportMaterialName = user_options.exportMaterialName; + exportTexturesName = user_options.exportTexturesName; + exportCameras = user_options.exportCameras; + exportInactive = user_options.exportInactive; + exportGameObjectsTag = user_options.exportGameObjectsTag; + exportGameObjectsLayer = user_options.exportGameObjectsLayer; + exportBatching = user_options.exportBatching; + exportNavMesh = user_options.exportNavMesh; + blockLeafNodesCreation = user_options.blockLeafNodesCreation; + exportSubmeshesInExtra = user_options.exportSubmeshesInExtra; + reduceGLTFChars = user_options.reduceGLTFChars; + exportNormals = user_options.exportNormals; + exportLightmapUVs = user_options.exportLightmapUVs; + convertToGLB = user_options.convertToGLB; + createUVOffsetExtras = user_options.createUVOffsetExtras; + + //SCENE EXTRAS + exportSceneSkyboxEnvironment = user_options.exportSceneSkyboxEnvironment; + exportSceneSkyboxBackground = user_options.exportSceneSkyboxBackground; + createCubeForSkybox = user_options.createCubeForSkybox; + exportSceneSkyboxBackgroundEvenDefault = user_options.exportSceneSkyboxBackgroundEvenDefault; + exportSceneFog = user_options.exportSceneFog; + } + public void SetPrefsValues() + { + //TEXTURE QUALITY + PlayerPrefs.SetFloat("gltf_o_colorTextureSaturation", colorTextureSaturation); + PlayerPrefs.SetInt("gltf_o_exportSeparatedAlphaMap", GetIntFromBool(exportSeparatedAlphaMap)); + PlayerPrefs.SetInt("gltf_o_exportTextureType", (int)exportTextureType); + PlayerPrefs.SetInt("gltf_o_fallbackGLTFTexture", GetIntFromBool(fallbackGLTFTexture)); + PlayerPrefs.SetInt("gltf_o_allImagesQuality", allImagesQuality); + PlayerPrefs.SetInt("gltf_o_overrideLightmapQuality", overrideLightmapQuality); + PlayerPrefs.SetInt("gltf_o_overrideNormalQuality",overrideNormalQuality); + PlayerPrefs.SetInt("gltf_o_overrideMetallicSmoothnessQuality", overrideMetallicSmoothnessQuality); + PlayerPrefs.SetInt("gltf_o_overrideCubemapQuality", overrideCubemapQuality); + PlayerPrefs.SetInt("gltf_o_overrideDefaultQuality", overrideDefaultQuality); + + PlayerPrefs.SetInt("gltf_o_overrideDefaultExportTextureType", (int)overrideDefaultExportTextureType); + PlayerPrefs.SetInt("gltf_o_overrideLightmapExportTextureType", (int)overrideLightmapExportTextureType); + PlayerPrefs.SetInt("gltf_o_overrideMetallicSmoothnessExportTextureType", (int)overrideMetallicSmoothnessExportTextureType); + PlayerPrefs.SetInt("gltf_o_overrideNormalExportTextureType", (int)overrideNormalExportTextureType); + PlayerPrefs.SetInt("gltf_o_overrideCubemapTextureType", (int)overrideCubemapTextureType); + + //LIGHTMAP + PlayerPrefs.SetFloat("gltf_o_quantizeMainUVsTo", maxLightmapClamp); + PlayerPrefs.SetFloat("gltf_o_saturationLightmap", saturationLightmap); + PlayerPrefs.SetFloat("gltf_o_lightmapIntensityMultiplier", lightmapIntensityMultiplier); + PlayerPrefs.SetFloat("gltf_o_lightmapContrastCheat", lightmapContrastCheat); + PlayerPrefs.SetInt("gltf_o_whiteImageForNonStaticLightmaps", GetIntFromBool(whiteImageForNonStaticLightmaps)); + + //QUANTIZATION + PlayerPrefs.SetInt("gltf_o_quantizeGLTF", GetIntFromBool(quantizeGLTF)); + PlayerPrefs.SetInt("gltf_o_quantizeMainUVsTo", (int)quantizeMainUVsTo); + PlayerPrefs.SetInt("gltf_o_quantizeLightUVsTo", (int)quantizeLightUVsTo); + PlayerPrefs.SetInt("gltf_o_quantizeVerticesTo", (int)quantizeVerticesTo); + PlayerPrefs.SetInt("gltf_o_quantizeNormalsTo", (int)quantizeNormalsTo); + + // OTHER OPTIONS + PlayerPrefs.SetInt("gltf_o_exportGameObjectName", GetIntFromBool(exportGameObjectName)); + PlayerPrefs.SetInt("gltf_o_exportMaterialName", GetIntFromBool(exportMaterialName)); + PlayerPrefs.SetInt("gltf_o_exportTexturesName", GetIntFromBool(exportTexturesName)); + PlayerPrefs.SetInt("gltf_o_exportCameras", GetIntFromBool(exportCameras)); + PlayerPrefs.SetInt("gltf_o_exportInactive", GetIntFromBool(exportInactive)); + PlayerPrefs.SetInt("gltf_o_exportGameObjectsTag", GetIntFromBool(exportGameObjectsTag)); + PlayerPrefs.SetInt("gltf_o_exportGameObjectsLayer", GetIntFromBool(exportGameObjectsLayer)); + PlayerPrefs.SetInt("gltf_o_exportBatching", GetIntFromBool(exportBatching)); + PlayerPrefs.SetInt("gltf_o_exportNavMesh", GetIntFromBool(exportNavMesh)); + PlayerPrefs.SetInt("gltf_o_exportSubmeshesInExtra", GetIntFromBool(exportSubmeshesInExtra)); + //export name here too + PlayerPrefs.SetInt("gltf_o_reduceGLTFChars", GetIntFromBool(reduceGLTFChars)); + PlayerPrefs.SetInt("gltf_o_exportNormals", GetIntFromBool(exportNormals)); + PlayerPrefs.SetInt("gltf_o_exportLightmapUVs", GetIntFromBool(exportLightmapUVs)); + PlayerPrefs.SetInt("gltf_o_convertToGLB", GetIntFromBool(convertToGLB)); + PlayerPrefs.SetInt("gltf_o_createUVOffsetExtras", GetIntFromBool(createUVOffsetExtras)); + + // ANIMATIONS - PENDING + + // SCENE EXTRAS + PlayerPrefs.SetInt("gltf_o_exportSceneSkyboxEnvironment", GetIntFromBool(exportSceneSkyboxEnvironment)); + PlayerPrefs.SetInt("gltf_o_exportSceneSkyboxBackground", GetIntFromBool(exportSceneSkyboxBackground)); + PlayerPrefs.SetInt("gltf_o_createCubeForSkybox", GetIntFromBool(createCubeForSkybox)); + PlayerPrefs.SetInt("gltf_o_exportSceneSkyboxBackgroundEvenDefault", GetIntFromBool(exportSceneSkyboxBackgroundEvenDefault)); + PlayerPrefs.SetInt("gltf_o_exportSceneFog", GetIntFromBool(exportSceneFog)); + + + + } + public static ComponentType GetComponentType(ComponentTypeSelected compType, bool signed = false) + { + switch (compType) + { + case ComponentTypeSelected.BYTE: + if (signed) + return ComponentType.BYTE; + else + return ComponentType.UNSIGNED_BYTE; + case ComponentTypeSelected.SHORT: + if (signed) + return ComponentType.SHORT; + else + return ComponentType.UNSIGNED_SHORT; + default: + return ComponentType.FLOAT; + } + } + + private bool GetBoolFromInt(int val) + { + if (val == 0) + return false; + else + return true; + } + private int GetIntFromBool(bool val) + { + if (val) + return 1; + else + return 0; + } + + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/Utilities/ExportGLTFOptions.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/Utilities/ExportGLTFOptions.cs.meta new file mode 100644 index 0000000..9153308 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/Utilities/ExportGLTFOptions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 87dcd3ddf6666e248b97c4b0f206dc0a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/GLTFGenerator/Utilities/Min_Max.cs b/Scripts/GLTFExporter/GLTFGenerator/Utilities/Min_Max.cs new file mode 100644 index 0000000..3e39d12 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/Utilities/Min_Max.cs @@ -0,0 +1,242 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class Min_Max + { + public float[] min; + public float[] max; + public float[] scale; + public float[] offset; + //public bool reqSign = false; // USED FOR QUANTIZATION + + public Min_Max(float _min, float _max, int values_qty) + { + min = new float[values_qty]; + max = new float[values_qty]; + for (int i =0; i < values_qty; i++) + { + min[i] = _min; + max[i] = _max; + } + } + + public Min_Max(float[] f) + { + min = new float[1]; + max = new float[1]; + + min[0] = f[0]; + max[0] = f[0]; + + foreach (int val in f) + { + if (val > max[0]) max[0] = val; + if (val < min[0]) min[0] = val; + } + //if (min[0] < 0 && max[0] > 0) + // reqSign = true; + } + public Min_Max(Vector2[] v2) + { + min = new float[2]; + max = new float[2]; + + min[0] = v2[0].x; + min[1] = v2[0].y; + + max[0] = v2[0].x; + max[1] = v2[0].y; + for (int i =0; i < v2.Length; i++) + { + if (v2[i].x > max[0]) max[0] = v2[i].x; + if (v2[i].y > max[1]) max[1] = v2[i].y; + + if (v2[i].x < min[0]) min[0] = v2[i].x; + if (v2[i].y < min[1]) min[1] = v2[i].y; + } + //if (min[0] < 0 && max[0] > 0) + // reqSign = true; + //if (min[1] < 0 && max[1] > 0) + // reqSign = true; + } + public Min_Max(Vector3[] v3, Vector3 modifier) + { + min = new float[3]; + max = new float[3]; + + min[0] = v3[0].x * modifier.x; + min[1] = v3[0].y * modifier.y; + min[2] = v3[0].z * modifier.z; + + max[0] = v3[0].x * modifier.x; + max[1] = v3[0].y * modifier.y; + max[2] = v3[0].z * modifier.z; + for (int i = 0; i < v3.Length; i++) + { + Vector3 nv3 = new Vector3(v3[i].x * modifier.x, v3[i].y * modifier.y, v3[i].z * modifier.z); + if (nv3.x > max[0]) max[0] = nv3.x; + if (nv3.y > max[1]) max[1] = nv3.y; + if (nv3.z > max[2]) max[2] = nv3.z; + + if (nv3.x < min[0]) min[0] = nv3.x; + if (nv3.y < min[1]) min[1] = nv3.y; + if (nv3.z < min[2]) min[2] = nv3.z; + } + + //if (min[0] < 0 && max[0] > 0) + // reqSign = true; + //if (min[1] < 0 && max[1] > 0) + // reqSign = true; + //if (min[2] < 0 && max[2] > 0) + // reqSign = true; + } + + public Min_Max(Vector4[] v4, Vector4 modifier) + { + min = new float[4]; + max = new float[4]; + + min[0] = v4[0].x * modifier.x; + min[1] = v4[0].y * modifier.y; + min[2] = v4[0].z * modifier.z; + min[3] = v4[0].w * modifier.w; + + max[0] = v4[0].x * modifier.x; + max[1] = v4[0].y * modifier.y; + max[2] = v4[0].z * modifier.z; + max[3] = v4[0].w * modifier.w; + for (int i = 0; i < v4.Length; i++) + { + Vector4 nv4 = new Vector4(v4[i].x * modifier.x, v4[i].y * modifier.y, v4[i].z * modifier.z, v4[i].w * modifier.w); + if (nv4.x > max[0]) max[0] = nv4.x; + if (nv4.y > max[1]) max[1] = nv4.y; + if (nv4.z > max[2]) max[2] = nv4.z; + if (nv4.w > max[3]) max[3] = nv4.w; + + if (nv4.x < min[0]) min[0] = nv4.x; + if (nv4.y < min[1]) min[1] = nv4.y; + if (nv4.z < min[2]) min[2] = nv4.z; + if (nv4.w < min[3]) min[3] = nv4.w; + } + } + public Min_Max(int[] i) + { + min = new float[1]; + max = new float[1]; + + min[0] = i[0]; + max[0] = i[0]; + + foreach (int val in i) + { + if (val > max[0]) max[0] = val; + if (val < min[0]) min[0] = val; + } + //if (min[0] < 0 && max[0] > 0) + // reqSign = true; + } + + public string GetValues(bool get_min, bool as_int = false) + { + if (get_min) + return GetValueFromArray(min, as_int); + else + return GetValueFromArray(max, as_int); + + } + + public string GetValueFromArray(float [] array, bool as_int) + { + string result = ""; + foreach (float f in array) + { + if (as_int) + { + result += Mathf.RoundToInt(f).ToString("D"); + } + else + { + result += f.ToString(); + } + result += ","; + } + return StringUtilities.RemoveCharacterFromString(result, 1, false); + } + public float[] GetQuantizationScale() + { + if (scale != null) + return scale; + + float[] result = new float[min.Length]; + + for (int i =0; i < result.Length; i++) + if (max[i] != min[i]) + result[i] = max[i] - min[i]; + else + result[i] = 1; + + scale = result; + return result; + } + public float[] GetQuantizationOffset() + { + if (offset != null) + return offset; + + float[] result = new float[min.Length]; + + for (int i = 0; i < result.Length; i++) + result[i] = min[i]; + + offset = result; + return result; + } + public static float Normalize(float _val, float _min, float _max, bool neg_one_to_pos_one = false) + { + if (_min == _max) + return 0; + if (_min > _max) + { + Debug.LogWarning("MIN VALUE IS HIGER THAN MAX VALUE, RETURNING -1"); + return -1; + } + else + { + if (!neg_one_to_pos_one) // VALUE WILL GO FROM 0 TO + { + return (_val - _min) / (_max - _min); + } + else + { + float _modif = (_min + _max) / 2; + return (_val - _modif) / (_max - _modif); + } + } + } + + public float GetMaxValueFromVectors() + { + float maxVal = 0; + foreach (float f in max) + { + if (f > maxVal) + maxVal = f; + } + return maxVal; + } + + public float GetMinValueFromVectors() + { + float minVal = 0; + foreach (float f in min) + { + if (f < minVal) + minVal = f; + } + return minVal; + } + } +} diff --git a/Scripts/GLTFExporter/GLTFGenerator/Utilities/Min_Max.cs.meta b/Scripts/GLTFExporter/GLTFGenerator/Utilities/Min_Max.cs.meta new file mode 100644 index 0000000..85f5ae7 --- /dev/null +++ b/Scripts/GLTFExporter/GLTFGenerator/Utilities/Min_Max.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 49da870cdf3188a4f953a03fe624e382 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/Mono_Exporters.meta b/Scripts/GLTFExporter/Mono_Exporters.meta new file mode 100644 index 0000000..0720b3a --- /dev/null +++ b/Scripts/GLTFExporter/Mono_Exporters.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 228954348ee9b5547ac9c9eda1629742 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/Mono_Exporters/Mono_ExportToGLTF.cs b/Scripts/GLTFExporter/Mono_Exporters/Mono_ExportToGLTF.cs new file mode 100644 index 0000000..b73fbfd --- /dev/null +++ b/Scripts/GLTFExporter/Mono_Exporters/Mono_ExportToGLTF.cs @@ -0,0 +1,132 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using WEBGL_EXPORTER.GLTF; +public class Mono_ExportToGLTF : MonoBehaviour +{ + public SO_ExportGLTFOptions gltfCustomOptions; + public string gltfName = "gltf"; + + //public bool exportForNFT = false; + + public string modelId; + public string exportLocation; + public int curBuild = 0; + + public Transform targetParent; + public Transform startPosition; + + public ReflectionProbe optionalEnvironmentReflections; + public virtual void ExportGLTF(string location, bool test_build = false) { + if (targetParent == null) + targetParent = transform; + + string finalModelID = test_build ? modelId + "_" + curBuild.ToString() : modelId; + + SetupExtrasComputedData(); + + ExportGLTFOptions export_options; + if (gltfCustomOptions != null) + { + export_options = new ExportGLTFOptions(gltfCustomOptions); + } + else + { + export_options = new ExportGLTFOptions(); + } + + if (optionalEnvironmentReflections != null) + export_options.computedEnvironmentCubemap = optionalEnvironmentReflections.bakedTexture as Cubemap; + ExportToGLTF.CallExportGLTF(location, gltfName, targetParent, export_options, true, finalModelID, true); + + if (test_build) curBuild++; + + ClearExtrasComputedData(); + + } + private void SetupExtrasComputedData() + { + ObjectMasterComputedExtrasMono _masterExtras = targetParent.gameObject.AddComponent(); + if (startPosition != null) + _masterExtras.AddProperty(new ObjectProperty("startPosition",startPosition.gameObject)); + } + private void ClearExtrasComputedData() + { + ObjectMasterComputedExtrasMono [] computedMaster = targetParent.GetComponentsInChildren(); + for (int i =0; i < computedMaster.Length; i++) + DestroyImmediate(computedMaster[i]); + + ObjectNodeComputedExtrasMono[] computedNodes = targetParent.GetComponentsInChildren (); + for (int i = 0; i < computedNodes.Length; i++) + DestroyImmediate(computedNodes[i]); + } + //private ExportGLTFOptions getNFTGLTFOptions() + //{ + // ExportGLTFOptions options = new ExportGLTFOptions(); + // options.exportLocation = exportLocation; + + // // NODES - OPTIONS + // options.exportGameObjectName = true; + // options.exportMaterialName = true; + // options.exportTexturesName = false; + // options.exportCameras = false; + // options.exportInactive = true; + // options.exportGameObjectsTag = true; + // options.exportGameObjectsLayer = true; + // options.exportBatching = true; + // options.exportNavMesh = true; + + // //MESH OPTIONS + // options.reduceGLTFChars = false; + // options.exportNormals = true; + // options.exportLightmapUVs = true; + // options.convertToGLB = true; // pendig + // options.createUVOffsetExtras = false; //pending + // options.exportSubmeshesInExtra = true; + + // //TEXTURES QUALITY + // options.colorTextureSaturation = 0.75f; + // options.exportSeparatedAlphaMap = true; + // options.exportTextureType = TextureExportType.WEBP; + // options.fallbackGLTFTexture = false; + // options.allImagesQuality = 75; + // options.overrideLightmapQuality = 90; + // options.overrideNormalQuality = 0; + // options.overrideMetallicSmoothnessQuality = 0; + // options.overrideDefaultQuality = 0; + // options.overrideCubemapQuality = 0; + // options.overrideEnvironmentQuality = 0; + + // options.overrideLightmapExportTextureType = TextureExportType.DEFAULT; + // options.overrideMetallicSmoothnessExportTextureType = TextureExportType.WEBP; + // options.overrideNormalExportTextureType = TextureExportType.WEBP; + // options.overrideDefaultExportTextureType = TextureExportType.WEBP; + // options.overrideCubemapTextureType = TextureExportType.WEBP; + + // //LIGHTMAP OPTIONS + // options.maxLightmapClamp = 5f; + // options.saturationLightmap = 1f; + // options.lightmapIntensityMultiplier = 1f; + // options.lightmapContrastCheat = 1f; + // options.whiteImageForNonStaticLightmaps = true; + + // //QUANTIZATION + // options.quantizeGLTF = true; + // options.quantizeMainUVsTo = ComponentTypeSelected.SHORT; + // options.quantizeLightUVsTo = ComponentTypeSelected.SHORT; + // options.quantizeVerticesTo = ComponentTypeSelected.FLOAT; + // options.quantizeNormalsTo = ComponentTypeSelected.BYTE; + + // // SCENE + // options.exportSceneSkyboxBackground = true; + // options.exportSceneSkyboxEnvironment = true; + // options.createCubeForSkybox = true; + // options.exportSceneSkyboxBackgroundEvenDefault = false; + // options.exportSceneFog = true; + + + + // options.extraExportMainCameraInGLTF = true; + // return options; + //} +} diff --git a/Scripts/GLTFExporter/Mono_Exporters/Mono_ExportToGLTF.cs.meta b/Scripts/GLTFExporter/Mono_Exporters/Mono_ExportToGLTF.cs.meta new file mode 100644 index 0000000..6fb949f --- /dev/null +++ b/Scripts/GLTFExporter/Mono_Exporters/Mono_ExportToGLTF.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4adafa3a9cc37174b81a247d97c9162b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References.meta b/Scripts/GLTFExporter/References.meta new file mode 100644 index 0000000..a1a931a --- /dev/null +++ b/Scripts/GLTFExporter/References.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 33396544f7976e2498a690a5c01706c4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/1_Buffers.PNG b/Scripts/GLTFExporter/References/1_Buffers.PNG new file mode 100644 index 0000000..c27f0fa Binary files /dev/null and b/Scripts/GLTFExporter/References/1_Buffers.PNG differ diff --git a/Scripts/GLTFExporter/References/1_Buffers.PNG.meta b/Scripts/GLTFExporter/References/1_Buffers.PNG.meta new file mode 100644 index 0000000..e1a848e --- /dev/null +++ b/Scripts/GLTFExporter/References/1_Buffers.PNG.meta @@ -0,0 +1,91 @@ +fileFormatVersion: 2 +guid: 90788155b0c2b854bbe916a9093fec63 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/2_0_Accesors.PNG b/Scripts/GLTFExporter/References/2_0_Accesors.PNG new file mode 100644 index 0000000..73f0a40 Binary files /dev/null and b/Scripts/GLTFExporter/References/2_0_Accesors.PNG differ diff --git a/Scripts/GLTFExporter/References/2_0_Accesors.PNG.meta b/Scripts/GLTFExporter/References/2_0_Accesors.PNG.meta new file mode 100644 index 0000000..048deb2 --- /dev/null +++ b/Scripts/GLTFExporter/References/2_0_Accesors.PNG.meta @@ -0,0 +1,91 @@ +fileFormatVersion: 2 +guid: 03372715107fe3d45bb5657647ac786a +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/2_1_Component_Types.PNG b/Scripts/GLTFExporter/References/2_1_Component_Types.PNG new file mode 100644 index 0000000..9a473c0 Binary files /dev/null and b/Scripts/GLTFExporter/References/2_1_Component_Types.PNG differ diff --git a/Scripts/GLTFExporter/References/2_1_Component_Types.PNG.meta b/Scripts/GLTFExporter/References/2_1_Component_Types.PNG.meta new file mode 100644 index 0000000..32d0d5a --- /dev/null +++ b/Scripts/GLTFExporter/References/2_1_Component_Types.PNG.meta @@ -0,0 +1,91 @@ +fileFormatVersion: 2 +guid: 1cc2a72a55afea4489baa7c7039a2af4 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/2_2_Types.PNG b/Scripts/GLTFExporter/References/2_2_Types.PNG new file mode 100644 index 0000000..7e8c747 Binary files /dev/null and b/Scripts/GLTFExporter/References/2_2_Types.PNG differ diff --git a/Scripts/GLTFExporter/References/2_2_Types.PNG.meta b/Scripts/GLTFExporter/References/2_2_Types.PNG.meta new file mode 100644 index 0000000..4bcbf99 --- /dev/null +++ b/Scripts/GLTFExporter/References/2_2_Types.PNG.meta @@ -0,0 +1,91 @@ +fileFormatVersion: 2 +guid: e577f72cf02cb604a8ddbfc373f096e5 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/2_3_AccesorsExample.PNG b/Scripts/GLTFExporter/References/2_3_AccesorsExample.PNG new file mode 100644 index 0000000..e4a207a Binary files /dev/null and b/Scripts/GLTFExporter/References/2_3_AccesorsExample.PNG differ diff --git a/Scripts/GLTFExporter/References/2_3_AccesorsExample.PNG.meta b/Scripts/GLTFExporter/References/2_3_AccesorsExample.PNG.meta new file mode 100644 index 0000000..017be7e --- /dev/null +++ b/Scripts/GLTFExporter/References/2_3_AccesorsExample.PNG.meta @@ -0,0 +1,91 @@ +fileFormatVersion: 2 +guid: 9032712888828144384e2495069f9fc6 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/2_4_AccessorExample2.PNG b/Scripts/GLTFExporter/References/2_4_AccessorExample2.PNG new file mode 100644 index 0000000..af47b04 Binary files /dev/null and b/Scripts/GLTFExporter/References/2_4_AccessorExample2.PNG differ diff --git a/Scripts/GLTFExporter/References/2_4_AccessorExample2.PNG.meta b/Scripts/GLTFExporter/References/2_4_AccessorExample2.PNG.meta new file mode 100644 index 0000000..001f0dc --- /dev/null +++ b/Scripts/GLTFExporter/References/2_4_AccessorExample2.PNG.meta @@ -0,0 +1,91 @@ +fileFormatVersion: 2 +guid: 4ec7a2dd2f3294f41b59d84921edbc82 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/2_5_SparseAccesors (modify certain vertices).PNG b/Scripts/GLTFExporter/References/2_5_SparseAccesors (modify certain vertices).PNG new file mode 100644 index 0000000..251ba4a Binary files /dev/null and b/Scripts/GLTFExporter/References/2_5_SparseAccesors (modify certain vertices).PNG differ diff --git a/Scripts/GLTFExporter/References/2_5_SparseAccesors (modify certain vertices).PNG.meta b/Scripts/GLTFExporter/References/2_5_SparseAccesors (modify certain vertices).PNG.meta new file mode 100644 index 0000000..95ad64e --- /dev/null +++ b/Scripts/GLTFExporter/References/2_5_SparseAccesors (modify certain vertices).PNG.meta @@ -0,0 +1,91 @@ +fileFormatVersion: 2 +guid: 0dd25f5fc146a1f4f9cc78a0f72f77ce +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/GLTF_Documentacion.txt b/Scripts/GLTFExporter/References/GLTF_Documentacion.txt new file mode 100644 index 0000000..711d095 --- /dev/null +++ b/Scripts/GLTFExporter/References/GLTF_Documentacion.txt @@ -0,0 +1,2 @@ +https://github.com/KhronosGroup/glTF/tree/master/specification/2.0 +https://github.com/KhronosGroup/glTF-Sample-Models \ No newline at end of file diff --git a/Scripts/GLTFExporter/References/GLTF_Documentacion.txt.meta b/Scripts/GLTFExporter/References/GLTF_Documentacion.txt.meta new file mode 100644 index 0000000..e7cee97 --- /dev/null +++ b/Scripts/GLTFExporter/References/GLTF_Documentacion.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6935553439e8bc0448c99f219f23a88b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/Scenes.PNG b/Scripts/GLTFExporter/References/Scenes.PNG new file mode 100644 index 0000000..48ed1d6 Binary files /dev/null and b/Scripts/GLTFExporter/References/Scenes.PNG differ diff --git a/Scripts/GLTFExporter/References/Scenes.PNG.meta b/Scripts/GLTFExporter/References/Scenes.PNG.meta new file mode 100644 index 0000000..20ee935 --- /dev/null +++ b/Scripts/GLTFExporter/References/Scenes.PNG.meta @@ -0,0 +1,94 @@ +fileFormatVersion: 2 +guid: 972b9ecf1eeeffd428d8edf4c1bbf735 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/accessorTypes.PNG b/Scripts/GLTFExporter/References/accessorTypes.PNG new file mode 100644 index 0000000..0b48d6a Binary files /dev/null and b/Scripts/GLTFExporter/References/accessorTypes.PNG differ diff --git a/Scripts/GLTFExporter/References/accessorTypes.PNG.meta b/Scripts/GLTFExporter/References/accessorTypes.PNG.meta new file mode 100644 index 0000000..394c4ef --- /dev/null +++ b/Scripts/GLTFExporter/References/accessorTypes.PNG.meta @@ -0,0 +1,94 @@ +fileFormatVersion: 2 +guid: 8c584eadaaa805f4881c91dacea73dfd +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/nodeAttributes.PNG b/Scripts/GLTFExporter/References/nodeAttributes.PNG new file mode 100644 index 0000000..f538a92 Binary files /dev/null and b/Scripts/GLTFExporter/References/nodeAttributes.PNG differ diff --git a/Scripts/GLTFExporter/References/nodeAttributes.PNG.meta b/Scripts/GLTFExporter/References/nodeAttributes.PNG.meta new file mode 100644 index 0000000..6436f4f --- /dev/null +++ b/Scripts/GLTFExporter/References/nodeAttributes.PNG.meta @@ -0,0 +1,94 @@ +fileFormatVersion: 2 +guid: 20f9cb2fc155b5549a3c99962e52e280 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/nodesHierarchy.PNG b/Scripts/GLTFExporter/References/nodesHierarchy.PNG new file mode 100644 index 0000000..70327c0 Binary files /dev/null and b/Scripts/GLTFExporter/References/nodesHierarchy.PNG differ diff --git a/Scripts/GLTFExporter/References/nodesHierarchy.PNG.meta b/Scripts/GLTFExporter/References/nodesHierarchy.PNG.meta new file mode 100644 index 0000000..ef76a08 --- /dev/null +++ b/Scripts/GLTFExporter/References/nodesHierarchy.PNG.meta @@ -0,0 +1,94 @@ +fileFormatVersion: 2 +guid: b567a1a5f4ce0414da1bd77465e4c16f +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/primitiveMode.PNG b/Scripts/GLTFExporter/References/primitiveMode.PNG new file mode 100644 index 0000000..30bcb12 Binary files /dev/null and b/Scripts/GLTFExporter/References/primitiveMode.PNG differ diff --git a/Scripts/GLTFExporter/References/primitiveMode.PNG.meta b/Scripts/GLTFExporter/References/primitiveMode.PNG.meta new file mode 100644 index 0000000..df3f350 --- /dev/null +++ b/Scripts/GLTFExporter/References/primitiveMode.PNG.meta @@ -0,0 +1,94 @@ +fileFormatVersion: 2 +guid: f1a7ed217152f0a42bf2e45928027b70 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/primitives.txt b/Scripts/GLTFExporter/References/primitives.txt new file mode 100644 index 0000000..30cd19e --- /dev/null +++ b/Scripts/GLTFExporter/References/primitives.txt @@ -0,0 +1 @@ +https://github.com/KhronosGroup/glTF/tree/master/specification/2.0/#primitivemode \ No newline at end of file diff --git a/Scripts/GLTFExporter/References/primitives.txt.meta b/Scripts/GLTFExporter/References/primitives.txt.meta new file mode 100644 index 0000000..5b06c30 --- /dev/null +++ b/Scripts/GLTFExporter/References/primitives.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5f9b9ed379f525849bee44c0f7619b67 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/GLTFExporter/References/save_multiMaterial.PNG b/Scripts/GLTFExporter/References/save_multiMaterial.PNG new file mode 100644 index 0000000..b16f733 Binary files /dev/null and b/Scripts/GLTFExporter/References/save_multiMaterial.PNG differ diff --git a/Scripts/GLTFExporter/References/save_multiMaterial.PNG.meta b/Scripts/GLTFExporter/References/save_multiMaterial.PNG.meta new file mode 100644 index 0000000..8e1f00b --- /dev/null +++ b/Scripts/GLTFExporter/References/save_multiMaterial.PNG.meta @@ -0,0 +1,94 @@ +fileFormatVersion: 2 +guid: 93ed5889ef6cff74489e1a557606ca71 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/MonoEnhanceWeb.meta b/Scripts/MonoEnhanceWeb.meta new file mode 100644 index 0000000..bcf3b37 --- /dev/null +++ b/Scripts/MonoEnhanceWeb.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30ef07ab27140b846a134bdfa0b68286 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/MonoEnhanceWeb/WebAnimatorSpeed.cs b/Scripts/MonoEnhanceWeb/WebAnimatorSpeed.cs new file mode 100644 index 0000000..e064415 --- /dev/null +++ b/Scripts/MonoEnhanceWeb/WebAnimatorSpeed.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + public class WebAnimatorSpeed : MonoBehaviour + { + public float animationSpeed = 1.0f; + } +} diff --git a/Scripts/MonoEnhanceWeb/WebAnimatorSpeed.cs.meta b/Scripts/MonoEnhanceWeb/WebAnimatorSpeed.cs.meta new file mode 100644 index 0000000..3dd3d2a --- /dev/null +++ b/Scripts/MonoEnhanceWeb/WebAnimatorSpeed.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cf4faae16fb0a9043ba0ee530a34996f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/MonoEnhanceWeb/WebColliderEnhance.cs b/Scripts/MonoEnhanceWeb/WebColliderEnhance.cs new file mode 100644 index 0000000..bf72cdf --- /dev/null +++ b/Scripts/MonoEnhanceWeb/WebColliderEnhance.cs @@ -0,0 +1,75 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace WEBGL_EXPORTER.GLTF +{ + [ExecuteAlways] + public class WebColliderEnhance : MonoBehaviour + { + public bool setMassFromRigidBody = true; + public float density = 1; + public float gravityMultiplier = 1.0f; + //public float restitution = 0; + //public float friction = 0; + + Collider _collider; + private void OnEnable() + { + _collider = transform.GetComponent(); + } + public float GetMass() + { + if (_collider != null) + { + Vector3 _bounds = new Vector3(_collider.bounds.extents.x * 2, _collider.bounds.extents.y * 2, _collider.bounds.extents.z * 2); + float volume = _bounds.x * _bounds.y * _bounds.z; + + return volume * density; + } + else + { + return 1; + } + } + } + + + +#if UNITY_EDITOR + [CustomEditor(typeof(WebColliderEnhance))] + public class WebRigidbodyEnhanceEditor : Editor + { + private WebColliderEnhance myScript; + private MonoScript script; + + private void OnEnable() + { + myScript = target as WebColliderEnhance; + script = MonoScript.FromMonoBehaviour((WebColliderEnhance)target); + } + + public override void OnInspectorGUI() + { + EditorGUILayout.ObjectField("Script: ", script, typeof(MonoScript), false); + //base.OnInspectorGUI(); + myScript.setMassFromRigidBody = EditorGUILayout.Toggle("Set Mass From RigidBody: ", myScript.setMassFromRigidBody); + if (!myScript.setMassFromRigidBody) + { + myScript.density = EditorGUILayout.FloatField("Density: ", myScript.density); + EditorGUILayout.LabelField("Calculated Mass: " + myScript.GetMass() + " kgs"); + } + myScript.gravityMultiplier = EditorGUILayout.FloatField("Gravity Multiplier: ", myScript.gravityMultiplier); + //myScript.friction = EditorGUILayout.FloatField("Friction: ", myScript.friction); + //if (myScript.friction < 0) + // myScript.friction = 0; + //myScript.restitution = EditorGUILayout.Slider("Restitution: ", myScript.restitution,0f,1f); + + + } + } +#endif +} diff --git a/Scripts/MonoEnhanceWeb/WebColliderEnhance.cs.meta b/Scripts/MonoEnhanceWeb/WebColliderEnhance.cs.meta new file mode 100644 index 0000000..3c1742e --- /dev/null +++ b/Scripts/MonoEnhanceWeb/WebColliderEnhance.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fce1bad88c6dd5d4aa05012a8a47ca80 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/MonoEnhanceWeb/WebPositionalAudioSource.cs b/Scripts/MonoEnhanceWeb/WebPositionalAudioSource.cs new file mode 100644 index 0000000..983576c --- /dev/null +++ b/Scripts/MonoEnhanceWeb/WebPositionalAudioSource.cs @@ -0,0 +1,51 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER.GLTF +{ + //[RequireComponent(typeof(AudioSource))] + //[ExecuteAlways] + public class WebPositionalAudioSource : MonoBehaviour + { + public enum Distance { linear = 0,inverse = 1, exponential = 2 } + + public string emitterName; + public AudioClip clip; + + public float gain = 1.0f; //volume + public bool loop = true; + public bool playing = true; + + public float speed = 1.0f; + public float pitch = 1.0f; + + public bool isGlobalAudio = false; + + public float coneInnerAngleDegree = 45f; + public float coneOuterAngleDegree = 45f; + public float coneOuterGain = 0f; + public Distance distance = Distance.inverse; + + //only works when distance model is set to linear + public float maxDistance = 10000f; + public float refDistance = 1f; + //whens set to linear max value is one, otherwise max value can go higher + public float rollOffFactor = 1f; + public float rollOffFactorLinear = 1f; + + + + private void Start() + { + // used to have it enabled or disabled + } +#if UNITY_EDITOR + private void OnDrawGizmos() + { + Gizmos.DrawIcon(transform.position,"unity-to-threejs/WebPositionalAudioSource.png",true); + } +#endif + } + +} diff --git a/Scripts/MonoEnhanceWeb/WebPositionalAudioSource.cs.meta b/Scripts/MonoEnhanceWeb/WebPositionalAudioSource.cs.meta new file mode 100644 index 0000000..53a3501 --- /dev/null +++ b/Scripts/MonoEnhanceWeb/WebPositionalAudioSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 97e2cf55d8b84434194b8b85a69e36d9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/PathPreferences.cs b/Scripts/PathPreferences.cs new file mode 100644 index 0000000..f7ae61f --- /dev/null +++ b/Scripts/PathPreferences.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + public class PathPreferences + { + public const string webpConverterLocalPath = "Assets/Unity-GLTF-Exporter/ExternalUtilities/libwebp-1.2/"; + public const string ktx2ConverterLocalPath = "Assets/Unity-GLTF-Exporter/ExternalUtilities/KTX-Software/bin/"; + + public const string chromeLocation = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; + public const string localServerLocation = "C:/wamp64/www/"; + + public const string cubemapModelFBXRelativePath = "Assets/Unity-GLTF-Exporter/Models/Utilities/cubemap_threejs.prefab"; + + public const string standardTextureGenerationMaterialFolder = "Assets/Unity-GLTF-Exporter/PrefabUtils/MaterialEditor/Standard/"; + public const string URPTextureGenerationMaterialFolder = "Assets/Unity-GLTF-Exporter/PrefabUtils/MaterialEditor/URP/"; + + public const string renderTextureHolderPrefabPath = "Assets/Unity-GLTF-Exporter/PrefabUtils/RenderTextureHolder.prefab"; + + public const string normalMapSimpleMaterialName = "NormalMapSimpleMaterial.mat"; + public const string HDRSimpleMaterialName = "HDRSimpleMaterial.mat"; + public const string basicSimpleMaterialName = "BasicSimpleMaterial.mat"; + public const string basicEditableMaterialName = "BasicEditableMaterial.mat"; + + public const string skyboxToCubemapPrefabPath = "Assets/Unity-GLTF-Exporter/PrefabUtils/Skybox_Converter.prefab"; + public const string sphericalToCubemapPrefabPath = "Assets/Unity-GLTF-Exporter/PrefabUtils/SphericalToCubemap_Converter.prefab"; + } +} diff --git a/Scripts/PathPreferences.cs.meta b/Scripts/PathPreferences.cs.meta new file mode 100644 index 0000000..da9ceea --- /dev/null +++ b/Scripts/PathPreferences.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6a6f4e1d0956e2141980d336dedf887f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers.meta b/Scripts/SceneModifiers.meta new file mode 100644 index 0000000..90c4de7 --- /dev/null +++ b/Scripts/SceneModifiers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0f61c47de42c4d348bbe61ed0b396751 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/AddChildMeshColliders.cs b/Scripts/SceneModifiers/AddChildMeshColliders.cs new file mode 100644 index 0000000..a00b6c1 --- /dev/null +++ b/Scripts/SceneModifiers/AddChildMeshColliders.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[ExecuteAlways] +public class AddChildMeshColliders : MonoBehaviour +{ + public bool addColliders = false; + private void OnEnable() + { + if (addColliders) + { + MeshRenderer[] childs = transform.GetComponentsInChildren(); + foreach(MeshRenderer mr in childs) + { + Collider col = mr.transform.GetComponent(); + if (col == null) + { + mr.gameObject.AddComponent(); + } + } + } + } +} diff --git a/Scripts/SceneModifiers/AddChildMeshColliders.cs.meta b/Scripts/SceneModifiers/AddChildMeshColliders.cs.meta new file mode 100644 index 0000000..e5c2eb3 --- /dev/null +++ b/Scripts/SceneModifiers/AddChildMeshColliders.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6da799e5d82fe504992e48f187d4442a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/AddQuadInAreaLight.cs b/Scripts/SceneModifiers/AddQuadInAreaLight.cs new file mode 100644 index 0000000..9dc577c --- /dev/null +++ b/Scripts/SceneModifiers/AddQuadInAreaLight.cs @@ -0,0 +1,76 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace WEBGL_EXPORTER +{ + public class AddQuadInAreaLight : MonoBehaviour + { + public MeshFilter meshFilter; + public MeshRenderer meshRenderer; + public void UpdateQuad() + { + Light light = GetComponent(); + if (light != null) + { + if (light.type == LightType.Area) + { + if (meshFilter == null || meshRenderer == null) + { + GameObject quadObject = GameObject.CreatePrimitive(PrimitiveType.Quad); + + if (meshFilter == null) + meshFilter = gameObject.AddComponent(); + if (meshRenderer == null) + meshRenderer = gameObject.AddComponent(); + + meshFilter.sharedMesh = quadObject.GetComponent().sharedMesh; + meshRenderer.sharedMaterial = quadObject.GetComponent().sharedMaterial; + } + + + + //quadObject.transform.localPosition = Vector3.zero; + //quadObject.transform.localEulerAngles = new Vector3(180, 0, 0); + + Debug.Log(transform.parent.lossyScale); + + transform.localScale = new Vector3(light.areaSize.x/ transform.parent.lossyScale.x, light.areaSize.y/ transform.parent.lossyScale.y, -1); + + } + else + { + Debug.Log("not area light"); + } + } + } + } + + #if UNITY_EDITOR + [CustomEditor(typeof(AddQuadInAreaLight))] + public class AddQuadInAreaLightEditor : Editor + { + private MonoScript script; + private AddQuadInAreaLight myScript; + private void OnEnable() + { + myScript = (AddQuadInAreaLight)target; + script = MonoScript.FromMonoBehaviour(myScript); + + } + + public override void OnInspectorGUI() + { + string quadUpdate = (myScript.meshFilter == null || myScript.meshRenderer == null) ? "Create Quad" : "Update Quad"; + if (GUILayout.Button(quadUpdate, GUILayout.Height(40f))) + { + myScript.UpdateQuad(); + } + //base.OnInspectorGUI(); + } + } + #endif +} diff --git a/Scripts/SceneModifiers/AddQuadInAreaLight.cs.meta b/Scripts/SceneModifiers/AddQuadInAreaLight.cs.meta new file mode 100644 index 0000000..2a878e7 --- /dev/null +++ b/Scripts/SceneModifiers/AddQuadInAreaLight.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4d51980da25235b47906c4b84362b310 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/BakerMover.cs b/Scripts/SceneModifiers/BakerMover.cs new file mode 100644 index 0000000..b210249 --- /dev/null +++ b/Scripts/SceneModifiers/BakerMover.cs @@ -0,0 +1,75 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + [ExecuteAlways] + public class BakerMover : MonoBehaviour + { + public GameObject targetObject; + public GameObject[] turnoffObjects; + public Vector3 globalPosition; + public Quaternion globalRotation; + public Vector3 globalTestPosition; + public Quaternion globalTestRotation; + [HideInInspector] + public bool firstTime = true; + + // NOTE: CANT PLACE INITIAL VALUE ON ENABLE, WHEN IT DUPLICATES IT RESETS THE POSITION TO ITS CURRENT VALUE + + public void SetForExport(bool set = true) + { + if (set) + { + targetObject.SetActive(true); + MoveToSavedPosition(); + } + else + { + MoveToOutsidePosition(); + } + } + // Update is called once per frame + public void GetObjectPosition() + { + if (targetObject == null) + targetObject = gameObject; + globalPosition = gameObject.transform.position; + globalRotation = gameObject.transform.rotation; + } + public void GetObjectTestPosition() + { + if (targetObject == null) + targetObject = gameObject; + globalTestPosition = gameObject.transform.position; + globalTestRotation = gameObject.transform.rotation; + } + public void MoveToSavedPosition() + { + if (targetObject != null) + { + targetObject.transform.position = globalPosition; + targetObject.transform.rotation = globalRotation; + foreach (GameObject go in turnoffObjects) + { + if (go != null) + go.SetActive(false); + } + } + } + public void MoveToOutsidePosition() + { + if (targetObject != null) + { + targetObject.transform.position = globalTestPosition; + targetObject.transform.rotation = globalTestRotation; + foreach (GameObject go in turnoffObjects) + { + if (go != null) + go.SetActive(true); + } + } + } + } +} diff --git a/Scripts/SceneModifiers/BakerMover.cs.meta b/Scripts/SceneModifiers/BakerMover.cs.meta new file mode 100644 index 0000000..4b224ff --- /dev/null +++ b/Scripts/SceneModifiers/BakerMover.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 948099b5d366705498c5c0ad80e59acb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/ChangeChildMaterials.cs b/Scripts/SceneModifiers/ChangeChildMaterials.cs new file mode 100644 index 0000000..63698bd --- /dev/null +++ b/Scripts/SceneModifiers/ChangeChildMaterials.cs @@ -0,0 +1,117 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; + +namespace WEBGL_EXPORTER +{ + [ExecuteAlways] + public class ChangeChildMaterials : MonoBehaviour + { + public bool test = false; + public Material searchFor; + public Material changeTo; + public string matName = ""; + + public bool withName = false; + + public void ChangeChildMaterialsAction() + { + //string curPath = AssetDatabase.GetAssetPath(changeTo); + //Material newMat = (Material)AssetDatabase.LoadAssetAtPath(curPath, typeof(Material)); + + + + MeshRenderer[] childRenderers = transform.GetComponentsInChildren(); + if (!withName) + { + foreach (MeshRenderer mr in childRenderers) + { + if (mr.sharedMaterial == searchFor) + { + mr.sharedMaterial = changeTo; + } + } + } + else + { + foreach (MeshRenderer mr in childRenderers) + { + if (mr.sharedMaterial.name == matName) + { + Debug.Log("itis"); + mr.sharedMaterial = changeTo; + } + } + } + } + } + + +} + +namespace WEBGL_EXPORTER +{ + + [CustomEditor(typeof(ChangeChildMaterials))] + public class ChangeChildMaterialsEditor : Editor + { + ChangeChildMaterials myScript; + MonoScript script; + + private void OnEnable() + { + myScript = (ChangeChildMaterials)target; + script = MonoScript.FromMonoBehaviour(myScript); + } + + public override void OnInspectorGUI() + { + if (myScript.withName == false) + { + if (GUILayout.Button("change with string", GUILayout.Height(30f))) + { + myScript.withName = true; + } + } + else + { + if (GUILayout.Button("change with material", GUILayout.Height(30f))) + { + myScript.withName = false; + } + } + if (!myScript.withName) + { + myScript.searchFor = (Material)EditorGUILayout.ObjectField("Search For: ", myScript.searchFor, typeof(Material), false); + } + else + { + myScript.matName = EditorGUILayout.TextField("Material Name: ", myScript.matName); + } + myScript.changeTo = (Material)EditorGUILayout.ObjectField("Change To: ",myScript.changeTo, typeof(Material), false); + if (!myScript.withName) + { + if (myScript.searchFor != null && myScript.changeTo != null) + { + if (GUILayout.Button("Change child materials", GUILayout.Height(40f))) + { + myScript.ChangeChildMaterialsAction(); + } + } + } + else + { + if (myScript.matName != "" && myScript.changeTo != null) + { + if (GUILayout.Button("Change child materials", GUILayout.Height(40f))) + { + myScript.ChangeChildMaterialsAction(); + } + } + } + } + } +} +#endif diff --git a/Scripts/SceneModifiers/ChangeChildMaterials.cs.meta b/Scripts/SceneModifiers/ChangeChildMaterials.cs.meta new file mode 100644 index 0000000..1cd7829 --- /dev/null +++ b/Scripts/SceneModifiers/ChangeChildMaterials.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ad8a839f20119b45b9991b8db501876 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/ChangeChildName.cs b/Scripts/SceneModifiers/ChangeChildName.cs new file mode 100644 index 0000000..f900b82 --- /dev/null +++ b/Scripts/SceneModifiers/ChangeChildName.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + public class ChangeChildName : MonoBehaviour + { + public string preWords = ""; + public string postWords = ""; + + public int removeInitChars = 0; + public int removeLastChars = 0; + // Start is called before the first frame update + public void ChangeFirstChildNames() + { + List < GameObject > childObjects = new List(); + childObjects = GameObjectUtilities.GetTopHierarchyChilds(gameObject,childObjects,true); + foreach (GameObject go in childObjects) + { + ChangeObjecName(go); + } + } + public void ChangeAllChildNames() + { + Transform[] gos = gameObject.GetComponentsInChildren(); + foreach(Transform go in gos) + { + ChangeObjecName(go.gameObject); + } + } + void ChangeObjecName(GameObject tarObject) + { + string centerName = tarObject.name; + centerName = StringUtilities.RemoveCharacterFromString(centerName, removeInitChars, true); + centerName = StringUtilities.RemoveCharacterFromString(centerName, removeLastChars, false); + tarObject.name = preWords + centerName + postWords; + } + } +} diff --git a/Scripts/SceneModifiers/ChangeChildName.cs.meta b/Scripts/SceneModifiers/ChangeChildName.cs.meta new file mode 100644 index 0000000..e680c11 --- /dev/null +++ b/Scripts/SceneModifiers/ChangeChildName.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 95562d5a32c8d3f40972a54e766cd4cf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/CreateMeshColliderOnChilds.cs b/Scripts/SceneModifiers/CreateMeshColliderOnChilds.cs new file mode 100644 index 0000000..d9c2e32 --- /dev/null +++ b/Scripts/SceneModifiers/CreateMeshColliderOnChilds.cs @@ -0,0 +1,67 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + public class CreateMeshColliderOnChilds : MonoBehaviour + { + [HideInInspector] + public List createdMeshCollider; + [HideInInspector] + public List lastCollider; + public bool createdsColliders = false; + public bool displayButtons = true; + public void CreateMeshColliders() + { + if (createdMeshCollider == null) + createdMeshCollider = new List(); + + MeshFilter[] allChildsMF = GetComponentsInChildren(); + foreach (MeshFilter mf in allChildsMF) // GRAB ALL CHILDS + { + Collider col = mf.transform.GetComponent(); // GRAB EACH CHILDS COLLIDER + if (col == null) // IF THEY DONT HAVE COLLIDER + { + MeshCollider mc = mf.transform.gameObject.AddComponent(); // ADD A MESH COLLIDER AND ADD THIS MESH COLLIDER TO THE LIST + createdMeshCollider.Add(mc); + } + else + { + if (col.GetType() != typeof(MeshCollider)) // IF IT HAS A COLLIDER BUT ITS TYPE IS DIFFERENTE THAN MESH COLLIDER + { + MeshCollider mc = mf.gameObject.AddComponent(); // ADD A MESH COLLIDER AND ADD IT TO THE LIST; + createdMeshCollider.Add(mc); + + lastCollider.Add(col); + col.enabled = false; + + } + } + } + createdsColliders = true; + } + + public void RevertMeshColliders() + { + if (createdMeshCollider != null) + { + foreach (MeshCollider mc in createdMeshCollider) + { + if (mc != null) + DestroyImmediate(mc); + } + createdMeshCollider.Clear(); + } + if (lastCollider != null) + { + foreach (Collider col in lastCollider) + { + col.enabled = true; + } + lastCollider.Clear(); + } + createdsColliders = false; + } + } +} diff --git a/Scripts/SceneModifiers/CreateMeshColliderOnChilds.cs.meta b/Scripts/SceneModifiers/CreateMeshColliderOnChilds.cs.meta new file mode 100644 index 0000000..bd15470 --- /dev/null +++ b/Scripts/SceneModifiers/CreateMeshColliderOnChilds.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 856c6d651439cef45892cf586ce52377 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/DisplayHiddenChilds.cs b/Scripts/SceneModifiers/DisplayHiddenChilds.cs new file mode 100644 index 0000000..5b28bc8 --- /dev/null +++ b/Scripts/SceneModifiers/DisplayHiddenChilds.cs @@ -0,0 +1,82 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +# endif + + + +public class DisplayHiddenChilds : MonoBehaviour +{ + public GameObject[] hiddenChildsObjects; + public bool toggleOn = false; + public void SelectHiddenChildObjects() + { + + } + public void ToggleHiddenObjects() + { + foreach(GameObject t in hiddenChildsObjects) + { + t.SetActive(toggleOn); + + } + toggleOn = !toggleOn; + } +} +#if UNITY_EDITOR + +[CustomEditor(typeof(DisplayHiddenChilds))] +public class DisplayHiddenChildsEditor : Editor +{ + DisplayHiddenChilds myScript; + GameObject[] goArray; + private void OnEnable() + { + + myScript = (DisplayHiddenChilds)target; + + Transform[] allChilds = myScript.transform.GetComponentsInChildren(true); + List hiddenObjects = new List(); + + + foreach (Transform t in allChilds) + { + if (t.gameObject.activeInHierarchy == false) { + hiddenObjects.Add(t.gameObject); + } + } + + myScript.hiddenChildsObjects = new GameObject[hiddenObjects.Count]; + + for (int i =0;i< hiddenObjects.Count; i++) + { + myScript.hiddenChildsObjects[i] = hiddenObjects[i]; + } + + + + + + } + + public override void OnInspectorGUI() + { + //base.OnInspectorGUI(); + if (GUILayout.Button("Select Hidden")) + { + Selection.objects = myScript.hiddenChildsObjects; + } + string add = myScript.toggleOn? "on":"off"; + if (GUILayout.Button("Toggle Hidden " + add)) + + { + myScript.ToggleHiddenObjects(); + } + } + +} + + +# endif \ No newline at end of file diff --git a/Scripts/SceneModifiers/DisplayHiddenChilds.cs.meta b/Scripts/SceneModifiers/DisplayHiddenChilds.cs.meta new file mode 100644 index 0000000..2bd25ff --- /dev/null +++ b/Scripts/SceneModifiers/DisplayHiddenChilds.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0e30247da5d10284f8d3382fe9320978 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/MaterialOptions.cs b/Scripts/SceneModifiers/MaterialOptions.cs new file mode 100644 index 0000000..c07601f --- /dev/null +++ b/Scripts/SceneModifiers/MaterialOptions.cs @@ -0,0 +1,93 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + public class MaterialOptions : MonoBehaviour + { + public Material[] materialOptions; + public MeshRenderer[] changeMesh; + public int curMat = 0; + public bool displayOptions = true; + + public bool canOffset = false; + [HideInInspector] + public int offsetColumns = 1; + [HideInInspector] + public int offsetRows = 1; + [HideInInspector] + public int curColumn = 1; + [HideInInspector] + public int curRow = 1; + public void ChangeMaterial(bool nextMaterial) + { + if (nextMaterial) + { + curMat++; + if (curMat >= materialOptions.Length) + curMat = 0; + } + else + { + curMat--; + if (curMat < 0) + curMat = materialOptions.Length -1; + } + + foreach (MeshRenderer mr in changeMesh) + { + mr.sharedMaterial = materialOptions[curMat]; + } + } + public void SelectOffset(int offsetInt) + { + //te + switch (offsetInt) + { + case 0: //TOP + changeOffset(false, 1); + curRow--; + break; + case 1: //LEFT + changeOffset(true, 3); + curColumn--; + break; + case 2: //RIGHT + changeOffset(true, 5); + curColumn++; + break; + case 3: //BOTTOM + changeOffset(false, 7); + curRow++; + break; + } + if (curRow > offsetRows) + curRow = 1; + if (curRow < 1) + curRow = offsetRows; + + if (curColumn > offsetColumns) + curColumn = 1; + if (curColumn < 1) + curColumn = offsetColumns; + } + private void changeOffset(bool changeColumn, int move) + { + + foreach (MeshRenderer mr in changeMesh) + { + OffsetUVs ou = mr.transform.GetComponent(); + if (ou == null) + ou = mr.gameObject.AddComponent(); + + if (changeColumn) + ou.offsetValue = (1f / (float)offsetColumns); + else + ou.offsetValue = (1f / (float)offsetRows); + + ou.OffsetAllUVs(move); + } + } + } +} diff --git a/Scripts/SceneModifiers/MaterialOptions.cs.meta b/Scripts/SceneModifiers/MaterialOptions.cs.meta new file mode 100644 index 0000000..172e1c7 --- /dev/null +++ b/Scripts/SceneModifiers/MaterialOptions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8d4523436dbbfe04e8b483834e23dba8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/ModifyUVs.meta b/Scripts/SceneModifiers/ModifyUVs.meta new file mode 100644 index 0000000..6a93c1b --- /dev/null +++ b/Scripts/SceneModifiers/ModifyUVs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6b1647490fed2bc4d9f3a825f42f3c68 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/ModifyUVs/OffsetChildOffsetUVs.cs b/Scripts/SceneModifiers/ModifyUVs/OffsetChildOffsetUVs.cs new file mode 100644 index 0000000..9760b39 --- /dev/null +++ b/Scripts/SceneModifiers/ModifyUVs/OffsetChildOffsetUVs.cs @@ -0,0 +1,45 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER { + [ExecuteAlways] + public class OffsetChildOffsetUVs : MonoBehaviour + { + //public float offsetQuantity = 0.125f; + public OffsetUVs[] targetOffsets; + public void SetOffset(int move) + { + if (targetOffsets == null) + { + OffsetUVs[] offsetuvs = GetComponentsInChildren(); + foreach (OffsetUVs ofuv in offsetuvs) + { + ofuv.OffsetAllUVs(move); + } + + } + else + { + if (targetOffsets.Length == 0) + { + OffsetUVs[] offsetuvs = GetComponentsInChildren(); + foreach (OffsetUVs ofuv in offsetuvs) + { + ofuv.OffsetAllUVs(move); + } + } + else + { + foreach (OffsetUVs ofuv in targetOffsets) + { + if (ofuv != null) + { + ofuv.OffsetAllUVs(move); + } + } + } + } + } + } +} diff --git a/Scripts/SceneModifiers/ModifyUVs/OffsetChildOffsetUVs.cs.meta b/Scripts/SceneModifiers/ModifyUVs/OffsetChildOffsetUVs.cs.meta new file mode 100644 index 0000000..2df900e --- /dev/null +++ b/Scripts/SceneModifiers/ModifyUVs/OffsetChildOffsetUVs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1471a57b0187c75428aa38e0bf5e06e9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/ModifyUVs/OffsetUVs.cs b/Scripts/SceneModifiers/ModifyUVs/OffsetUVs.cs new file mode 100644 index 0000000..5b0cba0 --- /dev/null +++ b/Scripts/SceneModifiers/ModifyUVs/OffsetUVs.cs @@ -0,0 +1,397 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEditor; +using UnityEditor.SceneManagement; +using System.IO; +using System; + +namespace WEBGL_EXPORTER +{ + [ExecuteInEditMode] + [DisallowMultipleComponent] + [RequireComponent (typeof(MeshFilter))] + [RequireComponent(typeof(OffsetUVsOrigMesh))] + public class OffsetUVs : MonoBehaviour + { + private string instancedFolderName = "mesh_instances"; + public float offsetValue = 0.125f; + [HideInInspector] + public MeshFilter meshFilter; + [HideInInspector] + public bool modifiedMesh = false; + private string instanceDirectory; + [HideInInspector] + public Mesh editedMesh; + [HideInInspector] + public bool uvsFromLightmapUvs = false; + + //public OffsetUVsOrigMesh origMesh; + + + + //[HideInInspector] + //public Mesh originalMesh; + [HideInInspector] + public Mesh baseMesh; + //[HideInInspector] + //public OffsetUVsOrigMesh om; + + public Vector2 offsetUVs; + [HideInInspector] + public Vector2 savedOffsetUVs; + + public Vector2 scaleUVS = Vector2.one; + [HideInInspector] + public Vector2 savedScaleUVs = Vector2.one; + + [HideInInspector] + public int objectID; + + [HideInInspector] + public bool AutoChange = true; + +/* public int targetSubmesh = 0; + public Vector2[][] uvsArray; + public int[][] triangleIndices;*/ + + + private void OnEnable() + { + //origMesh = GetComponent(); + if (objectID != gameObject.GetInstanceID()) + { + objectID = gameObject.GetInstanceID(); + GetOriginalMesh(); + editedMesh = Instantiate(GetComponent().originalMesh); + } + meshFilter = GetComponent(); + if (meshFilter == null) + { + OffsetUVsOrigMesh origMesh = GetComponent(); + if (origMesh != null) + DestroyImmediate(origMesh); + DestroyImmediate(this); + //DestroyImmediate + } + if (meshFilter.sharedMesh == null) + OffsetTargetUVs(Vector2.zero); + +/* if (meshFilter.sharedMesh.subMeshCount > 1) + { + GetSubmeshArray(); + }*/ + } + //private void GetSubmeshArray() + //{ +/* //if (uvsArray == null) + //{ + + int submeshCount = meshFilter.sharedMesh.subMeshCount; + uvsArray = new Vector2[submeshCount][]; + triangleIndices = new int[submeshCount][]; + + for (int i = 0; i < meshFilter.sharedMesh.subMeshCount; i++) + { + //triangleIndices[i] = meshFilter.sharedMesh.GetTriangles(i).Length / 3; + //Debug.Log(triangleIndices[i]); + triangleIndices[i] = meshFilter.sharedMesh.GetTriangles(i); + foreach (int fi in triangleIndices[i]) + { + Debug.Log("index: " + fi); + } + } + // step 1: Get the all the triangle indices + // Step 2: Use the triangle indices to fetch a vertex list + // Step 3: Use this list + Debug.Log(meshFilter.sharedMesh.uv.Length); + Debug.Log(meshFilter.sharedMesh.vertices.Length); + int maxVal = 0; + for (int i = 0; i < submeshCount; i++) + { + int startVal = maxVal; // STARTS FROM 0, AND WITH EACH CYCLE IT GROWS + //maxVal += triangleIndices[i]; // SETS THE LIMIT + + //Debug.Log("from: " + startVal + " to: " + maxVal); + //Debug.Log(meshFilter.sharedMesh.uv.Length); + //Debug.Log(meshFilter.sharedMesh.vertices.Length); + Vector2[] resultVector2 = new Vector2[maxVal - startVal]; + for (int j = startVal; j < maxVal; j++) + { + resultVector2[j-startVal] = meshFilter.sharedMesh.uv[j]; + } + uvsArray[i] = resultVector2; + } + //} + + if (uvsArray != null) + { + foreach (Vector2[] v2 in uvsArray) + { + Debug.Log(v2.Length); + } + } + + //if ()*/ + //} + public void SetOffsetUvs() + { + if (objectID != gameObject.GetInstanceID()) + { + objectID = gameObject.GetInstanceID(); + GetOriginalMesh(); + OffsetTargetUVs(Vector2.zero); + } + if (scaleUVS != savedScaleUVs || offsetUVs != savedOffsetUVs) + OffsetTargetUVs(Vector2.zero); + } + public static void SetAllToOriginalMesh(bool origMesh) + { + OffsetUVs[] allOffsetUVs = FindObjectsOfType(); + foreach (OffsetUVs ou in allOffsetUVs) + { + ou.SetOriginalMesh(origMesh); + } + } + public void SetLightmapUvsAsMainUvs(bool set = true) + { + if (set) + { + uvsFromLightmapUvs = true; + OffsetTargetUVs(Vector2.zero); // WE OFFSET THE VALUES TO MAKE SURE WE ALREADY HAVE AN INSTANCE PF THE UVS + List lightmapUvs = new List(); + editedMesh.GetUVs(1, lightmapUvs); + editedMesh.SetUVs(0, lightmapUvs); + OffsetTargetUVs(Vector2.zero); // AND UPDATE A NEW VALUE + } + else + { + uvsFromLightmapUvs = false; + + List origUvs = new List(); + GetComponent().originalMesh.GetUVs(0, origUvs); + editedMesh.SetUVs(0, origUvs); + OffsetTargetUVs(Vector2.zero); // UPDATE NEW VALUE + } + } + private void OnValidate() + { + if (AutoChange) + { + //Undo.RecordObject(editedMesh, "offset uvs"); + SetOffsetUvs(); + } + } + public void ResetOriginalMesh() + { + meshFilter.sharedMesh = GetComponent().originalMesh; + editedMesh = Instantiate(GetComponent().originalMesh); + OffsetTargetUVs(Vector2.zero); + + } + public void GetOriginalMesh() + { + meshFilter = GetComponent(); + OffsetUVsOrigMesh om = GetComponent(); + + if (om.originalMesh != null) + { + if (meshFilter.sharedMesh == null) + { + meshFilter.sharedMesh = om.originalMesh; + } + + editedMesh = Instantiate(om.originalMesh); + + if (scaleUVS != savedScaleUVs || offsetUVs != savedOffsetUVs) + { + OffsetTargetUVs(Vector2.zero); + } + } + else + { + Debug.LogWarning(om.transform.name + " object, does not have mesh filter, remove object or delete component"); + } + } + public void SetOriginalMesh(bool setOrig = true) + { + AutoChange = !setOrig; + if (setOrig) + { + GetComponent().sharedMesh = GetComponent().originalMesh; + } + else + { + OffsetTargetUVs(Vector2.zero); + } + } + public void DebugClick() + { + Debug.Log(GetComponent().originalMesh.uv2.Length); + Debug.Log(GetComponent().sharedMesh.uv2.Length); + + Debug.Log(GetComponent().originalMesh.uv.Length); + Debug.Log(GetComponent().sharedMesh.uv.Length); + } + public void OffsetAllUVs(int move) + { + modifiedMesh = true; + switch (move) + { + case 0: + OffsetTargetUVs(new Vector2(-offsetValue, offsetValue)); + break; + case 1: + OffsetTargetUVs(new Vector2(0f, offsetValue)); + break; + case 2: + OffsetTargetUVs(new Vector2(offsetValue, offsetValue)); + break; + + case 3: + OffsetTargetUVs(new Vector2(-offsetValue, 0f)); + break; + case 4: + //OffsetTargetUVs(new Vector2(0f, 0f)); + break; + case 5: + OffsetTargetUVs(new Vector2(offsetValue, 0f)); + break; + + case 6: + OffsetTargetUVs(new Vector2(-offsetValue, -offsetValue)); + break; + case 7: + OffsetTargetUVs(new Vector2(0f, -offsetValue)); + break; + case 8: + OffsetTargetUVs(new Vector2(offsetValue, -offsetValue)); + break; + + + default: + Debug.Log("non valid int"); + break; + } + + + } + + public void OffsetTargetUVs(Vector2 addValues) + { + savedScaleUVs = scaleUVS; + savedOffsetUVs = offsetUVs; + OffsetUVsOrigMesh om = GetComponent(); + + if (om.originalMesh != null) // added + { + if (this.enabled) + { + offsetUVs = new Vector2(offsetUVs.x + addValues.x, offsetUVs.y + addValues.y); + + List newUvs = new List(); + if (!uvsFromLightmapUvs) + { + for (int i = 0; i < om.originalMesh.uv.Length; i++) + { + newUvs.Add(new Vector2((om.originalMesh.uv[i].x * scaleUVS.x) + offsetUVs.x, (om.originalMesh.uv[i].y * scaleUVS.y) + offsetUVs.y)); + } + } + else + { + for (int i = 0; i < om.originalMesh.uv2.Length; i++) + { + newUvs.Add(new Vector2((om.originalMesh.uv2[i].x * scaleUVS.x) + offsetUVs.x, (om.originalMesh.uv2[i].y * scaleUVS.y) + offsetUVs.y)); + } + } + + editedMesh.SetUVs(0, newUvs); + meshFilter.mesh = editedMesh; + EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); + } + } + + } + + + public string GetFolderLocation() + { + string[] tempString = SceneManager.GetActiveScene().path.Split('/'); + string sceneDirectory = ""; + for (int i = 0; i < tempString.Length - 1; i++) // we want to remove the name of the scene, we only need the folder path; + sceneDirectory += tempString[i] + "/"; + instanceDirectory = sceneDirectory + instancedFolderName; + + if (!AssetDatabase.IsValidFolder(instanceDirectory)) // if the folder doesnt exist, create it. + { + AssetDatabase.CreateFolder(StringUtilities.RemoveCharacterFromString(sceneDirectory, 1, false), instancedFolderName); + } + + return (StringUtilities.RemoveCharacterFromString(Application.dataPath, 6, false) + instanceDirectory + "/"); + } + /* public void CreateInstance(bool removeOld = true) + { + + + meshFilter = GetComponent(); + + + GameObject dupObject = GameObject.Instantiate(meshFilter.gameObject); + + List firstChildObjects = GameObjectUtilities.GetTopHierarchyChilds(dupObject, null, true); + foreach (GameObject go in firstChildObjects) //THIS WAY WE MAKE SURE WE ONLY EXPORT THIS GAME OBJECT, AND NOT AL THE CHILDS + DestroyImmediate(go); + + string objectName = "(inst)_" + UnityEngine.Random.Range(0, 9999999).ToString() + System.DateTime.Now.Hour.ToString("D2") + System.DateTime.Now.Minute.ToString("D2") + System.DateTime.Now.Second.ToString("D2"); + FileModelExporter.ExportToFBX(dupObject, objectName, GetFolderLocation()); + DestroyImmediate(dupObject); + + GameObject newObject = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath(instanceDirectory + "/" + objectName + ".fbx", typeof(GameObject)) as GameObject); + + + + newObject.name = objectName; + newObject.transform.position = meshFilter.transform.position; + newObject.transform.rotation = meshFilter.transform.rotation; + newObject.transform.parent = meshFilter.transform.parent; + newObject.transform.localScale = meshFilter.transform.localScale; + newObject.GetComponent().materials = meshFilter.GetComponent().sharedMaterials; + newObject.AddComponent(); + + if (removeOld) // THIS SECTION WILL GET THE CHILD OBJECTS OF THE ORIGINAL MESH, AND ASSIGN THEM TO THE NEW INSTANCE AS CHILDS + { + dupObject = GameObject.Instantiate(meshFilter.gameObject); + dupObject.transform.position = meshFilter.gameObject.transform.position; + dupObject.transform.rotation = meshFilter.gameObject.transform.rotation; + dupObject.transform.parent = meshFilter.gameObject.transform.parent; + dupObject.transform.localScale = meshFilter.gameObject.transform.localScale; + + firstChildObjects = GameObjectUtilities.GetTopHierarchyChilds(dupObject, null, true); + foreach (GameObject go in firstChildObjects) + { + go.transform.parent = newObject.transform; + } + DestroyImmediate(dupObject); + } + newObject.transform.SetSiblingIndex(meshFilter.transform.GetSiblingIndex()); + if (removeOld) + DestroyImmediate(meshFilter.gameObject); + Selection.activeGameObject = newObject.gameObject; + + }*/ +/* public void SaveChanges() + { + string[] splitString = transform.name.Split(' '); + GameObject dupObject = GameObject.Instantiate(meshFilter.gameObject); + + List firstChildObjects = GameObjectUtilities.GetTopHierarchyChilds(dupObject, null, true); + foreach (GameObject go in firstChildObjects) //THIS WAY WE MAKE SURE WE ONLY EXPORT THIS GAME OBJECT, AND NOT AL THE CHILDS + DestroyImmediate(go); + + FileExporter.ExportToFBX(dupObject, splitString[0], GetFolderLocation()); + DestroyImmediate(dupObject); + //Debug.Log(splitString[0]); + }*/ + } +} diff --git a/Scripts/SceneModifiers/ModifyUVs/OffsetUVs.cs.meta b/Scripts/SceneModifiers/ModifyUVs/OffsetUVs.cs.meta new file mode 100644 index 0000000..638cd92 --- /dev/null +++ b/Scripts/SceneModifiers/ModifyUVs/OffsetUVs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 830eae718402bb14eb960ab2de9560b7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/ModifyUVs/OffsetUVsOrigMesh.cs b/Scripts/SceneModifiers/ModifyUVs/OffsetUVsOrigMesh.cs new file mode 100644 index 0000000..a7b523d --- /dev/null +++ b/Scripts/SceneModifiers/ModifyUVs/OffsetUVsOrigMesh.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + [ExecuteAlways] + [RequireComponent(typeof(MeshFilter))] + public class OffsetUVsOrigMesh : MonoBehaviour + { + public Mesh originalMesh; + private void OnEnable() + { + if (originalMesh == null) + { + originalMesh = GetComponent().sharedMesh; + } + } +/* public void GetOriginalMesh() + { + + }*/ + } +} diff --git a/Scripts/SceneModifiers/ModifyUVs/OffsetUVsOrigMesh.cs.meta b/Scripts/SceneModifiers/ModifyUVs/OffsetUVsOrigMesh.cs.meta new file mode 100644 index 0000000..6e069ca --- /dev/null +++ b/Scripts/SceneModifiers/ModifyUVs/OffsetUVsOrigMesh.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0dadc5b463297044580bf463e1336fa2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/ModifyUVs/OffsetUVsTemporaryReset.cs b/Scripts/SceneModifiers/ModifyUVs/OffsetUVsTemporaryReset.cs new file mode 100644 index 0000000..4e6fa41 --- /dev/null +++ b/Scripts/SceneModifiers/ModifyUVs/OffsetUVsTemporaryReset.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + public class OffsetUVsTemporaryReset : MonoBehaviour + { + public void SetOriginalMesh() + { + OffsetUVs [] allOffsetUVs = GameObject.FindObjectsOfType(); + foreach (OffsetUVs ou in allOffsetUVs) + { + ou.SetOriginalMesh(); + } + } + public void SetEditedMesh() + { + OffsetUVs[] allOffsetUVs = GameObject.FindObjectsOfType(); + foreach (OffsetUVs ou in allOffsetUVs) + { + ou.SetOriginalMesh(false); + } + } + + } +} diff --git a/Scripts/SceneModifiers/ModifyUVs/OffsetUVsTemporaryReset.cs.meta b/Scripts/SceneModifiers/ModifyUVs/OffsetUVsTemporaryReset.cs.meta new file mode 100644 index 0000000..0b4750b --- /dev/null +++ b/Scripts/SceneModifiers/ModifyUVs/OffsetUVsTemporaryReset.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4acf88e44457b254ab082f67094f70dc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/SwitchChildMaterials.cs b/Scripts/SceneModifiers/SwitchChildMaterials.cs new file mode 100644 index 0000000..286255f --- /dev/null +++ b/Scripts/SceneModifiers/SwitchChildMaterials.cs @@ -0,0 +1,39 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +namespace WEBGL_EXPORTER +{ + public class SwitchChildMaterials : MonoBehaviour + { + public Material originalMaterial; + public Material targetMaterial; + // Start is called before the first frame update + public void SwitchToTargetMaterial() + { + Debug.Log("totarget"); + ChangeToMaterial(originalMaterial, targetMaterial); + } + public void SwitchToOriginalMaterial() + { + Debug.Log("tooriginial"); + ChangeToMaterial(targetMaterial, originalMaterial); + } + public void ChangeToMaterial(Material from, Material to) + { + Debug.Log(from + " " + to); + MeshRenderer[] mrs = GetComponentsInChildren(); + foreach (MeshRenderer mr in mrs) + { + for (int i = 0; i < mr.sharedMaterials.Length; i++) + { + if (mr.sharedMaterials[i] == from) + { + Material[] mats = mr.sharedMaterials; + mats[i] = to; + mr.sharedMaterials = mats; + } + } + } + } + } +} diff --git a/Scripts/SceneModifiers/SwitchChildMaterials.cs.meta b/Scripts/SceneModifiers/SwitchChildMaterials.cs.meta new file mode 100644 index 0000000..849dad6 --- /dev/null +++ b/Scripts/SceneModifiers/SwitchChildMaterials.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e572a7d170192e143a3de4992534b863 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/SceneModifiers/TurnChildGameObjectVisibility.cs b/Scripts/SceneModifiers/TurnChildGameObjectVisibility.cs new file mode 100644 index 0000000..5611d00 --- /dev/null +++ b/Scripts/SceneModifiers/TurnChildGameObjectVisibility.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + [ExecuteAlways] + public class TurnChildGameObjectVisibility : MonoBehaviour + { + public List tarObjects; + public int curObject = 0; + + public void GetFirstChildObjects() + { + tarObjects = GameObjectUtilities.GetTopHierarchyChilds(gameObject,null,true); + } + public void TurnNextObject(bool nextObj) + { + if (nextObj) + { + curObject++; + if (curObject >= tarObjects.Count) + curObject = 0; + } + else { + if (curObject <= 0) + curObject = tarObjects.Count - 1; + else + curObject--; + } + + foreach(GameObject go in tarObjects) + { + go.SetActive(false); + } + + tarObjects[curObject].SetActive(true); + } + } +} diff --git a/Scripts/SceneModifiers/TurnChildGameObjectVisibility.cs.meta b/Scripts/SceneModifiers/TurnChildGameObjectVisibility.cs.meta new file mode 100644 index 0000000..0ee5923 --- /dev/null +++ b/Scripts/SceneModifiers/TurnChildGameObjectVisibility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bf8328eff1b107446b0e90878176ef5e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities.meta b/Scripts/Utilities.meta new file mode 100644 index 0000000..9ca5105 --- /dev/null +++ b/Scripts/Utilities.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 746950acd0034584bba17b4a997bc268 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/ArrayListsUtilities.cs b/Scripts/Utilities/ArrayListsUtilities.cs new file mode 100644 index 0000000..9edd9c7 --- /dev/null +++ b/Scripts/Utilities/ArrayListsUtilities.cs @@ -0,0 +1,110 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + public class ArrayListsUtilities + { + public static List GetWorkingMeshRenderersListFromChilds(Transform targetParent) + { + List meshRendChildsResult = new List(); + MeshRenderer[] allChildMeshrenderers = targetParent.GetComponentsInChildren(); + foreach(MeshRenderer mr in allChildMeshrenderers) + { + MeshFilter mf = mr.gameObject.GetComponent(); + if (mf != null) + { + if (mf.sharedMesh != null) + { + meshRendChildsResult.Add(mr); + } + } + } + return meshRendChildsResult; + } + public static MeshRenderer[] GetWorkingMeshRenderersArrayFromChilds(Transform targetParent) + { + List meshRendChildsResult = GetWorkingMeshRenderersListFromChilds(targetParent); + MeshRenderer[] result = new MeshRenderer[meshRendChildsResult.Count]; + for (int i = 0; i < result.Length;i++) + { + result[i] = meshRendChildsResult[i]; + } + return result; + } + public static string[] ChangeArraySize(string[] targetArray, int newSize) + { + string[] newArray = new string[newSize]; + for (int i = 0; i < newSize; i++) + { + if (targetArray.Length == i) + break; + else + newArray[i] = targetArray[i]; + } + return newArray; + } + public static long[] ChangeArraySize(long[] targetArray, int newSize) + { + long[] newArray = new long[newSize]; + for (int i = 0; i < newSize; i++) + { + if (targetArray.Length == i) + break; + else + newArray[i] = targetArray[i]; + } + return newArray; + } + + public static int[] ChangeArraySize(int[] targetArray, int newSize) + { + int[] newArray = new int[newSize]; + for (int i = 0; i < newSize; i++) + { + if (targetArray.Length == i) + break; + else + newArray[i] = targetArray[i]; + } + return newArray; + } + public static GameObject[] ChangeArraySize(GameObject[] targetArray, int newSize) + { + GameObject[] newArray = new GameObject[newSize]; + for (int i = 0; i < newSize; i++) + { + if (targetArray.Length == i) + break; + else + newArray[i] = targetArray[i]; + } + return newArray; + } + public static Material[] ChangeArraySize(Material[] targetArray, int newSize) + { + Material[] newArray = new Material[newSize]; + for (int i = 0; i < newSize; i++) + { + if (targetArray.Length == i) + break; + else + newArray[i] = targetArray[i]; + } + return newArray; + } + public static GameObjectArray[] ChangeArraySize(GameObjectArray[] targetArray, int newSize) + { + GameObjectArray[] newArray = new GameObjectArray[newSize]; + for (int i = 0; i < newSize; i++) + { + if (targetArray.Length == i) + break; + else + newArray[i] = targetArray[i]; + } + return newArray; + } + } +} diff --git a/Scripts/Utilities/ArrayListsUtilities.cs.meta b/Scripts/Utilities/ArrayListsUtilities.cs.meta new file mode 100644 index 0000000..f0b6705 --- /dev/null +++ b/Scripts/Utilities/ArrayListsUtilities.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 166f50eadb75b104a880a7a7d645ac91 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/CreateThumbImages.cs b/Scripts/Utilities/CreateThumbImages.cs new file mode 100644 index 0000000..f0eda42 --- /dev/null +++ b/Scripts/Utilities/CreateThumbImages.cs @@ -0,0 +1,115 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.Threading; +using System.IO; + +namespace WEBGL_EXPORTER +{ + public class CreateThumbImages + { + public static void CreateThumbnailsFromFolderObject(string targetFolder, string extension, System.Type type, bool overwrite = true) + { + string target_folder_correct = targetFolder; + if (!target_folder_correct.StartsWith("Assets/")) + target_folder_correct = "Assets/"+target_folder_correct; + if (Directory.Exists(StringUtilities.GetFullPathFromLocalPath(target_folder_correct))) + { + CreateThumbnails(target_folder_correct, extension, type, overwrite); + } + else + { + Debug.LogError("Thumbnail folder does not exists, please check"); + } + } + public static void CreateThumbnailsFromFolderObject(Object targetFolder,string extension,System.Type type, bool overwrite = true) + { + if (targetFolder != null) + { + CreateThumbnails(AssetDatabase.GetAssetPath(targetFolder),extension,type, overwrite); + } + } + public static void CreateThumbnails(string targetPath, string extension, System.Type type, bool overwrite = true) + { + string[] pathLocations = StringUtilities.GetFilesPathFromFolder(targetPath, true, extension, true, true); + List destinationList = new List(); // used to later set labels for the images created + foreach (string st in pathLocations) + { + + var thumbMat = AssetDatabase.LoadAssetAtPath(st, type); + Texture2D newTexture = GetThumbnailPreview(thumbMat); + if (newTexture != null) + { + string destination = Path.GetDirectoryName(st); + string thumbName = StringUtilities.GetFileNameFromPath(st) + "_thumb"; + string finalDestination = destination + "/" + thumbName + ".png"; + destinationList.Add(finalDestination); + if (overwrite || !File.Exists(finalDestination)) + { + FileExporter.ExportToPNG(newTexture, thumbName, destination, overwrite); + } + } + } + + AssetDatabase.Refresh(); + + foreach(string st in destinationList) + { + Texture2D obj = (Texture2D)AssetDatabase.LoadAssetAtPath(st, typeof(Texture2D)); + + string[] stAllLabels = AssetDatabase.GetLabels(obj); + bool addLabel = true; + foreach (string stlb in stAllLabels) + { + if (stlb == "Thumb") + { + addLabel = false; + break; + } + } + if (addLabel) + { + string[] newLabels = new string[stAllLabels.Length + 1]; + for (int i = 0; i < stAllLabels.Length; i++) + { + newLabels[i] = stAllLabels[i]; + } + newLabels[newLabels.Length - 1] = "Thumb"; + AssetDatabase.SetLabels(obj, newLabels); + } + } + } + public static void CreateThumbnail(string targetPath, System.Type type, bool overwrite = true) + { + var thumbObj = AssetDatabase.LoadAssetAtPath(targetPath, type); + Texture2D newTexture = GetThumbnailPreview(thumbObj); + if (newTexture != null) + { + string destination = Path.GetDirectoryName(targetPath); + string thumbName = StringUtilities.GetFileNameFromPath(targetPath) + "_thumb"; + FileExporter.ExportToPNG(newTexture, thumbName, destination, overwrite); + } + AssetDatabase.Refresh(); + } + public static Texture2D GetThumbnailPreview(Object targetObject) + { + + if (targetObject != null) + { + Texture2D previewTexture = AssetPreview.GetAssetPreview(targetObject); + while (AssetPreview.IsLoadingAssetPreview(targetObject.GetInstanceID())) + { + previewTexture = AssetPreview.GetAssetPreview(targetObject); + Thread.Sleep(30); + } + return previewTexture; + } + return null; + } + + + } + + +} diff --git a/Scripts/Utilities/CreateThumbImages.cs.meta b/Scripts/Utilities/CreateThumbImages.cs.meta new file mode 100644 index 0000000..cf10e95 --- /dev/null +++ b/Scripts/Utilities/CreateThumbImages.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 176f26c48a62ac646809c29817b1264a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/CreateUXMLFile.cs b/Scripts/Utilities/CreateUXMLFile.cs new file mode 100644 index 0000000..bf5dab6 --- /dev/null +++ b/Scripts/Utilities/CreateUXMLFile.cs @@ -0,0 +1,114 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + public class CreateUXMLFile + { + public static void CreateUSSFromStyles(int buttonHeight, int buttonWidth, int buttonMargin, int labelSize, string buttonUpLocalLocation, string buttonHoverLocalLocation, string buttonActiveLocalLocation, string fullSaveLocation) + { + string result = ""; + result += ".row {\n"+ + "display: flex;\n"+ + "flex-direction: row;\n"+ + "justify-content: center;\n"+ + "}\n"+ + ".header{\n"+ + "font-size: 15px;\n"+ + "color: #ffd800;\n"+ + "}\n"+ + ".prefab-button{\n"+ + "height: " + buttonHeight + "px;\n"+ + "width: " + buttonWidth + "px;\n"+ + "margin: " + buttonMargin + "px;\n"+ + "justify-content:flex-end;\n"+ + "}\n"+ + ".prefab-button__icon{\n"+ + "pointer-events:none;\n"+ + "}\n"+ + ".unity-button {\n"+ + "background-image: url(\"/"+ buttonUpLocalLocation + "\");\n"+ + "}\n"+ + ".unity-button:hover {\n"+ + "background-image: url(\"/"+ buttonHoverLocalLocation + "\");\n"+ + "}\n"+ + ".unity-button:active {\n"+ + "background-image: url(\"/"+ buttonActiveLocalLocation + "\");\n"+ + "}\n"+ + "Label{\n"+ + "font-size:"+labelSize+"px;\n"+ + "}\n"; + FileExporter.ExportToText(result, "button_styles_uss", fullSaveLocation, "uss"); + AssetDatabase.Refresh(); + } + + public static void CreateUXMLCodesFromSubfolders(int rowSize, int maxRowsQty, string targetLocalFolder,string extension,bool getAllSubfolders=false) + { + string [] subfolders = StringUtilities.GetSubfoldersPathsFromFolder(targetLocalFolder,true,true,getAllSubfolders); + string[] result = new string[subfolders.Length]; + for (int i = 0; i < subfolders.Length; i++) + { + Debug.Log(subfolders[i]); + result[i] = CreateUXMLCode(rowSize, maxRowsQty, subfolders[i], extension); + if (result[i] != "") + { + Debug.Log("exporting"); + FileExporter.ExportToText(result[i], "buttons_uxml", subfolders[i], "uxml"); + } + } + AssetDatabase.Refresh(); + + //return result; + } + public static string CreateUXMLCode(int rowSize, int maxRowQty, string targetLocalFolder/*,bool firstFileExtension = true*/, string extension) + { +/* if (firstFileExtension) { + string [] filestemp = StringUtilities.GetFilesPathFromFolder(targetLocalFolder, true); + if (filestemp.Length > 0) + extension = StringUtilities.GetExtensionFromFile(filestemp[0]); + }*/ + string [] files = StringUtilities.GetFilesPathFromFolder(targetLocalFolder, true, extension,true); + + + string result = ""; + if (files != null) + { + if (files.Length > 0) + { + result += "\n"; + int rowCounter = 0; + for (int i = 0; i < files.Length; i++) + { + if (rowCounter == 0) + { + result += "\n"; + } + result += CreatePrefabButton(StringUtilities.GetFileNameFromPath(files[i]), files[i]); + rowCounter += 1; + if (rowCounter == rowSize) + { + rowCounter = 0; + result += "\n"; + } + } + if (rowCounter < rowSize) + result += "\n"; + result += "\n"; + } + } + return result; + } + public static string CreatePrefabButton(string labelName, string location, string className = "prefab-button") + { + string result = ""; + + result += "\n"; + + return result; + } + } +} diff --git a/Scripts/Utilities/CreateUXMLFile.cs.meta b/Scripts/Utilities/CreateUXMLFile.cs.meta new file mode 100644 index 0000000..f5cc5de --- /dev/null +++ b/Scripts/Utilities/CreateUXMLFile.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fbafbc4e497294441b3285f2850c2b85 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/FileExporter.cs b/Scripts/Utilities/FileExporter.cs new file mode 100644 index 0000000..8bf326a --- /dev/null +++ b/Scripts/Utilities/FileExporter.cs @@ -0,0 +1,209 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.IO; +namespace WEBGL_EXPORTER +{ + public class FileExporter : MonoBehaviour + { + public static string ExportToJPEG(Texture2D texture, string name, string path,int quality = 75, bool invertWidth = false, bool invertHeight = false) + { + if (quality > 100) + quality = 100; + if (quality < 1) + quality = 1; + ImageGenerator.MakeReadableTexture(texture); + texture = ImageGenerator.InvertTexture(texture, invertWidth, invertHeight); + byte[] textureInfo = ImageConversion.EncodeToJPG(texture,quality); + // change to path variable + File.WriteAllBytes(path + "/" + name + ".jpg", textureInfo); + + return path + "/" + name + ".jpg"; + } + + public static void ExportToPNG(Texture2D texture, string name, string path,bool overwrite = true,bool debugWarning = true) + { + if (texture != null) + { + string pathToSave = path + "/" + name + ".png"; + if (overwrite || !File.Exists(pathToSave)) + { + + ImageGenerator.MakeReadableTexture(texture); + byte[] textureInfo = ImageConversion.EncodeToPNG(texture); + // change to path variable + + + + File.WriteAllBytes(path + "/" + name + ".png", textureInfo); + } + else + { + if (debugWarning) + Debug.LogWarning("file in: " + pathToSave + " exists, skipping"); + } + } + } + public static void ExportToEXR(Texture2D texture, string name, string path, Texture2D.EXRFlags flags = Texture2D.EXRFlags.CompressZIP) + { + ImageGenerator.MakeReadableTexture(texture,false); + byte[] textureInfo = ImageConversion.EncodeToEXR(texture,flags); + File.WriteAllBytes(path + "/" + name + ".exr", textureInfo); + //DestroyImmediate(texture); + + } + public static string ExportToText(string tarText, string name, string path, string ext = "txt") + { + if (!path.EndsWith("/")) + path += "/"; + File.WriteAllText(path + name + "." + ext, tarText); + return path + name + "." + ext; + } + public static void ReplaceStringInFile(string filePath, string stringToReplace, string replaceString) + { + if (File.Exists(filePath)) + { + string text = File.ReadAllText(filePath); + text = text.Replace(stringToReplace, replaceString); + string fileName = StringUtilities.GetFileNameFromPath(filePath); + string extension = StringUtilities.GetExtensionFromFile(filePath); + string path = StringUtilities.GetFolderNameFromFile(filePath); + Debug.Log(text); + ExportToText(text,fileName,path,extension); + } + else + { + Debug.Log(filePath); + } + } + public static void DuplicateFolder(string sourceDirName, string destDirName, bool copySubDirs = true, string[] fileExtensions = null) + { + // Get the subdirectories for the specified directory. + DirectoryInfo dir = new DirectoryInfo(sourceDirName); + if (!dir.Exists) + { + Debug.Log( + "Source directory does not exist or could not be found: " + + sourceDirName); + } + else + { + DirectoryInfo[] dirs = dir.GetDirectories(); + // If the destination directory doesn't exist, create it. + if (!Directory.Exists(destDirName)) + { + Directory.CreateDirectory(destDirName); + } + + // Get the files in the directory and copy them to the new location. + FileInfo[] files = dir.GetFiles(); + foreach (FileInfo file in files) + { + if (file.Extension != ".meta") + { + if (fileExtensions == null) + { + string temppath = Path.Combine(destDirName, file.Name); + file.CopyTo(temppath, true); + } + else + { + bool hasExtension = false; + foreach (string st in fileExtensions) + { + if (file.Extension == ("." + st)) + { + hasExtension = true; + break; + } + } + if (hasExtension) + { + string temppath = Path.Combine(destDirName, file.Name); + file.CopyTo(temppath, true); + } + } + } + } + + // If copying subdirectories, copy them and their contents to new location. + if (copySubDirs) + { + foreach (DirectoryInfo subdir in dirs) + { + string temppath = Path.Combine(destDirName, subdir.Name); + DuplicateFolder(subdir.FullName, temppath, copySubDirs, fileExtensions); + } + } + } + } + public static void CopyFileFromAsset(Object obj, string location, string name, bool overwrite = false) + { + string origPath = AssetDatabase.GetAssetPath(obj); + string ext = "." + StringUtilities.GetExtensionFromFile(origPath); + location = (location.EndsWith("/")|| location.EndsWith("\\")) ? location : location + "/"; + location += name + ext; + CopyFile(origPath,location,overwrite); + } + public static void CopyFile(string sourceFile, string destFile,bool overwrite = false) + { + File.Copy(sourceFile, destFile, overwrite); + } + public static string DuplicateFile(string sourceFile, int countModif = 0) + { + if (File.Exists(sourceFile)) + { + string[] fileSplit = sourceFile.Split('.'); + string destFile = fileSplit[0] + "_" + countModif.ToString() + "." + fileSplit[1]; + if (File.Exists(destFile)) + { + Debug.Log("not copying file"); + return DuplicateFile(sourceFile, countModif+1); + } + else + { + Debug.Log("copying file"); + File.Copy(sourceFile, destFile); + return destFile; + } + } + else + { + return ""; + } + } + public static void DeleteFile(string tarPath) + { + if (File.Exists(tarPath)) + { + File.Delete(tarPath); + } + } + public static string CreateFolder(string folderFullPath) + { + if (!Directory.Exists(folderFullPath)) + { + Directory.CreateDirectory(folderFullPath); + return folderFullPath; + } + return ""; + } + public static int GetFilesQty(string folderFullPath) + { + if (Directory.Exists(folderFullPath)) + { + return Directory.GetFiles(folderFullPath).Length; + } + return 0; + } + public static bool DirectoryExists(string folderFullPath) + { + if (Directory.Exists(folderFullPath)) + { + return true; + } + return false; + } + } +} diff --git a/Scripts/Utilities/FileExporter.cs.meta b/Scripts/Utilities/FileExporter.cs.meta new file mode 100644 index 0000000..9abca9d --- /dev/null +++ b/Scripts/Utilities/FileExporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b6eec6717c43052439d867aa7916ed84 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/GameObjectArray.cs b/Scripts/Utilities/GameObjectArray.cs new file mode 100644 index 0000000..def749f --- /dev/null +++ b/Scripts/Utilities/GameObjectArray.cs @@ -0,0 +1,20 @@ +using System; +using UnityEngine; + +namespace WEBGL_EXPORTER { + [Serializable] + public class GameObjectArray { + [SerializeField] + public GameObject[] gameObjects; + + public GameObjectArray(GameObject[] gameObjectArray) + { + gameObjects = gameObjectArray; + } + public GameObjectArray() + { + gameObjects = new GameObject[0]; + } + } + +} diff --git a/Scripts/Utilities/GameObjectArray.cs.meta b/Scripts/Utilities/GameObjectArray.cs.meta new file mode 100644 index 0000000..f149c19 --- /dev/null +++ b/Scripts/Utilities/GameObjectArray.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 320b1a3233838664ba773e0fb7316692 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/GameObjectUtilities.cs b/Scripts/Utilities/GameObjectUtilities.cs new file mode 100644 index 0000000..685ff61 --- /dev/null +++ b/Scripts/Utilities/GameObjectUtilities.cs @@ -0,0 +1,221 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + public class GameObjectUtilities + { + public static List GetTopHierarchyChilds(GameObject parentObject, List existingList = null, bool includeInactive = false) + { + + List result = null; + if (existingList != null) + result = existingList; + else + result = new List(); + if (parentObject != null) + { + Transform[] childs = parentObject.GetComponentsInChildren(includeInactive); + foreach (Transform t in childs) + { + if (t.parent == parentObject.transform) + { + result.Add(t.gameObject); + } + } + } + return result; + } + public static List GetNonRepeatingObjectList(GameObject tarObject, List existingList = null) + { + List result = null; + if (existingList != null) + result = existingList; + else + result = new List(); + bool newObject = true; + if (tarObject != null) + { + foreach (GameObject go in result) + { + if (go == tarObject) + { + newObject = false; + break; + } + } + } + if (newObject) + result.Add(tarObject); + + return result; + } + public static GameObject[] CombineArraysNoRepeatingObjects(GameObject[] arr1, GameObject[] arr2) + { + + if (arr1 == null) + { + arr1 = new GameObject[0]; + } + if (arr2 == null) + { + return arr1; + } + List finalList = new List(); + foreach (GameObject go in arr1) + { + if (go != null) + finalList.Add(go); + } + foreach (GameObject go2 in arr2) + { + if (go2 != null) + { + bool newObject = true; + foreach (GameObject go1 in arr1) + { + if (go2 == go1) + { + newObject = false; + break; + } + } + if (newObject) finalList.Add(go2); + } + } + + GameObject[] listArray = new GameObject[finalList.Count]; + for (int i = 0; i < finalList.Count; i++) + { + listArray[i] = finalList[i]; + } + return listArray; + } + public static GameObject[] RemoveObjectsFromArray(GameObject[] target, GameObject[] remove) + { + if (target == null) + return null; + if (remove == null) + return target; + List finalList = new List(); + foreach (GameObject go1 in target) + { + bool originalObject = true; + foreach (GameObject go2 in remove) + { + if (go2 == go1) + { + originalObject = false; + break; + } + } + if (originalObject) finalList.Add(go1); + + } + + GameObject[] listArray = new GameObject[finalList.Count]; + for (int i = 0; i < finalList.Count; i++) + { + listArray[i] = finalList[i]; + } + return listArray; + } + public static GameObject[] RemoveNullObjects(GameObject[] target) + { + List finalList = new List(); + foreach(GameObject go in target) + { + if (go != null) + { + finalList.Add(go); + } + } + if (finalList.Count == target.Length) + return target; + else + { + GameObject[] listArray = new GameObject[finalList.Count]; + for (int i = 0; i < finalList.Count; i++) + { + listArray[i] = finalList[i]; + } + return listArray; + } + } + public static List RemoveNullObjects(List target) + { + List finalList = new List(); + foreach (GameObject go in target) + { + if (go != null) + { + finalList.Add(go); + } + } + return finalList; + } + public static GameObject[] RemoveObjectFromArray(GameObject[] target, GameObject remove) + { + if (remove == null) + return target; + List finalList = new List(); + foreach (GameObject go in target) + { + if (go != null) + { + if (go != remove) + { + finalList.Add(go); + } + } + } + GameObject[] listArray = new GameObject[finalList.Count]; + for (int i = 0; i < finalList.Count; i++) + { + listArray[i] = finalList[i]; + } + return listArray; + } + public static GameObject[] AddObjectToArray(GameObject[] target,GameObject add, bool canRepeat = false) + { + if (add == null) + return target; + + if (!canRepeat) + { + bool repeat = false; + foreach (GameObject go in target) + { + if (go != null) + { + if (go == add) + { + repeat = true; + break; + } + } + } + + if (repeat) + return target; + } + + GameObject[] listArray = new GameObject[target.Length+1]; + for (int i = 0; i < target.Length; i++) + { + listArray[i] = target[i]; + } + listArray[target.Length] = add; + return listArray; + } + public static GameObject InstantiateFromRelativeFolder(string relativePath,string name, Transform targetParent = null) + { + Debug.Log(relativePath); + GameObject result = GameObject.Instantiate((GameObject) AssetDatabase.LoadAssetAtPath(relativePath, typeof(GameObject))); + result.name = name; + result.transform.parent = targetParent; + return result; + } + } +} diff --git a/Scripts/Utilities/GameObjectUtilities.cs.meta b/Scripts/Utilities/GameObjectUtilities.cs.meta new file mode 100644 index 0000000..344f3e0 --- /dev/null +++ b/Scripts/Utilities/GameObjectUtilities.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 30eeedd33112999488ed337b3b207a55 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/GuiLayoutExtras.cs b/Scripts/Utilities/GuiLayoutExtras.cs new file mode 100644 index 0000000..2542bfc --- /dev/null +++ b/Scripts/Utilities/GuiLayoutExtras.cs @@ -0,0 +1,82 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + public class GuiLayoutExtras + { + public static GUIStyle buttonGuiStyle; + private static float currentHorizontalMargin = 0; + private static int buttonsQty = 1; + public static void CenterLabel(string label, int height) + { + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label("", GUILayout.Height(height / 2 - 7)); + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.Label(label, GUILayout.Height(height / 2 + 7)); + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + } + public static float GetCenteredButtonWidth() + { + return ((Screen.width * GetDPI()) / buttonsQty) - ((currentHorizontalMargin*2* GetDPI()) / buttonsQty); + } + public static float GetCenteredLabelWidth(float margin = 0f) + { + return (Screen.width * GetDPI()) - margin; + } + public static float RealDPIFloatSize(float value) + { + return value * GetDPI(); + } + public static float GetRealScreenWidth() + { + return (Screen.width * GetDPI()); + } + public static float GetRealScreenHeight() + { + return (Screen.height * GetDPI()); + } + private static float GetDPI() + { + float dpi = Screen.dpi; + if (dpi == 0) + dpi = 96; + dpi = 96 / dpi; + return dpi; + } + public static void BeginAlignedHorizontal(float margin, int buttons_qty) + { + GUILayout.BeginHorizontal(); + buttonsQty = buttons_qty; + GUILayout.Box("", GUIStyle.none, GUILayout.Width((margin/1.4f)*GetDPI())); + currentHorizontalMargin = margin; + } + public static void EndAlignedHorizontal() + { + //GUILayout.Box("", GUIStyle.none, GUILayout.Width((currentHorizontalMargin) * GetDPI())); + currentHorizontalMargin = 0; + buttonsQty = 1; + GUILayout.EndHorizontal(); + } +/* public static void BeginCenteredButtons() + { + GUILayout.BeginArea(new Rect(0f, 100f, 100f, 80f)); + GUILayout.FlexibleSpace(); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + } + public static void EndCenteredButtons() + { + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.EndArea(); + }*/ + } +} diff --git a/Scripts/Utilities/GuiLayoutExtras.cs.meta b/Scripts/Utilities/GuiLayoutExtras.cs.meta new file mode 100644 index 0000000..e595622 --- /dev/null +++ b/Scripts/Utilities/GuiLayoutExtras.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bcf4aacae7edb6a468d2cbb993831550 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/ImageGenerator.cs b/Scripts/Utilities/ImageGenerator.cs new file mode 100644 index 0000000..93e23d7 --- /dev/null +++ b/Scripts/Utilities/ImageGenerator.cs @@ -0,0 +1,423 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + public class ImageGenerator + { + //public static TextureHolder GetTextureHolderFromAlpha(TextureHolder tarTexture) + //{ + // return new TextureHolder(GetTextureFromAlpha(tarTexture.savedTexture.texture), tarTexture.savedName + "t"); + //} + public static string GetImageImportType(Texture2D tarTexture) + { + string assetPath = AssetDatabase.GetAssetPath(tarTexture); + var tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; + TextureImporterSettings importSettings = new TextureImporterSettings(); + if (tImporter != null) + { + tImporter.ReadTextureSettings(importSettings); + + if (importSettings.textureType == TextureImporterType.Lightmap) + return "lightmap"; + if (importSettings.textureType == TextureImporterType.NormalMap) + return "normal"; + } + return "default"; + } + public static bool HasAlphaInformation(Texture2D tarTexture) + { + MakeReadableTexture(tarTexture); + Color[] pixels = tarTexture.GetPixels(); + for (int i = 0; i < pixels.Length; i++) + { + if (pixels[i].a < .95f) + { + return true; + } + } + return false; + } + + public static Texture2D[] CreateMultiTextureFromHDR(Texture2D hdrTexture, int textureQty = 2) + { + MakeReadableTexture(hdrTexture); + Texture2D[] result = new Texture2D[textureQty]; + for (int i =0; i < textureQty; i++) + { + result[i] = new Texture2D(hdrTexture.width, hdrTexture.height); + Color[] pixels = hdrTexture.GetPixels(); + float min = i * (1f / textureQty); + Debug.Log(min); + //float max = min + (1 / textureQty); + Debug.Log(hdrTexture.GetPixel(3,3).r); + + for (int j = 0; j < pixels.Length; j++) + { + pixels[j].r = Mathf.Clamp01((pixels[j].r - min) * textureQty); + pixels[j].g = Mathf.Clamp01((pixels[j].g - min) * textureQty); + pixels[j].b = Mathf.Clamp01((pixels[j].b - min) * textureQty); + } + result[i].SetPixels(pixels); + result[i].Apply(); + } + return result; + } + + public static Texture2D CreateGLTFMetallicRoughness(Texture2D tarTexture, float metallicMultiplier, float smoothnessMultiplier, bool isKTX = false) + { + Debug.Log(smoothnessMultiplier); + MakeReadableTexture(tarTexture); + Texture2D result = new Texture2D(tarTexture.width, tarTexture.height); + Color[] pixels = tarTexture.GetPixels(); + // alpha is smoothness + // any color is metallic, we pick red + Debug.Log(pixels.Length); + if (!isKTX) + { + for (int i = 0; i < pixels.Length; i++) + { + pixels[i].g = 1f - (pixels[i].a * smoothnessMultiplier); + pixels[i].r = pixels[i].r * metallicMultiplier; + pixels[i].b = 0f; + pixels[i].a = 1f; + } + } + else + { + for (int i = 0; i < pixels.Length; i++) + { + pixels[i].g = 1f - (pixels[i].a * smoothnessMultiplier); + pixels[i].r = pixels[i].r * metallicMultiplier; + pixels[i].b = 0f; + pixels[i].a = 1f; + + //pixels[i].b = pixels[i].r * metallicMultiplier; + + //pixels[i].g = pixels[i].a * smoothnessMultiplier;//smoothness + } + + } + result.SetPixels(pixels); + return result; + } + public static Texture2D GetTextureFromAlpha(Texture2D tarTexture, bool inverse = false) + { + MakeReadableTexture(tarTexture); + Texture2D result = new Texture2D(tarTexture.width, tarTexture.height); + Color[] pixels = tarTexture.GetPixels(); + for (int i = 0; i < pixels.Length; i++) + { + if (!inverse) + pixels[i].r = pixels[i].g = pixels[i].b = pixels[i].a; + else + pixels[i].r = pixels[i].g = pixels[i].b = 1.0f - pixels[i].a; + } + result.SetPixels(pixels); + result.Apply(); + return result; + } + public static Texture2D InvertTextureColors(Texture2D tarTexture) + { + Texture2D result = new Texture2D(tarTexture.width, tarTexture.height); + Color[] pixels = tarTexture.GetPixels(); + for (int i = 0; i < pixels.Length; i++) + { + pixels[i].r = 1.0f - pixels[i].r; + pixels[i].r = 1.0f - pixels[i].g; + pixels[i].r = 1.0f - pixels[i].b; + } + result.SetPixels(pixels); + result.Apply(); + return result; + } + public static Texture2D GetTextureFromPixels(Color[] pixels, int sizeX, int SizeY, bool invWidth = false, bool invHeight = false) + { + Texture2D result = new Texture2D(sizeX, SizeY); + result.SetPixels(pixels); + + return InvertTexture(result, invWidth, invHeight); + + } + public static Texture2D InvertTexture(Texture2D texture, bool invWidth, bool invHeight) + { + if (texture == null) + return null; + if (!invWidth && !invHeight) + return texture; + + Color[] pixels = texture.GetPixels(); + Color[] invPixels = new Color[pixels.Length]; + if (invWidth && !invHeight)//corroborar + { + for (int i = 0; i < texture.height; i++) + { + for (int j = 0; j < texture.width; j++) + { + invPixels[(texture.width * (i + 1)) - j - 1] = pixels[(texture.width * i) + j]; + } + } + } + if (!invWidth && invHeight)//corroborar + { + for (int i = 0; i < texture.height; i++) + { + for (int j = 0; j < texture.width; j++) + { + + invPixels[((texture.height - i - 1) * texture.width) + j] = pixels[(texture.width * i) + j]; + } + } + } + if (invWidth && invHeight) + { + for (int i = 0; i < pixels.Length; i++) + { + invPixels[i] = pixels[pixels.Length - 1 - i]; + } + + } + Texture2D result = new Texture2D(texture.width, texture.height); + result.SetPixels(invPixels); + result.Apply(); + + return result; + + + } + + public static Texture2D GetTextureFromColor(Color tarColor, int sizeX, int sizeY, bool convertToLinear = false) + { + Texture2D result = new Texture2D(sizeX, sizeY); + if (convertToLinear) + tarColor = tarColor.linear; + Color[] pixels = new Color[sizeX * sizeY]; + for (int i = 0; i < pixels.Length; i ++) + pixels[i] = tarColor; + result.SetPixels(pixels); + result.Apply(); + + return result; + } + public static float SingleFloatFromAlpha(Texture2D tarTexture) // returns a float if all the alpha image has a single color + { + MakeReadableTexture(tarTexture); + Color[] pixels = tarTexture.GetPixels(); + float result = pixels[0].a; + for (int i = 0; i < pixels.Length; i++) + { + if (result != pixels[i].a) + { + result = -1f; + break; + } + } + return result; + } + public static float SinlgeFloatFromTexture(Texture2D tarTexture) // returns a float if all the red image has the same color, this is useful for black and white images (metal) + { + MakeReadableTexture(tarTexture); + Color[] pixels = tarTexture.GetPixels(); + float result = pixels[0].r; + float result2 = pixels[0].g; + float result3 = pixels[0].b; + for (int i = 0; i < pixels.Length; i++) + { + if (result != pixels[i].r) + { + result = -1f; + break; + } + if (result2 != pixels[i].g) + { + result = -1f; + break; + } + if (result3 != pixels[i].b) + { + result = -1f; + break; + } + } + return result; + } + + public static void MakeReadableTexture(Texture2D texture, bool uncompressed = true) + { + string assetPath = AssetDatabase.GetAssetPath(texture); + var tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; + bool changed = false; + if (tImporter != null) + { + if (uncompressed && tImporter.textureCompression != TextureImporterCompression.Uncompressed) + { + tImporter.textureCompression = TextureImporterCompression.Uncompressed; + changed = true; + } + if (!tImporter.isReadable || tImporter.maxTextureSize != 8192) + { + //tImporter.textureType = TextureImporterType.Default; + tImporter.isReadable = true; + tImporter.maxTextureSize = 8192; + changed = true; + + } + if (changed) + { + AssetDatabase.ImportAsset(assetPath); + AssetDatabase.Refresh(); + } + + } + } + public static void MakeReadableTexture(List textures, bool uncompressed = true, bool refresh = true) + { + bool changed = false; + for (int i =0; i < textures.Count; i++) { + string assetPath = AssetDatabase.GetAssetPath(textures[i]); + var tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; + + if (tImporter != null) + { + if (uncompressed && tImporter.textureCompression != TextureImporterCompression.Uncompressed) + { + tImporter.textureCompression = TextureImporterCompression.Uncompressed; + changed = true; + } + if (!tImporter.isReadable || tImporter.maxTextureSize != 8192) + { + //tImporter.textureType = TextureImporterType.Default; + tImporter.isReadable = true; + tImporter.maxTextureSize = 8192; + changed = true; + + } + if (changed) + { + AssetDatabase.ImportAsset(assetPath); + } + } + } + if (changed && refresh) + { + AssetDatabase.Refresh(); + } + } + + public static void MakeTextureTypeDefault(List textures, bool refresh = true) + { + for (int i = 0; i < textures.Count; i++) + { + string assetPath = AssetDatabase.GetAssetPath(textures[i]); + var tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; + if (tImporter != null) + { + if (tImporter.textureType != TextureImporterType.Default) + { + tImporter.textureType = TextureImporterType.Default; + AssetDatabase.ImportAsset(assetPath); + } + } + } + if (refresh) + AssetDatabase.Refresh(); + } + public static void RefreshDatabase() + { + AssetDatabase.Refresh(); + } + public static void MakeTextureTypeDefault(Texture2D texture) + { + string assetPath = AssetDatabase.GetAssetPath(texture); + var tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; + if (tImporter != null) + { + if (tImporter.textureType != TextureImporterType.Default) + { + tImporter.textureType = TextureImporterType.Default; + AssetDatabase.ImportAsset(assetPath); + AssetDatabase.Refresh(); + } + } + } + public static void MakeReadableCubemap(Cubemap texture) + { + string assetPath = AssetDatabase.GetAssetPath(texture); + var tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; + if (tImporter != null) + { + if (!tImporter.isReadable || tImporter.textureCompression != TextureImporterCompression.Uncompressed) + { + tImporter.isReadable = true; + tImporter.textureCompression = TextureImporterCompression.Uncompressed; + + AssetDatabase.ImportAsset(assetPath); + AssetDatabase.Refresh(); + } + } + } + + public static void MakeTextureTypeLightmap(Texture2D texture) + { + string assetPath = AssetDatabase.GetAssetPath(texture); + var tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; + if (tImporter != null) + { + bool changed = false; + if (tImporter.textureType != TextureImporterType.Lightmap) + { + tImporter.textureType = TextureImporterType.Lightmap; + changed = true; + } + if (!tImporter.isReadable) + { + tImporter.isReadable = true; + changed = true; + } + if (tImporter.textureCompression != TextureImporterCompression.Uncompressed) + { + tImporter.textureCompression = TextureImporterCompression.Uncompressed; + changed = true; + } + if (changed) + { + AssetDatabase.ImportAsset(assetPath); + AssetDatabase.Refresh(); + } + } + } + public static Color MultColor(Color color1, Color color2) + { + return new Color(color1.r * color2.r, color1.g * color2.g, color1.b * color2.b); + + } + public static Color ClampRangeColor(Color color) + { + Color result = new Color(MathExtraUtils.ClampRangeValue (color.r,0.2f,0.8f), + MathExtraUtils.ClampRangeValue (color.g, 0.2f, 0.8f), + MathExtraUtils.ClampRangeValue(color.b, 0.2f, 0.8f), + color.a); + return result; + } + + public static Texture2D CreateSimpleTexture(Color color, int size = 16) + { + Color[] pixels = new Color[Mathf.RoundToInt(Mathf.Pow(size, 2f))]; + for (int i = 0; i < pixels.Length; i++) + pixels[i] = color; + return GetTextureFromPixels(pixels, size, size); + } + public static Vector2 GetImageOriginalSize(Texture2D tarTexture) // widt/height + { + + Texture2D tmpTexture = new Texture2D(1, 1); + byte[] tmpBytes = System.IO.File.ReadAllBytes(StringUtilities.GetFullPathFromAsset(tarTexture)); + tmpTexture.LoadImage(tmpBytes); + Vector2 result = new Vector2(tmpTexture.width, tmpTexture.height); + Object.DestroyImmediate(tmpTexture); + return result; + } + + } +} diff --git a/Scripts/Utilities/ImageGenerator.cs.meta b/Scripts/Utilities/ImageGenerator.cs.meta new file mode 100644 index 0000000..3289905 --- /dev/null +++ b/Scripts/Utilities/ImageGenerator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 74613f02fdaaa8945ad3fd6ccf901a6c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/ImageUtilities.cs b/Scripts/Utilities/ImageUtilities.cs new file mode 100644 index 0000000..8f85dc6 --- /dev/null +++ b/Scripts/Utilities/ImageUtilities.cs @@ -0,0 +1,29 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + public class ImageUtilities + { + public static float GetImageMaxPixelFloatValue(Texture2D target_texture, float max_possible_value = 20f,bool is_lightmap = true) + { + if (is_lightmap) + ImageGenerator.MakeTextureTypeLightmap(target_texture); + Color[] allColors = target_texture.GetPixels(); + float maxVal = 0; + for (int i = 0; i < allColors.Length; i++) + { + if (allColors[i].r > maxVal) + maxVal = allColors[i].r; + if (allColors[i].g > maxVal) + maxVal = allColors[i].g; + if (allColors[i].b > maxVal) + maxVal = allColors[i].b; + } + if (maxVal > max_possible_value) + return max_possible_value; + return maxVal; + } + } +} diff --git a/Scripts/Utilities/ImageUtilities.cs.meta b/Scripts/Utilities/ImageUtilities.cs.meta new file mode 100644 index 0000000..361a54c --- /dev/null +++ b/Scripts/Utilities/ImageUtilities.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9295752449057354296b568fd94f56a9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/MathExtraUtils.cs b/Scripts/Utilities/MathExtraUtils.cs new file mode 100644 index 0000000..883e90e --- /dev/null +++ b/Scripts/Utilities/MathExtraUtils.cs @@ -0,0 +1,35 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WEBGL_EXPORTER +{ + public class MathExtraUtils + { + public static float ClampRangeValue(float value, float min, float max) + { + + float midVal = (min + max) / 2; // GET MIDDLE VALUE BETWEEN THE 2 NUMBERS + float differenceVal = ((midVal - min) + (max - midVal)) / 2; // VALUE TO BE ADDED OR SUBSTRACTED TO THE MID VALUE, UNTIL NOW WE HAVENT USED "VALUE" PROVIDED BY USER + float result = ((value - midVal) * differenceVal) / midVal; // RULE OF 3, TO GET THE RANGE VALUE (FROM -DIFFERENCEVAL TO +DIFFERENCEVAL) + result += midVal; + if (result < min) + result = min; + if (result > max) + result = max; + return result; + } + public static float DegreeToRadians(float degree) + { + return (degree * Mathf.Deg2Rad); + } + + public static float RoundFloat(float tarFloat, int decimals) + { + + float multiplier = Mathf.Pow(10, decimals); + Debug.Log(Mathf.Round(tarFloat * multiplier) * (1 / multiplier)); + return Mathf.Round(tarFloat * multiplier) * (1/multiplier); + } + } +} diff --git a/Scripts/Utilities/MathExtraUtils.cs.meta b/Scripts/Utilities/MathExtraUtils.cs.meta new file mode 100644 index 0000000..4708064 --- /dev/null +++ b/Scripts/Utilities/MathExtraUtils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 087e38ee45b843844a2677dabb61ef3a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/RenderTextureImageConverter.cs b/Scripts/Utilities/RenderTextureImageConverter.cs new file mode 100644 index 0000000..86893a8 --- /dev/null +++ b/Scripts/Utilities/RenderTextureImageConverter.cs @@ -0,0 +1,251 @@ +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; +using UnityEngine.Rendering; + +namespace WEBGL_EXPORTER +{ + public class RenderTextureImageConverter + { + private static GameObject renderTextureImageGen; + private static Camera ortoCam; + private static MeshRenderer planeMeshRenderer; + private static Material normalMapMaterial; + private static Material hdrMaterial; + private static Material basicMaterial; + + private static Vector3 initLocalScale; + public enum MaterialType { basic, hdr, normal }; + public static void InitializeRenderTexture() + { + string loc = ""; + if (!loc.EndsWith("/") || !loc.EndsWith("\\")) + loc += "/"; + if (RenderPipelineManager.currentPipeline == null)//standard + loc = PathPreferences.standardTextureGenerationMaterialFolder; + else + loc = PathPreferences.URPTextureGenerationMaterialFolder; //FOR NOW WILL EITHER BE URP OR STANDARD + renderTextureImageGen = GameObject.Instantiate((GameObject)AssetDatabase.LoadAssetAtPath(PathPreferences.renderTextureHolderPrefabPath, typeof(GameObject))); + ortoCam = renderTextureImageGen.GetComponent(); + planeMeshRenderer = renderTextureImageGen.GetComponentInChildren(); + initLocalScale = planeMeshRenderer.transform.localScale; + normalMapMaterial = AssetDatabase.LoadAssetAtPath(loc + PathPreferences.normalMapSimpleMaterialName, typeof(Material)) as Material; + hdrMaterial = AssetDatabase.LoadAssetAtPath(loc + PathPreferences.HDRSimpleMaterialName, typeof(Material)) as Material; + //basicMaterial = AssetDatabase.LoadAssetAtPath(loc + PathPreferences.basicSimpleMaterialName, typeof(Material)) as Material; + basicMaterial = AssetDatabase.LoadAssetAtPath(loc + PathPreferences.basicEditableMaterialName, typeof(Material)) as Material; + basicMaterial.EnableKeyword("_BaseMap"); + } + public static void TerminateRenderTexture() + { + GameObject.DestroyImmediate(renderTextureImageGen); + } + + public static void CreateDualTextureWithHDR(Texture2D texture, string base_name, string extra_name, string path, float shadow_multiply=1, float light_dim=1, int quality = 75) + { + hdrMaterial.SetFloat("_ShadowMultiplier", shadow_multiply); + hdrMaterial.SetFloat("_LightDim", light_dim); + planeMeshRenderer.sharedMaterial.SetInt("_GetShadow", 1); + CreateTextureWithRenderTexture(texture, base_name, path,MaterialType.hdr,quality); + planeMeshRenderer.sharedMaterial.SetInt("_GetShadow", 0); + CreateTextureWithRenderTexture(texture, extra_name, path, MaterialType.hdr, quality); + } + public static float CreateNormalizedHDR(Texture2D texture_hdr, string name, string path, int quality = 75, bool isLightmap = true, float saturate_compensation = 1.3f, float max_factor = 20, float contrast_modify = 1f, int textureSizeDivide = 1) + { + if (isLightmap) + ImageGenerator.MakeTextureTypeLightmap(texture_hdr); + planeMeshRenderer.sharedMaterial = hdrMaterial; + planeMeshRenderer.sharedMaterial.SetTexture("_BaseMap", texture_hdr); + planeMeshRenderer.sharedMaterial.SetFloat("_SaturateCompensation", saturate_compensation); + float _factor = ImageUtilities.GetImageMaxPixelFloatValue(texture_hdr, max_factor,true); + planeMeshRenderer.sharedMaterial.SetInt("_GetFactor256", 0); + planeMeshRenderer.sharedMaterial.SetFloat("_ScaleFactor",_factor); + planeMeshRenderer.sharedMaterial.SetFloat("_Contrast", contrast_modify); + CreateTextureWithRenderTexture(texture_hdr,name,path,MaterialType.hdr,quality,1, textureSizeDivide); + return _factor; + } + + //private static float GetMultiplyFactorOld(Texture2D hdr_texture, int max_factor, string name, string path, int quality = 75) + //{ + // if (ortoCam.targetTexture != null) + // { + // RenderTexture.active = null; + // ortoCam.targetTexture.Release(); + // } + + // RenderTexture renderTexture = new RenderTexture(hdr_texture.width, hdr_texture.height, 0); + // ortoCam.targetTexture = renderTexture; + + // if (hdr_texture.width == hdr_texture.height) + // planeMeshRenderer.gameObject.transform.localScale = initLocalScale; + + // float multiply = (float)hdr_texture.width / (float)hdr_texture.height; + // if (hdr_texture.height > hdr_texture.width) + // multiply = (float)hdr_texture.width / (float)hdr_texture.height; + + // planeMeshRenderer.gameObject.transform.localScale = new Vector3(initLocalScale.x * multiply, initLocalScale.y, initLocalScale.z); + + // ortoCam.Render(); + + // Texture2D final = new Texture2D(hdr_texture.width, hdr_texture.height); + // RenderTexture.active = renderTexture; + // final.ReadPixels(new Rect(0, 0, final.width, final.height), 0, 0); + // final.Apply(); + + + // FileExporter.ExportToJPEG(final, name, path, quality); + + // Color32[] allColors = final.GetPixels32(); + // float maxVal = 0; + // Debug.Log(allColors[57531].r); + // Debug.Log(allColors[0].r); + // int savei = 0; + // int incolor = 0; + // for (int i =0; i < allColors.Length;i++) + // { + // if (allColors[i].r > maxVal) + // { + // maxVal = allColors[i].r; + // incolor = 0; + // savei = i; + // } + // if (allColors[i].g > maxVal) + // { + // maxVal = allColors[i].g; + // incolor = 1; + // savei = i; + // } + // if (allColors[i].b > maxVal) + // { + // maxVal = allColors[i].b; + // incolor = 2; + // savei = i; + // } + // } + // Debug.Log(maxVal + " in " + savei + " in color " + incolor); + // float result = maxVal * 100f; + // if (result > max_factor) + // result = max_factor; + // if (ortoCam.targetTexture != null) + // { + // RenderTexture.active = null; + // ortoCam.targetTexture.Release(); + // } + + // return result; + + //} + public static void CreateTextureWithRenderTexture(Texture2D texture, string name, string path, MaterialType mat = MaterialType.basic,int quality = 75, float basicMaterialSaturation = 1f, int textureSizeDivide = 1, bool test = false) + { + + if (ortoCam.targetTexture != null) + { + RenderTexture.active = null; + ortoCam.targetTexture.Release(); + } + + // SET MATERIAL + if (mat == MaterialType.basic) + { + planeMeshRenderer.sharedMaterial = basicMaterial; + basicMaterial.SetTexture("_BaseMap", texture); + + //planeMeshRenderer.sharedMaterial.SetTexture("_BaseMap", texture as Texture2D); + + planeMeshRenderer.sharedMaterial.SetFloat("_Saturation", basicMaterialSaturation); + + } + + + if (mat == MaterialType.hdr) + { + planeMeshRenderer.sharedMaterial = hdrMaterial; + planeMeshRenderer.sharedMaterial.SetTexture("_BaseMap", texture); + } + else if (mat == MaterialType.normal) + { + planeMeshRenderer.sharedMaterial = normalMapMaterial; + planeMeshRenderer.sharedMaterial.SetTexture("_NormalTextureMap", texture); + } + + //SET MATERIAL ATTRIBUTES IN BASIC MATERIAL + + + //CREATE TEXTURE FROM RENDER TEXTURE + RenderTexture renderTexture = new RenderTexture(texture.width/ textureSizeDivide, texture.height/ textureSizeDivide, 0); + ortoCam.targetTexture = renderTexture; + + if (texture.width == texture.height) + { + planeMeshRenderer.gameObject.transform.localScale = initLocalScale; + } + + //Debug.Log("=== texture map dimensions === width: " + texture.width + " - height: " + texture.height + texture.name); + if (texture.width > texture.height) + { + float multiply = (float)(texture.width/ textureSizeDivide) / (float)(texture.height/ textureSizeDivide); + planeMeshRenderer.gameObject.transform.localScale = new Vector3 (initLocalScale.x * multiply, initLocalScale.y, initLocalScale.z); + } + if (texture.height > texture.width) + { + + float multiply = (float)(texture.width/ textureSizeDivide) / (float)(texture.height/ textureSizeDivide); + planeMeshRenderer.gameObject.transform.localScale = new Vector3(initLocalScale.x * multiply, initLocalScale.y, initLocalScale.z); + } + + ortoCam.Render(); + + Texture2D final = new Texture2D(texture.width/ textureSizeDivide, texture.height/ textureSizeDivide); + RenderTexture.active = renderTexture; + final.ReadPixels(new Rect(0, 0, final.width, final.height), 0, 0); + final.Apply(); + + FileExporter.ExportToJPEG(final, name, path, quality); + + + if (ortoCam.targetTexture != null) + { + RenderTexture.active = null; + ortoCam.targetTexture.Release(); + } + } + public static void MultiCreateTexturesFromHDRs(List HDRTextures, string prename, string texturesPath) + { + //Texture2D[] result = new Texture2D[HDRTextures.Length]; + if (HDRTextures.Count > 0) + { + //GameObject renderTextureImageGen = GameObject.Instantiate((GameObject)AssetDatabase.LoadAssetAtPath("Assets/MaquetaWEB/PrefabUtils/RenderTextureHolder.prefab", typeof(GameObject))); + //Camera ortoCam = renderTextureImageGen.GetComponent(); + //MeshRenderer planeMesh = renderTextureImageGen.GetComponentInChildren(); + + + + for (int i = 0; i < HDRTextures.Count; i++) + { + if (ortoCam.targetTexture != null) + { + RenderTexture.active = null; + ortoCam.targetTexture.Release(); + } + RenderTexture renderTexture = new RenderTexture(HDRTextures[i].width, HDRTextures[i].height, 0); + ortoCam.targetTexture = renderTexture; + ImageGenerator.MakeTextureTypeDefault(HDRTextures[i]); + planeMeshRenderer.sharedMaterial.SetTexture("_BaseMap", HDRTextures[i]); + ortoCam.Render(); + + Texture2D final = new Texture2D(HDRTextures[i].width, HDRTextures[i].height); + RenderTexture.active = renderTexture; + final.ReadPixels(new Rect(0, 0, final.width, final.height), 0, 0); + final.Apply(); + + FileExporter.ExportToJPEG(final, prename + i, texturesPath); + } + if (ortoCam.targetTexture != null) + { + RenderTexture.active = null; + ortoCam.targetTexture.Release(); + } + GameObject.DestroyImmediate(renderTextureImageGen); + } + } + } +} diff --git a/Scripts/Utilities/RenderTextureImageConverter.cs.meta b/Scripts/Utilities/RenderTextureImageConverter.cs.meta new file mode 100644 index 0000000..7c8a925 --- /dev/null +++ b/Scripts/Utilities/RenderTextureImageConverter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d26bc7b0a9d702c47ba5535d29bfa761 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/SphericalPanoramaToCubemapConverter.cs b/Scripts/Utilities/SphericalPanoramaToCubemapConverter.cs new file mode 100644 index 0000000..a1ba26f --- /dev/null +++ b/Scripts/Utilities/SphericalPanoramaToCubemapConverter.cs @@ -0,0 +1,96 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace WEBGL_EXPORTER +{ + public class SphericalPanoramaToCubemapConverter + { + public static Cubemap GetCubemapFromSceneSkybox(int face_size = 1024) + { + // instantiate a prefab containing the converter + GameObject sphericalToCubemapConverter = GameObject.Instantiate((GameObject)AssetDatabase.LoadAssetAtPath(PathPreferences.skyboxToCubemapPrefabPath, typeof(GameObject))); + + // size of each cubemap face + RenderTexture renderTexture = new RenderTexture(face_size, face_size, 0); + + // Get all cameras + Camera[] ortoCamArray = sphericalToCubemapConverter.GetComponentsInChildren(); + + // Create the Cubemap + Cubemap cm = new Cubemap(face_size, TextureFormat.RGBA32, false); + + for (int i = 0; i < ortoCamArray.Length; i++) + { + CubemapFace cubeFace = (CubemapFace)i; //0 = x+, 1 = x-, 2 = y+, 3 = y-, 4 = z+, 5 = z- + ortoCamArray[i].targetTexture = renderTexture; + ortoCamArray[i].Render(); + RenderTexture.active = renderTexture; + Texture2D finalTexture = new Texture2D(face_size, face_size); + finalTexture.ReadPixels(new Rect(0, 0, finalTexture.width, finalTexture.height), 0, 0); + finalTexture.Apply(); + cm.SetPixels(finalTexture.GetPixels(), cubeFace); + + // clear data use + GameObject.DestroyImmediate(finalTexture); + RenderTexture.active = null; + ortoCamArray[i].targetTexture.Release(); + } + cm.Apply(); + + GameObject.DestroyImmediate(sphericalToCubemapConverter); + return cm; + } + public static Cubemap GetCubemapFromSphericalPanorama(Texture2D tarTexture, int optionalSize = 0, bool _skybox = false) + { + + // instantiate a prefab containing the converter + GameObject sphericalToCubemapConverter = GameObject.Instantiate((GameObject)AssetDatabase.LoadAssetAtPath(PathPreferences.sphericalToCubemapPrefabPath, typeof(GameObject))); + + // get half size of the target panorama height texture + int textureSize = (int)tarTexture.height / 2; + if (optionalSize > 0) + textureSize = optionalSize; + RenderTexture renderTexture = new RenderTexture(textureSize, textureSize, 0); + + // Get all cameras + Camera[] ortoCamArray = sphericalToCubemapConverter.GetComponentsInChildren(); + + // Create the Cubemap + Cubemap cm = new Cubemap(textureSize,TextureFormat.RGBA32,false); + + Material sphereMat = sphericalToCubemapConverter.GetComponentInChildren().sharedMaterial; + sphereMat.SetTexture("_BaseMap",tarTexture); + sphereMat.mainTexture = tarTexture; + + for (int i = 0; i < ortoCamArray.Length; i++) + { + CubemapFace cubeFace = (CubemapFace)i; //0 = x+, 1 = x-, 2 = y+, 3 = y-, 4 = z+, 5 = z- + ortoCamArray[i].targetTexture = renderTexture; + ortoCamArray[i].Render(); + RenderTexture.active = renderTexture; + Texture2D finalTexture = new Texture2D(textureSize, textureSize); + finalTexture.ReadPixels(new Rect(0, 0, finalTexture.width, finalTexture.height), 0, 0); + finalTexture.Apply(); + cm.SetPixels(finalTexture.GetPixels(), cubeFace); + + // clear data use + GameObject.DestroyImmediate(finalTexture); + RenderTexture.active = null; + ortoCamArray[i].targetTexture.Release(); + } + cm.Apply(); + + GameObject.DestroyImmediate(sphericalToCubemapConverter); + return cm; + } + public static Texture2D[] GetCubemapTexturesFromSphericalPanorama(Texture2D tarTexture, int optionalSize = 0) //if tarSize = 0, it will take the height half + { + ImageGenerator.MakeReadableTexture(tarTexture); + Cubemap tempCubemap = GetCubemapFromSphericalPanorama(tarTexture,optionalSize); + return CubemapExtra.CreateCubemapTextures(tempCubemap); + } + + + } +} diff --git a/Scripts/Utilities/SphericalPanoramaToCubemapConverter.cs.meta b/Scripts/Utilities/SphericalPanoramaToCubemapConverter.cs.meta new file mode 100644 index 0000000..65db72f --- /dev/null +++ b/Scripts/Utilities/SphericalPanoramaToCubemapConverter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aa85a3b3b221f3b4b9b5c92acd558c82 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/StaticVariables.cs b/Scripts/Utilities/StaticVariables.cs new file mode 100644 index 0000000..922e2b0 --- /dev/null +++ b/Scripts/Utilities/StaticVariables.cs @@ -0,0 +1,34 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +namespace WEBGL_EXPORTER +{ + public class StaticVariables + { + //pending to change, move to preferences core interprika + + + public static bool exportHiddenInSceneObjects = true; + public static Vector3 THREEPositionModifier = new Vector3(-100f, 100f, 100f); // MODIFIER TO GET THE SAME POSITION THREE JS USES + public static float THREESizeModifier = 100f; + public static int sliceLastCharacterCount = 5; + public static bool combineGroups = true; + public static string actionablesVarName = "actionables"; + public static string lightmapNonStaticTextureName = "lmbasic"; + + public static float lightmapIntensityValue = 1f; + public static string lightmapNonStaticVarName = "lmn"; + public static int groupParentDigits = 3; + public static bool exportSimpleMaterial = false; + + // public static string clockDeltaName = "clockDelta"; + public static List stringListTempHolder; + + //SETUP + public static bool exportMayaCode = true; + public static string mayapyLocation = "C:/Program Files/Autodesk/Maya2019/bin/mayapy.exe"; + public static string wwwLocalFolder = "C:/wamp64/www/"; + //public static string + + } +} diff --git a/Scripts/Utilities/StaticVariables.cs.meta b/Scripts/Utilities/StaticVariables.cs.meta new file mode 100644 index 0000000..8c66718 --- /dev/null +++ b/Scripts/Utilities/StaticVariables.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3d9b2937ff226574285ee0bfd6dc8c75 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/StringUtilities.cs b/Scripts/Utilities/StringUtilities.cs new file mode 100644 index 0000000..aee5630 --- /dev/null +++ b/Scripts/Utilities/StringUtilities.cs @@ -0,0 +1,443 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using UnityEngine.SceneManagement; +using System.IO; +namespace WEBGL_EXPORTER +{ + public class StringUtilities : MonoBehaviour + { + public static string RemoveExtraChars(string code) + { + string result = code; + result = result.Replace("\n",""); + result = result.Replace(" ", ""); + + return result; + } + public static List GetNonRepeatingStringList(string addString, List existingList = null) + { + List result; + if (existingList == null) + { + result = new List(); + } + else + { + result = existingList; + } + // MAKE SURE WERE NOT ADDING AN EMPTY STRING TO THE ARRAY + if (addString != "") + { + bool repeat = false; + foreach (string s in result) + { + // IF WE FIND THE STRING ALREADY EXISTS, WE BREAK AND DONT ADD THIS STRING TO THE LIST + if (s == addString) + { + repeat = true; + break; + } + } + if (!repeat) + { + result.Add(addString); + } + } + return result; + } + public static string RemoveCharacterFromString(string tarString, int quantity, bool initChars = true) + { + string result = tarString; + if (initChars) + { + result = result.Substring(quantity); + } + else + { + if ((result.Length - quantity) >= 0) + { + result = result.Substring(0, result.Length - quantity); + } + else + { + Debug.LogWarning("Error while trying to remove last chars from string, please check"); + } + } + return result; + } + //public static string Vector3ToGLTFString(Vector3 vector3) + //{ + // return (-vector3.x).ToString() + "," + vector3.z.ToString() + "," + (-vector3.y).ToString(); + //} + public static string Vector3ToString(Vector3 vector3, bool multiply_static, float x_modif = 1f, float y_modif =1f, float z_modif =1f) + { + Vector3 finalVector3 = CleanVector3(vector3); + if (multiply_static) + finalVector3 = new Vector3(vector3.x * StaticVariables.THREEPositionModifier.x, vector3.y * StaticVariables.THREEPositionModifier.y, vector3.z * StaticVariables.THREEPositionModifier.z); + //if (negativeZ) + //finalVector3 = new Vector3(finalVector3.x, finalVector3.y, finalVector3.z); + return (finalVector3.x * x_modif).ToString() + "," + (finalVector3.y * y_modif).ToString() + "," + (finalVector3.z * z_modif).ToString(); + } + public static string QuaternionToString(Quaternion quaternion, bool unity_to_threejs_quaternion = false) + { + quaternion = CleanQuaternion(quaternion); //make siure to remove exponentional floats + if (!unity_to_threejs_quaternion) + return quaternion.x.ToString() + "," + quaternion.y.ToString() + "," + quaternion.z.ToString() + "," + quaternion.w.ToString(); + else + return quaternion.w.ToString() + "," + quaternion.x.ToString() + "," + quaternion.y.ToString() + "," + quaternion.z.ToString(); + } + private static Vector3 CleanVector3(Vector3 tar_vector3) + { + return new Vector3(CleanFloat(tar_vector3.x), CleanFloat(tar_vector3.y), CleanFloat(tar_vector3.z)); + } + private static Quaternion CleanQuaternion(Quaternion tar_quaternion) + { + return new Quaternion(CleanFloat(tar_quaternion.x), CleanFloat(tar_quaternion.y), CleanFloat(tar_quaternion.z), CleanFloat(tar_quaternion.w)); + } + private static float CleanFloat(float tar_float) + { + if (tar_float < 0.00001f && tar_float > -0.00001f) + { + return 0; + } + return tar_float; + } + public static string Vector2ToString(Vector2 vector2, bool THREEVector2) + { + Vector2 finalVector2 = vector2; + if (THREEVector2) + finalVector2 = new Vector3(vector2.x * StaticVariables.THREEPositionModifier.x, vector2.y * StaticVariables.THREEPositionModifier.y); + return finalVector2.x.ToString() + "," + finalVector2.y.ToString(); + } + public static string Vector3RotationToString(Vector3 vector3) //CHECAR!!!, NO ESTOY SEGURO SI LOS 3 VALORES SON NEGATIVOS!! + { + Vector3 finalVector3 = new Vector3(-(vector3.x * 3.1416f / 180f), -(vector3.y * 3.1416f / 180f), -(vector3.z * 3.1416f / 180f)); + return finalVector3.x.ToString() + "," + finalVector3.y.ToString() + "," + finalVector3.z.ToString(); + + } + public static string FloatRotationToThreeString(float value) + { + return (value * 3.1416f / 180f).ToString(); + } + public static string DegreeToRadians(float degree) + { + return (degree * 3.1416f / 180f).ToString("F3"); + } + + //ARRAYS TO STRING + public static string ArrayToString(int[] int_values) + { + string result = ""; + if (int_values != null) + { + foreach(int i in int_values) + { + result += i + ","; + } + result = RemoveCharacterFromString(result, 1, false); + } + return result; + } + public static string ArrayToString(List int_values) + { + string result = ""; + if (int_values != null) + { + foreach (int i in int_values) + { + result += i + ","; + } + result = RemoveCharacterFromString(result, 1, false); + } + return result; + } + public static string ArrayToString(float[] float_values) + { + string result = ""; + if (float_values != null) + { + foreach (float f in float_values) + { + result += f + ","; + } + result = RemoveCharacterFromString(result, 1, false); + } + return result; + } + public static string ArrayToString(List float_values) + { + string result = ""; + if (float_values != null) + { + foreach (float f in float_values) + { + result += f + ","; + } + result = RemoveCharacterFromString(result, 1, false); + } + return result; + } + public static string ArrayToString(List string_values, bool with_quotes = true) + { + string result = ""; + if (string_values != null) + { + foreach (string s in string_values) + { + if (with_quotes) result += "\""; + result += s; + if (with_quotes) result += "\""; + result += ","; + } + result = RemoveCharacterFromString(result, 1, false); + } + return result; + } + public static string GetSafeChars(string tarString) + { + string result = tarString.Replace("\\","\\\\").Replace("\"", "\\\""); + return result; + } + public static string ArrayToString(string[] string_values, bool with_quotes = true) + { + string result = ""; + if (string_values != null) + { + foreach (string s in string_values) + { + if (with_quotes) result += "\""; + result += s; + if (with_quotes) result += "\""; + result += ","; + } + result = RemoveCharacterFromString(result, 1, false); + } + return result; + } + + //END ARRAYS TO STRING + + public static string GetRandomUuid() + { + string result = ""; + for (int i = 0; i < 8; i++) + { + result += GetRandomChar(); + } + result += "-"; + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 4; j++) + { + result += GetRandomChar(); + } + result += "-"; + } + for (int i = 0; i < 12; i++) + { + result += GetRandomChar(); + } + return result; + } + public static char GetRandomChar() + { + string st = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + char c = st[Random.Range(0, st.Length)]; + return c; + } + public static string GetSeparatedString(string targetString, string separationString, bool getFirstString = true) + { + string[] splitCode = targetString.Split(new string[] { separationString }, System.StringSplitOptions.None); + if (getFirstString) + { + return splitCode[0]; + } + else + { + return splitCode[splitCode.Length - 1]; + } + } + + public static string GetFolderNameFromSubfolder(string tarPath) + { + string correctPath = tarPath.Replace("\\","/"); + if (correctPath.EndsWith("/")) + { + correctPath = StringUtilities.RemoveCharacterFromString(correctPath, 1, false); + } + return StringUtilities.GetSeparatedString(correctPath, "/", false); + } + public static string GetFolderNameFromFile(string tarPath) + { + return Path.GetDirectoryName(tarPath); + } + public static string GetFileNameFromPath(string tarPath) + { + string correctPath = tarPath.Replace("\\", "/"); + string fileName = StringUtilities.GetSeparatedString(correctPath, "/", false); + return StringUtilities.GetSeparatedString(fileName,"."); + } + public static string GetFullPathFromAsset(Object tarObject) + { + string result = ""; + result = Application.dataPath + StringUtilities.RemoveCharacterFromString(AssetDatabase.GetAssetPath(tarObject), 6); + //Debug.Log(result); + return result; + } + public static string[] GetSubfoldersPathsFromFolder(string tarFolder, bool isLocal = true, bool returnLocalFolders = true, bool getSubfolders = false) + { + if (isLocal) + tarFolder = StringUtilities.GetFullPathFromLocalPath(tarFolder); + + SearchOption so = SearchOption.TopDirectoryOnly; + if (getSubfolders) + so = SearchOption.AllDirectories; + string[] result = Directory.GetDirectories(tarFolder, "*", so); + if (returnLocalFolders) + for (int i = 0; i < result.Length; i++) + { + result[i] = "Assets" + result[i].Substring(Application.dataPath.Length); + } + + return result; + } + public static string[] GetFilesPathFromFolder(string tarFolder, bool isLocal, string extension = "",bool returnLocalFolder = false ,bool getFilesFromSubdirectories = false) + { + string searchLocation = tarFolder; +/* if (!searchLocation.EndsWith("/")) + searchLocation += "/";*/ + if (isLocal) + searchLocation = Application.dataPath + StringUtilities.RemoveCharacterFromString(tarFolder, 6); + + if (Directory.Exists(searchLocation)) + { + string[] allFilesPath; + if (getFilesFromSubdirectories) + allFilesPath = Directory.GetFiles(searchLocation, "*" + extension + "*", SearchOption.AllDirectories); + else + allFilesPath = Directory.GetFiles(searchLocation, "*" + extension + "*", SearchOption.TopDirectoryOnly); + + if (extension != "") + { + List filesList = new List(); + foreach (string st in allFilesPath) + { + if (st.ToLower().EndsWith("." + extension.ToLower())) + filesList.Add(st); + } + + string[] result = new string[filesList.Count]; + for (int i = 0; i < filesList.Count; i++) + { + if (returnLocalFolder) + result[i] = "Assets" + StringUtilities.GetSeparatedString(filesList[i], Application.dataPath, false); + else + result[i] = filesList[i]; + } + return result; + } + else + { + if (returnLocalFolder) + { + for (int i = 0; i < allFilesPath.Length; i++) + { + allFilesPath[i] = "Assets" + StringUtilities.GetSeparatedString(allFilesPath[i], Application.dataPath, false); + } + } + + return allFilesPath; + } + } + else + { + Debug.Log("directory does not exists: " + tarFolder); + return null; + } + } + /// + /// Returns the local path starting with "Assets" + /// + /// + /// + public static string GetLocalPathFromFullPath(string fullPath) + { + string result = "Assets" + StringUtilities.GetSeparatedString(fullPath, Application.dataPath, false); + return result; + } + public static string GetFullPathFromLocalPath(string localPath) + { + //string result = "Assets" + StringUtilities.GetSeparatedString(fullPath, Application.dataPath, false); + string result = StringUtilities.RemoveCharacterFromString(Application.dataPath,6,false) + localPath; + return result; + } + public static string GetExtensionFromFile(string filePath) + { + if (!filePath.Contains(".")) + return ""; + return GetSeparatedString(filePath, ".",false); + } + public static string GetExtensionFromObjectAsset(Object obj) + { + + if (obj == null) + return ""; + + return GetSeparatedString(AssetDatabase.GetAssetPath(obj), ".", false); + } + public static string RemoveExtensionFromFile(string filePath) + { + return StringUtilities.GetSeparatedString(filePath, ".", true); + } + public static string GetParentFolderPathFromPath(string tarPath) + { + string correctPath = tarPath.Replace("\\", "/"); + if (correctPath.EndsWith("/")) + correctPath = StringUtilities.RemoveCharacterFromString(correctPath, 1, false); + + string[] splitStringResult = correctPath.Split('/'); + string result = ""; + for(int i = 0; i < splitStringResult.Length - 1; i++) + { + result += splitStringResult[i]; + if (i != splitStringResult.Length - 2) + result += "/"; + } + return result; + } + // require objects + public static string GetCurrentScenePath(bool localpath = true,bool removeExtension = false, bool removeAssetsString = false) + { + string result = SceneManager.GetActiveScene().path; + if (removeExtension) + result = RemoveCharacterFromString(result, 6,false); // remove .unity extension (".unity" = 6 characters) + if (!localpath) + return GetFullPathFromLocalPath(result); // if a full path is required, we cant remove "Assets/" string + + if (removeAssetsString) + result = RemoveCharacterFromString(result, 7); // remove .unity extension ("assets/" = 7 characters) + return result; + } + public static string GetStringJsonLegal(string tarString) + { + char[] replaceChars = { '\\', '`','\'', 'ñ','"' }; + foreach (char c in replaceChars) + { + tarString = tarString.Replace(c, '_'); + } + return tarString.ToLower(); + } + public static string GetStringWithLegalCharacters(string tarString) + { + char[] replaceChars = { '\\', '`', '*', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '$', '\'',' ', 'ñ',';',':','/',',','@','"'}; + foreach (char c in replaceChars) + { + tarString = tarString.Replace(c, '_'); + } + return tarString.ToLower(); + } + + } +} diff --git a/Scripts/Utilities/StringUtilities.cs.meta b/Scripts/Utilities/StringUtilities.cs.meta new file mode 100644 index 0000000..a44e717 --- /dev/null +++ b/Scripts/Utilities/StringUtilities.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 94d0fcd1775c9eb4d8d4d4cf80a5880e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/TextureScaler.cs b/Scripts/Utilities/TextureScaler.cs new file mode 100644 index 0000000..f47eafe --- /dev/null +++ b/Scripts/Utilities/TextureScaler.cs @@ -0,0 +1,73 @@ +using UnityEngine; + +/// A unility class with functions to scale Texture2D Data. +/// +/// Scale is performed on the GPU using RTT, so it's blazing fast. +/// Setting up and Getting back the texture data is the bottleneck. +/// But Scaling itself costs only 1 draw call and 1 RTT State setup! +/// WARNING: This script override the RTT Setup! (It sets a RTT!) +/// +/// Note: This scaler does NOT support aspect ratio based scaling. You will have to do it yourself! +/// It supports Alpha, but you will have to divide by alpha in your shaders, +/// because of premultiplied alpha effect. Or you should use blend modes. +public class TextureScaler +{ + + /// + /// Returns a scaled copy of given texture. + /// + /// Source texure to scale + /// Destination texture width + /// Destination texture height + /// Filtering mode + public static Texture2D scaled(Texture2D src, int width, int height, FilterMode mode = FilterMode.Trilinear) + { + Rect texR = new Rect(0, 0, width, height); + _gpu_scale(src, width, height, mode); + + //Get rendered data back to a new texture + Texture2D result = new Texture2D(width, height, TextureFormat.ARGB32, true); + result.Reinitialize(width, height); + result.ReadPixels(texR, 0, 0, true); + return result; + } + + /// + /// Scales the texture data of the given texture. + /// + /// Texure to scale + /// New width + /// New height + /// Filtering mode + public static void scale(Texture2D tex, int width, int height, FilterMode mode = FilterMode.Trilinear) + { + Rect texR = new Rect(0, 0, width, height); + _gpu_scale(tex, width, height, mode); + + // Update new texture + tex.Reinitialize(width, height); + tex.ReadPixels(texR, 0, 0, true); + tex.Apply(true); //Remove this if you hate us applying textures for you :) + } + + // Internal unility that renders the source texture into the RTT - the scaling method itself. + static void _gpu_scale(Texture2D src, int width, int height, FilterMode fmode) + { + //We need the source texture in VRAM because we render with it + src.filterMode = fmode; + src.Apply(true); + + //Using RTT for best quality and performance. Thanks, Unity 5 + RenderTexture rtt = new RenderTexture(width, height, 32); + + //Set the RTT in order to render to it + Graphics.SetRenderTarget(rtt); + + //Setup 2D matrix in range 0..1, so nobody needs to care about sized + GL.LoadPixelMatrix(0, 1, 1, 0); + + //Then clear & draw the texture to fill the entire RTT. + GL.Clear(true, true, new Color(0, 0, 0, 0)); + Graphics.DrawTexture(new Rect(0, 0, 1, 1), src); + } +} \ No newline at end of file diff --git a/Scripts/Utilities/TextureScaler.cs.meta b/Scripts/Utilities/TextureScaler.cs.meta new file mode 100644 index 0000000..be5aadf --- /dev/null +++ b/Scripts/Utilities/TextureScaler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 218f1ad98f12012468761ad6a1bdc40c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/TransformUtilities.cs b/Scripts/Utilities/TransformUtilities.cs new file mode 100644 index 0000000..d8cde9a --- /dev/null +++ b/Scripts/Utilities/TransformUtilities.cs @@ -0,0 +1,48 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TransformUtilities { + /// + /// Converts target unity matrix to gltf matrix + /// + /// + /// + public static Matrix4x4 GetGLTFMatrix(Matrix4x4 targetMatrix) + { + // MODIFY THE MATRIX TO HAVE NEGATIVE Z IN TRANSLATION AND X,Y ROTATION NEGATIVE + + //return new Matrix4x4(new Vector4(targetMatrix.m00, targetMatrix.m01, -targetMatrix.m02, targetMatrix.m03), + // new Vector4(targetMatrix.m10, targetMatrix.m11, -targetMatrix.m12, targetMatrix.m13), + // new Vector4(-targetMatrix.m20, -targetMatrix.m21, targetMatrix.m22, -targetMatrix.m23), + // new Vector4(targetMatrix.m30, targetMatrix.m31, targetMatrix.m32, targetMatrix.m33)); + + + Matrix4x4 result = new Matrix4x4(new Vector4(targetMatrix.m00, targetMatrix.m10, -targetMatrix.m20, targetMatrix.m30), + new Vector4(targetMatrix.m01, targetMatrix.m11, -targetMatrix.m21, targetMatrix.m31), + new Vector4(-targetMatrix.m02, -targetMatrix.m12, targetMatrix.m22, targetMatrix.m32), + new Vector4(targetMatrix.m03, targetMatrix.m13, -targetMatrix.m23, targetMatrix.m33)); + + return result; + + //Matrix4x4 result = new Matrix4x4(new Vector4(targetMatrix.m00, targetMatrix.m10, -targetMatrix.m20, targetMatrix.m30), + // new Vector4(targetMatrix.m01, targetMatrix.m11, -targetMatrix.m21, targetMatrix.m31), + // new Vector4(-targetMatrix.m02, -targetMatrix.m12, targetMatrix.m22, targetMatrix.m32), + // new Vector4(targetMatrix.m03, targetMatrix.m13, -targetMatrix.m23, targetMatrix.m33)); + + //return result; + + //return new Matrix4x4(new Vector4(result.m00, result.m01, result.m02, result.m03), + // new Vector4(result.m10, result.m11, result.m12, result.m13), + // new Vector4(result.m20, result.m21, result.m22, result.m23), + // new Vector4(result.m30, result.m31, result.m32, result.m33)); + + + //return result; + + } + //public static Matrix4x4 GetRelativeMatrix(Matrix4x4 targetMatrix) + //{ + + //} +} diff --git a/Scripts/Utilities/TransformUtilities.cs.meta b/Scripts/Utilities/TransformUtilities.cs.meta new file mode 100644 index 0000000..9701c7a --- /dev/null +++ b/Scripts/Utilities/TransformUtilities.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 121bc29256d456a4daabc289392978fb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/VectorUtilities.cs b/Scripts/Utilities/VectorUtilities.cs new file mode 100644 index 0000000..e62ece6 --- /dev/null +++ b/Scripts/Utilities/VectorUtilities.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +namespace WEBGL_EXPORTER +{ + public class VectorUtilities + { + public static Vector3 addVectors3(Vector3 v1, Vector3 v2) + { + return new Vector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); + } + public static Vector3 multVector3(Vector3 v1, Vector3 v2) + { + return new Vector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); + } + } +} diff --git a/Scripts/Utilities/VectorUtilities.cs.meta b/Scripts/Utilities/VectorUtilities.cs.meta new file mode 100644 index 0000000..0ef5286 --- /dev/null +++ b/Scripts/Utilities/VectorUtilities.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 79962e6dfb60f224294a2bc8fd85ba84 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Utilities/WriteToBinaryUtilities.cs b/Scripts/Utilities/WriteToBinaryUtilities.cs new file mode 100644 index 0000000..c1fbb6b --- /dev/null +++ b/Scripts/Utilities/WriteToBinaryUtilities.cs @@ -0,0 +1,224 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System.IO; +using WEBGL_EXPORTER.GLTF; +namespace WEBGL_EXPORTER +{ + public class WriteToBinaryUtilities + { + private static BinaryWriter writer; + private static int byteLength; + public static void OpenNewBinaryFile(string fileName, string filePath, string extension = "bin") + { + if (!filePath.EndsWith("/")) + filePath += "/"; + writer = new BinaryWriter(File.Open(filePath + fileName + "." + extension, FileMode.Create)); + byteLength = 0; + } + public static void WriteBinaryWithComponentType() + { + + } + // UNSIGNED SHORT + public static void WriteUnsignedShorts(uint [] uintArray) + { + byteLength += uintArray.Length * 2; + foreach (uint i in uintArray) + { + + writer.Write((ushort)i); + } + } + public static void WriteUnsignedShorts(int[] intArray) + { + byteLength += intArray.Length * 2; //ushorts are made of 2 bytes + foreach (int i in intArray) + { + writer.Write((ushort)i); + } + } + // END USIGNED SHORT + // UNSIGNED BYTE + public static void WriteUnsignedBytes(uint[] uintArray) + { + byteLength += uintArray.Length; + foreach (uint i in uintArray) + { + + writer.Write((byte)i); + } + } + public static void WriteUnsignedBytes(int[] intArray) + { + byteLength += intArray.Length; //bytes are made of 1 bytes + foreach (int i in intArray) + { + writer.Write((byte)i); + } + } + // END USIGNED BYTE + // FLOATS + public static void WriteFloats(float[] floatArray) + { + byteLength += floatArray.Length * 4; + foreach (float i in floatArray) + { + writer.Write(i); + } + } + // END FLOATS + // FLOATS + public static void WriteInts(int[] intArray) + { + byteLength += intArray.Length * 4; + foreach (float i in intArray) + { + writer.Write(i); + } + } + // END FLOATS + // MATRIX + public static void WriteMatrix4(Matrix4x4[] matrix_4s) + { + Debug.Log("CHECK HERE IF SAVING CORRECTLY THE MATRIX"); + byteLength += matrix_4s.Length * 64; //float are made of 4 bytes, and matrices are made of 16 float (16*4 = 64) + foreach (Matrix4x4 m4 in matrix_4s) + { + writer.Write(m4.m00); writer.Write(m4.m10); writer.Write(m4.m20); writer.Write(m4.m30); + writer.Write(m4.m01); writer.Write(m4.m11); writer.Write(m4.m21); writer.Write(m4.m31); + writer.Write(m4.m02); writer.Write(m4.m12); writer.Write(m4.m22); writer.Write(m4.m32); + writer.Write(m4.m03); writer.Write(m4.m13); writer.Write(m4.m23); writer.Write(m4.m33); + } + + } + // VECTORS + public static void WriteVector4(Vector4[] vectors, ComponentType component_type = ComponentType.FLOAT) + { + if (component_type == ComponentType.FLOAT || component_type == ComponentType.NONE_SET) + { + byteLength += vectors.Length * 16; //float are made of 4 bytes, and vectors are made of 3 float (3*4 = 12) + foreach (Vector4 v4 in vectors) + { + writer.Write(v4.x); + writer.Write(v4.y); + writer.Write(v4.z); + writer.Write(v4.w); + } + } + if (component_type == ComponentType.UNSIGNED_SHORT || component_type == ComponentType.SHORT) + { + byteLength += vectors.Length * 8; //ushorts are made of 2 bytes, and vectors are made of 4 float (4*2 = 8) + foreach (Vector4 v4 in vectors) + { + //Debug.Log("vertex"); + writer.Write((ushort)v4.x); + writer.Write((ushort)v4.y); + writer.Write((ushort)v4.z); + writer.Write((ushort)v4.w); + } + } + if (component_type == ComponentType.UNSIGNED_BYTE || component_type == ComponentType.BYTE) + { + byteLength += vectors.Length * 4; //bytes are made of 1 bytes, and vectors are made of 4 float (4*1 = 4) + foreach (Vector4 v4 in vectors) + { + //Debug.Log("normal"); + writer.Write((byte)v4.x); + writer.Write((byte)v4.y); + writer.Write((byte)v4.z); + writer.Write((byte)v4.w); + } + } + } + public static void WriteVector3(Vector3[] vectors, ComponentType component_type = ComponentType.FLOAT) + { + if (component_type == ComponentType.FLOAT || component_type == ComponentType.NONE_SET) + { + byteLength += vectors.Length * 12; //float are made of 4 bytes, and vectors are made of 3 float (3*4 = 12) + foreach (Vector3 v3 in vectors) + { + writer.Write(v3.x); + writer.Write(v3.y); + writer.Write(v3.z); + } + } + if (component_type == ComponentType.UNSIGNED_SHORT || component_type == ComponentType.SHORT) + { + byteLength += vectors.Length * 8; //ushorts are made of 2 bytes, and vectors are made of 3 float (3*2 = 6) + 2 to keep boundary of 4 + foreach (Vector3 v3 in vectors) + { + //Debug.Log("vertex"); + writer.Write((ushort)v3.x); + writer.Write((ushort)v3.y); + writer.Write((ushort)v3.z); + WriteEmptyDuo(); + } + } + if (component_type == ComponentType.UNSIGNED_BYTE || component_type == ComponentType.BYTE) + { + byteLength += vectors.Length * 4; //bytes are made of 1 bytes, and vectors are made of 3 float (3*1 = 3) + 1 to keep boundary of 4 + foreach (Vector3 v3 in vectors) + { + //Debug.Log("normal"); + writer.Write((byte)v3.x); + writer.Write((byte)v3.y); + writer.Write((byte)v3.z); + WriteEmptySingle(); //keep boundary of 4 + } + } + } + public static void WriteVector2(Vector2[] vectors, ComponentType component_type = ComponentType.FLOAT) + { + if (component_type == ComponentType.FLOAT || component_type == ComponentType.NONE_SET) + { + byteLength += vectors.Length * 8; //float are made of 4 bytes, and vectors are made of 3 float (2*4 = 8) + foreach (Vector2 v2 in vectors) + { + writer.Write(v2.x); + writer.Write(v2.y); + } + } + if (component_type == ComponentType.UNSIGNED_SHORT || component_type == ComponentType.SHORT) + { + byteLength += vectors.Length * 4; //ushorts are made of 2 bytes, and vectors are made of 2 float (2*2 = 4) + foreach (Vector2 v2 in vectors) + { + writer.Write((ushort)v2.x); + writer.Write((ushort)v2.y); + } + } + if (component_type == ComponentType.UNSIGNED_BYTE || component_type == ComponentType.BYTE) + { + byteLength += vectors.Length * 2; //bytes are made of 1 bytes, and vectors are made of 2 float (2*1 = 2) + foreach (Vector2 v2 in vectors) + { + writer.Write((byte)v2.x); + writer.Write((byte)v2.y); + } + } + + } + // SPACING + public static void WriteEmptySingle(int qty = 1) + { + for (int i = 0; i < qty; i++) + { + writer.Write((byte)0); + } + } + public static void WriteEmptyDuo() + { + writer.Write((short)0); + } + public static int GetByteLenght() + { + return byteLength; + } + public static void CloseBinaryFile() + { + + writer.Close(); + } + } +} diff --git a/Scripts/Utilities/WriteToBinaryUtilities.cs.meta b/Scripts/Utilities/WriteToBinaryUtilities.cs.meta new file mode 100644 index 0000000..24a6d77 --- /dev/null +++ b/Scripts/Utilities/WriteToBinaryUtilities.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c15f5f10f39bbe642b9006c318fad116 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: