diff options
| author | Bryan Galdrikian <[email protected]> | 2017-02-24 09:32:20 -0800 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-02-24 09:32:20 -0800 |
| commit | e1bf674c16e3c8472b29574159c789cd3f0c64e0 (patch) | |
| tree | 9f0cfce09c71a2c27ff19589fcad6cd83504477c /tools/ArtistTools/source/CoreLib/Utils | |
| parent | first commit (diff) | |
| download | blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.tar.xz blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.zip | |
Updating to [email protected] and [email protected] with a new directory structure.
NvBlast folder is gone, files have been moved to top level directory. README is changed to reflect this.
Diffstat (limited to 'tools/ArtistTools/source/CoreLib/Utils')
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Automate.cpp | 530 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Automate.h | 23 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/CoreLibUtils.h | 65 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/MathUtil.cpp | 327 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/MathUtil.h | 557 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Profiler.cpp | 82 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Profiler.h | 51 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Settings.cpp | 767 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Settings.h | 392 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Stats.cpp | 76 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Stats.h | 54 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Timer.cpp | 80 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/Timer.h | 68 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/ViewerOutput.cpp | 75 | ||||
| -rw-r--r-- | tools/ArtistTools/source/CoreLib/Utils/ViewerOutput.h | 136 |
15 files changed, 3283 insertions, 0 deletions
diff --git a/tools/ArtistTools/source/CoreLib/Utils/Automate.cpp b/tools/ArtistTools/source/CoreLib/Utils/Automate.cpp new file mode 100644 index 0000000..6c7d551 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Automate.cpp @@ -0,0 +1,530 @@ +#include <windows.h> + +#include <QtWidgets/QApplication> + +#include "AppMainWindow.h" +//#include "SimpleScene.h" + +#include "OpenAutomate.h" +#include "Automate.h" +#include "Settings.h" + +//#define OPEN_CONSOLE +#ifdef OPEN_CONSOLE +#include <Windows.h> +#endif + +#include <cassert> +#include <string> + +#include <Nv/Common/NvCoCommon.h> + +#define KEYSTR ("Software\\OpenAutomate\\RegisteredApps\\NVIDIA\\FurViewer\\v1.0\\") + +const oaChar *Benchmarks[] = { + "HairBall", + "Teapot", + "Manjaladon", + "WitcherHorse", + NV_NULL +}; +oaInt NumBenchmarks = 1; + +static void ParseArgs(int argc, char *argv[]); + +static void OAMainLoop(const char *opt); +static bool RegisterAppItself(); +static int RunApp(QApplication& a); +static void GetAllOptions(void); +static void GetCurrentOptions(void); + +static bool g_isAutomateMode = false; +static int InstallModeFlag = 0; +static char *OAOpt = NV_NULL; + +bool AutomateInstallApp() +{ + return RegisterAppItself(); +} + +static bool RegisterAppItself() +{ + char exePath[MAX_PATH]; + if(!GetExePath(exePath)) + { + fprintf(stderr, "Cannot get exe path\r\n"); + return false; + } + + HKEY hKey; + DWORD dwRes = RegOpenKeyExA( + HKEY_LOCAL_MACHINE, + KEYSTR, + 0, + KEY_WRITE | KEY_READ, + &hKey); + + DWORD dwSize = MAX_PATH; + char buf[MAX_PATH]; + if(dwRes == ERROR_SUCCESS) + { + dwRes = RegQueryValueExA( + hKey, + "INSTALL_ROOT_PATH", + NV_NULL, + NV_NULL, + (LPBYTE)buf, + &dwSize); + if(dwRes == ERROR_SUCCESS && !lstrcmpiA(buf, exePath)) + { + RegCloseKey(hKey); + return true; + } + } + else + { + dwRes = RegCreateKeyExA( + HKEY_LOCAL_MACHINE, + KEYSTR, + 0, + NV_NULL, + REG_OPTION_NON_VOLATILE, + KEY_WRITE, NV_NULL, + &hKey, + &dwSize); + if(ERROR_SUCCESS != dwRes) + { + RegCloseKey(hKey); + return false; + } + } + + bool bRet = false; + do + { + dwRes = RegSetValueExA( + hKey, + "INSTALL_ROOT_PATH", + 0, + REG_SZ, + (BYTE*)exePath, + (DWORD)strlen(exePath)); + if(ERROR_SUCCESS != dwRes) + { + fprintf(stderr, "Write INSTALL_ROOT_PATH Failed\r\n"); + break; + } + +#ifdef _WIN64 +#ifdef _DEBUG + strcat(exePath, "FurViewer.win64.D.exe"); +#else + strcat(exePath, "FurViewer.win64.exe"); +#endif +#else +#ifdef _DEBUG + strcat(exePath, "FurViewer.win32.D.exe"); +#else + strcat(exePath, "FurViewer.win32.exe"); +#endif +#endif + + dwRes = RegSetValueExA( + hKey, + "ENTRY_EXE", + 0, + REG_SZ, + (BYTE*)exePath, + (DWORD)strlen(exePath)); + if(ERROR_SUCCESS != dwRes) + { + fprintf(stderr, "Write ENTRY_EXE Failed\r\n"); + break; + } + + ZeroMemory(buf, sizeof(buf)); + SYSTEMTIME tm; + GetLocalTime(&tm); + sprintf( + buf, + "%04d-%02d-%02d %02d:%02d:%02d", + tm.wYear, + tm.wMonth, + tm.wDay, + tm.wHour, + tm.wMinute, + tm.wSecond); + dwRes = RegSetValueExA( + hKey, + "INSTALL_DATETIME", + 0, + REG_SZ, + (BYTE*)buf, + (DWORD)strlen(buf)); + if(ERROR_SUCCESS != dwRes) + { + fprintf(stderr, "Write INSTALL_DATETIME Failed\r\n"); + break; + } + + dwRes = RegSetValueExA( + hKey, + "REGION", + 0, + REG_SZ, + (BYTE*)"en_US", + (DWORD)strlen("en_US")); + if(ERROR_SUCCESS != dwRes) + { + fprintf(stderr, "Write REGION Failed\r\n"); + break; + } + + bRet = true; + } while(0); + + RegCloseKey(hKey); + return bRet; +} + +static const char *FormatDataType(oaOptionDataType value_type) +{ + switch(value_type) + { + case OA_TYPE_STRING: + return "String"; + case OA_TYPE_INT: + return "Int"; + case OA_TYPE_FLOAT: + return "Float"; + case OA_TYPE_ENUM: + return "Enum"; + case OA_TYPE_BOOL: + return "Bool"; + default: + return "Unknown"; + } +} + +static const char *FormatCompareOp(oaComparisonOpType op_value) +{ + switch(op_value) + { + case OA_COMP_OP_EQUAL: + return "Equal"; + case OA_COMP_OP_NOT_EQUAL: + return "NotEqual"; + case OA_COMP_OP_GREATER: + return "Greater"; + case OA_COMP_OP_LESS: + return "Less"; + case OA_COMP_OP_GREATER_OR_EQUAL: + return "GreaterOrEqual"; + case OA_COMP_OP_LESS_OR_EQUAL: + return "LessOrEqual"; + default: + return "Unknown"; + } +} + +static void ConvertOAValue(oaOptionDataType value_type, + const oaValue *value, + char *result) +{ + switch(value_type) + { + case OA_TYPE_STRING: + case OA_TYPE_ENUM: + if (value->String) strcpy(result, value->String); + else result[0] = '\0'; + break; + case OA_TYPE_INT: + sprintf(result, "%d", value->Int); + break; + case OA_TYPE_FLOAT: + sprintf(result, "%f", value->Float); + break; + case OA_TYPE_BOOL: + sprintf(result, "%1d", value->Bool); + break; + default: + return; + } +} + +static void PrintOptions(const oaNamedOption *option) +{ + char buf[MAX_PATH]; + ConvertOAValue(option->DataType, &option->Value, buf); + + fprintf(stderr, "name=%s,type=%s,value=%s\r\n", option->Name, FormatDataType(option->DataType), buf); + if(option->MaxValue.Int && option->MinValue.Int) + { + fprintf(stderr," numsteps=%d", option->NumSteps); + ConvertOAValue(option->DataType, &option->MinValue, buf); + fprintf(stderr, "minvalue=%s", buf); + ConvertOAValue(option->DataType, &option->MaxValue, buf); + fprintf(stderr,"maxvalue=%s\r\n", buf); + } + + if(option->Dependency.ParentName) + { + ConvertOAValue(option->Dependency.ComparisonValType, &option->Dependency.ComparisonVal, buf); + fprintf(stderr, " parentname=%s,comparisionop=%s,comparisiontype=%s,comparisionvalue=%s\r\n", + option->Dependency.ParentName, + FormatCompareOp(option->Dependency.ComparisonOp), + FormatDataType(option->Dependency.ComparisonValType), + buf); + } +} + +#if (0) // Remove this! +int main(int argc, char *argv[]) +{ + SetConsoleTitleA("OA - simple application"); + ParseArgs(argc, argv); + + AppSettings::Inst().InitOptions(); + + if(InstallModeFlag) + { + InstallApp(); + } + else if(OAModeFlag) + { + OAMainLoop(OAOpt); + } + else + { + RunApp(); + } + + return(0); +} +#endif + +void GetAllOptions(void) +{ + fprintf(stderr, "All Options: \r\n"); + for(oaInt i=0; i < AppSettings::Inst().GetNumOptions(); ++i) + { + oaNamedOption* option = AppSettings::Inst().GetOption(i); + if (!strcmp(option->Name, "User/ProjectPath")) + continue; + if (!strcmp(option->Name, "User/FurAssetPath")) + continue; + PrintOptions(AppSettings::Inst().GetOption(i)); + oaAddOption(AppSettings::Inst().GetOption(i)); + } +} + +void GetCurrentOptions(void) +{ + fprintf(stderr, "Current Options: \r\n"); + + std::map<std::string, OptionValue>::const_iterator Iter = AppSettings::Inst().GetCurrentOptionMap()->begin(); + + oaNamedOption option; + oaInitOption(&option); + + for(; Iter != AppSettings::Inst().GetCurrentOptionMap()->end(); ++Iter) + { + if (!strcmp(Iter->second.Name, "User/ProjectPath")) + continue; + if (!strcmp(Iter->second.Name, "User/FurAssetPath")) + continue; + + option.Name = Iter->second.Name; + option.Value = Iter->second.Value; + option.DataType = Iter->second.Type; + PrintOptions(&option); + + oaAddOptionValue(Iter->second.Name, + Iter->second.Type, + &Iter->second.Value); + } +} + +void SetOptions(void) +{ + oaNamedOption *Option; + + fprintf(stderr, "Set Options: \r\n"); + while ((Option = oaGetNextOption()) != NV_NULL) + { + /* + * Set option value to persist for subsequent runs of the game + * to the given value. Option->Name will be the name of the value, + * and Option->Value will contain the appropriate value. + */ + PrintOptions(Option); + AppSettings::Inst().SetOptionValue(Option->Name, Option->DataType, &Option->Value); + } + + AppSettings::Inst().WriteOptionsFile(); +} + +void GetBenchmarks(void) +{ + /* foreach known available benchmark call oaAddBenchmark() with a unique string identifying it */ + for(oaInt i=0; i < NumBenchmarks; ++i) + oaAddBenchmark(Benchmarks[i]); +} + +void RunBenchmark(const oaChar *benchmark_name) +{ + oaValue Val; + int i; + + bool FoundBenchmark = false; + for(i=0; i < NumBenchmarks; ++i) + if(!strcmp(Benchmarks[i], benchmark_name)) + { + FoundBenchmark = true; + break; + } + + /* Check if the requested benchark is valid */ + if(!FoundBenchmark) + { + char Msg[1024]; + sprintf(Msg, "'%s' is not a valid benchmark.", benchmark_name); + OA_RAISE_ERROR(INVALID_BENCHMARK, benchmark_name); + } + + /* Setup everything to run the benchmark */ + + /* oaStartBenchmark() must be called right before the first frame */ + oaStartBenchmark(); + + /* + * Run the benchmark, and call oaDisplayFrame() right before the final + * present call for each frame + */ + //for(i=0; i < 50; ++i) + //{ + // SLEEP(20); + + // oaValue FrameValue; + // FrameValue.Int = i; + // oaValue OtherInt; + // OtherInt.Int = i+1000; + // oaChar str[100]; + // sprintf(str, "frame number: %d\00", i); + // oaValue Str; + // Str.String = str; + + // oaAddFrameValue("FrameCount", OA_TYPE_INT, &FrameValue); + // oaAddFrameValue("OtherInt", OA_TYPE_INT, &OtherInt); + // oaAddFrameValue("String", OA_TYPE_STRING, &Str); + + // oaDisplayFrame((oaFloat)(i * 20) / (oaFloat)1000); + //} + { +// SimpleScene* scene = SimpleScene::Inst(); + AppMainWindow::Inst().menu_clearScene(); + } + + /* Return some result values */ + Val.Int = 18249; + oaAddResultValue("Score", OA_TYPE_INT, &Val); + + Val.Float = 29.14; + oaAddResultValue("Some other score", OA_TYPE_FLOAT, &Val); + + /* oaStartBenchmark() must be called right after the last frame */ + oaEndBenchmark(); +} + +int AutomateInit(const char* opt) +{ + oaVersion Version; + if (!oaInit((const oaString)opt, &Version)) + { + Error("OA did not initialize properly."); + return 1; + } + g_isAutomateMode = true; + return 0; +} + +void AutomateRun() +{ + oaCommand Command; + + oaInitCommand(&Command); + switch(oaGetNextCommand(&Command)) + { + /* No more commands, exit program */ + case OA_CMD_EXIT: + AppMainWindow::Inst().close(); + return; + + /* Run as normal */ + case OA_CMD_RUN: + break; + + /* Enumerate all in-game options */ + case OA_CMD_GET_ALL_OPTIONS: + GetAllOptions(); + break; + + /* Return the option values currently set */ + case OA_CMD_GET_CURRENT_OPTIONS: + GetCurrentOptions(); + break; + + /* Set all in-game options */ + case OA_CMD_SET_OPTIONS: + SetOptions(); + break; + + /* Enumerate all known benchmarks */ + case OA_CMD_GET_BENCHMARKS: + GetBenchmarks(); + break; + + /* Run benchmark */ + case OA_CMD_RUN_BENCHMARK: + RunBenchmark(Command.BenchmarkName); + break; + } +} + +bool IsAutomateMode() +{ + return g_isAutomateMode; +} + +bool GetAutomateInstallModeOption(int argc, char* argv[]) +{ + for (int idx = 1; idx < argc; ++idx) + { + if (!strcmp(argv[idx], "-install")) + { + return true; + } + } + return false; +} + + +std::string GetAutomateOption(int argc, char* argv[]) +{ + for (int idx = 1; idx < argc; ++idx) + { + if (!strcmp(argv[idx], "-openautomate")) + { + if ((idx + 1) < argc) + { + return argv[idx+1]; + } + else + { + Error("-openautomate option must have an argument."); + return ""; + } + } + } + return ""; +} diff --git a/tools/ArtistTools/source/CoreLib/Utils/Automate.h b/tools/ArtistTools/source/CoreLib/Utils/Automate.h new file mode 100644 index 0000000..6f5de4f --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Automate.h @@ -0,0 +1,23 @@ + +// Wrapper functions for OpenAutomate + +// Add application info into registry key for Automate +// Return true if succeeded +bool AutomateInstallApp(); + +// Initialize OpenAutomate with its command line option. No need to cleanup +int AutomateInit(const char* opt); + +// Call this function when the application is idle when IsAutomateMode() is true +void AutomateRun(); + +// Returns true if automate mode is initialized by AutomateInit() call +bool IsAutomateMode(); + +// Utility function to parse the command line option for OpenAutomate +// Returns OpenAutomate option if it has. If not, returns empty string +std::string GetAutomateOption(int argc, char* argv[]); + +// Returns true if it has "-install" in the command line option +bool GetAutomateInstallModeOption(int argc, char* argv[]); + diff --git a/tools/ArtistTools/source/CoreLib/Utils/CoreLibUtils.h b/tools/ArtistTools/source/CoreLib/Utils/CoreLibUtils.h new file mode 100644 index 0000000..6decd0c --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/CoreLibUtils.h @@ -0,0 +1,65 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013-2015 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// +#pragma once + +#include <QtCore/QFile> +#include <QtCore/QTemporaryFile> + +namespace utils { + +inline std::string GetTempFilePath() +{ + QByteArray tempFilePath; + QTemporaryFile tempFile; + // temp file will be automatically deleted after this function + tempFile.open(); + tempFilePath = tempFile.fileName().toLocal8Bit(); + return std::string(tempFilePath); +} + +inline bool RenameFile(const char* srcFilePath, const char* targetFilePath, bool isOvewrite = false) +{ + if (QFile::exists(targetFilePath)) + { + if (isOvewrite == false) return false; + if (!QFile::remove(targetFilePath)) return false; + } + return QFile::rename(srcFilePath, targetFilePath); +} + +inline bool CopyFile(const char* srcFilePath, const char* targetFilePath, bool isOverwrite = false) +{ + if (QFile::exists(targetFilePath)) + { + if (isOverwrite == false) return false; + if (!QFile::remove(targetFilePath)) return false; + } + return QFile::copy(srcFilePath, targetFilePath); +} + +} // end of utils diff --git a/tools/ArtistTools/source/CoreLib/Utils/MathUtil.cpp b/tools/ArtistTools/source/CoreLib/Utils/MathUtil.cpp new file mode 100644 index 0000000..bdb3a77 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/MathUtil.cpp @@ -0,0 +1,327 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// This file contains wrapper functions to make hair lib easy to setup and use +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#include "MathUtil.h" +#include <string.h> + +//////////////////////////////////////////////////////////////////////////////////////// +void gfsdk_makeIdentity(atcore_float4x4& transform) +{ + memset(&transform, 0, sizeof(atcore_float4x4)); + transform._11 = 1.0f; + transform._22 = 1.0f; + transform._33 = 1.0f; + transform._44 = 1.0f; +} + +//////////////////////////////////////////////////////////////////////////////////////// +void gfsdk_makeTranslation(atcore_float4x4& m, const atcore_float3& t) +{ + gfsdk_makeIdentity(m); + m._41 = t.x; + m._42 = t.y; + m._43 = t.z; +} + +//////////////////////////////////////////////////////////////////////////////////////// +void gfsdk_makeScale(atcore_float4x4& m, const atcore_float3& s) +{ + gfsdk_makeIdentity(m); + m._11 = s.x; + m._12 = s.y; + m._13 = s.z; +} + +//////////////////////////////////////////////////////////////////////////////// +void gfsdk_makeRotation(atcore_float4x4& m, const atcore_float4& q) +{ + gfsdk_makeIdentity(m); + + const float x = q.x; + const float y = q.y; + const float z = q.z; + const float w = q.w; + + const float x2 = x + x; + const float y2 = y + y; + const float z2 = z + z; + + const float xx = x2*x; + const float yy = y2*y; + const float zz = z2*z; + + const float xy = x2*y; + const float xz = x2*z; + const float xw = x2*w; + + const float yz = y2*z; + const float yw = y2*w; + const float zw = z2*w; + + m._11 = 1.0f - yy - zz; + m._12 = xy + zw; + m._13 = xz - yw; + + m._21 = xy - zw; + m._22 = 1.0f - xx - zz; + m._23 = yz + xw; + + m._31 = xz + yw; + m._32 = yz - xw; + m._33 = 1.0f - xx - yy; +} + +//////////////////////////////////////////////////////////////////////////////// +atcore_float4x4 gfsdk_makeTransform(const atcore_float4& q, const atcore_float3& t, const atcore_float3 &s) +{ + atcore_float4x4 m; + + gfsdk_makeRotation(m, q); + + m._11 *= s.x; m._12 *= s.x; m._13 *= s.x; + m._21 *= s.y; m._22 *= s.y; m._23 *= s.y; + m._31 *= s.z; m._32 *= s.z; m._33 *= s.z; + + m._41 = t.x; + m._42 = t.y; + m._43 = t.z; + + return m; +} + +//////////////////////////////////////////////////////////////////////////////// +atcore_float4 gfsdk_getRotation(const atcore_float4x4& sm) +{ + atcore_float4x4 m = sm; + + gfsdk_orthonormalize(m); + + atcore_float4 q; + + float x,y,z,w; + + float tr = m._11 + m._22 + m._33, h; + if(tr >= 0) + { + h = sqrt(tr +1); + w = float(0.5) * h; + h = float(0.5) / h; + + x = (m._23 - m._32) * h; + y = (m._31 - m._13) * h; + z = (m._12 - m._21) * h; + } + else + { + float max = m._11; + int i = 0; + if (m._22 > m._11) + { + i = 1; + max = m._22; + } + if (m._33 > max) + i = 2; + switch (i) + { + case 0: + h = sqrt((m._11 - (m._22 + m._33)) + 1); + x = float(0.5) * h; + h = float(0.5) / h; + + y = (m._21 + m._12) * h; + z = (m._13 + m._31) * h; + w = (m._23 - m._32) * h; + break; + case 1: + h = sqrt((m._22 - (m._33 + m._11)) + 1); + y = float(0.5) * h; + h = float(0.5) / h; + + z = (m._32 + m._23) * h; + x = (m._21 + m._12) * h; + w = (m._31 - m._13) * h; + break; + case 2: + h = sqrt((m._33 - (m._11 + m._22)) + 1); + z = float(0.5) * h; + h = float(0.5) / h; + + x = (m._13 + m._31) * h; + y = (m._32 + m._23) * h; + w = (m._12 - m._21) * h; + break; + default: // Make compiler happy + x = y = z = w = 0; + break; + } + } + + return gfsdk_makeFloat4(x,y,z,w); +} + +//////////////////////////////////////////////////////////////////////////////////////// +atcore_float4x4 gfsdk_lerp(atcore_float4x4& start, atcore_float4x4& end, float t) +{ + atcore_float4 sq = gfsdk_getRotation(start); + atcore_float4 eq = gfsdk_getRotation(end); + atcore_float3 st = gfsdk_getTranslation(start); + atcore_float3 et = gfsdk_getTranslation(end); + + atcore_float3 ss = gfsdk_getScale(start); + atcore_float3 es = gfsdk_getScale(end); + atcore_float3 s = gfsdk_lerp(ss, es, t); + + atcore_dualquaternion sdq = gfsdk_makeDQ(sq, st); + atcore_dualquaternion edq = gfsdk_makeDQ(eq, et); + + atcore_dualquaternion dq = gfsdk_lerp(sdq, edq, t); + + atcore_float4 gr = getRotation(dq); + atcore_float3 gt = getTranslation(dq); + + return gfsdk_makeTransform(gr, gt, s); +} + +//////////////////////////////////////////////////////////////////////////////// +atcore_float4x4 operator*(const atcore_float4x4& in1, const atcore_float4x4& in2) +{ +#define MATRIX_SUM(OUT, IN1, IN2, ROW, COL) OUT._##ROW##COL = IN1._##ROW##1 * IN2._1##COL + IN1._##ROW##2 * IN2._2##COL + IN1._##ROW##3 * IN2._3##COL + IN1._##ROW##4 * IN2._4##COL; + + atcore_float4x4 out; + + MATRIX_SUM(out, in1, in2, 1, 1); + MATRIX_SUM(out, in1, in2, 1, 2); + MATRIX_SUM(out, in1, in2, 1, 3); + MATRIX_SUM(out, in1, in2, 1, 4); + + MATRIX_SUM(out, in1, in2, 2, 1); + MATRIX_SUM(out, in1, in2, 2, 2); + MATRIX_SUM(out, in1, in2, 2, 3); + MATRIX_SUM(out, in1, in2, 2, 4); + + MATRIX_SUM(out, in1, in2, 3, 1); + MATRIX_SUM(out, in1, in2, 3, 2); + MATRIX_SUM(out, in1, in2, 3, 3); + MATRIX_SUM(out, in1, in2, 3, 4); + + MATRIX_SUM(out, in1, in2, 4, 1); + MATRIX_SUM(out, in1, in2, 4, 2); + MATRIX_SUM(out, in1, in2, 4, 3); + MATRIX_SUM(out, in1, in2, 4, 4); + +#undef MATRIX_SUM + + return out; +} + +//////////////////////////////////////////////////////////////////////////////// +float +gfsdk_getDeterminant(const atcore_float4x4& m) +{ + const float* matrix = (const float*)&m; + + atcore_float3 p0 = gfsdk_makeFloat3(matrix[0*4+0], matrix[0*4+1], matrix[0*4+2]); + atcore_float3 p1 = gfsdk_makeFloat3(matrix[1*4+0], matrix[1*4+1], matrix[1*4+2]); + atcore_float3 p2 = gfsdk_makeFloat3(matrix[2*4+0], matrix[2*4+1], matrix[2*4+2]); + + atcore_float3 tempv = gfsdk_cross(p1,p2); + + return gfsdk_dot(p0, tempv); +} + +//////////////////////////////////////////////////////////////////////////////// +atcore_float4x4 +gfsdk_getSubMatrix(int ki,int kj, const atcore_float4x4& m) +{ + atcore_float4x4 out; + gfsdk_makeIdentity(out); + + float* pDst = (float*)&out; + const float* matrix = (const float*)&m; + + int row, col; + int dstCol = 0, dstRow = 0; + + for ( col = 0; col < 4; col++ ) + { + if ( col == kj ) + { + continue; + } + for ( dstRow = 0, row = 0; row < 4; row++ ) + { + if ( row == ki ) + { + continue; + } + pDst[dstCol*4+dstRow] = matrix[col*4+row]; + dstRow++; + } + dstCol++; + } + + return out; +} + +//////////////////////////////////////////////////////////////////////////////// +atcore_float4x4 gfsdk_inverse(const atcore_float4x4& m) +{ + atcore_float4x4 im; + + float* inverse_matrix = (float*)&im; + + float det = gfsdk_getDeterminant(m); + det = 1.0f / det; + for (int i = 0; i < 4; i++ ) + { + for (int j = 0; j < 4; j++ ) + { + int sign = 1 - ( ( i + j ) % 2 ) * 2; + + atcore_float4x4 subMat = gfsdk_getSubMatrix(i, j, m); + float subDeterminant = gfsdk_getDeterminant(subMat); + + inverse_matrix[i*4+j] = ( subDeterminant * sign ) * det; + } + } + + return im; +} + +//////////////////////////////////////////////////////////////////////////////// +atcore_dualquaternion gfsdk_makeDQ(const atcore_float4x4& m) +{ + atcore_float4 q = gfsdk_getRotation(m); + atcore_float3 t = gfsdk_getTranslation(m); + + return gfsdk_makeDQ(q, t); +} diff --git a/tools/ArtistTools/source/CoreLib/Utils/MathUtil.h b/tools/ArtistTools/source/CoreLib/Utils/MathUtil.h new file mode 100644 index 0000000..7b7a2a5 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/MathUtil.h @@ -0,0 +1,557 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// +#pragma once + +#include "corelib_global.h" +#include "CoreLib.h" +#include "math.h" +#include "float.h" + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_lerp(float v1, float v2, float t) +{ + return (1.0f - t) * v1 + t * v2; +} + +inline float gfsdk_min(float x, float y) { + return (x < y) ? x : y; +} + +inline float gfsdk_max(float x, float y) { + return (x > y) ? x : y; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float2 gfsdk_makeFloat2(float x, float y) +{ + atcore_float2 v; + v.x = x; + v.y = y; + return v; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float2 operator*(float s, const atcore_float2 &p) +{ + return gfsdk_makeFloat2(s * p.x, s * p.y); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float2 operator*(const atcore_float2 &p, float s) +{ + return gfsdk_makeFloat2(s * p.x, s * p.y); +} + + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_makeFloat3(float x, float y, float z) +{ + atcore_float3 v; + v.x = x; + v.y = y; + v.z = z; + return v; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 operator+(const atcore_float3 &p0, const atcore_float3 &p1) +{ + return gfsdk_makeFloat3(p0.x + p1.x, p0.y + p1.y, p0.z + p1.z); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3& operator+=(atcore_float3 &v, const atcore_float3 & v1) +{ + v.x += v1.x; v.y += v1.y; v.z += v1.z; + return v; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 operator-(const atcore_float3 &p0, const atcore_float3 &p1) +{ + return gfsdk_makeFloat3(p0.x - p1.x, p0.y - p1.y, p0.z - p1.z); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3& operator-=(atcore_float3 &v, const atcore_float3 & v1) +{ + v.x -= v1.x; v.y -= v1.y; v.z -= v1.z; + return v; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 operator*(float s, const atcore_float3 &p) +{ + return gfsdk_makeFloat3(s * p.x, s * p.y, s * p.z); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 operator*(const atcore_float3 &p, float s) +{ + return gfsdk_makeFloat3(s * p.x, s * p.y, s * p.z); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_dot(const atcore_float3& v0, const atcore_float3 &v1) { + return v0.x * v1.x + v0.y * v1.y + v0.z * v1.z; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_lengthSquared(const atcore_float3& v) { + return gfsdk_dot(v,v); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_length(const atcore_float3 &v) { + return sqrt(gfsdk_lengthSquared(v)); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_distance(const atcore_float3 &v1, const atcore_float3 &v2) { + return gfsdk_length(v2-v1); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline const atcore_float3& gfsdk_normalize(atcore_float3 &v) { + float l = gfsdk_length(v); + if (l != 0) { v.x /= l; v.y /= l; v.z /= l; } + return v; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_cross(const atcore_float3& v1, const atcore_float3& v2) +{ + return gfsdk_makeFloat3( + v1.y * v2.z - v1.z * v2.y, + v1.z * v2.x - v1.x * v2.z, + v1.x * v2.y - v1.y * v2.x); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_lerp(const atcore_float3& v1, const atcore_float3& v2, float t) +{ + return gfsdk_makeFloat3(gfsdk_lerp(v1.x, v2.x, t), gfsdk_lerp(v1.y, v2.y, t), gfsdk_lerp(v1.z, v2.z, t)); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_min(const atcore_float3& v1, const atcore_float3 &v2) +{ + return gfsdk_makeFloat3( + gfsdk_min(v1.x, v2.x), + gfsdk_min(v1.y, v2.y), + gfsdk_min(v1.z, v2.z) + ); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_max(const atcore_float3& v1, const atcore_float3 &v2) +{ + return gfsdk_makeFloat3( + gfsdk_max(v1.x, v2.x), + gfsdk_max(v1.y, v2.y), + gfsdk_max(v1.z, v2.z) + ); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_min(const atcore_float3 &v) +{ + return gfsdk_min(gfsdk_min(v.x, v.y), v.z); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_max(const atcore_float3 &v) +{ + return gfsdk_max(gfsdk_max(v.x, v.y), v.z); +} + +//////////////////////////////////////////////////////////////////////////////// +// float4 +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float4 gfsdk_makeFloat4(float x = 0.0f, float y = 0.0f, float z = 0.0f, float w = 0.0f) +{ + atcore_float4 v; + v.x = x; + v.y = y; + v.z = z; + v.w = w; + return v; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float4 gfsdk_makeFloat4(const atcore_float3& v, float w) +{ + return gfsdk_makeFloat4(v.x, v.y, v.z, w); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float4& operator+=(atcore_float4 &v, const atcore_float4 & v1) +{ + v.x += v1.x; v.y += v1.y; v.z += v1.z; v.w += v1.w; + return v; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float4 operator*(float s, const atcore_float4 &p) +{ + return gfsdk_makeFloat4(s * p.x, s * p.y, s * p.z, s * p.w); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float4 operator*(const atcore_float4 &p, float s) +{ + return gfsdk_makeFloat4(s * p.x, s * p.y, s * p.z, s * p.w); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_dot(const atcore_float4& v0, const atcore_float4 &v1) { + return v0.x * v1.x + v0.y * v1.y + v0.z * v1.z + v0.w * v1.w; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_lengthSquared(const atcore_float4& v) { + return gfsdk_dot(v,v); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline float gfsdk_length(const atcore_float4 &v) { + return sqrt(gfsdk_lengthSquared(v)); +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline const atcore_float4 gfsdk_normalize(const atcore_float4 &v) { + atcore_float4 nv = v; + + float l = gfsdk_length(nv); + if (l > FLT_EPSILON) + { + const float s = 1.0f / l; + + nv.x *= s; + nv.y *= s; + nv.z *= s; + nv.w *= s; + } + + return nv; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float4 gfsdk_lerp(const atcore_float4& v1, const atcore_float4& v2, float t) +{ + return gfsdk_makeFloat4( + gfsdk_lerp(v1.x, v2.x, t), + gfsdk_lerp(v1.y, v2.y, t), + gfsdk_lerp(v1.z, v2.z, t), + gfsdk_lerp(v1.w, v2.w, t) + ); +} + +//////////////////////////////////////////////////////////////////////////////// +// quaternion +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +inline atcore_float4 gfsdk_quaternionConjugate(const atcore_float4& in) +{ + return gfsdk_makeFloat4(-in.x, -in.y, -in.z, in.w); +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float4 gfsdk_quaternionMultiply(const atcore_float4& q0, const atcore_float4& q1) +{ + atcore_float4 q; + + const float tx = q0.w * q1.x + q0.x * q1.w + q0.y * q1.z - q0.z * q1.y; + const float ty = q0.w * q1.y + q0.y * q1.w + q0.z * q1.x - q0.x * q1.z; + const float tz = q0.w * q1.z + q0.z * q1.w + q0.x * q1.y - q0.y * q1.x; + + q.w = q0.w * q1.w - q0.x * q1.x - q0.y * q1.y - q0.z * q1.z; + q.x = tx; + q.y = ty; + q.z = tz; + + return q; +} + +//////////////////////////////////////////////////////////////////////////////// +// 4x4 matrix +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////// +CORELIB_EXPORT void gfsdk_makeIdentity(atcore_float4x4& transform); +CORELIB_EXPORT void gfsdk_makeTranslation(atcore_float4x4& m, const atcore_float3& t); +CORELIB_EXPORT void gfsdk_makeScale(atcore_float4x4& m, const atcore_float3& s); +CORELIB_EXPORT void gfsdk_makeRotation(atcore_float4x4& m, const atcore_float4& q); + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float4x4& operator*=(atcore_float4x4& m, float s) +{ + float* data = (float*)&m; + for (int i = 0; i < 16; i++) + data[i] *= s; + + return m; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline void gfsdk_setPosition(atcore_float4x4&m, const atcore_float3& v) +{ + m._41 = v.x; + m._42 = v.y; + m._43 = v.z; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float4x4 gfsdk_transpose(const atcore_float4x4& m) +{ + atcore_float4x4 om; + + om._11 = m._11; om._12 = m._21; om._13 = m._31; om._14 = m._41; + om._21 = m._12; om._22 = m._22; om._23 = m._32; om._24 = m._42; + om._31 = m._13; om._32 = m._23; om._33 = m._33; om._34 = m._43; + om._41 = m._14; om._42 = m._24; om._43 = m._34; om._44 = m._44; + + return om; +} + +//////////////////////////////////////////////////////////////////////////////////////// +inline atcore_float4x4& operator+=(atcore_float4x4& m1, const atcore_float4x4& m2) +{ + float* data1 = (float*)&m1; + float* data2 = (float*)&m2; + + for (int i = 0; i < 16; i++) + data1[i] += data2[i]; + + return m1; +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float4 gfsdk_transform(const atcore_float4x4 &m, atcore_float4 op) +{ + atcore_float4 p; + + p.x = op.x * m._11 + op.y * m._21 + op.z * m._31 + op.w * m._41; + p.y = op.x * m._12 + op.y * m._22 + op.z * m._32 + op.w * m._42; + p.z = op.x * m._13 + op.y * m._23 + op.z * m._33 + op.w * m._43; + p.w = op.x * m._14 + op.y * m._24 + op.z * m._34 + op.w * m._44; + + return p; +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_transformCoord(const atcore_float4x4 &m, atcore_float3 op) +{ + atcore_float3 p; + + p.x = op.x * m._11 + op.y * m._21 + op.z * m._31 + m._41; + p.y = op.x * m._12 + op.y * m._22 + op.z * m._32 + m._42; + p.z = op.x * m._13 + op.y * m._23 + op.z * m._33 + m._43; + + return p; +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_transformVector(const atcore_float4x4 &m, atcore_float3 op) +{ + atcore_float3 p; + + p.x = op.x * m._11 + op.y * m._21 + op.z * m._31; + p.y = op.x * m._12 + op.y * m._22 + op.z * m._32; + p.z = op.x * m._13 + op.y * m._23 + op.z * m._33; + + return p; +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_getScale(const atcore_float4x4& m) +{ + atcore_float3 ax = gfsdk_makeFloat3(m._11, m._12, m._13); + atcore_float3 ay = gfsdk_makeFloat3(m._21, m._22, m._23); + atcore_float3 az = gfsdk_makeFloat3(m._31, m._32, m._33); + + return gfsdk_makeFloat3(gfsdk_length(ax), gfsdk_length(ay), gfsdk_length(az)); +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_getTranslation(const atcore_float4x4& m) +{ + return gfsdk_makeFloat3(m._41, m._42, m._43); +} + +//////////////////////////////////////////////////////////////////////////////// +inline void gfsdk_setTranslation(atcore_float4x4& m, const atcore_float3 &v) +{ + m._41 = v.x; + m._42 = v.y; + m._43 = v.z; +} + +//////////////////////////////////////////////////////////////////////////////// +inline const atcore_float4x4& gfsdk_orthonormalize(atcore_float4x4& m) +{ + atcore_float3 ax = gfsdk_makeFloat3(m._11, m._12, m._13); + atcore_float3 ay = gfsdk_makeFloat3(m._21, m._22, m._23); + atcore_float3 az = gfsdk_makeFloat3(m._31, m._32, m._33); + + gfsdk_normalize(ax); + gfsdk_normalize(ay); + gfsdk_normalize(az); + + m._11 = ax.x; m._12 = ax.y; m._13 = ax.z; + m._21 = ay.x; m._22 = ay.y; m._23 = ay.z; + m._31 = az.x; m._32 = az.y; m._33 = az.z; + + return m; +} + +//////////////////////////////////////////////////////////////////////////////// +CORELIB_EXPORT atcore_float4x4 gfsdk_lerp(atcore_float4x4& start, atcore_float4x4& end, float t); + +//////////////////////////////////////////////////////////////////////////////// +CORELIB_EXPORT atcore_float4 gfsdk_getRotation(const atcore_float4x4& m); + +//////////////////////////////////////////////////////////////////////////////// +CORELIB_EXPORT atcore_float4x4 gfsdk_makeTransform(const atcore_float4& q, const atcore_float3& t, const atcore_float3 &s); + +//////////////////////////////////////////////////////////////////////////////// +CORELIB_EXPORT atcore_float4x4 operator*(const atcore_float4x4& in1, const atcore_float4x4& in2); + +//////////////////////////////////////////////////////////////////////////////// +CORELIB_EXPORT atcore_float4x4 gfsdk_inverse(const atcore_float4x4& m); + +//////////////////////////////////////////////////////////////////////////////// +// dual quaternion +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +inline atcore_dualquaternion gfsdk_makeDQ(const atcore_float4& q, const atcore_float3& t) +{ + atcore_dualquaternion dq; + + dq.q0 = gfsdk_normalize(q); + dq.q1 = gfsdk_quaternionMultiply(gfsdk_makeFloat4(t, 0), dq.q0) * 0.5f; + + return dq; +} + +//////////////////////////////////////////////////////////////////////////////// +atcore_dualquaternion gfsdk_makeDQ(const atcore_float4x4& m); + +//////////////////////////////////////////////////////////////////////////////// +inline const atcore_dualquaternion& gfsdk_normalize(atcore_dualquaternion & dq) +{ + float mag = gfsdk_dot( dq.q0, dq.q0); + float deLen = 1.0f / sqrt(mag+FLT_EPSILON); + + dq.q0 = dq.q0 * deLen; + dq.q1 = dq.q1 * deLen; + + return dq; +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_dualquaternion operator*(float s, const atcore_dualquaternion & dq) +{ + return atcore_dualquaternion(s * dq.q0, s * dq.q1); +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_dualquaternion operator*(const atcore_dualquaternion & dq, float s) +{ + return atcore_dualquaternion(s * dq.q0, s * dq.q1); +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_dualquaternion& operator+=(atcore_dualquaternion &dq, const atcore_dualquaternion & dq2) +{ + // hemispherization + float sign = (gfsdk_dot(dq.q0, dq2.q0) < -FLT_EPSILON) ? -1.0f: 1.0f; + + dq.q0 += sign * dq2.q0; + dq.q1 += sign * dq2.q1; + + return dq; +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_dualquaternion gfsdk_lerp(const atcore_dualquaternion &dq1, const atcore_dualquaternion & dq2, float t) +{ + atcore_dualquaternion dq = dq1 * (1.0f - t); + + float sign = (gfsdk_dot(dq1.q0, dq2.q0) < -FLT_EPSILON) ? -1.0f: 1.0f; + + dq += (t * sign) * dq2; + gfsdk_normalize(dq); + + return dq; +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_transformCoord(const atcore_dualquaternion& dq, const atcore_float3 &vecIn) +{ + atcore_float3 d0 = gfsdk_makeFloat3(dq.q0.x, dq.q0.y, dq.q0.z); + atcore_float3 de = gfsdk_makeFloat3(dq.q1.x, dq.q1.y, dq.q1.z); + float a0 = dq.q0.w; + float ae = dq.q1.w; + + atcore_float3 temp = gfsdk_cross( d0, vecIn ) + a0 * vecIn; + atcore_float3 temp2 = 2.0f * (a0 * de - ae * d0 + gfsdk_cross(d0, de)); + + return vecIn + temp2 + 2.0f * gfsdk_cross( d0, temp); +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 gfsdk_transformVector(const atcore_dualquaternion& dq, const atcore_float3 &vecIn) +{ + atcore_float3 d0 = gfsdk_makeFloat3(dq.q0.x, dq.q0.y, dq.q0.z); + atcore_float3 de = gfsdk_makeFloat3(dq.q1.x, dq.q1.y, dq.q1.z); + float a0 = dq.q0.w; + float ae = dq.q1.w; + + atcore_float3 temp = gfsdk_cross( d0, vecIn ) + a0 * vecIn; + return vecIn + 2.0f * gfsdk_cross( d0, temp); +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float4 getRotation(const atcore_dualquaternion& dq) +{ + return dq.q0; +} + +//////////////////////////////////////////////////////////////////////////////// +inline atcore_float3 getTranslation(const atcore_dualquaternion& dq) +{ + atcore_float4 dual = 2.0f * dq.q1; + atcore_float4 t = gfsdk_quaternionMultiply(dual, gfsdk_quaternionConjugate( dq.q0 )); + + return gfsdk_makeFloat3(t.x, t.y, t.z); +} + diff --git a/tools/ArtistTools/source/CoreLib/Utils/Profiler.cpp b/tools/ArtistTools/source/CoreLib/Utils/Profiler.cpp new file mode 100644 index 0000000..aab4de3 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Profiler.cpp @@ -0,0 +1,82 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +#pragma once + +#include "nvToolsExt.h" +#include <stdlib.h> // for rand() + +void ProfilerRangePush(const char* name) { + unsigned int color = 0xFF000000 | ((rand()%256) << 16) | ((rand()%256) << 8) | (rand()%256); + // Zero the structure + nvtxEventAttributes_t event_attrib = {0}; + // Set the version and the size information + event_attrib.version = NVTX_VERSION; + event_attrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; + // Configure the attributes. 0 is the default for all attributes + event_attrib.colorType = NVTX_COLOR_ARGB; + event_attrib.color = color; + event_attrib.messageType = NVTX_MESSAGE_TYPE_ASCII; + event_attrib.message.ascii = name; + nvtxRangePushEx(&event_attrib); +} + +void ProfilerRangePush(const char* name, unsigned int color) { + // Zero the structure + nvtxEventAttributes_t event_attrib = {0}; + // Set the version and the size information + event_attrib.version = NVTX_VERSION; + event_attrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; + // Configure the attributes. 0 is the default for all attributes + event_attrib.colorType = NVTX_COLOR_ARGB; + event_attrib.color = color; + event_attrib.messageType = NVTX_MESSAGE_TYPE_ASCII; + event_attrib.message.ascii = name; + nvtxRangePushEx(&event_attrib); +} + +void ProfilerRangePop() { + nvtxRangePop(); +} + +#include "Profiler.h" + +ScopedProfiler::ScopedProfiler(const char* name) +{ + ProfilerRangePush(name); +} + +ScopedProfiler::ScopedProfiler(const char* name, unsigned int color) +{ + ProfilerRangePush(name, color); +} + +ScopedProfiler::~ScopedProfiler() +{ + ProfilerRangePop(); +} diff --git a/tools/ArtistTools/source/CoreLib/Utils/Profiler.h b/tools/ArtistTools/source/CoreLib/Utils/Profiler.h new file mode 100644 index 0000000..5f00175 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Profiler.h @@ -0,0 +1,51 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +#pragma once + +#include "corelib_global.h" + +// name - the name to be displayed +void ProfilerRangePush(const char* name); + +// name - the name to be displayed +// color - ARGB color. ex) 0xFFFF0000 = Red, 0xFF0000FF = Blue +void ProfilerRangePush(const char* name, unsigned int color); + +void ProfilerRangePop(); + +struct CORELIB_EXPORT ScopedProfiler +{ + ScopedProfiler(const char* name); + + ScopedProfiler(const char* name, unsigned int color); + + ~ScopedProfiler(); +}; + +#define FUNCTION_PROFILER() ScopedProfiler _scoped_function_profiler(__FUNCTION__); diff --git a/tools/ArtistTools/source/CoreLib/Utils/Settings.cpp b/tools/ArtistTools/source/CoreLib/Utils/Settings.cpp new file mode 100644 index 0000000..5445bef --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Settings.cpp @@ -0,0 +1,767 @@ +/******************************************************************************* +* NVIDIA Corporation +* Software License Agreement - OpenAutomate SDK +* +* IMPORTANT - READ BEFORE COPYING, INSTALLING OR USING +* Do not use or load the OpenAutomate SDK and any associated materials +* provided by NVIDIA on NVIDIA�s website (collectively, the "Software") +* until You have carefully read the following terms and conditions. By +* loading or using the Software, You agree to fully comply with the terms +* and conditions of this Software License Agreement ("Agreement") by and +* between NVIDIA Corporation, a Delaware corporation with its principal +* place of business at 2701 San Tomas Expressway, Santa Clara, California +* 95050 U.S.A. ("NVIDIA"), and You. If You do not wish to so agree, do not +* install or use the Software. +* +* For the purposes of this Agreement: +* +* "Licensee," "You" and/or "Your" shall mean, collectively and +* individually, Original Equipment Manufacturers, Independent Hardware +* Vendors, Independent Software Vendors, and End-Users of the Software +* pursuant to the terms and conditions of this Agreement. +* +* "Derivative Works" shall mean derivatives of the Software created by You +* or a third party on Your behalf, which term shall include: (a) for +* copyrightable or copyrighted material, any translation, abridgement, +* revision or other form in which an existing work may be recast, +* transformed or adapted; (b) for work protected by topography or mask +* right, any translation, abridgement, revision or other form in which an +* existing work may be recast, transformed or adapted; (c) for patentable +* or patented material, any Improvement; and (d) for material protected by +* trade secret, any new material derived from or employing such existing +* trade secret. +* +* "Excluded License" is any license that requires as a condition of use, +* modification and/or distribution of software subject to the Excluded +* License, that such software or other software distributed and/or +* combined with such software be (i) disclosed or distributed in source +* code form, (ii) licensed for the purpose of making derivative works, or +* (iii) redistributable at no charge. +* +* SECTION 1 - GRANT OF LICENSE. +* NVIDIA agrees to provide the Software and any associated materials +* pursuant to the terms and conditions of this Agreement. Subject to the +* terms of this Agreement, NVIDIA grants to You a nonexclusive, +* transferable, worldwide, revocable, limited, royalty-free, fully paid-up +* license under NVIDIA�s copyrights to +* +* (a) install, deploy, use, have used execute, reproduce, display, +* perform, run, modify the source code of the Software, or to prepare and +* have prepared Derivative Works thereof the Software for Your own +* internal development, testing and maintenance purposes to incorporate +* the Software or Derivative Works thereof, in part or whole, into Your +* software applications; +* +* (b) to transfer, distribute and sublicense the Software (in its +* unmodified form as delivered to You by NVIDIA pursuant to this +* Agreement) in any medium or technology for Your sublicensees to +* incorporate the Software or Derivative Works thereof, in part or whole, +* into their respective software applications; and +* +* (c) to transfer, distribute and sublicense Derivative Works (in object +* code only) of the Software (i)_as incorporated in Your application +* software in any medium or technology; and (ii) certified as OpenAutomate +* Compatible Software. +* +* You may exercise your license rights pursuant to Subsection 1(b) and (c) +* above pursuant to the terms and conditions of any form of end-user +* software license agreement of Your choice, including but not limited to +* an Excluded License. +* +* In the event NVIDIA certifies Your application software, incorporating +* the Derivative Works (in object code only) of the Software, as +* OpenAutomate compatible ("OpenAutomate Compatible Software"), NVIDIA +* grants You a nonexclusive, worldwide, revocable, paid-up license to use +* the name and trademark to "OpenAutomate Compatible" solely for the +* purposes of identifying and/or marketing Your application software as +* OpenAutomate Compatible Software; provided that Licensee fully complies +* with the following: +* +* (x) Licensee agrees that it is strictly prohibited from using the name +* and trademark of "OpenAutomate Compatible" if Your application software +* is not OpenAutomate Compatible Software; +* +* (y) if NVIDIA objects to Your improper use of the "OpenAutomate +* Compatible" name and trademark, You will take all reasonable steps +* necessary to resolve NVIDIA�s objections. NVIDIA may reasonably monitor +* the quality of Your application software bearing the "OpenAutomate +* Compatible" name or trademark pursuant to this Agreement; and +* +* (z) any goodwill attached to NVIDIA�s trademarks, service marks, or +* trade names belong to NVIDIA and this Agreement does not grant You any +* right to use them. +* +* If You are not the final manufacturer or vendor of a computer system or +* software program incorporating the Software, or if Your Contractors (as +* defined below), affiliates or subsidiaries need to exercise any, some or +* all of the license grant described above herein to the Software on Your +* behalf, then You may transfer a copy of the Software, (and related +* end-user documentation) to such recipient for use in accordance with the +* terms of this Agreement, provided such recipient agrees to be fully +* bound by the terms hereof. Except as expressly permitted in this +* Agreement, Unless otherwise authorized in the Agreement, You shall not +* otherwise assign, sublicense, lease, or in any other way transfer or +* disclose Software to any third party. Unless otherwise authorized in the +* Agreement, You shall not reverse- compile, disassemble, +* reverse-engineer, or in any manner attempt to derive the source code of +* the Software from the object code portions of the Software. +* +* Except as expressly stated in this Agreement, no license or right is +* granted to You directly or by implication, inducement, estoppel or +* otherwise. NVIDIA shall have the right to inspect or have an independent +* auditor inspect Your relevant records to verify Your compliance with the +* terms and conditions of this Agreement. +* +* SECTION 2 - CONFIDENTIALITY. +* If applicable, any exchange of Confidential Information (as defined in +* the NDA) shall be made pursuant to the terms and conditions of a +* separately signed Non-Disclosure Agreement ("NDA") by and between NVIDIA +* and You. For the sake of clarity, You agree that the Software is +* Confidential Information of NVIDIA. +* +* If You wish to have a third party consultant or subcontractor +* ("Contractor") perform work on Your behalf which involves access to or +* use of Software, You shall obtain a written confidentiality agreement +* from the Contractor which contains terms and obligations with respect to +* access to or use of Software no less restrictive than those set forth in +* this Agreement and excluding any distribution or sublicense rights, and +* use for any other purpose than permitted in this Agreement. Otherwise, +* You shall not disclose the terms or existence of this Agreement or use +* NVIDIA's name in any publications, advertisements, or other +* announcements without NVIDIA's prior written consent. Unless otherwise +* provided in this Agreement, You do not have any rights to use any NVIDIA +* trademarks or logos. +* +* SECTION 3 - OWNERSHIP OF SOFTWARE AND INTELLECTUAL PROPERTY RIGHTS. +* All rights, title and interest to all copies of the Software remain with +* NVIDIA, subsidiaries, licensors, or its suppliers. The Software is +* copyrighted and protected by the laws of the United States and other +* countries, and international treaty provisions. You may not remove any +* copyright notices from the Software. NVIDIA may make changes to the +* Software, or to items referenced therein, at any time and without +* notice, but is not obligated to support or update the Software. Except +* as otherwise expressly provided, NVIDIA grants no express or implied +* right under any NVIDIA patents, copyrights, trademarks, or other +* intellectual property rights. +* +* All rights, title and interest in the Derivative Works of the Software +* remain with You subject to the underlying license from NVIDIA to the +* Software. In Your sole discretion, You may grant NVIDIA, upon NVIDIA�s +* request for such a license described herein, an irrevocable, perpetual, +* nonexclusive, worldwide, royalty-free paid-up license to make, have +* made, use, have used, sell, license, distribute, sublicense or otherwise +* transfer Derivative Works created by You that add functionality or +* improvement to the Software. +* +* You has no obligation to give NVIDIA any suggestions, comments or other +* feedback ("Feedback") relating to the Software. However, NVIDIA may use +* and include any Feedback that You voluntarily provide to improve the +* Software or other related NVIDIA technologies. Accordingly, if You +* provide Feedback, You agree NVIDIA and its licensees may freely use, +* reproduce, license, distribute, and otherwise commercialize the Feedback +* in the Software or other related technologies without the payment of any +* royalties or fees. +* +* You may transfer the Software only if the recipient agrees to be fully +* bound by these terms and conditions of this Agreement. +* +* SECTION 4 - NO WARRANTIES. +* THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY +* OF ANY KIND, INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, +* OR FITNESS FOR A PARTICULAR PURPOSE. NVIDIA does not warrant or assume +* responsibility for the accuracy or completeness of any information, +* text, graphics, links or other items contained within the Software. +* NVIDIA does not represent that errors or other defects will be +* identified or corrected. +* +* SECTION 5 - LIMITATION OF LIABILITY. +* EXCEPT WITH RESPECT TO THE MISUSE OF THE OTHER PARTY�S INTELLECTUAL +* PROPERTY OR DISCLOSURE OF THE OTHER PARTY�S CONFIDENTIAL INFORMATION IN +* BREACH OF THIS AGREEMENT, IN NO EVENT SHALL NVIDIA, SUBSIDIARIES, +* LICENSORS, OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER +* (INCLUDING, WITHOUT LIMITATION, INDIRECT, LOST PROFITS, CONSEQUENTIAL, +* BUSINESS INTERRUPTION OR LOST INFORMATION) ARISING OUT OF THE USE OF OR +* INABILITY TO USE THE SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS PROHIBIT EXCLUSION OR +* LIMITATION OF LIABILITY FOR IMPLIED WARRANTIES OR CONSEQUENTIAL OR +* INCIDENTAL DAMAGES, SO THE ABOVE LIMITATION MAY NOT APPLY TO YOU. YOU +* MAY ALSO HAVE OTHER LEGAL RIGHTS THAT VARY FROM JURISDICTION TO +* JURISDICTION. NOTWITHSTANDING THE FOREGOING, NVIDIA�S AGGREGATE +* LIABILITY ARISING OUT OF THIS AGREEMENT SHALL NOT EXCEED ONE HUNDRED +* UNITED STATES DOLLARS (USD$100). +* +* SECTION 6 - TERM. +* This Agreement and the licenses granted hereunder shall be effective as +* of the date You download the applicable Software ("Effective Date") and +* continue for a period of one (1) year ("Initial Term") respectively, +* unless terminated earlier in accordance with the "Termination" provision +* of this Agreement. Unless either party notifies the other party of its +* intent to terminate this Agreement at least three (3) months prior to +* the end of the Initial Term or the applicable renewal period, this +* Agreement will be automatically renewed for one (1) year renewal periods +* thereafter, unless terminated in accordance with the "Termination" +* provision of this Agreement. +* +* SECTION 7 - TERMINATION. +* NVIDIA may terminate this Agreement at any time if You violate its +* terms. Upon termination, You will immediately destroy the Software or +* return all copies of the Software to NVIDIA, and certify to NVIDIA in +* writing that such actions have been completed. Upon termination or +* expiration of this Agreement the license grants to Licensee shall +* terminate, except that sublicenses rightfully granted by Licensee under +* this Agreement in connection with Section 1(b) and (c) of this Agreement +* provided by Licensee prior to the termination or expiration of this +* Agreement shall survive in accordance with their respective form of +* license terms and conditions. +* +* SECTION 8 - MISCELLANEOUS. +* +* SECTION 8.1 - SURVIVAL. +* Those provisions in this Agreement, which by their nature need to +* survive the termination or expiration of this Agreement, shall survive +* termination or expiration of the Agreement, including but not limited to +* Sections 2, 3, 4, 5, 7, and 8. +* +* SECTION 8.2 - APPLICABLE LAWS. +* Claims arising under this Agreement shall be governed by the laws of +* Delaware, excluding its principles of conflict of laws and the United +* Nations Convention on Contracts for the Sale of Goods. The state and/or +* federal courts residing in Santa Clara County, California shall have +* exclusive jurisdiction over any dispute or claim arising out of this +* Agreement. You may not export the Software in violation of applicable +* export laws and regulations. +* +* SECTION 8.3 - AMENDMENT. +* The Agreement shall not be modified except by a written agreement that +* names this Agreement and any provision to be modified, is dated +* subsequent to the Effective Date, and is signed by duly authorized +* representatives of both parties. +* +* SECTION 8.4 - NO WAIVER. +* No failure or delay on the part of either party in the exercise of any +* right, power or remedy under this Agreement or under law, or to insist +* upon or enforce performance by the other party of any of the provisions +* of this Agreement or under law, shall operate as a waiver thereof, nor +* shall any single or partial exercise of any right, power or remedy +* preclude other or further exercise thereof, or the exercise of any other +* right, power or remedy; rather the provision, right, or remedy shall be +* and remain in full force and effect. +* +* SECTION 8.5 - NO ASSIGNMENT. +* This Agreement and Licensee�s rights and obligations herein, may not be +* assigned, subcontracted, delegated, or otherwise transferred by Licensee +* without NVIDIA�s prior written consent, and any attempted assignment, +* subcontract, delegation, or transfer in violation of the foregoing will +* be null and void. The terms of this Agreement shall be binding upon +* Licensee�s assignees. +* +* SECTION 8.6 - GOVERNMENT RESTRICTED RIGHTS. +* The parties acknowledge that the Software is subject to U.S. export +* control laws and regulations. The parties agree to comply with all +* applicable international and national laws that apply to the Software, +* including the U.S. Export Administration Regulations, as well as +* end-user, end-use and destination restrictions issued by U.S. and other +* governments. +* +* The Software has been developed entirely at private expense and is +* commercial computer software provided with RESTRICTED RIGHTS. Use, +* duplication or disclosure of the Software by the U.S. Government or a +* U.S. Government subcontractor is subject to the restrictions set forth +* in the Agreement under which the Software was obtained pursuant to DFARS +* 227.7202-3(a) or as set forth in subparagraphs (c)(1) and (2) of the +* Commercial Computer Software - Restricted Rights clause at FAR +* 52.227-19, as applicable. Contractor/manufacturer is NVIDIA, 2701 San +* Tomas Expressway, Santa Clara, CA 95050. Use of the Software by the +* Government constitutes acknowledgment of NVIDIA's proprietary rights +* therein. +* +* SECTION 8.7 - INDEPENDENT CONTRACTORS. +* Licensee�s relationship to NVIDIA is that of an independent contractor, +* and neither party is an agent or partner of the other. Licensee will +* not have, and will not represent to any third party that it has, any +* authority to act on behalf of NVIDIA. +* +* SECTION 8.8 - SEVERABILITY. +* If for any reason a court of competent jurisdiction finds any provision +* of this Agreement, or portion thereof, to be unenforceable, that +* provision of the Agreement will be enforced to the maximum extent +* permissible so as to affect the intent of the parties, and the remainder +* of this Agreement will continue in full force and effect. This Agreement +* has been negotiated by the parties and their respective counsel and will +* be interpreted fairly in accordance with its terms and without any +* strict construction in favor of or against either party. +* +* SECTION 8.9 - ENTIRE AGREEMENT. +* This Agreement and NDA constitute the entire agreement between the +* parties with respect to the subject matter contemplated herein, and +* merges all prior and contemporaneous communications. +* +******************************************************************************/ + + +#include "settings.h" +#include "Nv.h" + +char OptionsFileName[] = "FurViewerOptions.txt"; +//std::vector<void *> AllocBlocks; + +using namespace std; + +void Error(const char *fmt, ...); +static int HexCharToInt(unsigned char c); +bool GetExePath(char* exe_path); +static int Hex2BytesToInt(const unsigned char *buf); +static oaFloat StrToFloat(const char *buf); +static void WriteFloat(FILE *fp, oaFloat val); +static void StripNewLine(char *str); +void *Alloc(size_t n); +char *StrDup(const char *str); + +bool GetExePath(char* exe_path) +{ +#if WIN32 + char delim = '\\'; +#else + char delim = '/'; +#endif + + DWORD dwRet; + dwRet = GetModuleFileNameA(NV_NULL, exe_path, MAX_PATH); + if ( dwRet == 0 ) + { + exe_path[0] = '\0'; + return false; + } + + int i; + for ( i = dwRet; i > 0; i-- ) + { + if ( exe_path[i-1] == delim ) + break; + } + exe_path[i] = '\0'; + + return true; +} + +void Error(const char *fmt, ...) +{ + va_list AP; + va_start(AP, fmt); + + char msg[1024]; + //fprintf(msg, "ERROR: "); + //vfprintf(msg, fmt, AP); + //fprintf(msg, "\n"); + sprintf(msg, fmt, AP); + OutputDebugStringA(msg); + assert(0); +// exit(-1); +} + +static int HexCharToInt(unsigned char c) +{ + if(c >= '0' && c <= '9') + return((int)(c - '0')); + + c = tolower(c); + if(c >= 'a' && c <= 'f') + return((int)(c - 'a' + 10)); + + return(0); +} + +static int Hex2BytesToInt(const unsigned char *buf) +{ + return(HexCharToInt(buf[0]) << 4 | HexCharToInt(buf[1])); +} + +static oaFloat StrToFloat(const char *buf) +{ + size_t Len = strlen(buf); + if(Len != sizeof(oaFloat) * 2) + return(0.0); + + oaFloat Ret; + unsigned char *Buf = (unsigned char *)&Ret; + for(int i=0; i < sizeof(oaFloat); ++i) + { + Buf[i] = Hex2BytesToInt((const unsigned char *)buf); + buf += 2; + } + + return(Ret); +} + +static void WriteFloat(FILE *fp, oaFloat val) +{ + unsigned char *Buf = (unsigned char *)&val; + for(int i=0; i < sizeof(oaFloat); ++i) + fprintf(fp, "%02x", Buf[i]); +} + +static void StripNewLine(char *str) +{ + size_t StrLen = strlen(str); + if(StrLen == 0) + return; + + for(size_t i=StrLen-1; i >= 0; --i) + if(str[i] == '\n') + { + str[i] = 0; + break; + } +} + +void *Alloc(size_t n) +{ + void *Ret = malloc(n); + assert(n != 0); + + //AllocBlocks.push_back(Ret); + return(Ret); +} + +char *StrDup(const char *str) +{ + assert(str != NV_NULL); + char *Ret = strdup(str); + + //AllocBlocks.push_back(Ret); + return(Ret); +} + +AppSettings::AppSettings() +{ + int NumOptions = 0; +} + +AppSettings::~AppSettings() +{ + Cleanup(); +} + +void AppSettings::InitOptions(void) +{ + { + oaNamedOption *Option; + + // Resolution (enum) + Option = &Options[NumOptions++]; + oaInitOption(Option); + Option->Name = "User/Resolution"; + Option->DataType = OA_TYPE_ENUM; + Option->Value.Enum = "640x480"; + + Options[NumOptions] = *Option; + Option = &Options[NumOptions++]; + Option->Value.Enum = "1024x768"; + + Options[NumOptions] = *Option; + Option = &Options[NumOptions++]; + Option->Value.Enum = "1200x768"; + + Options[NumOptions] = *Option; + Option = &Options[NumOptions++]; + Option->Value.Enum = "1600x1200"; + + // AA (enum) + Option = &Options[NumOptions++]; + oaInitOption(Option); + + Option->Name = "User/AA"; + Option->DataType = OA_TYPE_ENUM; + Option->Value.Enum = "Off"; + + Options[NumOptions] = *Option; + Option = &Options[NumOptions++]; + Option->Value.Enum = "2X"; + + Options[NumOptions] = *Option; + Option = &Options[NumOptions++]; + Option->Value.Enum = "4X"; + + Options[NumOptions] = *Option; + Option = &Options[NumOptions++]; + Option->Value.Enum = "8X"; + + // device id (int) + Option = &Options[NumOptions++]; + oaInitOption(Option); + Option->Name = "User/Device"; + Option->DataType = OA_TYPE_INT; + + Option->Value.Int = -1; // when -1 to choose a good GPU + + //Backdoor (enum) + Option = &Options[NumOptions++]; + oaInitOption(Option); + Option->Name = "User/Backdoor"; + Option->DataType = OA_TYPE_STRING; + Option->Value.String = ""; + + // HideUI (bool) + Option = &Options[NumOptions++]; + oaInitOption(Option); + Option->Name = "User/HideUI"; + Option->DataType = OA_TYPE_BOOL; + + Option->Value.Bool = OA_FALSE; + + // Perf mode (bool) + Option = &Options[NumOptions++]; + oaInitOption(Option); + Option->Name = "User/PerfMode"; + Option->DataType = OA_TYPE_BOOL; + + Option->Value.Bool = OA_FALSE; + + // Play (bool) + Option = &Options[NumOptions++]; + oaInitOption(Option); + Option->Name = "User/Play"; + Option->DataType = OA_TYPE_BOOL; + + Option->Value.Bool = OA_FALSE; + + // ProjectPath (string) + Option = &Options[NumOptions++]; + oaInitOption(Option); + Option->Name = "User/ProjectPath"; + Option->DataType = OA_TYPE_STRING; + Option->Value.String = ""; + + // FurAssetPath (string) + Option = &Options[NumOptions++]; + oaInitOption(Option); + Option->Name = "User/FurAssetPath"; + Option->DataType = OA_TYPE_STRING; + Option->Value.String = ""; + + // FurDemoPlaylist (string) + Option = &Options[NumOptions++]; + oaInitOption(Option); + Option->Name = "User/FurDemoPlaylist"; + Option->DataType = OA_TYPE_STRING; + Option->Value.String = ""; + + //Option = &Options[NumOptions++]; + //oaInitOption(Option); + //Option->Name = "r2_slight_fade"; + //Option->DataType = OA_TYPE_FLOAT; + //Option->MinValue.Float = 0.0; + //Option->MaxValue.Float = 100.0; + //Option->NumSteps = 200; + } + + //**************************************************************************** + //*** Init OptionValues + //**************************************************************************** + + // Initialize default options + for(int i=0; i < NumOptions; ++i) + { + string Name(Options[i].Name); + OptionValueMap[Name].Name = Options[i].Name; + OptionValueMap[Name].Type = Options[i].DataType; + OptionValueMap[Name].Value = Options[i].Value; + } + + InitDefaultOptions(); + /////////////////////////////////////////////////////// + // Load any persistent options if they've been previously set + ReadOptionsFile(); +} + +void AppSettings::InitDefaultOptions(void) +{ + oaValue Value; + + Value.Enum = "1200x768"; + SetOptionValue("User/Resolution", OA_TYPE_ENUM, &Value); + + Value.Enum = "8X"; + SetOptionValue("User/AA", OA_TYPE_ENUM, &Value); +} + +void AppSettings::SetOptionValue(const char *name, + oaOptionDataType type, + const oaValue *value) +{ + string Name(name); + assert(OptionValueMap.find(Name) != OptionValueMap.end()); + assert(OptionValueMap[Name].Type == type); + + switch(type) + { + case OA_TYPE_STRING: + OptionValueMap[Name].Value.String = StrDup(value->String); + break; + + case OA_TYPE_ENUM: + OptionValueMap[Name].Value.Enum = StrDup(value->Enum); + break; + + default: + OptionValueMap[Name].Value = *value; + } +} + +void AppSettings::ReadOptionsFile(void) +{ + char optionFile[MAX_PATH] = ""; + if(!GetExePath(optionFile)) + { + fprintf(stderr, "Cannot get exe path\r\n"); + } + strcat(optionFile, OptionsFileName); + + + FILE *FP = fopen(optionFile, "rb"); + if(!FP) + return; + + fprintf(stderr, "FurViewer: Reading options file \"%s\".\n", + optionFile); + fflush(stderr); + + char Line[1024] = ""; + int LineNum = 1; + while (fgets(Line, sizeof(Line), FP) != NV_NULL) + { + StripNewLine(Line); + if(Line[0] == 0) + continue; + + char *Name = strtok(Line, "\t"); + char *Value = strtok(NV_NULL, ""); + + if(!Name || !Value) + { + //Error("Invalid format in options file \"%s\" on line %d\n", + //OptionsFileName, + //LineNum); + continue; + } + + map<string, OptionValue>::const_iterator OptVal = + OptionValueMap.find(string(Name)); + + if(OptVal == OptionValueMap.end()) + Error("Unknown option \"%s\" defined in options file \"%s\" on line %d.", + Name, + OptionsFileName, + LineNum); + + SetOptionValue(Name, OptVal->second.Type, Value); + + LineNum++; + } + + fclose(FP); +} + +void AppSettings::Cleanup(void) +{ + //vector<void *>::iterator Iter = AllocBlocks.begin(); + //for(; Iter != AllocBlocks.end(); Iter++) + // free(*Iter); + + //AllocBlocks.clear(); +} + + +void AppSettings::WriteOptionsFile(FILE *fp) +{ + map<string, OptionValue>::const_iterator Iter = OptionValueMap.begin(); + for(; Iter != OptionValueMap.end(); ++Iter) + { + fprintf(fp, "%s\t", Iter->second.Name); + switch(Iter->second.Type) + { + case OA_TYPE_INT: + fprintf(fp, "%d", Iter->second.Value.Int); + break; + + case OA_TYPE_BOOL: + fprintf(fp, "%d", (int)Iter->second.Value.Bool); + break; + + case OA_TYPE_FLOAT: + WriteFloat(fp, Iter->second.Value.Float); + break; + + case OA_TYPE_STRING: + fprintf(fp, "%s", Iter->second.Value.String); + break; + + case OA_TYPE_ENUM: + fprintf(fp, "%s", Iter->second.Value.Enum); + break; + + } + + fprintf(fp, "\n"); + } +} + +void AppSettings::WriteOptionsFile(void) +{ + char optionFile[MAX_PATH] = ""; + if(!GetExePath(optionFile)) + { + fprintf(stderr, "Cannot get exe path\r\n"); + } + strcat(optionFile, OptionsFileName); + + fprintf(stderr, "FurViewer: Writing options file \"%s\".\n", + optionFile); + fflush(stderr); + + FILE *FP = fopen(optionFile, "wb"); + if(!FP) + Error("Couldn't open \"%s\" for write.\n", optionFile); + + WriteOptionsFile(FP); + + fclose(FP); +} + +void AppSettings::SetOptionValue(const char *name, + oaOptionDataType type, + const char *value) +{ + assert(name != NV_NULL); + assert(type != OA_TYPE_INVALID); + assert(value != NV_NULL); + + oaValue Value; + switch(type) + { + case OA_TYPE_INT: + Value.Int = atoi(value); + break; + + case OA_TYPE_FLOAT: + Value.Float = StrToFloat(value); + break; + + case OA_TYPE_BOOL: + Value.Bool = atoi(value) ? OA_TRUE : OA_FALSE; + break; + + case OA_TYPE_STRING: + Value.String = (oaString)value; + break; + + case OA_TYPE_ENUM: + Value.Enum = (oaString)value; + break; + } + + SetOptionValue(name, type, &Value); +} + + + diff --git a/tools/ArtistTools/source/CoreLib/Utils/Settings.h b/tools/ArtistTools/source/CoreLib/Utils/Settings.h new file mode 100644 index 0000000..a845732 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Settings.h @@ -0,0 +1,392 @@ +/******************************************************************************* +* NVIDIA Corporation +* Software License Agreement - OpenAutomate SDK +* +* IMPORTANT - READ BEFORE COPYING, INSTALLING OR USING +* Do not use or load the OpenAutomate SDK and any associated materials +* provided by NVIDIA on NVIDIA�s website (collectively, the "Software") +* until You have carefully read the following terms and conditions. By +* loading or using the Software, You agree to fully comply with the terms +* and conditions of this Software License Agreement ("Agreement") by and +* between NVIDIA Corporation, a Delaware corporation with its principal +* place of business at 2701 San Tomas Expressway, Santa Clara, California +* 95050 U.S.A. ("NVIDIA"), and You. If You do not wish to so agree, do not +* install or use the Software. +* +* For the purposes of this Agreement: +* +* "Licensee," "You" and/or "Your" shall mean, collectively and +* individually, Original Equipment Manufacturers, Independent Hardware +* Vendors, Independent Software Vendors, and End-Users of the Software +* pursuant to the terms and conditions of this Agreement. +* +* "Derivative Works" shall mean derivatives of the Software created by You +* or a third party on Your behalf, which term shall include: (a) for +* copyrightable or copyrighted material, any translation, abridgement, +* revision or other form in which an existing work may be recast, +* transformed or adapted; (b) for work protected by topography or mask +* right, any translation, abridgement, revision or other form in which an +* existing work may be recast, transformed or adapted; (c) for patentable +* or patented material, any Improvement; and (d) for material protected by +* trade secret, any new material derived from or employing such existing +* trade secret. +* +* "Excluded License" is any license that requires as a condition of use, +* modification and/or distribution of software subject to the Excluded +* License, that such software or other software distributed and/or +* combined with such software be (i) disclosed or distributed in source +* code form, (ii) licensed for the purpose of making derivative works, or +* (iii) redistributable at no charge. +* +* SECTION 1 - GRANT OF LICENSE. +* NVIDIA agrees to provide the Software and any associated materials +* pursuant to the terms and conditions of this Agreement. Subject to the +* terms of this Agreement, NVIDIA grants to You a nonexclusive, +* transferable, worldwide, revocable, limited, royalty-free, fully paid-up +* license under NVIDIA�s copyrights to +* +* (a) install, deploy, use, have used execute, reproduce, display, +* perform, run, modify the source code of the Software, or to prepare and +* have prepared Derivative Works thereof the Software for Your own +* internal development, testing and maintenance purposes to incorporate +* the Software or Derivative Works thereof, in part or whole, into Your +* software applications; +* +* (b) to transfer, distribute and sublicense the Software (in its +* unmodified form as delivered to You by NVIDIA pursuant to this +* Agreement) in any medium or technology for Your sublicensees to +* incorporate the Software or Derivative Works thereof, in part or whole, +* into their respective software applications; and +* +* (c) to transfer, distribute and sublicense Derivative Works (in object +* code only) of the Software (i)_as incorporated in Your application +* software in any medium or technology; and (ii) certified as OpenAutomate +* Compatible Software. +* +* You may exercise your license rights pursuant to Subsection 1(b) and (c) +* above pursuant to the terms and conditions of any form of end-user +* software license agreement of Your choice, including but not limited to +* an Excluded License. +* +* In the event NVIDIA certifies Your application software, incorporating +* the Derivative Works (in object code only) of the Software, as +* OpenAutomate compatible ("OpenAutomate Compatible Software"), NVIDIA +* grants You a nonexclusive, worldwide, revocable, paid-up license to use +* the name and trademark to "OpenAutomate Compatible" solely for the +* purposes of identifying and/or marketing Your application software as +* OpenAutomate Compatible Software; provided that Licensee fully complies +* with the following: +* +* (x) Licensee agrees that it is strictly prohibited from using the name +* and trademark of "OpenAutomate Compatible" if Your application software +* is not OpenAutomate Compatible Software; +* +* (y) if NVIDIA objects to Your improper use of the "OpenAutomate +* Compatible" name and trademark, You will take all reasonable steps +* necessary to resolve NVIDIA�s objections. NVIDIA may reasonably monitor +* the quality of Your application software bearing the "OpenAutomate +* Compatible" name or trademark pursuant to this Agreement; and +* +* (z) any goodwill attached to NVIDIA�s trademarks, service marks, or +* trade names belong to NVIDIA and this Agreement does not grant You any +* right to use them. +* +* If You are not the final manufacturer or vendor of a computer system or +* software program incorporating the Software, or if Your Contractors (as +* defined below), affiliates or subsidiaries need to exercise any, some or +* all of the license grant described above herein to the Software on Your +* behalf, then You may transfer a copy of the Software, (and related +* end-user documentation) to such recipient for use in accordance with the +* terms of this Agreement, provided such recipient agrees to be fully +* bound by the terms hereof. Except as expressly permitted in this +* Agreement, Unless otherwise authorized in the Agreement, You shall not +* otherwise assign, sublicense, lease, or in any other way transfer or +* disclose Software to any third party. Unless otherwise authorized in the +* Agreement, You shall not reverse- compile, disassemble, +* reverse-engineer, or in any manner attempt to derive the source code of +* the Software from the object code portions of the Software. +* +* Except as expressly stated in this Agreement, no license or right is +* granted to You directly or by implication, inducement, estoppel or +* otherwise. NVIDIA shall have the right to inspect or have an independent +* auditor inspect Your relevant records to verify Your compliance with the +* terms and conditions of this Agreement. +* +* SECTION 2 - CONFIDENTIALITY. +* If applicable, any exchange of Confidential Information (as defined in +* the NDA) shall be made pursuant to the terms and conditions of a +* separately signed Non-Disclosure Agreement ("NDA") by and between NVIDIA +* and You. For the sake of clarity, You agree that the Software is +* Confidential Information of NVIDIA. +* +* If You wish to have a third party consultant or subcontractor +* ("Contractor") perform work on Your behalf which involves access to or +* use of Software, You shall obtain a written confidentiality agreement +* from the Contractor which contains terms and obligations with respect to +* access to or use of Software no less restrictive than those set forth in +* this Agreement and excluding any distribution or sublicense rights, and +* use for any other purpose than permitted in this Agreement. Otherwise, +* You shall not disclose the terms or existence of this Agreement or use +* NVIDIA's name in any publications, advertisements, or other +* announcements without NVIDIA's prior written consent. Unless otherwise +* provided in this Agreement, You do not have any rights to use any NVIDIA +* trademarks or logos. +* +* SECTION 3 - OWNERSHIP OF SOFTWARE AND INTELLECTUAL PROPERTY RIGHTS. +* All rights, title and interest to all copies of the Software remain with +* NVIDIA, subsidiaries, licensors, or its suppliers. The Software is +* copyrighted and protected by the laws of the United States and other +* countries, and international treaty provisions. You may not remove any +* copyright notices from the Software. NVIDIA may make changes to the +* Software, or to items referenced therein, at any time and without +* notice, but is not obligated to support or update the Software. Except +* as otherwise expressly provided, NVIDIA grants no express or implied +* right under any NVIDIA patents, copyrights, trademarks, or other +* intellectual property rights. +* +* All rights, title and interest in the Derivative Works of the Software +* remain with You subject to the underlying license from NVIDIA to the +* Software. In Your sole discretion, You may grant NVIDIA, upon NVIDIA�s +* request for such a license described herein, an irrevocable, perpetual, +* nonexclusive, worldwide, royalty-free paid-up license to make, have +* made, use, have used, sell, license, distribute, sublicense or otherwise +* transfer Derivative Works created by You that add functionality or +* improvement to the Software. +* +* You has no obligation to give NVIDIA any suggestions, comments or other +* feedback ("Feedback") relating to the Software. However, NVIDIA may use +* and include any Feedback that You voluntarily provide to improve the +* Software or other related NVIDIA technologies. Accordingly, if You +* provide Feedback, You agree NVIDIA and its licensees may freely use, +* reproduce, license, distribute, and otherwise commercialize the Feedback +* in the Software or other related technologies without the payment of any +* royalties or fees. +* +* You may transfer the Software only if the recipient agrees to be fully +* bound by these terms and conditions of this Agreement. +* +* SECTION 4 - NO WARRANTIES. +* THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY +* OF ANY KIND, INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, +* OR FITNESS FOR A PARTICULAR PURPOSE. NVIDIA does not warrant or assume +* responsibility for the accuracy or completeness of any information, +* text, graphics, links or other items contained within the Software. +* NVIDIA does not represent that errors or other defects will be +* identified or corrected. +* +* SECTION 5 - LIMITATION OF LIABILITY. +* EXCEPT WITH RESPECT TO THE MISUSE OF THE OTHER PARTY�S INTELLECTUAL +* PROPERTY OR DISCLOSURE OF THE OTHER PARTY�S CONFIDENTIAL INFORMATION IN +* BREACH OF THIS AGREEMENT, IN NO EVENT SHALL NVIDIA, SUBSIDIARIES, +* LICENSORS, OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER +* (INCLUDING, WITHOUT LIMITATION, INDIRECT, LOST PROFITS, CONSEQUENTIAL, +* BUSINESS INTERRUPTION OR LOST INFORMATION) ARISING OUT OF THE USE OF OR +* INABILITY TO USE THE SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS PROHIBIT EXCLUSION OR +* LIMITATION OF LIABILITY FOR IMPLIED WARRANTIES OR CONSEQUENTIAL OR +* INCIDENTAL DAMAGES, SO THE ABOVE LIMITATION MAY NOT APPLY TO YOU. YOU +* MAY ALSO HAVE OTHER LEGAL RIGHTS THAT VARY FROM JURISDICTION TO +* JURISDICTION. NOTWITHSTANDING THE FOREGOING, NVIDIA�S AGGREGATE +* LIABILITY ARISING OUT OF THIS AGREEMENT SHALL NOT EXCEED ONE HUNDRED +* UNITED STATES DOLLARS (USD$100). +* +* SECTION 6 - TERM. +* This Agreement and the licenses granted hereunder shall be effective as +* of the date You download the applicable Software ("Effective Date") and +* continue for a period of one (1) year ("Initial Term") respectively, +* unless terminated earlier in accordance with the "Termination" provision +* of this Agreement. Unless either party notifies the other party of its +* intent to terminate this Agreement at least three (3) months prior to +* the end of the Initial Term or the applicable renewal period, this +* Agreement will be automatically renewed for one (1) year renewal periods +* thereafter, unless terminated in accordance with the "Termination" +* provision of this Agreement. +* +* SECTION 7 - TERMINATION. +* NVIDIA may terminate this Agreement at any time if You violate its +* terms. Upon termination, You will immediately destroy the Software or +* return all copies of the Software to NVIDIA, and certify to NVIDIA in +* writing that such actions have been completed. Upon termination or +* expiration of this Agreement the license grants to Licensee shall +* terminate, except that sublicenses rightfully granted by Licensee under +* this Agreement in connection with Section 1(b) and (c) of this Agreement +* provided by Licensee prior to the termination or expiration of this +* Agreement shall survive in accordance with their respective form of +* license terms and conditions. +* +* SECTION 8 - MISCELLANEOUS. +* +* SECTION 8.1 - SURVIVAL. +* Those provisions in this Agreement, which by their nature need to +* survive the termination or expiration of this Agreement, shall survive +* termination or expiration of the Agreement, including but not limited to +* Sections 2, 3, 4, 5, 7, and 8. +* +* SECTION 8.2 - APPLICABLE LAWS. +* Claims arising under this Agreement shall be governed by the laws of +* Delaware, excluding its principles of conflict of laws and the United +* Nations Convention on Contracts for the Sale of Goods. The state and/or +* federal courts residing in Santa Clara County, California shall have +* exclusive jurisdiction over any dispute or claim arising out of this +* Agreement. You may not export the Software in violation of applicable +* export laws and regulations. +* +* SECTION 8.3 - AMENDMENT. +* The Agreement shall not be modified except by a written agreement that +* names this Agreement and any provision to be modified, is dated +* subsequent to the Effective Date, and is signed by duly authorized +* representatives of both parties. +* +* SECTION 8.4 - NO WAIVER. +* No failure or delay on the part of either party in the exercise of any +* right, power or remedy under this Agreement or under law, or to insist +* upon or enforce performance by the other party of any of the provisions +* of this Agreement or under law, shall operate as a waiver thereof, nor +* shall any single or partial exercise of any right, power or remedy +* preclude other or further exercise thereof, or the exercise of any other +* right, power or remedy; rather the provision, right, or remedy shall be +* and remain in full force and effect. +* +* SECTION 8.5 - NO ASSIGNMENT. +* This Agreement and Licensee�s rights and obligations herein, may not be +* assigned, subcontracted, delegated, or otherwise transferred by Licensee +* without NVIDIA�s prior written consent, and any attempted assignment, +* subcontract, delegation, or transfer in violation of the foregoing will +* be null and void. The terms of this Agreement shall be binding upon +* Licensee�s assignees. +* +* SECTION 8.6 - GOVERNMENT RESTRICTED RIGHTS. +* The parties acknowledge that the Software is subject to U.S. export +* control laws and regulations. The parties agree to comply with all +* applicable international and national laws that apply to the Software, +* including the U.S. Export Administration Regulations, as well as +* end-user, end-use and destination restrictions issued by U.S. and other +* governments. +* +* The Software has been developed entirely at private expense and is +* commercial computer software provided with RESTRICTED RIGHTS. Use, +* duplication or disclosure of the Software by the U.S. Government or a +* U.S. Government subcontractor is subject to the restrictions set forth +* in the Agreement under which the Software was obtained pursuant to DFARS +* 227.7202-3(a) or as set forth in subparagraphs (c)(1) and (2) of the +* Commercial Computer Software - Restricted Rights clause at FAR +* 52.227-19, as applicable. Contractor/manufacturer is NVIDIA, 2701 San +* Tomas Expressway, Santa Clara, CA 95050. Use of the Software by the +* Government constitutes acknowledgment of NVIDIA's proprietary rights +* therein. +* +* SECTION 8.7 - INDEPENDENT CONTRACTORS. +* Licensee�s relationship to NVIDIA is that of an independent contractor, +* and neither party is an agent or partner of the other. Licensee will +* not have, and will not represent to any third party that it has, any +* authority to act on behalf of NVIDIA. +* +* SECTION 8.8 - SEVERABILITY. +* If for any reason a court of competent jurisdiction finds any provision +* of this Agreement, or portion thereof, to be unenforceable, that +* provision of the Agreement will be enforced to the maximum extent +* permissible so as to affect the intent of the parties, and the remainder +* of this Agreement will continue in full force and effect. This Agreement +* has been negotiated by the parties and their respective counsel and will +* be interpreted fairly in accordance with its terms and without any +* strict construction in favor of or against either party. +* +* SECTION 8.9 - ENTIRE AGREEMENT. +* This Agreement and NDA constitute the entire agreement between the +* parties with respect to the subject matter contemplated herein, and +* merges all prior and contemporaneous communications. +* +******************************************************************************/ + + +#ifndef _SETTINGS_H +#define _SETTINGS_H + +#include <assert.h> +#include <ctype.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <vector> +#include <map> +#include <string> +#include <conio.h> +#include <OpenAutomate.h> + +#include "corelib_global.h" + +#if WIN32 +# include <windows.h> +# define SLEEP(ms) Sleep(ms) +#else +# include <unistd.h> +# define SLEEP(ms) usleep(1000 * (ms)) +#endif + +void Error(const char *fmt, ...); +bool GetExePath(char* exe_path); + +struct OptionValue +{ + const char *Name; + oaOptionDataType Type; + oaValue Value; +}; + +class CORELIB_EXPORT AppSettings +{ +public: + AppSettings(); + ~AppSettings(); + + static AppSettings& Inst() + { + static AppSettings s_inst; + return s_inst; + } + + void InitOptions(); + + void WriteOptionsFile(); + + void SetOptionValue(const char *name, + oaOptionDataType type, + const oaValue *value); + + int GetNumOptions(){return NumOptions;} + + oaNamedOption* GetOption(int i){return &Options[i];} + + OptionValue* GetOptionValue(char* opt_name) + { + return &OptionValueMap[opt_name]; + } + + std::map<std::string, OptionValue>* GetCurrentOptionMap() + { + return &OptionValueMap; + } + +private: + + void Cleanup(); + + void InitDefaultOptions(); + + void ReadOptionsFile(); + + void WriteOptionsFile(FILE *fp); + + void SetOptionValue(const char *name, + oaOptionDataType type, + const char *value); + + oaNamedOption Options[128]; + std::map<std::string, OptionValue> OptionValueMap; + + int NumOptions; +}; + +#endif
\ No newline at end of file diff --git a/tools/ArtistTools/source/CoreLib/Utils/Stats.cpp b/tools/ArtistTools/source/CoreLib/Utils/Stats.cpp new file mode 100644 index 0000000..d52aa14 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Stats.cpp @@ -0,0 +1,76 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// +/////////////////////////////////////////////////////////////////////////////// +#include "Stats.h" + +void Stats::reset() +{ + m_totalRenderTime = 0.0f; + m_shadowRenderTime = 0.0f; + m_meshRenderTime = 0.0f; + m_hairRenderTime = 0.0f; + m_hairStatsTime = 0.0f; + m_totalUpdateTime = 0.0f; + m_meshSkinningTime = 0.0f; + m_hairSkinningTime = 0.0f; + m_hairSimulationTime = 0.0f; + m_queryTime = 0.0f; +} + +/////////////////////////////////////////////////////////////////////////////// +void Stats::add(const Stats& toAdd) +{ + m_totalRenderTime += toAdd.m_totalRenderTime; + m_shadowRenderTime += toAdd.m_shadowRenderTime; + m_meshRenderTime += toAdd.m_meshRenderTime; + m_hairRenderTime += toAdd.m_hairRenderTime; + m_hairStatsTime += toAdd.m_hairStatsTime; + + m_totalUpdateTime += toAdd.m_totalUpdateTime; + m_meshSkinningTime += toAdd.m_meshSkinningTime; + m_hairSkinningTime += toAdd.m_hairSkinningTime; + m_hairSimulationTime += toAdd.m_hairSimulationTime; + + m_queryTime += toAdd.m_queryTime; +} + +/////////////////////////////////////////////////////////////////////////////// +void Stats::average(float numFrames) +{ + m_totalRenderTime /= numFrames; + m_shadowRenderTime /= numFrames; + m_meshRenderTime /= numFrames; + m_hairRenderTime /= numFrames; + m_hairStatsTime /= numFrames; + m_totalUpdateTime /= numFrames; + m_meshSkinningTime /= numFrames; + m_hairSkinningTime /= numFrames; + m_hairSimulationTime /= numFrames; + m_queryTime /= numFrames; +} + diff --git a/tools/ArtistTools/source/CoreLib/Utils/Stats.h b/tools/ArtistTools/source/CoreLib/Utils/Stats.h new file mode 100644 index 0000000..fb22e57 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Stats.h @@ -0,0 +1,54 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +#pragma once + +#include "corelib_global.h" + +// scene statistics +struct CORELIB_EXPORT Stats +{ + double m_totalRenderTime; + double m_shadowRenderTime; + double m_meshRenderTime; + double m_hairRenderTime; + double m_hairStatsTime; + + double m_totalUpdateTime; + double m_meshSkinningTime; + double m_hairSkinningTime; + double m_hairSimulationTime; + + double m_queryTime; + + Stats() { reset(); } + + void reset(); + void add(const Stats& toAdd); + void average(float numFrames); +};
\ No newline at end of file diff --git a/tools/ArtistTools/source/CoreLib/Utils/Timer.cpp b/tools/ArtistTools/source/CoreLib/Utils/Timer.cpp new file mode 100644 index 0000000..2161989 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Timer.cpp @@ -0,0 +1,80 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +#include "Timer.h" + +Timer::Timer(bool isStartNow) +{ + ::QueryPerformanceFrequency(&m_ticksPerSecond); + Reset(isStartNow); +} + +void Timer::Reset(bool isStartNow) +{ + m_isPaused = true; + m_totalPausedTime.QuadPart = 0; + m_lastPausedTime.QuadPart = 0; + if (isStartNow) + { + Start(); + } +} + +void Timer::Start() +{ + if (m_isPaused) + { + LARGE_INTEGER timeNow; + ::QueryPerformanceCounter(&timeNow); + m_totalPausedTime.QuadPart += timeNow.QuadPart - m_lastPausedTime.QuadPart; + m_isPaused = false; + } +} + +void Timer::Pause() +{ + if (!m_isPaused) + { + m_isPaused = true; + ::QueryPerformanceCounter(&m_lastPausedTime); + } +} + +LONGLONG Timer::GetTicksElapsed() const +{ + LARGE_INTEGER timeNow; + if (m_isPaused) + { + timeNow = m_lastPausedTime; + } + else + { + ::QueryPerformanceCounter(&timeNow); + } + return (timeNow.QuadPart - m_totalPausedTime.QuadPart); +} diff --git a/tools/ArtistTools/source/CoreLib/Utils/Timer.h b/tools/ArtistTools/source/CoreLib/Utils/Timer.h new file mode 100644 index 0000000..c14ff97 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/Timer.h @@ -0,0 +1,68 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +#pragma once + +#define WIN32_LEAN_AND_MEAN +#include <Windows.h> + +#include "corelib_global.h" + +class CORELIB_EXPORT Timer +{ +public: + Timer(bool isStartNow = false); + void Start(); + void Reset(bool isStartNow = false); + void Pause(); + bool IsRunning() const + { + return !m_isPaused; + } + double GetTimeInMilliSeconds() const + { + return double(GetTicksElapsed()*1000.0) / GetTicksPerSecond(); + } + double GetTimeInSeconds() const + { + return double(GetTicksElapsed()) / GetTicksPerSecond(); + } + +public: + bool m_isPaused; + + // Get time ticks elapsed + LONGLONG GetTicksElapsed() const; + // Get the timer frequency. Time tick count per second + LONGLONG GetTicksPerSecond() const { + return m_ticksPerSecond.QuadPart; + } + LARGE_INTEGER m_ticksPerSecond; + LARGE_INTEGER m_lastPausedTime; + LARGE_INTEGER m_totalPausedTime; +}; diff --git a/tools/ArtistTools/source/CoreLib/Utils/ViewerOutput.cpp b/tools/ArtistTools/source/CoreLib/Utils/ViewerOutput.cpp new file mode 100644 index 0000000..d5486bc --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/ViewerOutput.cpp @@ -0,0 +1,75 @@ +#include <windows.h> +#include "ViewerOutput.h" + +ViewerOutput& ViewerOutput::Inst() +{ + static ViewerOutput inst; + return inst; +} + +void ViewerOutput::RegisterPrinter( FrontPrinter* printer ) +{ + if(!printer) return; + + _printers.insert(printer); +} + +void ViewerOutput::UnRegisterPrinter( FrontPrinter* printer ) +{ + if(!printer) return; + + auto itr = _printers.find(printer); + if(itr != _printers.end()) + _printers.erase(itr); +} + +void ViewerOutput::print( FrontPrinter::Effect e, unsigned long color, const char* fmt, ... ) +{ + va_list args; + va_start(args, fmt); + + vsprintf_s(_buf, MAX_BUFFER_SIZE, fmt, args); + + va_end(args); + + for (auto itr = _printers.begin(); itr != _printers.end(); ++itr) + { + (*itr)->print(_buf, color, e); + } +} + +////////////////////////////////////////////////////////////////////////// +ViewerStream::~ViewerStream() +{ + flush(); +} + +ViewerStream& ViewerStream::flush() +{ + this->std::ostream::flush(); + + if(_buffer.size() == 0) + return (*this); + + ViewerOutput::Inst().print(_effect, _color, _buffer.buf); + _buffer.reset(); + + return (*this); +} + +ViewerStream::ViewerStreamBuf::ViewerStreamBuf() +{ + reset(); +} + +std::streamsize ViewerStream::ViewerStreamBuf::size() +{ + return (pptr() - pbase()); +} + +void ViewerStream::ViewerStreamBuf::reset() +{ + memset(buf, 0, sizeof(buf)); + setp(buf, buf + FURVIEWER_MAX_OUTPUT_CHAR); +} + diff --git a/tools/ArtistTools/source/CoreLib/Utils/ViewerOutput.h b/tools/ArtistTools/source/CoreLib/Utils/ViewerOutput.h new file mode 100644 index 0000000..b1fb9f7 --- /dev/null +++ b/tools/ArtistTools/source/CoreLib/Utils/ViewerOutput.h @@ -0,0 +1,136 @@ +// This code contains NVIDIA Confidential Information and is disclosed +// under the Mutual Non-Disclosure Agreement. +// +// Notice +// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES +// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +// +// NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless +// expressly authorized by NVIDIA. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2013-2015 NVIDIA Corporation. All rights reserved. +// +// NVIDIA Corporation and its licensors retain all intellectual property and proprietary +// rights in and to this software and related documentation and any modifications thereto. +// Any use, reproduction, disclosure or distribution of this software and related +// documentation without an express license agreement from NVIDIA Corporation is +// strictly prohibited. +// + +#pragma once + +#include <set> + +#include "corelib_global.h" + +/* + * !! CAUSION: + * Not thread safe, should only output messages in the MAIN thread! + * Otherwise, cannot guarantee the Qt Gui behavior. + */ + +// DON'T TRY TO WRITE CHARS MORE THAN THE FURVIEWER_MAX_OUTPUT_CHAR +#define FURVIEWER_MAX_OUTPUT_CHAR 2048 + +// c-style print +#define viewer_msg(fmt, ...) ViewerOutput::Inst().print(FrontPrinter::NONE, 0, fmt, ##__VA_ARGS__) +#define viewer_warn(fmt, ...) ViewerOutput::Inst().print(FrontPrinter::NONE, RGB(255,200,020), fmt, ##__VA_ARGS__) +#define viewer_info(fmt, ...) ViewerOutput::Inst().print(FrontPrinter::NONE, RGB(118,185,000), fmt, ##__VA_ARGS__) +#define viewer_err(fmt, ...) ViewerOutput::Inst().print(FrontPrinter::NONE, RGB(255,000,000), fmt, ##__VA_ARGS__) +#define viewer_fatal(fmt, ...) ViewerOutput::Inst().print(FrontPrinter::BOLD, RGB(255,000,000), fmt, ##__VA_ARGS__) + +// c++ style output stream +#define viewer_stream_msg ViewerStream(FrontPrinter::NONE, 0) +#define viewer_stream_warn ViewerStream(FrontPrinter::NONE, RGB(255,200,020)) +#define viewer_stream_info ViewerStream(FrontPrinter::NONE, RGB(118,185,000)) +#define viewer_stream_err ViewerStream(FrontPrinter::NONE, RGB(255,000,000)) +#define viewer_stream_fatal ViewerStream(FrontPrinter::NONE, RGB(255,000,000)) + + +////////////////////////////////////////////////////////////////////////// +// implementation +////////////////////////////////////////////////////////////////////////// +class FrontPrinter +{ +public: + enum Effect + { + NONE = 0x0, + BOLD = 0x1, + ITALIC = 0x2, + UNDERLINE = 0x4 + }; + + virtual void print(const char* txt, unsigned long color = 0, Effect e = NONE) = 0; +}; + +class CORELIB_EXPORT ViewerOutput +{ +public: + static ViewerOutput& Inst(); + + void RegisterPrinter(FrontPrinter* printer); + void UnRegisterPrinter(FrontPrinter* printer); + + void print(FrontPrinter::Effect e, unsigned long color, const char* fmt, ...); + +private: + enum {MAX_BUFFER_SIZE = FURVIEWER_MAX_OUTPUT_CHAR + 1}; + + char _buf[MAX_BUFFER_SIZE]; + + std::set<FrontPrinter*> _printers; +}; + + +////////////////////////////////////////////////////////////////////////// +// stream to support c++ style output + +#include <streambuf> +#include <sstream> + +class ViewerStream : public std::ostream +{ +public: + explicit ViewerStream(FrontPrinter::Effect e, unsigned long color) + : std::ostream(&_buffer) + , _effect(e) + , _color(color) + {} + + ~ViewerStream(); + + ViewerStream& flush(); + +private: + + class ViewerStreamBuf : public std::streambuf + { + public: + enum + { + STATIC_BUFFER_SIZE = FURVIEWER_MAX_OUTPUT_CHAR + 1, + }; + + ViewerStreamBuf(); + + void reset(); + std::streamsize size(); + + // fixed stack buffer + char buf[STATIC_BUFFER_SIZE]; + }; + + ViewerStreamBuf _buffer; + FrontPrinter::Effect _effect; + unsigned long _color; +}; |