diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..a4cf70872 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# https://editorconfig.org/ + +root = true + +[*] +tab_width = 3 +indent_style = space +indent_size = 3 + +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf +charset = utf-8 diff --git a/.travis.yml b/.travis.yml index 8e5970686..72177bad3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,42 @@ language: cpp -compiler: - - clang - - gcc + +dist: xenial + +matrix: + include: + - os: osx + compiler: clang + env: if CXXFLAGS="-fgnu-inline-asm -fasm-blocks" + - os: linux + compiler: gcc + - os: linux + compiler: clang + +addons: + apt: + packages: + - build-essential + - nasm + - libogg-dev + - libxft-dev + - libx11-dev + - libxxf86vm-dev + - libopenal-dev + - libfreetype6-dev + - libxcursor-dev + - libxinerama-dev + - libxi-dev + - libxrandr-dev + - libxss-dev + - libglu1-mesa-dev + - libgtk-3-dev + +script: + - mkdir -p My\ Projects/TestProject/buildFiles/travis/ + - cd My\ Projects/TestProject/buildFiles/travis/ + - cmake ../../../.. -DTORQUE_APP_NAME=TestProject -DCMAKE_BUILD_TYPE=Debug + - make 2>/dev/null # Do the actual build, but ignore all the warnings + - make # build again. This time all output is printed but the warnings that happened earlier do not happen again + - make install + - cd ../../game/ + - ls diff --git a/Engine/lib/nativeFileDialogs/README.md b/Engine/lib/nativeFileDialogs/README.md index 7ff1008a3..83238e133 100644 --- a/Engine/lib/nativeFileDialogs/README.md +++ b/Engine/lib/nativeFileDialogs/README.md @@ -1,6 +1,6 @@ # Native File Dialog # -A tiny, neat C library that portably invokes native file open and save dialogs. Write dialog code once and have it pop up native dialogs on all supported platforms. Avoid linking large dependencies like wxWidgets and qt. +A tiny, neat C library that portably invokes native file open, folder select and save dialogs. Write dialog code once and have it pop up native dialogs on all supported platforms. Avoid linking large dependencies like wxWidgets and qt. Features: @@ -11,11 +11,12 @@ Features: - Paid support available. - Multiple file selection support. - 64-bit and 32-bit friendly. - - GCC, Clang and Visual Studio supported. - - No third party dependencies. + - GCC, Clang, Xcode, Mingw and Visual Studio supported. + - No third party dependencies for building or linking. - Support for Vista's modern `IFileDialog` on Windows. - Support for non-deprecated Cocoa APIs on OS X. - - GTK+3 dialog on Linux. + - GTK3 dialog on Linux. + - Optional Zenity support on Linux to avoid linking GTK. - Tested, works alongside [http://www.libsdl.org](SDL2) on all platforms, for the game developers out there. # Example Usage # @@ -50,47 +51,74 @@ See [NFD.h](src/include/nfd.h) for more options. # Screenshots # -![Windows 8 rendering an IFileOpenDialog](screens/open_win8.png?raw=true) +![Windows 8 rendering an IFileOpenDialog](screens/open_win.png?raw=true) ![GTK3 on Linux](screens/open_gtk3.png?raw=true) ![Cocoa on Yosemite](screens/open_cocoa.png?raw=true) +## Changelog ## + +release | what's new | date +--------|-----------------------------|--------- +1.0.0 | initial | oct 2014 +1.1.0 | premake5; scons deprecated | aug 2016 +1.1.1 | mingw support, build fixes | aug 2016 +1.1.2 | test_pickfolder() added | aug 2016 +1.1.3 | zenity linux backend added | nov 2017 +1.1.3 | fix char type in decls | nov 2017 +1.1.4 | fix win32 memleaks | dec 2018 +1.1.4 | improve win32 errorhandling | dec 2018 +1.1.4 | macos fix focus bug | dec 2018 + ## Building ## -NFD uses [SCons](http://www.scons.org) for cross-platform builds. After installing SCons, build it with: +NFD uses [Premake5](https://premake.github.io/download.html) generated Makefiles and IDE project files. The generated project files are checked in under `build/` so you don't have to download and use Premake in most cases. - cd src - scons debug=[0,1] +If you need to run Premake5 directly, further [build documentation](docs/build.md) is available. -Alternatively, you can avoid Scons by just including NFD files to your existing project: +Previously, NFD used SCons to build. It still works, but is now deprecated; updates to it are discouraged. Opt to use the native build system where possible. - 1. Add all header files in `src/` and `src/include` to your project. - 2. Add `src/include` to your include search path or copy it into your existing search path. - 3. Add `src/nfd_common.c` to your project. - 4. Add `src/nfd_` to your project, where `` is the NFD backend for the platform you are fixing to build. - 5. On Visual Studio, define `_CRT_SECURE_NO_WARNINGS` to avoid warnings. +`nfd.a` will be built for release builds, and `nfd_d.a` will be built for debug builds. + +### Makefiles ### + +The makefile offers five options, with `release_x64` as the default. + + make config=release_x86 + make config=release_x64 + make config=debug_x86 + make config=debug_x64 ### Compiling Your Programs ### 1. Add `src/include` to your include search path. - 2. Add `nfd.lib` to the list of list of static libraries to link against. - 3. Add `src/` to the library search path. + 2. Add `nfd.lib` or `nfd_d.lib` to the list of list of static libraries to link against (for release or debug, respectively). + 3. Add `build//` to the library search path. -On Linux, you must compile and link against GTK+. Recommend use of `pkg-config --cflags --libs gtk+-3.0`. +#### Linux GTK #### +`apt-get libgtk-3-dev` installs the gtk dependency for library compilation. -On Mac OS X, add `AppKit` to the list of frameworks. +On Linux, you have the option of compiling and linking against GTK. If you use it, the recommended way to compile is to include the arguments of `pkg-config --cflags --libs gtk+-3.0`. +#### Linux Zenity #### + +Alternatively, you can use the Zenity backend by running the Makefile in `build/gmake_linux_zenity`. Zenity runs the dialog in its own address space, but requires the user to have Zenity correctly installed and configured on their system. + +#### MacOS #### +On Mac OS, add `AppKit` to the list of frameworks. + +#### Windows #### On Windows, ensure you are building against `comctl32.lib`. ## Usage ## See `NFD.h` for API calls. See `tests/*.c` for example code. -See `tests/SConstruct` for a working build script that compiles on all platforms. +After compiling, `build/bin` contains compiled test programs. ## File Filter Syntax ## -There is a form of file filtering in every file dialog, but no consistent means of supporting it. NFD provides support for filtering files by groups of extensions, providing its own descriptions (where applicable) for the extensions. +There is a form of file filtering in every file dialog API, but no consistent means of supporting it. NFD provides support for filtering files by groups of extensions, providing its own descriptions (where applicable) for the extensions. A wildcard filter is always added to every dialog. @@ -113,16 +141,14 @@ See [test_opendialogmultiple.c](test/test_opendialogmultiple.c). # Known Limitations # -I accept quality code patches, or will resolve these and other matters through support. +I accept quality code patches, or will resolve these and other matters through support. See [submitting pull requests](docs/submitting_pull_requests.md) for details. - No support for Windows XP's legacy dialogs such as `GetOpenFileName`. - - No support for file filter names -- ex: "Image Files" (*.png, *.jpg). Nameless filters are supported, though. - - No support for selecting folders instead of files. - - On Linux, GTK+ cannot be uninitialized to save memory. Launching a file dialog costs memory. I am open to accepting an alternative `nfd_zenity.c` implementation which uses Zenity and pipes. + - No support for file filter names -- ex: "Image Files" (*.png, *.jpg). Nameless filters are supported, however. # Copyright and Credit # -Copyright © 2014 [Frogtoss Games](http://www.frogtoss.com), Inc. +Copyright © 2014-2017 [Frogtoss Games](http://www.frogtoss.com), Inc. File [LICENSE](LICENSE) covers all files in this repo. Native File Dialog by Michael Labbe @@ -130,6 +156,10 @@ Native File Dialog by Michael Labbe Tomasz Konojacki for [microutf8](http://puszcza.gnu.org.ua/software/microutf8/) +[Denis Kolodin](https://github.com/DenisKolodin) for mingw support. + +[Tom Mason](https://github.com/wheybags) for Zenity support. + ## Support ## Directed support for this work is available from the original author under a paid agreement. diff --git a/Engine/lib/nativeFileDialogs/nfd_cocoa.m b/Engine/lib/nativeFileDialogs/nfd_cocoa.m index d3fb48347..39a0931de 100644 --- a/Engine/lib/nativeFileDialogs/nfd_cocoa.m +++ b/Engine/lib/nativeFileDialogs/nfd_cocoa.m @@ -117,7 +117,7 @@ static nfdresult_t AllocPathSet( NSArray *urls, nfdpathset_t *pathset ) /* public */ -nfdresult_t NFD_OpenDialog( const char *filterList, +nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList, const nfdchar_t *defaultPath, nfdchar_t **outPath ) { @@ -146,6 +146,7 @@ nfdresult_t NFD_OpenDialog( const char *filterList, if ( !*outPath ) { [pool release]; + [keyWindow makeKeyAndOrderFront:nil]; return NFD_ERROR; } memcpy( *outPath, utf8Path, len+1 ); /* copy null term */ @@ -163,6 +164,7 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, nfdpathset_t *outPaths ) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSWindow *keyWindow = [[NSApplication sharedApplication] keyWindow]; NSOpenPanel *dialog = [NSOpenPanel openPanel]; [dialog setAllowsMultipleSelection:YES]; @@ -181,12 +183,14 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, if ( [urls count] == 0 ) { [pool release]; + [keyWindow makeKeyAndOrderFront:nil]; return NFD_CANCEL; } if ( AllocPathSet( urls, outPaths ) == NFD_ERROR ) { [pool release]; + [keyWindow makeKeyAndOrderFront:nil]; return NFD_ERROR; } @@ -194,6 +198,7 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, } [pool release]; + [keyWindow makeKeyAndOrderFront:nil]; return nfdResult; } @@ -203,7 +208,8 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, nfdchar_t **outPath ) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - + NSWindow *keyWindow = [[NSApplication sharedApplication] keyWindow]; + NSSavePanel *dialog = [NSSavePanel savePanel]; [dialog setExtensionHidden:NO]; @@ -225,6 +231,7 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, if ( !*outPath ) { [pool release]; + [keyWindow makeKeyAndOrderFront:nil]; return NFD_ERROR; } memcpy( *outPath, utf8Path, byteLen ); @@ -232,7 +239,7 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, } [pool release]; - + [keyWindow makeKeyAndOrderFront:nil]; return nfdResult; } @@ -241,7 +248,7 @@ nfdresult_t NFD_PickFolder(const nfdchar_t *defaultPath, { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSWindow *keyWindow = [[NSApplication sharedApplication] keyWindow]; + NSWindow *keyWindow = [[NSApplication sharedApplication] keyWindow]; NSOpenPanel *dialog = [NSOpenPanel openPanel]; [dialog setAllowsMultipleSelection:NO]; [dialog setCanChooseDirectories:YES]; @@ -264,6 +271,7 @@ nfdresult_t NFD_PickFolder(const nfdchar_t *defaultPath, if ( !*outPath ) { [pool release]; + [keyWindow makeKeyAndOrderFront:nil]; return NFD_ERROR; } memcpy( *outPath, utf8Path, len+1 ); /* copy null term */ diff --git a/Engine/lib/nativeFileDialogs/nfd_gtk.c b/Engine/lib/nativeFileDialogs/nfd_gtk.c index 65bc41dad..7a9958ed1 100644 --- a/Engine/lib/nativeFileDialogs/nfd_gtk.c +++ b/Engine/lib/nativeFileDialogs/nfd_gtk.c @@ -165,7 +165,7 @@ static void WaitForCleanup(void) /* public */ -nfdresult_t NFD_OpenDialog( const char *filterList, +nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList, const nfdchar_t *defaultPath, nfdchar_t **outPath ) { diff --git a/Engine/lib/nativeFileDialogs/nfd_win.cpp b/Engine/lib/nativeFileDialogs/nfd_win.cpp index 1187fc84b..9e94d9d58 100644 --- a/Engine/lib/nativeFileDialogs/nfd_win.cpp +++ b/Engine/lib/nativeFileDialogs/nfd_win.cpp @@ -4,6 +4,10 @@ http://www.frogtoss.com/labs */ +#define _CRTDBG_MAP_ALLOC +#include +#include + /* only locally define UNICODE in this compilation unit */ #ifndef UNICODE #define UNICODE @@ -19,7 +23,7 @@ #include #include #include -#include +#include #include "nfd_common.h" @@ -47,9 +51,9 @@ static void CopyWCharToNFDChar( const wchar_t *inStr, nfdchar_t **outStr ) /* includes NULL terminator byte in return */ static size_t GetUTF8ByteCountForWChar( const wchar_t *str ) { - int bytesNeeded = WideCharToMultiByte( CP_UTF8, 0, - str, -1, - NULL, 0, NULL, NULL ); + size_t bytesNeeded = WideCharToMultiByte( CP_UTF8, 0, + str, -1, + NULL, 0, NULL, NULL ); assert( bytesNeeded ); return bytesNeeded+1; } @@ -148,12 +152,12 @@ static nfdresult_t AddFiltersToDialog( ::IFileDialog *fileOpenDialog, const char } /* filterCount plus 1 because we hardcode the *.* wildcard after the while loop */ - COMDLG_FILTERSPEC *specList = (COMDLG_FILTERSPEC*)NFDi_Malloc( sizeof(COMDLG_FILTERSPEC) * (filterCount + 1) ); + COMDLG_FILTERSPEC *specList = (COMDLG_FILTERSPEC*)NFDi_Malloc( sizeof(COMDLG_FILTERSPEC) * ((size_t)filterCount + 1) ); if ( !specList ) { return NFD_ERROR; } - for (size_t i = 0; i < filterCount+1; ++i ) + for (UINT i = 0; i < filterCount+1; ++i ) { specList[i].pszName = NULL; specList[i].pszSpec = NULL; @@ -181,9 +185,8 @@ static nfdresult_t AddFiltersToDialog( ::IFileDialog *fileOpenDialog, const char if ( *p_filterList == ';' || *p_filterList == '\0' ) { /* end of filter -- add it to specList */ - - // Empty filter name -- Windows describes them by extension. - CopyNFDCharToWChar(specbuf, (wchar_t**)&specList[specIdx].pszName); + + CopyNFDCharToWChar( specbuf, (wchar_t**)&specList[specIdx].pszName ); CopyNFDCharToWChar( specbuf, (wchar_t**)&specList[specIdx].pszSpec ); memset( specbuf, 0, sizeof(char)*NFD_MAX_STRLEN ); @@ -270,6 +273,8 @@ static nfdresult_t AllocPathSet( IShellItemArray *shellItems, nfdpathset_t *path // Calculate length of name with UTF-8 encoding bufSize += GetUTF8ByteCountForWChar( name ); + + CoTaskMemFree(name); } assert(bufSize); @@ -304,6 +309,7 @@ static nfdresult_t AllocPathSet( IShellItemArray *shellItems, nfdpathset_t *path shellItem->GetDisplayName(SIGDN_FILESYSPATH, &name); int bytesWritten = CopyWCharToExistingNFDCharBuffer(name, p_buf); + CoTaskMemFree(name); ptrdiff_t index = p_buf - pathSet->buf; assert( index >= 0 ); @@ -353,29 +359,30 @@ static nfdresult_t SetDefaultPath( IFileDialog *dialog, const char *defaultPath /* public */ -nfdresult_t NFD_OpenDialog( const char *filterList, +nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList, const nfdchar_t *defaultPath, nfdchar_t **outPath ) { nfdresult_t nfdResult = NFD_ERROR; // Init COM library. - HRESULT result = ::CoInitializeEx(NULL, - ::COINIT_APARTMENTTHREADED | - ::COINIT_DISABLE_OLE1DDE ); + HRESULT coResult = ::CoInitializeEx(NULL, + ::COINIT_APARTMENTTHREADED | + ::COINIT_DISABLE_OLE1DDE ); ::IFileOpenDialog *fileOpenDialog(NULL); - if ( !SUCCEEDED(result)) + if ( !SUCCEEDED(coResult)) { + fileOpenDialog = NULL; NFDi_SetError("Could not initialize COM."); goto end; } // Create dialog - result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL, - CLSCTX_ALL, ::IID_IFileOpenDialog, - reinterpret_cast(&fileOpenDialog) ); + HRESULT result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL, + CLSCTX_ALL, ::IID_IFileOpenDialog, + reinterpret_cast(&fileOpenDialog) ); if ( !SUCCEEDED(result) ) { @@ -412,6 +419,7 @@ nfdresult_t NFD_OpenDialog( const char *filterList, if ( !SUCCEEDED(result) ) { NFDi_SetError("Could not get file path for selected."); + shellItem->Release(); goto end; } @@ -420,6 +428,7 @@ nfdresult_t NFD_OpenDialog( const char *filterList, if ( !*outPath ) { /* error is malloc-based, error message would be redundant */ + shellItem->Release(); goto end; } @@ -436,8 +445,12 @@ nfdresult_t NFD_OpenDialog( const char *filterList, nfdResult = NFD_ERROR; } - end: - ::CoUninitialize(); +end: + if (fileOpenDialog) + fileOpenDialog->Release(); + + if (SUCCEEDED(coResult)) + ::CoUninitialize(); return nfdResult; } @@ -449,10 +462,10 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, nfdresult_t nfdResult = NFD_ERROR; // Init COM library. - HRESULT result = ::CoInitializeEx(NULL, - ::COINIT_APARTMENTTHREADED | - ::COINIT_DISABLE_OLE1DDE ); - if ( !SUCCEEDED(result)) + HRESULT coResult = ::CoInitializeEx(NULL, + ::COINIT_APARTMENTTHREADED | + ::COINIT_DISABLE_OLE1DDE ); + if ( !SUCCEEDED(coResult)) { NFDi_SetError("Could not initialize COM."); return NFD_ERROR; @@ -461,12 +474,13 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, ::IFileOpenDialog *fileOpenDialog(NULL); // Create dialog - result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL, - CLSCTX_ALL, ::IID_IFileOpenDialog, - reinterpret_cast(&fileOpenDialog) ); + HRESULT result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL, + CLSCTX_ALL, ::IID_IFileOpenDialog, + reinterpret_cast(&fileOpenDialog) ); if ( !SUCCEEDED(result) ) { + fileOpenDialog = NULL; NFDi_SetError("Could not create dialog."); goto end; } @@ -512,6 +526,7 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, if ( AllocPathSet( shellItems, outPaths ) == NFD_ERROR ) { + shellItems->Release(); goto end; } @@ -528,8 +543,12 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, nfdResult = NFD_ERROR; } - end: - ::CoUninitialize(); +end: + if ( fileOpenDialog ) + fileOpenDialog->Release(); + + if (SUCCEEDED(coResult)) + ::CoUninitialize(); return nfdResult; } @@ -541,10 +560,10 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, nfdresult_t nfdResult = NFD_ERROR; // Init COM library. - HRESULT result = ::CoInitializeEx(NULL, - ::COINIT_APARTMENTTHREADED | - ::COINIT_DISABLE_OLE1DDE ); - if ( !SUCCEEDED(result)) + HRESULT coResult = ::CoInitializeEx(NULL, + ::COINIT_APARTMENTTHREADED | + ::COINIT_DISABLE_OLE1DDE ); + if ( !SUCCEEDED(coResult)) { NFDi_SetError("Could not initialize COM."); return NFD_ERROR; @@ -553,12 +572,13 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, ::IFileSaveDialog *fileSaveDialog(NULL); // Create dialog - result = ::CoCreateInstance(::CLSID_FileSaveDialog, NULL, - CLSCTX_ALL, ::IID_IFileSaveDialog, - reinterpret_cast(&fileSaveDialog) ); + HRESULT result = ::CoCreateInstance(::CLSID_FileSaveDialog, NULL, + CLSCTX_ALL, ::IID_IFileSaveDialog, + reinterpret_cast(&fileSaveDialog) ); if ( !SUCCEEDED(result) ) { + fileSaveDialog = NULL; NFDi_SetError("Could not create dialog."); goto end; } @@ -591,6 +611,7 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, result = shellItem->GetDisplayName(::SIGDN_FILESYSPATH, &filePath); if ( !SUCCEEDED(result) ) { + shellItem->Release(); NFDi_SetError("Could not get file path for selected."); goto end; } @@ -600,6 +621,7 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, if ( !*outPath ) { /* error is malloc-based, error message would be redundant */ + shellItem->Release(); goto end; } @@ -616,8 +638,12 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, nfdResult = NFD_ERROR; } - end: - ::CoUninitialize(); +end: + if ( fileSaveDialog ) + fileSaveDialog->Release(); + + if (SUCCEEDED(coResult)) + ::CoUninitialize(); return nfdResult; } @@ -729,7 +755,8 @@ nfdresult_t NFD_PickFolder(const nfdchar_t *defaultPath, ComPtr pShellItem; if (!SUCCEEDED(pFileDialog->GetResult(&pShellItem))) { - return NFD_OKAY; + NFDi_SetError("Could not get shell item from dialog."); + return NFD_ERROR; } // Finally get the path diff --git a/Engine/lib/nativeFileDialogs/nfd_zenity.c b/Engine/lib/nativeFileDialogs/nfd_zenity.c new file mode 100644 index 000000000..1890eec9e --- /dev/null +++ b/Engine/lib/nativeFileDialogs/nfd_zenity.c @@ -0,0 +1,311 @@ +/* + Native File Dialog + + http://www.frogtoss.com/labs +*/ + +#include +#include +#include +#include "nfd.h" +#include "nfd_common.h" + +#define SIMPLE_EXEC_IMPLEMENTATION +#include "simple_exec.h" + + +const char NO_ZENITY_MSG[] = "zenity not installed"; + + +static void AddTypeToFilterName( const char *typebuf, char *filterName, size_t bufsize ) +{ + size_t len = strlen(filterName); + if( len > 0 ) + strncat( filterName, " *.", bufsize - len - 1 ); + else + strncat( filterName, "--file-filter=*.", bufsize - len - 1 ); + + len = strlen(filterName); + strncat( filterName, typebuf, bufsize - len - 1 ); +} + +static void AddFiltersToCommandArgs(char** commandArgs, int commandArgsLen, const char *filterList ) +{ + char typebuf[NFD_MAX_STRLEN] = {0}; + const char *p_filterList = filterList; + char *p_typebuf = typebuf; + char filterName[NFD_MAX_STRLEN] = {0}; + int i; + + if ( !filterList || strlen(filterList) == 0 ) + return; + + while ( 1 ) + { + + if ( NFDi_IsFilterSegmentChar(*p_filterList) ) + { + char typebufWildcard[NFD_MAX_STRLEN]; + /* add another type to the filter */ + assert( strlen(typebuf) > 0 ); + assert( strlen(typebuf) < NFD_MAX_STRLEN-1 ); + + snprintf( typebufWildcard, NFD_MAX_STRLEN, "*.%s", typebuf ); + + AddTypeToFilterName( typebuf, filterName, NFD_MAX_STRLEN ); + + p_typebuf = typebuf; + memset( typebuf, 0, sizeof(char) * NFD_MAX_STRLEN ); + } + + if ( *p_filterList == ';' || *p_filterList == '\0' ) + { + /* end of filter -- add it to the dialog */ + + for(i = 0; commandArgs[i] != NULL && i < commandArgsLen; i++); + + commandArgs[i] = strdup(filterName); + + filterName[0] = '\0'; + + if ( *p_filterList == '\0' ) + break; + } + + if ( !NFDi_IsFilterSegmentChar( *p_filterList ) ) + { + *p_typebuf = *p_filterList; + p_typebuf++; + } + + p_filterList++; + } + + /* always append a wildcard option to the end*/ + + for(i = 0; commandArgs[i] != NULL && i < commandArgsLen; i++); + + commandArgs[i] = strdup("--file-filter=*.*"); +} + +static nfdresult_t ZenityCommon(char** command, int commandLen, const char* defaultPath, const char* filterList, char** stdOut) +{ + if(defaultPath != NULL) + { + char* prefix = "--filename"; + int len = strlen(prefix) + strlen(defaultPath) + 1; + + char* tmp = (char*) calloc(len, 1); + strcat(tmp, prefix); + strcat(tmp, defaultPath); + + int i; + for(i = 0; command[i] != NULL && i < commandLen; i++); + + command[i] = tmp; + } + + AddFiltersToCommandArgs(command, commandLen, filterList); + + int byteCount = 0; + int exitCode = 0; + int processInvokeError = runCommandArray(stdOut, &byteCount, &exitCode, 0, command); + + for(int i = 0; command[i] != NULL && i < commandLen; i++) + free(command[i]); + + nfdresult_t result = NFD_OKAY; + + if(processInvokeError == COMMAND_NOT_FOUND) + { + NFDi_SetError(NO_ZENITY_MSG); + result = NFD_ERROR; + } + else + { + if(exitCode == 1) + result = NFD_CANCEL; + } + + return result; +} + + +static nfdresult_t AllocPathSet(char* zenityList, nfdpathset_t *pathSet ) +{ + size_t bufSize = 0; + nfdchar_t *p_buf; + size_t count = 0; + + assert(zenityList); + assert(pathSet); + + size_t len = strlen(zenityList) + 1; + pathSet->buf = NFDi_Malloc(len); + + int numEntries = 1; + + for(size_t i = 0; i < len; i++) + { + char ch = zenityList[i]; + + if(ch == '|') + { + numEntries++; + ch = '\0'; + } + + pathSet->buf[i] = ch; + } + + pathSet->count = numEntries; + assert( pathSet->count > 0 ); + + pathSet->indices = NFDi_Malloc( sizeof(size_t)*pathSet->count ); + + int entry = 0; + pathSet->indices[0] = 0; + for(size_t i = 0; i < len; i++) + { + char ch = zenityList[i]; + + if(ch == '|') + { + entry++; + pathSet->indices[entry] = i + 1; + } + } + + return NFD_OKAY; +} + +/* public */ + +nfdresult_t NFD_OpenDialog( const char *filterList, + const nfdchar_t *defaultPath, + nfdchar_t **outPath ) +{ + int commandLen = 100; + char* command[commandLen]; + memset(command, 0, commandLen * sizeof(char*)); + + command[0] = strdup("zenity"); + command[1] = strdup("--file-selection"); + command[2] = strdup("--title=Open File"); + + char* stdOut = NULL; + nfdresult_t result = ZenityCommon(command, commandLen, defaultPath, filterList, &stdOut); + + if(stdOut != NULL) + { + size_t len = strlen(stdOut); + *outPath = NFDi_Malloc(len); + memcpy(*outPath, stdOut, len); + (*outPath)[len-1] = '\0'; // trim out the final \n with a null terminator + free(stdOut); + } + else + { + *outPath = NULL; + } + + return result; +} + + +nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList, + const nfdchar_t *defaultPath, + nfdpathset_t *outPaths ) +{ + int commandLen = 100; + char* command[commandLen]; + memset(command, 0, commandLen * sizeof(char*)); + + command[0] = strdup("zenity"); + command[1] = strdup("--file-selection"); + command[2] = strdup("--title=Open Files"); + command[3] = strdup("--multiple"); + + char* stdOut = NULL; + nfdresult_t result = ZenityCommon(command, commandLen, defaultPath, filterList, &stdOut); + + if(stdOut != NULL) + { + size_t len = strlen(stdOut); + stdOut[len-1] = '\0'; // remove trailing newline + + if ( AllocPathSet( stdOut, outPaths ) == NFD_ERROR ) + result = NFD_ERROR; + + free(stdOut); + } + else + { + result = NFD_ERROR; + } + + return result; +} + +nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList, + const nfdchar_t *defaultPath, + nfdchar_t **outPath ) +{ + int commandLen = 100; + char* command[commandLen]; + memset(command, 0, commandLen * sizeof(char*)); + + command[0] = strdup("zenity"); + command[1] = strdup("--file-selection"); + command[2] = strdup("--title=Save File"); + command[3] = strdup("--save"); + + char* stdOut = NULL; + nfdresult_t result = ZenityCommon(command, commandLen, defaultPath, filterList, &stdOut); + + if(stdOut != NULL) + { + size_t len = strlen(stdOut); + *outPath = NFDi_Malloc(len); + memcpy(*outPath, stdOut, len); + (*outPath)[len-1] = '\0'; // trim out the final \n with a null terminator + free(stdOut); + } + else + { + *outPath = NULL; + } + + return result; +} + +nfdresult_t NFD_PickFolder(const nfdchar_t *defaultPath, + nfdchar_t **outPath) +{ + int commandLen = 100; + char* command[commandLen]; + memset(command, 0, commandLen * sizeof(char*)); + + command[0] = strdup("zenity"); + command[1] = strdup("--file-selection"); + command[2] = strdup("--directory"); + command[3] = strdup("--title=Select folder"); + + char* stdOut = NULL; + nfdresult_t result = ZenityCommon(command, commandLen, defaultPath, "", &stdOut); + + if(stdOut != NULL) + { + size_t len = strlen(stdOut); + *outPath = NFDi_Malloc(len); + memcpy(*outPath, stdOut, len); + (*outPath)[len-1] = '\0'; // trim out the final \n with a null terminator + free(stdOut); + } + else + { + *outPath = NULL; + } + + return result; +} diff --git a/Engine/lib/nativeFileDialogs/simple_exec.h b/Engine/lib/nativeFileDialogs/simple_exec.h new file mode 100644 index 000000000..b85327b55 --- /dev/null +++ b/Engine/lib/nativeFileDialogs/simple_exec.h @@ -0,0 +1,214 @@ +// copied from: https://github.com/wheybags/simple_exec/blob/5a74c507c4ce1b2bb166177ead4cca7cfa23cb35/simple_exec.h + +// simple_exec.h, single header library to run external programs + retrieve their status code and output (unix only for now) +// +// do this: +// #define SIMPLE_EXEC_IMPLEMENTATION +// before you include this file in *one* C or C++ file to create the implementation. +// i.e. it should look like this: +// #define SIMPLE_EXEC_IMPLEMENTATION +// #include "simple_exec.h" + +#ifndef SIMPLE_EXEC_H +#define SIMPLE_EXEC_H + +int runCommand(char** stdOut, int* stdOutByteCount, int* returnCode, int includeStdErr, char* command, ...); +int runCommandArray(char** stdOut, int* stdOutByteCount, int* returnCode, int includeStdErr, char* const* allArgs); + +#endif // SIMPLE_EXEC_H + +#ifdef SIMPLE_EXEC_IMPLEMENTATION + +#include +#include +#include +#include +#include +#include +#include +#include + +#define release_assert(x) do { int __release_assert_tmp__ = (x); assert(__release_assert_tmp__); } while(0) + +enum PIPE_FILE_DESCRIPTORS +{ + READ_FD = 0, + WRITE_FD = 1 +}; + +enum RUN_COMMAND_ERROR +{ + COMMAND_RAN_OK = 0, + COMMAND_NOT_FOUND = 1 +}; + +int runCommandArray(char** stdOut, int* stdOutByteCount, int* returnCode, int includeStdErr, char* const* allArgs) +{ + // adapted from: https://stackoverflow.com/a/479103 + + int bufferSize = 256; + char buffer[bufferSize + 1]; + + int dataReadFromChildDefaultSize = bufferSize * 5; + int dataReadFromChildSize = dataReadFromChildDefaultSize; + int dataReadFromChildUsed = 0; + char* dataReadFromChild = (char*)malloc(dataReadFromChildSize); + + + int parentToChild[2]; + release_assert(pipe(parentToChild) == 0); + + int childToParent[2]; + release_assert(pipe(childToParent) == 0); + + int errPipe[2]; + release_assert(pipe(errPipe) == 0); + + pid_t pid; + switch( pid = fork() ) + { + case -1: + { + release_assert(0 && "Fork failed"); + } + + case 0: // child + { + release_assert(dup2(parentToChild[READ_FD ], STDIN_FILENO ) != -1); + release_assert(dup2(childToParent[WRITE_FD], STDOUT_FILENO) != -1); + + if(includeStdErr) + { + release_assert(dup2(childToParent[WRITE_FD], STDERR_FILENO) != -1); + } + else + { + int devNull = open("/dev/null", O_WRONLY); + release_assert(dup2(devNull, STDERR_FILENO) != -1); + } + + // unused + release_assert(close(parentToChild[WRITE_FD]) == 0); + release_assert(close(childToParent[READ_FD ]) == 0); + release_assert(close(errPipe[READ_FD]) == 0); + + const char* command = allArgs[0]; + execvp(command, allArgs); + + char err = 1; + write(errPipe[WRITE_FD], &err, 1); + + close(errPipe[WRITE_FD]); + close(parentToChild[READ_FD]); + close(childToParent[WRITE_FD]); + + exit(0); + } + + + default: // parent + { + // unused + release_assert(close(parentToChild[READ_FD]) == 0); + release_assert(close(childToParent[WRITE_FD]) == 0); + release_assert(close(errPipe[WRITE_FD]) == 0); + + while(1) + { + ssize_t bytesRead = 0; + switch(bytesRead = read(childToParent[READ_FD], buffer, bufferSize)) + { + case 0: // End-of-File, or non-blocking read. + { + int status = 0; + release_assert(waitpid(pid, &status, 0) == pid); + + // done with these now + release_assert(close(parentToChild[WRITE_FD]) == 0); + release_assert(close(childToParent[READ_FD]) == 0); + + char errChar = 0; + read(errPipe[READ_FD], &errChar, 1); + close(errPipe[READ_FD]); + + if(errChar) + { + free(dataReadFromChild); + return COMMAND_NOT_FOUND; + } + + // free any un-needed memory with realloc + add a null terminator for convenience + dataReadFromChild = (char*)realloc(dataReadFromChild, dataReadFromChildUsed + 1); + dataReadFromChild[dataReadFromChildUsed] = '\0'; + + if(stdOut != NULL) + *stdOut = dataReadFromChild; + else + free(dataReadFromChild); + + if(stdOutByteCount != NULL) + *stdOutByteCount = dataReadFromChildUsed; + if(returnCode != NULL) + *returnCode = WEXITSTATUS(status); + + return COMMAND_RAN_OK; + } + case -1: + { + release_assert(0 && "read() failed"); + } + + default: + { + if(dataReadFromChildUsed + bytesRead + 1 >= dataReadFromChildSize) + { + dataReadFromChildSize += dataReadFromChildDefaultSize; + dataReadFromChild = (char*)realloc(dataReadFromChild, dataReadFromChildSize); + } + + memcpy(dataReadFromChild + dataReadFromChildUsed, buffer, bytesRead); + dataReadFromChildUsed += bytesRead; + break; + } + } + } + } + } +} + +int runCommand(char** stdOut, int* stdOutByteCount, int* returnCode, int includeStdErr, char* command, ...) +{ + va_list vl; + va_start(vl, command); + + char* currArg = NULL; + + int allArgsInitialSize = 16; + int allArgsSize = allArgsInitialSize; + char** allArgs = (char**)malloc(sizeof(char*) * allArgsSize); + allArgs[0] = command; + + int i = 1; + do + { + currArg = va_arg(vl, char*); + allArgs[i] = currArg; + + i++; + + if(i >= allArgsSize) + { + allArgsSize += allArgsInitialSize; + allArgs = (char**)realloc(allArgs, sizeof(char*) * allArgsSize); + } + + } while(currArg != NULL); + + va_end(vl); + + int retval = runCommandArray(stdOut, stdOutByteCount, returnCode, includeStdErr, allArgs); + free(allArgs); + return retval; +} + +#endif //SIMPLE_EXEC_IMPLEMENTATION diff --git a/Engine/source/T3D/Scene.cpp b/Engine/source/T3D/Scene.cpp new file mode 100644 index 000000000..aeed7399b --- /dev/null +++ b/Engine/source/T3D/Scene.cpp @@ -0,0 +1,236 @@ +#include "Scene.h" + +Scene * Scene::smRootScene = nullptr; +Vector Scene::smSceneList; + +IMPLEMENT_CO_NETOBJECT_V1(Scene); + +Scene::Scene() : + mIsSubScene(false), + mParentScene(nullptr), + mSceneId(-1), + mIsEditing(false), + mIsDirty(false) +{ + +} + +Scene::~Scene() +{ + +} + +void Scene::initPersistFields() +{ + Parent::initPersistFields(); + + addGroup("Internal"); + addField("isSubscene", TypeBool, Offset(mIsSubScene, Scene), "", AbstractClassRep::FIELD_HideInInspectors); + addField("isEditing", TypeBool, Offset(mIsEditing, Scene), "", AbstractClassRep::FIELD_HideInInspectors); + addField("isDirty", TypeBool, Offset(mIsDirty, Scene), "", AbstractClassRep::FIELD_HideInInspectors); + endGroup("Internal"); +} + +bool Scene::onAdd() +{ + if (!Parent::onAdd()) + return false; + + smSceneList.push_back(this); + mSceneId = smSceneList.size() - 1; + + /*if (smRootScene == nullptr) + { + //we're the first scene, so we're the root. woo! + smRootScene = this; + } + else + { + mIsSubScene = true; + smRootScene->mSubScenes.push_back(this); + }*/ + + return true; +} + +void Scene::onRemove() +{ + Parent::onRemove(); + + smSceneList.remove(this); + mSceneId = -1; + + /*if (smRootScene == this) + { + for (U32 i = 0; i < mSubScenes.size(); i++) + { + mSubScenes[i]->deleteObject(); + } + } + else if (smRootScene != nullptr) + { + for (U32 i = 0; i < mSubScenes.size(); i++) + { + if(mSubScenes[i]->getId() == getId()) + smRootScene->mSubScenes.erase(i); + } + }*/ +} + +void Scene::addObject(SimObject* object) +{ + //Child scene + Scene* scene = dynamic_cast(object); + if (scene) + { + //We'll keep these principly separate so they don't get saved into each other + mSubScenes.push_back(scene); + return; + } + + SceneObject* sceneObj = dynamic_cast(object); + if (sceneObj) + { + //We'll operate on the presumption that if it's being added via regular parantage means, it's considered permanent + mPermanentObjects.push_back(sceneObj); + Parent::addObject(object); + + return; + } + + //Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene? + Parent::addObject(object); +} + +void Scene::removeObject(SimObject* object) +{ + //Child scene + Scene* scene = dynamic_cast(object); + if (scene) + { + //We'll keep these principly separate so they don't get saved into each other + mSubScenes.remove(scene); + return; + } + + SceneObject* sceneObj = dynamic_cast(object); + if (sceneObj) + { + //We'll operate on the presumption that if it's being added via regular parantage means, it's considered permanent + + mPermanentObjects.remove(sceneObj); + Parent::removeObject(object); + + return; + } + + Parent::removeObject(object); +} + +void Scene::addDynamicObject(SceneObject* object) +{ + mDynamicObjects.push_back(object); + + //Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene? + Parent::addObject(object); +} + +void Scene::removeDynamicObject(SceneObject* object) +{ + mDynamicObjects.remove(object); + + //Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene? + Parent::removeObject(object); +} + +void Scene::interpolateTick(F32 delta) +{ + +} + +void Scene::processTick() +{ + +} + +void Scene::advanceTime(F32 timeDelta) +{ + +} + +U32 Scene::packUpdate(NetConnection *conn, U32 mask, BitStream *stream) +{ + bool ret = Parent::packUpdate(conn, mask, stream); + + return ret; +} + +void Scene::unpackUpdate(NetConnection *conn, BitStream *stream) +{ + +} + +// +Vector Scene::getObjectsByClass(String className) +{ + return Vector(); +} + +DefineEngineFunction(getScene, Scene*, (U32 sceneId), (0), + "Get the root Scene object that is loaded.\n" + "@return The id of the Root Scene. Will be 0 if no root scene is loaded") +{ + if (Scene::smSceneList.empty() || sceneId >= Scene::smSceneList.size()) + return nullptr; + + return Scene::smSceneList[sceneId]; +} + +DefineEngineFunction(getRootScene, S32, (), , + "Get the root Scene object that is loaded.\n" + "@return The id of the Root Scene. Will be 0 if no root scene is loaded") +{ + Scene* root = Scene::getRootScene(); + + if (root) + return root->getId(); + + return 0; +} + +DefineEngineMethod(Scene, getRootScene, S32, (),, + "Get the root Scene object that is loaded.\n" + "@return The id of the Root Scene. Will be 0 if no root scene is loaded") +{ + Scene* root = Scene::getRootScene(); + + if (root) + return root->getId(); + + return 0; +} + +DefineEngineMethod(Scene, addDynamicObject, void, (SceneObject* sceneObj), (nullAsType()), + "Get the root Scene object that is loaded.\n" + "@return The id of the Root Scene. Will be 0 if no root scene is loaded") +{ + object->addDynamicObject(sceneObj); +} + +DefineEngineMethod(Scene, removeDynamicObject, void, (SceneObject* sceneObj), (nullAsType()), + "Get the root Scene object that is loaded.\n" + "@return The id of the Root Scene. Will be 0 if no root scene is loaded") +{ + object->removeDynamicObject(sceneObj); +} + +DefineEngineMethod(Scene, getObjectsByClass, String, (String className), (""), + "Get the root Scene object that is loaded.\n" + "@return The id of the Root Scene. Will be 0 if no root scene is loaded") +{ + if (className == String::EmptyString) + return ""; + + //return object->getObjectsByClass(className); + return ""; +} diff --git a/Engine/source/T3D/Scene.h b/Engine/source/T3D/Scene.h new file mode 100644 index 000000000..111044247 --- /dev/null +++ b/Engine/source/T3D/Scene.h @@ -0,0 +1,79 @@ +#pragma once + +#include "console/engineAPI.h" + +#ifndef _NETOBJECT_H_ +#include "sim/netObject.h" +#endif + +#ifndef _ITICKABLE_H_ +#include "core/iTickable.h" +#endif + +#include "scene/sceneObject.h" + +/// Scene +/// This object is effectively a smart container to hold and manage any relevent scene objects and data +/// used to run things. +class Scene : public NetObject, public virtual ITickable +{ + typedef NetObject Parent; + + bool mIsSubScene; + + Scene* mParentScene; + + Vector mSubScenes; + + Vector mPermanentObjects; + + Vector mDynamicObjects; + + S32 mSceneId; + + bool mIsEditing; + + bool mIsDirty; + +protected: + static Scene * smRootScene; + + DECLARE_CONOBJECT(Scene); + +public: + Scene(); + ~Scene(); + + static void initPersistFields(); + + virtual bool onAdd(); + virtual void onRemove(); + + virtual void interpolateTick(F32 delta); + virtual void processTick(); + virtual void advanceTime(F32 timeDelta); + + virtual void addObject(SimObject* object); + virtual void removeObject(SimObject* object); + + void addDynamicObject(SceneObject* object); + void removeDynamicObject(SceneObject* object); + + // + //Networking + U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream); + void unpackUpdate(NetConnection *conn, BitStream *stream); + + // + Vector getObjectsByClass(String className); + + static Scene *getRootScene() + { + if (Scene::smSceneList.empty()) + return nullptr; + + return Scene::smSceneList[0]; + } + + static Vector smSceneList; +}; \ No newline at end of file diff --git a/Engine/source/T3D/components/animation/animationComponent.cpp b/Engine/source/T3D/components/animation/animationComponent.cpp index cb7808b8b..59ff1fbf8 100644 --- a/Engine/source/T3D/components/animation/animationComponent.cpp +++ b/Engine/source/T3D/components/animation/animationComponent.cpp @@ -621,8 +621,6 @@ void AnimationComponent::advanceThreads(F32 dt) Thread& st = mAnimationThreads[i]; if (st.thread && st.sequence != -1) { - bool cyclic = getShape()->sequences[st.sequence].isCyclic(); - if (!getShape()->sequences[st.sequence].isCyclic() && !st.atEnd && ((st.timescale > 0.f) ? mOwnerShapeInstance->getPos(st.thread) >= 1.0 : mOwnerShapeInstance->getPos(st.thread) <= 0)) diff --git a/Engine/source/T3D/components/camera/cameraComponent.cpp b/Engine/source/T3D/components/camera/cameraComponent.cpp index 2cd1b7d08..4e566bba7 100644 --- a/Engine/source/T3D/components/camera/cameraComponent.cpp +++ b/Engine/source/T3D/components/camera/cameraComponent.cpp @@ -237,8 +237,6 @@ bool CameraComponent::getCameraTransform(F32* pos,MatrixF* mat) { // Returns camera to world space transform // Handles first person / third person camera position - bool isServer = isServerObject(); - if (mTargetNodeIdx == -1) { if (mUseParentTransform) @@ -479,7 +477,6 @@ void CameraComponent::setRotation(RotationF newRot) Frustum CameraComponent::getFrustum() { Frustum visFrustum; - F32 left, right, top, bottom; F32 aspectRatio = mClientScreen.x / mClientScreen.y; visFrustum.set(false, mDegToRad(mCameraFov), aspectRatio, 0.1f, 1000, mOwner->getTransform()); diff --git a/Engine/source/T3D/components/collision/collisionComponent.cpp b/Engine/source/T3D/components/collision/collisionComponent.cpp index 3736fbe04..5eee24a9e 100644 --- a/Engine/source/T3D/components/collision/collisionComponent.cpp +++ b/Engine/source/T3D/components/collision/collisionComponent.cpp @@ -538,7 +538,6 @@ PhysicsCollision* CollisionComponent::buildColShapes() for (S32 o = start; o < end; o++) { const TSShape::Object &object = shape->objects[o]; - const String &meshName = shape->names[object.nameIndex]; if (object.numMeshes <= detail.objectDetailNum) continue; diff --git a/Engine/source/T3D/components/game/stateMachine.cpp b/Engine/source/T3D/components/game/stateMachine.cpp index fd1ef8505..8c9f8b4f9 100644 --- a/Engine/source/T3D/components/game/stateMachine.cpp +++ b/Engine/source/T3D/components/game/stateMachine.cpp @@ -152,7 +152,6 @@ void StateMachine::readConditions(StateTransition ¤tTransition) //get our first state StateTransition::Condition firstCondition; StateField firstField; - bool fieldRead = false; readFieldName(&firstField, reader); firstCondition.field = firstField; diff --git a/Engine/source/T3D/components/game/triggerComponent.cpp b/Engine/source/T3D/components/game/triggerComponent.cpp index 290fab437..873c1307d 100644 --- a/Engine/source/T3D/components/game/triggerComponent.cpp +++ b/Engine/source/T3D/components/game/triggerComponent.cpp @@ -239,8 +239,6 @@ bool TriggerComponent::testObject(SceneObject* enter) myList.setObject(mOwner); myCI->buildPolyList(PLC_Collision, &myList, enterBox, sphere); - - bool test = true; } } } diff --git a/Engine/source/T3D/components/physics/playerControllerComponent.cpp b/Engine/source/T3D/components/physics/playerControllerComponent.cpp index 5b7455bfc..d321f7904 100644 --- a/Engine/source/T3D/components/physics/playerControllerComponent.cpp +++ b/Engine/source/T3D/components/physics/playerControllerComponent.cpp @@ -330,9 +330,6 @@ void PlayerControllerComponent::updateMove() } // Update current orientation - bool doStandardMove = true; - GameConnection* con = mOwner->getControllingClient(); - MatrixF zRot; zRot.set(EulerF(0.0f, 0.0f, mOwner->getRotation().asEulerF().z)); @@ -355,7 +352,6 @@ void PlayerControllerComponent::updateMove() mContactInfo.jump = false; mContactInfo.run = false; - bool jumpSurface = false, runSurface = false; if (!mOwner->isMounted()) findContact(&mContactInfo.run, &mContactInfo.jump, &mContactInfo.contactNormal); if (mContactInfo.jump) @@ -577,7 +573,6 @@ void PlayerControllerComponent::updatePos(const F32 travelTime) newPos = mPhysicsRep->move(mVelocity * travelTime, collisionList); bool haveCollisions = false; - bool wasFalling = mFalling; if (collisionList.getCount() > 0) { mFalling = false; diff --git a/Engine/source/T3D/convexShape.cpp b/Engine/source/T3D/convexShape.cpp index 33e2bc65c..f179ad25a 100644 --- a/Engine/source/T3D/convexShape.cpp +++ b/Engine/source/T3D/convexShape.cpp @@ -719,8 +719,6 @@ bool ConvexShape::buildExportPolyList(ColladaUtils::ExportData* exportData, cons //Convex shapes only have the one 'level', so we'll just rely on the export post-process to back-fill if (isServerObject() && getClientObject()) { - ConvexShape* clientShape = dynamic_cast(getClientObject()); - exportData->meshData.increment(); //Prep a meshData for this shape in particular diff --git a/Engine/source/T3D/entity.cpp b/Engine/source/T3D/entity.cpp index ffe724406..bb8f7becf 100644 --- a/Engine/source/T3D/entity.cpp +++ b/Engine/source/T3D/entity.cpp @@ -306,8 +306,6 @@ void Entity::onPostAdd() bool Entity::_setGameObject(void *object, const char *index, const char *data) { - Entity *e = static_cast(object); - // Sanity! AssertFatal(data != NULL, "Cannot use a NULL asset Id."); @@ -513,8 +511,6 @@ U32 Entity::packUpdate(NetConnection *con, U32 mask, BitStream *stream) for (U32 i = 0; i < mNetworkedComponents.size(); i++) { - NetworkedComponent::UpdateState state = mNetworkedComponents[i].updateState; - if (mNetworkedComponents[i].updateState == NetworkedComponent::Adding) { const char* className = mComponents[mNetworkedComponents[i].componentIndex]->getClassName(); @@ -1381,7 +1377,6 @@ bool Entity::removeComponent(Component *comp, bool deleteComponent) //to re-add them. Need to implement a clean clear function that will clear the local list, and only delete unused behaviors during an update. void Entity::clearComponents(bool deleteComponents) { - bool srv = isServerObject(); if (!deleteComponents) { while (mComponents.size() > 0) @@ -1399,8 +1394,6 @@ void Entity::clearComponents(bool deleteComponents) { comp->onComponentRemove(); //in case the behavior needs to do cleanup on the owner - bool removed = mComponents.remove(comp); - //we only need to delete them on the server side. they'll be cleaned up on the client side //via the ghosting system for us if (isServerObject()) @@ -1663,7 +1656,6 @@ void Entity::notifyComponents(String signalFunction, String argA, String argB, S void Entity::setComponentsDirty() { - bool tmp = true; /*if (mToLoadComponents.empty()) mStartComponentUpdate = true; @@ -1694,7 +1686,6 @@ void Entity::setComponentsDirty() void Entity::setComponentDirty(Component *comp, bool forceUpdate) { - bool found = false; for (U32 i = 0; i < mComponents.size(); i++) { if (mComponents[i]->getId() == comp->getId()) diff --git a/Engine/source/T3D/entity.h b/Engine/source/T3D/entity.h index 5bf9898ea..b7e325ce5 100644 --- a/Engine/source/T3D/entity.h +++ b/Engine/source/T3D/entity.h @@ -309,7 +309,6 @@ Vector Entity::getComponents() Vector foundObjects; T *curObj; - Component* comp; // Loop through our child objects. for (U32 i = 0; i < mComponents.size(); i++) diff --git a/Engine/source/T3D/fx/particleEmitter.cpp b/Engine/source/T3D/fx/particleEmitter.cpp index b10d88f8a..bd2256e7d 100644 --- a/Engine/source/T3D/fx/particleEmitter.cpp +++ b/Engine/source/T3D/fx/particleEmitter.cpp @@ -490,7 +490,7 @@ void ParticleEmitterData::unpackData(BitStream* stream) #if defined(AFX_CAP_PARTICLE_POOLS) if (stream->readFlag()) { - pool_datablock = (afxParticlePoolData*)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); + pool_datablock = (afxParticlePoolData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); stream->read(&pool_index); pool_depth_fade = stream->readFlag(); pool_radial_fade = stream->readFlag(); diff --git a/Engine/source/T3D/gameFunctions.cpp b/Engine/source/T3D/gameFunctions.cpp index c49c75cb3..db2ac5a27 100644 --- a/Engine/source/T3D/gameFunctions.cpp +++ b/Engine/source/T3D/gameFunctions.cpp @@ -553,7 +553,6 @@ void renderFrame(GFXTextureTargetRef* target, MatrixF transform, Frustum frustum GFX->setStateBlock(mDefaultGuiSB); GFXTargetRef origTarget = GFX->getActiveRenderTarget(); - U32 origStyle = GFX->getCurrentRenderStyle(); // Clear the zBuffer so GUI doesn't hose object rendering accidentally GFX->clear(GFXClearZBuffer, ColorI(20, 20, 20), 1.0f, 0); diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 9a2c072a6..40ea1a3c1 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -6150,8 +6150,22 @@ void Player::updateWorkingCollisionSet() mWorkingQueryBox.maxExtents += twolPoint; disableCollision(); + + //We temporarily disable the collisions of anything mounted to us so we don't accidentally walk into things we've attached to us + for (SceneObject *ptr = mMount.list; ptr; ptr = ptr->getMountLink()) + { + ptr->disableCollision(); + } + mConvex.updateWorkingList(mWorkingQueryBox, isGhost() ? sClientCollisionContactMask : sServerCollisionContactMask); + + //And now re-enable the collisions of the mounted things + for (SceneObject *ptr = mMount.list; ptr; ptr = ptr->getMountLink()) + { + ptr->enableCollision(); + } + enableCollision(); } } @@ -6345,6 +6359,14 @@ U32 Player::packUpdate(NetConnection *con, U32 mask, BitStream *stream) if(len > 8191) len = 8191; stream->writeInt((S32)len, 13); + + // constrain the range of mRot.z + while (mRot.z < 0.0f) + mRot.z += M_2PI_F; + while (mRot.z > M_2PI_F) + mRot.z -= M_2PI_F; + + } stream->writeFloat(mRot.z / M_2PI_F, 7); stream->writeSignedFloat(mHead.x / (mDataBlock->maxLookAngle - mDataBlock->minLookAngle), 6); diff --git a/Engine/source/T3D/prefab.cpp b/Engine/source/T3D/prefab.cpp index 32e209c31..54080c8a0 100644 --- a/Engine/source/T3D/prefab.cpp +++ b/Engine/source/T3D/prefab.cpp @@ -34,6 +34,8 @@ #include "T3D/physics/physicsShape.h" #include "core/util/path.h" +#include "T3D/Scene.h" + // We use this locally ( within this file ) to prevent infinite recursion // while loading prefab files that contain other prefabs. static Vector sPrefabFileStack; @@ -269,11 +271,11 @@ void Prefab::setFile( String file ) SimGroup* Prefab::explode() { - SimGroup *missionGroup; + Scene* scene = Scene::getRootScene(); - if ( !Sim::findObject( "MissionGroup", missionGroup ) ) + if ( !scene) { - Con::errorf( "Prefab::explode, MissionGroup was not found." ); + Con::errorf( "Prefab::explode, Scene was not found." ); return NULL; } @@ -295,7 +297,7 @@ SimGroup* Prefab::explode() smChildToPrefabMap.erase( child->getId() ); } - missionGroup->addObject(group); + scene->addObject(group); mChildGroup = NULL; mChildMap.clear(); @@ -468,10 +470,10 @@ Prefab* Prefab::getPrefabByChild( SimObject *child ) bool Prefab::isValidChild( SimObject *simobj, bool logWarnings ) { - if ( simobj->getName() && dStricmp(simobj->getName(),"MissionGroup") == 0 ) + if ( simobj->getName() && simobj == Scene::getRootScene() ) { if ( logWarnings ) - Con::warnf( "MissionGroup is not valid within a Prefab." ); + Con::warnf( "root Scene is not valid within a Prefab." ); return false; } diff --git a/Engine/source/T3D/prefab.h b/Engine/source/T3D/prefab.h index fd1ebc2a4..36e5d12f3 100644 --- a/Engine/source/T3D/prefab.h +++ b/Engine/source/T3D/prefab.h @@ -93,7 +93,7 @@ public: void setFile( String file ); /// Removes all children from this Prefab and puts them into a SimGroup - /// which is added to the MissionGroup and returned to the caller. + /// which is added to the Scene and returned to the caller. SimGroup* explode(); bool buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF& sphere); diff --git a/Engine/source/T3D/proximityMine.h b/Engine/source/T3D/proximityMine.h index b14f5051a..7b448e628 100644 --- a/Engine/source/T3D/proximityMine.h +++ b/Engine/source/T3D/proximityMine.h @@ -72,8 +72,7 @@ class ProximityMine: public Item protected: enum MaskBits { DeployedMask = Parent::NextFreeMask, - ExplosionMask = Parent::NextFreeMask << 1, - NextFreeMask = Parent::NextFreeMask << 2 + ExplosionMask = Parent::NextFreeMask << 1 }; enum State diff --git a/Engine/source/T3D/shapeBase.cpp b/Engine/source/T3D/shapeBase.cpp index 7fb1c57da..3c41564aa 100644 --- a/Engine/source/T3D/shapeBase.cpp +++ b/Engine/source/T3D/shapeBase.cpp @@ -3266,7 +3266,7 @@ void ShapeBase::unpackUpdate(NetConnection *con, BitStream *stream) st.play = stream->readFlag(); if ( st.play ) { - st.profile = (SFXTrack*) stream->readRangedU32( DataBlockObjectIdFirst, + st.profile = (SFXTrack*)(uintptr_t)stream->readRangedU32( DataBlockObjectIdFirst, DataBlockObjectIdLast ); } diff --git a/Engine/source/T3D/shapeImage.cpp b/Engine/source/T3D/shapeImage.cpp index 56d413a2b..3e19c58bc 100644 --- a/Engine/source/T3D/shapeImage.cpp +++ b/Engine/source/T3D/shapeImage.cpp @@ -189,7 +189,7 @@ ShapeBaseImageData::ShapeBaseImageData() lightRadius = 10.f; lightBrightness = 1.0f; - shapeName = "core/art/shapes/noshape.dts"; + shapeName = "core/shapes/noshape.dts"; shapeNameFP = ""; imageAnimPrefix = ""; imageAnimPrefixFP = ""; @@ -1202,7 +1202,7 @@ void ShapeBaseImageData::unpackData(BitStream* stream) } projectile = (stream->readFlag() ? - (ProjectileData*)stream->readRangedU32(DataBlockObjectIdFirst, + (ProjectileData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast) : 0); cloakable = stream->readFlag(); @@ -1340,7 +1340,7 @@ void ShapeBaseImageData::unpackData(BitStream* stream) if (stream->readFlag()) { - s.emitter = (ParticleEmitterData*) stream->readRangedU32(DataBlockObjectIdFirst, + s.emitter = (ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); stream->read(&s.emitterTime); diff --git a/Engine/source/T3D/systems/render/meshRenderSystem.cpp b/Engine/source/T3D/systems/render/meshRenderSystem.cpp index 39b163601..6faf2a74c 100644 --- a/Engine/source/T3D/systems/render/meshRenderSystem.cpp +++ b/Engine/source/T3D/systems/render/meshRenderSystem.cpp @@ -21,11 +21,9 @@ void MeshRenderSystem::render(SceneManager *sceneManager, SceneRenderState* stat for (U32 i = 0; i < count; i++) { //Server side items exist for data, but we don't actually render them - bool isClient = MeshRenderSystemInterface::all[i]->mIsClient; if (!MeshRenderSystemInterface::all[i]->mIsClient) continue; - bool isStatic = MeshRenderSystemInterface::all[i]->mStatic; if (MeshRenderSystemInterface::all[i]->mStatic) continue; diff --git a/Engine/source/T3D/tsStatic.cpp b/Engine/source/T3D/tsStatic.cpp index 2530b294b..baf902e2e 100644 --- a/Engine/source/T3D/tsStatic.cpp +++ b/Engine/source/T3D/tsStatic.cpp @@ -1135,7 +1135,6 @@ bool TSStatic::buildExportPolyList(ColladaUtils::ExportData* exportData, const B if (isServerObject() && getClientObject()) { TSStatic* clientShape = dynamic_cast(getClientObject()); - U32 numDetails = clientShape->mShapeInstance->getNumDetails() - 1; exportData->meshData.increment(); diff --git a/Engine/source/T3D/vehicles/flyingVehicle.cpp b/Engine/source/T3D/vehicles/flyingVehicle.cpp index 2ee5bc375..bb50243b2 100644 --- a/Engine/source/T3D/vehicles/flyingVehicle.cpp +++ b/Engine/source/T3D/vehicles/flyingVehicle.cpp @@ -282,14 +282,14 @@ void FlyingVehicleData::unpackData(BitStream* stream) for (S32 i = 0; i < MaxSounds; i++) { sound[i] = NULL; if (stream->readFlag()) - sound[i] = (SFXProfile*)stream->readRangedU32(DataBlockObjectIdFirst, + sound[i] = (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); } for (S32 j = 0; j < MaxJetEmitters; j++) { jetEmitter[j] = NULL; if (stream->readFlag()) - jetEmitter[j] = (ParticleEmitterData*)stream->readRangedU32(DataBlockObjectIdFirst, + jetEmitter[j] = (ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); } diff --git a/Engine/source/T3D/vehicles/hoverVehicle.cpp b/Engine/source/T3D/vehicles/hoverVehicle.cpp index 1f1d259b5..7cc204046 100644 --- a/Engine/source/T3D/vehicles/hoverVehicle.cpp +++ b/Engine/source/T3D/vehicles/hoverVehicle.cpp @@ -411,13 +411,13 @@ void HoverVehicleData::unpackData(BitStream* stream) for (S32 i = 0; i < MaxSounds; i++) sound[i] = stream->readFlag()? - (SFXProfile*) stream->readRangedU32(DataBlockObjectIdFirst, + (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast): 0; for (S32 j = 0; j < MaxJetEmitters; j++) { jetEmitter[j] = NULL; if (stream->readFlag()) - jetEmitter[j] = (ParticleEmitterData*)stream->readRangedU32(DataBlockObjectIdFirst, + jetEmitter[j] = (ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); } diff --git a/Engine/source/T3D/vehicles/vehicle.cpp b/Engine/source/T3D/vehicles/vehicle.cpp index 18a7c4466..739fd2671 100644 --- a/Engine/source/T3D/vehicles/vehicle.cpp +++ b/Engine/source/T3D/vehicles/vehicle.cpp @@ -374,7 +374,7 @@ void VehicleData::unpackData(BitStream* stream) for (i = 0; i < Body::MaxSounds; i++) { body.sound[i] = NULL; if (stream->readFlag()) - body.sound[i] = (SFXProfile*)stream->readRangedU32(DataBlockObjectIdFirst, + body.sound[i] = (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast); } diff --git a/Engine/source/T3D/vehicles/wheeledVehicle.cpp b/Engine/source/T3D/vehicles/wheeledVehicle.cpp index f4f272fd3..e4e7885ea 100644 --- a/Engine/source/T3D/vehicles/wheeledVehicle.cpp +++ b/Engine/source/T3D/vehicles/wheeledVehicle.cpp @@ -494,7 +494,7 @@ void WheeledVehicleData::unpackData(BitStream* stream) Parent::unpackData(stream); tireEmitter = stream->readFlag()? - (ParticleEmitterData*) stream->readRangedU32(DataBlockObjectIdFirst, + (ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast): 0; for (S32 i = 0; i < MaxSounds; i++) diff --git a/Engine/source/afx/afxEffectGroup.cpp b/Engine/source/afx/afxEffectGroup.cpp index 749dbbddb..71c6a89b6 100644 --- a/Engine/source/afx/afxEffectGroup.cpp +++ b/Engine/source/afx/afxEffectGroup.cpp @@ -133,7 +133,7 @@ void afxEffectGroupData::unpack_fx(BitStream* stream, afxEffectList& fx) fx.clear(); S32 n_fx = stream->readInt(EFFECTS_PER_PHRASE_BITS); for (int i = 0; i < n_fx; i++) - fx.push_back((afxEffectWrapperData*)readDatablockID(stream)); + fx.push_back((afxEffectWrapperData*)(uintptr_t)readDatablockID(stream)); } #define myOffset(field) Offset(field, afxEffectGroupData) diff --git a/Engine/source/afx/afxEffectWrapper.cpp b/Engine/source/afx/afxEffectWrapper.cpp index 5906947ee..3ec9d855f 100644 --- a/Engine/source/afx/afxEffectWrapper.cpp +++ b/Engine/source/afx/afxEffectWrapper.cpp @@ -608,7 +608,7 @@ void afxEffectWrapperData::unpack_mods(BitStream* stream, afxXM_BaseData* mods[] { S32 n_mods = stream->readInt(6); for (int i = 0; i < n_mods; i++) - mods[i] = (afxXM_BaseData*) readDatablockID(stream); + mods[i] = (afxXM_BaseData*)(uintptr_t)readDatablockID(stream); } bool afxEffectWrapperData::preload(bool server, String &errorStr) diff --git a/Engine/source/afx/afxEffectron.cpp b/Engine/source/afx/afxEffectron.cpp index b1b7f7eff..cf60ede4b 100644 --- a/Engine/source/afx/afxEffectron.cpp +++ b/Engine/source/afx/afxEffectron.cpp @@ -147,7 +147,7 @@ void afxEffectronData::unpack_fx(BitStream* stream, afxEffectList& fx) fx.clear(); S32 n_fx = stream->readInt(EFFECTS_PER_PHRASE_BITS); for (int i = 0; i < n_fx; i++) - fx.push_back((afxEffectWrapperData*)readDatablockID(stream)); + fx.push_back((afxEffectWrapperData*)(uintptr_t)readDatablockID(stream)); } void afxEffectronData::packData(BitStream* stream) diff --git a/Engine/source/afx/afxMagicSpell.cpp b/Engine/source/afx/afxMagicSpell.cpp index 029e88e62..e169d70d7 100644 --- a/Engine/source/afx/afxMagicSpell.cpp +++ b/Engine/source/afx/afxMagicSpell.cpp @@ -304,7 +304,7 @@ void afxMagicSpellData::unpack_fx(BitStream* stream, afxEffectList& fx) fx.clear(); S32 n_fx = stream->readInt(EFFECTS_PER_PHRASE_BITS); for (int i = 0; i < n_fx; i++) - fx.push_back((afxEffectWrapperData*)readDatablockID(stream)); + fx.push_back((afxEffectWrapperData*)(uintptr_t)readDatablockID(stream)); } void afxMagicSpellData::packData(BitStream* stream) @@ -356,7 +356,7 @@ void afxMagicSpellData::unpackData(BitStream* stream) mDo_move_interrupts = stream->readFlag(); stream->read(&mMove_interrupt_speed); - mMissile_db = (afxMagicMissileData*) readDatablockID(stream); + mMissile_db = (afxMagicMissileData*)(uintptr_t)readDatablockID(stream); stream->read(&mLaunch_on_server_signal); stream->read(&mPrimary_target_types); diff --git a/Engine/source/afx/afxRenderHighlightMgr.cpp b/Engine/source/afx/afxRenderHighlightMgr.cpp index 28e875eb9..22632b1ef 100644 --- a/Engine/source/afx/afxRenderHighlightMgr.cpp +++ b/Engine/source/afx/afxRenderHighlightMgr.cpp @@ -151,6 +151,12 @@ void afxRenderHighlightMgr::render( SceneRenderState *state ) matrixSet.setProjection(*passRI->projection); mat->setTransforms(matrixSet, state); + // Setup HW skinning transforms if applicable + if (mat->usesHardwareSkinning()) + { + mat->setNodeTransforms(passRI->mNodeTransforms, passRI->mNodeTransformCount); + } + mat->setSceneInfo(state, sgData); mat->setBuffers(passRI->vertBuff, passRI->primBuff); @@ -173,4 +179,4 @@ void afxRenderHighlightMgr::render( SceneRenderState *state ) // Make sure the effect is gonna render. getSelectionEffect()->setSkip( false ); -} \ No newline at end of file +} diff --git a/Engine/source/afx/afxSelectron.cpp b/Engine/source/afx/afxSelectron.cpp index 81b60c836..67cd32849 100644 --- a/Engine/source/afx/afxSelectron.cpp +++ b/Engine/source/afx/afxSelectron.cpp @@ -214,7 +214,7 @@ void afxSelectronData::unpack_fx(BitStream* stream, afxEffectList& fx) fx.clear(); S32 n_fx = stream->readInt(EFFECTS_PER_PHRASE_BITS); for (int i = 0; i < n_fx; i++) - fx.push_back((afxEffectWrapperData*)readDatablockID(stream)); + fx.push_back((afxEffectWrapperData*)(uintptr_t)readDatablockID(stream)); } void afxSelectronData::packData(BitStream* stream) diff --git a/Engine/source/afx/afxSpellBook.cpp b/Engine/source/afx/afxSpellBook.cpp index cce22129b..15581ab32 100644 --- a/Engine/source/afx/afxSpellBook.cpp +++ b/Engine/source/afx/afxSpellBook.cpp @@ -128,7 +128,7 @@ void afxSpellBookData::unpackData(BitStream* stream) do_id_convert = true; for (S32 i = 0; i < pages_per_book*spells_per_page; i++) - rpg_spells[i] = (afxRPGMagicSpellData*) readDatablockID(stream); + rpg_spells[i] = (afxRPGMagicSpellData*)(uintptr_t)readDatablockID(stream); } DefineEngineMethod(afxSpellBookData, getPageSlotIndex, S32, (Point2I bookSlot),, diff --git a/Engine/source/afx/ce/afxLightBase_T3D.cpp b/Engine/source/afx/ce/afxLightBase_T3D.cpp index 56b76ccca..a6b8da051 100644 --- a/Engine/source/afx/ce/afxLightBase_T3D.cpp +++ b/Engine/source/afx/ce/afxLightBase_T3D.cpp @@ -195,8 +195,8 @@ void afxT3DLightBaseData::unpackData(BitStream* stream) stream->read( &mAnimState.animationPhase ); stream->read( &mFlareScale ); - mAnimationData = (LightAnimData*) readDatablockID(stream); - mFlareData = (LightFlareData*) readDatablockID(stream); + mAnimationData = (LightAnimData*)(uintptr_t)readDatablockID(stream); + mFlareData = (LightFlareData*)(uintptr_t)readDatablockID(stream); do_id_convert = true; } diff --git a/Engine/source/afx/ce/afxPhraseEffect.cpp b/Engine/source/afx/ce/afxPhraseEffect.cpp index 5df7dfc26..b574afbed 100644 --- a/Engine/source/afx/ce/afxPhraseEffect.cpp +++ b/Engine/source/afx/ce/afxPhraseEffect.cpp @@ -215,7 +215,7 @@ void afxPhraseEffectData::unpack_fx(BitStream* stream, afxEffectList& fx) fx.clear(); S32 n_fx = stream->readInt(EFFECTS_PER_PHRASE_BITS); for (int i = 0; i < n_fx; i++) - fx.push_back((afxEffectWrapperData*)readDatablockID(stream)); + fx.push_back((afxEffectWrapperData*)(uintptr_t)readDatablockID(stream)); } void afxPhraseEffectData::packData(BitStream* stream) diff --git a/Engine/source/app/net/serverQuery.cpp b/Engine/source/app/net/serverQuery.cpp index 17caac478..a1f60cd74 100644 --- a/Engine/source/app/net/serverQuery.cpp +++ b/Engine/source/app/net/serverQuery.cpp @@ -1611,9 +1611,7 @@ static void handleExtendedMasterServerListResponse(BitStream* stream, U32 key, U { U16 packetIndex, packetTotal; U32 i; - U16 serverCount, port; - U8 netNum[16]; - char addressBuffer[256]; + U16 serverCount; NetAddress addr; stream->read(&packetIndex); diff --git a/Engine/source/assets/assetManager.cpp b/Engine/source/assets/assetManager.cpp index c2591a84f..2018dd57c 100644 --- a/Engine/source/assets/assetManager.cpp +++ b/Engine/source/assets/assetManager.cpp @@ -130,8 +130,8 @@ void AssetManager::initPersistFields() // Call parent. Parent::initPersistFields(); - addField( "EchoInfo", TypeBool, Offset(mEchoInfo, AssetManager), "Whether the asset manager echos extra information to the console or not." ); - addField( "IgnoreAutoUnload", TypeBool, Offset(mIgnoreAutoUnload, AssetManager), "Whether the asset manager should ignore unloading of auto-unload assets or not." ); + addField( "EchoInfo", TypeBool, false, Offset(mEchoInfo, AssetManager), "Whether the asset manager echos extra information to the console or not." ); + addField( "IgnoreAutoUnload", TypeBool, true, Offset(mIgnoreAutoUnload, AssetManager), "Whether the asset manager should ignore unloading of auto-unload assets or not." ); } //----------------------------------------------------------------------------- @@ -228,7 +228,7 @@ bool AssetManager::loadModuleAutoLoadAssets(ModuleDefinition* pModuleDefinition) AssertFatal(pModuleDefinition != NULL, "Cannot auto load assets using a NULL module definition"); // Does the module have any assets associated with it? - if (pModuleDefinition->getModuleAssets().empty()) + if (pModuleDefinition->getModuleAssets().empty() && mEchoInfo) { // Yes, so warn. Con::warnf("Asset Manager: Cannot auto load assets to module '%s' as it has no existing assets.", pModuleDefinition->getSignature()); diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index 5fa20a82c..78a469522 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -836,7 +836,7 @@ public: /// Define a call-in point for calling into the engine. Unlike with DefineEngineFunction, the statically /// callable function will be confined to the namespace of the given class. /// -/// @param name The name of the C++ class (or a registered export scope). +/// @param classname The name of the C++ class (or a registered export scope). /// @param name The name of the method as it should be seen by the control layer. /// @param returnType The value type returned to the control layer. /// @param args The argument list as it would appear on the function definition diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index 447d96ce4..6cf6fd029 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -2834,13 +2834,16 @@ DefineEngineMethod( SimObject, getFieldValue, const char*, ( const char* fieldNa "@param index Optional parameter to specify the index of an array field separately.\n" "@return The value of the given field or \"\" if undefined." ) { + const U32 nameLen = dStrlen( fieldName ); + if (nameLen == 0) + return ""; + char fieldNameBuffer[ 1024 ]; char arrayIndexBuffer[ 64 ]; // Parse out index if the field is given in the form of 'name[index]'. const char* arrayIndex = NULL; - const U32 nameLen = dStrlen( fieldName ); if( fieldName[ nameLen - 1 ] == ']' ) { const char* leftBracket = dStrchr( fieldName, '[' ); diff --git a/Engine/source/environment/cloudLayer.cpp b/Engine/source/environment/cloudLayer.cpp index e30f1ecd1..08cb6ce00 100644 --- a/Engine/source/environment/cloudLayer.cpp +++ b/Engine/source/environment/cloudLayer.cpp @@ -398,10 +398,10 @@ void CloudLayer::_initTexture() } if ( mTextureName.isNotEmpty() ) - mTexture.set( mTextureName, &GFXStaticTextureSRGBProfile, "CloudLayer" ); + mTexture.set( mTextureName, &GFXNormalMapProfile, "CloudLayer" ); if ( mTexture.isNull() ) - mTexture.set( GFXTextureManager::getWarningTexturePath(), &GFXStaticTextureSRGBProfile, "CloudLayer" ); + mTexture.set( GFXTextureManager::getWarningTexturePath(), &GFXNormalMapProfile, "CloudLayer" ); } void CloudLayer::_initBuffers() @@ -501,4 +501,4 @@ void CloudLayer::_initBuffers() } mPB.unlock(); -} \ No newline at end of file +} diff --git a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp index bb78ba61e..95dfe4ad9 100644 --- a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp @@ -45,6 +45,8 @@ #include "materials/materialDefinition.h" #include "T3D/prefab.h" +#include "T3D/Scene.h" + IMPLEMENT_CONOBJECT(GuiMeshRoadEditorCtrl); ConsoleDocClass( GuiMeshRoadEditorCtrl, @@ -420,12 +422,14 @@ void GuiMeshRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) newRoad->registerObject(); - // Add to MissionGroup - SimGroup *missionGroup; - if ( !Sim::findObject( "MissionGroup", missionGroup ) ) - Con::errorf( "GuiMeshRoadEditorCtrl - could not find MissionGroup to add new MeshRoad" ); + // Add to scene + Scene *scene; + + scene = Scene::getRootScene(); + if ( !scene) + Con::errorf( "GuiMeshRoadEditorCtrl - could not find Scene to add new MeshRoad" ); else - missionGroup->addObject( newRoad ); + scene->addObject( newRoad ); Point3F pos( endPnt ); pos.z += mDefaultDepth * 0.5f; diff --git a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp index 50abb45df..23df5900d 100644 --- a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp @@ -43,6 +43,8 @@ #include "T3D/gameBase/gameConnection.h" #include "T3D/prefab.h" +#include "T3D/Scene.h" + IMPLEMENT_CONOBJECT(GuiRiverEditorCtrl); ConsoleDocClass( GuiRiverEditorCtrl, @@ -444,12 +446,12 @@ void GuiRiverEditorCtrl::_process3DMouseDown( const Gui3DMouseEvent& event ) return; } - // Add to MissionGroup - SimGroup *missionGroup; - if ( !Sim::findObject( "MissionGroup", missionGroup ) ) - Con::errorf( "GuiRiverEditorCtrl - could not find MissionGroup to add new River" ); + // Add to Scene + Scene* scene = Scene::getRootScene(); + if ( !scene ) + Con::errorf( "GuiRiverEditorCtrl - could not find root Scene to add new River" ); else - missionGroup->addObject( newRiver ); + scene->addObject( newRiver ); Point3F pos( endPnt ); pos.z += mDefaultDepth * 0.5f; diff --git a/Engine/source/environment/editors/guiRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiRoadEditorCtrl.cpp index 7a2ec8a96..c3b3f0e99 100644 --- a/Engine/source/environment/editors/guiRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiRoadEditorCtrl.cpp @@ -39,6 +39,8 @@ #include "gui/worldEditor/undoActions.h" #include "materials/materialDefinition.h" +#include "T3D/Scene.h" + IMPLEMENT_CONOBJECT(GuiRoadEditorCtrl); ConsoleDocClass( GuiRoadEditorCtrl, @@ -407,12 +409,12 @@ void GuiRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) newRoad->registerObject(); - // Add to MissionGroup - SimGroup *missionGroup; - if ( !Sim::findObject( "MissionGroup", missionGroup ) ) - Con::errorf( "GuiDecalRoadEditorCtrl - could not find MissionGroup to add new DecalRoad" ); + // Add to scene + Scene* scene = Scene::getRootScene(); + if ( !scene ) + Con::errorf( "GuiDecalRoadEditorCtrl - could not find scene to add new DecalRoad" ); else - missionGroup->addObject( newRoad ); + scene->addObject( newRoad ); newRoad->insertNode( tPos, mDefaultWidth, 0 ); U32 newNode = newRoad->insertNode( tPos, mDefaultWidth, 1 ); @@ -722,7 +724,7 @@ void GuiRoadEditorCtrl::renderScene(const RectI & updateRect) // Draw the spline based from the client-side road // because the serverside spline is not actually reliable... // Can be incorrect if the DecalRoad is before the TerrainBlock - // in the MissionGroup. + // in the scene. if ( mHoverRoad && mHoverRoad != mSelRoad ) { diff --git a/Engine/source/forest/editor/forestUndo.cpp b/Engine/source/forest/editor/forestUndo.cpp index 60be8d2b1..603986700 100644 --- a/Engine/source/forest/editor/forestUndo.cpp +++ b/Engine/source/forest/editor/forestUndo.cpp @@ -55,7 +55,7 @@ void ForestCreateUndoAction::addItem( ForestItemData *data, // We store the datablock ID rather than the actual pointer // since the pointer could go bad. SimObjectId dataId = item.getData()->getId(); - mItems.last().setData( (ForestItemData*)dataId ); + mItems.last().setData( (ForestItemData*)(uintptr_t)dataId ); } void ForestCreateUndoAction::redo() @@ -110,7 +110,7 @@ void ForestDeleteUndoAction::removeItem( const ForestItem &item ) SimObjectId dataId = item.getData()->getId(); mItems.push_back( item ); - mItems.last().setData( (ForestItemData*)dataId ); + mItems.last().setData( (ForestItemData*)(uintptr_t)dataId ); mData->removeItem( item.getKey(), item.getPosition() ); } @@ -171,7 +171,7 @@ void ForestUpdateAction::saveItem( const ForestItem &item ) // We store the datablock ID rather than the actual pointer // since the pointer could go bad. SimObjectId dataId = item.getData()->getId(); - mItems.last().setData( (ForestItemData*)dataId ); + mItems.last().setData( (ForestItemData*)(uintptr_t)dataId ); } void ForestUpdateAction::_swapState() @@ -215,7 +215,7 @@ void ForestUpdateAction::_swapState() item.getScale() ); // Save the state before this swap for the next swap. - newItem.setData( (ForestItemData*)data->getId() ); + newItem.setData( (ForestItemData*)(uintptr_t)data->getId() ); mItems.push_back( newItem ); } diff --git a/Engine/source/gfx/D3D11/gfxD3D11Device.cpp b/Engine/source/gfx/D3D11/gfxD3D11Device.cpp index 5144eba4b..f398b6bb6 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Device.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11Device.cpp @@ -233,7 +233,7 @@ DXGI_SWAP_CHAIN_DESC GFXD3D11Device::setupPresentParams(const GFXVideoMode &mode if (mode.fullScreen) { - d3dpp.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; + d3dpp.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED; d3dpp.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; d3dpp.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; } @@ -1893,4 +1893,4 @@ void GFXD3D11Device::setDebugMarker(ColorI color, const char *name) D3DPERF_SetMarker(D3DCOLOR_ARGB(color.alpha, color.red, color.green, color.blue), (LPCWSTR)&eventName); -} \ No newline at end of file +} diff --git a/Engine/source/gfx/gfxStringEnumTranslate.cpp b/Engine/source/gfx/gfxStringEnumTranslate.cpp index 8a3db347c..8c08c939e 100644 --- a/Engine/source/gfx/gfxStringEnumTranslate.cpp +++ b/Engine/source/gfx/gfxStringEnumTranslate.cpp @@ -77,11 +77,11 @@ _STRING_VALUE_LOOKUP_FXN(GFXStringBlendOp); #define INIT_LOOKUPTABLE( tablearray, enumprefix, type ) \ for( S32 i = enumprefix##_FIRST; i < enumprefix##_COUNT; i++ ) \ - tablearray[i] = (type)GFX_UNINIT_VAL; + tablearray[i] = (type)(uintptr_t)GFX_UNINIT_VAL; #define INIT_LOOKUPTABLE_EX( tablearray, enumprefix, type, typeTable ) \ for( S32 i = enumprefix##_FIRST; i < enumprefix##_COUNT; i++ ) \ {\ - tablearray[i] = (type)GFX_UNINIT_VAL;\ + tablearray[i] = (type)(uintptr_t)GFX_UNINIT_VAL;\ typeTable[i] = &defaultStringValueLookup;\ } diff --git a/Engine/source/gfx/gl/gfxGLPrimitiveBuffer.cpp b/Engine/source/gfx/gl/gfxGLPrimitiveBuffer.cpp index 385e0ed50..3df694de9 100644 --- a/Engine/source/gfx/gl/gfxGLPrimitiveBuffer.cpp +++ b/Engine/source/gfx/gl/gfxGLPrimitiveBuffer.cpp @@ -131,7 +131,7 @@ void GFXGLPrimitiveBuffer::finish() GLvoid* GFXGLPrimitiveBuffer::getBuffer() { // NULL specifies no offset into the hardware buffer - return (GLvoid*)mBufferOffset; + return (GLvoid*)(uintptr_t)mBufferOffset; } void GFXGLPrimitiveBuffer::zombify() diff --git a/Engine/source/gfx/gl/gfxGLVertexDecl.cpp b/Engine/source/gfx/gl/gfxGLVertexDecl.cpp index 64195164e..bfe6b6f93 100644 --- a/Engine/source/gfx/gl/gfxGLVertexDecl.cpp +++ b/Engine/source/gfx/gl/gfxGLVertexDecl.cpp @@ -130,7 +130,7 @@ void GFXGLVertexDecl::_initVerticesFormat(U32 stream) glElement.normalized = false; glElement.type = GL_FLOAT; glElement.stride = vertexSize; - glElement.pointerFirst = (void*)buffer; + glElement.pointerFirst = (void*)(uintptr_t)buffer; buffer += element.getSizeInBytes(); } @@ -141,7 +141,7 @@ void GFXGLVertexDecl::_initVerticesFormat(U32 stream) glElement.normalized = false; glElement.type = GL_FLOAT; glElement.stride = vertexSize; - glElement.pointerFirst = (void*)buffer; + glElement.pointerFirst = (void*)(uintptr_t)buffer; buffer += element.getSizeInBytes(); } @@ -152,7 +152,7 @@ void GFXGLVertexDecl::_initVerticesFormat(U32 stream) glElement.normalized = false; glElement.type = GL_FLOAT; glElement.stride = vertexSize; - glElement.pointerFirst = (void*)buffer; + glElement.pointerFirst = (void*)(uintptr_t)buffer; buffer += element.getSizeInBytes(); } @@ -163,7 +163,7 @@ void GFXGLVertexDecl::_initVerticesFormat(U32 stream) glElement.normalized = false; glElement.type = GL_FLOAT; glElement.stride = vertexSize; - glElement.pointerFirst = (void*)buffer; + glElement.pointerFirst = (void*)(uintptr_t)buffer; buffer += element.getSizeInBytes(); } @@ -174,7 +174,7 @@ void GFXGLVertexDecl::_initVerticesFormat(U32 stream) glElement.normalized = false; glElement.type = GL_FLOAT; glElement.stride = vertexSize; - glElement.pointerFirst = (void*)buffer; + glElement.pointerFirst = (void*)(uintptr_t)buffer; buffer += element.getSizeInBytes(); } @@ -185,7 +185,7 @@ void GFXGLVertexDecl::_initVerticesFormat(U32 stream) glElement.normalized = true; glElement.type = GL_UNSIGNED_BYTE; glElement.stride = vertexSize; - glElement.pointerFirst = (void*)buffer; + glElement.pointerFirst = (void*)(uintptr_t)buffer; buffer += element.getSizeInBytes(); } @@ -196,7 +196,7 @@ void GFXGLVertexDecl::_initVerticesFormat(U32 stream) glElement.normalized = false; glElement.type = GL_FLOAT; glElement.stride = vertexSize; - glElement.pointerFirst = (void*)buffer; + glElement.pointerFirst = (void*)(uintptr_t)buffer; buffer += element.getSizeInBytes(); } @@ -207,7 +207,7 @@ void GFXGLVertexDecl::_initVerticesFormat(U32 stream) glElement.normalized = false; glElement.type = GL_UNSIGNED_BYTE; glElement.stride = vertexSize; - glElement.pointerFirst = (void*)buffer; + glElement.pointerFirst = (void*)(uintptr_t)buffer; buffer += element.getSizeInBytes(); } @@ -221,7 +221,7 @@ void GFXGLVertexDecl::_initVerticesFormat(U32 stream) glElement.normalized = false; glElement.type = GL_FLOAT; glElement.stride = vertexSize; - glElement.pointerFirst = (void*)buffer; + glElement.pointerFirst = (void*)(uintptr_t)buffer; buffer += element.getSizeInBytes(); ++texCoordIndex; diff --git a/Engine/source/gui/buttons/guiSwatchButtonCtrl.cpp b/Engine/source/gui/buttons/guiSwatchButtonCtrl.cpp index 686ba0b04..7db73a05e 100644 --- a/Engine/source/gui/buttons/guiSwatchButtonCtrl.cpp +++ b/Engine/source/gui/buttons/guiSwatchButtonCtrl.cpp @@ -72,7 +72,7 @@ GuiSwatchButtonCtrl::GuiSwatchButtonCtrl() void GuiSwatchButtonCtrl::initPersistFields() { addField("color", TypeColorF, Offset(mSwatchColor, GuiSwatchButtonCtrl), "The foreground color of GuiSwatchButtonCtrl"); - addField( "gridBitmap", TypeString, Offset( mGridBitmap, GuiSwatchButtonCtrl ), "The bitmap used for the transparent grid" ); + addField( "gridBitmap", TypeRealString, Offset( mGridBitmap, GuiSwatchButtonCtrl ), "The bitmap used for the transparent grid" ); Parent::initPersistFields(); } diff --git a/Engine/source/gui/containers/guiSplitContainer.cpp b/Engine/source/gui/containers/guiSplitContainer.cpp index df52829dc..59b2bb75f 100644 --- a/Engine/source/gui/containers/guiSplitContainer.cpp +++ b/Engine/source/gui/containers/guiSplitContainer.cpp @@ -613,3 +613,25 @@ void GuiSplitContainer::onMouseDragged( const GuiEvent &event ) solvePanelConstraints(newDragPos, firstPanel, secondPanel, clientRect); } } + +void GuiSplitContainer::setSplitPoint(Point2I splitPoint) +{ + GuiContainer *firstPanel = dynamic_cast(at(0)); + GuiContainer *secondPanel = dynamic_cast(at(1)); + + // This function will constrain the panels to their minExtents and update the mSplitPoint + if (firstPanel && secondPanel) + { + RectI clientRect = getClientRect(); + + solvePanelConstraints(splitPoint, firstPanel, secondPanel, clientRect); + + layoutControls(clientRect); + } +} + +DefineEngineMethod(GuiSplitContainer, setSplitPoint, void, (Point2I splitPoint), , + "Set the position of the split handle.") +{ + object->setSplitPoint(splitPoint); +} diff --git a/Engine/source/gui/containers/guiSplitContainer.h b/Engine/source/gui/containers/guiSplitContainer.h index f3d853fe4..ab78fb0ff 100644 --- a/Engine/source/gui/containers/guiSplitContainer.h +++ b/Engine/source/gui/containers/guiSplitContainer.h @@ -87,6 +87,9 @@ public: virtual void solvePanelConstraints(Point2I newDragPos, GuiContainer * firstPanel, GuiContainer * secondPanel, const RectI& clientRect); virtual Point2I getMinExtent() const; + //Set the positin of the split handler + void setSplitPoint(Point2I splitPoint); + protected: S32 mFixedPanel; diff --git a/Engine/source/gui/controls/gui3DProjectionCtrl.cpp b/Engine/source/gui/controls/gui3DProjectionCtrl.cpp new file mode 100644 index 000000000..765b3f1f8 --- /dev/null +++ b/Engine/source/gui/controls/gui3DProjectionCtrl.cpp @@ -0,0 +1,298 @@ +//----------------------------------------------------------------------------- +// Gui3DProjectionCtrl +// Doppelganger Inc +// Orion Elenzil 200701 +// +// This control is meant to be merely a container for other controls. +// What's neat is that it's easy to 'attach' this control to a point in world-space +// or, more interestingly, to an object such as a player. +// +// Usage: +// * Create the Gui3DProjectionControl - by default it will be at 0, 0, 0. +// * You can change where it's located by setting the field "offsetWorld". +// - note you can specify that right in the .gui file +// * You can attach it to any SceneObject by calling "setAttachedTo()". +// +// Behaviour: +// * If you're attaching it to a player, by default it will center on the player's head. +// * If you attach it to an object, by default it will delete itself if the object is deleted. +// * Doesn't occlude w/r/t 3D objects. +// +// Console Methods: +// * SetAttachedTo(SceneObject) +// * GetAttachedTo() +// +// Params: +// * pointWorld - read/write point in worldspace. read-only if attached to an object. +// * offsetObject - an offset in objectspace. default 0, 0, 0. +// * offsetWorld - an offset in worldspace. default 0, 0, 0. +// * offsetScreen - an offset in screenspace. default 0, 0. +// * hAlign - horizontal alignment. 0 = left, 1 = center, 2 = right. default center. +// * vAlign - vertical alignment. 0 = top, 1 = center, 2 = bottomt. default center. +// * useEyePoint - H & V usage of the eyePoint, if player object. default 0, 1. (ie - use only the vertical component) +// * autoDelete - self-delete when attachedTo object is deleted. default true. +// +// Todo: +// * occlusion - hide the control when its anchor point is occluded. +// * integrate w/ zbuffer - this would actually be a change to the whole GuiControl system. +// * allow attaching to arbitrary nodes in a skeleton. +// * avoid projection when the object is out of the frustum. +// +// oxe 20070111 +//----------------------------------------------------------------------------- + +#include "console/console.h" +#include "console/consoleTypes.h" +#include "scene/sceneObject.h" +#include "T3D/player.h" +#include "gui/controls/gui3DProjectionCtrl.h" + +IMPLEMENT_CONOBJECT(Gui3DProjectionCtrl); + +//----------------------------------------------------------------------------- + +Gui3DProjectionCtrl::Gui3DProjectionCtrl() +{ + mTSCtrl = NULL; + mAttachedTo = NULL; + mAttachedToPlayer = NULL; + mAutoDelete = true; + mHAlign = center; + mVAlign = center; + mUseEyePoint.x = 0; + mUseEyePoint.y = 1; + + mPtWorld .set(0, 0, 0); + mPtProj .set(0, 0); + mOffsetObject.set(0, 0, 0); + mOffsetWorld .set(0, 0, 0); + mOffsetScreen.set(0, 0); +} + +void Gui3DProjectionCtrl::initPersistFields() +{ + Parent::initPersistFields(); + addGroup("3DProjection"); + addField("pointWorld" , TypePoint3F , Offset(mPtWorld , Gui3DProjectionCtrl)); + addField("offsetObject" , TypePoint3F , Offset(mOffsetObject , Gui3DProjectionCtrl)); + addField("offsetWorld" , TypePoint3F , Offset(mOffsetWorld , Gui3DProjectionCtrl)); + addField("offsetScreen" , TypePoint2I , Offset(mOffsetScreen , Gui3DProjectionCtrl)); + addField("hAlign" , TypeS32 , Offset(mHAlign , Gui3DProjectionCtrl)); + addField("vAlign" , TypeS32 , Offset(mVAlign , Gui3DProjectionCtrl)); + addField("useEyePoint" , TypePoint2I , Offset(mUseEyePoint , Gui3DProjectionCtrl)); + addField("autoDelete" , TypeBool , Offset(mAutoDelete , Gui3DProjectionCtrl)); + endGroup("3DProjection"); +} + +void Gui3DProjectionCtrl::onRender(Point2I offset, const RectI &updateRect) +{ + doPositioning(); + doProjection(); + doAlignment(); + + Parent::onRender(offset, updateRect); +} + +void Gui3DProjectionCtrl::resizeDuringRender() +{ + doPositioning(); + doProjection (); + doAlignment (); +} + + + +bool Gui3DProjectionCtrl::onWake() +{ + // walk up the GUI tree until we find a GuiTSCtrl. + + mTSCtrl = NULL; + GuiControl* walkCtrl = getParent(); + AssertFatal(walkCtrl != NULL, "Gui3DProjectionCtrl::onWake() - NULL parent"); + bool doMore = true; + + while (doMore) + { + mTSCtrl = dynamic_cast(walkCtrl); + walkCtrl = walkCtrl->getParent(); + doMore = (mTSCtrl == NULL) && (walkCtrl != NULL); + } + + if (!mTSCtrl) + Con::errorf("Gui3DProjectionCtrl::onWake() - no TSCtrl parent"); + + return Parent::onWake(); +} + +void Gui3DProjectionCtrl::onSleep() +{ + mTSCtrl = NULL; + return Parent::onSleep(); +} + +void Gui3DProjectionCtrl::onDeleteNotify(SimObject* obj) +{ + // - SimSet assumes that obj is a member of THIS, which in our case ain't true. + // oxe 20070116 - the following doesn't compile on GCC. + // SimSet::Parent::onDeleteNotify(obj); + + if (!obj) + { + Con::warnf("Gui3DProjectionCtrl::onDeleteNotify - got NULL"); + return; + } + + if (obj != mAttachedTo) + { + if (mAttachedTo != NULL) + Con::warnf("Gui3DProjectionCtrl::onDeleteNotify - got unexpected object: %d vs. %d", obj->getId(), mAttachedTo->getId()); + return; + } + + if (mAutoDelete) + this->deleteObject(); +} + +//----------------------------------------------------------------------------- + +void Gui3DProjectionCtrl::doPositioning() +{ + if (mAttachedTo == NULL) + return; + + Point3F ptBase; // the regular position of the object. + Point3F ptEye; // the render position of the eye node, if a player object. + Point3F pt; // combination of ptBase and ptEye. + + MatrixF mat; // utility + + mAttachedTo->getRenderTransform().getColumn(3, &ptBase); + + if (mAttachedToPlayer != NULL) + { + mAttachedToPlayer->getRenderEyeTransform(&mat); + mat.getColumn(3, &ptEye); + } + else + { + ptEye = ptBase; + } + + // use some components from ptEye but other position from ptBase + pt = ptBase; + if (mUseEyePoint.x != 0) + { + pt.x = ptEye.x; + pt.y = ptEye.y; + } + if (mUseEyePoint.y != 0) + { + pt.z = ptEye.z; + } + + // object-space offset + Point3F offsetObj; + QuatF quat(mAttachedTo->getRenderTransform()); + quat.mulP(mOffsetObject, &offsetObj); + pt += offsetObj; + + + // world-space offset + pt += mOffsetWorld; + + mPtWorld = pt; +} + + +void Gui3DProjectionCtrl::doProjection() +{ + if (!mTSCtrl) + return; + + Point3F pt; + + if (!mTSCtrl->project(mPtWorld, &pt)) + return; + + mPtProj.x = (S32)(pt.x + 0.5f); + mPtProj.y = (S32)(pt.y + 0.5f); +} + +void Gui3DProjectionCtrl::doAlignment() +{ + // alignment + Point2I offsetAlign; + switch(mHAlign) + { + default: + case center: + offsetAlign.x = -getBounds().extent.x / 2; + break; + case min: + offsetAlign.x = 0; + break; + case max: + offsetAlign.x = -getBounds().extent.x; + break; + } + + switch(mVAlign) + { + default: + case center: + offsetAlign.y = -getBounds().extent.y / 2; + break; + case min: + offsetAlign.y = 0; + break; + case max: + offsetAlign.y = -getBounds().extent.y; + break; + } + + // projected point + mPtScreen = mPtProj; + + // alignment offset + mPtScreen += offsetAlign; + + // screen offset + mPtScreen += mOffsetScreen; + +// setTrgPosition(mPtScreen); + RectI bounds = getBounds(); + bounds.point = mPtScreen; + setBounds(bounds); +} + +//----------------------------------------------------------------------------- + +void Gui3DProjectionCtrl::setAttachedTo(SceneObject* obj) +{ + if (obj == mAttachedTo) + return; + + if (mAttachedTo) + clearNotify(mAttachedTo); + + mAttachedTo = obj; + mAttachedToPlayer = dynamic_cast(obj); + + if (mAttachedTo) + deleteNotify(mAttachedTo); +} + +DefineEngineMethod(Gui3DProjectionCtrl, setAttachedTo, void, (SceneObject* target), (nullAsType()), "(object)") +{ + if(target) + object->setAttachedTo(target); +} + +DefineEngineMethod(Gui3DProjectionCtrl, getAttachedTo, S32, (),, "()") +{ + SceneObject* obj = object->getAttachedTo(); + if (!obj) + return 0; + else + return obj->getId(); +} diff --git a/Engine/source/gui/controls/gui3DProjectionCtrl.h b/Engine/source/gui/controls/gui3DProjectionCtrl.h new file mode 100644 index 000000000..b2d1949b0 --- /dev/null +++ b/Engine/source/gui/controls/gui3DProjectionCtrl.h @@ -0,0 +1,77 @@ +//----------------------------------------------------------------------------- +// Gui3DProjectionCtrl +// Doppelganger Inc +// Orion Elenzil 200701 +// +// +//----------------------------------------------------------------------------- + +#ifndef _GUI3DPROJECTIONCTRL_H_ +#define _GUI3DPROJECTIONCTRL_H_ + +#include "gui/core/guiTypes.h" +#include "gui/core/guiControl.h" +#include "gui/3d/guiTSControl.h" +#include "scene/sceneObject.h" +#include "T3D/player.h" + +class Gui3DProjectionCtrl : public GuiControl +{ + +//----------------------------------------------------------------------------- +// stock stuff +public: + Gui3DProjectionCtrl(); + typedef GuiControl Parent; + + DECLARE_CONOBJECT(Gui3DProjectionCtrl); + + static void initPersistFields (); + +//----------------------------------------------------------------------------- +// more interesting stuff + + GuiTSCtrl* mTSCtrl; /// must be a child of one of these. + SimObjectPtr mAttachedTo; /// optional object we're attached to. + SimObjectPtr mAttachedToPlayer; /// same pointer as mAttachedTo, but conveniently casted to player. + + Point3F mPtWorld; /// the worldspace point which we're projecting + Point2I mPtProj; /// the screenspace projected point. - note there are further modifiers before + Point2I mPtScreen; + + Point3F mOffsetObject; /// object-space offset applied first to the attached point to obtain mPtWorld. + Point3F mOffsetWorld; /// world-space offset applied second to the attached point to obtain mPtWorld. + Point2I mOffsetScreen; /// screen-space offset applied to mPtProj. note we still have centering, etc. + + enum alignment + { + min = 0, + center = 1, + max = 2 + }; + + alignment mHAlign; /// horizontal alignment + alignment mVAlign; /// horizontal alignment + + bool mAutoDelete; /// optionally self-delete when mAttachedTo is deleted. + Point2I mUseEyePoint; /// optionally use the eye point. x != 0 -> horiz. y != 0 -> vert. + + + virtual void onRender (Point2I offset, const RectI &updateRect); + virtual void resizeDuringRender (); + + virtual bool onWake (); + virtual void onSleep (); + virtual void onDeleteNotify (SimObject *object); + + void doPositioning (); + void doProjection (); + void doAlignment (); + + void setAttachedTo (SceneObject* obj); + SceneObject* getAttachedTo () { return mAttachedTo; } + void setWorldPt (Point3F& pt) { mPtWorld = pt; } + Point3F getWorldPt () { return mPtWorld; } +}; + +#endif //_GUI3DPROJECTIONCTRL_H_ \ No newline at end of file diff --git a/Engine/source/gui/controls/guiConsole.cpp b/Engine/source/gui/controls/guiConsole.cpp index d063272bf..3eb81e7e8 100644 --- a/Engine/source/gui/controls/guiConsole.cpp +++ b/Engine/source/gui/controls/guiConsole.cpp @@ -89,9 +89,6 @@ bool GuiConsole::onWake() S32 GuiConsole::getMaxWidth(S32 startIndex, S32 endIndex) { //sanity check - U32 size; - ConsoleLogEntry *log; - if (startIndex < 0 || (U32)endIndex >= mFilteredLog.size() || startIndex > endIndex) return 0; @@ -190,9 +187,6 @@ void GuiConsole::onPreRender() void GuiConsole::onRenderCell(Point2I offset, Point2I cell, bool /*selected*/, bool /*mouseOver*/) { - U32 size; - ConsoleLogEntry *log; - ConsoleLogEntry &entry = mFilteredLog[cell.y]; switch (entry.mLevel) { @@ -210,9 +204,6 @@ void GuiConsole::onCellSelected( Point2I cell ) { Parent::onCellSelected( cell ); - U32 size; - ConsoleLogEntry* log; - ConsoleLogEntry& entry = mFilteredLog[cell.y]; onMessageSelected_callback( entry.mLevel, entry.mString ); } diff --git a/Engine/source/gui/controls/guiListBoxCtrl.cpp b/Engine/source/gui/controls/guiListBoxCtrl.cpp index d47914d3d..cab79e1b0 100644 --- a/Engine/source/gui/controls/guiListBoxCtrl.cpp +++ b/Engine/source/gui/controls/guiListBoxCtrl.cpp @@ -631,7 +631,7 @@ DefineEngineMethod( GuiListBoxCtrl, addItem, S32, (const char* newItem, const ch else if(elementCount == 1) { U32 objId = dAtoi( color ); - return object->addItem( newItem, (void*)objId ); + return object->addItem( newItem, (void*)(uintptr_t)objId ); } else { @@ -1523,7 +1523,7 @@ void GuiListBoxCtrl::_mirror() if ( !found ) { - addItem( _makeMirrorItemName( curObj ), (void*)curId ); + addItem( _makeMirrorItemName( curObj ), (void*)(uintptr_t)curId ); } } } diff --git a/Engine/source/gui/controls/guiTextEditCtrl.cpp b/Engine/source/gui/controls/guiTextEditCtrl.cpp index 968fe17a6..65bb331a6 100644 --- a/Engine/source/gui/controls/guiTextEditCtrl.cpp +++ b/Engine/source/gui/controls/guiTextEditCtrl.cpp @@ -1241,6 +1241,9 @@ void GuiTextEditCtrl::onLoseFirstResponder() root->disableKeyboardTranslation(); } + updateHistory(&mTextBuffer, true); + mHistoryDirty = false; + //execute the validate command if( mValidateCommand.isNotEmpty() ) evaluate( mValidateCommand ); diff --git a/Engine/source/gui/editor/guiMenuBar.cpp b/Engine/source/gui/editor/guiMenuBar.cpp index 7a0f10ce3..ec75520c9 100644 --- a/Engine/source/gui/editor/guiMenuBar.cpp +++ b/Engine/source/gui/editor/guiMenuBar.cpp @@ -33,6 +33,7 @@ #include "gfx/gfxDrawUtil.h" #include "gfx/primBuilder.h" #include "console/engineAPI.h" +#include "gui/editor/guiPopupMenuCtrl.h" // menu bar: // basic idea - fixed height control bar at the top of a window, placed and sized in gui editor @@ -1113,6 +1114,13 @@ GuiMenuBar::GuiMenuBar() void GuiMenuBar::onRemove() { + GuiPopupMenuBackgroundCtrl* backgroundCtrl; + if (Sim::findObject("PopUpMenuControl", backgroundCtrl)) + { + if (backgroundCtrl->mMenuBarCtrl == this) + backgroundCtrl->mMenuBarCtrl = nullptr; + } + Parent::onRemove(); } @@ -1472,11 +1480,11 @@ PopupMenu* GuiMenuBar::getMenu(U32 index) return mMenuList[index].popupMenu; } -PopupMenu* GuiMenuBar::findMenu(StringTableEntry barTitle) +PopupMenu* GuiMenuBar::findMenu(String barTitle) { for (U32 i = 0; i < mMenuList.size(); i++) { - if (mMenuList[i].text == barTitle) + if (String::ToLower(mMenuList[i].text) == String::ToLower(barTitle)) return mMenuList[i].popupMenu; } @@ -1521,8 +1529,7 @@ DefineEngineMethod(GuiMenuBar, insert, void, (SimObject* pObject, S32 pos), (nul DefineEngineMethod(GuiMenuBar, findMenu, S32, (const char* barTitle), (""), "(barTitle)") { - StringTableEntry barTitleStr = StringTable->insert(barTitle); - PopupMenu* menu = object->findMenu(barTitleStr); + PopupMenu* menu = object->findMenu(barTitle); if (menu) return menu->getId(); diff --git a/Engine/source/gui/editor/guiMenuBar.h b/Engine/source/gui/editor/guiMenuBar.h index 054be37cc..985df8de6 100644 --- a/Engine/source/gui/editor/guiMenuBar.h +++ b/Engine/source/gui/editor/guiMenuBar.h @@ -116,7 +116,7 @@ public: U32 getMenuListCount() { return mMenuList.size(); } PopupMenu* getMenu(U32 index); - PopupMenu* findMenu(StringTableEntry barTitle); + PopupMenu* findMenu(String barTitle); DECLARE_CONOBJECT(GuiMenuBar); DECLARE_CALLBACK( void, onMouseInMenu, ( bool hasLeftMenu )); diff --git a/Engine/source/gui/editor/inspector/field.cpp b/Engine/source/gui/editor/inspector/field.cpp index 2808ee140..02046f7a9 100644 --- a/Engine/source/gui/editor/inspector/field.cpp +++ b/Engine/source/gui/editor/inspector/field.cpp @@ -50,7 +50,9 @@ GuiInspectorField::GuiInspectorField( GuiInspector* inspector, mField( field ), mFieldArrayIndex( NULL ), mEdit( NULL ), - mTargetObject(NULL) + mTargetObject(NULL), + mUseHeightOverride(false), + mHeightOverride(18) { if( field != NULL ) mCaption = field->pFieldname; @@ -77,7 +79,9 @@ GuiInspectorField::GuiInspectorField() mTargetObject(NULL), mVariableName(StringTable->EmptyString()), mCallbackName(StringTable->EmptyString()), - mSpecialEditField(false) + mSpecialEditField(false), + mUseHeightOverride(false), + mHeightOverride(18) { setCanSave( false ); } @@ -112,7 +116,12 @@ bool GuiInspectorField::onAdd() if ( mEdit == NULL ) return false; - setBounds(0,0,100,18); + S32 fieldHeight = 18; + + if (mUseHeightOverride) + fieldHeight = mHeightOverride; + + setBounds(0,0,100, fieldHeight); // Add our edit as a child addObject( mEdit ); diff --git a/Engine/source/gui/editor/inspector/field.h b/Engine/source/gui/editor/inspector/field.h index cb1210b53..3df9f5ece 100644 --- a/Engine/source/gui/editor/inspector/field.h +++ b/Engine/source/gui/editor/inspector/field.h @@ -84,6 +84,10 @@ class GuiInspectorField : public GuiControl /// bool mHighlighted; + //These are so we can special-case our height for additional room on certain field-types + bool mUseHeightOverride; + U32 mHeightOverride; + //An override that lets us bypass inspector-dependent logic for setting/getting variables/fields bool mSpecialEditField; //An override to make sure this field is associated to an object that isn't expressly diff --git a/Engine/source/gui/editor/inspector/mountingGroup.cpp b/Engine/source/gui/editor/inspector/mountingGroup.cpp index 759139658..158461902 100644 --- a/Engine/source/gui/editor/inspector/mountingGroup.cpp +++ b/Engine/source/gui/editor/inspector/mountingGroup.cpp @@ -133,9 +133,6 @@ bool GuiInspectorMountingGroup::inspectGroup() clearFields(); bool bNewItems = false; - bool bMakingArray = false; - GuiStackControl *pArrayStack = NULL; - GuiRolloutCtrl *pArrayRollout = NULL; bool bGrabItems = false; AbstractClassRep* commonAncestorClass = findCommonAncestorClass(); @@ -240,7 +237,6 @@ void GuiInspectorMountingGroup::updateAllFields() void GuiInspectorMountingGroup::onMouseMove(const GuiEvent &event) { //mParent->mOverDivider = false; - bool test = false; } DefineEngineMethod(GuiInspectorMountingGroup, inspectGroup, bool, (),, "Refreshes the dynamic fields in the inspector.") diff --git a/Engine/source/gui/editor/popupMenu.cpp b/Engine/source/gui/editor/popupMenu.cpp index 308fb4e67..9aef352ca 100644 --- a/Engine/source/gui/editor/popupMenu.cpp +++ b/Engine/source/gui/editor/popupMenu.cpp @@ -282,156 +282,159 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */) if (owner == NULL) return; - GuiControl* editorGui; - Sim::findObject("EditorGui", editorGui); + GuiPopupMenuBackgroundCtrl* backgroundCtrl; + Sim::findObject("PopUpMenuControl", backgroundCtrl); - if (editorGui) + GuiControlProfile* profile; + Sim::findObject("GuiMenubarProfile", profile); + + if (!profile) + return; + + if (mTextList == nullptr) { - GuiPopupMenuBackgroundCtrl* backgroundCtrl; - Sim::findObject("PopUpMenuControl", backgroundCtrl); + mTextList = new GuiPopupMenuTextListCtrl(); + mTextList->registerObject(); + mTextList->setControlProfile(profile); - GuiControlProfile* profile; - Sim::findObject("GuiMenubarProfile", profile); - - if (!profile) - return; - - if (mTextList == nullptr) - { - mTextList = new GuiPopupMenuTextListCtrl(); - mTextList->registerObject(); - mTextList->setControlProfile(profile); - - mTextList->mPopup = this; - mTextList->mMenuBar = getMenuBarCtrl(); - } - - if (!backgroundCtrl) - { - backgroundCtrl = new GuiPopupMenuBackgroundCtrl(); - - backgroundCtrl->registerObject("PopUpMenuControl"); - } - - if (!backgroundCtrl || !mTextList) - return; - - if (!mIsSubmenu) - { - //if we're a 'parent' menu, then tell the background to clear out all existing other popups - - backgroundCtrl->clearPopups(); - } - - //find out if we're doing a first-time add - S32 popupIndex = backgroundCtrl->findPopupMenu(this); - - if (popupIndex == -1) - { - backgroundCtrl->addObject(mTextList); - backgroundCtrl->mPopups.push_back(this); - } - - mTextList->mBackground = backgroundCtrl; - - owner->pushDialogControl(backgroundCtrl, 10); - - //Set the background control's menubar, if any, and if it's not already set - if(backgroundCtrl->mMenuBarCtrl == nullptr) - backgroundCtrl->mMenuBarCtrl = getMenuBarCtrl(); - - backgroundCtrl->setExtent(editorGui->getExtent()); - - mTextList->clear(); - - S32 textWidth = 0, width = 0; - S32 acceleratorWidth = 0; - GFont *font = profile->mFont; - - Point2I maxBitmapSize = Point2I(0, 0); - - S32 numBitmaps = profile->mBitmapArrayRects.size(); - if (numBitmaps) - { - RectI *bitmapBounds = profile->mBitmapArrayRects.address(); - for (S32 i = 0; i < numBitmaps; i++) - { - if (bitmapBounds[i].extent.x > maxBitmapSize.x) - maxBitmapSize.x = bitmapBounds[i].extent.x; - if (bitmapBounds[i].extent.y > maxBitmapSize.y) - maxBitmapSize.y = bitmapBounds[i].extent.y; - } - } - - for (U32 i = 0; i < mMenuItems.size(); i++) - { - if (!mMenuItems[i].mVisible) - continue; - - S32 iTextWidth = font->getStrWidth(mMenuItems[i].mText.c_str()); - S32 iAcceleratorWidth = mMenuItems[i].mAccelerator ? font->getStrWidth(mMenuItems[i].mAccelerator) : 0; - - if (iTextWidth > textWidth) - textWidth = iTextWidth; - if (iAcceleratorWidth > acceleratorWidth) - acceleratorWidth = iAcceleratorWidth; - } - - width = textWidth + acceleratorWidth + maxBitmapSize.x * 2 + 2 + 4; - - mTextList->setCellSize(Point2I(width, font->getHeight() + 2)); - mTextList->clearColumnOffsets(); - mTextList->addColumnOffset(-1); // add an empty column in for the bitmap index. - mTextList->addColumnOffset(maxBitmapSize.x + 1); - mTextList->addColumnOffset(maxBitmapSize.x + 1 + textWidth + 4); - - U32 entryCount = 0; - - for (U32 i = 0; i < mMenuItems.size(); i++) - { - if (!mMenuItems[i].mVisible) - continue; - - char buf[512]; - - // If this menu item is a submenu, then set the isSubmenu to 2 to indicate - // an arrow should be drawn. Otherwise set the isSubmenu normally. - char isSubmenu = 1; - if (mMenuItems[i].mIsSubmenu) - isSubmenu = 2; - - char bitmapIndex = 1; - if (mMenuItems[i].mBitmapIndex >= 0 && (mMenuItems[i].mBitmapIndex * 3 <= profile->mBitmapArrayRects.size())) - bitmapIndex = mMenuItems[i].mBitmapIndex + 2; - - dSprintf(buf, sizeof(buf), "%c%c\t%s\t%s", bitmapIndex, isSubmenu, mMenuItems[i].mText.c_str(), mMenuItems[i].mAccelerator ? mMenuItems[i].mAccelerator : ""); - mTextList->addEntry(entryCount, buf); - - if (!mMenuItems[i].mEnabled) - mTextList->setEntryActive(entryCount, false); - - entryCount++; - } - - Point2I pos = Point2I::Zero; - - if (x == -1 && y == -1) - pos = owner->getCursorPos(); - else - pos = Point2I(x, y); - - mTextList->setPosition(pos); - - //nudge in if we'd overshoot the screen - S32 widthDiff = (mTextList->getPosition().x + mTextList->getExtent().x) - backgroundCtrl->getWidth(); - if (widthDiff > 0) - { - Point2I popupPos = mTextList->getPosition(); - mTextList->setPosition(popupPos.x - widthDiff, popupPos.y); - } - - mTextList->setHidden(false); + mTextList->mPopup = this; + mTextList->mMenuBar = getMenuBarCtrl(); } + + if (!backgroundCtrl) + { + backgroundCtrl = new GuiPopupMenuBackgroundCtrl(); + + backgroundCtrl->registerObject("PopUpMenuControl"); + } + + if (!backgroundCtrl || !mTextList) + return; + + if (!mIsSubmenu) + { + //if we're a 'parent' menu, then tell the background to clear out all existing other popups + + backgroundCtrl->clearPopups(); + } + + //find out if we're doing a first-time add + S32 popupIndex = backgroundCtrl->findPopupMenu(this); + + if (popupIndex == -1) + { + backgroundCtrl->addObject(mTextList); + backgroundCtrl->mPopups.push_back(this); + } + + mTextList->mBackground = backgroundCtrl; + + owner->pushDialogControl(backgroundCtrl, 10); + + //Set the background control's menubar, if any, and if it's not already set + if(backgroundCtrl->mMenuBarCtrl == nullptr) + backgroundCtrl->mMenuBarCtrl = getMenuBarCtrl(); + + backgroundCtrl->setExtent(owner->getExtent()); + + mTextList->clear(); + + S32 textWidth = 0, width = 0; + S32 acceleratorWidth = 0; + GFont *font = profile->mFont; + + Point2I maxBitmapSize = Point2I(0, 0); + + S32 numBitmaps = profile->mBitmapArrayRects.size(); + if (numBitmaps) + { + RectI *bitmapBounds = profile->mBitmapArrayRects.address(); + for (S32 i = 0; i < numBitmaps; i++) + { + if (bitmapBounds[i].extent.x > maxBitmapSize.x) + maxBitmapSize.x = bitmapBounds[i].extent.x; + if (bitmapBounds[i].extent.y > maxBitmapSize.y) + maxBitmapSize.y = bitmapBounds[i].extent.y; + } + } + + for (U32 i = 0; i < mMenuItems.size(); i++) + { + if (!mMenuItems[i].mVisible) + continue; + + S32 iTextWidth = font->getStrWidth(mMenuItems[i].mText.c_str()); + S32 iAcceleratorWidth = mMenuItems[i].mAccelerator ? font->getStrWidth(mMenuItems[i].mAccelerator) : 0; + + if (iTextWidth > textWidth) + textWidth = iTextWidth; + if (iAcceleratorWidth > acceleratorWidth) + acceleratorWidth = iAcceleratorWidth; + } + + width = textWidth + acceleratorWidth + maxBitmapSize.x * 2 + 2 + 4; + + mTextList->setCellSize(Point2I(width, font->getHeight() + 2)); + mTextList->clearColumnOffsets(); + mTextList->addColumnOffset(-1); // add an empty column in for the bitmap index. + mTextList->addColumnOffset(maxBitmapSize.x + 1); + mTextList->addColumnOffset(maxBitmapSize.x + 1 + textWidth + 4); + + U32 entryCount = 0; + + for (U32 i = 0; i < mMenuItems.size(); i++) + { + if (!mMenuItems[i].mVisible) + continue; + + char buf[512]; + + // If this menu item is a submenu, then set the isSubmenu to 2 to indicate + // an arrow should be drawn. Otherwise set the isSubmenu normally. + char isSubmenu = 1; + if (mMenuItems[i].mIsSubmenu) + isSubmenu = 2; + + char bitmapIndex = 1; + if (mMenuItems[i].mBitmapIndex >= 0 && (mMenuItems[i].mBitmapIndex * 3 <= profile->mBitmapArrayRects.size())) + bitmapIndex = mMenuItems[i].mBitmapIndex + 2; + + dSprintf(buf, sizeof(buf), "%c%c\t%s\t%s", bitmapIndex, isSubmenu, mMenuItems[i].mText.c_str(), mMenuItems[i].mAccelerator ? mMenuItems[i].mAccelerator : ""); + mTextList->addEntry(entryCount, buf); + + if (!mMenuItems[i].mEnabled) + mTextList->setEntryActive(entryCount, false); + + entryCount++; + } + + Point2I pos = Point2I::Zero; + + if (x == -1 && y == -1) + pos = owner->getCursorPos(); + else + pos = Point2I(x, y); + + mTextList->setPosition(pos); + + //nudge in if we'd overshoot the screen + S32 widthDiff = (mTextList->getPosition().x + mTextList->getExtent().x) - backgroundCtrl->getWidth(); + if (widthDiff > 0) + { + Point2I popupPos = mTextList->getPosition(); + mTextList->setPosition(popupPos.x - widthDiff, popupPos.y); + } + + //If we'd overshoot the screen vertically, just mirror the axis so we're above the mouse + S32 heightDiff = (mTextList->getPosition().y + mTextList->getExtent().y) - backgroundCtrl->getHeight(); + if (heightDiff > 0) + { + Point2I popupPos = mTextList->getPosition(); + mTextList->setPosition(popupPos.x, popupPos.y - mTextList->getExtent().y); + } + + + mTextList->setHidden(false); } void PopupMenu::hidePopup() diff --git a/Engine/source/gui/utility/guiInputCtrl.cpp b/Engine/source/gui/utility/guiInputCtrl.cpp index c1799b43f..907d861a9 100644 --- a/Engine/source/gui/utility/guiInputCtrl.cpp +++ b/Engine/source/gui/utility/guiInputCtrl.cpp @@ -58,9 +58,25 @@ ConsoleDocClass( GuiInputCtrl, //------------------------------------------------------------------------------ +GuiInputCtrl::GuiInputCtrl() + : mSendAxisEvents(false), + mSendBreakEvents(false), + mSendModifierEvents(false) +{ +} + +//------------------------------------------------------------------------------ + void GuiInputCtrl::initPersistFields() { - + addGroup("GuiInputCtrl"); + addField("sendAxisEvents", TypeBool, Offset(mSendAxisEvents, GuiInputCtrl), + "If true, onAxisEvent callbacks will be sent for SI_AXIS Move events (Default false)."); + addField("sendBreakEvents", TypeBool, Offset(mSendBreakEvents, GuiInputCtrl), + "If true, break events for all devices will generate callbacks (Default false)."); + addField("sendModifierEvents", TypeBool, Offset(mSendModifierEvents, GuiInputCtrl), + "If true, Make events will be sent for modifier keys (Default false)."); + endGroup("GuiInputCtrl"); Parent::initPersistFields(); } @@ -110,6 +126,8 @@ static bool isModifierKey( U16 keyCode ) case KEY_RALT: case KEY_LSHIFT: case KEY_RSHIFT: + case KEY_MAC_LOPT: + case KEY_MAC_ROPT: return( true ); } @@ -117,33 +135,49 @@ static bool isModifierKey( U16 keyCode ) } IMPLEMENT_CALLBACK( GuiInputCtrl, onInputEvent, void, (const char* device, const char* action, bool state ), - ( device, action, state), - "@brief Callback that occurs when an input is triggered on this control\n\n" - "@param device The device type triggering the input, such as keyboard, mouse, etc\n" - "@param action The actual event occuring, such as a key or button\n" - "@param state True if the action is being pressed, false if it is being release\n\n" -); + ( device, action, state), + "@brief Callback that occurs when an input is triggered on this control\n\n" + "@param device The device type triggering the input, such as keyboard, mouse, etc\n" + "@param action The actual event occuring, such as a key or button\n" + "@param state True if the action is being pressed, false if it is being release\n\n"); + +IMPLEMENT_CALLBACK(GuiInputCtrl, onAxisEvent, void, (const char* device, const char* action, F32 axisValue), + (device, action, axisValue), + "@brief Callback that occurs when an axis event is triggered on this control\n\n" + "@param device The device type triggering the input, such as mouse, joystick, gamepad, etc\n" + "@param action The ActionMap code for the axis\n" + "@param axisValue The current value of the axis\n\n"); //------------------------------------------------------------------------------ bool GuiInputCtrl::onInputEvent( const InputEventInfo &event ) { - // TODO - add POV support... + char deviceString[32]; if ( event.action == SI_MAKE ) { if ( event.objType == SI_BUTTON || event.objType == SI_POV - || ( ( event.objType == SI_KEY ) && !isModifierKey( event.objInst ) ) ) + || event.objType == SI_KEY ) { - char deviceString[32]; if ( !ActionMap::getDeviceName( event.deviceType, event.deviceInst, deviceString ) ) - return( false ); + return false; - const char* actionString = ActionMap::buildActionString( &event ); + if ((event.objType == SI_KEY) && isModifierKey(event.objInst)) + { + if (!mSendModifierEvents) + return false; - //Con::executef( this, "onInputEvent", deviceString, actionString, "1" ); - onInputEvent_callback(deviceString, actionString, 1); + char keyString[32]; + if (!ActionMap::getKeyString(event.objInst, keyString)) + return false; - return( true ); + onInputEvent_callback(deviceString, keyString, 1); + } + else + { + const char* actionString = ActionMap::buildActionString(&event); + onInputEvent_callback(deviceString, actionString, 1); + } + return true; } } else if ( event.action == SI_BREAK ) @@ -152,14 +186,36 @@ bool GuiInputCtrl::onInputEvent( const InputEventInfo &event ) { char keyString[32]; if ( !ActionMap::getKeyString( event.objInst, keyString ) ) - return( false ); + return false; - //Con::executef( this, "onInputEvent", "keyboard", keyString, "0" ); - onInputEvent_callback("keyboard", keyString, 0); + onInputEvent_callback("keyboard", keyString, 0); + return true; + } + else if (mSendBreakEvents) + { + if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString)) + return false; - return( true ); + const char* actionString = ActionMap::buildActionString(&event); + + onInputEvent_callback(deviceString, actionString, 0); + return true; } } + else if (mSendAxisEvents && ((event.objType == SI_AXIS) || (event.objType == SI_INT) || (event.objType == SI_FLOAT))) + { + F32 fValue = event.fValue; + if (event.objType == SI_INT) + fValue = (F32)event.iValue; - return( false ); + if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString)) + return false; + + const char* actionString = ActionMap::buildActionString(&event); + + onAxisEvent_callback(deviceString, actionString, fValue); + return (event.deviceType != MouseDeviceType); // Don't consume mouse move events + } + + return false; } diff --git a/Engine/source/gui/utility/guiInputCtrl.h b/Engine/source/gui/utility/guiInputCtrl.h index e5769740c..be60371f3 100644 --- a/Engine/source/gui/utility/guiInputCtrl.h +++ b/Engine/source/gui/utility/guiInputCtrl.h @@ -32,23 +32,31 @@ /// to script. This is useful for implementing custom keyboard handling code. class GuiInputCtrl : public GuiMouseEventCtrl { - public: +protected: + bool mSendAxisEvents; + bool mSendBreakEvents; + bool mSendModifierEvents; - typedef GuiMouseEventCtrl Parent; - - // GuiControl. - virtual bool onWake(); - virtual void onSleep(); +public: - virtual bool onInputEvent( const InputEventInfo &event ); - - static void initPersistFields(); + typedef GuiMouseEventCtrl Parent; - DECLARE_CONOBJECT(GuiInputCtrl); - DECLARE_CATEGORY( "Gui Other Script" ); - DECLARE_DESCRIPTION( "A control that locks the mouse and reports all keyboard input events to script." ); + GuiInputCtrl(); - DECLARE_CALLBACK( void, onInputEvent, ( const char* device, const char* action, bool state )); + // GuiControl. + virtual bool onWake(); + virtual void onSleep(); + + virtual bool onInputEvent( const InputEventInfo &event ); + + static void initPersistFields(); + + DECLARE_CONOBJECT(GuiInputCtrl); + DECLARE_CATEGORY( "Gui Other Script" ); + DECLARE_DESCRIPTION( "A control that locks the mouse and reports all input events to script." ); + + DECLARE_CALLBACK( void, onInputEvent, ( const char* device, const char* action, bool state )); + DECLARE_CALLBACK(void, onAxisEvent, (const char* device, const char* action, F32 axisValue)); }; #endif // _GUI_INPUTCTRL_H diff --git a/Engine/source/gui/worldEditor/editTSCtrl.cpp b/Engine/source/gui/worldEditor/editTSCtrl.cpp index 4b5104cc9..032e29a1f 100644 --- a/Engine/source/gui/worldEditor/editTSCtrl.cpp +++ b/Engine/source/gui/worldEditor/editTSCtrl.cpp @@ -38,6 +38,7 @@ #include "scene/sceneRenderState.h" #include "renderInstance/renderBinManager.h" +#include "T3D/Scene.h" IMPLEMENT_CONOBJECT(EditTSCtrl); ConsoleDocClass( EditTSCtrl, @@ -795,15 +796,15 @@ void EditTSCtrl::_renderScene( ObjectRenderInst*, SceneRenderState *state, BaseM GFXTransformSaver saver; // render through console callbacks - SimSet * missionGroup = static_cast(Sim::findObject("MissionGroup")); - if(missionGroup) + Scene* scene = Scene::getRootScene(); + if(scene) { mConsoleRendering = true; // [ rene, 27-Jan-10 ] This calls onEditorRender on the server objects instead // of on the client objects which seems a bit questionable to me. - for(SimSetIterator itr(missionGroup); *itr; ++itr) + for(SimSetIterator itr(scene); *itr; ++itr) { SceneObject* object = dynamic_cast< SceneObject* >( *itr ); if( object && object->isRenderEnabled() && !object->isHidden() ) diff --git a/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp b/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp index ecae9f76d..bcb53df80 100644 --- a/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp +++ b/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp @@ -51,6 +51,8 @@ #include "T3D/portal.h" #include "math/mPolyhedron.impl.h" +#include "T3D/Scene.h" + IMPLEMENT_CONOBJECT( GuiConvexEditorCtrl ); ConsoleDocClass( GuiConvexEditorCtrl, @@ -121,12 +123,12 @@ bool GuiConvexEditorCtrl::onWake() if ( !Parent::onWake() ) return false; - SimGroup *missionGroup; - if ( !Sim::findObject( "MissionGroup", missionGroup ) ) + Scene* scene = Scene::getRootScene(); + if ( !scene ) return true; - SimGroup::iterator itr = missionGroup->begin(); - for ( ; itr != missionGroup->end(); itr++ ) + SimGroup::iterator itr = scene->begin(); + for ( ; itr != scene->end(); itr++ ) { if ( dStrcmp( (*itr)->getClassName(), "ConvexShape" ) == 0 ) { @@ -166,8 +168,8 @@ void GuiConvexEditorCtrl::setVisible( bool val ) mSavedGizmoFlags = -1; } - SimGroup* misGroup; - if (Sim::findObject("MissionGroup", misGroup)) + Scene* scene = Scene::getRootScene(); + if (scene != nullptr) { //Make our proxy objects "real" again for (U32 i = 0; i < mProxyObjects.size(); ++i) @@ -178,13 +180,13 @@ void GuiConvexEditorCtrl::setVisible( bool val ) AbstractClassRep* classRep = AbstractClassRep::findClassRep(mProxyObjects[i].targetObjectClass); if (!classRep) { - Con::errorf("WorldEditor::createPolyhedralObject - No such class: %s", mProxyObjects[i].targetObjectClass); + Con::errorf("WorldEditor::createPolyhedralObject - No such class: %s", mProxyObjects[i].targetObjectClass.c_str()); continue; } SceneObject* polyObj = createPolyhedralObject(mProxyObjects[i].targetObjectClass.c_str(), mProxyObjects[i].shapeProxy); - misGroup->addObject(polyObj); + scene->addObject(polyObj); //Now, remove the convex proxy mProxyObjects[i].shapeProxy->deleteObject(); @@ -222,19 +224,19 @@ void GuiConvexEditorCtrl::setVisible( bool val ) updateGizmoPos(); mSavedGizmoFlags = mGizmoProfile->flags; - SimGroup* misGroup; - if (Sim::findObject("MissionGroup", misGroup)) + Scene* scene = Scene::getRootScene(); + if (scene != nullptr) { - for (U32 c = 0; c < misGroup->size(); ++c) + for (U32 c = 0; c < scene->size(); ++c) { - bool isTrigger = (misGroup->at(c)->getClassName() == StringTable->insert("Trigger")); - bool isZone = (misGroup->at(c)->getClassName() == StringTable->insert("Zone")); - bool isPortal = (misGroup->at(c)->getClassName() == StringTable->insert("Portal")); - bool isOccluder = (misGroup->at(c)->getClassName() == StringTable->insert("OcclusionVolume")); + bool isTrigger = (scene->at(c)->getClassName() == StringTable->insert("Trigger")); + bool isZone = (scene->at(c)->getClassName() == StringTable->insert("Zone")); + bool isPortal = (scene->at(c)->getClassName() == StringTable->insert("Portal")); + bool isOccluder = (scene->at(c)->getClassName() == StringTable->insert("OcclusionVolume")); if (isZone || isPortal || isOccluder) { - SceneObject* sceneObj = static_cast(misGroup->at(c)); + SceneObject* sceneObj = static_cast(scene->at(c)); if (!sceneObj) { Con::errorf("WorldEditor::createConvexShapeFrom - Invalid object"); @@ -1350,9 +1352,9 @@ void GuiConvexEditorCtrl::setupShape( ConvexShape *shape ) shape->registerObject(); updateShape( shape ); - SimGroup *group; - if ( Sim::findObject( "missionGroup", group ) ) - group->addObject( shape ); + Scene* scene = Scene::getRootScene(); + if ( scene ) + scene->addObject( shape ); } void GuiConvexEditorCtrl::updateShape( ConvexShape *shape, S32 offsetFace ) @@ -1929,10 +1931,8 @@ ConvexEditorTool::EventResult ConvexEditorCreateTool::on3DMouseUp( const Gui3DMo } else if ( mStage == 0 ) { - SimGroup *mg; - Sim::findObject( "MissionGroup", mg ); - - mg->addObject( mNewConvex ); + SimGroup *scene = Scene::getRootScene(); + scene->addObject( mNewConvex ); mStage = -1; @@ -2128,9 +2128,9 @@ ConvexShape* ConvexEditorCreateTool::extrudeShapeFromFace( ConvexShape *inShape, newShape->registerObject(); mEditor->updateShape( newShape ); - SimGroup *group; - if ( Sim::findObject( "missionGroup", group ) ) - group->addObject( newShape ); + Scene* scene = Scene::getRootScene(); + if ( scene ) + scene->addObject( newShape ); return newShape; } @@ -2513,4 +2513,4 @@ if (convex) DefineEngineMethod( GuiConvexEditorCtrl, splitSelectedFace, void, (), , "" ) { object->splitSelectedFace(); -} \ No newline at end of file +} diff --git a/Engine/source/gui/worldEditor/terrainEditor.cpp b/Engine/source/gui/worldEditor/terrainEditor.cpp index f1bf5fd58..41ba690d2 100644 --- a/Engine/source/gui/worldEditor/terrainEditor.cpp +++ b/Engine/source/gui/worldEditor/terrainEditor.cpp @@ -36,7 +36,7 @@ #include "gui/worldEditor/terrainActions.h" #include "terrain/terrMaterial.h" - +#include "T3D/Scene.h" IMPLEMENT_CONOBJECT(TerrainEditor); @@ -2405,10 +2405,10 @@ void TerrainEditor::reorderMaterial( S32 index, S32 orderPos ) DefineEngineMethod( TerrainEditor, attachTerrain, void, (const char * terrain), (""), "(TerrainBlock terrain)") { - SimSet * missionGroup = dynamic_cast(Sim::findObject("MissionGroup")); - if (!missionGroup) + Scene* scene = Scene::getRootScene(); + if (!scene) { - Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: no mission group found"); + Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: no scene found"); return; } @@ -2417,7 +2417,7 @@ DefineEngineMethod( TerrainEditor, attachTerrain, void, (const char * terrain), // attach to first found terrainBlock if (dStrcmp (terrain,"")==0) { - for(SimSetIterator itr(missionGroup); *itr; ++itr) + for(SimSetIterator itr(scene); *itr; ++itr) { TerrainBlock* terrBlock = dynamic_cast(*itr); diff --git a/Engine/source/gui/worldEditor/worldEditor.cpp b/Engine/source/gui/worldEditor/worldEditor.cpp index 27c9dc473..2581cee72 100644 --- a/Engine/source/gui/worldEditor/worldEditor.cpp +++ b/Engine/source/gui/worldEditor/worldEditor.cpp @@ -51,6 +51,8 @@ #include "tools/editorTool.h" +#include "T3D/Scene.h" + IMPLEMENT_CONOBJECT( WorldEditor ); ConsoleDocClass( WorldEditor, @@ -455,19 +457,20 @@ bool WorldEditor::pasteSelection( bool dropSel ) return false; } - SimGroup *missionGroup = NULL; + SimGroup *targetGroup = NULL; if( isMethod( "getNewObjectGroup" ) ) { const char* targetGroupName = Con::executef( this, "getNewObjectGroup" ); - if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, missionGroup ) ) + if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, targetGroup) ) Con::errorf( "WorldEditor::pasteSelection() - no SimGroup called '%s'", targetGroupName ); } - if( !missionGroup ) + if( !targetGroup) { - if( !Sim::findObject( "MissionGroup", missionGroup ) ) + targetGroup = Scene::getRootScene(); + if( !targetGroup) { - Con::errorf( "WorldEditor::pasteSelection() - MissionGroup not found" ); + Con::errorf( "WorldEditor::pasteSelection() - Scene not found" ); return false; } } @@ -481,8 +484,8 @@ bool WorldEditor::pasteSelection( bool dropSel ) if ( !obj ) continue; - if ( missionGroup ) - missionGroup->addObject( obj ); + if (targetGroup) + targetGroup->addObject( obj ); action->addObject( obj ); @@ -594,7 +597,7 @@ void WorldEditor::hideObject(SceneObject* serverObj, bool hide) void WorldEditor::hideSelection(bool hide) { - SimGroup* pGroup = dynamic_cast(Sim::findObject("MissionGroup")); + Scene* scene = Scene::getRootScene(); // set server/client objects hide field for(U32 i = 0; i < mSelected->size(); i++) @@ -605,7 +608,7 @@ void WorldEditor::hideSelection(bool hide) // Prevent non-mission group objects (i.e. Player) from being hidden. // Otherwise it is difficult to show them again. - if(!serverObj->isChildOfGroup(pGroup)) + if(!serverObj->isChildOfGroup(scene)) continue; hideObject(serverObj, hide); @@ -2437,7 +2440,7 @@ void WorldEditor::renderScene( const RectI &updateRect ) } // Render the paths - renderPaths(Sim::findObject("MissionGroup")); + renderPaths(Scene::getRootScene()); // walk selected Selection* selection = getActiveSelectionSet(); @@ -3653,10 +3656,10 @@ void WorldEditor::makeSelectionPrefab( const char *filename ) return; } - SimGroup *missionGroup; - if ( !Sim::findObject( "MissionGroup", missionGroup ) ) + Scene* scene = Scene::getRootScene(); + if ( !scene) { - Con::errorf( "WorldEditor::makeSelectionPrefab - Could not find MissionGroup." ); + Con::errorf( "WorldEditor::makeSelectionPrefab - Could not find root Scene." ); return; } @@ -3746,7 +3749,7 @@ void WorldEditor::makeSelectionPrefab( const char *filename ) fabMat.inverse(); fab->setTransform( fabMat ); fab->registerObject(); - missionGroup->addObject( fab ); + scene->addObject( fab ); // Select it, mark level as dirty. clearSelection(); @@ -3812,10 +3815,10 @@ void WorldEditor::makeSelectionAMesh(const char *filename) return; } - SimGroup *missionGroup; - if (!Sim::findObject("MissionGroup", missionGroup)) + Scene* scene = Scene::getRootScene(); + if (!scene) { - Con::errorf("WorldEditor::makeSelectionAMesh - Could not find MissionGroup."); + Con::errorf("WorldEditor::makeSelectionAMesh - Could not find root Scene."); return; } @@ -3877,8 +3880,6 @@ void WorldEditor::makeSelectionAMesh(const char *filename) fabMat.inverse(); MatrixF objMat; - SimObject *obj = NULL; - SceneObject *sObj = NULL; Vector< SceneObject* > objectList; @@ -3967,7 +3968,7 @@ void WorldEditor::makeSelectionAMesh(const char *filename) fabMat.inverse(); ts->setTransform(fabMat); ts->registerObject(); - missionGroup->addObject(ts); + scene->addObject(ts); // Select it, mark level as dirty. clearSelection(); diff --git a/Engine/source/lighting/lightManager.cpp b/Engine/source/lighting/lightManager.cpp index 4d4eb2f9d..82faeaf68 100644 --- a/Engine/source/lighting/lightManager.cpp +++ b/Engine/source/lighting/lightManager.cpp @@ -226,8 +226,8 @@ void LightManager::registerGlobalLights( const Frustum *frustum, bool staticLigh { // Cull the lights using the frustum. getSceneManager()->getContainer()->findObjectList(*frustum, lightMask, &activeLights); - - if (enableZoneLightCulling) + /* + for (U32 i = 0; i < activeLights.size(); ++i) { for (U32 i = 0; i < activeLights.size(); ++i) { @@ -238,7 +238,7 @@ void LightManager::registerGlobalLights( const Frustum *frustum, bool staticLigh } } } - + */ // Store the culling position for sun placement // later... see setSpecialLight. mCullPos = frustum->getPosition(); diff --git a/Engine/source/math/mConstants.h b/Engine/source/math/mConstants.h index 42b071d1e..6218e4040 100644 --- a/Engine/source/math/mConstants.h +++ b/Engine/source/math/mConstants.h @@ -44,7 +44,7 @@ #define M_CONST_E_F 2.7182818284590452353602874f -#define POINT_EPSILON (1e-4) ///< Epsilon for point types. +#define POINT_EPSILON (0.0001f) ///< Epsilon for point types. /// Result of an overlap test. diff --git a/Engine/source/math/util/frustum.cpp b/Engine/source/math/util/frustum.cpp index bfb42a6bf..2ac1824b7 100644 --- a/Engine/source/math/util/frustum.cpp +++ b/Engine/source/math/util/frustum.cpp @@ -216,7 +216,7 @@ void Frustum::setNearFarDist( F32 nearDist, F32 farDist ) // Recalculate the frustum. MatrixF xfm( mTransform ); - const F32 CENTER_EPSILON = 0.001; + const F32 CENTER_EPSILON = 0.001f; F32 centerX = mNearLeft + (mNearRight - mNearLeft) * 0.5; F32 centerY = mNearBottom + (mNearTop - mNearBottom) * 0.5; if ((centerX > CENTER_EPSILON || centerX < -CENTER_EPSILON) || (centerY > CENTER_EPSILON || centerY < -CENTER_EPSILON) ) diff --git a/Engine/source/module/moduleManager.cpp b/Engine/source/module/moduleManager.cpp index c5d3b42f6..e122177e8 100644 --- a/Engine/source/module/moduleManager.cpp +++ b/Engine/source/module/moduleManager.cpp @@ -69,7 +69,7 @@ S32 QSORT_CALLBACK moduleDefinitionVersionIdSort( const void* a, const void* b ) ModuleManager::ModuleManager() : mEnforceDependencies(true), - mEchoInfo(true), + mEchoInfo(false), mDatabaseLocks( 0 ), mIgnoreLoadedGroups(false) { diff --git a/Engine/source/navigation/navMesh.cpp b/Engine/source/navigation/navMesh.cpp index 20b1bfa2c..c6189c366 100644 --- a/Engine/source/navigation/navMesh.cpp +++ b/Engine/source/navigation/navMesh.cpp @@ -107,8 +107,7 @@ DefineEngineFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, false SceneObject *obj; if(!Sim::findObject(objid, obj)) return; - if(remove) - obj->disableCollision(); + obj->mPathfindingIgnore = remove; SimSet *set = NavMesh::getServerSet(); for(U32 i = 0; i < set->size(); i++) { @@ -119,8 +118,6 @@ DefineEngineFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, false m->buildTiles(obj->getWorldBox()); } } - if(remove) - obj->enableCollision(); } DefineEngineFunction(NavMeshUpdateAroundObject, void, (S32 objid, bool remove), (0, false), @@ -129,8 +126,7 @@ DefineEngineFunction(NavMeshUpdateAroundObject, void, (S32 objid, bool remove), SceneObject *obj; if (!Sim::findObject(objid, obj)) return; - if (remove) - obj->disableCollision(); + obj->mPathfindingIgnore = remove; SimSet *set = NavMesh::getServerSet(); for (U32 i = 0; i < set->size(); i++) { @@ -141,8 +137,6 @@ DefineEngineFunction(NavMeshUpdateAroundObject, void, (S32 objid, bool remove), m->buildTiles(obj->getWorldBox()); } } - if (remove) - obj->enableCollision(); } diff --git a/Engine/source/platform/async/asyncPacketStream.h b/Engine/source/platform/async/asyncPacketStream.h index 25f63469e..44b4b661f 100644 --- a/Engine/source/platform/async/asyncPacketStream.h +++ b/Engine/source/platform/async/asyncPacketStream.h @@ -281,9 +281,22 @@ void AsyncPacketBufferedInputStream< Stream, Packet >::_requestNext() IResettable* resettable = dynamic_cast< IResettable* >( s ); if( resettable ) { + IPositionable< U32 >* positionable = dynamic_cast< IPositionable< U32 >* >( &Deref( stream ) ); + U32 pos; + if(positionable) + pos = positionable->getPosition(); + resettable->reset(); isEOS = false; this->mNumRemainingSourceElements = mNumTotalSourceElements; + + if( positionable ) + { + positionable->setPosition(pos); + U32 dur = stream->getDuration(); + if(dur != 0) //avoiding division by zero? not needed, probably + this->mNumRemainingSourceElements -= (U32)(mNumTotalSourceElements*(F32)pos/dur); + } } } else if( isEOS ) diff --git a/Engine/source/platform/input/event.h b/Engine/source/platform/input/event.h index 1c6d1f1dc..a63d0d62c 100644 --- a/Engine/source/platform/input/event.h +++ b/Engine/source/platform/input/event.h @@ -249,6 +249,14 @@ enum InputObjectInstancesEnum SI_DPOV2 = 0x215, SI_LPOV2 = 0x216, SI_RPOV2 = 0x217, + SI_POVMASK = 0x218, + SI_POVMASK2 = 0x219, + + /// Trackball event codes. + SI_XBALL = 0x21A, + SI_YBALL = 0x21B, + SI_XBALL2 = 0x21C, + SI_YBALL2 = 0x21D, XI_CONNECT = 0x300, XI_THUMBLX = 0x301, @@ -262,7 +270,7 @@ enum InputObjectInstancesEnum XI_DPAD_DOWN = 0x308, XI_DPAD_LEFT = 0x309, XI_DPAD_RIGHT = 0x310,*/ - + XI_START = 0x311, XI_BACK = 0x312, XI_LEFT_THUMB = 0x313, @@ -273,7 +281,8 @@ enum InputObjectInstancesEnum XI_A = 0x317, XI_B = 0x318, XI_X = 0x319, - XI_Y = 0x320, + XI_Y = 0x31A, + XI_GUIDE = 0x31B, INPUT_DEVICE_PLUGIN_CODES_START = 0x400, }; diff --git a/Engine/source/platform/nativeDialogs/fileDialog.cpp b/Engine/source/platform/nativeDialogs/fileDialog.cpp index 21bdfefa3..067458e9f 100644 --- a/Engine/source/platform/nativeDialogs/fileDialog.cpp +++ b/Engine/source/platform/nativeDialogs/fileDialog.cpp @@ -285,9 +285,9 @@ bool FileDialog::Execute() { // Single file selection, do it the easy way if(mForceRelativePath) - mData.mFile = Platform::makeRelativePathName(resultPath.c_str(), NULL); + mData.mFile = Con::getReturnBuffer(Platform::makeRelativePathName(resultPath.c_str(), NULL)); else - mData.mFile = resultPath.c_str(); + mData.mFile = Con::getReturnBuffer(resultPath.c_str()); } else if (mData.mStyle & FileDialogData::FDS_MULTIPLEFILES) { diff --git a/Engine/source/platform/platformNet.cpp b/Engine/source/platform/platformNet.cpp index 2a22499c4..1e5cb0a5a 100644 --- a/Engine/source/platform/platformNet.cpp +++ b/Engine/source/platform/platformNet.cpp @@ -230,7 +230,6 @@ namespace PlatformNetState // which are required for LAN queries (PC->Xbox connectivity). The wire protocol still // uses the VDP packet structure, though. S32 protocol = IPPROTO_UDP; - bool useVDP = false; #ifdef TORQUE_DISABLE_PC_CONNECTIVITY // Xbox uses a VDP (voice/data protocol) socket for networking protocol = IPPROTO_VDP; @@ -1956,7 +1955,6 @@ void Net::enableMulticast() if (error == NoError) { - NetAddress listenAddress; char listenAddressStr[256]; Net::addressToString(&multicastAddress, listenAddressStr); Con::printf("Multicast initialized on %s", listenAddressStr); diff --git a/Engine/source/platformMac/macFileIO.mm b/Engine/source/platformMac/macFileIO.mm index e4d182dc1..b2549e0f7 100644 --- a/Engine/source/platformMac/macFileIO.mm +++ b/Engine/source/platformMac/macFileIO.mm @@ -39,7 +39,7 @@ #import "platform/profiler.h" #import "cinterface/c_controlInterface.h" #import "core/volume.h" - +#include "console/engineAPI.h" //TODO: file io still needs some work... #define MAX_MAC_PATH_LONG 2048 @@ -992,25 +992,22 @@ bool Platform::fileTimeToString(FileTime * time, char * string, U32 strLen) { re //----------------------------------------------------------------------------- #if defined(TORQUE_DEBUG) -ConsoleFunction(testHasSubdir,void,2,2,"tests platform::hasSubDirectory") { - Con::printf("testing %s",(const char*)argv[1]); +DefineEngineFunction(testHasSubdir,void, (String _dir),,"tests platform::hasSubDirectory") { Platform::addExcludedDirectory(".svn"); - if(Platform::hasSubDirectory(argv[1])) + if(Platform::hasSubDirectory(_dir.c_str())) Con::printf(" has subdir"); else Con::printf(" does not have subdir"); } -ConsoleFunction(testDumpDirectories,void,4,4,"testDumpDirectories('path', int depth, bool noBasePath)") { +DefineEngineFunction(testDumpDirectories,void,(String _path, S32 _depth, bool _noBasePath),,"testDumpDirectories('path', int depth, bool noBasePath)") { Vector paths; - const S32 depth = dAtoi(argv[2]); - const bool noBasePath = dAtob(argv[3]); Platform::addExcludedDirectory(".svn"); - Platform::dumpDirectories(argv[1], paths, depth, noBasePath); + Platform::dumpDirectories(_path.c_str(), paths, _depth, _noBasePath); - Con::printf("Dumping directories starting from %s with depth %i", (const char*)argv[1],depth); + Con::printf("Dumping directories starting from %s with depth %i", _path.c_str(), _depth); for(Vector::iterator itr = paths.begin(); itr != paths.end(); itr++) { Con::printf(*itr); @@ -1018,14 +1015,13 @@ ConsoleFunction(testDumpDirectories,void,4,4,"testDumpDirectories('path', int de } -ConsoleFunction(testDumpPaths, void, 3, 3, "testDumpPaths('path', int depth)") +DefineEngineFunction(testDumpPaths, void, (String _path, S32 _depth),, "testDumpPaths('path', int depth)") { Vector files; - S32 depth = dAtoi(argv[2]); Platform::addExcludedDirectory(".svn"); - Platform::dumpPath(argv[1], files, depth); + Platform::dumpPath(_path.c_str(), files, _depth); for(Vector::iterator itr = files.begin(); itr != files.end(); itr++) { Con::printf("%s/%s",itr->pFullPath, itr->pFileName); @@ -1033,15 +1029,15 @@ ConsoleFunction(testDumpPaths, void, 3, 3, "testDumpPaths('path', int depth)") } //----------------------------------------------------------------------------- -ConsoleFunction(testFileTouch, bool , 2,2, "testFileTouch('path')") +DefineEngineFunction(testFileTouch, bool , (String _path),, "testFileTouch('path')") { - return dFileTouch(argv[1]); + return dFileTouch(_path.c_str()); } -ConsoleFunction(testGetFileTimes, bool, 2,2, "testGetFileTimes('path')") +DefineEngineFunction(testGetFileTimes, bool, (String _path),, "testGetFileTimes('path')") { FileTime create, modify; - bool ok = Platform::getFileTimes(argv[1], &create, &modify); + bool ok = Platform::getFileTimes(_path.c_str(), &create, &modify); Con::printf("%s Platform::getFileTimes %i, %i", ok ? "+OK" : "-FAIL", create, modify); return ok; } diff --git a/Engine/source/platformMac/macMath.mm b/Engine/source/platformMac/macMath.mm index c27375ee4..a59bf6609 100644 --- a/Engine/source/platformMac/macMath.mm +++ b/Engine/source/platformMac/macMath.mm @@ -24,6 +24,7 @@ #import "console/console.h" #import "math/mMath.h" #import "core/strings/stringFunctions.h" +#include "console/engineAPI.h" extern void mInstallLibrary_C(); extern void mInstallLibrary_Vec(); @@ -51,7 +52,13 @@ void Platform::setMathControlStateKnown() } //-------------------------------------- -ConsoleFunction( MathInit, void, 1, 10, "(DETECT|C|SSE)") +DefineEngineStringlyVariadicFunction( mathInit, void, 1, 10, "( ... )" + "@brief Install the math library with specified extensions.\n\n" + "Possible parameters are:\n\n" + " - 'DETECT' Autodetect math lib settings.\n\n" + " - 'C' Enable the C math routines. C routines are always enabled.\n\n" + " - 'SSE' Enable SSE math routines.\n\n" + "@ingroup Math") { U32 properties = CPU_PROP_C; // C entensions are always used diff --git a/Engine/source/platformSDL/sdlInput.cpp b/Engine/source/platformSDL/sdlInput.cpp index eb9e3dd8e..a60a0e7b5 100644 --- a/Engine/source/platformSDL/sdlInput.cpp +++ b/Engine/source/platformSDL/sdlInput.cpp @@ -27,15 +27,11 @@ #include "sdlInput.h" #include "platform/platformInput.h" +#include "sdlInputManager.h" #include "SDL.h" -#ifdef LOG_INPUT -#include -#include -#endif - // Static class variables: -InputManager* Input::smManager; +InputManager* Input::smManager = NULL; bool Input::smActive; U8 Input::smModifierKeys; bool Input::smLastKeyboardActivated; @@ -43,10 +39,6 @@ bool Input::smLastMouseActivated; bool Input::smLastJoystickActivated; InputEvent Input::smInputEvent; -#ifdef LOG_INPUT -static HANDLE gInputLog; -#endif - static void fillAsciiTable() {} //------------------------------------------------------------------------------ @@ -91,24 +83,17 @@ void Input::init() fillAsciiTable(); Con::printf( "" ); + smManager = new SDLInputManager; + if (smManager) + { + SDLInputManager::init(); + } + // Set ourselves to participate in per-frame processing. Process::notify(Input::process, PROCESS_INPUT_ORDER); } -//------------------------------------------------------------------------------ -DefineEngineFunction(isJoystickDetected, bool, (),, "") -{ - return(SDL_NumJoysticks() > 0); -} - -//------------------------------------------------------------------------------ -DefineEngineFunction(getJoystickAxes, const char*, (const char* instance), , "") -{ - // TODO SDL - return(""); -} - //------------------------------------------------------------------------------ U16 Input::getKeyCode( U16 asciiCode ) { @@ -118,7 +103,7 @@ U16 Input::getKeyCode( U16 asciiCode ) char c[2]; c[0]= asciiCode; c[1] = NULL; - return KeyMapSDL::getTorqueScanCodeFromSDL( SDL_GetScancodeFromName( c ) ); + return KeyMapSDL::getTorqueScanCodeFromSDL( SDL_GetScancodeFromKey( SDL_GetKeyFromName(c) ) ); } //------------------------------------------------------------------------------ @@ -159,6 +144,13 @@ void Input::destroy() SDL_QuitSubSystem( SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER ); + if (smManager) + { + if (smManager->isEnabled()) + smManager->disable(); + delete smManager; + smManager = NULL; + } } //------------------------------------------------------------------------------ @@ -186,8 +178,8 @@ void Input::activate() //ImmReleaseContext( getWin32WindowHandle(), winState.imeHandle ); #endif - if ( !Con::getBoolVariable( "$enableDirectInput" ) ) - return; + if (smManager && !smManager->isEnabled()) + smManager->enable(); if ( smManager && smManager->isEnabled() && !smActive ) { @@ -199,7 +191,10 @@ void Input::activate() //------------------------------------------------------------------------------ void Input::deactivate() { - if ( smManager && smManager->isEnabled() && smActive ) + if (smManager && smManager->isEnabled()) + smManager->disable(); + + if (smActive) { smActive = false; Con::printf( "Input deactivated." ); @@ -435,4 +430,4 @@ U32 KeyMapSDL::getSDLScanCodeFromTorque(U32 torque) buildScanCodeArray(); return T3D_SDL[torque]; -} \ No newline at end of file +} diff --git a/Engine/source/platformSDL/sdlInputManager.cpp b/Engine/source/platformSDL/sdlInputManager.cpp new file mode 100644 index 000000000..5c5d5ec72 --- /dev/null +++ b/Engine/source/platformSDL/sdlInputManager.cpp @@ -0,0 +1,1381 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +#include "console/console.h" +#include "console/consoleTypes.h" +#include "console/engineAPI.h" +#include "sim/actionMap.h" + +#include "sdlInputManager.h" + +typedef SDL_JoystickType SDLJoystickType; +DefineEnumType(SDLJoystickType); +ImplementEnumType(SDLJoystickType, + "The type of device connected.\n\n" + "@ingroup Input") +{ SDL_JOYSTICK_TYPE_UNKNOWN, "Unknown"}, +{ SDL_JOYSTICK_TYPE_GAMECONTROLLER, "Game Controller" }, +{ SDL_JOYSTICK_TYPE_WHEEL, "Wheel" }, +{ SDL_JOYSTICK_TYPE_ARCADE_STICK, "Arcade Stick" }, +{ SDL_JOYSTICK_TYPE_FLIGHT_STICK, "Flight Stick" }, +{ SDL_JOYSTICK_TYPE_DANCE_PAD, "Dance Pad" }, +{ SDL_JOYSTICK_TYPE_GUITAR, "Guitar" }, +{ SDL_JOYSTICK_TYPE_DRUM_KIT, "Drum Kit" }, +{ SDL_JOYSTICK_TYPE_ARCADE_PAD, "Arcade Pad" }, +{ SDL_JOYSTICK_TYPE_THROTTLE, "Throttle" }, +EndImplementEnumType; + +typedef SDL_JoystickPowerLevel SDLPowerEnum; +DefineEnumType(SDLPowerEnum); +ImplementEnumType(SDLPowerEnum, + "An enumeration of battery levels of a joystick.\n\n" + "@ingroup Input") +{ SDL_JOYSTICK_POWER_UNKNOWN, "Unknown" }, +{ SDL_JOYSTICK_POWER_EMPTY, "Empty" }, +{ SDL_JOYSTICK_POWER_LOW, "Low" }, +{ SDL_JOYSTICK_POWER_MEDIUM, "Medium" }, +{ SDL_JOYSTICK_POWER_FULL, "Full" }, +{ SDL_JOYSTICK_POWER_WIRED, "Wired" }, +{ SDL_JOYSTICK_POWER_MAX, "Max" }, +EndImplementEnumType; + +IMPLEMENT_STATIC_CLASS(SDLInputManager, , + "@brief Static class exposing the SDL_Joystick and SDL_GameController APIs to Torque Script.\n" + "SDLInputManager provides access to the functions of these APIs through static class " + "functions.These functions are not required to bind or process events.By setting " + "pref::Input::JoystickEnabled or pref::Input::sdlControllerEnabled to true, all connected " + "devices will automatically be opened.All of the joystick and controller events defined " + "in event.h can then be bound. For complete API documentation see the Joystick and Game " + "Controller section of https ://wiki.libsdl.org/APIByCategory#Input_Events.\n\n" + + "@tsexample\n" + "// Get the name and device type for all connected devices\n" + "%sdlDevices = SDLInputManager::numJoysticks();\n" + "for (%i = 0; %i < %sdlDevices; %i++)\n" + "{\n" + " %deviceName = SDLInputManager::JoystickNameForIndex(%i);\n" + " %deviceType = SDLInputManager::GetDeviceType(%i);\n" + "}\n" + "\n" + "// List all installed controller mappings\n" + "%numMappings = SDLInputManager::GameControllerNumMappings();\n" + "for (%i = 0; %i < %numMappings; %i++)\n" + " echo(SDLInputManager::GameControllerMappingForIndex(%i));\n" + "@endtsexample\n\n"); + +IMPLEMENT_GLOBAL_CALLBACK(onSDLDeviceConnected, void, (S32 sdlIndex, const char* deviceName, const char* deviceType), +(sdlIndex, deviceName, deviceType), +"Callback that occurs when an input device is connected to the system.\n\n" +"@param sdlIndex The index that will be used by sdl to refer to the device.\n" +"@param deviceName The name that the device reports. This will be the return " +"value of SDL_JoystickNameForIndex or SDL_GameControllerNameForIndex depending on the device type.\n" +"@param deviceType The type of device connected. See SDLInputManager::getDeviceType() " +"for possible string values.\n\n"); + +IMPLEMENT_GLOBAL_CALLBACK(onSDLDeviceDisconnected, void, (S32 sdlIndex), (sdlIndex), +"Callback that occurs when an input device is disconnected from the system.\n\n" +"@param sdlIndex The index of the device that was removed.\n"); + +//------------------------------------------------------------------------------ +// Static class variables: +bool SDLInputManager::smJoystickEnabled = true; +bool SDLInputManager::smJoystickSplitAxesLR = true; +bool SDLInputManager::smControllerEnabled = true; +bool SDLInputManager::smPOVButtonEvents = true; +bool SDLInputManager::smPOVMaskEvents = false; + +// Map SDL controller Axis to torque input event +// Commented text from map_StringForControllerAxis[] in SDL_gamecontroller.c +S32 SDLInputManager::map_EventForControllerAxis[] = { + SI_XAXIS, //"leftx", + SI_YAXIS, //"lefty", + SI_RXAXIS, //"rightx", + SI_RYAXIS, //"righty", + SI_ZAXIS, //"lefttrigger", + SI_RZAXIS, //"righttrigger", + -1 // NULL +}; + +// Map SDL controller button ID to torque input event +// Commented text from map_StringForControllerButton[] in SDL_gamecontroller.c +S32 SDLInputManager::map_EventForControllerButton[] = { + XI_A, //"a", + XI_B, //"b", + XI_X, //"x", + XI_Y, //"y", + XI_BACK, //"back", + XI_GUIDE, //"guide", + XI_START, //"start", + XI_LEFT_THUMB, //"leftstick", + XI_RIGHT_THUMB, //"rightstick", + XI_LEFT_SHOULDER, //"leftshoulder", + XI_RIGHT_SHOULDER, //"rightshoulder", + SI_UPOV, //"dpup", + SI_DPOV, //"dpdown", + SI_LPOV, //"dpleft", + SI_RPOV, //"dpright", + -1 // NULL +}; + +//------------------------------------------------------------------------------ +void SDLInputManager::joystickState::reset() +{ + sdlInstID = -1; + inputDevice = NULL; + numAxes = 0; + lastHatState[0] = 0; + lastHatState[1] = 0; +} + +//------------------------------------------------------------------------------ +SDLInputManager::SDLInputManager() +{ + mEnabled = true; + mJoystickActive = true; + + for (S32 i = 0; i < MaxJoysticks; ++i) + { + mJoysticks[i].reset(); + mJoysticks[i].torqueInstID = i; + } + + for (S32 i = 0; i < MaxControllers; ++i) + { + mControllers[i].sdlInstID = -1; + mControllers[i].torqueInstID = i; + mControllers[i].inputDevice = NULL; + } +} + +//------------------------------------------------------------------------------ +void SDLInputManager::init() +{ + Con::addVariable( "pref::Input::JoystickEnabled", TypeBool, &smJoystickEnabled, + "If true, Joystick devices will be automatically opened.\n\n" + "@ingroup Input"); + Con::addVariable("pref::Input::JoystickSplitAxesLR", TypeBool, &smJoystickSplitAxesLR, + "Split axis inputs on 4 axis joysticks. This has no effect on any other device.\n\n" + "4 Axis joysticks use IDs 0-3 which get mapped to xaxis, yaxis, zaxis and rxaxis. " + "When true, this will increment IDs 2 and 3 so the inputs map to xaxis, yaxis, rxaxis and ryaxis.\n" + "@ingroup Input"); + Con::addVariable("pref::Input::sdlControllerEnabled", TypeBool, &smControllerEnabled, + "If true, any Joystick device that SDL recognizes as a Game Controller will be automatically opened as a game controller.\n\n" + "@ingroup Input"); + Con::addVariable("pref::Input::JoystickPOVButtons", TypeBool, &smPOVButtonEvents, + "If true, the pov hat will be treated as 4 buttons and make/break events will be generated for " + "upov, dpov, lpov and rpov.\n" + "@ingroup Input"); + Con::addVariable("pref::Input::JoystickPOVMask", TypeBool, &smPOVMaskEvents, + "If true, the pov hat will be treated as a single input with a 4 bit mask value. The povmask " + "event will be generated with the current mask every time the mask value changes.\n" + "@ingroup Input"); + + // POV Hat mask bits + Con::setIntVariable("$SDLMask::HatUp", SDL_HAT_UP); + Con::setIntVariable("$SDLMask::HatRight", SDL_HAT_RIGHT); + Con::setIntVariable("$SDLMask::HatDown", SDL_HAT_DOWN); + Con::setIntVariable("$SDLMask::HatLeft", SDL_HAT_LEFT); +} + +//------------------------------------------------------------------------------ +bool SDLInputManager::enable() +{ + disable(); + + if (smControllerEnabled || smJoystickEnabled) + { + for (S32 i = 0; i < SDL_NumJoysticks(); ++i) + { + if (smControllerEnabled && SDL_IsGameController(i)) + openController(i, 0); + else if (smJoystickEnabled) + openJoystick(i, 0); + } + } + mEnabled = true; + return true; +} + +//------------------------------------------------------------------------------ +void SDLInputManager::disable() +{ + // Close any open devices + for (S32 i = 0; i < MaxControllers; ++i) + closeControllerByIndex(i); + for (S32 i = 0; i < MaxJoysticks; ++i) + closeJoystickByIndex(i); + + mEnabled = false; +} + +//------------------------------------------------------------------------------ +void SDLInputManager::process() +{ +} + +//------------------------------------------------------------------------------ +void SDLInputManager::processEvent(SDL_Event &evt) +{ + switch (evt.type) + { + case SDL_JOYAXISMOTION: + { + joystickState* torqueMapping; + if (mJoystickMap.isEmpty() || !mJoystickMap.find(evt.jaxis.which, torqueMapping)) + break; + // SDL axis value inputs are in (range: -32768 to 32767) + // Torque axis values are -1.0 to 1.0 + F32 value = ((F32)evt.jaxis.value) / (F32) (evt.jaxis.value > 0 ? SDL_JOYSTICK_AXIS_MAX : -SDL_JOYSTICK_AXIS_MIN); + S32 mapAxis = SI_XAXIS + evt.jaxis.axis; + if (evt.jaxis.axis > 1 && torqueMapping->numAxes == 4 && smJoystickSplitAxesLR) + mapAxis += 1; // On a 4 axis, we'll shift the second two so we use LX LY RX RY instead of LX LY LZ RX + buildInputEvent(JoystickDeviceType, torqueMapping->torqueInstID, SI_AXIS, mapAxis, SI_MOVE, value); + break; + } + + case SDL_JOYBALLMOTION: + { + joystickState* torqueMapping; + if (mJoystickMap.isEmpty() || !mJoystickMap.find(evt.jball.which, torqueMapping) || evt.jball.ball >= MaxBalls) + break; + if (evt.jball.xrel != 0) + buildInputEvent(JoystickDeviceType, torqueMapping->torqueInstID, SI_INT, evt.jball.ball ? SI_XBALL2 : SI_XBALL, SI_MOVE, (S32) evt.jball.xrel); + if (evt.jball.yrel != 0) + buildInputEvent(JoystickDeviceType, torqueMapping->torqueInstID, SI_INT, evt.jball.ball ? SI_YBALL2 : SI_YBALL, SI_MOVE, (S32) evt.jball.yrel); + break; + } + + case SDL_JOYHATMOTION: + { + joystickState* torqueMapping; + if (mJoystickMap.isEmpty() || !mJoystickMap.find(evt.jball.which, torqueMapping) || evt.jhat.hat >= MaxHats) + break; + if (torqueMapping->lastHatState[evt.jhat.hat] != evt.jhat.value) + { + buildHatEvents(JoystickDeviceType, torqueMapping->torqueInstID, torqueMapping->lastHatState[evt.jhat.hat], evt.jhat.value, evt.jhat.hat); + torqueMapping->lastHatState[evt.jhat.hat] = evt.jhat.value; + } + break; + } + + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + { + joystickState* torqueMapping; + if (mJoystickMap.isEmpty() || !mJoystickMap.find(evt.jbutton.which, torqueMapping)) + break; + buildInputEvent(JoystickDeviceType, torqueMapping->torqueInstID, SI_BUTTON, KEY_BUTTON0 + evt.jbutton.button, + evt.cbutton.state == SDL_PRESSED ? SI_MAKE : SI_BREAK, evt.cbutton.state == SDL_PRESSED ? 1.0f : 0.0f); + break; + } + + case SDL_JOYDEVICEADDED: + { + deviceConnectedCallback(evt.jdevice.which); + if (smControllerEnabled && SDL_IsGameController(evt.jdevice.which)) + break; // This device will be added as a controller + + if (smJoystickEnabled) + openJoystick(evt.jdevice.which, 0); + break; + } + + case SDL_JOYDEVICEREMOVED: + { + onSDLDeviceDisconnected_callback(evt.jdevice.which); + closeJoystick(evt.jdevice.which); + } + + case SDL_CONTROLLERAXISMOTION: + { + controllerState* torqueMapping; + if (mControllerMap.isEmpty() || !mControllerMap.find(evt.caxis.which, torqueMapping)) + break; + // SDL axis value inputs are in (range: -32768 to 32767) + // Torque axis values are -1.0 to 1.0 + F32 value = ((F32)evt.caxis.value) / (F32) (evt.caxis.value > 0 ? SDL_JOYSTICK_AXIS_MAX : -SDL_JOYSTICK_AXIS_MIN); + buildInputEvent(GamepadDeviceType, torqueMapping->torqueInstID, SI_AXIS, map_EventForControllerAxis[evt.caxis.axis], SI_MOVE, value); + break; + } + + case SDL_CONTROLLERBUTTONDOWN: + case SDL_CONTROLLERBUTTONUP: + { + controllerState* torqueMapping; + if (mControllerMap.isEmpty() || !mControllerMap.find(evt.cbutton.which, torqueMapping)) + break; + buildInputEvent(GamepadDeviceType, torqueMapping->torqueInstID, SI_BUTTON, map_EventForControllerButton[evt.cbutton.button], + evt.cbutton.state == SDL_PRESSED ? SI_MAKE : SI_BREAK, evt.cbutton.state == SDL_PRESSED ? 1.0f : 0.0f); + break; + } + + case SDL_CONTROLLERDEVICEADDED: + { + if (smControllerEnabled) + openController(evt.cdevice.which, 0); + break; + } + + case SDL_CONTROLLERDEVICEREMOVED: + { + closeController(evt.cdevice.which); + break; + } + + case SDL_CONTROLLERDEVICEREMAPPED: + break; + + default: +#ifdef TORQUE_DEBUG + Con::warnf("Unhandled SDL input event: 0x%04x", evt.type); +#endif + break; + } +} + +//------------------------------------------------------------------------------ +void SDLInputManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, S32 iValue) +{ + InputEventInfo newEvent; + + newEvent.deviceType = deviceType; + newEvent.deviceInst = deviceInst; + newEvent.objType = objType; + newEvent.objInst = objInst; + newEvent.action = action; + newEvent.iValue = iValue; + + newEvent.postToSignal(Input::smInputEvent); +} + +//------------------------------------------------------------------------------ +void SDLInputManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, F32 fValue) +{ + InputEventInfo newEvent; + + newEvent.deviceType = deviceType; + newEvent.deviceInst = deviceInst; + newEvent.objType = objType; + newEvent.objInst = objInst; + newEvent.action = action; + newEvent.fValue = fValue; + + newEvent.postToSignal(Input::smInputEvent); +} + +//------------------------------------------------------------------------------ +void SDLInputManager::buildHatEvents(U32 deviceType, U32 deviceInst, U8 lastState, U8 currentState, S32 hatIndex) +{ + if (smPOVButtonEvents) + { + if ((lastState & SDL_HAT_UP) != (currentState & SDL_HAT_UP)) + { + buildInputEvent(deviceType, deviceInst, SI_POV, hatIndex ? SI_UPOV2 : SI_UPOV, + (currentState & SDL_HAT_UP) ? SI_MAKE : SI_BREAK, (currentState & SDL_HAT_UP) ? 1.0f : 0.0f); + } + + if ((lastState & SDL_HAT_DOWN) != (currentState & SDL_HAT_DOWN)) + { + buildInputEvent(deviceType, deviceInst, SI_POV, hatIndex ? SI_DPOV2 : SI_DPOV, + (currentState & SDL_HAT_DOWN) ? SI_MAKE : SI_BREAK, (currentState & SDL_HAT_DOWN) ? 1.0f : 0.0f); + } + + if ((lastState & SDL_HAT_LEFT) != (currentState & SDL_HAT_LEFT)) + { + buildInputEvent(deviceType, deviceInst, SI_POV, hatIndex ? SI_LPOV2 : SI_LPOV, + (currentState & SDL_HAT_LEFT) ? SI_MAKE : SI_BREAK, (currentState & SDL_HAT_LEFT) ? 1.0f : 0.0f); + } + + if ((lastState & SDL_HAT_RIGHT) != (currentState & SDL_HAT_RIGHT)) + { + buildInputEvent(deviceType, deviceInst, SI_POV, hatIndex ? SI_RPOV2 : SI_RPOV, + (currentState & SDL_HAT_RIGHT) ? SI_MAKE : SI_BREAK, (currentState & SDL_HAT_RIGHT) ? 1.0f : 0.0f); + } + } + + if (smPOVMaskEvents) + { + buildInputEvent(deviceType, deviceInst, SI_INT, hatIndex ? SI_POVMASK2 : SI_POVMASK, SI_VALUE, (S32) currentState); + } +} + +//------------------------------------------------------------------------------ +S32 SDLInputManager::openController(S32 sdlIndex, S32 requestedTID) +{ + if ((sdlIndex < 0) || (sdlIndex >= SDL_NumJoysticks()) || (requestedTID < 0) || (requestedTID >= MaxControllers)) + return -1; + + if (SDL_IsGameController(sdlIndex)) + { + SDL_GameController *inputDevice = SDL_GameControllerOpen(sdlIndex); + if (inputDevice) + { + SDL_JoystickID sdlId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(inputDevice)); + + // See if the device is already open as a joystick + for (S32 i = 0; i < MaxJoysticks; ++i) + { + if (mJoysticks[i].sdlInstID == sdlId) + { + if (!closeJoystickByIndex(i)) + { + SDL_GameControllerClose(inputDevice); + return -1; + } + } + } + + controllerState* torqueMapping = NULL; + if (mControllerMap.find(sdlId, torqueMapping)) + { + if (torqueMapping->torqueInstID == (U32) requestedTID) + { + SDL_GameControllerClose(inputDevice); + return requestedTID; // Already open at the requested ID + } + closeControllerByIndex(torqueMapping->torqueInstID); + } + + S32 gamepadSlot = -1; + if (!mControllers[requestedTID].inputDevice) + gamepadSlot = requestedTID; + else + { + // Find the first available gamepad device slot + for (S32 i = 0; i < MaxControllers; ++i) + { + if (!mControllers[i].inputDevice) + { + gamepadSlot = i; + break; + } + } + } + + if (gamepadSlot == -1) + { + Con::errorf("Unable to open Game Controller %s. Too many devices present.", SDL_GameControllerName(inputDevice)); + SDL_GameControllerClose(inputDevice); + return -1; + } + + mControllers[gamepadSlot].inputDevice = inputDevice; + mControllers[gamepadSlot].sdlInstID = sdlId; + mControllerMap.insertUnique(sdlId, &mControllers[gamepadSlot]); + + return gamepadSlot; + } + } + return -1; +} + +//------------------------------------------------------------------------------ +void SDLInputManager::closeController(SDL_JoystickID sdlId) +{ + controllerState* torqueMapping = NULL; + if (mControllerMap.find(sdlId, torqueMapping)) + closeControllerByIndex(torqueMapping->torqueInstID); +} + +//------------------------------------------------------------------------------ +bool SDLInputManager::closeControllerByIndex(S32 index) +{ + if (index < 0 || index >= MaxControllers) + return false; + + if (mControllers[index].inputDevice && mControllers[index].sdlInstID != -1) + { + SDL_GameControllerClose(mControllers[index].inputDevice); + mControllerMap.erase(mControllers[index].sdlInstID); + mControllers[index].sdlInstID = -1; + mControllers[index].inputDevice = NULL; + return true; + } + + return false; +} + +//------------------------------------------------------------------------------ +S32 SDLInputManager::openJoystick(S32 sdlIndex, S32 requestedTID) +{ + if ((sdlIndex < 0) || (sdlIndex >= SDL_NumJoysticks()) || (requestedTID < 0) || (requestedTID >= MaxJoysticks)) + return -1; + + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + SDL_JoystickID sdlId = SDL_JoystickInstanceID(inputDevice); + + // See if the device is already open as a controller + for (S32 i = 0; i < MaxControllers; ++i) + { + if (mControllers[i].sdlInstID == sdlId) + { + if (!closeControllerByIndex(i)) + { + SDL_JoystickClose(inputDevice); + return -1; + } + } + } + + joystickState* torqueMapping = NULL; + if (mJoystickMap.find(sdlId, torqueMapping)) + { + if (torqueMapping->torqueInstID == (U32) requestedTID) + { + SDL_JoystickClose(inputDevice); + return requestedTID; // Already open at the requested ID + } + closeJoystickByIndex(torqueMapping->torqueInstID); + } + + S32 joystickSlot = -1; + if (!mJoysticks[requestedTID].inputDevice) + joystickSlot = requestedTID; + else + { + // Find the first available joystick device slot + for (S32 i = 0; i < MaxJoysticks; ++i) + { + if (!mJoysticks[i].inputDevice) + { + joystickSlot = i; + break; + } + } + } + + if (joystickSlot == -1) + { + Con::errorf("Unable to open Joystick %s. Too many devices present.", SDL_JoystickName(inputDevice)); + SDL_JoystickClose(inputDevice); + return -1; + } + + mJoysticks[joystickSlot].inputDevice = inputDevice; + mJoysticks[joystickSlot].sdlInstID = sdlId; + mJoysticks[joystickSlot].numAxes = SDL_JoystickNumAxes(inputDevice); + mJoystickMap.insertUnique(sdlId, &mJoysticks[joystickSlot]); + + return joystickSlot; + } + return -1; +} + +//------------------------------------------------------------------------------ +void SDLInputManager::closeJoystick(SDL_JoystickID sdlId) +{ + joystickState* torqueMapping = NULL; + if (mJoystickMap.find(sdlId, torqueMapping)) + closeJoystickByIndex(torqueMapping->torqueInstID); +} + +//------------------------------------------------------------------------------ +bool SDLInputManager::closeJoystickByIndex(S32 index) +{ + if (index < 0 || index >= MaxJoysticks) + return false; + + if (mJoysticks[index].inputDevice && mJoysticks[index].sdlInstID != -1) + { + SDL_JoystickClose(mJoysticks[index].inputDevice); + mJoystickMap.erase(mJoysticks[index].sdlInstID); + mJoysticks[index].reset(); + return true; + } + + return false; +} + +//------------------------------------------------------------------------------ +void SDLInputManager::closeDevice(S32 sdlIndex) +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return; + + SDL_JoystickID sdlId = -1; + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + sdlId = SDL_JoystickInstanceID(inputDevice); + SDL_JoystickClose(inputDevice); + } + + if (sdlId < 0) + return; + + for (S32 i = 0; i < MaxControllers; ++i) + { + if (mControllers[i].sdlInstID == sdlId) + { + closeControllerByIndex(i); + return; + } + } + + for (S32 i = 0; i < MaxJoysticks; ++i) + { + if (mJoysticks[i].sdlInstID == sdlId) + { + closeJoystickByIndex(i); + return; + } + } +} + +//------------------------------------------------------------------------------ +void SDLInputManager::deviceConnectedCallback(S32 index) +{ + // This will generate the script callback: + // onSDLDeviceConnected(%sdlIndex, %isController, %deviceName) + bool isController = SDL_IsGameController(index); + const char *deviceName = isController ? SDL_GameControllerNameForIndex(index) : SDL_JoystickNameForIndex(index); + SDL_JoystickType deviceType = SDL_JoystickGetDeviceType(index); + onSDLDeviceConnected_callback(index, deviceName, castConsoleTypeToString(deviceType)); +} + +//------------------------------------------------------------------------------ +// Console interface + +//------------------------------------------------------------------------------ +// Get the N'th SDL device state -1=doesn't exist, 0=closed, 1=open joystick, 2=open controller +S32 SDLInputManager::getJoystickOpenState(S32 sdlIndex) +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return -1; + + S32 currentState = 0; + // We need to open the joystick to get the sdl instanceID + // This will increase the refcount on the joystick if it was already open. + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + SDL_JoystickID sdlId = SDL_JoystickInstanceID(inputDevice); + controllerState* controllerMapping = NULL; + joystickState* joystickMapping = NULL; + if (!mControllerMap.isEmpty() && mControllerMap.find(sdlId, controllerMapping)) + currentState = 2; + else if (!mJoystickMap.isEmpty() && mJoystickMap.find(sdlId, joystickMapping)) + currentState = 1; + + // Close the joystick to return the refcount to the previouse state + SDL_JoystickClose(inputDevice); + } + + return currentState; +} + +//------------------------------------------------------------------------------ +// Fills in the torque device instance string from an sdl joystick index number +void SDLInputManager::getJoystickTorqueInst(S32 sdlIndex, char* instBuffer) +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return; + + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + SDL_JoystickID sdlId = SDL_JoystickInstanceID(inputDevice); + controllerState* controllerMapping = NULL; + joystickState* joystickMapping = NULL; + if (!mControllerMap.isEmpty() && mControllerMap.find(sdlId, controllerMapping)) + ActionMap::getDeviceName(GamepadDeviceType, controllerMapping->torqueInstID, instBuffer); + else if (!mJoystickMap.isEmpty() && mJoystickMap.find(sdlId, joystickMapping)) + ActionMap::getDeviceName(JoystickDeviceType, joystickMapping->torqueInstID, instBuffer); + + SDL_JoystickClose(inputDevice); + } +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, numJoysticks, S32, (), , + "@brief Returns the number of currently connected joystick devices.\n\n" + "Game Controllers are a sub-set of joysticks and are included in the joystick count. " + "See https://wiki.libsdl.org/SDL_NumJoysticks for more details.\n" + "@ingroup Input") +{ + return SDL_NumJoysticks(); +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, getDeviceOpenState, S32, ( S32 sdlIndex ), ( 0 ), + "@brief Used to determine the current state of the N'th item in the SDL device list.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return values:\n" + "-1 if the device does not exist (invalid sdlIndex passed)\n" + "0 The device is closed\n" + "1 The device is open as a Joystick\n" + "2 The device is open as a Game Controller\n" + "@ingroup Input") +{ + SDLInputManager* mgr = dynamic_cast(Input::getManager()); + if (mgr && mgr->isEnabled()) + return mgr->getJoystickOpenState(sdlIndex); + return -1; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, openAsJoystick, S32, ( S32 sdlIndex, S32 torqueInstId ), ( 0, 0 ), + "@brief Used to open the device as a Joystick.\n\n" + "If the device is currently open as a Game Controller, it will be closed and opened as " + "a Joystick. If it is currently opened as a Joystick with a different T3D instance ID, " + "it will be changed to the requested ID if that ID is available.\n" + "@param sdlIndex The SDL index for this device.\n" + "@param torqueInstId Is the requested T3D device instance ID. If there is already an open Joystick with " + "the requested ID, The first available ID will be assigned.\n" + "@return The T3D device instance ID assigned, or -1 if the device could not be opened.") +{ + SDLInputManager* mgr = dynamic_cast(Input::getManager()); + if (mgr && mgr->isEnabled()) + return mgr->openJoystick(sdlIndex, torqueInstId); + return -1; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, openAsController, S32, (S32 sdlIndex, S32 torqueInstId), (0, 0), + "@brief Used to open the device as a Game Controller.\n\n" + "If the device is currently open as a Joystick, it will be closed and opened as " + "a Game Controller. If it is currently opened as a Game Controller with a different " + "T3D instance ID, it will be changed to the requested ID if that ID is available.\n" + "@param sdlIndex The SDL index for this device.\n" + "@param torqueInstId Is the requested T3D device instance ID. If there is already an " + "open Game Controller with the requested ID, The first available ID will be assigned.\n" + "@return The T3D device instance ID assigned, or -1 if the device could not be opened.") +{ + SDLInputManager* mgr = dynamic_cast(Input::getManager()); + if (mgr && mgr->isEnabled()) + return mgr->openController(sdlIndex, torqueInstId); + return -1; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, closeDevice, void, (S32 sdlIndex), (0), + "@brief Used to close the N'th item in the SDL device list.\n\n" + "This will close a Joystick or Game Controller.\n" + "@param sdlIndex The SDL index for this device.\n") +{ + SDLInputManager* mgr = dynamic_cast(Input::getManager()); + if (mgr && mgr->isEnabled()) + mgr->closeDevice(sdlIndex); + return; +} + + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, getTorqueInstFromDevice, const char *, (S32 sdlIndex), (0), + "@brief Gets the T3D instance identifier for an open SDL joystick.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns the T3D instance ID used for mapping this device or Null if it does not exist.\n" + "@ingroup Input") +{ + SDLInputManager* mgr = dynamic_cast(Input::getManager()); + if (mgr && mgr->isEnabled()) + { + char* deviceInst = Con::getReturnBuffer(32); + deviceInst[0] = '\0'; + mgr->getJoystickTorqueInst(sdlIndex, deviceInst); + return deviceInst; + } + return NULL; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickNameForIndex, const char *, (S32 sdlIndex), (0), + "@brief Exposes SDL_JoystickNameForIndex() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns the name of the selected joystick or Null if it does not exist.\n" + "@see https://wiki.libsdl.org/SDL_JoystickNameForIndex \n" + "@ingroup Input") +{ + if (sdlIndex >= 0 && sdlIndex < SDL_NumJoysticks()) + return SDL_JoystickNameForIndex(sdlIndex); + return NULL; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, ControllerNameForIndex, const char *, (S32 sdlIndex), (0), + "@brief Exposes SDL_GameControllerNameForIndex() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns the implementation dependent name for the game controller, " + "or NULL if there is no name or the index is invalid.\n" + "@see https://wiki.libsdl.org/SDL_GameControllerNameForIndex \n" + "@ingroup Input") +{ + if (sdlIndex >= 0 && sdlIndex < SDL_NumJoysticks() || !SDL_IsGameController(sdlIndex)) + return SDL_GameControllerNameForIndex(sdlIndex); + return NULL; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickGetGUID, const char *, (S32 sdlIndex), (0), + "@brief Exposes SDL_JoystickGetDeviceGUID() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return GUID for the indexed device or Null if it does not exist.\n" + "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceGUID \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return NULL; + + SDL_JoystickGUID guidVal = SDL_JoystickGetDeviceGUID(sdlIndex); + char *guidStr = Con::getReturnBuffer(64); + SDL_JoystickGetGUIDString(guidVal, guidStr, 64); + + return guidStr; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GetVendor, S32, (S32 sdlIndex), (0), + "Gets the USB vendor ID of a joystick device, if available.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return The USB vendor ID. If the vendor ID isn't available this function returns 0.\n" + "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceVendor \n" + "@see https://wiki.libsdl.org/SDL_JoystickGetVendor \n" + "@see https://wiki.libsdl.org/SDL_GameControllerGetVendor \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return 0; + + return (S32) SDL_JoystickGetDeviceVendor(sdlIndex); +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GetProduct, S32, (S32 sdlIndex), (0), + "Gets the USB product ID of a joystick device, if available.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return The USB product ID. If the product ID isn't available this function returns 0.\n" + "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceProduct \n" + "@see https://wiki.libsdl.org/SDL_JoystickGetProduct \n" + "@see https://wiki.libsdl.org/SDL_GameControllerGetProduct \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return 0; + + return (S32)SDL_JoystickGetDeviceProduct(sdlIndex); +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GetProductVersion, S32, (S32 sdlIndex), (0), + "Gets the product version of a joystick device, if available.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return The product version. If the product version isn't available this function returns 0.\n" + "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceProductVersion \n" + "@see https://wiki.libsdl.org/SDL_JoystickGetProductVersion \n" + "@see https://wiki.libsdl.org/SDL_GameControllerGetProductVersion \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return 0; + + return (S32)SDL_JoystickGetDeviceProductVersion(sdlIndex); +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GetDeviceType, SDLJoystickType, (S32 sdlIndex), (0), + "@brief Exposes SDL_JoystickGetDeviceType() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return The type of device connected. Possible return strings are: \"Unknown\", " + "\"Game Controller\", \"Wheel\", \"Arcade Stick\", \"Flight Stick\", \"Dance Pad\", " + "\"Guitar\", \"Drum Kit\", \"Arcade Pad\" and \"Throttle\"\n" + "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceType \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return SDL_JOYSTICK_TYPE_UNKNOWN; + + return SDL_JoystickGetDeviceType(sdlIndex); +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickNumAxes, S32, (S32 sdlIndex), (0), + "@brief Exposes SDL_JoystickNumAxes() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns the number of axis controls/number of axes on success or zero on failure.\n" + "@see https://wiki.libsdl.org/SDL_JoystickNumAxes \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return 0; + + S32 numAxes = 0; + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + numAxes = SDL_JoystickNumAxes(inputDevice); + if (numAxes < 0) + { + Con::errorf("SDL Joystick error: %s", SDL_GetError()); + numAxes = 0; + } + + SDL_JoystickClose(inputDevice); + } + + return numAxes; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickNumBalls, S32, (S32 sdlIndex), (0), + "@brief Exposes SDL_JoystickNumBalls() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns the number of trackballs on success or zero on failure.\n" + "@see https://wiki.libsdl.org/SDL_JoystickNumBalls \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return 0; + + S32 numBalls = 0; + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + numBalls = SDL_JoystickNumBalls(inputDevice); + if (numBalls < 0) + { + Con::errorf("SDL Joystick error: %s", SDL_GetError()); + numBalls = 0; + } + + SDL_JoystickClose(inputDevice); + } + + return numBalls; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickNumButtons, S32, (S32 sdlIndex), (0), + "@brief Exposes SDL_JoystickNumButtons() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns the number of buttons on success or zero on failure.\n" + "@see https://wiki.libsdl.org/SDL_JoystickNumButtons \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return 0; + + S32 numButtons = 0; + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + numButtons = SDL_JoystickNumButtons(inputDevice); + if (numButtons < 0) + { + Con::errorf("SDL Joystick error: %s", SDL_GetError()); + numButtons = 0; + } + + SDL_JoystickClose(inputDevice); + } + + return numButtons; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickNumHats, S32, (S32 sdlIndex), (0), + "@brief Exposes SDL_JoystickNumHats() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns the number of POV hats on success or zero on failure.\n" + "@see https://wiki.libsdl.org/SDL_JoystickNumHats \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return 0; + + S32 numHats = 0; + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + numHats = SDL_JoystickNumHats(inputDevice); + if (numHats < 0) + { + Con::errorf("SDL Joystick error: %s", SDL_GetError()); + numHats = 0; + } + + SDL_JoystickClose(inputDevice); + } + + return numHats; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, IsGameController, bool, (S32 sdlIndex), (0), + "@brief Exposes SDL_IsGameController() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns true if the given joystick is supported by the game controller " + "interface, false if it isn't or it's an invalid index.\n" + "@see https://wiki.libsdl.org/SDL_IsGameController \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks() || !SDL_IsGameController(sdlIndex)) + return false; + + return true; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickIsHaptic, bool, (S32 sdlIndex), (0), + "@brief Exposes SDL_JoystickIsHaptic() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns true if the joystick is haptic.\n" + "@see https://wiki.libsdl.org/SDL_JoystickIsHaptic \n" + "@ingroup Input") +{ + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return false; + + bool isHaptic = false; + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + isHaptic = (SDL_JoystickIsHaptic(inputDevice) == SDL_TRUE); + SDL_JoystickClose(inputDevice); + } + + return isHaptic; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickPowerLevel, SDLPowerEnum, (S32 sdlIndex), (0), + "@brief Exposes SDL_JoystickCurrentPowerLevel() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns the current battery level or \"Wired\" if it's a connected device.\n" + "@see https://wiki.libsdl.org/SDL_JoystickCurrentPowerLevel \n" + "@ingroup Input") +{ + SDL_JoystickPowerLevel powerLevel = SDL_JOYSTICK_POWER_UNKNOWN; + if (sdlIndex >= 0 && sdlIndex < SDL_NumJoysticks()) + { + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + powerLevel = SDL_JoystickCurrentPowerLevel(inputDevice); + SDL_JoystickClose(inputDevice); + } + } + return powerLevel; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickGetSpecs, String, (S32 sdlIndex), (0), + "@brief A convenience function to reurn all of the data for a Joystick/Game Controller " + " packed as fields in a tab separated string.\n\n" + "There is overhead involved in querying joystick data, especially if the device is not open. " + "If more than one field is required, it is more efficient to call JoystickGetSpecs() and " + "parse the data out of the return string than to call the console method for each.\n" + "@param sdlIndex The SDL index for this device.\n" + "@return A tab separated string that can be parsed from script with getField()/getFields().\n\n" + "Field 0: Number of Axes\n" + " 1: Number of Buttons\n" + " 2: Number of POV Hats\n" + " 3: Number of Trackballs\n" + " 4: SDL_IsGameController() (Boolean)\n" + " 5: SDL_JoystickIsHaptic() (Boolean)\n" + " 6: Power Level (String)\n" + " 7: Device Type (String)\n" + "@ingroup Input") +{ + String specStr; + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return specStr; + + bool isController = SDL_IsGameController(sdlIndex); + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + SDL_JoystickPowerLevel powerLevel = SDL_JoystickCurrentPowerLevel(inputDevice); + SDL_JoystickType deviceType = SDL_JoystickGetDeviceType(sdlIndex); + + specStr = String::ToString("%d\t%d\t%d\t%d\t%d\t%d\t%s\t%s\t", + SDL_JoystickNumAxes(inputDevice), SDL_JoystickNumButtons(inputDevice), + SDL_JoystickNumHats(inputDevice), SDL_JoystickNumBalls(inputDevice), + isController ? 1 : 0, (SDL_JoystickIsHaptic(inputDevice) == SDL_TRUE) ? 1 : 0, + castConsoleTypeToString(powerLevel), castConsoleTypeToString(deviceType)); + SDL_JoystickClose(inputDevice); + } + + return specStr; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickGetAxes, String, (S32 sdlIndex), (0), + "@brief Gets the current value for all joystick axes.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return A tab separated string that can be parsed from script with getField()/getFields(). " + "Each axis is one field, so a 4 axis device will have 4 fields.\n\n" + "@ingroup Input") +{ + String axesStr; + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return axesStr; + + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + S32 numAxes = SDL_JoystickNumAxes(inputDevice); + for (S32 i = 0; i < numAxes; i++) + { + F32 axisVal = (F32) SDL_JoystickGetAxis(inputDevice, i); + F32 value = axisVal / (F32)(axisVal > 0.0f ? SDL_JOYSTICK_AXIS_MAX : -SDL_JOYSTICK_AXIS_MIN); + axesStr += String::ToString("%0.3f\t", value); + } + SDL_JoystickClose(inputDevice); + } + + return axesStr; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickGetButtons, String, (S32 sdlIndex), (0), + "@brief Gets the current value for all joystick buttons.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return A tab separated string that can be parsed from script with getField()/getFields(). " + "Each button is one field. 0 - SDL_JoystickNumButtons() fields.\n\n" + "@ingroup Input") +{ + String buttonStr; + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return buttonStr; + + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + S32 numbuttons = SDL_JoystickNumButtons(inputDevice); + for (S32 i = 0; i < numbuttons; i++) + { + buttonStr += String::ToString("%d\t", (S32) SDL_JoystickGetButton(inputDevice, i)); + } + SDL_JoystickClose(inputDevice); + } + + return buttonStr; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, JoystickGetHats, String, (S32 sdlIndex), (0), + "@brief Gets the current value for all POV hats.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return A tab separated string that can be parsed from script with getField()/getFields(). " + "Each hat is one field. 0 - SDL_JoystickNumHats() fields. The value is a 4 bit bitmask. " + "If no bits are set, the hat is centered. Bit 0 is up, 1 is right, 2 is down and 3 is left.\n\n" + "@ingroup Input") +{ + String hatStr; + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return hatStr; + + SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex); + if (inputDevice) + { + S32 numHats = SDL_JoystickNumHats(inputDevice); + for (S32 i = 0; i < numHats; i++) + { + hatStr += String::ToString("%d\t", (S32)SDL_JoystickGetHat(inputDevice, i)); + } + SDL_JoystickClose(inputDevice); + } + + return hatStr; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, ControllerGetAxes, String, (S32 sdlIndex), (0), + "@brief Gets the current value for all controller axes.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return A tab separated string that can be parsed from script with getField()/getFields(). " + "Game controllers always have 6 axes in the following order: 0-LX, 1-LY, 2-RX, 3-RY, 4-LT, 5-RT.\n\n" + "@ingroup Input") +{ + String axesStr; + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return axesStr; + + bool isController = SDL_IsGameController(sdlIndex); + if (!isController) + return axesStr; + + SDL_GameController *inputDevice = SDL_GameControllerOpen(sdlIndex); + if (inputDevice) + { + for (S32 i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++) + { + F32 axisVal = (F32)SDL_GameControllerGetAxis(inputDevice, (SDL_GameControllerAxis) i); + F32 value = axisVal / (F32)(axisVal > 0.0f ? SDL_JOYSTICK_AXIS_MAX : -SDL_JOYSTICK_AXIS_MIN); + axesStr += String::ToString("%0.3f\t", value); + } + SDL_GameControllerClose(inputDevice); + } + + return axesStr; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, ControllerGetButtons, String, (S32 sdlIndex), (0), + "@brief Gets the current value for all controller buttons.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return A tab separated string that can be parsed from script with getField()/getFields(). " + "Game controllers always have 15 buttons in the following order: 0-A, 1-B, 2-X, 3-Y, 4-Back, " + "5-Guide, 6-Start, 7-Left Stick, 8-Right Stick, 9-Left Shoulder, 10-Right Shoulder, " + "11-DPad Up, 12-DPad Down, 13-DPad Left, 14-DPad Right.\n\n" + "@ingroup Input") +{ + String buttonStr; + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return buttonStr; + + bool isController = SDL_IsGameController(sdlIndex); + if (!isController) + return buttonStr; + + SDL_GameController *inputDevice = SDL_GameControllerOpen(sdlIndex); + if (inputDevice) + { + for (S32 i = SDL_CONTROLLER_BUTTON_A; i < SDL_CONTROLLER_BUTTON_MAX; i++) + { + buttonStr += String::ToString("%d\t", (S32)SDL_GameControllerGetButton(inputDevice, (SDL_GameControllerButton) i)); + } + SDL_GameControllerClose(inputDevice); + } + + return buttonStr; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GameControllerMapping, String, (S32 sdlIndex), (0), + "@brief Exposes SDL_GameControllerMapping() to script.\n\n" + "@param sdlIndex The SDL index for this device.\n" + "@return Returns a string that has the controller's mapping or NULL if no mapping " + "is available or it does not exist.\n" + "@see https://wiki.libsdl.org/SDL_JoystickNameForIndex \n" + "@ingroup Input") +{ + String mapping; + if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks()) + return mapping; + + SDL_GameController *inputDevice = SDL_GameControllerOpen(sdlIndex); + if (inputDevice) + { + char* sdlStr = SDL_GameControllerMapping(inputDevice); + if (sdlStr) + { + mapping = sdlStr; + SDL_free(sdlStr); + } + else + Con::errorf("SDL Joystick error: %s", SDL_GetError()); + + SDL_GameControllerClose(inputDevice); + } + + return mapping; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GameControllerMappingForGUID, String, (const char* guidStr), , + "@brief Exposes SDL_GameControllerMappingForGUID() to script.\n\n" + "@param guidStr The GUID for which a mapping is desired.\n" + "@return Returns a mapping string or NULL on error.\n" + "@see https://wiki.libsdl.org/SDL_GameControllerMappingForGUID \n" + "@ingroup Input") +{ + String mapping; + SDL_JoystickGUID guid = SDL_JoystickGetGUIDFromString(guidStr); + + char* sdlStr = SDL_GameControllerMappingForGUID(guid); + if (sdlStr) + { + mapping = sdlStr; + SDL_free(sdlStr); + } + + return mapping; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GameControllerAddMapping, S32, (const char* mappingString), , + "@brief Exposes SDL_GameControllerAddMapping() to script.\n\n" + "Use this function to add support for controllers that SDL is unaware of or " + "to cause an existing controller to have a different binding.\n" + "@param mappingString The new mapping string to apply. Full details on the format of this " + "string are available at the linked SDL wiki page.\n" + "@return Returns 1 if a new mapping is added, 0 if an existing mapping is updated, -1 on error.\n" + "@see https://wiki.libsdl.org/SDL_GameControllerAddMapping \n" + "@ingroup Input") +{ + S32 retVal = SDL_GameControllerAddMapping(mappingString); + if (retVal == -1) + Con::errorf("SDL Joystick error: %s", SDL_GetError()); + + return retVal; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GameControllerAddMappingsFromFile, S32, (const char* fileName), , + "@brief Exposes SDL_GameControllerAddMappingsFromFile() to script.\n\n" + "Use this function to load a set of Game Controller mappings from a file, filtered by the " + "current SDL_GetPlatform(). A community sourced database of controllers is available at " + "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt \n" + "@param fileName The file to load mappings from.\n" + "@return Returns the number of mappings added or -1 on error.\n" + "@see https://wiki.libsdl.org/SDL_GameControllerAddMappingsFromFile \n" + "@ingroup Input") +{ + char torquePath[1024]; + Con::expandScriptFilename(torquePath, sizeof(torquePath), fileName); + S32 retVal = SDL_GameControllerAddMappingsFromFile(torquePath); + if (retVal == -1) + Con::errorf("SDL Joystick error: %s", SDL_GetError()); + + return retVal; +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GameControllerNumMappings, S32, (), , + "Get the number of mappings installed. Used with GameControllerMappingForIndex " + "to iterate through all installed mappings.\n\n" + "@ingroup Input") +{ + return SDL_GameControllerNumMappings(); +} + +//------------------------------------------------------------------------------ +DefineEngineStaticMethod(SDLInputManager, GameControllerMappingForIndex, String, (S32 mappingIndex), , + "Get the mapping at a particular index.\n\n" + "@param mappingIndex The index for which a mapping is desired.\n" + "@return Returns a mapping string or NULL if the index is out of range.\n" + "@ingroup Input") +{ + String mapping; + char* sdlStr = SDL_GameControllerMappingForIndex(mappingIndex); + + if (sdlStr) + { + mapping = sdlStr; + SDL_free(sdlStr); + } + + return mapping; +} diff --git a/Engine/source/platformSDL/sdlInputManager.h b/Engine/source/platformSDL/sdlInputManager.h new file mode 100644 index 000000000..b9c9f057d --- /dev/null +++ b/Engine/source/platformSDL/sdlInputManager.h @@ -0,0 +1,114 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +#ifndef _SDLINPUTMANAGER_H_ +#define _SDLINPUTMANAGER_H_ + +#ifndef _PLATFORMINPUT_H_ +#include "platform/platformInput.h" +#endif +#include "SDL.h" + +//------------------------------------------------------------------------------ +class SDLInputManager : public InputManager +{ + enum Constants { + MaxJoysticks = 4, // Up to 4 simultaneous joysticks + MaxControllers = 4, // Up to 4 simultaneous controllers + MaxHats = 2, // Maximum 2 hats per device + MaxBalls = 2, // Maximum 2 trackballs per device + MaxControllerAxes = 7, // From map_StringForControllerAxis[] in SDL_gamecontroller.c + MaxControllerButtons = 16 // From map_StringForControllerButton[] in SDL_gamecontroller.c + }; + + struct controllerState + { + S32 sdlInstID; // SDL device instance id + U32 torqueInstID; // Torque device instance id + SDL_GameController *inputDevice; + }; + + struct joystickState + { + S32 sdlInstID; // SDL device instance id + U32 torqueInstID; // Torque device instance id + SDL_Joystick *inputDevice; + U32 numAxes; + U8 lastHatState[MaxHats]; + + void reset(); + }; + +private: + typedef InputManager Parent; + + static S32 map_EventForControllerAxis[MaxControllerAxes]; + static S32 map_EventForControllerButton[MaxControllerButtons]; + + static bool smJoystickEnabled; + static bool smJoystickSplitAxesLR; + static bool smControllerEnabled; + static bool smPOVButtonEvents; + static bool smPOVMaskEvents; + + joystickState mJoysticks[MaxJoysticks]; + controllerState mControllers[MaxControllers]; + + // Used to look up a torque instance based on a device inst + HashTable mJoystickMap; + HashTable mControllerMap; + + bool mJoystickActive; + + void deviceConnectedCallback(S32 index); + bool closeControllerByIndex(S32 index); + void closeController(SDL_JoystickID sdlId); + bool closeJoystickByIndex(S32 index); + void closeJoystick(SDL_JoystickID sdlId); + + void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, S32 iValue); + void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, F32 fValue); + void buildHatEvents(U32 deviceType, U32 deviceInst, U8 lastState, U8 currentState, S32 hatIndex); + +public: + DECLARE_STATIC_CLASS(SDLInputManager); + +public: + SDLInputManager(); + + bool enable(); + void disable(); + void process(); + + void processEvent(SDL_Event &evt); + + static void init(); + + // Console interface: + S32 openJoystick(S32 sdlIndex, S32 requestedTID); + S32 openController(S32 sdlIndex, S32 requestedTID); + void closeDevice(S32 sdlIndex); + S32 getJoystickOpenState(S32 sdlIndex); + void getJoystickTorqueInst(S32 sdlIndex, char* instBuffer); +}; + +#endif // _SDLINPUTMANAGER_H_ diff --git a/Engine/source/platformX86UNIX/x86UNIXConsole.cpp b/Engine/source/platformX86UNIX/x86UNIXConsole.cpp index 9dee9d263..88e17f38e 100644 --- a/Engine/source/platformX86UNIX/x86UNIXConsole.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXConsole.cpp @@ -34,13 +34,14 @@ #include #include +#include "console/engineAPI.h" + StdConsole *stdConsole = NULL; -ConsoleFunction(enableWinConsole, void, 2, 2, "enableWinConsole(bool);") +DefineEngineFunction(enableWinConsole, void, (bool _enable),, "enableWinConsole(bool);") { - argc; if (stdConsole) - stdConsole->enable(dAtob(argv[1])); + stdConsole->enable(_enable); } void StdConsole::create() diff --git a/Engine/source/platformX86UNIX/x86UNIXFileio.cpp b/Engine/source/platformX86UNIX/x86UNIXFileio.cpp index 40f5fedae..690bae1f0 100644 --- a/Engine/source/platformX86UNIX/x86UNIXFileio.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXFileio.cpp @@ -55,7 +55,7 @@ #include "console/console.h" #include "core/strings/stringFunctions.h" #include "util/tempAlloc.h" - #include "cinterface/cinterface.h" + #include "cinterface/c_controlInterface.h" #include "core/volume.h" #if defined(__FreeBSD__) diff --git a/Engine/source/platformX86UNIX/x86UNIXMath.cpp b/Engine/source/platformX86UNIX/x86UNIXMath.cpp index 6d3d141c3..ada90c5f5 100644 --- a/Engine/source/platformX86UNIX/x86UNIXMath.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXMath.cpp @@ -24,7 +24,7 @@ #include "console/console.h" #include "math/mMath.h" #include "core/strings/stringFunctions.h" - +#include "console/engineAPI.h" extern void mInstallLibrary_C(); extern void mInstallLibrary_ASM(); @@ -35,7 +35,13 @@ extern void mInstall_Library_SSE(); //-------------------------------------- -ConsoleFunction( MathInit, void, 1, 10, "(detect|C|FPU|MMX|3DNOW|SSE|...)") +DefineEngineStringlyVariadicFunction( mathInit, void, 1, 10, "( ... )" + "@brief Install the math library with specified extensions.\n\n" + "Possible parameters are:\n\n" + " - 'DETECT' Autodetect math lib settings.\n\n" + " - 'C' Enable the C math routines. C routines are always enabled.\n\n" + " - 'SSE' Enable SSE math routines.\n\n" + "@ingroup Math") { U32 properties = CPU_PROP_C; // C entensions are always used diff --git a/Engine/source/platformX86UNIX/x86UNIXProcessControl.cpp b/Engine/source/platformX86UNIX/x86UNIXProcessControl.cpp index bf246d132..09c59af4d 100644 --- a/Engine/source/platformX86UNIX/x86UNIXProcessControl.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXProcessControl.cpp @@ -29,7 +29,7 @@ #include #include #include - +#include "console/engineAPI.h" #ifndef TORQUE_DEDICATED #include #endif @@ -203,10 +203,7 @@ void Platform::outputDebugString(const char *string, ...) //----------------------------------------------------------------------------- // testing function -ConsoleFunction(debug_debugbreak, void, 1, 1, "debug_debugbreak()") -{ - Platform::debugBreak(); -} +//DefineEngineFunction(debug_debugbreak, void, () , , "debug_debugbreak();"); //----------------------------------------------------------------------------- void Platform::restartInstance() diff --git a/Engine/source/scene/sceneContainer.cpp b/Engine/source/scene/sceneContainer.cpp index 128ef3edd..b08456b15 100644 --- a/Engine/source/scene/sceneContainer.cpp +++ b/Engine/source/scene/sceneContainer.cpp @@ -1392,7 +1392,7 @@ void SceneContainer::getBinRange( const F32 min, const F32 max, U32& minBin, U32 // This is truly lame, but it can happen. There must be a better way to // deal with this. if (minCoord == SceneContainer::csmTotalBinSize) - minCoord = SceneContainer::csmTotalBinSize - 0.01; + minCoord = SceneContainer::csmTotalBinSize - 0.01f; } AssertFatal(minCoord >= 0.0 && minCoord < SceneContainer::csmTotalBinSize, "Bad minCoord"); @@ -1415,7 +1415,7 @@ void SceneContainer::getBinRange( const F32 min, const F32 max, U32& minBin, U32 // This is truly lame, but it can happen. There must be a better way to // deal with this. if (minCoord == SceneContainer::csmTotalBinSize) - minCoord = SceneContainer::csmTotalBinSize - 0.01; + minCoord = SceneContainer::csmTotalBinSize - 0.01f; } AssertFatal(minCoord >= 0.0 && minCoord < SceneContainer::csmTotalBinSize, "Bad minCoord"); @@ -1426,7 +1426,7 @@ void SceneContainer::getBinRange( const F32 min, const F32 max, U32& minBin, U32 // This is truly lame, but it can happen. There must be a better way to // deal with this. if (maxCoord == SceneContainer::csmTotalBinSize) - maxCoord = SceneContainer::csmTotalBinSize - 0.01; + maxCoord = SceneContainer::csmTotalBinSize - 0.01f; } AssertFatal(maxCoord >= 0.0 && maxCoord < SceneContainer::csmTotalBinSize, "Bad maxCoord"); diff --git a/Engine/source/scene/sceneObject.cpp b/Engine/source/scene/sceneObject.cpp index ff7b6496c..354440fd2 100644 --- a/Engine/source/scene/sceneObject.cpp +++ b/Engine/source/scene/sceneObject.cpp @@ -93,6 +93,9 @@ ConsoleDocClass( SceneObject, "@ingroup gameObjects\n" ); +#ifdef TORQUE_TOOLS +extern bool gEditingMission; +#endif Signal< void( SceneObject* ) > SceneObject::smSceneObjectAdd; Signal< void( SceneObject* ) > SceneObject::smSceneObjectRemove; @@ -763,8 +766,14 @@ void SceneObject::onCameraScopeQuery( NetConnection* connection, CameraScopeQuer bool SceneObject::isRenderEnabled() const { - AbstractClassRep *classRep = getClassRep(); - return ( mObjectFlags.test( RenderEnabledFlag ) && classRep->isRenderEnabled() ); +#ifdef TORQUE_TOOLS + if (gEditingMission) + { + AbstractClassRep *classRep = getClassRep(); + return (mObjectFlags.test(RenderEnabledFlag) && classRep->isRenderEnabled()); + } +#endif + return (mObjectFlags.test(RenderEnabledFlag)); } //----------------------------------------------------------------------------- diff --git a/Engine/source/scene/simPath.cpp b/Engine/source/scene/simPath.cpp index 2145af3cc..efa8f05f0 100644 --- a/Engine/source/scene/simPath.cpp +++ b/Engine/source/scene/simPath.cpp @@ -35,6 +35,8 @@ #include "renderInstance/renderPassManager.h" #include "console/engineAPI.h" +#include "T3D/Scene.h" + extern bool gEditingMission; //-------------------------------------------------------------------------- @@ -59,13 +61,13 @@ DefineEngineFunction(pathOnMissionLoadDone, void, (),, "@ingroup Networking") { // Need to load subobjects for all loaded interiors... - SimGroup* pMissionGroup = dynamic_cast(Sim::findObject("MissionGroup")); - AssertFatal(pMissionGroup != NULL, "Error, mission done loading and no mission group?"); + Scene* scene = Scene::getRootScene(); + AssertFatal(scene != NULL, "Error, mission done loading and no scene?"); U32 currStart = 0; U32 currEnd = 1; Vector groups; - groups.push_back(pMissionGroup); + groups.push_back(scene); while (true) { for (U32 i = currStart; i < currEnd; i++) { diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 0a58e074b..b52047cca 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -36,6 +36,8 @@ #else # include # include +# include +# include #endif #ifndef ALAPIENTRY @@ -134,6 +136,31 @@ typedef void * (ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, con typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname ); typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param ); typedef void (ALCAPIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); +///Changes for effects +typedef void (ALAPIENTRY *LPALGENEFFECTS)(ALsizei n, ALuint *effects); +typedef void (ALAPIENTRY *LPALDELETEEFFECTS)(ALsizei n, const ALuint *effects); +typedef ALboolean (ALAPIENTRY *LPALISEFFECT)(ALuint effect); +typedef void (ALAPIENTRY *LPALEFFECTI)(ALuint effect, ALenum param, ALint value); +typedef void (ALAPIENTRY *LPALEFFECTIV)(ALuint effect, ALenum param, const ALint *values); +typedef void (ALAPIENTRY *LPALEFFECTF)(ALuint effect, ALenum param, ALfloat value); +typedef void (ALAPIENTRY *LPALEFFECTFV)(ALuint effect, ALenum param, const ALfloat *values); +typedef void (ALAPIENTRY *LPALGETEFFECTI)(ALuint effect, ALenum param, ALint *value); +typedef void (ALAPIENTRY *LPALGETEFFECTIV)(ALuint effect, ALenum param, ALint *values); +typedef void (ALAPIENTRY *LPALGETEFFECTF)(ALuint effect, ALenum param, ALfloat *value); +typedef void (ALAPIENTRY *LPALGETEFFECTFV)(ALuint effect, ALenum param, ALfloat *values); +typedef void (ALAPIENTRY *LPALRELEASEALEFFECTS)(ALCdevice *device); +typedef void (ALAPIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei n, ALuint *effectslots); +typedef void (ALAPIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei n, const ALuint *effectslots); +typedef ALboolean (ALAPIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint effectslot); +typedef void (ALAPIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint effectslot, ALenum param, ALint value); +typedef void (ALAPIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint effectslot, ALenum param, const ALint *values); +typedef void (ALAPIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint effectslot, ALenum param, ALfloat value); +typedef void (ALAPIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint effectslot, ALenum param, const ALfloat *values); +typedef void (ALAPIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint effectslot, ALenum param, ALint *value); +typedef void (ALAPIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint effectslot, ALenum param, ALint *values); +typedef void (ALAPIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint effectslot, ALenum param, ALfloat *value); +typedef void (ALAPIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint effectslot, ALenum param, ALfloat *values); +typedef void (ALAPIENTRY *LPALSOURCE3I)(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); typedef struct { @@ -166,6 +193,7 @@ typedef struct LPALISSOURCE alIsSource; LPALSOURCEI alSourcei; LPALSOURCEF alSourcef; + LPALSOURCE3I alSource3i; LPALSOURCE3F alSource3f; LPALSOURCEFV alSourcefv; LPALGETSOURCEI alGetSourcei; @@ -203,6 +231,29 @@ typedef struct LPALCISEXTENSIONPRESENT alcIsExtensionPresent; LPALCGETPROCADDRESS alcGetProcAddress; LPALCGETENUMVALUE alcGetEnumValue; + LPALGENEFFECTS alGenEffects; + LPALDELETEEFFECTS alDeleteEffects; + LPALISEFFECT alIsEffect; + LPALEFFECTI alEffecti; + LPALEFFECTIV alEffectiv; + LPALEFFECTF alEffectf; + LPALEFFECTFV alEffectfv; + LPALGETEFFECTI alGetEffecti; + LPALGETEFFECTIV alGetEffectiv; + LPALGETEFFECTF alGetEffectf; + LPALGETEFFECTFV alGetEffectfv; + LPALRELEASEALEFFECTS alReleaseEffects; + LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots; + LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots; + LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot; + LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti; + LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv; + LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf; + LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv; + LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti; + LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv; + LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf; + LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv; } OPENALFNTABLE, *LPOPENALFNTABLE; #endif diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index 13e891ece..e620a483c 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -42,16 +42,21 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, // TODO: The OpenAL device doesn't set the primary buffer // $pref::SFX::frequency or $pref::SFX::bitrate! + //check auxiliary device sends 4 and add them to the device + ALint attribs[4] = { 0 }; + ALCint iSends = 0; + attribs[0] = ALC_MAX_AUXILIARY_SENDS; + attribs[1] = 4; mDevice = mOpenAL.alcOpenDevice( name ); mOpenAL.alcGetError( mDevice ); if( mDevice ) { - mContext = mOpenAL.alcCreateContext( mDevice, NULL ); + mContext = mOpenAL.alcCreateContext( mDevice, attribs ); if( mContext ) mOpenAL.alcMakeContextCurrent( mContext ); - + mOpenAL.alcGetIntegerv(mDevice, ALC_MAX_AUXILIARY_SENDS, 1, &iSends); U32 err = mOpenAL.alcGetError( mDevice ); if( err != ALC_NO_ERROR ) @@ -78,7 +83,10 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, SFXALDevice::~SFXALDevice() { _releaseAllResources(); - + ///cleanup our effects + mOpenAL.alDeleteAuxiliaryEffectSlots(4, effectSlot); + mOpenAL.alDeleteEffects(2, effect); + ///cleanup of effects ends mOpenAL.alcMakeContextCurrent( NULL ); mOpenAL.alcDestroyContext( mContext ); mOpenAL.alcCloseDevice( mDevice ); @@ -145,6 +153,9 @@ void SFXALDevice::setListener( U32 index, const SFXListenerProperties& listener mOpenAL.alListenerfv( AL_POSITION, pos ); mOpenAL.alListenerfv( AL_VELOCITY, velocity ); mOpenAL.alListenerfv( AL_ORIENTATION, (const F32 *)&tupple[0] ); + ///Pass a unit size to openal, 1.0 assumes 1 meter to 1 game unit. + ///Crucial for air absorbtion calculations. + mOpenAL.alListenerf(AL_METERS_PER_UNIT, 1.0f); } //----------------------------------------------------------------------------- @@ -164,7 +175,13 @@ void SFXALDevice::setDistanceModel( SFXDistanceModel model ) if( mUserRolloffFactor != mRolloffFactor ) _setRolloffFactor( mUserRolloffFactor ); break; - + /// create a case for our exponential distance model + case SFXDistanceModelExponent: + mOpenAL.alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED); + if (mUserRolloffFactor != mRolloffFactor) + _setRolloffFactor(mUserRolloffFactor); + break; + default: AssertWarn( false, "SFXALDevice::setDistanceModel - distance model not implemented" ); } @@ -200,3 +217,109 @@ void SFXALDevice::setRolloffFactor( F32 factor ) mUserRolloffFactor = factor; } + +void SFXALDevice::openSlots() +{ + for (uLoop = 0; uLoop < 4; uLoop++) + { + mOpenAL.alGenAuxiliaryEffectSlots(1, &effectSlot[uLoop]); + } + + for (uLoop = 0; uLoop < 2; uLoop++) + { + mOpenAL.alGenEffects(1, &effect[uLoop]); + } + ///debug string output so we know our slots are open + Platform::outputDebugString("Slots Open"); +} + +///create reverb effect +void SFXALDevice::setReverb(const SFXReverbProperties& reverb) +{ + ///output a debug string so we know each time the reverb changes + Platform::outputDebugString("Updated"); + + ///load an efxeaxreverb default and add our values from + ///sfxreverbproperties to it + EFXEAXREVERBPROPERTIES prop = EFX_REVERB_PRESET_GENERIC; + + prop.flDensity = reverb.flDensity; + prop.flDiffusion = reverb.flDiffusion; + prop.flGain = reverb.flGain; + prop.flGainHF = reverb.flGainHF; + prop.flGainLF = reverb.flGainLF; + prop.flDecayTime = reverb.flDecayTime; + prop.flDecayHFRatio = reverb.flDecayHFRatio; + prop.flDecayLFRatio = reverb.flDecayLFRatio; + prop.flReflectionsGain = reverb.flReflectionsGain; + prop.flReflectionsDelay = reverb.flReflectionsDelay; + prop.flLateReverbGain = reverb.flLateReverbGain; + prop.flLateReverbDelay = reverb.flLateReverbDelay; + prop.flEchoTime = reverb.flEchoTime; + prop.flEchoDepth = reverb.flEchoDepth; + prop.flModulationTime = reverb.flModulationTime; + prop.flModulationDepth = reverb.flModulationDepth; + prop.flAirAbsorptionGainHF = reverb.flAirAbsorptionGainHF; + prop.flHFReference = reverb.flHFReference; + prop.flLFReference = reverb.flLFReference; + prop.flRoomRolloffFactor = reverb.flRoomRolloffFactor; + prop.iDecayHFLimit = reverb.iDecayHFLimit; + + if (mOpenAL.alGetEnumValue("AL_EFFECT_EAXREVERB") != 0) + { + + /// EAX Reverb is available. Set the EAX effect type + + mOpenAL.alEffecti(effect[0], AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB); + + ///add our values to the setup of the reverb + + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DENSITY, prop.flDensity); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DIFFUSION, prop.flDiffusion); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_GAIN, prop.flGain); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_GAINHF, prop.flGainHF); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_GAINLF, prop.flGainLF); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DECAY_TIME, prop.flDecayTime); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DECAY_HFRATIO, prop.flDecayHFRatio); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DECAY_LFRATIO, prop.flDecayLFRatio); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_REFLECTIONS_GAIN, prop.flReflectionsGain); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_REFLECTIONS_DELAY, prop.flReflectionsDelay); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_LATE_REVERB_GAIN, prop.flLateReverbGain); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_LATE_REVERB_DELAY, prop.flLateReverbDelay); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_ECHO_TIME, prop.flEchoTime); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_ECHO_DEPTH, prop.flEchoDepth); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_MODULATION_TIME, prop.flModulationTime); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_MODULATION_DEPTH, prop.flModulationDepth); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_AIR_ABSORPTION_GAINHF, prop.flAirAbsorptionGainHF); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_HFREFERENCE, prop.flHFReference); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_LFREFERENCE, prop.flLFReference); + mOpenAL.alEffectf(effect[0], AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, prop.flRoomRolloffFactor); + mOpenAL.alEffecti(effect[0], AL_EAXREVERB_DECAY_HFLIMIT, prop.iDecayHFLimit); + mOpenAL.alAuxiliaryEffectSloti(1, AL_EFFECTSLOT_EFFECT, effect[0]); + Platform::outputDebugString("eax reverb properties set"); + + } + else + { + + /// No EAX Reverb. Set the standard reverb effect + mOpenAL.alEffecti(effect[0], AL_EFFECT_TYPE, AL_EFFECT_REVERB); + + mOpenAL.alEffectf(effect[0], AL_REVERB_DENSITY, prop.flDensity); + mOpenAL.alEffectf(effect[0], AL_REVERB_DIFFUSION, prop.flDiffusion); + mOpenAL.alEffectf(effect[0], AL_REVERB_GAIN, prop.flGain); + mOpenAL.alEffectf(effect[0], AL_REVERB_GAINHF, prop.flGainHF); + mOpenAL.alEffectf(effect[0], AL_REVERB_DECAY_TIME, prop.flDecayTime); + mOpenAL.alEffectf(effect[0], AL_REVERB_DECAY_HFRATIO, prop.flDecayHFRatio); + mOpenAL.alEffectf(effect[0], AL_REVERB_REFLECTIONS_GAIN, prop.flReflectionsGain); + mOpenAL.alEffectf(effect[0], AL_REVERB_REFLECTIONS_DELAY, prop.flReflectionsDelay); + mOpenAL.alEffectf(effect[0], AL_REVERB_LATE_REVERB_GAIN, prop.flLateReverbGain); + mOpenAL.alEffectf(effect[0], AL_REVERB_LATE_REVERB_DELAY, prop.flLateReverbDelay); + mOpenAL.alEffectf(effect[0], AL_REVERB_AIR_ABSORPTION_GAINHF, prop.flAirAbsorptionGainHF); + mOpenAL.alEffectf(effect[0], AL_REVERB_ROOM_ROLLOFF_FACTOR, prop.flRoomRolloffFactor); + mOpenAL.alEffecti(effect[0], AL_REVERB_DECAY_HFLIMIT, prop.iDecayHFLimit); + mOpenAL.alAuxiliaryEffectSloti(1, AL_EFFECTSLOT_EFFECT, effect[0]); + + } + +} \ No newline at end of file diff --git a/Engine/source/sfx/openal/sfxALDevice.h b/Engine/source/sfx/openal/sfxALDevice.h index ee6f1ccdb..277b2496a 100644 --- a/Engine/source/sfx/openal/sfxALDevice.h +++ b/Engine/source/sfx/openal/sfxALDevice.h @@ -85,6 +85,15 @@ class SFXALDevice : public SFXDevice virtual void setDistanceModel( SFXDistanceModel model ); virtual void setDopplerFactor( F32 factor ); virtual void setRolloffFactor( F32 factor ); + //function for openAL to open slots + virtual void openSlots(); + //slots + ALuint effectSlot[4] = { 0 }; + ALuint effect[2] = { 0 }; + ALuint uLoop; + //get values from sfxreverbproperties and pass it to openal device + virtual void setReverb(const SFXReverbProperties& reverb); + virtual void resetReverb() {} }; #endif // _SFXALDEVICE_H_ \ No newline at end of file diff --git a/Engine/source/sfx/openal/sfxALVoice.cpp b/Engine/source/sfx/openal/sfxALVoice.cpp index 21fc51700..ccba74143 100644 --- a/Engine/source/sfx/openal/sfxALVoice.cpp +++ b/Engine/source/sfx/openal/sfxALVoice.cpp @@ -118,7 +118,8 @@ void SFXALVoice::_play() #ifdef DEBUG_SPEW Platform::outputDebugString( "[SFXALVoice] Starting playback" ); #endif - + //send every voice that plays to the alauxiliary slot that has the reverb + mOpenAL.alSource3i(mSourceName, AL_AUXILIARY_SEND_FILTER, 1, 0, AL_FILTER_NULL); mOpenAL.alSourcePlay( mSourceName ); //WORKAROUND: Adjust play cursor for buggy OAL when resuming playback. Do this after alSourcePlay diff --git a/Engine/source/sfx/openal/win32/LoadOAL.cpp b/Engine/source/sfx/openal/win32/LoadOAL.cpp index a3a31a0f7..df28cd440 100644 --- a/Engine/source/sfx/openal/win32/LoadOAL.cpp +++ b/Engine/source/sfx/openal/win32/LoadOAL.cpp @@ -439,7 +439,118 @@ ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable OutputDebugStringA("Failed to retrieve 'alcGetEnumValue' function address\n"); return AL_FALSE; } + lpOALFnTable->alGenEffects = (LPALGENEFFECTS)GetProcAddress(g_hOpenALDLL, "alGenEffects"); + if (lpOALFnTable->alGenEffects == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGenEffects' function address\n"); + } + lpOALFnTable->alEffecti = (LPALEFFECTI)GetProcAddress(g_hOpenALDLL, "alEffecti"); + if (lpOALFnTable->alEffecti == NULL) + { + OutputDebugStringA("Failed to retrieve 'alEffecti' function address\n"); + } + lpOALFnTable->alEffectiv = (LPALEFFECTIV)GetProcAddress(g_hOpenALDLL, "alEffectiv"); + if (lpOALFnTable->alEffectiv == NULL) + { + OutputDebugStringA("Failed to retrieve 'alEffectiv' function address\n"); + } + lpOALFnTable->alEffectf = (LPALEFFECTF)GetProcAddress(g_hOpenALDLL, "alEffectf"); + if (lpOALFnTable->alEffectf == NULL) + { + OutputDebugStringA("Failed to retrieve 'alEffectf' function address\n"); + } + lpOALFnTable->alEffectfv = (LPALEFFECTFV)GetProcAddress(g_hOpenALDLL, "alEffectfv"); + if (lpOALFnTable->alEffectfv == NULL) + { + OutputDebugStringA("Failed to retrieve 'alEffectfv' function address\n"); + } + lpOALFnTable->alGetEffecti = (LPALGETEFFECTI)GetProcAddress(g_hOpenALDLL, "alGetEffecti"); + if (lpOALFnTable->alGetEffecti == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGetEffecti' function address\n"); + } + lpOALFnTable->alGetEffectiv = (LPALGETEFFECTIV)GetProcAddress(g_hOpenALDLL, "alGetEffectiv"); + if (lpOALFnTable->alGetEffectiv == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGetEffectiv' function address\n"); + } + lpOALFnTable->alGetEffectf = (LPALGETEFFECTF)GetProcAddress(g_hOpenALDLL, "alGetEffectf"); + if (lpOALFnTable->alGetEffectf == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGetEffectf' function address\n"); + } + lpOALFnTable->alGetEffectfv = (LPALGETEFFECTFV)GetProcAddress(g_hOpenALDLL, "alGetEffectfv"); + if (lpOALFnTable->alGetEffectfv == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGetEffectfv' function address\n"); + } + lpOALFnTable->alDeleteEffects = (LPALDELETEEFFECTS)GetProcAddress(g_hOpenALDLL, "alDeleteEffects"); + if (lpOALFnTable->alDeleteEffects == NULL) + { + OutputDebugStringA("Failed to retrieve 'alDeleteEffects' function address\n"); + } + lpOALFnTable->alIsEffect = (LPALISEFFECT)GetProcAddress(g_hOpenALDLL, "alIsEffect"); + if (lpOALFnTable->alIsEffect == NULL) + { + OutputDebugStringA("Failed to retrieve 'alIsEffect' function address\n"); + } + lpOALFnTable->alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSlotf"); + if (lpOALFnTable->alAuxiliaryEffectSlotf == NULL) + { + OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSlotf' function address\n"); + } + lpOALFnTable->alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSlotfv"); + if (lpOALFnTable->alAuxiliaryEffectSlotfv == NULL) + { + OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSlotfv' function address\n"); + } + lpOALFnTable->alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSloti"); + if (lpOALFnTable->alAuxiliaryEffectSloti == NULL) + { + OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSloti' function address\n"); + } + lpOALFnTable->alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSlotiv"); + if (lpOALFnTable->alAuxiliaryEffectSlotiv == NULL) + { + OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSlotiv' function address\n"); + } + lpOALFnTable->alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)GetProcAddress(g_hOpenALDLL, "alIsAuxiliaryEffectSlot"); + if (lpOALFnTable->alIsAuxiliaryEffectSlot == NULL) + { + OutputDebugStringA("Failed to retrieve 'alIsAuxiliaryEffectSlot' function address\n"); + } + lpOALFnTable->alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)GetProcAddress(g_hOpenALDLL, "alGenAuxiliaryEffectSlots"); + if (lpOALFnTable->alGenAuxiliaryEffectSlots == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGenAuxiliaryEffectSlots' function address\n"); + } + lpOALFnTable->alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)GetProcAddress(g_hOpenALDLL, "alDeleteAuxiliaryEffectSlots"); + if (lpOALFnTable->alDeleteAuxiliaryEffectSlots == NULL) + { + OutputDebugStringA("Failed to retrieve 'alDeleteAuxiliaryEffectSlots' function address\n"); + } + lpOALFnTable->alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSlotf"); + if (lpOALFnTable->alGetAuxiliaryEffectSlotf == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSlotf' function address\n"); + } + lpOALFnTable->alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSlotfv"); + if (lpOALFnTable->alGetAuxiliaryEffectSlotfv == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSlotfv' function address\n"); + } + lpOALFnTable->alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSloti"); + if (lpOALFnTable->alGetAuxiliaryEffectSloti == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSloti' function address\n"); + } + lpOALFnTable->alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSlotiv"); + if (lpOALFnTable->alGetAuxiliaryEffectSlotiv == NULL) + { + OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSlotiv' function address\n"); + } + lpOALFnTable->alSource3i = (LPALSOURCE3I)GetProcAddress(g_hOpenALDLL, "alSource3i"); return AL_TRUE; } diff --git a/Engine/source/sfx/sfxCommon.h b/Engine/source/sfx/sfxCommon.h index 7b69b2506..a6c764ab9 100644 --- a/Engine/source/sfx/sfxCommon.h +++ b/Engine/source/sfx/sfxCommon.h @@ -153,6 +153,7 @@ enum SFXDistanceModel { SFXDistanceModelLinear, ///< Volume decreases linearly from min to max where it reaches zero. SFXDistanceModelLogarithmic, ///< Volume halves every min distance steps starting from min distance; attenuation stops at max distance. + SFXDistanceModelExponent, /// exponential falloff for distance attenuation. }; DefineEnumType( SFXDistanceModel ); @@ -187,6 +188,14 @@ inline F32 SFXDistanceAttenuation( SFXDistanceModel model, F32 minDistance, F32 gain = minDistance / ( minDistance + rolloffFactor * ( distance - minDistance ) ); break; + + ///create exponential distance model + case SFXDistanceModelExponent: + distance = getMax(distance, minDistance); + distance = getMin(distance, maxDistance); + + gain = pow((distance / minDistance), (-rolloffFactor)); + break; } @@ -313,97 +322,97 @@ class SFXFormat /// Reverb environment properties. /// /// @note A given device may not implement all properties. +///restructure our reverbproperties to match openal + class SFXReverbProperties { - public: - - typedef void Parent; - - F32 mEnvSize; - F32 mEnvDiffusion; - S32 mRoom; - S32 mRoomHF; - S32 mRoomLF; - F32 mDecayTime; - F32 mDecayHFRatio; - F32 mDecayLFRatio; - S32 mReflections; - F32 mReflectionsDelay; - F32 mReflectionsPan[ 3 ]; - S32 mReverb; - F32 mReverbDelay; - F32 mReverbPan[ 3 ]; - F32 mEchoTime; - F32 mEchoDepth; - F32 mModulationTime; - F32 mModulationDepth; - F32 mAirAbsorptionHF; - F32 mHFReference; - F32 mLFReference; - F32 mRoomRolloffFactor; - F32 mDiffusion; - F32 mDensity; - S32 mFlags; - - SFXReverbProperties() - : mEnvSize( 7.5f ), - mEnvDiffusion( 1.0f ), - mRoom( -1000 ), - mRoomHF( -100 ), - mRoomLF( 0 ), - mDecayTime( 1.49f ), - mDecayHFRatio( 0.83f ), - mDecayLFRatio( 1.0f ), - mReflections( -2602 ), - mReflectionsDelay( 0.007f ), - mReverb( 200 ), - mReverbDelay( 0.011f ), - mEchoTime( 0.25f ), - mEchoDepth( 0.0f ), - mModulationTime( 0.25f ), - mModulationDepth( 0.0f ), - mAirAbsorptionHF( -5.0f ), - mHFReference( 5000.0f ), - mLFReference( 250.0f ), - mRoomRolloffFactor( 0.0f ), - mDiffusion( 100.0f ), - mDensity( 100.0f ), - mFlags( 0 ) - { - mReflectionsPan[ 0 ] = 0.0f; - mReflectionsPan[ 1 ] = 0.0f; - mReflectionsPan[ 2 ] = 0.0f; - - mReverbPan[ 0 ] = 0.0f; - mReverbPan[ 1 ] = 0.0f; - mReverbPan[ 2 ] = 0.0f; - } - - void validate() - { - mEnvSize = mClampF( mEnvSize, 1.0f, 100.0f ); - mEnvDiffusion = mClampF( mEnvDiffusion, 0.0f, 1.0f ); - mRoom = mClamp( mRoom, -10000, 0 ); - mRoomHF = mClamp( mRoomHF, -10000, 0 ); - mRoomLF = mClamp( mRoomLF, -10000, 0 ); - mDecayTime = mClampF( mDecayTime, 0.1f, 20.0f ); - mDecayHFRatio = mClampF( mDecayHFRatio, 0.1f, 2.0f ); - mDecayLFRatio = mClampF( mDecayLFRatio, 0.1f, 2.0f ); - mReflections = mClamp( mReflections, -10000, 1000 ); - mReflectionsDelay = mClampF( mReflectionsDelay, 0.0f, 0.3f ); - mReverb = mClamp( mReverb, -10000, 2000 ); - mReverbDelay = mClampF( mReverbDelay, 0.0f, 0.1f ); - mEchoTime = mClampF( mEchoTime, 0.075f, 0.25f ); - mEchoDepth = mClampF( mEchoDepth, 0.0f, 1.0f ); - mModulationTime = mClampF( mModulationTime, 0.04f, 4.0f ); - mModulationDepth = mClampF( mModulationDepth, 0.0f, 1.0f ); - mAirAbsorptionHF = mClampF( mAirAbsorptionHF, -100.0f, 0.0f ); - mHFReference = mClampF( mHFReference, 1000.0f, 20000.0f ); - mLFReference = mClampF( mLFReference, 20.0f, 1000.0f ); - mRoomRolloffFactor = mClampF( mRoomRolloffFactor, 0.0f, 10.0f ); - mDiffusion = mClampF( mDiffusion, 0.0f, 100.0f ); - mDensity = mClampF( mDensity, 0.0f, 100.0f ); - } +public: + + struct Parent; + + float flDensity; + float flDiffusion; + float flGain; + float flGainHF; + float flGainLF; + float flDecayTime; + float flDecayHFRatio; + float flDecayLFRatio; + float flReflectionsGain; + float flReflectionsDelay; + float flReflectionsPan[3]; + float flLateReverbGain; + float flLateReverbDelay; + float flLateReverbPan[3]; + float flEchoTime; + float flEchoDepth; + float flModulationTime; + float flModulationDepth; + float flAirAbsorptionGainHF; + float flHFReference; + float flLFReference; + float flRoomRolloffFactor; + int iDecayHFLimit; + + ///set our defaults to be the same as no reverb otherwise our reverb + ///effects menu sounds + SFXReverbProperties() + { + flDensity = 0.0f; + flDiffusion = 0.0f; + flGain = 0.0f; + flGainHF = 0.0f; + flGainLF = 0.0000f; + flDecayTime = 0.0f; + flDecayHFRatio = 0.0f; + flDecayLFRatio = 0.0f; + flReflectionsGain = 0.0f; + flReflectionsDelay = 0.0f; + flReflectionsPan[3] = 0.0f; + flLateReverbGain = 0.0f; + flLateReverbDelay = 0.0f; + flLateReverbPan[3] = 0.0f; + flEchoTime = 0.0f; + flEchoDepth = 0.0f; + flModulationTime = 0.0f; + flModulationDepth = 0.0f; + flAirAbsorptionGainHF = 0.0f; + flHFReference = 0.0f; + flLFReference = 0.0f; + flRoomRolloffFactor = 0.0f; + iDecayHFLimit = 0; + } + + void validate() + { + flDensity = mClampF(flDensity, 0.0f, 1.0f); + flDiffusion = mClampF(flDiffusion, 0.0f, 1.0f); + flGain = mClampF(flGain, 0.0f, 1.0f); + flGainHF = mClampF(flGainHF, 0.0f, 1.0f); + flGainLF = mClampF(flGainLF, 0.0f, 1.0f); + flDecayTime = mClampF(flDecayTime, 0.1f, 20.0f); + flDecayHFRatio = mClampF(flDecayHFRatio, 0.1f, 2.0f); + flDecayLFRatio = mClampF(flDecayLFRatio, 0.1f, 2.0f); + flReflectionsGain = mClampF(flReflectionsGain, 0.0f, 3.16f); + flReflectionsDelay = mClampF(flReflectionsDelay, 0.0f, 0.3f); + flReflectionsPan[0] = mClampF(flReflectionsPan[0], -1.0f, 1.0f); + flReflectionsPan[1] = mClampF(flReflectionsPan[1], -1.0f, 1.0f); + flReflectionsPan[2] = mClampF(flReflectionsPan[2], -1.0f, 1.0f); + flLateReverbGain = mClampF(flLateReverbGain, 0.0f, 10.0f); + flLateReverbDelay = mClampF(flLateReverbDelay, 0.0f, 0.1f); + flLateReverbPan[0] = mClampF(flLateReverbPan[0], -1.0f, 1.0f); + flLateReverbPan[1] = mClampF(flLateReverbPan[1], -1.0f, 1.0f); + flLateReverbPan[2] = mClampF(flLateReverbPan[2], -1.0f, 1.0f); + flEchoTime = mClampF(flEchoTime, 0.075f, 0.25f); + flEchoDepth = mClampF(flEchoDepth, 0.0f, 1.0f); + flModulationTime = mClampF(flModulationTime, 0.04f, 4.0f); + flModulationDepth = mClampF(flModulationDepth, 0.0f, 1.0f); + flAirAbsorptionGainHF = mClampF(flAirAbsorptionGainHF, 0.892f, 1.0f); + flHFReference = mClampF(flHFReference, 1000.0f, 20000.0f); + flLFReference = mClampF(flLFReference, 20.0f, 1000.0f); + flRoomRolloffFactor = mClampF(flRoomRolloffFactor, 0.0f, 10.0f); + iDecayHFLimit = mClampF(iDecayHFLimit, 0, 1); + } }; @@ -415,73 +424,99 @@ class SFXReverbProperties /// Sound reverb properties. /// /// @note A given SFX device may not implement all properties. +///not in use by openal yet if u are going to use ambient reverb zones its +///probably best to not have reverb on the sound effect itself. class SFXSoundReverbProperties { - public: - - typedef void Parent; - - S32 mDirect; - S32 mDirectHF; - S32 mRoom; - S32 mRoomHF; - S32 mObstruction; - F32 mObstructionLFRatio; - S32 mOcclusion; - F32 mOcclusionLFRatio; - F32 mOcclusionRoomRatio; - F32 mOcclusionDirectRatio; - S32 mExclusion; - F32 mExclusionLFRatio; - S32 mOutsideVolumeHF; - F32 mDopplerFactor; - F32 mRolloffFactor; - F32 mRoomRolloffFactor; - F32 mAirAbsorptionFactor; - S32 mFlags; - - SFXSoundReverbProperties() - : mDirect( 0 ), - mDirectHF( 0 ), - mRoom( 0 ), - mRoomHF( 0 ), - mObstruction( 0 ), - mObstructionLFRatio( 0.0f ), - mOcclusion( 0 ), - mOcclusionLFRatio( 0.25f ), - mOcclusionRoomRatio( 1.5f ), - mOcclusionDirectRatio( 1.0f ), - mExclusion( 0 ), - mExclusionLFRatio( 1.0f ), - mOutsideVolumeHF( 0 ), - mDopplerFactor( 0.0f ), - mRolloffFactor( 0.0f ), - mRoomRolloffFactor( 0.0f ), - mAirAbsorptionFactor( 1.0f ), - mFlags( 0 ) - { - } - - void validate() - { - mDirect = mClamp( mDirect, -10000, 1000 ); - mDirectHF = mClamp( mDirectHF, -10000, 0 ); - mRoom = mClamp( mRoom, -10000, 1000 ); - mRoomHF = mClamp( mRoomHF, -10000, 0 ); - mObstruction = mClamp( mObstruction, -10000, 0 ); - mObstructionLFRatio = mClampF( mObstructionLFRatio, 0.0f, 1.0f ); - mOcclusion = mClamp( mOcclusion, -10000, 0 ); - mOcclusionLFRatio = mClampF( mOcclusionLFRatio, 0.0f, 1.0f ); - mOcclusionRoomRatio = mClampF( mOcclusionRoomRatio, 0.0f, 10.0f ); - mOcclusionDirectRatio= mClampF( mOcclusionDirectRatio, 0.0f, 10.0f ); - mExclusion = mClamp( mExclusion, -10000, 0 ); - mExclusionLFRatio = mClampF( mExclusionLFRatio, 0.0f, 1.0f ); - mOutsideVolumeHF = mClamp( mOutsideVolumeHF, -10000, 0 ); - mDopplerFactor = mClampF( mDopplerFactor, 0.0f, 10.0f ); - mRolloffFactor = mClampF( mRolloffFactor, 0.0f, 10.0f ); - mRoomRolloffFactor = mClampF( mRoomRolloffFactor, 0.0f, 10.0f ); - mAirAbsorptionFactor = mClampF( mAirAbsorptionFactor, 0.0f, 10.0f ); - } +public: + + typedef void Parent; + + float flDensity; + float flDiffusion; + float flGain; + float flGainHF; + float flGainLF; + float flDecayTime; + float flDecayHFRatio; + float flDecayLFRatio; + float flReflectionsGain; + float flReflectionsDelay; + float flReflectionsPan[3]; + float flLateReverbGain; + float flLateReverbDelay; + float flLateReverbPan[3]; + float flEchoTime; + float flEchoDepth; + float flModulationTime; + float flModulationDepth; + float flAirAbsorptionGainHF; + float flHFReference; + float flLFReference; + float flRoomRolloffFactor; + int iDecayHFLimit; + + + ///Set our defaults to have no reverb + ///if you are going to use zone reverbs its + ///probably best not to use per-voice reverb + SFXSoundReverbProperties() + { + flDensity = 0.0f; + flDiffusion = 0.0f; + flGain = 0.0f; + flGainHF = 0.0f; + flGainLF = 0.0000f; + flDecayTime = 0.0f; + flDecayHFRatio = 0.0f; + flDecayLFRatio = 0.0f; + flReflectionsGain = 0.0f; + flReflectionsDelay = 0.0f; + flReflectionsPan[3] = 0.0f; + flLateReverbGain = 0.0f; + flLateReverbDelay = 0.0f; + flLateReverbPan[3] = 0.0f; + flEchoTime = 0.0f; + flEchoDepth = 0.0f; + flModulationTime = 0.0f; + flModulationDepth = 0.0f; + flAirAbsorptionGainHF = 0.0f; + flHFReference = 0.0f; + flLFReference = 0.0f; + flRoomRolloffFactor = 0.0f; + iDecayHFLimit = 0; + } + + void validate() + { + flDensity = mClampF(flDensity, 0.0f, 1.0f); + flDiffusion = mClampF(flDiffusion, 0.0f, 1.0f); + flGain = mClampF(flGain, 0.0f, 1.0f); + flGainHF = mClampF(flGainHF, 0.0f, 1.0f); + flGainLF = mClampF(flGainLF, 0.0f, 1.0f); + flDecayTime = mClampF(flDecayTime, 0.1f, 20.0f); + flDecayHFRatio = mClampF(flDecayHFRatio, 0.1f, 2.0f); + flDecayLFRatio = mClampF(flDecayLFRatio, 0.1f, 2.0f); + flReflectionsGain = mClampF(flReflectionsGain, 0.0f, 3.16f); + flReflectionsDelay = mClampF(flReflectionsDelay, 0.0f, 0.3f); + flReflectionsPan[0] = mClampF(flReflectionsPan[0], -1.0f, 1.0f); + flReflectionsPan[1] = mClampF(flReflectionsPan[1], -1.0f, 1.0f); + flReflectionsPan[2] = mClampF(flReflectionsPan[2], -1.0f, 1.0f); + flLateReverbGain = mClampF(flLateReverbGain, 0.0f, 10.0f); + flLateReverbDelay = mClampF(flLateReverbDelay, 0.0f, 0.1f); + flLateReverbPan[0] = mClampF(flLateReverbPan[0], -1.0f, 1.0f); + flLateReverbPan[1] = mClampF(flLateReverbPan[1], -1.0f, 1.0f); + flLateReverbPan[2] = mClampF(flLateReverbPan[2], -1.0f, 1.0f); + flEchoTime = mClampF(flEchoTime, 0.075f, 0.25f); + flEchoDepth = mClampF(flEchoDepth, 0.0f, 1.0f); + flModulationTime = mClampF(flModulationTime, 0.04f, 4.0f); + flModulationDepth = mClampF(flModulationDepth, 0.0f, 1.0f); + flAirAbsorptionGainHF = mClampF(flAirAbsorptionGainHF, 0.892f, 1.0f); + flHFReference = mClampF(flHFReference, 1000.0f, 20000.0f); + flLFReference = mClampF(flLFReference, 20.0f, 1000.0f); + flRoomRolloffFactor = mClampF(flRoomRolloffFactor, 0.0f, 10.0f); + iDecayHFLimit = mClampF(iDecayHFLimit, 0, 1); + } }; diff --git a/Engine/source/sfx/sfxDescription.cpp b/Engine/source/sfx/sfxDescription.cpp index 1c82ba6a5..3b41b9b80 100644 --- a/Engine/source/sfx/sfxDescription.cpp +++ b/Engine/source/sfx/sfxDescription.cpp @@ -389,91 +389,55 @@ void SFXDescription::initPersistFields() addGroup( "Reverb" ); - addField( "useCustomReverb", TypeBool, Offset( mUseReverb, SFXDescription ), - "If true, use the reverb properties defined here on sounds.\n" - "By default, sounds will be assigned a generic reverb profile. By setting this flag to true, " - "a custom reverb setup can be defined using the \"Reverb\" properties that will then be assigned " - "to sounds playing with the description.\n\n" - "@ref SFX_reverb" ); - addField( "reverbDirect", TypeS32, Offset( mReverb.mDirect, SFXDescription ), - "Direct path level (at low and mid frequencies).\n" - "@note SUPPORTED: EAX/I3DL2/FMODSFX\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbDirectHF", TypeS32, Offset( mReverb.mDirectHF, SFXDescription ), - "Relative direct path level at high frequencies.\n" - "@note SUPPORTED: EAX/I3DL2\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbRoom", TypeS32, Offset( mReverb.mRoom, SFXDescription ), - "Room effect level (at low and mid frequencies).\n" - "@note SUPPORTED: EAX/I3DL2/FMODSFX\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbRoomHF", TypeS32, Offset( mReverb.mRoomHF, SFXDescription ), - "Relative room effect level at high frequencies.\n" - "@note SUPPORTED: EAX/I3DL2\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbObstruction", TypeS32, Offset( mReverb.mObstruction, SFXDescription ), - "Main obstruction control (attenuation at high frequencies).\n" - "@note SUPPORTED: EAX/I3DL2\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbObstructionLFRatio", TypeF32, Offset( mReverb.mObstructionLFRatio, SFXDescription ), - "Obstruction low-frequency level re. main control.\n" - "@note SUPPORTED: EAX/I3DL2\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbOcclusion", TypeS32, Offset( mReverb.mOcclusion, SFXDescription ), - "Main occlusion control (attenuation at high frequencies)." - "@note SUPPORTED: EAX/I3DL2\n\n" - "\n@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbOcclusionLFRatio", TypeF32, Offset( mReverb.mOcclusionLFRatio, SFXDescription ), - "Occlusion low-frequency level re. main control.\n" - "@note SUPPORTED: EAX/I3DL2\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbOcclusionRoomRatio", TypeF32, Offset( mReverb.mOcclusionRoomRatio, SFXDescription ), - "Relative occlusion control for room effect.\n" - "@note SUPPORTED: EAX Only\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbOcclusionDirectRatio",TypeF32, Offset( mReverb.mOcclusionDirectRatio, SFXDescription ), - "Relative occlusion control for direct path.\n" - "@note SUPPORTED: EAX Only\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbExclusion", TypeS32, Offset( mReverb.mExclusion, SFXDescription ), - "Main exclusion control (attenuation at high frequencies).\n" - "@note SUPPORTED: EAX Only\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbExclusionLFRatio", TypeF32, Offset( mReverb.mExclusionLFRatio, SFXDescription ), - "Exclusion low-frequency level re. main control.\n" - "@note SUPPORTED: EAX Only\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbOutsideVolumeHF", TypeS32, Offset( mReverb.mOutsideVolumeHF, SFXDescription ), - "Outside sound cone level at high frequencies.\n" - "@note SUPPORTED: EAX Only\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbDopplerFactor", TypeF32, Offset( mReverb.mDopplerFactor, SFXDescription ), - "Per-source doppler factor.\n" - "@note SUPPORTED: EAX Only\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbReverbRolloffFactor", TypeF32, Offset( mReverb.mRolloffFactor, SFXDescription ), - "Per-source logarithmic falloff factor.\n" - "@note SUPPORTED: EAX Only\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbRoomRolloffFactor", TypeF32, Offset( mReverb.mRoomRolloffFactor, SFXDescription ), - "Room effect falloff factor.\n" - "@note SUPPORTED: EAX/I3DL2\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbAirAbsorptionFactor", TypeF32, Offset( mReverb.mAirAbsorptionFactor, SFXDescription ), - "Multiplies SFXEnvironment::airAbsorptionHR.\n" - "@note SUPPORTED: EAX Only\n\n" - "@see http://www.atc.creative.com/algorithms/eax20.pdf" ); - addField( "reverbFlags", TypeS32, Offset( mReverb.mFlags, SFXDescription ), - "Bitfield combination of per-sound reverb flags.\n" - "@see REVERB_DIRECTHFAUTO\n" - "@see REVERB_ROOMAUTO\n" - "@see REVERB_ROOMHFAUTO\n" - "@see REVERB_INSTANCE0\n" - "@see REVERB_INSTANCE1\n" - "@see REVERB_INSTANCE2\n" - "@see REVERB_INSTANCE3\n" ); - - endGroup( "Reverb" ); + addField("useCustomReverb", TypeBool, Offset(mUseReverb, SFXDescription), + "If true, use the reverb properties defined here on sounds.\n" + "By default, sounds will be assigned a generic reverb profile. By setting this flag to true, " + "a custom reverb setup can be defined using the \"Reverb\" properties that will then be assigned " + "to sounds playing with the description.\n\n" + "@ref SFX_reverb"); + addField("reverbDensity", TypeF32, Offset(mReverb.flDensity, SFXDescription), + "Density of reverb environment."); + addField("reverbDiffusion", TypeF32, Offset(mReverb.flDiffusion, SFXDescription), + "Environment diffusion."); + addField("reverbGain", TypeF32, Offset(mReverb.flGain, SFXDescription), + "Reverb Gain Level."); + addField("reverbGainHF", TypeF32, Offset(mReverb.flGainHF, SFXDescription), + "Reverb Gain to high frequencies"); + addField("reverbGainLF", TypeF32, Offset(mReverb.flGainLF, SFXDescription), + "Reverb Gain to high frequencies"); + addField("reverbDecayTime", TypeF32, Offset(mReverb.flDecayTime, SFXDescription), + "Decay time for the reverb."); + addField("reverbDecayHFRatio", TypeF32, Offset(mReverb.flDecayHFRatio, SFXDescription), + "High frequency decay time ratio."); + addField("reverbDecayLFRatio", TypeF32, Offset(mReverb.flDecayLFRatio, SFXDescription), + "High frequency decay time ratio."); + addField("reflectionsGain", TypeF32, Offset(mReverb.flReflectionsGain, SFXDescription), + "Reflection Gain."); + addField("reflectionDelay", TypeF32, Offset(mReverb.flReflectionsDelay, SFXDescription), + "How long to delay reflections."); + addField("lateReverbGain", TypeF32, Offset(mReverb.flLateReverbGain, SFXDescription), + "Late reverb gain amount."); + addField("lateReverbDelay", TypeF32, Offset(mReverb.flLateReverbDelay, SFXDescription), + "Late reverb delay time."); + addField("reverbEchoTime", TypeF32, Offset(mReverb.flEchoTime, SFXDescription), + "Reverb echo time."); + addField("reverbEchoDepth", TypeF32, Offset(mReverb.flEchoDepth, SFXDescription), + "Reverb echo depth."); + addField("reverbModTime", TypeF32, Offset(mReverb.flModulationTime, SFXDescription), + "Reverb Modulation time."); + addField("reverbModTime", TypeF32, Offset(mReverb.flModulationDepth, SFXDescription), + "Reverb Modulation time."); + addField("airAbsorbtionGainHF", TypeF32, Offset(mReverb.flAirAbsorptionGainHF, SFXDescription), + "High Frequency air absorbtion"); + addField("reverbHFRef", TypeF32, Offset(mReverb.flHFReference, SFXDescription), + "Reverb High Frequency Reference."); + addField("reverbLFRef", TypeF32, Offset(mReverb.flLFReference, SFXDescription), + "Reverb Low Frequency Reference."); + addField("roomRolloffFactor", TypeF32, Offset(mReverb.flRoomRolloffFactor, SFXDescription), + "Rolloff factor for reverb."); + addField("decayHFLimit", TypeS32, Offset(mReverb.iDecayHFLimit, SFXDescription), + "High Frequency decay limit."); + endGroup("Reverb"); Parent::initPersistFields(); } @@ -570,24 +534,27 @@ void SFXDescription::packData( BitStream *stream ) if( mUseReverb ) { - stream->writeRangedS32( mReverb.mDirect, -10000, 1000 ); - stream->writeRangedS32( mReverb.mDirectHF, -10000, 0 ); - stream->writeRangedS32( mReverb.mRoom, -10000, 1000 ); - stream->writeRangedS32( mReverb.mRoomHF, -10000, 0 ); - stream->writeRangedS32( mReverb.mObstruction, -10000, 0 ); - stream->writeRangedF32( mReverb.mObstructionLFRatio, 0.0, 1.0, 7 ); - stream->writeRangedS32( mReverb.mOcclusion, -10000, 0 ); - stream->writeRangedF32( mReverb.mOcclusionLFRatio, 0.0, 1.0, 7 ); - stream->writeRangedF32( mReverb.mOcclusionRoomRatio, 0.0, 10.0, 7 ); - stream->writeRangedF32( mReverb.mOcclusionDirectRatio, 0.0, 10.0, 7 ); - stream->writeRangedS32( mReverb.mExclusion, -10000, 0 ); - stream->writeRangedF32( mReverb.mExclusionLFRatio, 0.0, 1.0, 7 ); - stream->writeRangedS32( mReverb.mOutsideVolumeHF, -10000, 0 ); - stream->writeRangedF32( mReverb.mDopplerFactor, 0.0, 10.0, 7 ); - stream->writeRangedF32( mReverb.mRolloffFactor, 0.0, 10.0, 7 ); - stream->writeRangedF32( mReverb.mRoomRolloffFactor, 0.0, 10.0, 7 ); - stream->writeRangedF32( mReverb.mAirAbsorptionFactor, 0.0, 10.0, 7 ); - stream->writeInt( mReverb.mFlags, 6 ); + stream->write(mReverb.flDensity); + stream->write(mReverb.flDiffusion); + stream->write(mReverb.flGain); + stream->write(mReverb.flGainHF); + stream->write(mReverb.flGainLF); + stream->write(mReverb.flDecayTime); + stream->write(mReverb.flDecayHFRatio); + stream->write(mReverb.flDecayLFRatio); + stream->write(mReverb.flReflectionsGain); + stream->write(mReverb.flReflectionsDelay); + stream->write(mReverb.flLateReverbGain); + stream->write(mReverb.flLateReverbDelay); + stream->write(mReverb.flEchoTime); + stream->write(mReverb.flEchoDepth); + stream->write(mReverb.flModulationTime); + stream->write(mReverb.flModulationDepth); + stream->write(mReverb.flAirAbsorptionGainHF); + stream->write(mReverb.flHFReference); + stream->write(mReverb.flLFReference); + stream->write(mReverb.flRoomRolloffFactor); + stream->write(mReverb.iDecayHFLimit); } } @@ -640,24 +607,27 @@ void SFXDescription::unpackData( BitStream *stream ) if( mUseReverb ) { - mReverb.mDirect = stream->readRangedS32( -10000, 1000 ); - mReverb.mDirectHF = stream->readRangedS32( -10000, 0 ); - mReverb.mRoom = stream->readRangedS32( -10000, 1000 ); - mReverb.mRoomHF = stream->readRangedS32( -10000, 0 ); - mReverb.mObstruction = stream->readRangedS32( -10000, 0 ); - mReverb.mObstructionLFRatio = stream->readRangedF32( 0.0, 1.0, 7 ); - mReverb.mOcclusion = stream->readRangedS32( -10000, 0 ); - mReverb.mOcclusionLFRatio = stream->readRangedF32( 0.0, 1.0, 7 ); - mReverb.mOcclusionRoomRatio = stream->readRangedF32( 0.0, 10.0, 7 ); - mReverb.mOcclusionDirectRatio = stream->readRangedF32( 0.0, 10.0, 7 ); - mReverb.mExclusion = stream->readRangedS32( -10000, 0 ); - mReverb.mExclusionLFRatio = stream->readRangedF32( 0.0, 1.0, 7 ); - mReverb.mOutsideVolumeHF = stream->readRangedS32( -10000, 0 ); - mReverb.mDopplerFactor = stream->readRangedF32( 0.0, 10.0, 7 ); - mReverb.mRolloffFactor = stream->readRangedF32( 0.0, 10.0, 7 ); - mReverb.mRoomRolloffFactor = stream->readRangedF32( 0.0, 10.0, 7 ); - mReverb.mAirAbsorptionFactor = stream->readRangedF32( 0.0, 10.0, 7 ); - mReverb.mFlags = stream->readInt( 6 ); + stream->read(&mReverb.flDensity); + stream->read(&mReverb.flDiffusion); + stream->read(&mReverb.flGain); + stream->read(&mReverb.flGainHF); + stream->read(&mReverb.flGainLF); + stream->read(&mReverb.flDecayTime); + stream->read(&mReverb.flDecayHFRatio); + stream->read(&mReverb.flDecayLFRatio); + stream->read(&mReverb.flReflectionsGain); + stream->read(&mReverb.flReflectionsDelay); + stream->read(&mReverb.flLateReverbGain); + stream->read(&mReverb.flLateReverbDelay); + stream->read(&mReverb.flEchoTime); + stream->read(&mReverb.flEchoDepth); + stream->read(&mReverb.flModulationTime); + stream->read(&mReverb.flModulationDepth); + stream->read(&mReverb.flAirAbsorptionGainHF); + stream->read(&mReverb.flHFReference); + stream->read(&mReverb.flLFReference); + stream->read(&mReverb.flRoomRolloffFactor); + stream->read(&mReverb.iDecayHFLimit); } } diff --git a/Engine/source/sfx/sfxDevice.h b/Engine/source/sfx/sfxDevice.h index b4d6485e3..f7dc66b77 100644 --- a/Engine/source/sfx/sfxDevice.h +++ b/Engine/source/sfx/sfxDevice.h @@ -178,6 +178,9 @@ public: /// Set the rolloff scale factor for distance attenuation of 3D sounds. virtual void setRolloffFactor( F32 factor ) {} + + /// send empty function to all sfxdevices + virtual void openSlots() {} /// Set the global reverb environment. virtual void setReverb( const SFXReverbProperties& reverb ) {} diff --git a/Engine/source/sfx/sfxEnvironment.cpp b/Engine/source/sfx/sfxEnvironment.cpp index 54bfc7d7d..780821719 100644 --- a/Engine/source/sfx/sfxEnvironment.cpp +++ b/Engine/source/sfx/sfxEnvironment.cpp @@ -144,70 +144,53 @@ void SFXEnvironment::initPersistFields() { addGroup( "Reverb" ); - addField( "envSize", TypeF32, Offset( mReverb.mEnvSize, SFXEnvironment ), - "Environment size in meters." ); - addField( "envDiffusion", TypeF32, Offset( mReverb.mEnvDiffusion, SFXEnvironment ), - "Environment diffusion." ); - addField( "room", TypeS32, Offset( mReverb.mRoom, SFXEnvironment ), - "Room effect level at mid-frequencies." ); - addField( "roomHF", TypeS32, Offset( mReverb.mRoomHF, SFXEnvironment ), - "Relative room effect level at high frequencies." ); - addField( "roomLF", TypeS32, Offset( mReverb.mRoomLF, SFXEnvironment ), - "Relative room effect level at low frequencies." ); - addField( "decayTime", TypeF32, Offset( mReverb.mDecayTime, SFXEnvironment ), - "Reverberation decay time at mid frequencies." ); - addField( "decayHFRatio", TypeF32, Offset( mReverb.mDecayHFRatio, SFXEnvironment ), - "High-frequency to mid-frequency decay time ratio." ); - addField( "decayLFRatio", TypeF32, Offset( mReverb.mDecayLFRatio, SFXEnvironment ), - "Low-frequency to mid-frequency decay time ratio." ); - addField( "reflections", TypeS32, Offset( mReverb.mReflections, SFXEnvironment ), - "Early reflections level relative to room effect." ); - addField( "reflectionsDelay", TypeF32, Offset( mReverb.mReflectionsDelay, SFXEnvironment ), - "Initial reflection delay time." ); - addField( "reflectionsPan", TypeF32, Offset( mReverb.mReflectionsPan, SFXEnvironment ), 3, - "Early reflections panning vector." ); - addField( "reverb", TypeS32, Offset( mReverb.mReverb, SFXEnvironment ), - "Late reverberation level relative to room effect." ); - addField( "reverbDelay", TypeF32, Offset( mReverb.mReverbDelay, SFXEnvironment ), - "Late reverberation delay time relative to initial reflection." ); - addField( "reverbPan", TypeF32, Offset( mReverb.mReverbPan, SFXEnvironment ), 3, - "Late reverberation panning vector." ); - addField( "echoTime", TypeF32, Offset( mReverb.mEchoTime, SFXEnvironment ), - "Echo time." ); - addField( "echoDepth", TypeF32, Offset( mReverb.mEchoDepth, SFXEnvironment ), - "Echo depth." ); - addField( "modulationTime", TypeF32, Offset( mReverb.mModulationTime, SFXEnvironment ), - "Modulation time." ); - addField( "modulationDepth", TypeF32, Offset( mReverb.mModulationDepth, SFXEnvironment ), - "Modulation depth." ); - addField( "airAbsorptionHF", TypeF32, Offset( mReverb.mAirAbsorptionHF, SFXEnvironment ), - "Change in level per meter at high frequencies." ); - addField( "HFReference", TypeF32, Offset( mReverb.mHFReference, SFXEnvironment ), - "Reference high frequency in Hertz." ); - addField( "LFReference", TypeF32, Offset( mReverb.mLFReference, SFXEnvironment ), - "Reference low frequency in Hertz." ); - addField( "roomRolloffFactor", TypeF32, Offset( mReverb.mRoomRolloffFactor, SFXEnvironment ), - "Logarithmic distance attenuation rolloff scale factor for reverb room size effect." ); - addField( "diffusion", TypeF32, Offset( mReverb.mDiffusion, SFXEnvironment ), - "Value that controls the echo density in the late reverberation decay." ); - addField( "density", TypeF32, Offset( mReverb.mDensity, SFXEnvironment ), - "Value that controls the modal density in the late reverberation decay." ); - addField( "flags", TypeS32, Offset( mReverb.mFlags, SFXEnvironment ), - "A bitfield of reverb flags.\n" - "@see REVERB_DECAYTIMESCALE\n" - "@see REVERB_REFLECTIONSSCALE\n" - "@see REVERB_REFLECTIONSDELAYSCALE\n" - "@see REVERB_REVERBSCALE\n" - "@see REVERB_REVERBDELAYSCALE\n" - "@see REVERB_DECAYHFLIMIT\n" - "@see REVERB_ECHOTIMESCALE\n" - "@see REVERB_MODULATIONTIMESCALE\n" - "@see REVERB_CORE0\n" - "@see REVERB_CORE1\n" - "@see REVERB_HIGHQUALITYREVERB\n" - "@see REVERB_HIGHQUALITYDPL2REVERB\n" ); - - endGroup( "Reverb" ); + addField("reverbDensity", TypeF32, Offset(mReverb.flDensity, SFXEnvironment), + "Density of reverb environment."); + addField("reverbDiffusion", TypeF32, Offset(mReverb.flDiffusion, SFXEnvironment), + "Environment diffusion."); + addField("reverbGain", TypeF32, Offset(mReverb.flGain, SFXEnvironment), + "Reverb Gain Level."); + addField("reverbGainHF", TypeF32, Offset(mReverb.flGainHF, SFXEnvironment), + "Reverb Gain to high frequencies"); + addField("reverbGainLF", TypeF32, Offset(mReverb.flGainLF, SFXEnvironment), + "Reverb Gain to high frequencies"); + addField("reverbDecayTime", TypeF32, Offset(mReverb.flDecayTime, SFXEnvironment), + "Decay time for the reverb."); + addField("reverbDecayHFRatio", TypeF32, Offset(mReverb.flDecayHFRatio, SFXEnvironment), + "High frequency decay time ratio."); + addField("reverbDecayLFRatio", TypeF32, Offset(mReverb.flDecayLFRatio, SFXEnvironment), + "High frequency decay time ratio."); + addField("reflectionsGain", TypeF32, Offset(mReverb.flReflectionsGain, SFXEnvironment), + "Reflection Gain."); + addField("reflectionDelay", TypeF32, Offset(mReverb.flReflectionsDelay, SFXEnvironment), + "How long to delay reflections."); + addField("reflectionsPan", TypeF32, Offset(mReverb.flReflectionsPan, SFXEnvironment), 3, + "Reflection reverberation panning vector."); + addField("lateReverbGain", TypeF32, Offset(mReverb.flLateReverbGain, SFXEnvironment), + "Late reverb gain amount."); + addField("lateReverbDelay", TypeF32, Offset(mReverb.flLateReverbDelay, SFXEnvironment), + "Late reverb delay time."); + addField("lateReverbPan", TypeF32, Offset(mReverb.flLateReverbPan, SFXEnvironment), 3, + "Late reverberation panning vector."); + addField("reverbEchoTime", TypeF32, Offset(mReverb.flEchoTime, SFXEnvironment), + "Reverb echo time."); + addField("reverbEchoDepth", TypeF32, Offset(mReverb.flEchoDepth, SFXEnvironment), + "Reverb echo depth."); + addField("reverbModTime", TypeF32, Offset(mReverb.flModulationTime, SFXEnvironment), + "Reverb Modulation time."); + addField("reverbModDepth", TypeF32, Offset(mReverb.flModulationDepth, SFXEnvironment), + "Reverb Modulation time."); + addField("airAbsorbtionGainHF", TypeF32, Offset(mReverb.flAirAbsorptionGainHF, SFXEnvironment), + "High Frequency air absorbtion"); + addField("reverbHFRef", TypeF32, Offset(mReverb.flHFReference, SFXEnvironment), + "Reverb High Frequency Reference."); + addField("reverbLFRef", TypeF32, Offset(mReverb.flLFReference, SFXEnvironment), + "Reverb Low Frequency Reference."); + addField("roomRolloffFactor", TypeF32, Offset(mReverb.flRoomRolloffFactor, SFXEnvironment), + "Rolloff factor for reverb."); + addField("decayHFLimit", TypeS32, Offset(mReverb.iDecayHFLimit, SFXEnvironment), + "High Frequency decay limit."); + endGroup("Reverb"); Parent::initPersistFields(); } @@ -257,35 +240,27 @@ void SFXEnvironment::packData( BitStream* stream ) { Parent::packData( stream ); - stream->write( mReverb.mEnvSize ); - stream->write( mReverb.mEnvDiffusion ); - stream->write( mReverb.mRoom ); - stream->write( mReverb.mRoomHF ); - stream->write( mReverb.mRoomLF ); - stream->write( mReverb.mDecayTime ); - stream->write( mReverb.mDecayHFRatio ); - stream->write( mReverb.mDecayLFRatio ); - stream->write( mReverb.mReflections ); - stream->write( mReverb.mReflectionsDelay ); - stream->write( mReverb.mReflectionsPan[ 0 ] ); - stream->write( mReverb.mReflectionsPan[ 1 ] ); - stream->write( mReverb.mReflectionsPan[ 2 ] ); - stream->write( mReverb.mReverb ); - stream->write( mReverb.mReverbDelay ); - stream->write( mReverb.mReverbPan[ 0 ] ); - stream->write( mReverb.mReverbPan[ 1 ] ); - stream->write( mReverb.mReverbPan[ 2 ] ); - stream->write( mReverb.mEchoTime ); - stream->write( mReverb.mEchoDepth ); - stream->write( mReverb.mModulationTime ); - stream->write( mReverb.mModulationDepth ); - stream->write( mReverb.mAirAbsorptionHF ); - stream->write( mReverb.mHFReference ); - stream->write( mReverb.mLFReference ); - stream->write( mReverb.mRoomRolloffFactor ); - stream->write( mReverb.mDiffusion ); - stream->write( mReverb.mDensity ); - stream->write( mReverb.mFlags ); + stream->write(mReverb.flDensity); + stream->write(mReverb.flDiffusion); + stream->write(mReverb.flGain); + stream->write(mReverb.flGainHF); + stream->write(mReverb.flGainLF); + stream->write(mReverb.flDecayTime); + stream->write(mReverb.flDecayHFRatio); + stream->write(mReverb.flDecayLFRatio); + stream->write(mReverb.flReflectionsGain); + stream->write(mReverb.flReflectionsDelay); + stream->write(mReverb.flLateReverbGain); + stream->write(mReverb.flLateReverbDelay); + stream->write(mReverb.flEchoTime); + stream->write(mReverb.flEchoDepth); + stream->write(mReverb.flModulationTime); + stream->write(mReverb.flModulationDepth); + stream->write(mReverb.flAirAbsorptionGainHF); + stream->write(mReverb.flHFReference); + stream->write(mReverb.flLFReference); + stream->write(mReverb.flRoomRolloffFactor); + stream->write(mReverb.iDecayHFLimit); } //----------------------------------------------------------------------------- @@ -294,33 +269,25 @@ void SFXEnvironment::unpackData( BitStream* stream ) { Parent::unpackData( stream ); - stream->read( &mReverb.mEnvSize ); - stream->read( &mReverb.mEnvDiffusion ); - stream->read( &mReverb.mRoom ); - stream->read( &mReverb.mRoomHF ); - stream->read( &mReverb.mRoomLF ); - stream->read( &mReverb.mDecayTime ); - stream->read( &mReverb.mDecayHFRatio ); - stream->read( &mReverb.mDecayLFRatio ); - stream->read( &mReverb.mReflections ); - stream->read( &mReverb.mReflectionsDelay ); - stream->read( &mReverb.mReflectionsPan[ 0 ] ); - stream->read( &mReverb.mReflectionsPan[ 1 ] ); - stream->read( &mReverb.mReflectionsPan[ 2 ] ); - stream->read( &mReverb.mReverb ); - stream->read( &mReverb.mReverbDelay ); - stream->read( &mReverb.mReverbPan[ 0 ] ); - stream->read( &mReverb.mReverbPan[ 1 ] ); - stream->read( &mReverb.mReverbPan[ 2 ] ); - stream->read( &mReverb.mEchoTime ); - stream->read( &mReverb.mEchoDepth ); - stream->read( &mReverb.mModulationTime ); - stream->read( &mReverb.mModulationDepth ); - stream->read( &mReverb.mAirAbsorptionHF ); - stream->read( &mReverb.mHFReference ); - stream->read( &mReverb.mLFReference ); - stream->read( &mReverb.mRoomRolloffFactor ); - stream->read( &mReverb.mDiffusion ); - stream->read( &mReverb.mDensity ); - stream->read( &mReverb.mFlags ); + stream->read(&mReverb.flDensity); + stream->read(&mReverb.flDiffusion); + stream->read(&mReverb.flGain); + stream->read(&mReverb.flGainHF); + stream->read(&mReverb.flGainLF); + stream->read(&mReverb.flDecayTime); + stream->read(&mReverb.flDecayHFRatio); + stream->read(&mReverb.flDecayLFRatio); + stream->read(&mReverb.flReflectionsGain); + stream->read(&mReverb.flReflectionsDelay); + stream->read(&mReverb.flLateReverbGain); + stream->read(&mReverb.flLateReverbDelay); + stream->read(&mReverb.flEchoTime); + stream->read(&mReverb.flEchoDepth); + stream->read(&mReverb.flModulationTime); + stream->read(&mReverb.flModulationDepth); + stream->read(&mReverb.flAirAbsorptionGainHF); + stream->read(&mReverb.flHFReference); + stream->read(&mReverb.flLFReference); + stream->read(&mReverb.flRoomRolloffFactor); + stream->read(&mReverb.iDecayHFLimit); } diff --git a/Engine/source/sfx/sfxSound.cpp b/Engine/source/sfx/sfxSound.cpp index 683f70cda..6b4895f80 100644 --- a/Engine/source/sfx/sfxSound.cpp +++ b/Engine/source/sfx/sfxSound.cpp @@ -81,6 +81,7 @@ SFXSound::SFXSound( SFXProfile *profile, SFXDescription* desc ) : Parent( profile, desc ), mVoice( NULL ) { + mSetPositionValue = 0; } //----------------------------------------------------------------------------- @@ -411,6 +412,9 @@ void SFXSound::_play() Platform::outputDebugString( "[SFXSound] virtualizing playback of source '%i'", getId() ); #endif } + if(getPosition() != mSetPositionValue) + setPosition(mSetPositionValue); + mSetPositionValue = 0; //Non looping sounds need this to reset. } //----------------------------------------------------------------------------- @@ -421,6 +425,7 @@ void SFXSound::_stop() if( mVoice ) mVoice->stop(); + mSetPositionValue = 0; } //----------------------------------------------------------------------------- @@ -431,6 +436,7 @@ void SFXSound::_pause() if( mVoice ) mVoice->pause(); + mSetPositionValue = getPosition(); } //----------------------------------------------------------------------------- @@ -511,6 +517,8 @@ void SFXSound::_updatePriority() U32 SFXSound::getPosition() const { + if( getLastStatus() == SFXStatusStopped) + return mSetPositionValue; if( mVoice ) return mVoice->getFormat().getDuration( mVoice->getPosition() ); else @@ -522,6 +530,8 @@ U32 SFXSound::getPosition() const void SFXSound::setPosition( U32 ms ) { AssertFatal( ms < getDuration(), "SFXSound::setPosition() - position out of range" ); + mSetPositionValue = ms; + if( mVoice ) mVoice->setPosition( mVoice->getFormat().getSampleCount( ms ) ); else @@ -693,8 +703,9 @@ DefineEngineMethod( SFXSound, setPosition, void, ( F32 position ),, "playback will resume at the given position when play() is called.\n\n" "@param position The new position of the play cursor (in seconds).\n" ) { - if( position >= 0 && position <= object->getDuration() ) - object->setPosition( position * 1000.0f ); + position *= 1000.0f; + if( position >= 0 && position < object->getDuration() ) + object->setPosition( position ); } //----------------------------------------------------------------------------- diff --git a/Engine/source/sfx/sfxSound.h b/Engine/source/sfx/sfxSound.h index 16c8b0b28..364f2ed59 100644 --- a/Engine/source/sfx/sfxSound.h +++ b/Engine/source/sfx/sfxSound.h @@ -81,6 +81,9 @@ class SFXSound : public SFXSource, /// _initBuffer() used for managing virtual sources. U32 mDuration; + ///Used for setPosition (time in miliseconds) + U32 mSetPositionValue; + /// Create a new voice for this source. bool _allocVoice( SFXDevice* device ); diff --git a/Engine/source/sfx/sfxSystem.cpp b/Engine/source/sfx/sfxSystem.cpp index ac292702c..34db19902 100644 --- a/Engine/source/sfx/sfxSystem.cpp +++ b/Engine/source/sfx/sfxSystem.cpp @@ -94,6 +94,9 @@ ImplementEnumType( SFXDistanceModel, { SFXDistanceModelLogarithmic, "Logarithmic", "Volume attenuates logarithmically starting from the reference distance and halving every reference distance step from there on. " "Attenuation stops at max distance but volume won't reach zero." }, + { SFXDistanceModelExponent, "Exponential", + "Volume attenuates exponentially starting from the reference distance and attenuating every reference distance step by the rolloff factor. " + "Attenuation stops at max distance but volume won't reach zero." }, EndImplementEnumType; ImplementEnumType( SFXChannel, @@ -473,6 +476,9 @@ bool SFXSystem::createDevice( const String& providerName, const String& deviceNa mDevice->setDistanceModel( mDistanceModel ); mDevice->setDopplerFactor( mDopplerFactor ); mDevice->setRolloffFactor( mRolloffFactor ); + //OpenAL requires slots for effects, this creates an empty function + //that will run when a sfxdevice is created. + mDevice->openSlots(); mDevice->setReverb( mReverb ); // Signal system. diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 981288f28..4e29f64d0 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -1159,7 +1159,7 @@ void DiffuseVertColorFeatureGLSL::processVert( Vector< ShaderComponent* >& comp outColor->setStructName( "OUT" ); outColor->setType( "vec4" ); - output = new GenOp( " @ = @;\r\n", outColor, inColor ); + output = new GenOp( " @ = @.bgra;\r\n", outColor, inColor ); } else output = NULL; // Nothing we need to do. diff --git a/Engine/source/sqlite/SQLiteObject.cpp b/Engine/source/sqlite/SQLiteObject.cpp index 4cba76720..7153e8740 100644 --- a/Engine/source/sqlite/SQLiteObject.cpp +++ b/Engine/source/sqlite/SQLiteObject.cpp @@ -519,30 +519,33 @@ void SQLiteObject::escapeSingleQuotes(const char* source, char *dest) // calls the C++ class function. // FIX: change all these to DefineEngineMethod! -ConsoleMethod(SQLiteObject, openDatabase, bool, 3, 3, "(const char* filename) Opens the database specifed by filename. Returns true or false.") +DefineEngineMethod(SQLiteObject, openDatabase, bool, (const char* filename),, "(const char* filename) Opens the database specifed by filename. Returns true or false.") { - return object->OpenDatabase(argv[2]); + return object->OpenDatabase(filename); } -DefineEngineMethod(SQLiteObject, loadOrSaveDb, bool, (const char* filename, bool isSave), , +DefineEngineMethod(SQLiteObject, loadOrSaveDb, bool, (const char* filename, bool isSave),, "Loads or saves a cached database from the disk db specifed by filename. Second argument determines loading (false) or saving (true). Returns true or false.") { return object->loadOrSaveDb(filename, isSave); } -ConsoleMethod(SQLiteObject, closeDatabase, void, 2, 2, "Closes the active database.") +DefineEngineMethod(SQLiteObject, closeDatabase, void, (),, "Closes the active database.") { object->CloseDatabase(); } -ConsoleMethod(SQLiteObject, query, S32, 4, 0, "(const char* sql, S32 mode) Performs an SQL query on the open database and returns an identifier to a valid result set. mode is currently unused, and is reserved for future use.") + + +DefineEngineStringlyVariadicMethod(SQLiteObject, query, S32, 1, 5, + "(const char* sql, S32 mode) Performs an SQL query on the open database and returns an identifier to a valid result set. mode is currently unused, and is reserved for future use.") { S32 iCount; S32 iIndex, iLen, iNewIndex, iArg, iArgLen, i; char* szNew; if (argc == 4) - return object->ExecuteSQL(argv[2]); + return object->ExecuteSQL(argv[1]); else if (argc > 4) { // Support for printf type querys, as per Ben Garney's suggestion @@ -552,10 +555,10 @@ ConsoleMethod(SQLiteObject, query, S32, 4, 0, "(const char* sql, S32 mode) Perfo // scan the query and count the question marks iCount = 0; - iLen = dStrlen(argv[2]); + iLen = dStrlen(argv[1]); for (iIndex = 0; iIndex < iLen; iIndex++) { - if (argv[2][iIndex] == '?') + if (argv[1][iIndex] == '?') iCount++; } @@ -567,7 +570,7 @@ ConsoleMethod(SQLiteObject, query, S32, 4, 0, "(const char* sql, S32 mode) Perfo // so now we need to calc the length of the new query string. This is easily achieved. // We simply take our base string length, subtract the question marks, then add in // the number of total characters used by our arguments. - iLen = dStrlen(argv[2]) - iCount; + iLen = dStrlen(argv[1]) - iCount; for (iIndex = 1; iIndex <= iCount; iIndex++) { iLen = iLen + dStrlen(argv[iIndex + 3]); @@ -576,12 +579,12 @@ ConsoleMethod(SQLiteObject, query, S32, 4, 0, "(const char* sql, S32 mode) Perfo szNew = new char[iLen]; // now we need to replace all the question marks with the actual arguments - iLen = dStrlen(argv[2]); + iLen = dStrlen(argv[1]); iNewIndex = 0; iArg = 1; for (iIndex = 0; iIndex <= iLen; iIndex++) { - if (argv[2][iIndex] == '?') + if (argv[1][iIndex] == '?') { // ok we need to replace this question mark with the actual argument // and iterate our pointers and everything as needed. This is no doubt @@ -600,79 +603,79 @@ ConsoleMethod(SQLiteObject, query, S32, 4, 0, "(const char* sql, S32 mode) Perfo } else - szNew[iNewIndex] = argv[2][iIndex]; + szNew[iNewIndex] = argv[1][iIndex]; iNewIndex++; } } else return 0; // incorrect number of question marks vs arguments - Con::printf("Old SQL: %s\nNew SQL: %s", argv[2].getStringValue(), szNew); + Con::printf("Old SQL: %s\nNew SQL: %s", argv[1].getStringValue(), szNew); return object->ExecuteSQL(szNew); } return 0; } -ConsoleMethod(SQLiteObject, clearResult, void, 3, 3, "(S32 resultSet) Clears memory used by the specified result set, and deletes the result set.") +DefineEngineMethod(SQLiteObject, clearResult, void, (S32 resultSet),, "(S32 resultSet) Clears memory used by the specified result set, and deletes the result set.") { - object->ClearResultSet(dAtoi(argv[2])); + object->ClearResultSet(resultSet); } -ConsoleMethod(SQLiteObject, nextRow, void, 3, 3, "(S32 resultSet) Moves the result set's row pointer to the next row.") +DefineEngineMethod(SQLiteObject, nextRow, void, (S32 resultSet),, "(S32 resultSet) Moves the result set's row pointer to the next row.") { sqlite_resultset* pResultSet; - pResultSet = object->GetResultSet(dAtoi(argv[2])); + pResultSet = object->GetResultSet(resultSet); if (pResultSet) { pResultSet->iCurrentRow++; } } -ConsoleMethod(SQLiteObject, previousRow, void, 3, 3, "(S32 resultSet) Moves the result set's row pointer to the previous row") +DefineEngineMethod(SQLiteObject, previousRow, void, (S32 resultSet),, "(S32 resultSet) Moves the result set's row pointer to the previous row") { sqlite_resultset* pResultSet; - pResultSet = object->GetResultSet(dAtoi(argv[2])); + pResultSet = object->GetResultSet(resultSet); if (pResultSet) { pResultSet->iCurrentRow--; } } -ConsoleMethod(SQLiteObject, firstRow, void, 3, 3, "(S32 resultSet) Moves the result set's row pointer to the very first row in the result set.") +DefineEngineMethod(SQLiteObject, firstRow, void, (S32 resultSet),, "(S32 resultSet) Moves the result set's row pointer to the very first row in the result set.") { sqlite_resultset* pResultSet; - pResultSet = object->GetResultSet(dAtoi(argv[2])); + pResultSet = object->GetResultSet(resultSet); if (pResultSet) { pResultSet->iCurrentRow = 0; } } -ConsoleMethod(SQLiteObject, lastRow, void, 3, 3, "(S32 resultSet) Moves the result set's row pointer to the very last row in the result set.") +DefineEngineMethod(SQLiteObject, lastRow, void, (S32 resultSet),, "(S32 resultSet) Moves the result set's row pointer to the very last row in the result set.") { sqlite_resultset* pResultSet; - pResultSet = object->GetResultSet(dAtoi(argv[2])); + pResultSet = object->GetResultSet(resultSet); if (pResultSet) { pResultSet->iCurrentRow = pResultSet->iNumRows - 1; } } -ConsoleMethod(SQLiteObject, setRow, void, 4, 4, "(S32 resultSet S32 row) Moves the result set's row pointer to the row specified. Row indices start at 1 not 0.") +DefineEngineMethod(SQLiteObject, setRow, void, (S32 resultSet, S32 row),, "(S32 resultSet S32 row) Moves the result set's row pointer to the row specified. Row indices start at 1 not 0.") { sqlite_resultset* pResultSet; - pResultSet = object->GetResultSet(dAtoi(argv[2])); + pResultSet = object->GetResultSet(resultSet); if (pResultSet) { - pResultSet->iCurrentRow = dAtoi(argv[3]) - 1; + pResultSet->iCurrentRow = row - 1; } } -ConsoleMethod(SQLiteObject, getRow, S32, 3, 3, "(S32 resultSet) Returns what row the result set's row pointer is currently on.") +DefineEngineMethod(SQLiteObject, getRow, S32, (S32 resultSet),, "(S32 resultSet) Returns what row the result set's row pointer is currently on.") { sqlite_resultset* pResultSet; - pResultSet = object->GetResultSet(dAtoi(argv[2])); + pResultSet = object->GetResultSet(resultSet); if (pResultSet) { return pResultSet->iCurrentRow + 1; @@ -681,10 +684,10 @@ ConsoleMethod(SQLiteObject, getRow, S32, 3, 3, "(S32 resultSet) Returns what row return 0; } -ConsoleMethod(SQLiteObject, numRows, S32, 3, 3, "(S32 resultSet) Returns the number of rows in the result set.") +DefineEngineMethod(SQLiteObject, numRows, S32, (S32 resultSet),, "(S32 resultSet) Returns the number of rows in the result set.") { sqlite_resultset* pResultSet; - pResultSet = object->GetResultSet(dAtoi(argv[2])); + pResultSet = object->GetResultSet(resultSet); if (pResultSet) { return pResultSet->iNumRows; @@ -693,10 +696,10 @@ ConsoleMethod(SQLiteObject, numRows, S32, 3, 3, "(S32 resultSet) Returns the num return 0; } -ConsoleMethod(SQLiteObject, numColumns, S32, 3, 3, "(S32 resultSet) Returns the number of columns in the result set.") +DefineEngineMethod(SQLiteObject, numColumns, S32, (S32 resultSet),, "(S32 resultSet) Returns the number of columns in the result set.") { sqlite_resultset* pResultSet; - pResultSet = object->GetResultSet(dAtoi(argv[2])); + pResultSet = object->GetResultSet(resultSet); if (pResultSet) { return pResultSet->iNumCols; @@ -705,33 +708,33 @@ ConsoleMethod(SQLiteObject, numColumns, S32, 3, 3, "(S32 resultSet) Returns the return 0; } -ConsoleMethod(SQLiteObject, endOfResult, bool, 3, 3, "(S32 resultSet) Checks to see if the internal pointer for the specified result set is at the end, indicating there are no more rows left to read.") +DefineEngineMethod(SQLiteObject, endOfResult, bool, (S32 resultSet),, "(S32 resultSet) Checks to see if the internal pointer for the specified result set is at the end, indicating there are no more rows left to read.") { - return object->EndOfResult(dAtoi(argv[2])); + return object->EndOfResult(resultSet); } -ConsoleMethod(SQLiteObject, EOR, bool, 3, 3, "(S32 resultSet) Same as endOfResult().") +DefineEngineMethod(SQLiteObject, EOR, bool, (S32 resultSet),, "(S32 resultSet) Same as endOfResult().") { - return object->EndOfResult(dAtoi(argv[2])); + return object->EndOfResult(resultSet); } -ConsoleMethod(SQLiteObject, EOF, bool, 3, 3, "(S32 resultSet) Same as endOfResult().") +DefineEngineMethod(SQLiteObject, EOFile, bool, (S32 resultSet),, "(S32 resultSet) Same as endOfResult().") { - return object->EndOfResult(dAtoi(argv[2])); + return object->EndOfResult(resultSet); } -ConsoleMethod(SQLiteObject, getColumnIndex, S32, 4, 4, "(resultSet columnName) Looks up the specified column name in the specified result set, and returns the columns index number. A return value of 0 indicates the lookup failed for some reason (usually this indicates you specified a column name that doesn't exist or is spelled wrong).") +DefineEngineMethod(SQLiteObject, getColumnIndex, S32, (S32 resultSet, String columnName),, "(resultSet columnName) Looks up the specified column name in the specified result set, and returns the columns index number. A return value of 0 indicates the lookup failed for some reason (usually this indicates you specified a column name that doesn't exist or is spelled wrong).") { - return object->GetColumnIndex(dAtoi(argv[2]), argv[3]); + return object->GetColumnIndex(resultSet, columnName); } -ConsoleMethod(SQLiteObject, getColumnName, const char *, 4, 4, "(resultSet columnIndex) Looks up the specified column index in the specified result set, and returns the column's name. A return value of an empty string indicates the lookup failed for some reason (usually this indicates you specified a column index that is invalid or exceeds the number of columns in the result set). Columns are index starting with 1 not 0") +DefineEngineMethod(SQLiteObject, getColumnName, const char *, (S32 resultSet, S32 columnIndex), , "(resultSet columnIndex) Looks up the specified column index in the specified result set, and returns the column's name. A return value of an empty string indicates the lookup failed for some reason (usually this indicates you specified a column index that is invalid or exceeds the number of columns in the result set). Columns are index starting with 1 not 0") { sqlite_resultset* pResultSet; sqlite_resultrow* pRow; S32 iColumn; - pResultSet = object->GetResultSet(dAtoi(argv[2])); + pResultSet = object->GetResultSet(resultSet); if (pResultSet) { pRow = pResultSet->vRows[pResultSet->iCurrentRow]; @@ -739,7 +742,7 @@ ConsoleMethod(SQLiteObject, getColumnName, const char *, 4, 4, "(resultSet colum return ""; // We assume they specified column by index. If they know the column name they wouldn't be calling this function :) - iColumn = dAtoi(argv[3]); + iColumn = columnIndex; if (iColumn == 0) return ""; // column indices start at 1, not 0 @@ -753,90 +756,91 @@ ConsoleMethod(SQLiteObject, getColumnName, const char *, 4, 4, "(resultSet colum return ""; } -ConsoleMethod(SQLiteObject, getColumn, const char *, 4, 4, "(resultSet column) Returns the value of the specified column (Column can be specified by name or index) in the current row of the specified result set. If the call fails, the returned string will indicate the error.") +DefineEngineStringlyVariadicMethod(SQLiteObject, getColumn, const char *, 4, 4, "(resultSet column) Returns the value of the specified column (Column can be specified by name or index) in the current row of the specified result set. If the call fails, the returned string will indicate the error.") { - sqlite_resultset* pResultSet; - sqlite_resultrow* pRow; - S32 iColumn; + sqlite_resultset* pResultSet; + sqlite_resultrow* pRow; + S32 iColumn; - pResultSet = object->GetResultSet(dAtoi(argv[2])); - if (pResultSet) - { - if (pResultSet->vRows.size() == 0) - return "NULL"; + pResultSet = object->GetResultSet(dAtoi(argv[2])); + if (pResultSet) + { + if (pResultSet->vRows.size() == 0) + return "NULL"; - pRow = pResultSet->vRows[pResultSet->iCurrentRow]; - if (!pRow) - return "invalid_row"; + pRow = pResultSet->vRows[pResultSet->iCurrentRow]; + if (!pRow) + return "invalid_row"; - // Is column specified by a name or an index? - iColumn = dAtoi(argv[3]); - if (iColumn == 0) - { - // column was specified by a name - iColumn = object->GetColumnIndex(dAtoi(argv[2]), argv[3]); - // if this is still 0 then we have some error - if (iColumn == 0) - return "invalid_column"; - } + // Is column specified by a name or an index? + iColumn = dAtoi(argv[3]); + if (iColumn == 0) + { + // column was specified by a name + iColumn = object->GetColumnIndex(dAtoi(argv[2]), argv[3]); + // if this is still 0 then we have some error + if (iColumn == 0) + return "invalid_column"; + } - // We temporarily padded the index in GetColumnIndex() so we could return a - // 0 for error. So now we need to drop it back down. - iColumn--; + // We temporarily padded the index in GetColumnIndex() so we could return a + // 0 for error. So now we need to drop it back down. + iColumn--; - // now we should have an index for our column data - if (pRow->vColumnValues[iColumn]) - return pRow->vColumnValues[iColumn]; - else - return "NULL"; - } - else - return "invalid_result_set"; + // now we should have an index for our column data + if (pRow->vColumnValues[iColumn]) + return pRow->vColumnValues[iColumn]; + else + return "NULL"; + } + else + return "invalid_result_set"; } -ConsoleMethod(SQLiteObject, getColumnNumeric, F32, 4, 4, "(resultSet column) Returns the value of the specified column (Column can be specified by name or index) in the current row of the specified result set. If the call fails, the returned string will indicate the error.") +DefineEngineStringlyVariadicMethod(SQLiteObject, getColumnNumeric, F32, 4, 4, "(resultSet column) Returns the value of the specified column (Column can be specified by name or index) in the current row of the specified result set. If the call fails, the returned string will indicate the error.") { - sqlite_resultset* pResultSet; - sqlite_resultrow* pRow; - S32 iColumn; + sqlite_resultset* pResultSet; + sqlite_resultrow* pRow; + S32 iColumn; - pResultSet = object->GetResultSet(dAtoi(argv[2])); - if (pResultSet) - { + pResultSet = object->GetResultSet(dAtoi(argv[2])); + if (pResultSet) + { - if (pResultSet->vRows.size() == 0) - return -1; + if (pResultSet->vRows.size() == 0) + return -1; - pRow = pResultSet->vRows[pResultSet->iCurrentRow]; - if (!pRow) - return -1;//"invalid_row"; + pRow = pResultSet->vRows[pResultSet->iCurrentRow]; + if (!pRow) + return -1;//"invalid_row"; - // Is column specified by a name or an index? - iColumn = dAtoi(argv[3]); - if (iColumn == 0) - { - // column was specified by a name - iColumn = object->GetColumnIndex(dAtoi(argv[2]), argv[3]); - // if this is still 0 then we have some error - if (iColumn == 0) - return -1;//"invalid_column"; - } + // Is column specified by a name or an index? + iColumn = dAtoi(argv[3]); + if (iColumn == 0) + { + // column was specified by a name + iColumn = object->GetColumnIndex(dAtoi(argv[2]), argv[3]); + // if this is still 0 then we have some error + if (iColumn == 0) + return -1;//"invalid_column"; + } - // We temporarily padded the index in GetColumnIndex() so we could return a - // 0 for error. So now we need to drop it back down. - iColumn--; + // We temporarily padded the index in GetColumnIndex() so we could return a + // 0 for error. So now we need to drop it back down. + iColumn--; - // now we should have an index for our column data - if (pRow->vColumnValues[iColumn]) - return dAtof(pRow->vColumnValues[iColumn]); - else - return 0; - } - else - return -1;//"invalid_result_set"; + // now we should have an index for our column data + if (pRow->vColumnValues[iColumn]) + return dAtof(pRow->vColumnValues[iColumn]); + else + return 0; + } + else + return -1;//"invalid_result_set"; } -ConsoleMethod(SQLiteObject, escapeString, const char *, 3, 3, "(string) Escapes the given string, making it safer to pass into a query.") + +DefineEngineMethod(SQLiteObject, escapeString, const char *, (String string),, "(string) Escapes the given string, making it safer to pass into a query.") { // essentially what we need to do here is scan the string for any occurrences of: ', ", and \ // and prepend them with a slash: \', \", \\ @@ -848,14 +852,14 @@ ConsoleMethod(SQLiteObject, escapeString, const char *, 3, 3, "(string) Escapes char* szNew; iCount = 0; - iLen = dStrlen(argv[2]); + iLen = dStrlen(string); for (iIndex = 0; iIndex < iLen; iIndex++) { - if (argv[2][iIndex] == '\'') + if (string[iIndex] == '\'') iCount++; - else if (argv[2][iIndex] == '\"') + else if (string[iIndex] == '\"') iCount++; - else if (argv[2][iIndex] == '\\') + else if (string[iIndex] == '\\') iCount++; } @@ -864,26 +868,26 @@ ConsoleMethod(SQLiteObject, escapeString, const char *, 3, 3, "(string) Escapes iNewIndex = 0; for (iIndex = 0; iIndex <= iLen; iIndex++) { - if (argv[2][iIndex] == '\'') + if (string[iIndex] == '\'') { szNew[iNewIndex] = '\\'; iNewIndex++; szNew[iNewIndex] = '\''; } - else if (argv[2][iIndex] == '\"') + else if (string[iIndex] == '\"') { szNew[iNewIndex] = '\\'; iNewIndex++; szNew[iNewIndex] = '\"'; } - else if (argv[2][iIndex] == '\\') + else if (string[iIndex] == '\\') { szNew[iNewIndex] = '\\'; iNewIndex++; szNew[iNewIndex] = '\\'; } else - szNew[iNewIndex] = argv[2][iIndex]; + szNew[iNewIndex] = string[iIndex]; iNewIndex++; } @@ -894,12 +898,12 @@ ConsoleMethod(SQLiteObject, escapeString, const char *, 3, 3, "(string) Escapes } -ConsoleMethod(SQLiteObject, numResultSets, S32, 2, 2, "numResultSets()") +DefineEngineMethod(SQLiteObject, numResultSets, S32, (),, "numResultSets()") { return object->numResultSets(); } -ConsoleMethod(SQLiteObject, getLastRowId, S32, 2, 2, "getLastRowId()") +DefineEngineMethod(SQLiteObject, getLastRowId, S32, (), , "getLastRowId()") { return object->getLastRowId(); } \ No newline at end of file diff --git a/Engine/source/terrain/terrImport.cpp b/Engine/source/terrain/terrImport.cpp index 063a80c93..abdb1a6c2 100644 --- a/Engine/source/terrain/terrImport.cpp +++ b/Engine/source/terrain/terrImport.cpp @@ -31,6 +31,8 @@ #include "util/noise2d.h" #include "core/volume.h" +#include "T3D/Scene.h" + using namespace Torque; DefineEngineStaticMethod( TerrainBlock, createNew, S32, (String terrainName, U32 resolution, String materialName, bool genNoise),, @@ -108,9 +110,9 @@ DefineEngineStaticMethod( TerrainBlock, createNew, S32, (String terrainName, U32 terrain->registerObject( terrainName.c_str() ); // Add to mission group! - SimGroup *missionGroup; - if( Sim::findObject( "MissionGroup", missionGroup ) ) - missionGroup->addObject( terrain ); + Scene* scene = Scene::getRootScene(); + if(scene) + scene->addObject( terrain ); return terrain->getId(); } @@ -245,10 +247,10 @@ DefineEngineStaticMethod( TerrainBlock, import, S32, (String terrainName, String terrain->import( (*heightmap), heightScale, metersPerPixel, layerMap, materials, flipYAxis ); terrain->registerObject(); - // Add to mission group! - SimGroup *missionGroup; - if ( Sim::findObject( "MissionGroup", missionGroup ) ) - missionGroup->addObject( terrain ); + // Add to scene! + Scene* scene = Scene::getRootScene(); + if (scene) + scene->addObject( terrain ); } return terrain->getId(); diff --git a/Engine/source/ts/collada/colladaImport.cpp b/Engine/source/ts/collada/colladaImport.cpp index cab5311ff..8206bb0a5 100644 --- a/Engine/source/ts/collada/colladaImport.cpp +++ b/Engine/source/ts/collada/colladaImport.cpp @@ -126,13 +126,14 @@ static void processNode(GuiTreeViewCtrl* tree, domNode* node, S32 parentID, Scen } } -DefineEngineFunction( enumColladaForImport, bool, (const char * shapePath, const char * ctrl), , +DefineEngineFunction( enumColladaForImport, bool, (const char * shapePath, const char * ctrl, bool loadCachedDts), ("", "", true), "(string shapePath, GuiTreeViewCtrl ctrl) Collect scene information from " "a COLLADA file and store it in a GuiTreeView control. This function is " "used by the COLLADA import gui to show a preview of the scene contents " "prior to import, and is probably not much use for anything else.\n" "@param shapePath COLLADA filename\n" "@param ctrl GuiTreeView control to add elements to\n" + "@param loadCachedDts dictates if it should try and load the cached dts file if it exists" "@return true if successful, false otherwise\n" "@ingroup Editors\n" "@internal") @@ -147,7 +148,7 @@ DefineEngineFunction( enumColladaForImport, bool, (const char * shapePath, const // Check if a cached DTS is available => no need to import the collada file // if we can load the DTS instead Torque::Path path(shapePath); - if (ColladaShapeLoader::canLoadCachedDTS(path)) + if (loadCachedDts && ColladaShapeLoader::canLoadCachedDTS(path)) return false; // Check if this is a Sketchup file (.kmz) and if so, mount the zip filesystem diff --git a/Engine/source/ts/collada/colladaLights.cpp b/Engine/source/ts/collada/colladaLights.cpp index fcc4bb67d..574478cab 100644 --- a/Engine/source/ts/collada/colladaLights.cpp +++ b/Engine/source/ts/collada/colladaLights.cpp @@ -30,6 +30,7 @@ #include "T3D/pointLight.h" #include "T3D/spotLight.h" +#include "T3D/Scene.h" //----------------------------------------------------------------------------- // Collada elements are very similar, but are arranged as separate, unrelated @@ -140,11 +141,11 @@ static void processNodeLights(AppNode* appNode, const MatrixF& offset, SimGroup* // Load lights from a collada file and add to the scene. DefineEngineFunction( loadColladaLights, bool, (const char * filename, const char * parentGroup, const char * baseObject), ("", ""), - "(string filename, SimGroup parentGroup=MissionGroup, SimObject baseObject=-1)" + "(string filename, SimGroup parentGroup=Scene, SimObject baseObject=-1)" "Load all light instances from a COLLADA (.dae) file and add to the scene.\n" "@param filename COLLADA filename to load lights from\n" "@param parentGroup (optional) name of an existing simgroup to add the new " - "lights to (defaults to MissionGroup)\n" + "lights to (defaults to root Scene)\n" "@param baseObject (optional) name of an object to use as the origin (useful " "if you are loading the lights for a collada scene and have moved or rotated " "the geometry)\n" @@ -165,16 +166,16 @@ DefineEngineFunction( loadColladaLights, bool, (const char * filename, const cha Torque::Path path(filename); // Optional group to add the lights to. Create if it does not exist, and use - // the MissionGroup if not specified. - SimGroup* missionGroup = dynamic_cast(Sim::findObject("MissionGroup")); + // the root Scene if not specified. + Scene* scene = Scene::getRootScene(); SimGroup* group = 0; if (!String::isEmpty(parentGroup)){ if (!Sim::findObject(parentGroup, group)) { // Create the group if it could not be found group = new SimGroup; if (group->registerObject(parentGroup)) { - if (missionGroup) - missionGroup->addObject(group); + if (scene) + scene->addObject(group); } else { delete group; @@ -183,7 +184,7 @@ DefineEngineFunction( loadColladaLights, bool, (const char * filename, const cha } } if (!group) - group = missionGroup; + group = scene; // Optional object to provide the base transform MatrixF offset(true); diff --git a/Engine/source/ts/loader/tsShapeLoader.cpp b/Engine/source/ts/loader/tsShapeLoader.cpp index 581f2a384..6cebbc7e0 100644 --- a/Engine/source/ts/loader/tsShapeLoader.cpp +++ b/Engine/source/ts/loader/tsShapeLoader.cpp @@ -412,7 +412,7 @@ void TSShapeLoader::generateObjects() AppMesh* mesh = subshape->objMeshes[iMesh]; mesh->detailSize = 2; String name = String::GetTrailingNumber( mesh->getName(), mesh->detailSize ); - name = getUniqueName( name, cmpMeshNameAndSize, meshNames, &(subshape->objMeshes), (void*)mesh->detailSize ); + name = getUniqueName( name, cmpMeshNameAndSize, meshNames, &(subshape->objMeshes), (void*)(uintptr_t)mesh->detailSize ); meshNames.push_back( name ); // Fix up any collision details that don't have a negative detail level. diff --git a/Engine/source/ts/tsShapeConstruct.cpp b/Engine/source/ts/tsShapeConstruct.cpp index c77802895..cefb769f7 100644 --- a/Engine/source/ts/tsShapeConstruct.cpp +++ b/Engine/source/ts/tsShapeConstruct.cpp @@ -74,9 +74,9 @@ EndImplementEnumType; //----------------------------------------------------------------------------- -String TSShapeConstructor::smCapsuleShapePath("core/art/shapes/unit_capsule.dts"); -String TSShapeConstructor::smCubeShapePath("core/art/shapes/unit_cube.dts"); -String TSShapeConstructor::smSphereShapePath("core/art/shapes/unit_sphere.dts"); +String TSShapeConstructor::smCapsuleShapePath("tools/shapes/unit_capsule.dts"); +String TSShapeConstructor::smCubeShapePath("tools/shapes/unit_cube.dts"); +String TSShapeConstructor::smSphereShapePath("tools/shapes/unit_sphere.dts"); ResourceRegisterPostLoadSignal< TSShape > TSShapeConstructor::_smAutoLoad( &TSShapeConstructor::_onTSShapeLoaded ); ResourceRegisterUnloadSignal< TSShape > TSShapeConstructor::_smAutoUnload( &TSShapeConstructor::_onTSShapeUnloaded ); diff --git a/Engine/source/windowManager/sdl/sdlWindow.cpp b/Engine/source/windowManager/sdl/sdlWindow.cpp index 914ca90ac..dbf182955 100644 --- a/Engine/source/windowManager/sdl/sdlWindow.cpp +++ b/Engine/source/windowManager/sdl/sdlWindow.cpp @@ -598,6 +598,7 @@ void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt) SDL_GetWindowSize( mWindowHandle, &width, &height ); mVideoMode.resolution.set( width, height ); getGFXTarget()->resetMode(); + resizeEvent.trigger(getWindowId(), width, height); break; } diff --git a/Engine/source/windowManager/sdl/sdlWindowMgr.cpp b/Engine/source/windowManager/sdl/sdlWindowMgr.cpp index f503c4fb1..5be1ae53d 100644 --- a/Engine/source/windowManager/sdl/sdlWindowMgr.cpp +++ b/Engine/source/windowManager/sdl/sdlWindowMgr.cpp @@ -21,6 +21,7 @@ //----------------------------------------------------------------------------- #include "windowManager/sdl/sdlWindowMgr.h" +#include "platformSDL/sdlInputManager.h" #include "gfx/gfxDevice.h" #include "core/util/journal/process.h" #include "core/strings/unicode.h" @@ -269,6 +270,13 @@ void PlatformWindowManagerSDL::_process() SDL_Event evt; while( SDL_PollEvent(&evt) ) { + if (evt.type >= SDL_JOYAXISMOTION && evt.type <= SDL_CONTROLLERDEVICEREMAPPED) + { + SDLInputManager* mgr = static_cast(Input::getManager()); + if (mgr) + mgr->processEvent(evt); + continue; + } switch(evt.type) { case SDL_QUIT: @@ -356,15 +364,16 @@ void PlatformWindowManagerSDL::_process() case(SDL_DROPCOMPLETE): { - if (!Con::isFunction("onDropEnd")) - break; - - Con::executef("onDropEnd"); + if (Con::isFunction("onDropEnd")) + Con::executef("onDropEnd"); + break; } default: { - //Con::printf("Event: %d", evt.type); +#ifdef TORQUE_DEBUG + Con::warnf("Unhandled SDL input event: 0x%04x", evt.type); +#endif } } } @@ -495,10 +504,12 @@ void InitWindowingSystem() AFTER_MODULE_INIT(gfx) { +#if !defined(TORQUE_DEDICATED) int res = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS | SDL_INIT_NOPARACHUTE); AssertFatal(res != -1, avar("SDL error:%s", SDL_GetError())); // By default, SDL enables text input. We disable it on initialization, and // we will enable it whenever the time is right. SDL_StopTextInput(); +#endif } diff --git a/Engine/source/windowManager/windowInputGenerator.cpp b/Engine/source/windowManager/windowInputGenerator.cpp index 435f88e7b..f2391d553 100644 --- a/Engine/source/windowManager/windowInputGenerator.cpp +++ b/Engine/source/windowManager/windowInputGenerator.cpp @@ -33,7 +33,6 @@ extern InputModifiers convertModifierBits(const U32 in); // Constructor/Destructor //----------------------------------------------------------------------------- WindowInputGenerator::WindowInputGenerator( PlatformWindow *window ) : - mNotifyPosition(true), mWindow(window), mInputController(NULL), mLastCursorPos(0,0), @@ -135,6 +134,7 @@ void WindowInputGenerator::handleMouseMove( WindowId did, U32 modifier, S32 x, S // Because of this we always have to generate and send off for processing // relative events, even if the mouse is not locked. // I'm considering removing this in the Canvas refactor, thoughts? [7/6/2007 justind] + // Now sends the absolute position event whenever an absolute position is received from the OS. [2/13/2019 mar] // Generate a base Movement along and Axis event InputEventInfo event; @@ -192,33 +192,23 @@ void WindowInputGenerator::handleMouseMove( WindowId did, U32 modifier, S32 x, S } - // When the window gains focus, we send a cursor position event - if( mNotifyPosition ) - { - mNotifyPosition = false; + // We use SI_MAKE to signify that the position is being set, not relatively moved. + event.action = SI_MAKE; - // We use SI_MAKE to signify that the position is being set, not relatively moved. - event.action = SI_MAKE; + // X Axis + event.objInst = SI_XAXIS; + event.fValue = (F32)x; + generateInputEvent(event); - // X Axis - event.objInst = SI_XAXIS; - event.fValue = (F32)x; - generateInputEvent(event); - - // Y Axis - event.objInst = SI_YAXIS; - event.fValue = (F32)y; - generateInputEvent(event); - } + // Y Axis + event.objInst = SI_YAXIS; + event.fValue = (F32)y; + generateInputEvent(event); mLastCursorPos = Point2I(x,y); - } else - { mLastCursorPos += Point2I(x,y); - mNotifyPosition = true; - } } void WindowInputGenerator::handleMouseButton( WindowId did, U32 modifiers, U32 action, U16 button ) @@ -388,8 +378,6 @@ void WindowInputGenerator::handleAppEvent( WindowId did, S32 event ) } else if(event == GainFocus) { - // Set an update flag to notify the consumer of the absolute mouse position next move - mNotifyPosition = true; mFocused = true; } diff --git a/Engine/source/windowManager/windowInputGenerator.h b/Engine/source/windowManager/windowInputGenerator.h index a5e9175c3..f4c3d2a76 100644 --- a/Engine/source/windowManager/windowInputGenerator.h +++ b/Engine/source/windowManager/windowInputGenerator.h @@ -37,8 +37,6 @@ class PlatformWindow; class WindowInputGenerator { - bool mNotifyPosition; - protected: PlatformWindow *mWindow; diff --git a/Templates/BaseGame/game/core/Core.cs b/Templates/BaseGame/game/core/Core.cs index 5559760ae..99efdd706 100644 --- a/Templates/BaseGame/game/core/Core.cs +++ b/Templates/BaseGame/game/core/Core.cs @@ -20,10 +20,11 @@ function CoreModule::onCreate(%this) ModuleDatabase.LoadExplicit( "Core_Rendering" ); ModuleDatabase.LoadExplicit( "Core_Utility" ); ModuleDatabase.LoadExplicit( "Core_GUI" ); - ModuleDatabase.LoadExplicit( "CoreModule" ); ModuleDatabase.LoadExplicit( "Core_Lighting" ); ModuleDatabase.LoadExplicit( "Core_SFX" ); ModuleDatabase.LoadExplicit( "Core_PostFX" ); + ModuleDatabase.LoadExplicit( "Core_Components" ); + ModuleDatabase.LoadExplicit( "Core_GameObjects" ); ModuleDatabase.LoadExplicit( "Core_ClientServer" ); %prefPath = getPrefpath(); @@ -32,63 +33,6 @@ function CoreModule::onCreate(%this) else exec("data/defaults.cs"); - %der = $pref::Video::displayDevice; - - //We need to hook the missing/warn material stuff early, so do it here - /*$Core::MissingTexturePath = "core/images/missingTexture"; - $Core::UnAvailableTexturePath = "core/images/unavailable"; - $Core::WarningTexturePath = "core/images/warnMat"; - $Core::CommonShaderPath = "core/shaders"; - - /*%classList = enumerateConsoleClasses( "Component" ); - - foreach$( %componentClass in %classList ) - { - echo("Native Component of type: " @ %componentClass); - }*/ - - //exec("./helperFunctions.cs"); - - // We need some of the default GUI profiles in order to get the canvas and - // other aspects of the GUI system ready. - //exec("./profiles.cs"); - - //This is a bit of a shortcut, but we'll load the client's default settings to ensure all the prefs get initialized correctly - - - // Initialization of the various subsystems requires some of the preferences - // to be loaded... so do that first. - /*exec("./globals.cs"); - - exec("./canvas.cs"); - exec("./cursor.cs"); - - exec("./renderManager.cs"); - exec("./lighting.cs"); - - exec("./audio.cs"); - exec("./sfx/audioAmbience.cs"); - exec("./sfx/audioData.cs"); - exec("./sfx/audioDescriptions.cs"); - exec("./sfx/audioEnvironments.cs"); - exec("./sfx/audioStates.cs"); - - exec("./parseArgs.cs"); - - // Materials and Shaders for rendering various object types - exec("./gfxData/commonMaterialData.cs"); - exec("./gfxData/shaders.cs"); - exec("./gfxData/terrainBlock.cs"); - exec("./gfxData/water.cs"); - exec("./gfxData/scatterSky.cs"); - exec("./gfxData/clouds.cs"); - - // Initialize all core post effects. - exec("./postFx.cs"); - - //VR stuff - exec("./oculusVR.cs");*/ - // Seed the random number generator. setRandomSeed(); diff --git a/Templates/BaseGame/game/core/Core.module b/Templates/BaseGame/game/core/Core.module index c7ab7b64b..b9a2490e3 100644 --- a/Templates/BaseGame/game/core/Core.module +++ b/Templates/BaseGame/game/core/Core.module @@ -5,15 +5,4 @@ ScriptFile="Core.cs" CreateFunction="onCreate" DestroyFunction="onDestroy" - Group="Core"> - - - \ No newline at end of file + Group="Core"/> \ No newline at end of file diff --git a/Templates/BaseGame/game/core/clientServer/Core_ClientServer.cs b/Templates/BaseGame/game/core/clientServer/Core_ClientServer.cs index 51a7fbe76..1866adc12 100644 --- a/Templates/BaseGame/game/core/clientServer/Core_ClientServer.cs +++ b/Templates/BaseGame/game/core/clientServer/Core_ClientServer.cs @@ -18,7 +18,7 @@ function Core_ClientServer::create( %this ) exec( "./scripts/client/client.cs" ); exec( "./scripts/server/server.cs" ); - $Game::MissionGroup = "MissionGroup"; + $Game::MainScene = getScene(0); initServer(); diff --git a/Templates/BaseGame/game/core/clientServer/scripts/client/connectionToServer.cs b/Templates/BaseGame/game/core/clientServer/scripts/client/connectionToServer.cs index 693c7fff7..11df6afd6 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/client/connectionToServer.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/client/connectionToServer.cs @@ -43,7 +43,7 @@ function GameConnection::initialControlSet(%this) // first check if the editor is active if (!isToolBuild() || !isMethod("Editor", "checkActiveLoadDone") || !Editor::checkActiveLoadDone()) { - if (Canvas.getContent() != PlayGui.getId()) + if (isObject(PlayGui) && Canvas.getContent() != PlayGui.getId()) Canvas.setContent(PlayGui); } } diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/levelInfo.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/levelInfo.cs index 51df91204..7da9a992e 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/levelInfo.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/levelInfo.cs @@ -115,7 +115,7 @@ function sendLoadInfoToClient( %client ) function parseMissionGroup( %className, %childGroup ) { if( getWordCount( %childGroup ) == 0) - %currentGroup = "MissionGroup"; + %currentGroup = getScene(0); else %currentGroup = %childGroup; @@ -136,7 +136,7 @@ function parseMissionGroup( %className, %childGroup ) function parseMissionGroupForIds( %className, %childGroup ) { if( getWordCount( %childGroup ) == 0) - %currentGroup = $Game::MissionGroup; + %currentGroup = getScene(0); else %currentGroup = %childGroup; diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs index 92801318d..32da4e9dd 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs @@ -98,9 +98,9 @@ function loadMissionStage2() // Exec the mission. The MissionGroup (loaded components) is added to the ServerGroup exec(%file); - if( !isObject(MissionGroup) ) + if( !isObject(getScene(0)) ) { - $Server::LoadFailMsg = "No 'MissionGroup' found in mission \"" @ %file @ "\"."; + $Server::LoadFailMsg = "No Scene found in level \"" @ %file @ "\"."; } } @@ -141,7 +141,7 @@ function loadMissionStage2() function endMission() { - if (!isObject( MissionGroup )) + if (!isObject( getScene(0) )) return; echo("*** ENDING MISSION"); @@ -159,7 +159,7 @@ function endMission() } // Delete everything - MissionGroup.delete(); + getScene(0).delete(); MissionCleanup.delete(); clearServerPaths(); diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs index 17f127314..47be979db 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs @@ -243,7 +243,7 @@ function onServerDestroyed() { physicsStopSimulation("server"); - if (!isObject( MissionGroup )) + if (!isObject( getScene(0) )) return; echo("*** ENDING MISSION"); @@ -262,7 +262,7 @@ function onServerDestroyed() } // Delete everything - MissionGroup.delete(); + getScene(0).delete(); MissionCleanup.delete(); clearServerPaths(); diff --git a/Templates/BaseGame/game/core/components/components/actionAnimationComponent.asset.taml b/Templates/BaseGame/game/core/components/components/actionAnimationComponent.asset.taml new file mode 100644 index 000000000..36d5b9a90 --- /dev/null +++ b/Templates/BaseGame/game/core/components/components/actionAnimationComponent.asset.taml @@ -0,0 +1,8 @@ + diff --git a/Templates/BaseGame/game/core/components/components/aiControllerComponent.asset.taml b/Templates/BaseGame/game/core/components/components/aiControllerComponent.asset.taml new file mode 100644 index 000000000..0111cd999 --- /dev/null +++ b/Templates/BaseGame/game/core/components/components/aiControllerComponent.asset.taml @@ -0,0 +1,8 @@ + diff --git a/Templates/BaseGame/game/core/components/components/armAnimationComponent.asset.taml b/Templates/BaseGame/game/core/components/components/armAnimationComponent.asset.taml new file mode 100644 index 000000000..d9fd4ef80 --- /dev/null +++ b/Templates/BaseGame/game/core/components/components/armAnimationComponent.asset.taml @@ -0,0 +1,8 @@ + diff --git a/Templates/BaseGame/game/core/components/components/game/controlObject.cs b/Templates/BaseGame/game/core/components/components/game/controlObject.cs deleted file mode 100644 index 7f477ecca..000000000 --- a/Templates/BaseGame/game/core/components/components/game/controlObject.cs +++ /dev/null @@ -1,89 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//----------------------------------------------------------------------------- - -//registerComponent("ControlObjectComponent", "Component", "Control Object", "Game", false, "Allows the behavior owner to operate as a camera."); - -function ControlObjectComponent::onAdd(%this) -{ - %this.addComponentField(clientOwner, "The shape to use for rendering", "int", "1", ""); - - %clientID = %this.getClientID(); - - if(%clientID && !isObject(%clientID.getControlObject())) - %clientID.setControlObject(%this.owner); -} - -function ControlObjectComponent::onRemove(%this) -{ - %clientID = %this.getClientID(); - - if(%clientID) - %clientID.setControlObject(0); -} - -function ControlObjectComponent::onClientConnect(%this, %client) -{ - if(%this.isControlClient(%client) && !isObject(%client.getControlObject())) - %client.setControlObject(%this.owner); -} - -function ControlObjectComponent::onClientDisconnect(%this, %client) -{ - if(%this.isControlClient(%client)) - %client.setControlObject(0); -} - -function ControlObjectComponent::getClientID(%this) -{ - return ClientGroup.getObject(%this.clientOwner-1); -} - -function ControlObjectComponent::isControlClient(%this, %client) -{ - %clientID = ClientGroup.getObject(%this.clientOwner-1); - - if(%client.getID() == %clientID) - return true; - else - return false; -} - -function ControlObjectComponent::onInspectorUpdate(%this, %field) -{ - %clientID = %this.getClientID(); - - if(%clientID && !isObject(%clientID.getControlObject())) - %clientID.setControlObject(%this.owner); -} - -function switchControlObject(%client, %newControlEntity) -{ - if(!isObject(%client) || !isObject(%newControlEntity)) - return error("SwitchControlObject: No client or target controller!"); - - %control = %newControlEntity.getComponent(ControlObjectComponent); - - if(!isObject(%control)) - return error("SwitchControlObject: Target controller has no conrol object behavior!"); - - %client.setControlObject(%newControlEntity); -} \ No newline at end of file diff --git a/Templates/BaseGame/game/core/shapes/materials.cs b/Templates/BaseGame/game/core/shapes/materials.cs new file mode 100644 index 000000000..2911ca4d2 --- /dev/null +++ b/Templates/BaseGame/game/core/shapes/materials.cs @@ -0,0 +1,16 @@ +//--- noshape.dts MATERIALS BEGIN --- +singleton Material(noshape_NoShape) +{ + mapTo = "NoShape"; + + diffuseMap[0] = ""; + diffuseColor[0] = "0.8 0.003067 0 .8"; + emissive[0] = 0; + doubleSided = false; + translucent = 1; + translucentBlendOp = "LerpAlpha"; + castShadows = false; + materialTag0 = "WorldEditor"; +}; + +//--- noshape.dts MATERIALS END --- diff --git a/Templates/BaseGame/game/core/shapes/noshape.dts b/Templates/BaseGame/game/core/shapes/noshape.dts new file mode 100644 index 000000000..a7a64cf10 Binary files /dev/null and b/Templates/BaseGame/game/core/shapes/noshape.dts differ diff --git a/Templates/BaseGame/game/core/shapes/noshape.mb b/Templates/BaseGame/game/core/shapes/noshape.mb new file mode 100644 index 000000000..24330c1db Binary files /dev/null and b/Templates/BaseGame/game/core/shapes/noshape.mb differ diff --git a/Templates/BaseGame/game/core/utility/Core_Utility.cs b/Templates/BaseGame/game/core/utility/Core_Utility.cs index d412f3544..e38d474d5 100644 --- a/Templates/BaseGame/game/core/utility/Core_Utility.cs +++ b/Templates/BaseGame/game/core/utility/Core_Utility.cs @@ -4,6 +4,8 @@ function Core_Utility::onCreate(%this) exec("./scripts/parseArgs.cs"); exec("./scripts/globals.cs"); exec("./scripts/helperFunctions.cs"); + exec("./scripts/gameObjectManagement.cs"); + exec("./scripts/persistanceManagement.cs"); } function Core_Utility::onDestroy(%this) diff --git a/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.cs b/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.cs new file mode 100644 index 000000000..f496111eb --- /dev/null +++ b/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.cs @@ -0,0 +1,181 @@ + +//Game Object management +function findGameObject(%name) +{ + //find all GameObjectAssets + %assetQuery = new AssetQuery(); + if(!AssetDatabase.findAssetType(%assetQuery, "GameObjectAsset")) + return 0; //if we didn't find ANY, just exit + + %count = %assetQuery.getCount(); + + for(%i=0; %i < %count; %i++) + { + %assetId = %assetQuery.getAsset(%i); + + //%assetName = AssetDatabase.getAssetName(%assetId); + + if(%assetId $= %name) + { + %gameObjectAsset = AssetDatabase.acquireAsset(%assetId); + + %assetQuery.delete(); + return %gameObjectAsset; + } + } + + %assetQuery.delete(); + return 0; +} + +function spawnGameObject(%name, %addToScene) +{ + if(%addToScene $= "") + %addToScene = true; + + //First, check if this already exists in our GameObjectPool + if(isObject(GameObjectPool)) + { + %goCount = GameObjectPool.countKey(%name); + + //if we have some already in the pool, pull it out and use that + if(%goCount != 0) + { + %goIdx = GameObjectPool.getIndexFromKey(%name); + %go = GameObjectPool.getValue(%goIdx); + + %go.setHidden(false); + %go.setScopeAlways(); + + if(%addToMissionGroup == true) //save instance when saving level + getScene(0).add(%go); + else // clear instance on level exit + MissionCleanup.add(%go); + + //remove from the object pool's list + GameObjectPool.erase(%goIdx); + + return %go; + } + } + + //We have no existing pool, or no existing game objects of this type, so spawn a new one + + %gameObjectAsset = findGameObject(%name); + + if(isObject(%gameObjectAsset)) + { + %newSGOObject = TamlRead(%gameObjectAsset.TAMLFilePath); + + if(%addToScene == true) //save instance when saving level + getScene(0).add(%newSGOObject); + else // clear instance on level exit + MissionCleanup.add(%newSGOObject); + + return %newSGOObject; + } + + return 0; +} + +function saveGameObject(%name, %tamlPath, %scriptPath) +{ + %gameObjectAsset = findGameObject(%name); + + //find if it already exists. If it does, we'll update it, if it does not, we'll make a new asset + if(isObject(%gameObjectAsset)) + { + %assetID = %gameObjectAsset.getAssetId(); + + %gameObjectAsset.TAMLFilePath = %tamlPath; + %gameObjectAsset.scriptFilePath = %scriptPath; + + TAMLWrite(%gameObjectAsset, AssetDatabase.getAssetFilePath(%assetID)); + AssetDatabase.refreshAsset(%assetID); + } + else + { + //Doesn't exist, so make a new one + %gameObjectAsset = new GameObjectAsset() + { + assetName = %name @ "Asset"; + gameObjectName = %name; + TAMLFilePath = %tamlPath; + scriptFilePath = %scriptPath; + }; + + //Save it alongside the taml file + %path = filePath(%tamlPath); + + TAMLWrite(%gameObjectAsset, %path @ "/" @ %name @ ".asset.taml"); + AssetDatabase.refreshAllAssets(true); + } +} + +//Allocates a number of a game object into a pool to be pulled from as needed +function allocateGameObjects(%name, %amount) +{ + //First, we need to make sure our pool exists + if(!isObject(GameObjectPool)) + { + new ArrayObject(GameObjectPool); + } + + //Next, we loop and generate our game objects, and add them to the pool + for(%i=0; %i < %amount; %i++) + { + %go = spawnGameObject(%name, false); + + //When our object is in the pool, it's not "real", so we need to make sure + //that we don't ghost it to clients untill we actually spawn it. + %go.clearScopeAlways(); + + //We also hide it, so that we don't 'exist' in the scene until we spawn + %go.hidden = true; + + //Lastly, add us to the pool, with the key being our game object type + GameObjectPool.add(%name, %go); + } +} + +function Entity::delete(%this) +{ + //we want to intercept the delete call, and add it to our GameObjectPool + //if it's a game object + if(%this.gameObjectAsset !$= "") + { + %this.setHidden(true); + %this.clearScopeAlways(); + + if(!isObject(GameObjectPool)) + { + new ArrayObject(GameObjectPool); + } + + GameObjectPool.add(%this.gameObjectAsset, %this); + + %missionSet = %this.getGroup(); + %missionSet.remove(%this); + } + else + { + %this.superClass.delete(); + } +} + +function clearGameObjectPool() +{ + if(isObject(GameObjectPool)) + { + %count = GameObjectPool.count(); + + for(%i=0; %i < %count; %i++) + { + %go = GameObjectPool.getValue(%i); + + %go.superClass.delete(); + } + + GameObjectPool.empty(); + } +} \ No newline at end of file diff --git a/Templates/BaseGame/game/core/utility/scripts/globals.cs b/Templates/BaseGame/game/core/utility/scripts/globals.cs index fcf52390a..adb035fdc 100644 --- a/Templates/BaseGame/game/core/utility/scripts/globals.cs +++ b/Templates/BaseGame/game/core/utility/scripts/globals.cs @@ -36,9 +36,6 @@ $pref::Input::JoystickEnabled = 0; // Set directory paths for various data or default images. $pref::Video::ProfilePath = "core/rendering/scripts/gfxprofile"; -/*$pref::Video::missingTexturePath = "core/images/missingTexture.png"; -$pref::Video::unavailableTexturePath = "core/images/unavailable.png"; -$pref::Video::warningTexturePath = "core/images/warnMat.dds";*/ $pref::Video::disableVerticalSync = 1; $pref::Video::mode = "800 600 false 32 60 4"; diff --git a/Templates/BaseGame/game/core/utility/scripts/helperFunctions.cs b/Templates/BaseGame/game/core/utility/scripts/helperFunctions.cs index 8abe3e6e6..d620d08b1 100644 --- a/Templates/BaseGame/game/core/utility/scripts/helperFunctions.cs +++ b/Templates/BaseGame/game/core/utility/scripts/helperFunctions.cs @@ -636,503 +636,6 @@ function mvReset() // There are others. } -//Persistance Manager tests - -new PersistenceManager(TestPManager); - -function runPManTest(%test) -{ - if (!isObject(TestPManager)) - return; - - if (%test $= "") - %test = 100; - - switch(%test) - { - case 0: - TestPManager.testFieldUpdates(); - case 1: - TestPManager.testObjectRename(); - case 2: - TestPManager.testNewObject(); - case 3: - TestPManager.testNewGroup(); - case 4: - TestPManager.testMoveObject(); - case 5: - TestPManager.testObjectRemove(); - case 100: - TestPManager.testFieldUpdates(); - TestPManager.testObjectRename(); - TestPManager.testNewObject(); - TestPManager.testNewGroup(); - TestPManager.testMoveObject(); - TestPManager.testObjectRemove(); - } -} - -function TestPManager::testFieldUpdates(%doNotSave) -{ - // Set some objects as dirty - TestPManager.setDirty(AudioGui); - TestPManager.setDirty(AudioSim); - TestPManager.setDirty(AudioMessage); - - // Alter some of the existing fields - AudioEffect.isLooping = true; - AudioMessage.isLooping = true; - AudioEffect.is3D = true; - - // Test removing a field - TestPManager.removeField(AudioGui, "isLooping"); - - // Alter some of the persistent fields - AudioGui.referenceDistance = 0.8; - AudioMessage.referenceDistance = 0.8; - - // Add some new dynamic fields - AudioGui.foo = "bar"; - AudioEffect.foo = "bar"; - - // Remove an object from the dirty list - // It shouldn't get updated in the file - TestPManager.removeDirty(AudioEffect); - - // Dirty an object in another file as well - TestPManager.setDirty(WarningMaterial); - - // Update a field that doesn't exist - WarningMaterial.glow[0] = true; - - // Drity another object to test for crashes - // when a dirty object is deleted - TestPManager.setDirty(SFXPausedSet); - - // Delete the object - SFXPausedSet.delete(); - - // Unless %doNotSave is set (by a batch/combo test) - // then go ahead and save now - if (!%doNotSave) - TestPManager.saveDirty(); -} - -function TestPManager::testObjectRename(%doNotSave) -{ - // Flag an object as dirty - if (isObject(AudioGui)) - TestPManager.setDirty(AudioGui); - else if (isObject(AudioGuiFoo)) - TestPManager.setDirty(AudioGuiFoo); - - // Rename it - if (isObject(AudioGui)) - AudioGui.setName(AudioGuiFoo); - else if (isObject(AudioGuiFoo)) - AudioGuiFoo.setName(AudioGui); - - // Unless %doNotSave is set (by a batch/combo test) - // then go ahead and save now - if (!%doNotSave) - TestPManager.saveDirty(); -} - -function TestPManager::testNewObject(%doNotSave) -{ - // Test adding a new named object - new SFXDescription(AudioNew) - { - volume = 0.5; - isLooping = true; - channel = $GuiAudioType; - foo = 2; - }; - - // Flag it as dirty - TestPManager.setDirty(AudioNew, "core/scripts/client/audio.cs"); - - // Test adding a new unnamed object - %obj = new SFXDescription() - { - volume = 0.75; - isLooping = true; - bar = 3; - }; - - // Flag it as dirty - TestPManager.setDirty(%obj, "core/scripts/client/audio.cs"); - - // Test adding an "empty" object - new SFXDescription(AudioEmpty); - - TestPManager.setDirty(AudioEmpty, "core/scripts/client/audio.cs"); - - // Unless %doNotSave is set (by a batch/combo test) - // then go ahead and save now - if (!%doNotSave) - TestPManager.saveDirty(); -} - -function TestPManager::testNewGroup(%doNotSave) -{ - // Test adding a new named SimGroup - new SimGroup(TestGroup) - { - foo = "bar"; - - new SFXDescription(TestObject) - { - volume = 0.5; - isLooping = true; - channel = $GuiAudioType; - foo = 1; - }; - new SimGroup(SubGroup) - { - foo = 2; - - new SFXDescription(SubObject) - { - volume = 0.5; - isLooping = true; - channel = $GuiAudioType; - foo = 3; - }; - }; - }; - - // Flag this as dirty - TestPManager.setDirty(TestGroup, "core/scripts/client/audio.cs"); - - // Test adding a new unnamed SimGroup - %group = new SimGroup() - { - foo = "bar"; - - new SFXDescription() - { - volume = 0.75; - channel = $GuiAudioType; - foo = 4; - }; - new SimGroup() - { - foo = 5; - - new SFXDescription() - { - volume = 0.75; - isLooping = true; - channel = $GuiAudioType; - foo = 6; - }; - }; - }; - - // Flag this as dirty - TestPManager.setDirty(%group, "core/scripts/client/audio.cs"); - - // Test adding a new unnamed SimSet - %set = new SimSet() - { - foo = "bar"; - - new SFXDescription() - { - volume = 0.75; - channel = $GuiAudioType; - foo = 7; - }; - new SimGroup() - { - foo = 8; - - new SFXDescription() - { - volume = 0.75; - isLooping = true; - channel = $GuiAudioType; - foo = 9; - }; - }; - }; - - // Flag this as dirty - TestPManager.setDirty(%set, "core/scripts/client/audio.cs"); - - // Unless %doNotSave is set (by a batch/combo test) - // then go ahead and save now - if (!%doNotSave) - TestPManager.saveDirty(); -} - -function TestPManager::testMoveObject(%doNotSave) -{ - // First add a couple of groups to the file - new SimGroup(MoveGroup1) - { - foo = "bar"; - - new SFXDescription(MoveObject1) - { - volume = 0.5; - isLooping = true; - channel = $GuiAudioType; - foo = 1; - }; - - new SimSet(SubGroup1) - { - new SFXDescription(SubObject1) - { - volume = 0.75; - isLooping = true; - channel = $GuiAudioType; - foo = 2; - }; - }; - }; - - // Flag this as dirty - TestPManager.setDirty(MoveGroup1, "core/scripts/client/audio.cs"); - - new SimGroup(MoveGroup2) - { - foo = "bar"; - - new SFXDescription(MoveObject2) - { - volume = 0.5; - isLooping = true; - channel = $GuiAudioType; - foo = 3; - }; - }; - - // Flag this as dirty - TestPManager.setDirty(MoveGroup2, "core/scripts/client/audio.cs"); - - // Unless %doNotSave is set (by a batch/combo test) - // then go ahead and save now - if (!%doNotSave) - TestPManager.saveDirty(); - - // Set them as dirty again - TestPManager.setDirty(MoveGroup1); - TestPManager.setDirty(MoveGroup2); - - // Give the subobject an new value - MoveObject1.foo = 4; - - // Move it into the other group - MoveGroup1.add(MoveObject2); - - // Switch the other subobject - MoveGroup2.add(MoveObject1); - - // Also add a new unnamed object to one of the groups - %obj = new SFXDescription() - { - volume = 0.75; - isLooping = true; - bar = 5; - }; - - MoveGroup1.add(%obj); - - // Unless %doNotSave is set (by a batch/combo test) - // then go ahead and save now - if (!%doNotSave) - TestPManager.saveDirty(); -} - -function TestPManager::testObjectRemove(%doNotSave) -{ - TestPManager.removeObjectFromFile(AudioSim); -} - -//Game Object management -function findGameObject(%name) -{ - //find all GameObjectAssets - %assetQuery = new AssetQuery(); - if(!AssetDatabase.findAssetType(%assetQuery, "GameObjectAsset")) - return 0; //if we didn't find ANY, just exit - - %count = %assetQuery.getCount(); - - for(%i=0; %i < %count; %i++) - { - %assetId = %assetQuery.getAsset(%i); - - //%assetName = AssetDatabase.getAssetName(%assetId); - - if(%assetId $= %name) - { - %gameObjectAsset = AssetDatabase.acquireAsset(%assetId); - - %assetQuery.delete(); - return %gameObjectAsset; - } - } - - %assetQuery.delete(); - return 0; -} - -function spawnGameObject(%name, %addToMissionGroup) -{ - if(%addToMissionGroup $= "") - %addToMissionGroup = true; - - //First, check if this already exists in our GameObjectPool - if(isObject(GameObjectPool)) - { - %goCount = GameObjectPool.countKey(%name); - - //if we have some already in the pool, pull it out and use that - if(%goCount != 0) - { - %goIdx = GameObjectPool.getIndexFromKey(%name); - %go = GameObjectPool.getValue(%goIdx); - - %go.setHidden(false); - %go.setScopeAlways(); - - if(%addToMissionGroup == true) //save instance when saving level - MissionGroup.add(%go); - else // clear instance on level exit - MissionCleanup.add(%go); - - //remove from the object pool's list - GameObjectPool.erase(%goIdx); - - return %go; - } - } - - //We have no existing pool, or no existing game objects of this type, so spawn a new one - - %gameObjectAsset = findGameObject(%name); - - if(isObject(%gameObjectAsset)) - { - %newSGOObject = TamlRead(%gameObjectAsset.TAMLFilePath); - - if(%addToMissionGroup == true) //save instance when saving level - MissionGroup.add(%newSGOObject); - else // clear instance on level exit - MissionCleanup.add(%newSGOObject); - - return %newSGOObject; - } - - return 0; -} - -function saveGameObject(%name, %tamlPath, %scriptPath) -{ - %gameObjectAsset = findGameObject(%name); - - //find if it already exists. If it does, we'll update it, if it does not, we'll make a new asset - if(isObject(%gameObjectAsset)) - { - %assetID = %gameObjectAsset.getAssetId(); - - %gameObjectAsset.TAMLFilePath = %tamlPath; - %gameObjectAsset.scriptFilePath = %scriptPath; - - TAMLWrite(%gameObjectAsset, AssetDatabase.getAssetFilePath(%assetID)); - AssetDatabase.refreshAsset(%assetID); - } - else - { - //Doesn't exist, so make a new one - %gameObjectAsset = new GameObjectAsset() - { - assetName = %name @ "Asset"; - gameObjectName = %name; - TAMLFilePath = %tamlPath; - scriptFilePath = %scriptPath; - }; - - //Save it alongside the taml file - %path = filePath(%tamlPath); - - TAMLWrite(%gameObjectAsset, %path @ "/" @ %name @ ".asset.taml"); - AssetDatabase.refreshAllAssets(true); - } -} - -//Allocates a number of a game object into a pool to be pulled from as needed -function allocateGameObjects(%name, %amount) -{ - //First, we need to make sure our pool exists - if(!isObject(GameObjectPool)) - { - new ArrayObject(GameObjectPool); - } - - //Next, we loop and generate our game objects, and add them to the pool - for(%i=0; %i < %amount; %i++) - { - %go = spawnGameObject(%name, false); - - //When our object is in the pool, it's not "real", so we need to make sure - //that we don't ghost it to clients untill we actually spawn it. - %go.clearScopeAlways(); - - //We also hide it, so that we don't 'exist' in the scene until we spawn - %go.hidden = true; - - //Lastly, add us to the pool, with the key being our game object type - GameObjectPool.add(%name, %go); - } -} - -function Entity::delete(%this) -{ - //we want to intercept the delete call, and add it to our GameObjectPool - //if it's a game object - if(%this.gameObjectAsset !$= "") - { - %this.setHidden(true); - %this.clearScopeAlways(); - - if(!isObject(GameObjectPool)) - { - new ArrayObject(GameObjectPool); - } - - GameObjectPool.add(%this.gameObjectAsset, %this); - - %missionSet = %this.getGroup(); - %missionSet.remove(%this); - } - else - { - %this.superClass.delete(); - } -} - -function clearGameObjectPool() -{ - if(isObject(GameObjectPool)) - { - %count = GameObjectPool.count(); - - for(%i=0; %i < %count; %i++) - { - %go = GameObjectPool.getValue(%i); - - %go.superClass.delete(); - } - - GameObjectPool.empty(); - } -} - // function switchCamera(%client, %newCamEntity) { @@ -1155,4 +658,17 @@ function switchCamera(%client, %newCamEntity) %client.setControlCameraFov(%cam.FOV); %client.camera = %newCamEntity; +} + +function switchControlObject(%client, %newControlEntity) +{ + if(!isObject(%client) || !isObject(%newControlEntity)) + return error("SwitchControlObject: No client or target controller!"); + + %control = %newControlEntity.getComponent(ControlObjectComponent); + + if(!isObject(%control)) + return error("SwitchControlObject: Target controller has no conrol object behavior!"); + + %control.setConnectionControlObject(%client); } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/utility/scripts/persistanceManagement.cs b/Templates/BaseGame/game/core/utility/scripts/persistanceManagement.cs new file mode 100644 index 000000000..aab054161 --- /dev/null +++ b/Templates/BaseGame/game/core/utility/scripts/persistanceManagement.cs @@ -0,0 +1,315 @@ +//Persistance Manager tests + +new PersistenceManager(TestPManager); + +function runPManTest(%test) +{ + if (!isObject(TestPManager)) + return; + + if (%test $= "") + %test = 100; + + switch(%test) + { + case 0: + TestPManager.testFieldUpdates(); + case 1: + TestPManager.testObjectRename(); + case 2: + TestPManager.testNewObject(); + case 3: + TestPManager.testNewGroup(); + case 4: + TestPManager.testMoveObject(); + case 5: + TestPManager.testObjectRemove(); + case 100: + TestPManager.testFieldUpdates(); + TestPManager.testObjectRename(); + TestPManager.testNewObject(); + TestPManager.testNewGroup(); + TestPManager.testMoveObject(); + TestPManager.testObjectRemove(); + } +} + +function TestPManager::testFieldUpdates(%doNotSave) +{ + // Set some objects as dirty + TestPManager.setDirty(AudioGui); + TestPManager.setDirty(AudioSim); + TestPManager.setDirty(AudioMessage); + + // Alter some of the existing fields + AudioEffect.isLooping = true; + AudioMessage.isLooping = true; + AudioEffect.is3D = true; + + // Test removing a field + TestPManager.removeField(AudioGui, "isLooping"); + + // Alter some of the persistent fields + AudioGui.referenceDistance = 0.8; + AudioMessage.referenceDistance = 0.8; + + // Add some new dynamic fields + AudioGui.foo = "bar"; + AudioEffect.foo = "bar"; + + // Remove an object from the dirty list + // It shouldn't get updated in the file + TestPManager.removeDirty(AudioEffect); + + // Dirty an object in another file as well + TestPManager.setDirty(WarningMaterial); + + // Update a field that doesn't exist + WarningMaterial.glow[0] = true; + + // Drity another object to test for crashes + // when a dirty object is deleted + TestPManager.setDirty(SFXPausedSet); + + // Delete the object + SFXPausedSet.delete(); + + // Unless %doNotSave is set (by a batch/combo test) + // then go ahead and save now + if (!%doNotSave) + TestPManager.saveDirty(); +} + +function TestPManager::testObjectRename(%doNotSave) +{ + // Flag an object as dirty + if (isObject(AudioGui)) + TestPManager.setDirty(AudioGui); + else if (isObject(AudioGuiFoo)) + TestPManager.setDirty(AudioGuiFoo); + + // Rename it + if (isObject(AudioGui)) + AudioGui.setName(AudioGuiFoo); + else if (isObject(AudioGuiFoo)) + AudioGuiFoo.setName(AudioGui); + + // Unless %doNotSave is set (by a batch/combo test) + // then go ahead and save now + if (!%doNotSave) + TestPManager.saveDirty(); +} + +function TestPManager::testNewObject(%doNotSave) +{ + // Test adding a new named object + new SFXDescription(AudioNew) + { + volume = 0.5; + isLooping = true; + channel = $GuiAudioType; + foo = 2; + }; + + // Flag it as dirty + TestPManager.setDirty(AudioNew, "core/scripts/client/audio.cs"); + + // Test adding a new unnamed object + %obj = new SFXDescription() + { + volume = 0.75; + isLooping = true; + bar = 3; + }; + + // Flag it as dirty + TestPManager.setDirty(%obj, "core/scripts/client/audio.cs"); + + // Test adding an "empty" object + new SFXDescription(AudioEmpty); + + TestPManager.setDirty(AudioEmpty, "core/scripts/client/audio.cs"); + + // Unless %doNotSave is set (by a batch/combo test) + // then go ahead and save now + if (!%doNotSave) + TestPManager.saveDirty(); +} + +function TestPManager::testNewGroup(%doNotSave) +{ + // Test adding a new named SimGroup + new SimGroup(TestGroup) + { + foo = "bar"; + + new SFXDescription(TestObject) + { + volume = 0.5; + isLooping = true; + channel = $GuiAudioType; + foo = 1; + }; + new SimGroup(SubGroup) + { + foo = 2; + + new SFXDescription(SubObject) + { + volume = 0.5; + isLooping = true; + channel = $GuiAudioType; + foo = 3; + }; + }; + }; + + // Flag this as dirty + TestPManager.setDirty(TestGroup, "core/scripts/client/audio.cs"); + + // Test adding a new unnamed SimGroup + %group = new SimGroup() + { + foo = "bar"; + + new SFXDescription() + { + volume = 0.75; + channel = $GuiAudioType; + foo = 4; + }; + new SimGroup() + { + foo = 5; + + new SFXDescription() + { + volume = 0.75; + isLooping = true; + channel = $GuiAudioType; + foo = 6; + }; + }; + }; + + // Flag this as dirty + TestPManager.setDirty(%group, "core/scripts/client/audio.cs"); + + // Test adding a new unnamed SimSet + %set = new SimSet() + { + foo = "bar"; + + new SFXDescription() + { + volume = 0.75; + channel = $GuiAudioType; + foo = 7; + }; + new SimGroup() + { + foo = 8; + + new SFXDescription() + { + volume = 0.75; + isLooping = true; + channel = $GuiAudioType; + foo = 9; + }; + }; + }; + + // Flag this as dirty + TestPManager.setDirty(%set, "core/scripts/client/audio.cs"); + + // Unless %doNotSave is set (by a batch/combo test) + // then go ahead and save now + if (!%doNotSave) + TestPManager.saveDirty(); +} + +function TestPManager::testMoveObject(%doNotSave) +{ + // First add a couple of groups to the file + new SimGroup(MoveGroup1) + { + foo = "bar"; + + new SFXDescription(MoveObject1) + { + volume = 0.5; + isLooping = true; + channel = $GuiAudioType; + foo = 1; + }; + + new SimSet(SubGroup1) + { + new SFXDescription(SubObject1) + { + volume = 0.75; + isLooping = true; + channel = $GuiAudioType; + foo = 2; + }; + }; + }; + + // Flag this as dirty + TestPManager.setDirty(MoveGroup1, "core/scripts/client/audio.cs"); + + new SimGroup(MoveGroup2) + { + foo = "bar"; + + new SFXDescription(MoveObject2) + { + volume = 0.5; + isLooping = true; + channel = $GuiAudioType; + foo = 3; + }; + }; + + // Flag this as dirty + TestPManager.setDirty(MoveGroup2, "core/scripts/client/audio.cs"); + + // Unless %doNotSave is set (by a batch/combo test) + // then go ahead and save now + if (!%doNotSave) + TestPManager.saveDirty(); + + // Set them as dirty again + TestPManager.setDirty(MoveGroup1); + TestPManager.setDirty(MoveGroup2); + + // Give the subobject an new value + MoveObject1.foo = 4; + + // Move it into the other group + MoveGroup1.add(MoveObject2); + + // Switch the other subobject + MoveGroup2.add(MoveObject1); + + // Also add a new unnamed object to one of the groups + %obj = new SFXDescription() + { + volume = 0.75; + isLooping = true; + bar = 5; + }; + + MoveGroup1.add(%obj); + + // Unless %doNotSave is set (by a batch/combo test) + // then go ahead and save now + if (!%doNotSave) + TestPManager.saveDirty(); +} + +function TestPManager::testObjectRemove(%doNotSave) +{ + TestPManager.removeObjectFromFile(AudioSim); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/convexEditor/main.cs b/Templates/BaseGame/game/tools/convexEditor/main.cs index 71e6b3090..4577f20e2 100644 --- a/Templates/BaseGame/game/tools/convexEditor/main.cs +++ b/Templates/BaseGame/game/tools/convexEditor/main.cs @@ -189,7 +189,7 @@ function ConvexEditorPlugin::onSaveMission( %this, %missionFile ) { if( ConvexEditorGui.isDirty ) { - MissionGroup.save( %missionFile ); + getScene(0).save( %missionFile ); ConvexEditorGui.isDirty = false; } } diff --git a/Templates/BaseGame/game/tools/gui/colladaImport.ed.gui b/Templates/BaseGame/game/tools/gui/colladaImport.ed.gui index 30838c76d..4c0f60316 100644 --- a/Templates/BaseGame/game/tools/gui/colladaImport.ed.gui +++ b/Templates/BaseGame/game/tools/gui/colladaImport.ed.gui @@ -1584,7 +1584,7 @@ function ColladaImportDlg::onOK(%this) function ColladaImportDlg::loadLights(%this) { // Get the ID of the last object added - %obj = MissionGroup.getObject(MissionGroup.getCount()-1); + %obj = getScene(0).getObject(getScene(0).getCount()-1); // Create a new SimGroup to hold the model and lights %group = new SimGroup(); @@ -1596,7 +1596,7 @@ function ColladaImportDlg::loadLights(%this) { %group.add(%obj); %group.bringToFront(%obj); - MissionGroup.add(%group); + getScene(0).add(%group); if (EditorTree.isVisible()) { EditorTree.removeItem(EditorTree.findItemByObjectId(%obj)); diff --git a/Templates/BaseGame/game/tools/levels/BlankRoom.mis b/Templates/BaseGame/game/tools/levels/BlankRoom.mis index 3d43918be..7e1243a8d 100644 --- a/Templates/BaseGame/game/tools/levels/BlankRoom.mis +++ b/Templates/BaseGame/game/tools/levels/BlankRoom.mis @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -new SimGroup(MissionGroup) { +new Scene(EditorTemplateLevel) { canSave = "1"; canSaveDynamicFields = "1"; cdTrack = "2"; diff --git a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs index 6564362e4..30c5dac26 100644 --- a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs +++ b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs @@ -1051,7 +1051,7 @@ function MaterialEditorGui::updateActiveMaterialName(%this, %name) // Some objects (ConvexShape, DecalRoad etc) reference Materials by name => need // to find and update all these references so they don't break when we rename the // Material. - MaterialEditorGui.updateMaterialReferences( MissionGroup, %action.oldName, %action.newName ); + MaterialEditorGui.updateMaterialReferences( getScene(0), %action.oldName, %action.newName ); } function MaterialEditorGui::updateMaterialReferences( %this, %obj, %oldName, %newName ) diff --git a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditorUndo.ed.cs b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditorUndo.ed.cs index 184f02ce4..c00d8f70f 100644 --- a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditorUndo.ed.cs +++ b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditorUndo.ed.cs @@ -187,7 +187,7 @@ function ActionUpdateActiveMaterialAnimationFlags::undo(%this) function ActionUpdateActiveMaterialName::redo(%this) { %this.material.setName(%this.newName); - MaterialEditorGui.updateMaterialReferences( MissionGroup, %this.oldName, %this.newName ); + MaterialEditorGui.updateMaterialReferences( getScene(0), %this.oldName, %this.newName ); if( MaterialEditorPreviewWindow.isVisible() && MaterialEditorGui.currentMaterial == %this.material ) { @@ -199,7 +199,7 @@ function ActionUpdateActiveMaterialName::redo(%this) function ActionUpdateActiveMaterialName::undo(%this) { %this.material.setName(%this.oldName); - MaterialEditorGui.updateMaterialReferences( MissionGroup, %this.newName, %this.oldName ); + MaterialEditorGui.updateMaterialReferences( getScene(0), %this.newName, %this.oldName ); if( MaterialEditorPreviewWindow.isVisible() && MaterialEditorGui.currentMaterial == %this.material ) { diff --git a/Templates/BaseGame/game/tools/meshRoadEditor/main.cs b/Templates/BaseGame/game/tools/meshRoadEditor/main.cs index d101e50b0..a6ccbc507 100644 --- a/Templates/BaseGame/game/tools/meshRoadEditor/main.cs +++ b/Templates/BaseGame/game/tools/meshRoadEditor/main.cs @@ -164,7 +164,7 @@ function MeshRoadEditorPlugin::onSaveMission( %this, %missionFile ) { if( MeshRoadEditorGui.isDirty ) { - MissionGroup.save( %missionFile ); + getScene(0).save( %missionFile ); MeshRoadEditorGui.isDirty = false; } } diff --git a/Templates/BaseGame/game/tools/missionAreaEditor/main.cs b/Templates/BaseGame/game/tools/missionAreaEditor/main.cs index 000197bc6..946d9ab1f 100644 --- a/Templates/BaseGame/game/tools/missionAreaEditor/main.cs +++ b/Templates/BaseGame/game/tools/missionAreaEditor/main.cs @@ -114,7 +114,7 @@ function MissionAreaEditorPlugin::createNewMissionArea(%this) %newMissionArea = new MissionArea(); %newMissionArea.area = "-256 -256 512 512"; - MissionGroup.add(%newMissionArea); + getScene(0).add(%newMissionArea); EditorGui.setEditor(MissionAreaEditorPlugin); diff --git a/Templates/BaseGame/game/tools/navEditor/CreateNewNavMeshDlg.gui b/Templates/BaseGame/game/tools/navEditor/CreateNewNavMeshDlg.gui index 755bce30a..0ea3f0d02 100644 --- a/Templates/BaseGame/game/tools/navEditor/CreateNewNavMeshDlg.gui +++ b/Templates/BaseGame/game/tools/navEditor/CreateNewNavMeshDlg.gui @@ -354,13 +354,13 @@ function CreateNewNavMeshDlg::create(%this) if(MeshMissionBounds.isStateOn()) { - if(!isObject(MissionGroup)) + if(!isObject(getScene(0))) { - MessageBoxOk("Error", "You must have a MissionGroup to use the mission bounds function."); + MessageBoxOk("Error", "You must have a Scene to use the mission bounds function."); return; } // Get maximum extents of all objects. - %box = MissionBoundsExtents(MissionGroup); + %box = MissionBoundsExtents(getScene(0)); %pos = GetBoxCenter(%box); %scale = (GetWord(%box, 3) - GetWord(%box, 0)) / 2 + 5 SPC (GetWord(%box, 4) - GetWord(%box, 1)) / 2 + 5 @@ -380,7 +380,7 @@ function CreateNewNavMeshDlg::create(%this) scale = %this-->MeshScale.getText(); }; } - MissionGroup.add(%mesh); + getScene(0).add(%mesh); NavEditorGui.selectObject(%mesh); Canvas.popDialog(CreateNewNavMeshDlg); diff --git a/Templates/BaseGame/game/tools/navEditor/main.cs b/Templates/BaseGame/game/tools/navEditor/main.cs index 6af3abf19..dd6f15772 100644 --- a/Templates/BaseGame/game/tools/navEditor/main.cs +++ b/Templates/BaseGame/game/tools/navEditor/main.cs @@ -205,7 +205,7 @@ function NavEditorPlugin::onSaveMission(%this, %missionFile) { if(NavEditorGui.isDirty) { - MissionGroup.save(%missionFile); + getScene(0).save(%missionFile); NavEditorGui.isDirty = false; } } diff --git a/Templates/BaseGame/game/tools/physicsTools/main.cs b/Templates/BaseGame/game/tools/physicsTools/main.cs index 8da40844e..4fbf44bdb 100644 --- a/Templates/BaseGame/game/tools/physicsTools/main.cs +++ b/Templates/BaseGame/game/tools/physicsTools/main.cs @@ -64,28 +64,6 @@ function destroyPhysicsTools() function PhysicsEditorPlugin::onWorldEditorStartup( %this ) { - new PopupMenu( PhysicsToolsMenu ) - { - superClass = "MenuBuilder"; - //class = "PhysXToolsMenu"; - - barTitle = "Physics"; - - item[0] = "Start Simulation" TAB "Ctrl-Alt P" TAB "physicsStartSimulation( \"client\" );physicsStartSimulation( \"server\" );"; - //item[1] = "Stop Simulation" TAB "" TAB "physicsSetTimeScale( 0 );"; - item[1] = "-"; - item[2] = "Speed 25%" TAB "" TAB "physicsSetTimeScale( 0.25 );"; - item[3] = "Speed 50%" TAB "" TAB "physicsSetTimeScale( 0.5 );"; - item[4] = "Speed 100%" TAB "" TAB "physicsSetTimeScale( 1.0 );"; - item[5] = "-"; - item[6] = "Reload NXBs" TAB "" TAB ""; - }; - - // Add our menu. - EditorGui.menuBar.insert( PhysicsToolsMenu, EditorGui.menuBar.dynamicItemInsertPos ); - - // Add ourselves to the window menu. - //EditorGui.addToWindowMenu( "Road and Path Editor", "", "RoadEditor" ); } function PhysicsToolsMenu::onMenuSelect(%this) diff --git a/Templates/BaseGame/game/tools/riverEditor/main.cs b/Templates/BaseGame/game/tools/riverEditor/main.cs index eafb3c3c8..5c082bd6d 100644 --- a/Templates/BaseGame/game/tools/riverEditor/main.cs +++ b/Templates/BaseGame/game/tools/riverEditor/main.cs @@ -178,7 +178,9 @@ function RiverEditorPlugin::onSaveMission( %this, %missionFile ) { if( RiverEditorGui.isDirty ) { - MissionGroup.save( %missionFile ); + //Get our root scene, which would be the level + getScene(0).save( %missionFile ); + RiverEditorGui.isDirty = false; } } diff --git a/Templates/BaseGame/game/tools/roadEditor/main.cs b/Templates/BaseGame/game/tools/roadEditor/main.cs index f45823670..25757a965 100644 --- a/Templates/BaseGame/game/tools/roadEditor/main.cs +++ b/Templates/BaseGame/game/tools/roadEditor/main.cs @@ -156,7 +156,7 @@ function RoadEditorPlugin::onSaveMission( %this, %missionFile ) { if( RoadEditorGui.isDirty ) { - MissionGroup.save( %missionFile ); + getScene(0).save( %missionFile ); RoadEditorGui.isDirty = false; } } diff --git a/Templates/BaseGame/game/tools/settings.xml b/Templates/BaseGame/game/tools/settings.xml index 761b16978..d01241a25 100644 --- a/Templates/BaseGame/game/tools/settings.xml +++ b/Templates/BaseGame/game/tools/settings.xml @@ -1,80 +1,83 @@ - - 100 - 0 - 0.8 - 1 - 15 - 0.8 - 0 - - 500 - 255 255 255 20 - 0 - 0 - 10 10 10 - 0 - - - screenCenter - 0 - 50 - WorldEditorInspectorPlugin - 40 - 6 1 - - 0 - 0 - 0 - 100 - 2 - 1 - 1 - - - http://www.garagegames.com/products/torque-3d/documentation/user - ../../../Documentation/Official Documentation.html - http://www.garagegames.com/products/torque-3d/forums - ../../../Documentation/Torque 3D - Script Manual.chm - - - 255 255 255 100 - 1 - 102 102 102 100 - 51 51 51 100 - 0 - - - tools/worldEditor/images/LockedHandle - tools/worldEditor/images/DefaultHandle - tools/worldEditor/images/SelectHandle - - - 1 - 1 - 1 - 1 - 1 - + 0 + WorldEditorInspectorPlugin + 6 + screenCenter + 50 + 40 - 0 255 0 255 - 100 100 100 255 - 255 255 255 255 - 255 0 0 255 255 255 0 255 - 0 0 255 255 + 0 255 0 255 + 255 0 0 255 255 255 0 255 + 255 255 255 255 + 0 0 255 255 + 100 100 100 255 8 - 1 - 0 - 255 20 + 255 + 0 + 1 + + 1 + 1 + 1 + 1 + 1 + + + 255 255 255 100 + 102 102 102 100 + 0 + 1 + 51 51 51 100 + + + ../../../Documentation/Official Documentation.html + ../../../Documentation/Torque 3D - Script Manual.chm + http://www.garagegames.com/products/torque-3d/documentation/user + http://www.garagegames.com/products/torque-3d/forums + + + tools/worldEditor/images/LockedHandle + tools/worldEditor/images/SelectHandle + tools/worldEditor/images/DefaultHandle + + + 0 + 2 + 100 + 0 + 1 + 1 + 0 + + + + 1 + 0.8 + 100 + 0.8 + 15 + 0 + 0 + + 0 + 500 + 0 + 10 10 10 + 255 255 255 20 + 0 + + + + AIPlayer data/FPSGameplay/levels @@ -84,7 +87,4 @@ - - AIPlayer - diff --git a/Templates/BaseGame/game/tools/shapeEditor/main.cs b/Templates/BaseGame/game/tools/shapeEditor/main.cs index efbc1c538..40b6af6e0 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/main.cs +++ b/Templates/BaseGame/game/tools/shapeEditor/main.cs @@ -175,7 +175,7 @@ function ShapeEditorPlugin::open(%this, %filename) ShapeEdNodes-->worldTransform.setStateOn(1); // Initialise and show the shape editor - ShapeEdShapeTreeView.open(MissionGroup); + ShapeEdShapeTreeView.open(getScene(0)); ShapeEdShapeTreeView.buildVisibleTree(true); ShapeEdPreviewGui.setVisible(true); diff --git a/Templates/BaseGame/game/tools/shapes/unit_capsule.dts b/Templates/BaseGame/game/tools/shapes/unit_capsule.dts new file mode 100644 index 000000000..bc9483fac Binary files /dev/null and b/Templates/BaseGame/game/tools/shapes/unit_capsule.dts differ diff --git a/Templates/BaseGame/game/tools/shapes/unit_cube.dts b/Templates/BaseGame/game/tools/shapes/unit_cube.dts new file mode 100644 index 000000000..feee7cf94 Binary files /dev/null and b/Templates/BaseGame/game/tools/shapes/unit_cube.dts differ diff --git a/Templates/BaseGame/game/tools/shapes/unit_sphere.dts b/Templates/BaseGame/game/tools/shapes/unit_sphere.dts new file mode 100644 index 000000000..4d435438e Binary files /dev/null and b/Templates/BaseGame/game/tools/shapes/unit_sphere.dts differ diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui index 8eaf11d4c..4b7b8a26e 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui @@ -184,11 +184,11 @@ function TimeAdjustSliderCtrl::onAction(%this) if ( !isObject( %this.tod ) ) { - if ( isObject( MissionGroup ) ) + if ( isObject( getScene(0) ) ) { - for ( %i = 0; %i < MissionGroup.getCount(); %i++ ) + for ( %i = 0; %i < getScene(0).getCount(); %i++ ) { - %obj = MissionGroup.getObject( %i ); + %obj = getScene(0).getObject( %i ); if ( %obj.getClassName() $= "TimeOfDay" ) { diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/objectBuilderGui.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/objectBuilderGui.ed.gui index 74f1200c6..fce36e940 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/objectBuilderGui.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/objectBuilderGui.ed.gui @@ -947,10 +947,10 @@ function ObjectBuilderGui::buildPlayerDropPoint(%this) %this.addField("spawnClass", "TypeString", "Spawn Class", "Player"); %this.addField("spawnDatablock", "TypeDataBlock", "Spawn Data", "PlayerData DefaultPlayerData"); - if( EWCreatorWindow.objectGroup.getID() == MissionGroup.getID() ) + if( EWCreatorWindow.objectGroup.getID() == getScene(0).getID() ) { if( !isObject("PlayerDropPoints") ) - MissionGroup.add( new SimGroup("PlayerDropPoints") ); + getScene(0).add( new SimGroup("PlayerDropPoints") ); %this.objectGroup = "PlayerDropPoints"; } @@ -967,10 +967,10 @@ function ObjectBuilderGui::buildObserverDropPoint(%this) %this.addField("spawnClass", "TypeString", "Spawn Class", "Camera"); %this.addField("spawnDatablock", "TypeDataBlock", "Spawn Data", "CameraData Observer"); - if( EWCreatorWindow.objectGroup.getID() == MissionGroup.getID() ) + if( EWCreatorWindow.objectGroup.getID() == getScene(0).getID() ) { if( !isObject("ObserverDropPoints") ) - MissionGroup.add( new SimGroup("ObserverDropPoints") ); + getScene(0).add( new SimGroup("ObserverDropPoints") ); %this.objectGroup = "ObserverDropPoints"; } diff --git a/Templates/BaseGame/game/tools/worldEditor/main.cs b/Templates/BaseGame/game/tools/worldEditor/main.cs index 8102438c6..5d337cdf1 100644 --- a/Templates/BaseGame/game/tools/worldEditor/main.cs +++ b/Templates/BaseGame/game/tools/worldEditor/main.cs @@ -133,6 +133,15 @@ function initializeWorldEditor() EVisibility.addOption( "Frustum Lock", "$Scene::lockCull", "" ); EVisibility.addOption( "Disable Zone Culling", "$Scene::disableZoneCulling", "" ); EVisibility.addOption( "Disable Terrain Occlusion", "$Scene::disableTerrainOcclusion", "" ); + + EVisibility.addOption( "Colorblindness: Protanopia", "$CBV_Protanopia", "toggleColorBlindnessViz" ); + EVisibility.addOption( "Colorblindness: Protanomaly", "$CBV_Protanomaly", "toggleColorBlindnessViz" ); + EVisibility.addOption( "Colorblindness: Deuteranopia", "$CBV_Deuteranopia", "toggleColorBlindnessViz" ); + EVisibility.addOption( "Colorblindness: Deuteranomaly", "$CBV_Deuteranomaly", "toggleColorBlindnessViz" ); + EVisibility.addOption( "Colorblindness: Tritanopia", "$CBV_Tritanopia", "toggleColorBlindnessViz" ); + EVisibility.addOption( "Colorblindness: Tritanomaly", "$CBV_Tritanomaly", "toggleColorBlindnessViz" ); + EVisibility.addOption( "Colorblindness: Achromatopsia", "$CBV_Achromatopsia", "toggleColorBlindnessViz" ); + EVisibility.addOption( "Colorblindness: Achromatomaly", "$CBV_Achromatomaly", "toggleColorBlindnessViz" ); } function destroyWorldEditor() diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.cs index 50aac111b..8cc951a99 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.cs @@ -317,10 +317,15 @@ function EditorGui::shutdown( %this ) /// will take over the default world editor window. function EditorGui::addToEditorsMenu( %this, %displayName, %accel, %newPlugin ) { + //We need to cache the editors list. So first see if we have our list we cache the entries into + if(!isObject(EditorsMenuList)) + { + new ArrayObject(EditorsMenuList); + } + %windowMenu = %this.findMenu( "Editors" ); %count = %windowMenu.getItemCount(); - %alreadyExists = false; for ( %i = 0; %i < %count; %i++ ) { @@ -336,7 +341,10 @@ function EditorGui::addToEditorsMenu( %this, %displayName, %accel, %newPlugin ) %accel = ""; if(!%alreadyExists) + { + EditorsMenuList.add(%displayName TAB %accel TAB %newPlugin); %windowMenu.addItem( %count, %displayName TAB %accel TAB %newPlugin ); + } return %accel; } @@ -637,7 +645,7 @@ function EditorGui::addCameraBookmark( %this, %name ) if( !isObject(CameraBookmarks) ) { %grp = new SimGroup(CameraBookmarks); - MissionGroup.add(%grp); + getScene(0).add(%grp); } CameraBookmarks.add( %obj ); @@ -835,12 +843,17 @@ function EditorGui::syncCameraGui( %this ) function WorldEditorPlugin::onActivated( %this ) { + if(!isObject(Scenes)) + $scenesRootGroup = new SimGroup(Scenes); + + $scenesRootGroup.add(getScene(0)); + EditorGui.bringToFront( EWorldEditor ); EWorldEditor.setVisible(true); EditorGui.menuBar.insert( EditorGui.worldMenu, EditorGui.menuBar.dynamicItemInsertPos ); EWorldEditor.makeFirstResponder(true); - EditorTree.open(MissionGroup,true); - EWCreatorWindow.setNewObjectGroup(MissionGroup); + EditorTree.open($scenesRootGroup,true); + EWCreatorWindow.setNewObjectGroup(getScene(0)); EWorldEditor.syncGui(); @@ -1464,7 +1477,7 @@ function EditorTree::onDeleteObject( %this, %object ) return true; if( %object == EWCreatorWindow.objectGroup ) - EWCreatorWindow.setNewObjectGroup( MissionGroup ); + EWCreatorWindow.setNewObjectGroup( getScene(0) ); // Append it to our list. %this.undoDeleteList = %this.undoDeleteList TAB %object; @@ -1596,6 +1609,13 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj ) { %popup.item[ 0 ] = "Add Camera Bookmark" TAB "" TAB "EditorGui.addCameraBookmarkByGui();"; } + else if( %obj.isMemberOfClass( "Scene" )) + { + %popup.item[ 0 ] = "Set as Active Scene" TAB "" TAB "EditorTree.showItemRenameCtrl( EditorTree.findItemByObjectId(" @ %popup.object @ ") );"; + %popup.item[ 1 ] = "Delete" TAB "" TAB "EWorldEditor.deleteMissionObject(" @ %popup.object @ ");"; + %popup.item[ 2 ] = "Inspect" TAB "" TAB "inspectObject(" @ %popup.object @ ");"; + %popup.item[ 3 ] = "-"; + } else { %popup.object = %obj; @@ -1673,8 +1693,8 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj ) if( %haveObjectEntries ) { - %popup.enableItem( 0, %obj.isNameChangeAllowed() && %obj.getName() !$= "MissionGroup" ); - %popup.enableItem( 1, %obj.getName() !$= "MissionGroup" ); + %popup.enableItem( 0, %obj.isNameChangeAllowed() && %obj !$= getScene(0) ); + %popup.enableItem( 1, %obj !$= getScene(0) ); if( %haveLockAndHideEntries ) { @@ -1864,6 +1884,7 @@ function Editor::open(%this) %this.editorEnabled(); Canvas.setContent(EditorGui); + $isFirstPersonVar = true; EditorGui.syncCameraGui(); } @@ -2025,21 +2046,21 @@ function EWorldEditor::syncToolPalette( %this ) function EWorldEditor::addSimGroup( %this, %groupCurrentSelection ) { %activeSelection = %this.getActiveSelection(); - if ( %activeSelection.getObjectIndex( MissionGroup ) != -1 ) + if ( %activeSelection.getObjectIndex( getScene(0) ) != -1 ) { - MessageBoxOK( "Error", "Cannot add MissionGroup to a new SimGroup" ); + MessageBoxOK( "Error", "Cannot add Scene to a new SimGroup" ); return; } // Find our parent. - %parent = MissionGroup; + %parent = getScene(0); if( !%groupCurrentSelection && isObject( %activeSelection ) && %activeSelection.getCount() > 0 ) { %firstSelectedObject = %activeSelection.getObject( 0 ); if( %firstSelectedObject.isMemberOfClass( "SimGroup" ) ) %parent = %firstSelectedObject; - else if( %firstSelectedObject.getId() != MissionGroup.getId() ) + else if( %firstSelectedObject.getId() != getScene(0).getId() ) %parent = %firstSelectedObject.parentGroup; } diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/SelectObjectsWindow.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/SelectObjectsWindow.ed.cs index 2c436f74f..65fae1760 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/SelectObjectsWindow.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/SelectObjectsWindow.ed.cs @@ -40,7 +40,7 @@ function ESelectObjectsWindow::toggleVisibility( %this ) /// to start searching for objects. function ESelectObjectsWindow::getRootGroup( %this ) { - return MissionGroup; + return getScene(0); } //--------------------------------------------------------------------------------------------- diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/editors/creator.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/editors/creator.ed.cs index 006031668..a2841d977 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/editors/creator.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/editors/creator.ed.cs @@ -179,7 +179,7 @@ function EWCreatorWindow::createStatic( %this, %file ) return; if( !isObject(%this.objectGroup) ) - %this.setNewObjectGroup( MissionGroup ); + %this.setNewObjectGroup( getScene(0) ); %objId = new TSStatic() { @@ -197,7 +197,7 @@ function EWCreatorWindow::createPrefab( %this, %file ) return; if( !isObject(%this.objectGroup) ) - %this.setNewObjectGroup( MissionGroup ); + %this.setNewObjectGroup( getScene(0) ); %objId = new Prefab() { @@ -215,7 +215,7 @@ function EWCreatorWindow::createObject( %this, %cmd ) return; if( !isObject(%this.objectGroup) ) - %this.setNewObjectGroup( MissionGroup ); + %this.setNewObjectGroup( getScene(0) ); pushInstantGroup(); %objId = eval(%cmd); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs index eb89d1a30..2a4853e62 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs @@ -124,6 +124,12 @@ function WorldEditor::onSelectionCentroidChanged( %this ) Inspector.refresh(); } +function WorldEditor::setSceneAsDirty(%this) +{ + EWorldEditor.isDirty = true; + +} + ////////////////////////////////////////////////////////////////////////// function WorldEditor::init(%this) @@ -198,7 +204,7 @@ function WorldEditor::export(%this) function WorldEditor::doExport(%this, %file) { - missionGroup.save("~/editor/" @ %file, true); + getScene(0).save("~/editor/" @ %file, true); } function WorldEditor::import(%this) diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/lightViz.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/lightViz.cs index 905b826c6..574063460 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/lightViz.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/lightViz.cs @@ -367,3 +367,81 @@ function toggleBackbufferViz( %enable ) else if ( !%enable ) AL_DeferredShading.enable(); } + +function toggleColorBlindnessViz( %enable ) +{ + if ( %enable $= "" ) + { + $CBV_Protanopia = ColorBlindnessVisualize.isEnabled() ? false : true; + ColorBlindnessVisualize.toggle(); + } + else if ( %enable ) + ColorBlindnessVisualize.enable(); + else if ( !%enable ) + ColorBlindnessVisualize.disable(); +} + +new ShaderData( ColorBlindnessVisualizeShader ) +{ + DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; + DXPixelShaderFile = "tools/worldEditor/scripts/shaders/dbgColorBlindnessVisualizeP.hlsl"; + + OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "tools/worldEditor/scripts/shaders/dbgColorBlindnessVisualizeP.glsl"; + + samplerNames[0] = "$backBuffer"; + + pixVersion = 2.0; +}; + +singleton PostEffect( ColorBlindnessVisualize ) +{ + isEnabled = false; + allowReflectPass = false; + renderTime = "PFXAfterBin"; + renderBin = "GlowBin"; + + shader = ColorBlindnessVisualizeShader; + stateBlock = PFX_DefaultStateBlock; + texture[0] = "$backBuffer"; + target = "$backBuffer"; + renderPriority = 10; +}; + +function ColorBlindnessVisualize::setShaderConsts(%this) +{ + %mode = 0; + + if($CBV_Protanopia) + %mode = 1; + else if($CBV_Protanomaly) + %mode = 2; + else if($CBV_Deuteranopia) + %mode = 3; + else if($CBV_Deuteranomaly) + %mode = 4; + else if($CBV_Tritanopia) + %mode = 5; + else if($CBV_Tritanomaly) + %mode = 6; + else if($CBV_Achromatopsia) + %mode = 7; + else if($CBV_Achromatomaly) + %mode = 8; + + %this.setShaderConst("$mode", %mode); +} + +function ColorBlindnessVisualize::onEnabled( %this ) +{ + AL_NormalsVisualize.disable(); + AL_DepthVisualize.disable(); + AL_LightSpecularVisualize.disable(); + AL_LightColorVisualize.disable(); + $AL_NormalsVisualizeVar = false; + $AL_DepthVisualizeVar = false; + $AL_LightSpecularVisualizeVar = false; + $AL_LightColorVisualizeVar = false; + + return true; +} \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs index 8c558bfef..0f9f38852 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.cs @@ -272,7 +272,7 @@ function EditorSaveMission() // now write the terrain and mission files out: if(EWorldEditor.isDirty || ETerrainEditor.isMissionDirty) - MissionGroup.save($Server::MissionFile); + getScene(0).save($Server::MissionFile); if(ETerrainEditor.isDirty) { // Find all of the terrain files @@ -483,6 +483,21 @@ function EditorOpenMission(%filename) } } +function EditorOpenSceneAppend(%levelAsset) +{ + //Load the asset's level file + exec(%levelAsset.levelFile); + + //We'll assume the scene name and assetname are the same for now + %sceneName = %levelAsset.AssetName; + %scene = nameToID(%sceneName); + if(isObject(%scene)) + { + //Append it to our scene heirarchy + $scenesRootGroup.add(%scene); + } +} + function EditorExportToCollada() { @@ -882,6 +897,64 @@ function EditorDropTypeMenu::setupDefaultState(%this) ////////////////////////////////////////////////////////////////////////// +function EditorSnapToMenu::onSelectItem(%this, %id, %text) +{ + EWorldEditor.SnapTo(%id); +} + +function EditorSnapToMenu::setupDefaultState(%this) +{ + Parent::setupDefaultState(%this); +} + +function WorldEditor::snapTo(%this, %id) +{ + if(%this.getSelectionSize() > 2) + { + error("Please select two objects before selecting a Snap To function."); + return; + } + + %objTarget = %this.getSelectedObject(0); + %objToSnap = %this.getSelectedObject(%this.getSelectionSize()-1); + + switch$(%id) + { + case 0: + %objToSnap.setTransform(setWord(%objToSnap.getTransform(), 0, getWord(%objTarget.getTransform(), 0))); + case 1: + %objTargetXEdge = getWord(%objTarget.getTransform(), 0) + getWord(%objTarget.getObjectBox(), 0); + %objToSnapXEdge = %objTargetXEdge - getWord(%objToSnap.getObjectBox(), 3); + %objToSnap.setTransform(setWord(%objToSnap.getTransform(), 0, %objToSnapXEdge)); + case 2: + %objTargetXEdge = getWord(%objTarget.getTransform(), 0) + getWord(%objTarget.getObjectBox(), 3); + %objToSnapXEdge = %objTargetXEdge - getWord(%objToSnap.getObjectBox(), 0); + %objToSnap.setTransform(setWord(%objToSnap.getTransform(), 0, %objToSnapXEdge)); + case 3: + %objToSnap.setTransform(setWord(%objToSnap.getTransform(), 1, getWord(%objTarget.getTransform(), 1))); + case 4: + %objTargetXEdge = getWord(%objTarget.getTransform(), 1) + getWord(%objTarget.getObjectBox(), 1); + %objToSnapXEdge = %objTargetXEdge - getWord(%objToSnap.getObjectBox(), 4); + %objToSnap.setTransform(setWord(%objToSnap.getTransform(), 1, %objToSnapXEdge)); + case 5: + %objTargetXEdge = getWord(%objTarget.getTransform(), 1) + getWord(%objTarget.getObjectBox(), 4); + %objToSnapXEdge = %objTargetXEdge - getWord(%objToSnap.getObjectBox(), 1); + %objToSnap.setTransform(setWord(%objToSnap.getTransform(), 1, %objToSnapXEdge)); + case 6: + %objToSnap.setTransform(setWord(%objToSnap.getTransform(), 2, getWord(%objTarget.getTransform(), 2))); + case 7: + %objTargetXEdge = getWord(%objTarget.getTransform(), 2) + getWord(%objTarget.getObjectBox(), 2); + %objToSnapXEdge = %objTargetXEdge - getWord(%objToSnap.getObjectBox(), 5); + %objToSnap.setTransform(setWord(%objToSnap.getTransform(), 2, %objToSnapXEdge)); + case 8: + %objTargetXEdge = getWord(%objTarget.getTransform(), 2) + getWord(%objTarget.getObjectBox(), 5); + %objToSnapXEdge = %objTargetXEdge - getWord(%objToSnap.getObjectBox(), 2); + %objToSnap.setTransform(setWord(%objToSnap.getTransform(), 2, %objToSnapXEdge)); + } +} + +////////////////////////////////////////////////////////////////////////// + function EditorAlignBoundsMenu::onSelectItem(%this, %id, %text) { // Have the editor align all selected objects by the selected bounds. diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/menus.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/menus.ed.cs index e0d53a76d..57338ba1f 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/menus.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/menus.ed.cs @@ -113,7 +113,7 @@ function EditorGui::buildMenus(%this) %this.menuBar = new GuiMenuBar(WorldEditorMenubar) { dynamicItemInsertPos = 3; - extent = "1024 20"; + extent = Canvas.extent.x SPC "20"; minExtent = "320 20"; horizSizing = "width"; profile = "GuiMenuBarProfile"; @@ -233,8 +233,32 @@ function EditorGui::buildMenus(%this) Item[15] = "Manage Bookmarks..." TAB "Ctrl-Shift B" TAB "EditorGui.toggleCameraBookmarkWindow();"; item[16] = "Jump to Bookmark" TAB %this.cameraBookmarksMenu; }; + %this.menuBar.insert(%cameraMenu); - + + // Snap Menu + %snapToMenu = new PopupMenu() + { + superClass = "MenuBuilder"; + class = "EditorSnapToMenu"; + + barTitle = "SnapTo"; + + // The onSelectItem() callback for this menu re-purposes the command field + // as the MenuBuilder version is not used. + item[0] = "Snap 2nd Object To 1st X" TAB "" TAB "X"; + item[1] = "Snap 2nd Object To 1st X+" TAB "" TAB "X+"; + item[2] = "Snap 2nd Object To 1st X-" TAB "" TAB "X-"; + item[3] = "Snap 2nd Object To 1st Y" TAB "" TAB "Y"; + item[4] = "Snap 2nd Object to 1st Y+" TAB "" TAB "Y+"; + item[5] = "Snap 2nd Object to 1st Y-" TAB "" TAB "Y-"; + item[6] = "Snap 2nd Object To 1st Z" TAB "" TAB "Z"; + item[7] = "Snap 2nd Object to 1st Z+" TAB "" TAB "Z+"; + item[8] = "Snap 2nd Object to 1st Z-" TAB "" TAB "Z-"; + + }; + %this.menuBar.insert(%snapToMenu); + // Editors Menu %editorsMenu = new PopupMenu() { @@ -251,6 +275,41 @@ function EditorGui::buildMenus(%this) //item[5] = "-"; }; %this.menuBar.insert(%editorsMenu); + + //if we're just refreshing the menus, we probably have a list of editors we want added to the Editors menu there, so check and if so, add them now + if(isObject(EditorsMenuList)) + { + %editorsListCount = EditorsMenuList.count(); + + for(%e = 0; %e < %editorsListCount; %e++) + { + %menuEntry = EditorsMenuList.getKey(%e); + %editorsMenu.addItem(%e, %menuEntry); + } + } + + if(isObject(PhysicsEditorPlugin)) + { + %physicsToolsMenu = new PopupMenu() + { + superClass = "MenuBuilder"; + //class = "PhysXToolsMenu"; + + barTitle = "Physics"; + + item[0] = "Start Simulation" TAB "Ctrl-Alt P" TAB "physicsStartSimulation( \"client\" );physicsStartSimulation( \"server\" );"; + //item[1] = "Stop Simulation" TAB "" TAB "physicsSetTimeScale( 0 );"; + item[1] = "-"; + item[2] = "Speed 25%" TAB "" TAB "physicsSetTimeScale( 0.25 );"; + item[3] = "Speed 50%" TAB "" TAB "physicsSetTimeScale( 0.5 );"; + item[4] = "Speed 100%" TAB "" TAB "physicsSetTimeScale( 1.0 );"; + item[5] = "-"; + item[6] = "Reload NXBs" TAB "" TAB ""; + }; + + // Add our menu. + %this.menuBar.insert( %physicsToolsMenu, EditorGui.menuBar.dynamicItemInsertPos ); + } // Lighting Menu %lightingMenu = new PopupMenu() @@ -389,6 +448,11 @@ function EditorGui::buildMenus(%this) ////////////////////////////////////////////////////////////////////////// +function WorldEditorMenubar::onResize(%this) +{ + %this.extent.x = Canvas.extent.x; +} + function EditorGui::attachMenus(%this) { %this.menuBar.attachToCanvas(Canvas, 0); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBlindnessVisualizeP.glsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBlindnessVisualizeP.glsl new file mode 100644 index 000000000..6dff4aba4 --- /dev/null +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBlindnessVisualizeP.glsl @@ -0,0 +1,121 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +//Using calculations and values provided by Alan Zucconi +// www.alanzucconi.com + +#include "../../../../core/rendering/shaders/gl/hlslCompat.glsl" +#include "shadergen:/autogenConditioners.h" + +in vec2 uv0; +uniform sampler2D backBufferTex; + +in float mode; + +out vec4 OUT_col; + +void main() +{ + vec4 imageColor = texture( backBufferTex, uv0 ); + + if(mode == 0) + { + OUT_col = imageColor; + } + else + { + vec3 R = imageColor.r; + vec3 G = imageColor.g; + vec3 B = imageColor.b; + + if(mode == 1) // Protanopia + { + R = vec3(0.56667, 0.43333, 0); + G = vec3(0.55833, 0.44167, 0); + B = vec3(0, 0.24167, 0.75833); + } + else if(mode == 2) // Protanomaly + { + R = vec3(0.81667, 0.18333, 0); + G = vec3(0.33333, 0.66667, 0); + B = vec3(0, 0.125, 0.875); + } + else if(mode == 3) // Deuteranopia + { + R = vec3(0.625, 0.375, 0); + G = vec3(0.70, 0.30, 0); + B = vec3(0, 0.30, 0.70); + } + else if(mode == 4) // Deuteranomaly + { + R = vec3(0.80, 0.20, 0); + G = vec3(0.25833, 0.74167, 0); + B = vec3(0, 0.14167, 0.85833); + } + else if(mode == 5) // Tritanopia + { + R = vec3(0.95, 0.05, 0); + G = vec3(0, 0.43333, 0.56667); + B = vec3(0, 0.475, 0.525); + } + else if(mode == 6) // Tritanomaly + { + R = vec3(0.96667, 0.03333, 0); + G = vec3(0, 0.73333, 0.26667); + B = vec3(0, 0.18333, 0.81667); + } + else if(mode == 7) // Achromatopsia + { + R = vec3(0.299, 0.587, 0.114); + G = vec3(0.299, 0.587, 0.114); + B = vec3(0.299, 0.587, 0.114); + } + else if(mode == 8) // Achromatomaly + { + R = vec3(0.618, 0.32, 0.062); + G = vec3(0.163, 0.775, 0.062); + B = vec3(0.163, 0.320, 0.516); + } + + //First set + vec4 c = imageColor; + + c.r = c.r * R[0] + c.g * R[1] + c.b * R[2]; + c.g = c.r * G[0] + c.g * G[1] + c.b * G[2]; + c.b = c.r * B[0] + c.g * B[1] + c.b * B[2]; + + vec3 cb = c.rgb; + + cb.r = c.r * R[0] + c.g * R[1] + c.b * R[2]; + cb.g = c.r * G[0] + c.g * G[1] + c.b * G[2]; + cb.b = c.r * B[0] + c.g * B[1] + c.b * B[2]; + + // Difference + vec3 diff = abs(c.rgb - cb); + + float lum = c.r*.3 + c.g*.59 + c.b*.11; + vec3 bw = vec3(lum, lum, lum); + + // return vec4(lerp(bw, vec3(1, 0, 0), saturate((diff.r + diff.g + diff.b) / 3)), c.a); + OUT_col = vec4(c.rgb,1); + } +} diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBlindnessVisualizeP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBlindnessVisualizeP.hlsl new file mode 100644 index 000000000..fcb4ff41c --- /dev/null +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBlindnessVisualizeP.hlsl @@ -0,0 +1,118 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +//Using calculations and values provided by Alan Zucconi +// www.alanzucconi.com + +#include "../../../../core/rendering/shaders/shaderModelAutoGen.hlsl" +#include "../../../../core/rendering/shaders/postFX/postFx.hlsl" + +TORQUE_UNIFORM_SAMPLER2D(backBufferTex,0); + +uniform float mode; + +float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 +{ + float4 imageColor = TORQUE_TEX2D( backBufferTex, IN.uv0 ); + + if(mode == 0) + { + return imageColor; + } + else + { + float3 R = imageColor.r; + float3 G = imageColor.g; + float3 B = imageColor.b; + + if(mode == 1) // Protanopia + { + R = float3(0.56667, 0.43333, 0); + G = float3(0.55833, 0.44167, 0); + B = float3(0, 0.24167, 0.75833); + } + else if(mode == 2) // Protanomaly + { + R = float3(0.81667, 0.18333, 0); + G = float3(0.33333, 0.66667, 0); + B = float3(0, 0.125, 0.875); + } + else if(mode == 3) // Deuteranopia + { + R = float3(0.625, 0.375, 0); + G = float3(0.70, 0.30, 0); + B = float3(0, 0.30, 0.70); + } + else if(mode == 4) // Deuteranomaly + { + R = float3(0.80, 0.20, 0); + G = float3(0.25833, 0.74167, 0); + B = float3(0, 0.14167, 0.85833); + } + else if(mode == 5) // Tritanopia + { + R = float3(0.95, 0.05, 0); + G = float3(0, 0.43333, 0.56667); + B = float3(0, 0.475, 0.525); + } + else if(mode == 6) // Tritanomaly + { + R = float3(0.96667, 0.03333, 0); + G = float3(0, 0.73333, 0.26667); + B = float3(0, 0.18333, 0.81667); + } + else if(mode == 7) // Achromatopsia + { + R = float3(0.299, 0.587, 0.114); + G = float3(0.299, 0.587, 0.114); + B = float3(0.299, 0.587, 0.114); + } + else if(mode == 8) // Achromatomaly + { + R = float3(0.618, 0.32, 0.062); + G = float3(0.163, 0.775, 0.062); + B = float3(0.163, 0.320, 0.516); + } + + //First set + float4 c = imageColor; + + c.r = c.r * R[0] + c.g * R[1] + c.b * R[2]; + c.g = c.r * G[0] + c.g * G[1] + c.b * G[2]; + c.b = c.r * B[0] + c.g * B[1] + c.b * B[2]; + + float3 cb = c.rgb; + + cb.r = c.r * R[0] + c.g * R[1] + c.b * R[2]; + cb.g = c.r * G[0] + c.g * G[1] + c.b * G[2]; + cb.b = c.r * B[0] + c.g * B[1] + c.b * B[2]; + + // Difference + float3 diff = abs(c.rgb - cb); + + float lum = c.r*.3 + c.g*.59 + c.b*.11; + float3 bw = float3(lum, lum, lum); + + // return float4(lerp(bw, float3(1, 0, 0), saturate((diff.r + diff.g + diff.b) / 3)), c.a); + return float4(c.rgb,1); + } +} diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBufferP.glsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBufferP.glsl index 0b7e370bf..01b2d737b 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBufferP.glsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBufferP.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/gl/hlslCompat.glsl" +#include "../../../../core/rendering/shaders/gl/hlslCompat.glsl" in vec2 uv0; uniform sampler2D colorBufferTex; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBufferP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBufferP.hlsl index e996f840a..e7bf0e5e9 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBufferP.hlsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgColorBufferP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/postfx/postFx.hlsl" +#include "../../../../core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(colorBufferTex,0); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.glsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.glsl index 8ada46462..8e034a55f 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.glsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/gl/hlslCompat.glsl" +#include "../../../../core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" in vec2 uv0; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.hlsl index 83547571a..26147b5be 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.hlsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgDepthVisualizeP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/postfx/postFx.hlsl" -#include "core/shaders/shaderModelAutoGen.hlsl" +#include "../../../../core/rendering/shaders/postFX/postFx.hlsl" +#include "../../../../core/rendering/shaders/shaderModelAutoGen.hlsl" TORQUE_UNIFORM_SAMPLER2D(deferredTex, 0); TORQUE_UNIFORM_SAMPLER1D(depthViz, 1); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgGlowVisualizeP.glsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgGlowVisualizeP.glsl index cdc58d7c6..85afcf4c8 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgGlowVisualizeP.glsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgGlowVisualizeP.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/gl/hlslCompat.glsl" +#include "../../../../core/rendering/shaders/gl/hlslCompat.glsl" in vec2 uv0; uniform sampler2D glowBuffer; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgGlowVisualizeP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgGlowVisualizeP.hlsl index b78d29d67..d4b3028f8 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgGlowVisualizeP.hlsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgGlowVisualizeP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/postfx/postFx.hlsl" +#include "../../../../core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(glowBuffer, 0); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightColorVisualizeP.glsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightColorVisualizeP.glsl index 86fb67268..d354adc0d 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightColorVisualizeP.glsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightColorVisualizeP.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/gl/hlslCompat.glsl" +#include "../../../../core/rendering/shaders/gl/hlslCompat.glsl" in vec2 uv0; uniform sampler2D lightDeferredTex; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightColorVisualizeP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightColorVisualizeP.hlsl index 38e5832f5..f178e66c0 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightColorVisualizeP.hlsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightColorVisualizeP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/shaderModelAutoGen.hlsl" -#include "core/shaders/postfx/postFx.hlsl" +#include "../../../../core/rendering/shaders/shaderModelAutoGen.hlsl" +#include "../../../../core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(lightDeferredTex,0); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightSpecularVisualizeP.glsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightSpecularVisualizeP.glsl index e8a037d2b..51fe2f8eb 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightSpecularVisualizeP.glsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightSpecularVisualizeP.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/gl/hlslCompat.glsl" +#include "../../../../core/rendering/shaders/gl/hlslCompat.glsl" in vec2 uv0; uniform sampler2D lightDeferredTex; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightSpecularVisualizeP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightSpecularVisualizeP.hlsl index 66424a11f..7c45e4115 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightSpecularVisualizeP.hlsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgLightSpecularVisualizeP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/postfx/postFx.hlsl" +#include "../../../../core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(lightDeferredTex,0); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.glsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.glsl index ab3323360..274dc0369 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.glsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/gl/hlslCompat.glsl" +#include "../../../../core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" in vec2 uv0; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.hlsl index 913745bb5..2d813a0eb 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.hlsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgNormalVisualizeP.hlsl @@ -20,8 +20,8 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/postfx/postFx.hlsl" -#include "core/shaders/shaderModelAutoGen.hlsl" +#include "../../../../core/rendering/shaders/postFX/postFx.hlsl" +#include "../../../../core/rendering/shaders/shaderModelAutoGen.hlsl" TORQUE_UNIFORM_SAMPLER2D(deferredTex, 0); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgShadowVisualizeP.glsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgShadowVisualizeP.glsl index f73f7812d..3f6f775b6 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgShadowVisualizeP.glsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgShadowVisualizeP.glsl @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/gl/hlslCompat.glsl" +#include "../../../../core/rendering/shaders/gl/hlslCompat.glsl" in vec2 uv0; uniform sampler2D shadowMap; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgShadowVisualizeP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgShadowVisualizeP.hlsl index 3c56c2abd..a4978a49f 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgShadowVisualizeP.hlsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgShadowVisualizeP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/shaderModel.hlsl" +#include "../../../../core/rendering/shaders/shaderModel.hlsl" struct MaterialDecoratorConnectV { diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgSpecMapVisualizeP.glsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgSpecMapVisualizeP.glsl index d391a1963..6342ed973 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgSpecMapVisualizeP.glsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgSpecMapVisualizeP.glsl @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/gl/hlslCompat.glsl" +#include "../../../../core/rendering/shaders/gl/hlslCompat.glsl" in vec2 uv0; uniform sampler2D matinfoTex; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgSpecMapVisualizeP.hlsl b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgSpecMapVisualizeP.hlsl index 59252cd7b..6dd32a480 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgSpecMapVisualizeP.hlsl +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/shaders/dbgSpecMapVisualizeP.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "core/shaders/postfx/postFx.hlsl" +#include "../../../../core/rendering/shaders/postFX/postFx.hlsl" TORQUE_UNIFORM_SAMPLER2D(matinfoTex,0); diff --git a/Templates/Full/game/art/shapes/cube/cube.dae b/Templates/Full/game/art/shapes/cube/cube.dae index 720fdc14c..d6c1d4bcc 100644 --- a/Templates/Full/game/art/shapes/cube/cube.dae +++ b/Templates/Full/game/art/shapes/cube/cube.dae @@ -1,119 +1,73 @@ - + - Matt - 3dsMax 10 - Feeling ColladaMax v3.05B. - ColladaMax Export Options: ExportNormals=1;ExportEPolyAsTriangles=1;ExportXRefs=1;ExportSelected=0;ExportTangents=0;ExportAnimations=0;SampleAnim=1;ExportAnimClip=1;BakeMatrices=1;ExportRelativePaths=1;AnimStart=0;AnimEnd=3.33333; - cube.max + Blender User + Blender 2.79.0 commit date:2017-09-11, commit time:10:43, hash:5bd8ac9 - 2009-09-09T07:28:49Z - 2009-09-09T07:28:53Z - + 2019-02-11T07:13:36 + 2019-02-11T07:13:36 + Z_UP - - ./grid.dds + + grid.dds - - - - - - + - grid.dds - A8R8G8B8 + grid_dds grid_dds-surface - WRAP - WRAP - NONE - NONE - NONE + + 0 0 0 1 + - 0.588235 0.588235 0.588235 1 + 0 0 0 1 - - - - 0 - 0 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - - - 1 - - - + - 0.9 0.9 0.9 1 + 0.3743451 0.3743451 0.3743451 1 - 0.415939 + 50 - - 0 0 0 1 - - - 1 - 1 1 1 1 - - 1 - + + 1 + - - - - 0 - - - 0 - - - - - - 0 - 0 - 0 - 0 - - + + + + + - -0.5 -0.5 0 0.5 -0.5 0 -0.5 0.5 0 0.5 0.5 0 -0.5 -0.5 1 0.5 -0.5 1 -0.5 0.5 1 0.5 0.5 1 + -0.5 -0.5 0 0.5 -0.5 0 -0.5 0.5 0 0.5 0.5 0 -0.5 -0.5 1 0.5 -0.5 1 -0.5 0.5 1 0.5 0.5 1 0.1666666 0.5 0.3333333 -0.1666666 0.5 0.6666666 -0.5 0.1666666 0.3333333 -0.5 -0.1666666 0.6666666 -0.5 0.5 0.3333333 -0.5 0.5 0.6666666 -0.1666666 -0.5 0.3333333 0.1666666 -0.5 0.6666666 -0.5 -0.5 0.3333333 -0.5 -0.5 0.6666666 -0.1666666 0.5 0 0.1666666 0.5 0 0.5 0.5 0.3333333 0.5 0.5 0.6666666 -0.1666666 -0.1666666 1 0.1666666 0.1666666 1 0.5 -0.1666666 1 0.5 0.1666666 1 -0.1666666 -0.1666666 0 0.1666666 0.1666666 0 -0.5 -0.1666666 1 -0.5 0.1666666 1 0.5 -0.1666666 0 0.5 0.1666666 0 -0.5 -0.1666666 0 -0.5 0.1666666 0 -0.1666666 -0.5 1 0.1666666 -0.5 1 0.5 -0.1666666 0.3333333 0.5 0.1666666 0.6666666 0.5 -0.5 0.3333333 0.5 -0.5 0.6666666 -0.1666666 -0.5 0 0.1666666 -0.5 0 -0.1666666 0.5 1 0.1666666 0.5 1 -0.5 0.1666666 0.6666666 -0.5 -0.1666666 0.3333333 0.1666666 0.5 0.6666666 -0.1666666 0.5 0.3333333 0.5 -0.1666666 0.6666666 0.5 0.1666666 0.3333333 -0.1666666 -0.5 0.6666666 0.1666666 -0.5 0.3333333 -0.1666666 0.1666666 1 0.1666666 -0.1666666 1 0.1666666 -0.1666666 0 -0.1666666 0.1666666 0 - + @@ -121,65 +75,63 @@ - 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 + 0 0 -1 0 0 1 0 -1 0 1 0 0 0 1 0 -1 0 0 - + - - 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0 + + 1 0 1 0.3333333 0.6666666 0.3333333 0 1 0 0.6666667 0.3333333 0.6666667 0 0 0.3333333 0 0.3333333 0.3333333 1 1 0.6666667 1 0.6666667 0.6666667 0 0 0.3333333 0 0.3333333 0.3333333 1 1 0.6666667 1 0.6666667 0.6666667 0 0 0.3333333 0 0.3333333 0.3333333 1 1 0.6666667 1 0.6666667 0.6666667 0 0 0.3333333 0 0.3333333 0.3333333 1 1 0.6666666 1 0.6666667 0.6666667 0 0 0.3333333 0 0.3333333 0.3333333 1 1 0.6666666 1 0.6666667 0.6666667 0.3333333 0.3333333 0 0.3333333 0 0 0.6666667 0.6666667 0.3333333 0.6666667 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.6666667 0 0.3333333 0.3333333 0.6666667 0 0.6666667 0 0.3333333 0.6666667 0.6666667 0.6666666 1 0.3333333 0.6666667 0.6666666 1 0.3333333 1 0.3333333 0.6666667 0.3333333 0.6666667 0.3333333 1 0 0.6666667 0.3333333 1 0 1 0 0.6666667 0.6666667 0.6666667 1 0.6666667 1 1 0.3333333 0.3333333 0.6666667 0.3333333 0.6666667 0.6666667 0.6666667 0.6666667 0.6666667 0.3333333 1 0.6666667 0.6666667 0.3333333 1 0.3333333 1 0.6666667 0.3333333 0.3333333 0.3333333 0 0.6666667 0.3333333 0.3333333 0 0.6666666 0 0.6666667 0.3333333 0.6666667 0.3333333 0.6666666 0 1 0.3333333 0.6666666 0 1 0 1 0.3333333 0.3333333 0.3333333 0 0.3333333 0 0 0.6666667 0.6666667 0.3333333 0.6666667 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.6666667 0 0.3333333 0.3333333 0.6666667 0 0.6666667 0 0.3333333 0.6666667 0.6666667 0.6666666 1 0.3333333 0.6666667 0.6666666 1 0.3333333 1 0.3333333 0.6666667 0.3333333 0.6666667 0.3333333 1 0 0.6666667 0.3333333 1 0 1 0 0.6666667 0.6666667 0.6666667 1 0.6666667 1 1 0.3333333 0.3333333 0.6666667 0.3333333 0.6666667 0.6666667 0.6666667 0.6666667 0.6666667 0.3333333 1 0.6666667 0.6666667 0.3333333 1 0.3333333 1 0.6666667 0.3333333 0.3333333 0.3333333 0 0.6666667 0.3333333 0.3333333 0 0.6666666 0 0.6666667 0.3333333 0.6666667 0.3333333 0.6666666 0 1 0.3333333 0.6666666 0 1 0 1 0.3333333 0.3333333 0.3333333 0 0.3333333 0 0 0.6666667 0.6666667 0.3333333 0.6666667 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.6666667 0 0.3333333 0.3333333 0.6666667 0 0.6666667 0 0.3333333 0.6666667 0.6666667 0.6666667 1 0.3333333 0.6666667 0.6666667 1 0.3333333 1 0.3333333 0.6666667 0.3333333 0.6666667 0.3333333 1 0 0.6666667 0.3333333 1 0 1 0 0.6666667 0.6666667 0.6666667 1 0.6666667 1 1 0.3333333 0.3333333 0.6666667 0.3333333 0.6666667 0.6666667 0.6666667 0.6666667 0.6666667 0.3333333 1 0.6666667 0.6666667 0.3333333 1 0.3333333 1 0.6666667 0.3333333 0.3333333 0.3333333 0 0.6666667 0.3333333 0.3333333 0 0.6666667 0 0.6666667 0.3333333 0.6666667 0.3333333 0.6666667 0 1 0.3333333 0.6666667 0 1 0 1 0.3333333 0.3333333 0.3333333 0 0.3333333 0 0 0.6666667 0.6666667 0.3333333 0.6666667 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.6666667 0 0.3333333 0.3333333 0.6666667 0 0.6666667 0 0.3333333 0.6666667 0.6666667 0.6666667 1 0.3333333 0.6666667 0.6666667 1 0.3333333 1 0.3333333 0.6666667 0.3333333 0.6666667 0.3333333 1 0 0.6666667 0.3333333 1 0 1 0 0.6666667 0.6666667 0.6666667 1 0.6666667 1 1 0.3333333 0.3333333 0.6666667 0.3333333 0.6666667 0.6666667 0.6666667 0.6666667 0.6666667 0.3333333 1 0.6666667 0.6666667 0.3333333 1 0.3333333 1 0.6666667 0.3333333 0.3333333 0.3333333 0 0.6666667 0.3333333 0.3333333 0 0.6666667 0 0.6666667 0.3333333 0.6666667 0.3333333 0.6666667 0 1 0.3333333 0.6666667 0 1 0 1 0.3333333 0.3333333 0.3333333 0 0.3333333 0 0 0.6666667 0.6666667 0.3333333 0.6666667 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.6666667 0 0.3333333 0.3333333 0.6666667 0 0.6666667 0 0.3333333 0.6666667 0.6666667 0.6666667 1 0.3333333 0.6666667 0.6666667 1 0.3333333 1 0.3333333 0.6666667 0.3333333 0.6666667 0.3333333 1 0 0.6666667 0.3333333 1 0 1 0 0.6666667 0.6666667 0.6666667 1 0.6666667 1 1 0.3333333 0.3333333 0.6666667 0.3333333 0.6666667 0.6666667 0.6666667 0.6666667 0.6666667 0.3333333 1 0.6666667 0.6666667 0.3333333 1 0.3333333 1 0.6666667 0.3333333 0.3333333 0.3333333 0 0.6666667 0.3333333 0.3333333 0 0.6666667 0 0.6666667 0.3333333 0.6666667 0.3333333 0.6666667 0 1 0.3333333 0.6666667 0 1 0 1 0.3333333 0.6666666 0.3333333 0.6666666 0 1 0 0.3333333 0.6666667 0.3333333 0.3333333 0.6666666 0.3333333 0.6666666 0.3333333 0.3333333 0.3333333 0.6666666 0 0.3333333 0.3333333 0.3333333 0 0.6666666 0 0.3333333 0.6666667 0 0.6666667 0.3333333 0.3333333 0 0.6666667 0 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0 0.3333333 0.3333333 0 0 0.3333333 0 0 0.3333333 0 0.3333333 0.6666667 0.3333333 1 0 1 0.6666666 0.3333333 0.6666666 0.6666667 0.3333333 0.6666667 0.3333333 0.6666667 0.6666666 0.6666667 0.3333333 1 0.6666666 0.6666667 0.6666666 1 0.3333333 1 0.6666666 0.3333333 1 0.3333333 0.6666666 0.6666667 1 0.3333333 1 0.6666667 0.6666666 0.6666667 0.6666666 0.6666667 1 0.6666667 0.6666666 1 1 0.6666667 1 1 0.6666666 1 - + - + + + + + 0.02745097 0.02745097 1 0 0 1 0 0 1 0.02352941 0.02352941 1 0 0 1 0 0 1 1 0.1176471 0.1176471 1 0.003921568 0.003921568 1 0.02352941 0.02352941 1 0.003921568 0.003921568 1 0.09019607 0.09019607 1 0.0862745 0.0862745 0.003921568 0.003921568 1 0 0 1 0.007843136 0.007843136 1 0.9411765 0.0980392 0.1529412 0.854902 0.0117647 0.1529412 0.6313726 0.01568627 0.3843137 0.07058823 0.07058823 1 0.003921568 0.003921568 1 0.07058823 0.07058823 1 1 0.07450979 0.07450979 1 0.04313725 0.04313725 1 0.0980392 0.0980392 0.1372549 0.1372549 1 0.09411764 0.09411764 1 0.2431373 0.2431373 1 1 0.05098038 0.05098038 1 0.172549 0.172549 1 0.0117647 0.0117647 0.1647059 0.1647059 1 0 0 1 0.003921568 0.003921568 1 1 0 0 1 0 0 1 0 0 0.003921568 0.003921568 1 0 0 1 0.1647059 0.1647059 1 1 0 0 1 0.003921568 0.003921568 0.003921568 0.003921568 1 0.003921568 0.003921568 1 1 0.003921568 0.003921568 0 0 1 1 0.003921568 0.003921568 1 0 0 0 0 1 1 0 0 1 0 0 1 0.003921568 0.003921568 1 0 0 1 0.007843136 0.007843136 1 0.003921568 0.003921568 1 0.003921568 0.003921568 1 0.007843136 0.007843136 1 0 0 1 0.007843136 0.007843136 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0.003921568 0.003921568 1 0 0 1 1 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 1 0 0 0.003921568 0.003921568 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0.2431373 0.2431373 1 0.003921568 0.003921568 1 0.1372549 0.1372549 1 1 0.0117647 0.0117647 1 0.04313725 0.04313725 0.2431373 0.2431373 1 0.2431373 0.2431373 1 1 0.04313725 0.04313725 0.003921568 0.003921568 1 1 0.04313725 0.04313725 1 0.1019608 0.1019608 0.003921568 0.003921568 1 1 0.0117647 0.0117647 1 0.172549 0.172549 1 0.04313725 0.04313725 1 0.172549 0.172549 1 0.1254902 0.1254902 1 0.04313725 0.04313725 1 0.04313725 0.04313725 1 0.1254902 0.1254902 1 0.1019608 0.1019608 1 0.1254902 0.1254902 1 0.03137254 0.03137254 1 0.1019608 0.1019608 1 0.0117647 0.0117647 1 0.007843136 0.007843136 1 0.05098038 0.05098038 0.2431373 0.2431373 1 0.0117647 0.0117647 1 1 0.0117647 0.0117647 1 0.0117647 0.0117647 0.0117647 0.0117647 1 1 0.007843136 0.007843136 0.0117647 0.0117647 1 0 0 1 1 0.007843136 0.007843136 0.2431373 0.2431373 1 0.09411764 0.09411764 1 0.0117647 0.0117647 1 0.09411764 0.09411764 1 0.02352941 0.02352941 1 0.0117647 0.0117647 1 0.0117647 0.0117647 1 0.02352941 0.02352941 1 0 0 1 0.02352941 0.02352941 1 0 0 1 0 0 1 0.07058823 0.07058823 1 0.0117647 0.0117647 1 0.07058823 0.07058823 1 1 0.0980392 0.0980392 1 0.1960784 0.1960784 0.07058823 0.07058823 1 0.07058823 0.07058823 1 1 0.1960784 0.1960784 0.0117647 0.0117647 1 1 0.1960784 0.1960784 1 0 0 0.0117647 0.0117647 1 1 0.0980392 0.0980392 1 0.04313725 0.04313725 1 0.1960784 0.1960784 1 0.04313725 0.04313725 1 0.007843136 0.007843136 1 0.1960784 0.1960784 1 0.1960784 0.1960784 1 0.007843136 0.007843136 1 0 0 1 0.007843136 0.007843136 1 0.0117647 0.0117647 1 0 0 1 0.0980392 0.0980392 1 0.09019607 0.09019607 1 0.07450979 0.07450979 0.07058823 0.07058823 1 0.04705882 0.04705882 1 1 0.0980392 0.0980392 1 0.0980392 0.0980392 0.04705882 0.04705882 1 1 0.09019607 0.09019607 0.04705882 0.04705882 1 0 0 1 1 0.09019607 0.09019607 0.07058823 0.07058823 1 0.003921568 0.003921568 1 0.04705882 0.04705882 1 0.003921568 0.003921568 1 0.05490195 0.05490195 1 0.04705882 0.04705882 1 0.04705882 0.04705882 1 0.05490195 0.05490195 1 0 0 1 0.05490195 0.05490195 1 0.0117647 0.0117647 1 0 0 1 0.007843136 0.007843136 1 0.0117647 0.0117647 1 0.003921568 0.003921568 1 0.6313726 0.01568627 0.3843137 0.8313726 0.09019607 0.2588235 0.007843136 0.007843136 1 0.007843136 0.007843136 1 0.8313726 0.09019607 0.2588235 0.0117647 0.0117647 1 0.8313726 0.09019607 0.2588235 0.6901961 0 0.3098039 0.0117647 0.0117647 1 0.6313726 0.01568627 0.3843137 0.854902 0.0117647 0.1529412 0.8313726 0.09019607 0.2588235 0.854902 0.0117647 0.1529412 0.9607843 0.1137255 0.1529412 0.8313726 0.09019607 0.2588235 0.8313726 0.09019607 0.2588235 0.9607843 0.1137255 0.1529412 0.6901961 0 0.3098039 0.9607843 0.1137255 0.1529412 0.9490196 0.1882353 0.2392157 0.6901961 0 0.3098039 0.6313726 0.01568627 0.3843137 0.8470588 0.003921568 0.1568627 0.9411765 0.0980392 0.1529412 0.007843136 0.007843136 1 0.01568627 0.0117647 0.9960784 0.6313726 0.01568627 0.3843137 0.6313726 0.01568627 0.3843137 0.01568627 0.0117647 0.9960784 0.8470588 0.003921568 0.1568627 0.01568627 0.0117647 0.9960784 0.05490195 0.003921568 0.9450981 0.8470588 0.003921568 0.1568627 0.007843136 0.007843136 1 0 0 1 0.01568627 0.0117647 0.9960784 0 0 1 0 0 1 0.01568627 0.01568627 1 0.01568627 0.0117647 0.9960784 0 0 1 0.05490195 0.003921568 0.9450981 0 0 1 0.1333333 0.1333333 1 0.05490195 0.003921568 0.9450981 1 0.02352941 0.02352941 1 0.0117647 0.0117647 1 0.1176471 0.1176471 1 0.0862745 0.0862745 1 0.0117647 0.0117647 1 0.02352941 0.02352941 1 0.02352941 0.02352941 1 0.0117647 0.0117647 1 0.0117647 0.0117647 1 0.0117647 0.0117647 1 0.03529411 0.03529411 1 0.0117647 0.0117647 1 0.0862745 0.0862745 1 0.09019607 0.09019607 1 0.0117647 0.0117647 1 0.09019607 0.09019607 1 0.05098038 0.05098038 1 0.0117647 0.0117647 1 0.0117647 0.0117647 1 0.05098038 0.05098038 1 0.03529411 0.03529411 1 0.05098038 0.05098038 1 0.03137254 0.03137254 1 0.03529411 0.03529411 1 0.0862745 0.0862745 1 0.07450979 0.07450979 1 0.003921568 0.003921568 1 0.02352941 0.02352941 1 0.1843137 0.1843137 1 0.0862745 0.0862745 1 0.0862745 0.0862745 1 0.1843137 0.1843137 1 0.07450979 0.07450979 1 0.1843137 0.1843137 1 0.07843136 0.07843136 1 0.07450979 0.07450979 1 0.02352941 0.02352941 1 0.003921568 0.003921568 1 0.1843137 0.1843137 1 0.003921568 0.003921568 1 0.04705882 0.04705882 1 0.1843137 0.1843137 1 0.1843137 0.1843137 1 0.04705882 0.04705882 1 0.07843136 0.07843136 1 0.04705882 0.04705882 1 0.07843136 0.07843136 1 0.07843136 0.07843136 0 0 1 0.03921568 0.03921568 1 0.02745097 0.02745097 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0.03921568 0.03921568 1 0 0 1 0.01568627 0.01568627 1 0.03921568 0.03921568 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0.01568627 0.01568627 1 0 0 1 0.06274509 0.06274509 1 0.01568627 0.01568627 1 0 0 1 0 0 1 0.02352941 0.02352941 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0.003921568 0.003921568 1 0 0 1 + + + + + - + - -

0 0 9 2 1 11 3 2 10 3 2 10 1 3 8 0 0 9 4 4 8 5 5 9 7 6 11 7 6 11 6 7 10 4 4 8 0 8 4 1 9 5 5 10 7 5 10 7 4 11 6 0 8 4 1 12 0 3 13 1 7 14 3 7 14 3 5 15 2 1 12 0 3 16 4 2 17 5 6 18 7 6 18 7 7 19 6 3 16 4 2 20 0 0 21 1 4 22 3 4 22 3 6 23 2 2 20 0

+ + +

0 0 0 0 32 0 1 1 26 0 2 2 3 0 3 3 31 0 4 4 27 0 5 5 4 1 6 6 34 1 7 7 22 1 8 8 7 1 9 9 43 1 10 10 23 1 11 11 0 2 12 12 40 2 13 13 14 2 14 14 5 2 15 15 35 2 16 16 15 2 17 17 1 3 18 18 30 3 19 19 36 3 20 20 7 3 21 21 25 3 22 22 37 3 23 23 3 4 24 24 19 4 25 25 8 4 26 26 6 4 27 27 42 4 28 28 9 4 29 29 2 5 30 30 33 5 31 31 10 5 32 32 4 5 33 33 28 5 34 34 11 5 35 35 10 5 36 36 12 5 37 37 2 5 38 38 11 5 39 39 44 5 40 40 10 5 41 41 10 5 42 42 44 5 43 43 12 5 44 44 44 5 45 45 13 5 46 46 12 5 47 47 11 5 48 48 28 5 49 49 44 5 50 50 28 5 51 51 29 5 52 52 44 5 53 53 44 5 54 54 29 5 55 55 13 5 56 56 29 5 57 57 6 5 58 58 13 5 59 59 11 5 60 60 17 5 61 61 4 5 62 62 10 5 63 63 45 5 64 64 11 5 65 65 11 5 66 66 45 5 67 67 17 5 68 68 45 5 69 69 16 5 70 70 17 5 71 71 10 5 72 72 33 5 73 73 45 5 74 74 33 5 75 75 32 5 76 76 45 5 77 77 45 5 78 78 32 5 79 79 16 5 80 80 32 5 81 81 0 5 82 82 16 5 83 83 8 4 84 84 20 4 85 85 3 4 86 86 9 4 87 87 46 4 88 88 8 4 89 89 8 4 90 90 46 4 91 91 20 4 92 92 46 4 93 93 21 4 94 94 20 4 95 95 9 4 96 96 42 4 97 97 46 4 98 98 42 4 99 99 43 4 100 100 46 4 101 101 46 4 102 102 43 4 103 103 21 4 104 104 43 4 105 105 7 4 106 106 21 4 107 107 9 4 108 108 13 4 109 109 6 4 110 110 8 4 111 111 47 4 112 112 9 4 113 113 9 4 114 114 47 4 115 115 13 4 116 116 47 4 117 117 12 4 118 118 13 4 119 119 8 4 120 120 19 4 121 121 47 4 122 122 19 4 123 123 18 4 124 124 47 4 125 125 47 4 126 126 18 4 127 127 12 4 128 128 18 4 129 129 2 4 130 130 12 4 131 131 36 3 132 132 38 3 133 133 1 3 134 134 37 3 135 135 48 3 136 136 36 3 137 137 36 3 138 138 48 3 139 139 38 3 140 140 48 3 141 141 39 3 142 142 38 3 143 143 37 3 144 144 25 3 145 145 48 3 146 146 25 3 147 147 24 3 148 148 48 3 149 149 48 3 150 150 24 3 151 151 39 3 152 152 24 3 153 153 5 3 154 154 39 3 155 155 37 3 156 156 21 3 157 157 7 3 158 158 36 3 159 159 49 3 160 160 37 3 161 161 37 3 162 162 49 3 163 163 21 3 164 164 49 3 165 165 20 3 166 166 21 3 167 167 36 3 168 168 30 3 169 169 49 3 170 170 30 3 171 171 31 3 172 172 49 3 173 173 49 3 174 174 31 3 175 175 20 3 176 176 31 3 177 177 3 3 178 178 20 3 179 179 14 2 180 180 16 2 181 181 0 2 182 182 15 2 183 183 50 2 184 184 14 2 185 185 14 2 186 186 50 2 187 187 16 2 188 188 50 2 189 189 17 2 190 190 16 2 191 191 15 2 192 192 35 2 193 193 50 2 194 194 35 2 195 195 34 2 196 196 50 2 197 197 50 2 198 198 34 2 199 199 17 2 200 200 34 2 201 201 4 2 202 202 17 2 203 203 15 2 204 204 39 2 205 205 5 2 206 206 14 2 207 207 51 2 208 208 15 2 209 209 15 2 210 210 51 2 211 211 39 2 212 212 51 2 213 213 38 2 214 214 39 2 215 215 14 2 216 216 40 2 217 217 51 2 218 218 40 2 219 219 41 2 220 220 51 2 221 221 51 2 222 222 41 2 223 223 38 2 224 224 41 2 225 225 1 2 226 226 38 2 227 227 22 1 228 228 28 1 229 229 4 1 230 230 23 1 231 231 52 1 232 232 22 1 233 233 22 1 234 234 52 1 235 235 28 1 236 236 52 1 237 237 29 1 238 238 28 1 239 239 23 1 240 240 43 1 241 241 52 1 242 242 43 1 243 243 42 1 244 244 52 1 245 245 52 1 246 246 42 1 247 247 29 1 248 248 42 1 249 249 6 1 250 250 29 1 251 251 23 1 252 252 25 1 253 253 7 1 254 254 22 1 255 255 53 1 256 256 23 1 257 257 23 1 258 258 53 1 259 259 25 1 260 260 53 1 261 261 24 1 262 262 25 1 263 263 22 1 264 264 34 1 265 265 53 1 266 266 34 1 267 267 35 1 268 268 53 1 269 269 53 1 270 270 35 1 271 271 24 1 272 272 35 1 273 273 5 1 274 274 24 1 275 275 26 0 276 276 40 0 277 277 0 0 278 278 27 0 279 279 54 0 280 280 26 0 281 281 26 0 282 282 54 0 283 283 40 0 284 284 54 0 285 285 41 0 286 286 40 0 287 287 27 0 288 288 31 0 289 289 54 0 290 290 31 0 291 291 30 0 292 292 54 0 293 293 54 0 294 294 30 0 295 295 41 0 296 296 30 0 297 297 1 0 298 298 41 0 299 299 27 0 300 300 19 0 301 301 3 0 302 302 26 0 303 303 55 0 304 304 27 0 305 305 27 0 306 306 55 0 307 307 19 0 308 308 55 0 309 309 18 0 310 310 19 0 311 311 26 0 312 312 32 0 313 313 55 0 314 314 32 0 315 315 33 0 316 316 55 0 317 317 55 0 318 318 33 0 319 319 18 0 320 320 33 0 321 321 2 0 322 322 18 0 323 323

+ - - - 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 - + + + 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 + - - - + - - - 0 - 3.33333 - - - - - 30 - - - + -
+
\ No newline at end of file diff --git a/Templates/Full/game/core/scripts/client/audioEnvironments.cs b/Templates/Full/game/core/scripts/client/audioEnvironments.cs index 09fc4de1a..b2c70d589 100644 --- a/Templates/Full/game/core/scripts/client/audioEnvironments.cs +++ b/Templates/Full/game/core/scripts/client/audioEnvironments.cs @@ -24,893 +24,1366 @@ // // For customized presets, best derive from one of these presets. -singleton SFXEnvironment( AudioEnvOff ) +singleton SFXEnvironment(Generic) { - envSize = "7.5"; - envDiffusion = "1.0"; - room = "-10000"; - roomHF = "-10000"; - roomLF = "0"; - decayTime = "1.0"; - decayHFRatio = "1.0"; - decayLFRatio = "1.0"; - reflections = "-2602"; - reflectionsDelay = "0.007"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "200"; - reverbDelay = "0.011"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "0.0"; - density = "0.0"; - flags = 0x33; -}; - -singleton SFXEnvironment( AudioEnvGeneric ) -{ - envSize = "7.5"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-100"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.83"; - decayLFRatio = "1.0"; - reflections = "-2602"; - reflectionsDelay = "0.007"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "200"; - reverbDelay = "0.011"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvRoom ) -{ - envSize = "1.9"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-454"; - roomLF = "0"; - decayTime = "0.4"; - decayHFRatio = "0.83"; - decayLFRatio = "1.0"; - reflections = "-1646"; - reflectionsDelay = "0.002"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "53"; - reverbDelay = "0.003"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvPaddedCell ) -{ - envSize = "1.4"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-6000"; - roomLF = "0"; - decayTime = "0.17"; - decayHFRatio = "0.1"; - decayLFRatio = "1.0"; - reflections = "-1204"; - reflectionsDelay = "0.001"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "207"; - reverbDelay = "0.002"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvBathroom ) -{ - envSize = "1.4"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-1200"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.54"; - decayLFRatio = "1.0"; - reflections = "-370"; - reflectionsDelay = "0.007"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "1030"; - reverbDelay = "0.011"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "60.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvLivingRoom ) -{ - envSize = "2.5"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-6000"; - roomLF = "0"; - decayTime = "0.5"; - decayHFRatio = "0.1"; - decayLFRatio = "1.0"; - reflections = "-1376"; - reflectionsDelay = "0.003"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "-1104"; - reverbDelay = "0.004"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvStoneRoom ) -{ - envSize = "11.6"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "300"; - roomLF = "0"; - decayTime = "2.31"; - decayHFRatio = "0.64"; - decayLFRatio = "1.0"; - reflections = "-711"; - reflectionsDelay = "0.012"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "83"; - reverbDelay = "0.017"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "-5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvAuditorium ) -{ - envSize = "21.6"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-476"; - roomLF = "0"; - decayTime = "4.32"; - decayHFRatio = "0.59"; - decayLFRatio = "1.0"; - reflections = "0.789"; - reflectionsDelay = "0.02"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "-289"; - reverbDelay = "0.03"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvConcertHall ) -{ - envSize = "19.6"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-500"; - roomLF = "0"; - decayTime = "3.92"; - decayHFRatio = "0.7"; - decayLFRatio = "1.0"; - reflections = "-1230"; - reflectionsDelay = "0.02"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "-2"; - reverbDelay = "0.029"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvCave ) -{ - envSize = "14.6"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "0"; - roomLF = "0"; - decayTime = "2.91"; - decayHFRatio = "1.3"; - decayLFRatio = "1.0"; - reflections = "-602"; - reflectionsDelay = "0.015"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "-302"; - reverbDelay = "0.022"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x1f; -}; - -singleton SFXEnvironment( AudioEnvArena ) -{ - envSize = "36.2f"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-698"; - roomLF = "0"; - decayTime = "7.24"; - decayHFRatio = "0.33"; - decayLFRatio = "1.0"; - reflections = "-1166"; - reflectionsDelay = "0.02"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "16"; - reverbDelay = "0.03"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvHangar ) -{ - envSize = "50.3"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-1000"; - roomLF = "0"; - decayTime = "10.05"; - decayHFRatio = "0.23"; - decayLFRatio = "1.0"; - reflections = "-602"; - reflectionsDelay = "0.02"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "198"; - reverbDelay = "0.03"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvCarpettedHallway ) -{ - envSize = "1.9"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-4000"; - roomLF = "0"; - decayTime = "0.3"; - decayHFRatio = "0.1"; - decayLFRatio = "1.0"; - reflections = "-1831"; - reflectionsDelay = "0.002"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "-1630"; - reverbDelay = "0.03"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvHallway ) -{ - envSize = "1.8"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-300"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.59"; - decayLFRatio = "1.0"; - reflections = "-1219"; - reflectionsDelay = "0.007"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "441"; - reverbDelay = "0.011"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvStoneCorridor ) -{ - envSize = "13.5"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-237"; - roomLF = "0"; - decayTime = "2.7"; - decayHFRatio = "0.79"; - decayLFRatio = "1.0"; - reflections = "-1214"; - reflectionsDelay = "0.013"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "395"; - reverbDelay = "0.02"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvAlley ) -{ - envSize = "7.5"; - envDiffusion = "0.3"; - room = "-1000"; - roomHF = "-270"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.86"; - decayLFRatio = "1.0"; - reflections = "-1204"; - reflectionsDelay = "0.007"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "-4"; - reverbDelay = "0.011"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.125"; - echoDepth = "0.95"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvForest ) -{ - envSize = "38.0"; - envDiffusion = "0.3"; - room = "-1000"; - roomHF = "-3300"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.54"; - decayLFRatio = "1.0"; - reflections = "-2560"; - reflectionsDelay = "0.162"; - reflectionsPan[ 0 ] = "0.0"; - reflectionsPan[ 1 ] = "0.0"; - reflectionsPan[ 2 ] = "0.0"; - reverb = "-229"; - reverbDelay = "0.088"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.125"; - echoDepth = "1.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "79.0"; - density = "100.0"; - flags = 0x3f; -}; - -singleton SFXEnvironment( AudioEnvCity ) -{ - envSize = "7.5"; - envDiffusion = "0.5"; - room = "-1000"; - roomHF = "-800"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.67"; - decayLFRatio = "1.0"; - reflections = "-2273"; - reflectionsDelay = "0.007"; + reverbDensity = "1.000"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.8913"; + reverbGainLF = "1.000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.8300"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.0500"; + reflectionDelay = "0.0070"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "-1691"; - reverbDelay = "0.011"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "50.0"; - density = "100.0"; - flags = 0x3f; + lateReverbGain = "1.2589"; + lateReverbDelay = "0.0110"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; }; -singleton SFXEnvironment( AudioEnvMountains ) +singleton SFXEnvironment(PaddedCell) { - envSize = "100.0"; - envDiffusion = "0.27"; - room = "-1000"; - roomHF = "-2500"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.21"; - decayLFRatio = "1.0"; - reflections = "-2780"; - reflectionsDelay = "0.3"; + reverbDensity = "0.1715"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.0010"; + reverbGainLF = "1.000"; + reverbDecayTime = "0.1700"; + reverbDecayHFRatio = "0.1000"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.2500"; + reflectionDelay = "0.0010"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "-1434"; - reverbDelay = "0.1"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "1.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "27.0"; - density = "100.0"; - flags = 0x1f; + lateReverbGain = "1.2691"; + lateReverbDelay = "0.0020"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; }; -singleton SFXEnvironment( AudioEnvQuary ) +singleton SFXEnvironment(PresetRoom) { - envSize = "17.5"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-1000"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.83"; - decayLFRatio = "1.0"; - reflections = "-10000"; - reflectionsDelay = "0.061"; + reverbDensity = "0.4287"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.5929"; + reverbGainLF = "1.000"; + reverbDecayTime = "0.4000"; + reverbDecayHFRatio = "0.8300"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.1503"; + reflectionDelay = "0.0020"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "500"; - reverbDelay = "0.025"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.125"; - echoDepth = "0.7"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; + lateReverbGain = "1.0629"; + lateReverbDelay = "0.0030"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; }; -singleton SFXEnvironment( AudioEnvPlain ) +singleton SFXEnvironment(PresetBathroom) { - envSize = "42.5"; - envDiffusion = "0.21"; - room = "-1000"; - roomHF = "-2000"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.5"; - decayLFRatio = "1.0"; - reflections = "-2466"; - reflectionsDelay = "0.179"; + reverbDensity = "0.1715"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.2512"; + reverbGainLF = "1.000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.5400"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.6531"; + reflectionDelay = "0.0070"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "-1926"; - reverbDelay = "0.1"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "1.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "21.0"; - density = "100.0"; - flags = 0x3f; + lateReverbGain = "3.2734"; + lateReverbDelay = "0.0110"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; }; -singleton SFXEnvironment( AudioEnvParkingLot ) +singleton SFXEnvironment(PresetLivingroom) { - envSize = "8.3"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "0"; - roomLF = "0"; - decayTime = "1.65"; - decayHFRatio = "1.5"; - decayLFRatio = "1.0"; - reflections = "-1363"; - reflectionsDelay = "0.008"; + reverbDensity = "0.9766"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.0010"; + reverbGainLF = "1.0000"; + reverbDecayTime = "0.0900"; + reverbDecayHFRatio = "0.5000"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.2051"; + reflectionDelay = "0.0030"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "-1153"; - reverbDelay = "0.012"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x1f; + lateReverbGain = "0.2805"; + lateReverbDelay = "0.0040"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; }; -singleton SFXEnvironment( AudioEnvSewerPipe ) +singleton SFXEnvironment(PresetStoneroom) { - envSize = "1.7"; - envDiffusion = "0.8"; - room = "-1000"; - roomHF = "-1000"; - roomLF = "0"; - decayTime = "2.81"; - decayHFRatio = "0.14"; - decayLFRatio = "1.0"; - reflections = "429"; - reflectionsDelay = "0.014"; + reverbDensity = "1.000"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.7079"; + reverbGainLF = "1.0000"; + reverbDecayTime = "2.3100"; + reverbDecayHFRatio = "0.6400"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.4411"; + reflectionDelay = "0.0120"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "1023"; - reverbDelay = "0.21"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "0.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "80.0"; - density = "60.0"; - flags = 0x3f; + lateReverbGain = "1.1003"; + lateReverbDelay = "0.0170"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; }; -singleton SFXEnvironment( AudioEnvUnderwater ) +singleton SFXEnvironment(PresetAuditorium) { - envSize = "1.8"; - envDiffusion = "1.0"; - room = "-1000"; - roomHF = "-4000"; - roomLF = "0"; - decayTime = "1.49"; - decayHFRatio = "0.1"; - decayLFRatio = "1.0"; - reflections = "-449"; - reflectionsDelay = "0.007"; + reverbDensity = "1.000"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.5781"; + reverbGainLF = "1.0000"; + reverbDecayTime = "4.3200"; + reverbDecayHFRatio = "0.5900"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.4032"; + reflectionDelay = "0.0200"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "1700"; - reverbDelay = "0.011"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "1.18"; - modulationDepth = "0.348"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x3f; + lateReverbGain = "0.7170"; + lateReverbDelay = "0.0300"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; }; -singleton SFXEnvironment( AudioEnvDrugged ) +singleton SFXEnvironment(PresetConcerthall) { - envSize = "1.9"; - envDiffusion = "0.5"; - room = "-1000"; - roomHF = "0"; - roomLF = "0"; - decayTime = "8.39"; - decayHFRatio = "1.39"; - decayLFRatio = "1.0"; - reflections = "-115"; - reflectionsDelay = "0.002"; + reverbDensity = "1.000"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.5632"; + reverbGainLF = "1.0000"; + reverbDecayTime = "3.9200"; + reverbDecayHFRatio = "0.7000"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.2427"; + reflectionDelay = "0.0200"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "985"; - reverbDelay = "0.03"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "0.25"; - modulationDepth = "1.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x1f; + lateReverbGain = "0.9977"; + lateReverbDelay = "0.0290"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; }; -singleton SFXEnvironment( AudioEnvDizzy ) +singleton SFXEnvironment(PresetCave) { - envSize = "1.8"; - envDiffusion = "0.6"; - room = "-1000.0"; - roomHF = "-400"; - roomLF = "0"; - decayTime = "17.23"; - decayHFRatio = "0.56"; - decayLFRatio = "1.0"; - reflections = "-1713"; - reflectionsDelay = "0.02"; + reverbDensity = "1.000"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "1.000"; + reverbGainLF = "1.0000"; + reverbDecayTime = "2.9100"; + reverbDecayHFRatio = "1.3000"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.5000"; + reflectionDelay = "0.0250"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "-613"; - reverbDelay = "0.03"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "1.0"; - modulationTime = "0.81"; - modulationDepth = "0.31"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x1f; + lateReverbGain = "0.7063"; + lateReverbDelay = "0.0220"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "0"; }; -singleton SFXEnvironment( AudioEnvPsychotic ) +singleton SFXEnvironment(PresetArena) { - envSize = "1.0"; - envDiffusion = "0.5"; - room = "-1000"; - roomHF = "-151"; - roomLF = "0"; - decayTime = "7.56"; - decayHFRatio = "0.91"; - decayLFRatio = "1.0"; - reflections = "-626"; - reflectionsDelay = "0.02"; + reverbDensity = "1.000"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.4477"; + reverbGainLF = "1.0000"; + reverbDecayTime = "7.2400"; + reverbDecayHFRatio = "0.3300"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.2612"; + reflectionDelay = "0.0200"; reflectionsPan[ 0 ] = "0.0"; reflectionsPan[ 1 ] = "0.0"; reflectionsPan[ 2 ] = "0.0"; - reverb = "774"; - reverbDelay = "0.03"; - reverbPan[ 0 ] = "0.0"; - reverbPan[ 1 ] = "0.0"; - reverbPan[ 2 ] = "0.0"; - echoTime = "0.25"; - echoDepth = "0.0"; - modulationTime = "4.0"; - modulationDepth = "1.0"; - airAbsorptionHF = "-5.0"; - HFReference = "5000.0"; - LFReference = "250.0"; - roomRolloffFactor = "0.0"; - diffusion = "100.0"; - density = "100.0"; - flags = 0x1f; + lateReverbGain = "1.0186"; + lateReverbDelay = "0.0300"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetHangar) +{ + reverbDensity = "1.000"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.3162"; + reverbGainLF = "1.0000"; + reverbDecayTime = "10.0500"; + reverbDecayHFRatio = "0.2300"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.5000"; + reflectionDelay = "0.0200"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.2560"; + lateReverbDelay = "0.0300"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetCarpetedHall) +{ + reverbDensity = "0.4287"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.0100"; + reverbGainLF = "1.0000"; + reverbDecayTime = "0.3000"; + reverbDecayHFRatio = "0.1000"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.1215"; + reflectionDelay = "0.0020"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.1531"; + lateReverbDelay = "0.0300"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetHallway) +{ + reverbDensity = "0.3645"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.7079"; + reverbGainLF = "1.0000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.5900"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.2458"; + reflectionDelay = "0.0070"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.6615"; + lateReverbDelay = "0.0110"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetStoneCorridor) +{ + reverbDensity = "1.000"; + reverbDiffusion = "1.000"; + reverbGain = "0.3162"; + reverbGainHF = "0.7612"; + reverbGainLF = "1.0000"; + reverbDecayTime = "2.7000"; + reverbDecayHFRatio = "0.7900"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.2472"; + reflectionDelay = "0.0130"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.5758"; + lateReverbDelay = "0.0200"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetStoneAlley) +{ + reverbDensity = "1.000"; + reverbDiffusion = "0.300"; + reverbGain = "0.3162"; + reverbGainHF = "0.7328"; + reverbGainLF = "1.0000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.8600"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.2500"; + reflectionDelay = "0.0070"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.9954"; + lateReverbDelay = "0.0110"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1250"; + reverbEchoDepth = "0.9500"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetForest) +{ + reverbDensity = "1.000"; + reverbDiffusion = "0.300"; + reverbGain = "0.3162"; + reverbGainHF = "0.0224"; + reverbGainLF = "1.0000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.5400"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.0525"; + reflectionDelay = "0.1620"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.7682"; + lateReverbDelay = "0.0880"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1250"; + reverbEchoDepth = "1.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetCity) +{ + reverbDensity = "1.000"; + reverbDiffusion = "0.500"; + reverbGain = "0.3162"; + reverbGainHF = "0.3981"; + reverbGainLF = "1.0000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.6700"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.0730"; + reflectionDelay = "0.0070"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.1427"; + lateReverbDelay = "0.0110"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1250"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetMountains) +{ + reverbDensity = "1.000"; + reverbDiffusion = "0.2700"; + reverbGain = "0.3162"; + reverbGainHF = "0.0562"; + reverbGainLF = "1.0000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.2100"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.0407"; + reflectionDelay = "0.3000"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.1919"; + lateReverbDelay = "0.1000"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1250"; + reverbEchoDepth = "1.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "0"; +}; + +singleton SFXEnvironment(PresetQuarry) +{ + reverbDensity = "1.000"; + reverbDiffusion = "1.0000"; + reverbGain = "0.3162"; + reverbGainHF = "0.3162"; + reverbGainLF = "1.0000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.8300"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.0000"; + reflectionDelay = "0.0610"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.7783"; + lateReverbDelay = "0.0250"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1250"; + reverbEchoDepth = "0.7000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetPlain) +{ + reverbDensity = "1.000"; + reverbDiffusion = "0.2100"; + reverbGain = "0.3162"; + reverbGainHF = "0.1000"; + reverbGainLF = "1.0000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.5000"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.0585"; + reflectionDelay = "0.1790"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.1089"; + lateReverbDelay = "0.1000"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "1.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetParkinglot) +{ + reverbDensity = "1.000"; + reverbDiffusion = "1.0000"; + reverbGain = "0.3162"; + reverbGainHF = "1.0000"; + reverbGainLF = "1.0000"; + reverbDecayTime = "1.6500"; + reverbDecayHFRatio = "1.5000"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.2082"; + reflectionDelay = "0.0080"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.2652"; + lateReverbDelay = "0.0120"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "0"; +}; + +singleton SFXEnvironment(PresetSewerpipe) +{ + reverbDensity = "0.3071"; + reverbDiffusion = "0.8000"; + reverbGain = "0.3162"; + reverbGainHF = "0.3162"; + reverbGainLF = "1.0000"; + reverbDecayTime = "2.8100"; + reverbDecayHFRatio = "0.1400"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "1.6387"; + reflectionDelay = "0.0140"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "3.2471"; + lateReverbDelay = "0.0210"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetUnderwater) +{ + reverbDensity = "0.3645"; + reverbDiffusion = "1.0000"; + reverbGain = "0.3162"; + reverbGainHF = "0.0100"; + reverbGainLF = "1.0000"; + reverbDecayTime = "1.4900"; + reverbDecayHFRatio = "0.1000"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.5963"; + reflectionDelay = "0.0070"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "7.0795"; + lateReverbDelay = "0.0110"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "1.1800"; + reverbModDepth = "0.3480"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(PresetDrugged) +{ + reverbDensity = "0.4287"; + reverbDiffusion = "0.5000"; + reverbGain = "0.3162"; + reverbGainHF = "1.0000"; + reverbGainLF = "1.0000"; + reverbDecayTime = "8.3900"; + reverbDecayHFRatio = "1.3900"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.8760"; + reflectionDelay = "0.0020"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "3.1081"; + lateReverbDelay = "0.0300"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "1.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "0"; +}; + +singleton SFXEnvironment(PresetDizzy) +{ + reverbDensity = "0.3645"; + reverbDiffusion = "0.6000"; + reverbGain = "0.3162"; + reverbGainHF = "0.6310"; + reverbGainLF = "1.0000"; + reverbDecayTime = "17.2300"; + reverbDecayHFRatio = "0.5600"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.1392"; + reflectionDelay = "0.0200"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.4937"; + lateReverbDelay = "0.0300"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "1.0000"; + reverbModTime = "0.8100"; + reverbModDepth = "0.3100"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "0"; +}; + +singleton SFXEnvironment(PresetPsychotic) +{ + reverbDensity = "0.0625"; + reverbDiffusion = "0.5000"; + reverbGain = "0.3162"; + reverbGainHF = "0.8404"; + reverbGainLF = "1.0000"; + reverbDecayTime = "7.5600"; + reverbDecayHFRatio = "0.9100"; + reverbDecayLFRatio = "1.0000"; + reflectionsGain = "0.4864"; + reflectionDelay = "0.0200"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "2.4378"; + lateReverbDelay = "0.0300"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "4.0000"; + reverbModDepth = "1.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "0"; +}; + +singleton SFXEnvironment(CastleSmallroom) +{ + reverbDensity = "1.0000"; + reverbDiffusion = "0.8900"; + reverbGain = "0.3162"; + reverbGainHF = "0.3981"; + reverbGainLF = "0.1000"; + reverbDecayTime = "1.2200"; + reverbDecayHFRatio = "0.8300"; + reverbDecayLFRatio = "0.3100"; + reflectionsGain = "0.8913"; + reflectionDelay = "0.0220"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.9953"; + lateReverbDelay = "0.0110"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1380"; + reverbEchoDepth = "0.0800"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(CastleShortPassage) +{ + reverbDensity = "1.0000"; + reverbDiffusion = "0.8900"; + reverbGain = "0.3162"; + reverbGainHF = "0.3162"; + reverbGainLF = "0.1000"; + reverbDecayTime = "2.3200"; + reverbDecayHFRatio = "0.8300"; + reverbDecayLFRatio = "0.3100"; + reflectionsGain = "0.8913"; + reflectionDelay = "0.0070"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.2589"; + lateReverbDelay = "0.0230"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1380"; + reverbEchoDepth = "0.0800"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5168.0001"; + reverbLFRef = "139.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(CastleMediumRoom) +{ + reverbDensity = "1.0000"; + reverbDiffusion = "0.9300"; + reverbGain = "0.3162"; + reverbGainHF = "0.2818"; + reverbGainLF = "0.1000"; + reverbDecayTime = "2.0400"; + reverbDecayHFRatio = "0.8300"; + reverbDecayLFRatio = "0.4600"; + reflectionsGain = "0.6310"; + reflectionDelay = "0.0220"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.5849"; + lateReverbDelay = "0.0110"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1550"; + reverbEchoDepth = "0.0300"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5168.0001"; + reverbLFRef = "139.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(CastleLargeRoom) +{ + reverbDensity = "1.0000"; + reverbDiffusion = "0.8200"; + reverbGain = "0.3162"; + reverbGainHF = "0.2818"; + reverbGainLF = "0.1259"; + reverbDecayTime = "2.5300"; + reverbDecayHFRatio = "0.8300"; + reverbDecayLFRatio = "0.5000"; + reflectionsGain = "0.4467"; + reflectionDelay = "0.0340"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.2589"; + lateReverbDelay = "0.0160"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1850"; + reverbEchoDepth = "0.0700"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5168.0001"; + reverbLFRef = "139.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(CastleLongPassage) +{ + reverbDensity = "1.0000"; + reverbDiffusion = "0.8900"; + reverbGain = "0.3162"; + reverbGainHF = "0.3981"; + reverbGainLF = "0.1000"; + reverbDecayTime = "3.4200"; + reverbDecayHFRatio = "0.8300"; + reverbDecayLFRatio = "0.3100"; + reflectionsGain = "0.8913"; + reflectionDelay = "0.0070"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.4125"; + lateReverbDelay = "0.0230"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1380"; + reverbEchoDepth = "0.0800"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5168.0001"; + reverbLFRef = "139.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(CastleHall) +{ + reverbDensity = "1.0000"; + reverbDiffusion = "0.8100"; + reverbGain = "0.3162"; + reverbGainHF = "0.2818"; + reverbGainLF = "0.1778"; + reverbDecayTime = "3.1400"; + reverbDecayHFRatio = "0.7900"; + reverbDecayLFRatio = "0.6200"; + reflectionsGain = "0.1778"; + reflectionDelay = "0.0560"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.1220"; + lateReverbDelay = "0.0240"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5168.0001"; + reverbLFRef = "139.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(CastleCupboard) +{ + reverbDensity = "1.0000"; + reverbDiffusion = "0.8900"; + reverbGain = "0.3162"; + reverbGainHF = "0.2818"; + reverbGainLF = "0.1000"; + reverbDecayTime = "0.6700"; + reverbDecayHFRatio = "0.8700"; + reverbDecayLFRatio = "0.3100"; + reflectionsGain = "1.4125"; + reflectionDelay = "0.0100"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "3.5481"; + lateReverbDelay = "0.0070"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1380"; + reverbEchoDepth = "0.0800"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5168.0001"; + reverbLFRef = "139.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(CastleCourtyard) +{ + reverbDensity = "1.0000"; + reverbDiffusion = "0.4200"; + reverbGain = "0.3162"; + reverbGainHF = "0.4467"; + reverbGainLF = "0.1995"; + reverbDecayTime = "2.1300"; + reverbDecayHFRatio = "0.6100"; + reverbDecayLFRatio = "0.2300"; + reflectionsGain = "0.2239"; + reflectionDelay = "0.1600"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.7079"; + lateReverbDelay = "0.0360"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.3700"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5000.0000"; + reverbLFRef = "250.0000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "0"; +}; + +singleton SFXEnvironment(CastleAlcove) +{ + reverbDensity = "1.0000"; + reverbDiffusion = "0.8900"; + reverbGain = "0.3162"; + reverbGainHF = "0.5012"; + reverbGainLF = "0.1000"; + reverbDecayTime = "1.6400"; + reverbDecayHFRatio = "0.8700"; + reverbDecayLFRatio = "0.3100"; + reflectionsGain = "1.0000"; + reflectionDelay = "0.0070"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.4125"; + lateReverbDelay = "0.0340"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1380"; + reverbEchoDepth = "0.0800"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "5168.0001"; + reverbLFRef = "139.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(FactorySmallRoom) +{ + reverbDensity = "0.3645"; + reverbDiffusion = "0.8200"; + reverbGain = "0.3162"; + reverbGainHF = "0.7943"; + reverbGainLF = "0.5012"; + reverbDecayTime = "1.7200"; + reverbDecayHFRatio = "0.6500"; + reverbDecayLFRatio = "1.3100"; + reflectionsGain = "0.7079"; + reflectionDelay = "0.0100"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.7783"; + lateReverbDelay = "0.0240"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1190"; + reverbEchoDepth = "0.0700"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "3762.6001"; + reverbLFRef = "362.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(FactoryShortPassage) +{ + reverbDensity = "0.3645"; + reverbDiffusion = "0.6400"; + reverbGain = "0.2512"; + reverbGainHF = "0.7943"; + reverbGainLF = "0.5012"; + reverbDecayTime = "2.5300"; + reverbDecayHFRatio = "0.6500"; + reverbDecayLFRatio = "1.3100"; + reflectionsGain = "1.0000"; + reflectionDelay = "0.0100"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.2589"; + lateReverbDelay = "0.0380"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1350"; + reverbEchoDepth = "0.2300"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "3762.6001"; + reverbLFRef = "362.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(FactoryMediumRoom) +{ + reverbDensity = "0.4287"; + reverbDiffusion = "0.8200"; + reverbGain = "0.2512"; + reverbGainHF = "0.7943"; + reverbGainLF = "0.5012"; + reverbDecayTime = "2.7600"; + reverbDecayHFRatio = "0.6500"; + reverbDecayLFRatio = "1.3100"; + reflectionsGain = "0.2818"; + reflectionDelay = "0.0220"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.4125"; + lateReverbDelay = "0.0230"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1740"; + reverbEchoDepth = "0.0700"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "3762.6001"; + reverbLFRef = "362.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(FactoryLargeRoom) +{ + reverbDensity = "0.4287"; + reverbDiffusion = "0.7500"; + reverbGain = "0.2512"; + reverbGainHF = "0.7079"; + reverbGainLF = "0.6310"; + reverbDecayTime = "4.2400"; + reverbDecayHFRatio = "0.5100"; + reverbDecayLFRatio = "1.3100"; + reflectionsGain = "0.1778"; + reflectionDelay = "0.0390"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.1220"; + lateReverbDelay = "0.0230"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2310"; + reverbEchoDepth = "0.0700"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "3762.6001"; + reverbLFRef = "362.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(FactoryLongPassage) +{ + reverbDensity = "0.3645"; + reverbDiffusion = "0.6400"; + reverbGain = "0.2512"; + reverbGainHF = "0.7943"; + reverbGainLF = "0.5012"; + reverbDecayTime = "4.0000"; + reverbDecayHFRatio = "0.6500"; + reverbDecayLFRatio = "1.3100"; + reflectionsGain = "1.0000"; + reflectionDelay = "0.0200"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.2589"; + lateReverbDelay = "0.0370"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1350"; + reverbEchoDepth = "0.2300"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "3762.6001"; + reverbLFRef = "362.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(FactoryHall) +{ + reverbDensity = "0.4287"; + reverbDiffusion = "0.7500"; + reverbGain = "0.3162"; + reverbGainHF = "0.7079"; + reverbGainLF = "0.6310"; + reverbDecayTime = "7.4300"; + reverbDecayHFRatio = "0.5100"; + reverbDecayLFRatio = "1.3100"; + reflectionsGain = "0.0631"; + reflectionDelay = "0.0730"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.8913"; + lateReverbDelay = "0.0270"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.0700"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "3762.6001"; + reverbLFRef = "362.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(FactoryCupboard) +{ + reverbDensity = "0.3071"; + reverbDiffusion = "0.6300"; + reverbGain = "0.2512"; + reverbGainHF = "0.7943"; + reverbGainLF = "0.5012"; + reverbDecayTime = "0.4900"; + reverbDecayHFRatio = "0.6500"; + reverbDecayLFRatio = "1.3100"; + reflectionsGain = "1.2589"; + reflectionDelay = "0.0100"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.9953"; + lateReverbDelay = "0.0320"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1070"; + reverbEchoDepth = "0.0700"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "3762.6001"; + reverbLFRef = "362.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(FactoryCourtyard) +{ + reverbDensity = "0.3071"; + reverbDiffusion = "0.5700"; + reverbGain = "0.3162"; + reverbGainHF = "0.3162"; + reverbGainLF = "0.6310"; + reverbDecayTime = "2.3200"; + reverbDecayHFRatio = "0.2900"; + reverbDecayLFRatio = "0.5600"; + reflectionsGain = "0.2239"; + reflectionDelay = "0.1400"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "0.3981"; + lateReverbDelay = "0.0390"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.2500"; + reverbEchoDepth = "0.2900"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "3762.6001"; + reverbLFRef = "362.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; +}; + +singleton SFXEnvironment(FactoryAlcove) +{ + reverbDensity = "0.3645"; + reverbDiffusion = "0.5900"; + reverbGain = "0.2512"; + reverbGainHF = "0.7943"; + reverbGainLF = "0.5012"; + reverbDecayTime = "3.1400"; + reverbDecayHFRatio = "0.6500"; + reverbDecayLFRatio = "1.3100"; + reflectionsGain = "1.4125"; + reflectionDelay = "0.0100"; + reflectionsPan[ 0 ] = "0.0"; + reflectionsPan[ 1 ] = "0.0"; + reflectionsPan[ 2 ] = "0.0"; + lateReverbGain = "1.0000"; + lateReverbDelay = "0.0380"; + lateReverbPan[ 0 ] = "0.0"; + lateReverbPan[ 1 ] = "0.0"; + lateReverbPan[ 2 ] = "0.0"; + reverbEchoTime = "0.1140"; + reverbEchoDepth = "0.1000"; + reverbModTime = "0.2500"; + reverbModDepth = "0.0000"; + airAbsorbtionGainHF = "0.9943"; + reverbHFRef = "3762.6001"; + reverbLFRef = "362.5000"; + roomRolloffFactor = "0.0000"; + decayHFLimit = "1"; }; diff --git a/Templates/Full/game/core/scripts/client/helperfuncs.cs b/Templates/Full/game/core/scripts/client/helperfuncs.cs index f8988a270..511a47d4a 100644 --- a/Templates/Full/game/core/scripts/client/helperfuncs.cs +++ b/Templates/Full/game/core/scripts/client/helperfuncs.cs @@ -219,7 +219,7 @@ function AggregateControl::callMethod(%this, %method, %args) function parseMissionGroup( %className, %childGroup ) { if( getWordCount( %childGroup ) == 0) - %currentGroup = "MissionGroup"; + %currentGroup = getRootScene(); else %currentGroup = %childGroup; @@ -240,7 +240,7 @@ function parseMissionGroup( %className, %childGroup ) function parseMissionGroupForIds( %className, %childGroup ) { if( getWordCount( %childGroup ) == 0) - %currentGroup = "MissionGroup"; + %currentGroup = getRootScene(); else %currentGroup = %childGroup; diff --git a/Templates/Full/game/core/scripts/server/missionDownload.cs b/Templates/Full/game/core/scripts/server/missionDownload.cs index 2b1168b39..b3bf07ef2 100644 --- a/Templates/Full/game/core/scripts/server/missionDownload.cs +++ b/Templates/Full/game/core/scripts/server/missionDownload.cs @@ -49,7 +49,7 @@ function GameConnection::loadMission(%this) else { commandToClient(%this, 'MissionStartPhase1', $missionSequence, - $Server::MissionFile, MissionGroup.musicTrack); + $Server::MissionFile, getRootScene().musicTrack); echo("*** Sending mission load to client: " @ $Server::MissionFile); } } diff --git a/Templates/Full/game/core/scripts/server/missionLoad.cs b/Templates/Full/game/core/scripts/server/missionLoad.cs index d85b15516..f5acb588b 100644 --- a/Templates/Full/game/core/scripts/server/missionLoad.cs +++ b/Templates/Full/game/core/scripts/server/missionLoad.cs @@ -96,12 +96,12 @@ function loadMissionStage2() // to caching mission lighting. $missionCRC = getFileCRC( %file ); - // Exec the mission. The MissionGroup (loaded components) is added to the ServerGroup + // Exec the mission. The Scene (loaded components) is added to the ServerGroup exec(%file); - if( !isObject(MissionGroup) ) + if( !isObject(getRootScene()) ) { - $Server::LoadFailMsg = "No 'MissionGroup' found in mission \"" @ %file @ "\"."; + $Server::LoadFailMsg = "No 'Scene' found in mission \"" @ %file @ "\"."; } } @@ -145,7 +145,7 @@ function loadMissionStage2() function endMission() { - if (!isObject( MissionGroup )) + if (!isObject( getRootScene() )) return; echo("*** ENDING MISSION"); @@ -163,7 +163,7 @@ function endMission() } // Delete everything - MissionGroup.delete(); + getRootScene().delete(); MissionCleanup.delete(); clearServerPaths(); diff --git a/Templates/Full/game/levels/Empty Room.mis b/Templates/Full/game/levels/Empty Room.mis index d20a6cd16..0b530cc38 100644 --- a/Templates/Full/game/levels/Empty Room.mis +++ b/Templates/Full/game/levels/Empty Room.mis @@ -1,6 +1,5 @@ //--- OBJECT WRITE BEGIN --- -new SimGroup(MissionGroup) { - canSave = "1"; +new Scene(EmptyLevel) { canSaveDynamicFields = "1"; enabled = "1"; diff --git a/Templates/Full/game/levels/Empty Terrain.mis b/Templates/Full/game/levels/Empty Terrain.mis index 5553698fa..1dcf27de9 100644 --- a/Templates/Full/game/levels/Empty Terrain.mis +++ b/Templates/Full/game/levels/Empty Terrain.mis @@ -1,7 +1,10 @@ //--- OBJECT WRITE BEGIN --- -new SimGroup(MissionGroup) { +new Scene(EmptyTerrainLevel) { canSave = "1"; canSaveDynamicFields = "1"; + isSubscene = "0"; + isEditing = "0"; + isDirty = "0"; enabled = "1"; new LevelInfo(theLevelInfo) { @@ -37,6 +40,8 @@ new SimGroup(MissionGroup) { rotation = "1 0 0 0"; canSave = "1"; canSaveDynamicFields = "1"; + scale = "1 1 1"; + tile = "0"; }; new SimGroup(PlayerDropPoints) { canSave = "1"; @@ -163,7 +168,6 @@ new SimGroup(MissionGroup) { scale = "1 1 1"; canSave = "1"; canSaveDynamicFields = "1"; - surface = "0 0 0 1 1.29457 -0.42643 0.5"; surface = "0 1 0 0 1.29457 -0.42643 -0.5"; surface = "0.707107 0 0 0.707106 1.29457 5.75621 0"; diff --git a/Templates/Full/game/levels/Outpost.mis b/Templates/Full/game/levels/Outpost.mis index 6a7045e30..8b1cda54b 100644 --- a/Templates/Full/game/levels/Outpost.mis +++ b/Templates/Full/game/levels/Outpost.mis @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -new SimGroup(MissionGroup) { +new Scene(OutpostLevel) { canSave = "1"; canSaveDynamicFields = "1"; enabled = "1"; diff --git a/Templates/Full/game/scripts/server/gameCore.cs b/Templates/Full/game/scripts/server/gameCore.cs index bb7aed714..9917d1048 100644 --- a/Templates/Full/game/scripts/server/gameCore.cs +++ b/Templates/Full/game/scripts/server/gameCore.cs @@ -134,12 +134,12 @@ package GameCore // to caching mission lighting. $missionCRC = getFileCRC( %file ); - // Exec the mission. The MissionGroup (loaded components) is added to the ServerGroup + // Exec the mission. The Scene (loaded components) is added to the ServerGroup exec(%file); - if( !isObject(MissionGroup) ) + if( !isObject(getRootScene()) ) { - $Server::LoadFailMsg = "No 'MissionGroup' found in mission \"" @ %file @ "\"."; + $Server::LoadFailMsg = "No Scene found in mission \"" @ %file @ "\"."; } } diff --git a/Templates/Full/game/scripts/server/item.cs b/Templates/Full/game/scripts/server/item.cs index f4f355386..ad6859b9e 100644 --- a/Templates/Full/game/scripts/server/item.cs +++ b/Templates/Full/game/scripts/server/item.cs @@ -92,7 +92,7 @@ function ItemData::onThrow(%this, %user, %amount) rotation = "0 0 1 "@ (getRandom() * 360); count = %amount; }; - MissionGroup.add(%obj); + getRootScene().add(%obj); %obj.schedulePop(); return %obj; } diff --git a/Templates/Full/game/scripts/server/turret.cs b/Templates/Full/game/scripts/server/turret.cs index 19b19ed22..be43d7043 100644 --- a/Templates/Full/game/scripts/server/turret.cs +++ b/Templates/Full/game/scripts/server/turret.cs @@ -87,7 +87,7 @@ function TurretShapeData::onRemove(%this, %obj) } // This is on MissionGroup so it doesn't happen when the mission has ended -function MissionGroup::respawnTurret(%this, %datablock, %className, %transform, %static, %respawn) +function Scene::respawnTurret(%this, %datablock, %className, %transform, %static, %respawn) { %turret = new (%className)() { @@ -97,7 +97,7 @@ function MissionGroup::respawnTurret(%this, %datablock, %className, %transform, }; %turret.setTransform(%transform); - MissionGroup.add(%turret); + getRootScene().add(%turret); return %turret; } @@ -149,7 +149,7 @@ function TurretShapeData::onDestroyed(%this, %obj, %lastState) if (%obj.doRespawn()) { - MissionGroup.schedule($TurretShape::RespawnTime, "respawnTurret", %this, %obj.getClassName(), %obj.getTransform(), true, true); + getRootScene().schedule($TurretShape::RespawnTime, "respawnTurret", %this, %obj.getClassName(), %obj.getTransform(), true, true); } } @@ -331,7 +331,7 @@ function AITurretShapeData::onThrow(%this, %user, %amount) client = %user.client; isAiControlled = true; }; - MissionGroup.add(%obj); + getRootScene().add(%obj); // Let the turret know that we're a firend %obj.addToIgnoreList(%user); diff --git a/Templates/Full/game/shaders/.gitignore b/Templates/Full/game/shaders/.gitignore deleted file mode 100644 index 5baa4d384..000000000 --- a/Templates/Full/game/shaders/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/procedural/ diff --git a/Templates/Full/game/shaders/procedural/.gitignore b/Templates/Full/game/shaders/procedural/.gitignore new file mode 100644 index 000000000..013488d4e --- /dev/null +++ b/Templates/Full/game/shaders/procedural/.gitignore @@ -0,0 +1,2 @@ +*.hlsl +*.glsl \ No newline at end of file diff --git a/Templates/Full/game/tools/convexEditor/main.cs b/Templates/Full/game/tools/convexEditor/main.cs index 496140cd4..54de25d02 100644 --- a/Templates/Full/game/tools/convexEditor/main.cs +++ b/Templates/Full/game/tools/convexEditor/main.cs @@ -189,7 +189,7 @@ function ConvexEditorPlugin::onSaveMission( %this, %missionFile ) { if( ConvexEditorGui.isDirty ) { - MissionGroup.save( %missionFile ); + getRootScene().save( %missionFile ); ConvexEditorGui.isDirty = false; } } diff --git a/Templates/Full/game/tools/gui/colladaImport.ed.gui b/Templates/Full/game/tools/gui/colladaImport.ed.gui index 30838c76d..b83c1e477 100644 --- a/Templates/Full/game/tools/gui/colladaImport.ed.gui +++ b/Templates/Full/game/tools/gui/colladaImport.ed.gui @@ -1584,7 +1584,7 @@ function ColladaImportDlg::onOK(%this) function ColladaImportDlg::loadLights(%this) { // Get the ID of the last object added - %obj = MissionGroup.getObject(MissionGroup.getCount()-1); + %obj = getRootScene().getObject(getRootScene().getCount()-1); // Create a new SimGroup to hold the model and lights %group = new SimGroup(); @@ -1596,7 +1596,7 @@ function ColladaImportDlg::loadLights(%this) { %group.add(%obj); %group.bringToFront(%obj); - MissionGroup.add(%group); + getRootScene().add(%group); if (EditorTree.isVisible()) { EditorTree.removeItem(EditorTree.findItemByObjectId(%obj)); diff --git a/Templates/Full/game/tools/levels/BlankRoom.mis b/Templates/Full/game/tools/levels/BlankRoom.mis index 5ca65ed5a..bbef5d24f 100644 --- a/Templates/Full/game/tools/levels/BlankRoom.mis +++ b/Templates/Full/game/tools/levels/BlankRoom.mis @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -new SimGroup(MissionGroup) { +new Scene(EditorTemplateLevel) { canSaveDynamicFields = "1"; cdTrack = "2"; CTF_scoreLimit = "5"; diff --git a/Templates/Full/game/tools/materialEditor/scripts/materialEditor.ed.cs b/Templates/Full/game/tools/materialEditor/scripts/materialEditor.ed.cs index 87b940dd9..191e77bf6 100644 --- a/Templates/Full/game/tools/materialEditor/scripts/materialEditor.ed.cs +++ b/Templates/Full/game/tools/materialEditor/scripts/materialEditor.ed.cs @@ -1129,7 +1129,7 @@ function MaterialEditorGui::updateActiveMaterialName(%this, %name) // Some objects (ConvexShape, DecalRoad etc) reference Materials by name => need // to find and update all these references so they don't break when we rename the // Material. - MaterialEditorGui.updateMaterialReferences( MissionGroup, %action.oldName, %action.newName ); + MaterialEditorGui.updateMaterialReferences( getRootScene(), %action.oldName, %action.newName ); } function MaterialEditorGui::updateMaterialReferences( %this, %obj, %oldName, %newName ) diff --git a/Templates/Full/game/tools/materialEditor/scripts/materialEditorUndo.ed.cs b/Templates/Full/game/tools/materialEditor/scripts/materialEditorUndo.ed.cs index 184f02ce4..2adf419ca 100644 --- a/Templates/Full/game/tools/materialEditor/scripts/materialEditorUndo.ed.cs +++ b/Templates/Full/game/tools/materialEditor/scripts/materialEditorUndo.ed.cs @@ -187,7 +187,7 @@ function ActionUpdateActiveMaterialAnimationFlags::undo(%this) function ActionUpdateActiveMaterialName::redo(%this) { %this.material.setName(%this.newName); - MaterialEditorGui.updateMaterialReferences( MissionGroup, %this.oldName, %this.newName ); + MaterialEditorGui.updateMaterialReferences( getRootScene(), %this.oldName, %this.newName ); if( MaterialEditorPreviewWindow.isVisible() && MaterialEditorGui.currentMaterial == %this.material ) { @@ -199,7 +199,7 @@ function ActionUpdateActiveMaterialName::redo(%this) function ActionUpdateActiveMaterialName::undo(%this) { %this.material.setName(%this.oldName); - MaterialEditorGui.updateMaterialReferences( MissionGroup, %this.newName, %this.oldName ); + MaterialEditorGui.updateMaterialReferences( getRootScene(), %this.newName, %this.oldName ); if( MaterialEditorPreviewWindow.isVisible() && MaterialEditorGui.currentMaterial == %this.material ) { diff --git a/Templates/Full/game/tools/meshRoadEditor/main.cs b/Templates/Full/game/tools/meshRoadEditor/main.cs index d101e50b0..5b76bcd63 100644 --- a/Templates/Full/game/tools/meshRoadEditor/main.cs +++ b/Templates/Full/game/tools/meshRoadEditor/main.cs @@ -164,7 +164,7 @@ function MeshRoadEditorPlugin::onSaveMission( %this, %missionFile ) { if( MeshRoadEditorGui.isDirty ) { - MissionGroup.save( %missionFile ); + getRootScene().save( %missionFile ); MeshRoadEditorGui.isDirty = false; } } diff --git a/Templates/Full/game/tools/missionAreaEditor/main.cs b/Templates/Full/game/tools/missionAreaEditor/main.cs index 000197bc6..ebb62bb9c 100644 --- a/Templates/Full/game/tools/missionAreaEditor/main.cs +++ b/Templates/Full/game/tools/missionAreaEditor/main.cs @@ -114,7 +114,7 @@ function MissionAreaEditorPlugin::createNewMissionArea(%this) %newMissionArea = new MissionArea(); %newMissionArea.area = "-256 -256 512 512"; - MissionGroup.add(%newMissionArea); + getRootScene().add(%newMissionArea); EditorGui.setEditor(MissionAreaEditorPlugin); diff --git a/Templates/Full/game/tools/navEditor/CreateNewNavMeshDlg.gui b/Templates/Full/game/tools/navEditor/CreateNewNavMeshDlg.gui index 755bce30a..af39140c9 100644 --- a/Templates/Full/game/tools/navEditor/CreateNewNavMeshDlg.gui +++ b/Templates/Full/game/tools/navEditor/CreateNewNavMeshDlg.gui @@ -354,13 +354,13 @@ function CreateNewNavMeshDlg::create(%this) if(MeshMissionBounds.isStateOn()) { - if(!isObject(MissionGroup)) + if(!isObject(getRootScene())) { - MessageBoxOk("Error", "You must have a MissionGroup to use the mission bounds function."); + MessageBoxOk("Error", "You must have a Scene to use the mission bounds function."); return; } // Get maximum extents of all objects. - %box = MissionBoundsExtents(MissionGroup); + %box = MissionBoundsExtents(getRootScene()); %pos = GetBoxCenter(%box); %scale = (GetWord(%box, 3) - GetWord(%box, 0)) / 2 + 5 SPC (GetWord(%box, 4) - GetWord(%box, 1)) / 2 + 5 @@ -380,7 +380,7 @@ function CreateNewNavMeshDlg::create(%this) scale = %this-->MeshScale.getText(); }; } - MissionGroup.add(%mesh); + getRootScene().add(%mesh); NavEditorGui.selectObject(%mesh); Canvas.popDialog(CreateNewNavMeshDlg); diff --git a/Templates/Full/game/tools/navEditor/main.cs b/Templates/Full/game/tools/navEditor/main.cs index 6af3abf19..2a742bf51 100644 --- a/Templates/Full/game/tools/navEditor/main.cs +++ b/Templates/Full/game/tools/navEditor/main.cs @@ -205,7 +205,7 @@ function NavEditorPlugin::onSaveMission(%this, %missionFile) { if(NavEditorGui.isDirty) { - MissionGroup.save(%missionFile); + getRootScene().save(%missionFile); NavEditorGui.isDirty = false; } } diff --git a/Templates/Full/game/tools/physicsTools/main.cs b/Templates/Full/game/tools/physicsTools/main.cs index 8da40844e..4fbf44bdb 100644 --- a/Templates/Full/game/tools/physicsTools/main.cs +++ b/Templates/Full/game/tools/physicsTools/main.cs @@ -64,28 +64,6 @@ function destroyPhysicsTools() function PhysicsEditorPlugin::onWorldEditorStartup( %this ) { - new PopupMenu( PhysicsToolsMenu ) - { - superClass = "MenuBuilder"; - //class = "PhysXToolsMenu"; - - barTitle = "Physics"; - - item[0] = "Start Simulation" TAB "Ctrl-Alt P" TAB "physicsStartSimulation( \"client\" );physicsStartSimulation( \"server\" );"; - //item[1] = "Stop Simulation" TAB "" TAB "physicsSetTimeScale( 0 );"; - item[1] = "-"; - item[2] = "Speed 25%" TAB "" TAB "physicsSetTimeScale( 0.25 );"; - item[3] = "Speed 50%" TAB "" TAB "physicsSetTimeScale( 0.5 );"; - item[4] = "Speed 100%" TAB "" TAB "physicsSetTimeScale( 1.0 );"; - item[5] = "-"; - item[6] = "Reload NXBs" TAB "" TAB ""; - }; - - // Add our menu. - EditorGui.menuBar.insert( PhysicsToolsMenu, EditorGui.menuBar.dynamicItemInsertPos ); - - // Add ourselves to the window menu. - //EditorGui.addToWindowMenu( "Road and Path Editor", "", "RoadEditor" ); } function PhysicsToolsMenu::onMenuSelect(%this) diff --git a/Templates/Full/game/tools/riverEditor/main.cs b/Templates/Full/game/tools/riverEditor/main.cs index eafb3c3c8..1c6ce72ed 100644 --- a/Templates/Full/game/tools/riverEditor/main.cs +++ b/Templates/Full/game/tools/riverEditor/main.cs @@ -178,7 +178,7 @@ function RiverEditorPlugin::onSaveMission( %this, %missionFile ) { if( RiverEditorGui.isDirty ) { - MissionGroup.save( %missionFile ); + getRootScene().save( %missionFile ); RiverEditorGui.isDirty = false; } } diff --git a/Templates/Full/game/tools/roadEditor/main.cs b/Templates/Full/game/tools/roadEditor/main.cs index f45823670..9b2f70f56 100644 --- a/Templates/Full/game/tools/roadEditor/main.cs +++ b/Templates/Full/game/tools/roadEditor/main.cs @@ -156,7 +156,7 @@ function RoadEditorPlugin::onSaveMission( %this, %missionFile ) { if( RoadEditorGui.isDirty ) { - MissionGroup.save( %missionFile ); + getRootScene().save( %missionFile ); RoadEditorGui.isDirty = false; } } diff --git a/Templates/Full/game/tools/shapeEditor/main.cs b/Templates/Full/game/tools/shapeEditor/main.cs index 721313e95..1c021cb01 100644 --- a/Templates/Full/game/tools/shapeEditor/main.cs +++ b/Templates/Full/game/tools/shapeEditor/main.cs @@ -168,7 +168,7 @@ function ShapeEditorPlugin::open(%this, %filename) ShapeEdNodes-->worldTransform.setStateOn(1); // Initialise and show the shape editor - ShapeEdShapeTreeView.open(MissionGroup); + ShapeEdShapeTreeView.open(getRootScene()); ShapeEdShapeTreeView.buildVisibleTree(true); ShapeEdPreviewGui.setVisible(true); diff --git a/Templates/Full/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui b/Templates/Full/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui index 8eaf11d4c..9f36921ad 100644 --- a/Templates/Full/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui +++ b/Templates/Full/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui @@ -184,11 +184,11 @@ function TimeAdjustSliderCtrl::onAction(%this) if ( !isObject( %this.tod ) ) { - if ( isObject( MissionGroup ) ) + if ( isObject( getRootScene() ) ) { - for ( %i = 0; %i < MissionGroup.getCount(); %i++ ) + for ( %i = 0; %i < getRootScene().getCount(); %i++ ) { - %obj = MissionGroup.getObject( %i ); + %obj = getRootScene().getObject( %i ); if ( %obj.getClassName() $= "TimeOfDay" ) { diff --git a/Templates/Full/game/tools/worldEditor/gui/objectBuilderGui.ed.gui b/Templates/Full/game/tools/worldEditor/gui/objectBuilderGui.ed.gui index 129e5988c..3cc78887f 100644 --- a/Templates/Full/game/tools/worldEditor/gui/objectBuilderGui.ed.gui +++ b/Templates/Full/game/tools/worldEditor/gui/objectBuilderGui.ed.gui @@ -965,10 +965,10 @@ function ObjectBuilderGui::buildPlayerDropPoint(%this) %this.addField("spawnClass", "TypeString", "Spawn Class", "Player"); %this.addField("spawnDatablock", "TypeDataBlock", "Spawn Data", "PlayerData DefaultPlayerData"); - if( EWCreatorWindow.objectGroup.getID() == MissionGroup.getID() ) + if( EWCreatorWindow.objectGroup.getID() == getRootScene().getID() ) { if( !isObject("PlayerDropPoints") ) - MissionGroup.add( new SimGroup("PlayerDropPoints") ); + getRootScene().add( new SimGroup("PlayerDropPoints") ); %this.objectGroup = "PlayerDropPoints"; } @@ -985,10 +985,10 @@ function ObjectBuilderGui::buildObserverDropPoint(%this) %this.addField("spawnClass", "TypeString", "Spawn Class", "Camera"); %this.addField("spawnDatablock", "TypeDataBlock", "Spawn Data", "CameraData Observer"); - if( EWCreatorWindow.objectGroup.getID() == MissionGroup.getID() ) + if( EWCreatorWindow.objectGroup.getID() == getRootScene().getID() ) { if( !isObject("ObserverDropPoints") ) - MissionGroup.add( new SimGroup("ObserverDropPoints") ); + getRootScene().add( new SimGroup("ObserverDropPoints") ); %this.objectGroup = "ObserverDropPoints"; } diff --git a/Templates/Full/game/tools/worldEditor/scripts/EditorGui.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/EditorGui.ed.cs index 50aac111b..f8bb433ff 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/EditorGui.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/EditorGui.ed.cs @@ -317,10 +317,15 @@ function EditorGui::shutdown( %this ) /// will take over the default world editor window. function EditorGui::addToEditorsMenu( %this, %displayName, %accel, %newPlugin ) { + //We need to cache the editors list. So first see if we have our list we cache the entries into + if(!isObject(EditorsMenuList)) + { + new ArrayObject(EditorsMenuList); + } + %windowMenu = %this.findMenu( "Editors" ); %count = %windowMenu.getItemCount(); - - + %alreadyExists = false; for ( %i = 0; %i < %count; %i++ ) { @@ -336,7 +341,10 @@ function EditorGui::addToEditorsMenu( %this, %displayName, %accel, %newPlugin ) %accel = ""; if(!%alreadyExists) + { + EditorsMenuList.add(%displayName TAB %accel TAB %newPlugin); %windowMenu.addItem( %count, %displayName TAB %accel TAB %newPlugin ); + } return %accel; } @@ -637,7 +645,7 @@ function EditorGui::addCameraBookmark( %this, %name ) if( !isObject(CameraBookmarks) ) { %grp = new SimGroup(CameraBookmarks); - MissionGroup.add(%grp); + getRootScene().add(%grp); } CameraBookmarks.add( %obj ); @@ -835,12 +843,17 @@ function EditorGui::syncCameraGui( %this ) function WorldEditorPlugin::onActivated( %this ) { + if(!isObject(Scenes)) + $scenesRootGroup = new SimGroup(Scenes); + + $scenesRootGroup.add(getRootScene()); + EditorGui.bringToFront( EWorldEditor ); EWorldEditor.setVisible(true); EditorGui.menuBar.insert( EditorGui.worldMenu, EditorGui.menuBar.dynamicItemInsertPos ); EWorldEditor.makeFirstResponder(true); - EditorTree.open(MissionGroup,true); - EWCreatorWindow.setNewObjectGroup(MissionGroup); + EditorTree.open($scenesRootGroup,true); + EWCreatorWindow.setNewObjectGroup(getRootScene()); EWorldEditor.syncGui(); @@ -1464,7 +1477,7 @@ function EditorTree::onDeleteObject( %this, %object ) return true; if( %object == EWCreatorWindow.objectGroup ) - EWCreatorWindow.setNewObjectGroup( MissionGroup ); + EWCreatorWindow.setNewObjectGroup( getRootScene() ); // Append it to our list. %this.undoDeleteList = %this.undoDeleteList TAB %object; @@ -1596,6 +1609,13 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj ) { %popup.item[ 0 ] = "Add Camera Bookmark" TAB "" TAB "EditorGui.addCameraBookmarkByGui();"; } + else if( %obj.isMemberOfClass( "Scene" )) + { + %popup.item[ 0 ] = "Set as Active Scene" TAB "" TAB "EditorTree.showItemRenameCtrl( EditorTree.findItemByObjectId(" @ %popup.object @ ") );"; + %popup.item[ 1 ] = "Delete" TAB "" TAB "EWorldEditor.deleteMissionObject(" @ %popup.object @ ");"; + %popup.item[ 2 ] = "Inspect" TAB "" TAB "inspectObject(" @ %popup.object @ ");"; + %popup.item[ 3 ] = "-"; + } else { %popup.object = %obj; @@ -1673,8 +1693,8 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj ) if( %haveObjectEntries ) { - %popup.enableItem( 0, %obj.isNameChangeAllowed() && %obj.getName() !$= "MissionGroup" ); - %popup.enableItem( 1, %obj.getName() !$= "MissionGroup" ); + %popup.enableItem( 0, %obj.isNameChangeAllowed() && %obj.getName() !$= getRootScene() ); + %popup.enableItem( 1, %obj.getName() !$= getRootScene() ); if( %haveLockAndHideEntries ) { @@ -1864,6 +1884,7 @@ function Editor::open(%this) %this.editorEnabled(); Canvas.setContent(EditorGui); + $isFirstPersonVar = true; EditorGui.syncCameraGui(); } @@ -2025,21 +2046,21 @@ function EWorldEditor::syncToolPalette( %this ) function EWorldEditor::addSimGroup( %this, %groupCurrentSelection ) { %activeSelection = %this.getActiveSelection(); - if ( %activeSelection.getObjectIndex( MissionGroup ) != -1 ) + if ( %activeSelection.getObjectIndex( getRootScene() ) != -1 ) { - MessageBoxOK( "Error", "Cannot add MissionGroup to a new SimGroup" ); + MessageBoxOK( "Error", "Cannot add Scene to a new SimGroup" ); return; } // Find our parent. - %parent = MissionGroup; + %parent = getRootScene(); if( !%groupCurrentSelection && isObject( %activeSelection ) && %activeSelection.getCount() > 0 ) { %firstSelectedObject = %activeSelection.getObject( 0 ); if( %firstSelectedObject.isMemberOfClass( "SimGroup" ) ) %parent = %firstSelectedObject; - else if( %firstSelectedObject.getId() != MissionGroup.getId() ) + else if( %firstSelectedObject.getId() != getRootScene().getId() ) %parent = %firstSelectedObject.parentGroup; } @@ -2625,4 +2646,4 @@ function EditorDropdownSliderContainer::onMouseDown(%this) function EditorDropdownSliderContainer::onRightMouseDown(%this) { Canvas.popDialog(%this); -} \ No newline at end of file +} diff --git a/Templates/Full/game/tools/worldEditor/scripts/SelectObjectsWindow.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/SelectObjectsWindow.ed.cs index 2c436f74f..f6c11b41b 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/SelectObjectsWindow.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/SelectObjectsWindow.ed.cs @@ -40,7 +40,7 @@ function ESelectObjectsWindow::toggleVisibility( %this ) /// to start searching for objects. function ESelectObjectsWindow::getRootGroup( %this ) { - return MissionGroup; + return getRootScene(); } //--------------------------------------------------------------------------------------------- diff --git a/Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs index 22c823b1f..5d87e9411 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs @@ -186,7 +186,7 @@ function EWCreatorWindow::createStatic( %this, %file ) return; if( !isObject(%this.objectGroup) ) - %this.setNewObjectGroup( MissionGroup ); + %this.setNewObjectGroup( getRootScene() ); %objId = new TSStatic() { @@ -204,7 +204,7 @@ function EWCreatorWindow::createPrefab( %this, %file ) return; if( !isObject(%this.objectGroup) ) - %this.setNewObjectGroup( MissionGroup ); + %this.setNewObjectGroup( getRootScene() ); %objId = new Prefab() { @@ -222,7 +222,7 @@ function EWCreatorWindow::createObject( %this, %cmd ) return; if( !isObject(%this.objectGroup) ) - %this.setNewObjectGroup( MissionGroup ); + %this.setNewObjectGroup( getRootScene() ); pushInstantGroup(); %objId = eval(%cmd); diff --git a/Templates/Full/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs index eb89d1a30..1258fe8fa 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs @@ -124,6 +124,12 @@ function WorldEditor::onSelectionCentroidChanged( %this ) Inspector.refresh(); } +function WorldEditor::setSceneAsDirty(%this) +{ + EWorldEditor.isDirty = true; + +} + ////////////////////////////////////////////////////////////////////////// function WorldEditor::init(%this) @@ -198,7 +204,7 @@ function WorldEditor::export(%this) function WorldEditor::doExport(%this, %file) { - missionGroup.save("~/editor/" @ %file, true); + getRootScene().save("~/editor/" @ %file, true); } function WorldEditor::import(%this) diff --git a/Templates/Full/game/tools/worldEditor/scripts/menuHandlers.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/menuHandlers.ed.cs index f476ccaeb..9b3518469 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/menuHandlers.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/menuHandlers.ed.cs @@ -272,7 +272,7 @@ function EditorSaveMission() // now write the terrain and mission files out: if(EWorldEditor.isDirty || ETerrainEditor.isMissionDirty) - MissionGroup.save($Server::MissionFile); + getRootScene().save($Server::MissionFile); if(ETerrainEditor.isDirty) { // Find all of the terrain files @@ -483,6 +483,21 @@ function EditorOpenMission(%filename) } } +function EditorOpenSceneAppend(%levelAsset) +{ + //Load the asset's level file + exec(%levelAsset.levelFile); + + //We'll assume the scene name and assetname are the same for now + %sceneName = %levelAsset.AssetName; + %scene = nameToID(%sceneName); + if(isObject(%scene)) + { + //Append it to our scene heirarchy + $scenesRootGroup.add(%scene); + } +} + function EditorExportToCollada() { diff --git a/Templates/Full/game/tools/worldEditor/scripts/menus.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/menus.ed.cs index 9f8a24e58..7115410ed 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/menus.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/menus.ed.cs @@ -113,7 +113,7 @@ function EditorGui::buildMenus(%this) %this.menuBar = new GuiMenuBar(WorldEditorMenubar) { dynamicItemInsertPos = 3; - extent = "1024 20"; + extent = Canvas.extent.x SPC "20"; minExtent = "320 20"; horizSizing = "width"; profile = "GuiMenuBarProfile"; @@ -251,6 +251,41 @@ function EditorGui::buildMenus(%this) //item[5] = "-"; }; %this.menuBar.insert(%editorsMenu); + + //if we're just refreshing the menus, we probably have a list of editors we want added to the Editors menu there, so check and if so, add them now + if(isObject(EditorsMenuList)) + { + %editorsListCount = EditorsMenuList.count(); + + for(%e = 0; %e < %editorsListCount; %e++) + { + %menuEntry = EditorsMenuList.getKey(%e); + %editorsMenu.addItem(%e, %menuEntry); + } + } + + if(isObject(PhysicsEditorPlugin)) + { + %physicsToolsMenu = new PopupMenu() + { + superClass = "MenuBuilder"; + //class = "PhysXToolsMenu"; + + barTitle = "Physics"; + + item[0] = "Start Simulation" TAB "Ctrl-Alt P" TAB "physicsStartSimulation( \"client\" );physicsStartSimulation( \"server\" );"; + //item[1] = "Stop Simulation" TAB "" TAB "physicsSetTimeScale( 0 );"; + item[1] = "-"; + item[2] = "Speed 25%" TAB "" TAB "physicsSetTimeScale( 0.25 );"; + item[3] = "Speed 50%" TAB "" TAB "physicsSetTimeScale( 0.5 );"; + item[4] = "Speed 100%" TAB "" TAB "physicsSetTimeScale( 1.0 );"; + item[5] = "-"; + item[6] = "Reload NXBs" TAB "" TAB ""; + }; + + // Add our menu. + %this.menuBar.insert( %physicsToolsMenu, EditorGui.menuBar.dynamicItemInsertPos ); + } // Lighting Menu %lightingMenu = new PopupMenu() @@ -389,6 +424,11 @@ function EditorGui::buildMenus(%this) ////////////////////////////////////////////////////////////////////////// +function WorldEditorMenubar::onResize(%this) +{ + %this.extent.x = Canvas.extent.x; +} + function EditorGui::attachMenus(%this) { %this.menuBar.attachToCanvas(Canvas, 0); diff --git a/Tools/CMake/torque3d.cmake b/Tools/CMake/torque3d.cmake index 765ee0265..86de22786 100644 --- a/Tools/CMake/torque3d.cmake +++ b/Tools/CMake/torque3d.cmake @@ -204,6 +204,9 @@ mark_as_advanced(TORQUE_DEBUG_GFX_MODE) #option(DEBUG_SPEW "more debug" OFF) set(TORQUE_NO_DSO_GENERATION ON) +option(TORQUE_USE_ZENITY "use the Zenity backend for NFD" OFF) +mark_as_advanced(TORQUE_USE_ZENITY) + if(WIN32) # warning C4800: 'XXX' : forcing value to bool 'true' or 'false' (performance warning) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4800") @@ -462,7 +465,11 @@ if(TORQUE_SDL) # Add other flags to the compiler add_definitions(${GTK3_CFLAGS_OTHER}) - set(BLACKLIST "nfd_win.cpp" "nfd_cocoa.m" ) + if(TORQUE_USE_ZENITY) + set(BLACKLIST "nfd_win.cpp" "nfd_cocoa.m" "nfd_gtk.c" ) + else() + set(BLACKLIST "nfd_win.cpp" "nfd_cocoa.m" "simple_exec.h" "nfd_zenity.c") + endif() addLib(nativeFileDialogs) set(BLACKLIST "" ) @@ -472,7 +479,7 @@ if(TORQUE_SDL) addLib(nativeFileDialogs) set(BLACKLIST "" ) else() - set(BLACKLIST "nfd_gtk.c" "nfd_cocoa.m" ) + set(BLACKLIST "nfd_gtk.c" "nfd_cocoa.m" "simple_exec.h" "nfd_zenity.c") addLib(nativeFileDialogs) set(BLACKLIST "" ) addLib(comctl32)