Initial implementation of the new Base Game Template and some starting modules.
This makes some tweaks to the engine to support this, specifically, it tweaks the hardcoded shaderpaths to defer to a pref variable, so none of the shader paths are hardcoded. Also tweaks how post effects read in texture files, removing a bizzare filepath interpretation choice, where if the file path didn't start with "/" it forcefully appended the script's file path. This made it impossible to have images not in the same dir as the script file defining the post effect. This was changed and the existing template's post effects tweaked for now to just add "./" to those few paths impacted, as well as the perf vars to support the non-hardcoded shader paths in the engine.
1
Templates/BaseGame/BaseGame.cmake
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Project-specific Cmake configurations go here
|
||||
1
Templates/BaseGame/DeleteCachedDTSs.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
for /R %%a IN (*.dae) do IF EXIST "%%~pna.cached.dts" del "%%~pna.cached.dts"
|
||||
15
Templates/BaseGame/DeleteCachedDTSs.command
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd "`dirname "$0"`"
|
||||
|
||||
for i in $(find . -type f \( -iname "*.dae" \))
|
||||
do
|
||||
len=$((${#i} - 4))
|
||||
file=${i:0:$len}.cached.dts
|
||||
if [ -e $file ]
|
||||
then
|
||||
echo "Removing ${file}"
|
||||
rm $file
|
||||
fi
|
||||
done
|
||||
|
||||
6
Templates/BaseGame/DeleteDSOs.bat
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for /R %%a IN (*.cs) do IF EXIST "%%a.dso" del "%%a.dso"
|
||||
for /R %%a IN (*.cs) do IF EXIST "%%a.edso" del "%%a.edso"
|
||||
for /R %%a IN (*.gui) do IF EXIST "%%a.dso" del "%%a.dso"
|
||||
for /R %%a IN (*.gui) do IF EXIST "%%a.edso" del "%%a.edso"
|
||||
for /R %%a IN (*.ts) do IF EXIST "%%a.dso" del "%%a.dso"
|
||||
for /R %%a IN (*.ts) do IF EXIST "%%a.edso" del "%%a.edso"
|
||||
19
Templates/BaseGame/DeleteDSOs.command
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd "`dirname "$0"`"
|
||||
|
||||
for i in $(find . -type f \( -iname "*.cs" \))
|
||||
do
|
||||
file=${i}.dso
|
||||
if [ -e $file ]
|
||||
then
|
||||
echo "Removing ${file}"
|
||||
rm $file
|
||||
fi
|
||||
file=${i}.edso
|
||||
if [ -e $file ]
|
||||
then
|
||||
echo "Removing ${file}"
|
||||
rm $file
|
||||
fi
|
||||
done
|
||||
6
Templates/BaseGame/DeletePrefs.bat
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
del /s prefs.cs
|
||||
del /s config.cs
|
||||
del /s banlist.cs
|
||||
del /s config.cs.dso
|
||||
del /s prefs.cs.dso
|
||||
del /s banlist.cs.dso
|
||||
3
Templates/BaseGame/DeletePrefs.command
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
find "`dirname "$0"`" -type f \( -name "prefs.cs" -or -name "config.cs" -or -name "banlist.cs" -or -name "prefs.cs.dso" -or -name "config.cs.dso" -or -name "banlist.cs.dso" \) -exec rm {} \;
|
||||
7
Templates/BaseGame/cleanShaders.bat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
REM Delete procedural shaders
|
||||
|
||||
del /q /a:-R game\shaders\procedural\*.*
|
||||
|
||||
REM Delete dumped shader disassembly files
|
||||
|
||||
del /q /s /a:-R *_dis.txt
|
||||
4
Templates/BaseGame/cleanShaders.command
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd "`dirname "$0"`"
|
||||
rm -rf game/shaders/procedural/*.*
|
||||
1
Templates/BaseGame/game/Template.torsion.exports
Normal file
|
|
@ -0,0 +1 @@
|
|||
<exports/>
|
||||
436
Templates/BaseGame/game/core/audio.cs
Normal file
|
|
@ -0,0 +1,436 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Source groups.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton SFXDescription( AudioMaster );
|
||||
singleton SFXSource( AudioChannelMaster )
|
||||
{
|
||||
description = AudioMaster;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioChannel )
|
||||
{
|
||||
sourceGroup = AudioChannelMaster;
|
||||
};
|
||||
|
||||
singleton SFXSource( AudioChannelDefault )
|
||||
{
|
||||
description = AudioChannel;
|
||||
};
|
||||
singleton SFXSource( AudioChannelGui )
|
||||
{
|
||||
description = AudioChannel;
|
||||
};
|
||||
singleton SFXSource( AudioChannelEffects )
|
||||
{
|
||||
description = AudioChannel;
|
||||
};
|
||||
singleton SFXSource( AudioChannelMessages )
|
||||
{
|
||||
description = AudioChannel;
|
||||
};
|
||||
singleton SFXSource( AudioChannelMusic )
|
||||
{
|
||||
description = AudioChannel;
|
||||
};
|
||||
|
||||
// Set default playback states of the channels.
|
||||
|
||||
AudioChannelMaster.play();
|
||||
AudioChannelDefault.play();
|
||||
|
||||
AudioChannelGui.play();
|
||||
AudioChannelMusic.play();
|
||||
AudioChannelMessages.play();
|
||||
|
||||
// Stop in-game effects channels.
|
||||
AudioChannelEffects.stop();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Master SFXDescriptions.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Master description for interface audio.
|
||||
singleton SFXDescription( AudioGui )
|
||||
{
|
||||
volume = 1.0;
|
||||
sourceGroup = AudioChannelGui;
|
||||
};
|
||||
|
||||
// Master description for game effects audio.
|
||||
singleton SFXDescription( AudioEffect )
|
||||
{
|
||||
volume = 1.0;
|
||||
sourceGroup = AudioChannelEffects;
|
||||
};
|
||||
|
||||
// Master description for audio in notifications.
|
||||
singleton SFXDescription( AudioMessage )
|
||||
{
|
||||
volume = 1.0;
|
||||
sourceGroup = AudioChannelMessages;
|
||||
};
|
||||
|
||||
// Master description for music.
|
||||
singleton SFXDescription( AudioMusic )
|
||||
{
|
||||
volume = 1.0;
|
||||
sourceGroup = AudioChannelMusic;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SFX Functions.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/// This initializes the sound system device from
|
||||
/// the defaults in the $pref::SFX:: globals.
|
||||
function sfxStartup()
|
||||
{
|
||||
echo( "\nsfxStartup..." );
|
||||
|
||||
// If we have a provider set, try initialize a device now.
|
||||
|
||||
if( $pref::SFX::provider !$= "" )
|
||||
{
|
||||
if( sfxInit() )
|
||||
return;
|
||||
else
|
||||
{
|
||||
// Force auto-detection.
|
||||
$pref::SFX::autoDetect = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If enabled autodetect a safe device.
|
||||
|
||||
if( ( !isDefined( "$pref::SFX::autoDetect" ) || $pref::SFX::autoDetect ) &&
|
||||
sfxAutodetect() )
|
||||
return;
|
||||
|
||||
// Failure.
|
||||
|
||||
error( " Failed to initialize device!\n\n" );
|
||||
|
||||
$pref::SFX::provider = "";
|
||||
$pref::SFX::device = "";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/// This initializes the sound system device from
|
||||
/// the defaults in the $pref::SFX:: globals.
|
||||
function sfxInit()
|
||||
{
|
||||
// If already initialized, shut down the current device first.
|
||||
|
||||
if( sfxGetDeviceInfo() !$= "" )
|
||||
sfxShutdown();
|
||||
|
||||
// Start it up!
|
||||
%maxBuffers = $pref::SFX::useHardware ? -1 : $pref::SFX::maxSoftwareBuffers;
|
||||
if ( !sfxCreateDevice( $pref::SFX::provider, $pref::SFX::device, $pref::SFX::useHardware, %maxBuffers ) )
|
||||
return false;
|
||||
|
||||
// This returns a tab seperated string with
|
||||
// the initialized system info.
|
||||
%info = sfxGetDeviceInfo();
|
||||
$pref::SFX::provider = getField( %info, 0 );
|
||||
$pref::SFX::device = getField( %info, 1 );
|
||||
$pref::SFX::useHardware = getField( %info, 2 );
|
||||
%useHardware = $pref::SFX::useHardware ? "Yes" : "No";
|
||||
%maxBuffers = getField( %info, 3 );
|
||||
|
||||
echo( " Provider: " @ $pref::SFX::provider );
|
||||
echo( " Device: " @ $pref::SFX::device );
|
||||
echo( " Hardware: " @ %useHardware );
|
||||
echo( " Max Buffers: " @ %maxBuffers );
|
||||
echo( " " );
|
||||
|
||||
if( isDefined( "$pref::SFX::distanceModel" ) )
|
||||
sfxSetDistanceModel( $pref::SFX::distanceModel );
|
||||
if( isDefined( "$pref::SFX::dopplerFactor" ) )
|
||||
sfxSetDopplerFactor( $pref::SFX::dopplerFactor );
|
||||
if( isDefined( "$pref::SFX::rolloffFactor" ) )
|
||||
sfxSetRolloffFactor( $pref::SFX::rolloffFactor );
|
||||
|
||||
// Restore master volume.
|
||||
|
||||
sfxSetMasterVolume( $pref::SFX::masterVolume );
|
||||
|
||||
// Restore channel volumes.
|
||||
|
||||
for( %channel = 0; %channel <= 8; %channel ++ )
|
||||
sfxSetChannelVolume( %channel, $pref::SFX::channelVolume[ %channel ] );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// Destroys the current sound system device.
|
||||
function sfxShutdown()
|
||||
{
|
||||
// Store volume prefs.
|
||||
|
||||
$pref::SFX::masterVolume = sfxGetMasterVolume();
|
||||
|
||||
for( %channel = 0; %channel <= 8; %channel ++ )
|
||||
$pref::SFX::channelVolume[ %channel ] = sfxGetChannelVolume( %channel );
|
||||
|
||||
// We're assuming here that a null info
|
||||
// string means that no device is loaded.
|
||||
if( sfxGetDeviceInfo() $= "" )
|
||||
return;
|
||||
|
||||
sfxDeleteDevice();
|
||||
}
|
||||
|
||||
|
||||
/// Determines which of the two SFX providers is preferable.
|
||||
function sfxCompareProvider( %providerA, %providerB )
|
||||
{
|
||||
if( %providerA $= %providerB )
|
||||
return 0;
|
||||
|
||||
switch$( %providerA )
|
||||
{
|
||||
// Always prefer FMOD over anything else.
|
||||
case "FMOD":
|
||||
return 1;
|
||||
|
||||
// Prefer OpenAL over anything but FMOD.
|
||||
case "OpenAL":
|
||||
if( %providerB $= "FMOD" )
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
|
||||
// choose XAudio over DirectSound
|
||||
case "XAudio":
|
||||
if( %providerB $= "FMOD" || %providerB $= "OpenAL" )
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
case "DirectSound":
|
||||
if( %providerB !$= "FMOD" && %providerB !$= "OpenAL" && %providerB !$= "XAudio" )
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Try to detect and initalize the best SFX device available.
|
||||
function sfxAutodetect()
|
||||
{
|
||||
// Get all the available devices.
|
||||
|
||||
%devices = sfxGetAvailableDevices();
|
||||
|
||||
// Collect and sort the devices by preferentiality.
|
||||
|
||||
%deviceTrySequence = new ArrayObject();
|
||||
%bestMatch = -1;
|
||||
%count = getRecordCount( %devices );
|
||||
for( %i = 0; %i < %count; %i ++ )
|
||||
{
|
||||
%info = getRecord( %devices, %i );
|
||||
%provider = getField( %info, 0 );
|
||||
|
||||
%deviceTrySequence.push_back( %provider, %info );
|
||||
}
|
||||
|
||||
%deviceTrySequence.sortfkd( "sfxCompareProvider" );
|
||||
|
||||
// Try the devices in order.
|
||||
|
||||
%count = %deviceTrySequence.count();
|
||||
for( %i = 0; %i < %count; %i ++ )
|
||||
{
|
||||
%provider = %deviceTrySequence.getKey( %i );
|
||||
%info = %deviceTrySequence.getValue( %i );
|
||||
|
||||
$pref::SFX::provider = %provider;
|
||||
$pref::SFX::device = getField( %info, 1 );
|
||||
$pref::SFX::useHardware = getField( %info, 2 );
|
||||
|
||||
// By default we've decided to avoid hardware devices as
|
||||
// they are buggy and prone to problems.
|
||||
$pref::SFX::useHardware = false;
|
||||
|
||||
if( sfxInit() )
|
||||
{
|
||||
$pref::SFX::autoDetect = false;
|
||||
%deviceTrySequence.delete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Found no suitable device.
|
||||
|
||||
error( "sfxAutodetect - Could not initialize a valid SFX device." );
|
||||
|
||||
$pref::SFX::provider = "";
|
||||
$pref::SFX::device = "";
|
||||
$pref::SFX::useHardware = "";
|
||||
|
||||
%deviceTrySequence.delete();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Backwards-compatibility with old channel system.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Volume channel IDs for backwards-compatibility.
|
||||
|
||||
$GuiAudioType = 1; // Interface.
|
||||
$SimAudioType = 2; // Game.
|
||||
$MessageAudioType = 3; // Notifications.
|
||||
$MusicAudioType = 4; // Music.
|
||||
|
||||
$AudioChannels[ 0 ] = AudioChannelDefault;
|
||||
$AudioChannels[ $GuiAudioType ] = AudioChannelGui;
|
||||
$AudioChannels[ $SimAudioType ] = AudioChannelEffects;
|
||||
$AudioChannels[ $MessageAudioType ] = AudioChannelMessages;
|
||||
$AudioChannels[ $MusicAudioType ] = AudioChannelMusic;
|
||||
|
||||
function sfxOldChannelToGroup( %channel )
|
||||
{
|
||||
return $AudioChannels[ %channel ];
|
||||
}
|
||||
|
||||
function sfxGroupToOldChannel( %group )
|
||||
{
|
||||
%id = %group.getId();
|
||||
for( %i = 0;; %i ++ )
|
||||
if( !isObject( $AudioChannels[ %i ] ) )
|
||||
return -1;
|
||||
else if( $AudioChannels[ %i ].getId() == %id )
|
||||
return %i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
function sfxSetMasterVolume( %volume )
|
||||
{
|
||||
AudioChannelMaster.setVolume( %volume );
|
||||
}
|
||||
|
||||
function sfxGetMasterVolume( %volume )
|
||||
{
|
||||
return AudioChannelMaster.getVolume();
|
||||
}
|
||||
|
||||
function sfxStopAll( %channel )
|
||||
{
|
||||
// Don't stop channel itself since that isn't quite what the function
|
||||
// here intends.
|
||||
|
||||
%channel = sfxOldChannelToGroup( %channel );
|
||||
if (isObject(%channel))
|
||||
{
|
||||
foreach( %source in %channel )
|
||||
%source.stop();
|
||||
}
|
||||
}
|
||||
|
||||
function sfxGetChannelVolume( %channel )
|
||||
{
|
||||
%obj = sfxOldChannelToGroup( %channel );
|
||||
if( isObject( %obj ) )
|
||||
return %obj.getVolume();
|
||||
}
|
||||
|
||||
function sfxSetChannelVolume( %channel, %volume )
|
||||
{
|
||||
%obj = sfxOldChannelToGroup( %channel );
|
||||
if( isObject( %obj ) )
|
||||
%obj.setVolume( %volume );
|
||||
}
|
||||
|
||||
/*singleton SimSet( SFXPausedSet );
|
||||
|
||||
|
||||
/// Pauses the playback of active sound sources.
|
||||
///
|
||||
/// @param %channels An optional word list of channel indices or an empty
|
||||
/// string to pause sources on all channels.
|
||||
/// @param %pauseSet An optional SimSet which is filled with the paused
|
||||
/// sources. If not specified the global SfxSourceGroup
|
||||
/// is used.
|
||||
///
|
||||
/// @deprecated
|
||||
///
|
||||
function sfxPause( %channels, %pauseSet )
|
||||
{
|
||||
// Did we get a set to populate?
|
||||
if ( !isObject( %pauseSet ) )
|
||||
%pauseSet = SFXPausedSet;
|
||||
|
||||
%count = SFXSourceSet.getCount();
|
||||
for ( %i = 0; %i < %count; %i++ )
|
||||
{
|
||||
%source = SFXSourceSet.getObject( %i );
|
||||
|
||||
%channel = sfxGroupToOldChannel( %source.getGroup() );
|
||||
if( %channels $= "" || findWord( %channels, %channel ) != -1 )
|
||||
{
|
||||
%source.pause();
|
||||
%pauseSet.add( %source );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Resumes the playback of paused sound sources.
|
||||
///
|
||||
/// @param %pauseSet An optional SimSet which contains the paused sound
|
||||
/// sources to be resumed. If not specified the global
|
||||
/// SfxSourceGroup is used.
|
||||
/// @deprecated
|
||||
///
|
||||
function sfxResume( %pauseSet )
|
||||
{
|
||||
if ( !isObject( %pauseSet ) )
|
||||
%pauseSet = SFXPausedSet;
|
||||
|
||||
%count = %pauseSet.getCount();
|
||||
for ( %i = 0; %i < %count; %i++ )
|
||||
{
|
||||
%source = %pauseSet.getObject( %i );
|
||||
%source.play();
|
||||
}
|
||||
|
||||
// Clear our pause set... the caller is left
|
||||
// to clear his own if he passed one.
|
||||
%pauseSet.clear();
|
||||
}*/
|
||||
162
Templates/BaseGame/game/core/canvas.cs
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function createCanvas(%windowTitle)
|
||||
{
|
||||
if ($isDedicated)
|
||||
{
|
||||
GFXInit::createNullDevice();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create the Canvas
|
||||
$GameCanvas = new GuiCanvas(Canvas)
|
||||
{
|
||||
displayWindow = $platform !$= "windows";
|
||||
};
|
||||
|
||||
// Set the window title
|
||||
if (isObject(Canvas))
|
||||
{
|
||||
Canvas.setWindowTitle(%windowTitle @ " - " @ $pref::Video::displayDevice);
|
||||
configureCanvas();
|
||||
}
|
||||
else
|
||||
{
|
||||
error("Canvas creation failed. Shutting down.");
|
||||
quit();
|
||||
}
|
||||
}
|
||||
|
||||
// Constants for referencing video resolution preferences
|
||||
$WORD::RES_X = 0;
|
||||
$WORD::RES_Y = 1;
|
||||
$WORD::FULLSCREEN = 2;
|
||||
$WORD::BITDEPTH = 3;
|
||||
$WORD::REFRESH = 4;
|
||||
$WORD::AA = 5;
|
||||
|
||||
function configureCanvas()
|
||||
{
|
||||
// Setup a good default if we don't have one already.
|
||||
if ($pref::Video::Resolution $= "")
|
||||
$pref::Video::Resolution = "800 600";
|
||||
if ($pref::Video::FullScreen $= "")
|
||||
$pref::Video::FullScreen = false;
|
||||
if ($pref::Video::BitDepth $= "")
|
||||
$pref::Video::BitDepth = "32";
|
||||
if ($pref::Video::RefreshRate $= "")
|
||||
$pref::Video::RefreshRate = "60";
|
||||
if ($pref::Video::AA $= "")
|
||||
$pref::Video::AA = "4";
|
||||
|
||||
%resX = $pref::Video::Resolution.x;
|
||||
%resY = $pref::Video::Resolution.y;
|
||||
%fs = $pref::Video::FullScreen;
|
||||
%bpp = $pref::Video::BitDepth;
|
||||
%rate = $pref::Video::RefreshRate;
|
||||
%aa = $pref::Video::AA;
|
||||
|
||||
if($cliFullscreen !$= "") {
|
||||
%fs = $cliFullscreen;
|
||||
$cliFullscreen = "";
|
||||
}
|
||||
|
||||
echo("--------------");
|
||||
echo("Attempting to set resolution to \"" @ %resX SPC %resY SPC %fs SPC %bpp SPC %rate SPC %aa @ "\"");
|
||||
|
||||
%deskRes = getDesktopResolution();
|
||||
%deskResX = getWord(%deskRes, $WORD::RES_X);
|
||||
%deskResY = getWord(%deskRes, $WORD::RES_Y);
|
||||
%deskResBPP = getWord(%deskRes, 2);
|
||||
|
||||
// We shouldn't be getting this any more but just in case...
|
||||
if (%bpp $= "Default")
|
||||
%bpp = %deskResBPP;
|
||||
|
||||
// Make sure we are running at a valid resolution
|
||||
if (%fs $= "0" || %fs $= "false")
|
||||
{
|
||||
// Windowed mode has to use the same bit depth as the desktop
|
||||
%bpp = %deskResBPP;
|
||||
|
||||
// Windowed mode also has to run at a smaller resolution than the desktop
|
||||
if ((%resX >= %deskResX) || (%resY >= %deskResY))
|
||||
{
|
||||
warn("Warning: The requested windowed resolution is equal to or larger than the current desktop resolution. Attempting to find a better resolution");
|
||||
|
||||
%resCount = Canvas.getModeCount();
|
||||
for (%i = (%resCount - 1); %i >= 0; %i--)
|
||||
{
|
||||
%testRes = Canvas.getMode(%i);
|
||||
%testResX = getWord(%testRes, $WORD::RES_X);
|
||||
%testResY = getWord(%testRes, $WORD::RES_Y);
|
||||
%testBPP = getWord(%testRes, $WORD::BITDEPTH);
|
||||
|
||||
if (%testBPP != %bpp)
|
||||
continue;
|
||||
|
||||
if ((%testResX < %deskResX) && (%testResY < %deskResY))
|
||||
{
|
||||
// This will work as our new resolution
|
||||
%resX = %testResX;
|
||||
%resY = %testResY;
|
||||
|
||||
warn("Warning: Switching to \"" @ %resX SPC %resY SPC %bpp @ "\"");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pref::Video::Resolution = %resX SPC %resY;
|
||||
$pref::Video::FullScreen = %fs;
|
||||
$pref::Video::BitDepth = %bpp;
|
||||
$pref::Video::RefreshRate = %rate;
|
||||
$pref::Video::AA = %aa;
|
||||
|
||||
if (%fs == 1 || %fs $= "true")
|
||||
%fsLabel = "Yes";
|
||||
else
|
||||
%fsLabel = "No";
|
||||
|
||||
echo("Accepted Mode: " NL
|
||||
"--Resolution : " @ %resX SPC %resY NL
|
||||
"--Full Screen : " @ %fsLabel NL
|
||||
"--Bits Per Pixel : " @ %bpp NL
|
||||
"--Refresh Rate : " @ %rate NL
|
||||
"--AA TypeXLevel : " @ %aa NL
|
||||
"--------------");
|
||||
|
||||
// Actually set the new video mode
|
||||
Canvas.setVideoMode(%resX, %resY, %fs, %bpp, %rate, %aa);
|
||||
|
||||
commandToServer('setClientAspectRatio', %resX, %resY);
|
||||
|
||||
// AA piggybacks on the AA setting in $pref::Video::mode.
|
||||
// We need to parse the setting between AA modes, and then it's level
|
||||
// It's formatted as AATypexAALevel
|
||||
// So, FXAAx4 or MLAAx2
|
||||
if ( isObject( FXAA_PostEffect ) )
|
||||
FXAA_PostEffect.isEnabled = ( %aa > 0 ) ? true : false;
|
||||
}
|
||||
51
Templates/BaseGame/game/core/console/console.gui
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
new GuiControl(ConsoleDlg) {
|
||||
profile = "GuiDefaultProfile";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
position = "0 0";
|
||||
extent = "640 480";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
helpTag = "0";
|
||||
|
||||
new GuiConsoleEditCtrl(ConsoleEntry) {
|
||||
profile = "ConsoleTextEditProfile";
|
||||
horizSizing = "width";
|
||||
vertSizing = "top";
|
||||
position = "0 462";
|
||||
extent = "640 18";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
altCommand = "ConsoleEntry::eval();";
|
||||
helpTag = "0";
|
||||
maxLength = "255";
|
||||
historySize = "40";
|
||||
password = "0";
|
||||
tabComplete = "0";
|
||||
sinkAllKeyEvents = "1";
|
||||
useSiblingScroller = "1";
|
||||
};
|
||||
new GuiScrollCtrl() {
|
||||
internalName = "Scroll";
|
||||
profile = "ConsoleScrollProfile";
|
||||
horizSizing = "width";
|
||||
vertSizing = "height";
|
||||
position = "0 0";
|
||||
extent = "640 462";
|
||||
minExtent = "8 8";
|
||||
visible = "1";
|
||||
helpTag = "0";
|
||||
willFirstRespond = "1";
|
||||
hScrollBar = "alwaysOn";
|
||||
vScrollBar = "alwaysOn";
|
||||
lockHorizScroll = "false";
|
||||
lockVertScroll = "false";
|
||||
constantThumbHeight = "0";
|
||||
childMargin = "0 0";
|
||||
|
||||
new GuiConsole( ConsoleMessageLogView ) {
|
||||
profile = "GuiConsoleProfile";
|
||||
position = "0 0";
|
||||
};
|
||||
};
|
||||
};
|
||||
108
Templates/BaseGame/game/core/console/main.cs
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
exec("./profiles.cs");
|
||||
exec("./console.gui");
|
||||
|
||||
GlobalActionMap.bind("keyboard", "tilde", "toggleConsole");
|
||||
|
||||
function ConsoleEntry::eval()
|
||||
{
|
||||
%text = trim(ConsoleEntry.getValue());
|
||||
if(%text $= "")
|
||||
return;
|
||||
|
||||
// If it's missing a trailing () and it's not a variable,
|
||||
// append the parentheses.
|
||||
if(strpos(%text, "(") == -1 && !isDefined(%text)) {
|
||||
if(strpos(%text, "=") == -1 && strpos(%text, " ") == -1) {
|
||||
if(strpos(%text, "{") == -1 && strpos(%text, "}") == -1) {
|
||||
%text = %text @ "()";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append a semicolon if need be.
|
||||
%pos = strlen(%text) - 1;
|
||||
if(strpos(%text, ";", %pos) == -1 && strpos(%text, "}") == -1) {
|
||||
%text = %text @ ";";
|
||||
}
|
||||
|
||||
// Turn off warnings for assigning from void
|
||||
// and evaluate the snippet.
|
||||
if(!isDefined("$Con::warnVoidAssignment"))
|
||||
%oldWarnVoidAssignment = true;
|
||||
else
|
||||
%oldWarnVoidAssignment = $Con::warnVoidAssignment;
|
||||
$Con::warnVoidAssignment = false;
|
||||
|
||||
echo("==>" @ %text);
|
||||
if( !startsWith(%text, "function ")
|
||||
&& !startsWith(%text, "datablock ")
|
||||
&& !startsWith(%text, "foreach(")
|
||||
&& !startsWith(%text, "foreach$(")
|
||||
&& !startsWith(%text, "if(")
|
||||
&& !startsWith(%text, "while(")
|
||||
&& !startsWith(%text, "for(")
|
||||
&& !startsWith(%text, "switch(")
|
||||
&& !startsWith(%text, "switch$("))
|
||||
eval("%result = " @ %text);
|
||||
else
|
||||
eval(%text);
|
||||
$Con::warnVoidAssignment = %oldWarnVoidAssignment;
|
||||
|
||||
ConsoleEntry.setValue("");
|
||||
|
||||
// Echo result.
|
||||
if(%result !$= "")
|
||||
echo(%result);
|
||||
}
|
||||
|
||||
function ToggleConsole(%make)
|
||||
{
|
||||
if (%make) {
|
||||
if (ConsoleDlg.isAwake()) {
|
||||
// Deactivate the console.
|
||||
Canvas.popDialog(ConsoleDlg);
|
||||
} else {
|
||||
Canvas.pushDialog(ConsoleDlg, 99);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ConsoleDlg::hideWindow(%this)
|
||||
{
|
||||
%this-->Scroll.setVisible(false);
|
||||
}
|
||||
|
||||
function ConsoleDlg::showWindow(%this)
|
||||
{
|
||||
%this-->Scroll.setVisible(true);
|
||||
}
|
||||
|
||||
function ConsoleDlg::setAlpha( %this, %alpha)
|
||||
{
|
||||
if (%alpha $= "")
|
||||
ConsoleScrollProfile.fillColor = $ConsoleDefaultFillColor;
|
||||
else
|
||||
ConsoleScrollProfile.fillColor = getWords($ConsoleDefaultFillColor, 0, 2) SPC %alpha * 255.0;
|
||||
}
|
||||
70
Templates/BaseGame/game/core/console/profiles.cs
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
if(!isObject(GuiConsoleProfile))
|
||||
new GuiControlProfile(GuiConsoleProfile)
|
||||
{
|
||||
fontType = ($platform $= "macos") ? "Monaco" : "Lucida Console";
|
||||
fontSize = ($platform $= "macos") ? 13 : 12;
|
||||
fontColor = "255 255 255";
|
||||
fontColorHL = "0 255 255";
|
||||
fontColorNA = "255 0 0";
|
||||
fontColors[6] = "100 100 100";
|
||||
fontColors[7] = "100 100 0";
|
||||
fontColors[8] = "0 0 100";
|
||||
fontColors[9] = "0 100 0";
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if(!isObject(GuiConsoleTextProfile))
|
||||
new GuiControlProfile(GuiConsoleTextProfile)
|
||||
{
|
||||
fontColor = "0 0 0";
|
||||
autoSizeWidth = true;
|
||||
autoSizeHeight = true;
|
||||
textOffset = "2 2";
|
||||
opaque = true;
|
||||
fillColor = "255 255 255";
|
||||
border = true;
|
||||
borderThickness = 1;
|
||||
borderColor = "0 0 0";
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if(!isObject(ConsoleScrollProfile))
|
||||
new GuiControlProfile(ConsoleScrollProfile : GuiScrollProfile)
|
||||
{
|
||||
opaque = true;
|
||||
fillColor = "0 0 0 175";
|
||||
border = 1;
|
||||
//borderThickness = 0;
|
||||
borderColor = "0 0 0";
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if(!isObject(ConsoleTextEditProfile))
|
||||
new GuiControlProfile(ConsoleTextEditProfile : GuiTextEditProfile)
|
||||
{
|
||||
fillColor = "242 241 240 255";
|
||||
fillColorHL = "255 255 255";
|
||||
category = "Core";
|
||||
};
|
||||
102
Templates/BaseGame/game/core/cursor.cs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// Cursor toggle functions.
|
||||
//---------------------------------------------------------------------------------------------
|
||||
$cursorControlled = true;
|
||||
function showCursor()
|
||||
{
|
||||
if ($cursorControlled)
|
||||
lockMouse(false);
|
||||
Canvas.cursorOn();
|
||||
}
|
||||
|
||||
function hideCursor()
|
||||
{
|
||||
if ($cursorControlled)
|
||||
lockMouse(true);
|
||||
Canvas.cursorOff();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// In the CanvasCursor package we add some additional functionality to the built-in GuiCanvas
|
||||
// class, of which the global Canvas object is an instance. In this case, the behavior we want
|
||||
// is for the cursor to automatically display, except when the only guis visible want no
|
||||
// cursor - usually the in game interface.
|
||||
//---------------------------------------------------------------------------------------------
|
||||
package CanvasCursorPackage
|
||||
{
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// checkCursor
|
||||
// The checkCursor method iterates through all the root controls on the canvas checking each
|
||||
// ones noCursor property. If the noCursor property exists as anything other than false or an
|
||||
// empty string on every control, the cursor will be hidden.
|
||||
//---------------------------------------------------------------------------------------------
|
||||
function GuiCanvas::checkCursor(%this)
|
||||
{
|
||||
%count = %this.getCount();
|
||||
for(%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%control = %this.getObject(%i);
|
||||
if ((%control.noCursor $= "") || !%control.noCursor)
|
||||
{
|
||||
showCursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If we get here, every control requested a hidden cursor, so we oblige.
|
||||
hideCursor();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// The following functions override the GuiCanvas defaults that involve changing the content
|
||||
// of the Canvas. Basically, all we are doing is adding a call to checkCursor to each one.
|
||||
//---------------------------------------------------------------------------------------------
|
||||
function GuiCanvas::setContent(%this, %ctrl)
|
||||
{
|
||||
Parent::setContent(%this, %ctrl);
|
||||
%this.checkCursor();
|
||||
}
|
||||
|
||||
function GuiCanvas::pushDialog(%this, %ctrl, %layer, %center)
|
||||
{
|
||||
Parent::pushDialog(%this, %ctrl, %layer, %center);
|
||||
%this.checkCursor();
|
||||
}
|
||||
|
||||
function GuiCanvas::popDialog(%this, %ctrl)
|
||||
{
|
||||
Parent::popDialog(%this, %ctrl);
|
||||
%this.checkCursor();
|
||||
}
|
||||
|
||||
function GuiCanvas::popLayer(%this, %layer)
|
||||
{
|
||||
Parent::popLayer(%this, %layer);
|
||||
%this.checkCursor();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
activatePackage(CanvasCursorPackage);
|
||||
BIN
Templates/BaseGame/game/core/fonts/Arial 10 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/Arial 12 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/Arial 14 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/Arial 16 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/Arial 36 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/Arial Bold 14 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/Arial Bold 16 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/Arial Bold 18 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/ArialBold 14 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/ArialItalic 14 (ansi).uft
Normal file
BIN
Templates/BaseGame/game/core/fonts/Lucida Console 12 (ansi).uft
Normal file
55
Templates/BaseGame/game/core/gfxData/clouds.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CloudLayer
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( CloudLayerShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/cloudLayerV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/cloudLayerP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/cloudLayerV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/cloudLayerP.glsl";
|
||||
|
||||
samplerNames[0] = "$normalHeightMap";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// BasicClouds
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( BasicCloudsShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/basicCloudsV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/basicCloudsP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/basicCloudsV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/basicCloudsP.glsl";
|
||||
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
79
Templates/BaseGame/game/core/gfxData/commonMaterialData.cs
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Anim flag settings - must match material.h
|
||||
// These cannot be enumed through script becuase it cannot
|
||||
// handle the "|" operation for combining them together
|
||||
// ie. Scroll | Wave does not work.
|
||||
//-----------------------------------------------------------------------------
|
||||
$scroll = 1;
|
||||
$rotate = 2;
|
||||
$wave = 4;
|
||||
$scale = 8;
|
||||
$sequence = 16;
|
||||
|
||||
|
||||
// Common stateblock definitions
|
||||
new GFXSamplerStateData(SamplerClampLinear)
|
||||
{
|
||||
textureColorOp = GFXTOPModulate;
|
||||
addressModeU = GFXAddressClamp;
|
||||
addressModeV = GFXAddressClamp;
|
||||
addressModeW = GFXAddressClamp;
|
||||
magFilter = GFXTextureFilterLinear;
|
||||
minFilter = GFXTextureFilterLinear;
|
||||
mipFilter = GFXTextureFilterLinear;
|
||||
};
|
||||
|
||||
new GFXSamplerStateData(SamplerClampPoint)
|
||||
{
|
||||
textureColorOp = GFXTOPModulate;
|
||||
addressModeU = GFXAddressClamp;
|
||||
addressModeV = GFXAddressClamp;
|
||||
addressModeW = GFXAddressClamp;
|
||||
magFilter = GFXTextureFilterPoint;
|
||||
minFilter = GFXTextureFilterPoint;
|
||||
mipFilter = GFXTextureFilterPoint;
|
||||
};
|
||||
|
||||
new GFXSamplerStateData(SamplerWrapLinear)
|
||||
{
|
||||
textureColorOp = GFXTOPModulate;
|
||||
addressModeU = GFXTextureAddressWrap;
|
||||
addressModeV = GFXTextureAddressWrap;
|
||||
addressModeW = GFXTextureAddressWrap;
|
||||
magFilter = GFXTextureFilterLinear;
|
||||
minFilter = GFXTextureFilterLinear;
|
||||
mipFilter = GFXTextureFilterLinear;
|
||||
};
|
||||
|
||||
new GFXSamplerStateData(SamplerWrapPoint)
|
||||
{
|
||||
textureColorOp = GFXTOPModulate;
|
||||
addressModeU = GFXTextureAddressWrap;
|
||||
addressModeV = GFXTextureAddressWrap;
|
||||
addressModeW = GFXTextureAddressWrap;
|
||||
magFilter = GFXTextureFilterPoint;
|
||||
minFilter = GFXTextureFilterPoint;
|
||||
mipFilter = GFXTextureFilterPoint;
|
||||
};
|
||||
48
Templates/BaseGame/game/core/gfxData/scatterSky.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
new GFXStateBlockData( ScatterSkySBData )
|
||||
{
|
||||
cullMode = "GFXCullNone";
|
||||
|
||||
zDefined = true;
|
||||
zEnable = true;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
vertexColorEnable = true;
|
||||
};
|
||||
|
||||
singleton ShaderData( ScatterSkyShaderData )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/scatterSkyV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/scatterSkyP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/scatterSkyV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/scatterSkyP.glsl";
|
||||
|
||||
samplerNames[0] = "$nightSky";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
140
Templates/BaseGame/game/core/gfxData/shaders.cs
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This file contains shader data necessary for various engine utility functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
singleton ShaderData( ParticlesShaderData )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/particlesV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/particlesP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/particlesV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/particlesP.glsl";
|
||||
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
samplerNames[1] = "$prepassTex";
|
||||
samplerNames[2] = "$paraboloidLightMap";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( OffscreenParticleCompositeShaderData )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/particleCompositeV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/particleCompositeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/particleCompositeV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/particleCompositeP.glsl";
|
||||
|
||||
samplerNames[0] = "$colorSource";
|
||||
samplerNames[1] = "$edgeSource";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Planar Reflection
|
||||
//-----------------------------------------------------------------------------
|
||||
new ShaderData( ReflectBump )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/planarReflectBumpV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/planarReflectBumpP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/planarReflectBumpV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/planarReflectBumpP.glsl";
|
||||
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
samplerNames[1] = "$refractMap";
|
||||
samplerNames[2] = "$bumpMap";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
new ShaderData( Reflect )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/planarReflectV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/planarReflectP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/planarReflectV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/planarReflectP.glsl";
|
||||
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
samplerNames[1] = "$refractMap";
|
||||
|
||||
pixVersion = 1.4;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// fxFoliageReplicator
|
||||
//-----------------------------------------------------------------------------
|
||||
new ShaderData( fxFoliageReplicatorShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/fxFoliageReplicatorV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/fxFoliageReplicatorP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/gl/fxFoliageReplicatorV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/fxFoliageReplicatorP.glsl";
|
||||
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
samplerNames[1] = "$alphaMap";
|
||||
|
||||
pixVersion = 1.4;
|
||||
};
|
||||
|
||||
singleton ShaderData( VolumetricFogPrePassShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogPreV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogPreP.glsl";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
singleton ShaderData( VolumetricFogShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogP.glsl";
|
||||
|
||||
samplerNames[0] = "$prepassTex";
|
||||
samplerNames[1] = "$depthBuffer";
|
||||
samplerNames[2] = "$frontBuffer";
|
||||
samplerNames[3] = "$density";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
singleton ShaderData( VolumetricFogReflectionShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogRefl.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogPreV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogRefl.glsl";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
36
Templates/BaseGame/game/core/gfxData/terrainBlock.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/// Used when generating the blended base texture.
|
||||
singleton ShaderData( TerrainBlendShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/terrain/blendV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/terrain/blendP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/terrain/gl/blendV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/terrain/gl/blendP.glsl";
|
||||
|
||||
samplerNames[0] = "layerTex";
|
||||
samplerNames[1] = "textureMap";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
208
Templates/BaseGame/game/core/gfxData/water.cs
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Water
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( WaterShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/water/waterV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/water/waterP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/water/gl/waterV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/water/gl/waterP.glsl";
|
||||
|
||||
samplerNames[0] = "$bumpMap"; // noise
|
||||
samplerNames[1] = "$prepassTex"; // #prepass
|
||||
samplerNames[2] = "$reflectMap"; // $reflectbuff
|
||||
samplerNames[3] = "$refractBuff"; // $backbuff
|
||||
samplerNames[4] = "$skyMap"; // $cubemap
|
||||
samplerNames[5] = "$foamMap"; // foam
|
||||
samplerNames[6] = "$depthGradMap"; // depthMap ( color gradient )
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
new GFXSamplerStateData(WaterSampler)
|
||||
{
|
||||
textureColorOp = GFXTOPModulate;
|
||||
addressModeU = GFXAddressWrap;
|
||||
addressModeV = GFXAddressWrap;
|
||||
addressModeW = GFXAddressWrap;
|
||||
magFilter = GFXTextureFilterLinear;
|
||||
minFilter = GFXTextureFilterAnisotropic;
|
||||
mipFilter = GFXTextureFilterLinear;
|
||||
maxAnisotropy = 4;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( WaterStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = WaterSampler; // noise
|
||||
samplerStates[1] = SamplerClampPoint; // #prepass
|
||||
samplerStates[2] = SamplerClampLinear; // $reflectbuff
|
||||
samplerStates[3] = SamplerClampPoint; // $backbuff
|
||||
samplerStates[4] = SamplerWrapLinear; // $cubemap
|
||||
samplerStates[5] = SamplerWrapLinear; // foam
|
||||
samplerStates[6] = SamplerClampLinear; // depthMap ( color gradient )
|
||||
cullDefined = true;
|
||||
cullMode = "GFXCullCCW";
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( UnderWaterStateBlock : WaterStateBlock )
|
||||
{
|
||||
cullMode = "GFXCullCW";
|
||||
};
|
||||
|
||||
singleton CustomMaterial( WaterMat )
|
||||
{
|
||||
sampler["prepassTex"] = "#prepass";
|
||||
sampler["reflectMap"] = "$reflectbuff";
|
||||
sampler["refractBuff"] = "$backbuff";
|
||||
// These samplers are set in code not here.
|
||||
// This is to allow different WaterObject instances
|
||||
// to use this same material but override these textures
|
||||
// per instance.
|
||||
//sampler["bumpMap"] = "";
|
||||
//sampler["skyMap"] = "";
|
||||
//sampler["foamMap"] = "";
|
||||
//sampler["depthGradMap"] = "";
|
||||
|
||||
shader = WaterShader;
|
||||
stateBlock = WaterStateBlock;
|
||||
version = 3.0;
|
||||
|
||||
useAnisotropic[0] = true;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Underwater
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( UnderWaterShader : WaterShader )
|
||||
{
|
||||
defines = "UNDERWATER";
|
||||
};
|
||||
|
||||
singleton CustomMaterial( UnderwaterMat )
|
||||
{
|
||||
// These samplers are set in code not here.
|
||||
// This is to allow different WaterObject instances
|
||||
// to use this same material but override these textures
|
||||
// per instance.
|
||||
//sampler["bumpMap"] = "core/art/water/noise02";
|
||||
//sampler["foamMap"] = "core/art/water/foam";
|
||||
|
||||
sampler["prepassTex"] = "#prepass";
|
||||
sampler["refractBuff"] = "$backbuff";
|
||||
|
||||
shader = UnderWaterShader;
|
||||
stateBlock = UnderWaterStateBlock;
|
||||
specular = "0.75 0.75 0.75 1.0";
|
||||
specularPower = 48.0;
|
||||
version = 3.0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Basic Water
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( WaterBasicShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/water/waterBasicV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/water/waterBasicP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/water/gl/waterBasicV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/water/gl/waterBasicP.glsl";
|
||||
|
||||
samplerNames[0] = "$bumpMap";
|
||||
samplerNames[2] = "$reflectMap";
|
||||
samplerNames[3] = "$refractBuff";
|
||||
samplerNames[4] = "$skyMap";
|
||||
samplerNames[5] = "$depthGradMap";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( WaterBasicStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = WaterSampler; // noise
|
||||
samplerStates[2] = SamplerClampLinear; // $reflectbuff
|
||||
samplerStates[3] = SamplerClampPoint; // $backbuff
|
||||
samplerStates[4] = SamplerWrapLinear; // $cubemap
|
||||
cullDefined = true;
|
||||
cullMode = "GFXCullCCW";
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( UnderWaterBasicStateBlock : WaterBasicStateBlock )
|
||||
{
|
||||
cullMode = "GFXCullCW";
|
||||
};
|
||||
|
||||
singleton CustomMaterial( WaterBasicMat )
|
||||
{
|
||||
// These samplers are set in code not here.
|
||||
// This is to allow different WaterObject instances
|
||||
// to use this same material but override these textures
|
||||
// per instance.
|
||||
//sampler["bumpMap"] = "core/art/water/noise02";
|
||||
//sampler["skyMap"] = "$cubemap";
|
||||
|
||||
//sampler["prepassTex"] = "#prepass";
|
||||
sampler["reflectMap"] = "$reflectbuff";
|
||||
sampler["refractBuff"] = "$backbuff";
|
||||
|
||||
cubemap = NewLevelSkyCubemap;
|
||||
shader = WaterBasicShader;
|
||||
stateBlock = WaterBasicStateBlock;
|
||||
version = 2.0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Basic UnderWater
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( UnderWaterBasicShader : WaterBasicShader)
|
||||
{
|
||||
defines = "UNDERWATER";
|
||||
};
|
||||
|
||||
singleton CustomMaterial( UnderwaterBasicMat )
|
||||
{
|
||||
// These samplers are set in code not here.
|
||||
// This is to allow different WaterObject instances
|
||||
// to use this same material but override these textures
|
||||
// per instance.
|
||||
//sampler["bumpMap"] = "core/art/water/noise02";
|
||||
//samplers["skyMap"] = "$cubemap";
|
||||
|
||||
//sampler["prepassTex"] = "#prepass";
|
||||
sampler["refractBuff"] = "$backbuff";
|
||||
|
||||
shader = UnderWaterBasicShader;
|
||||
stateBlock = UnderWaterBasicStateBlock;
|
||||
version = 2.0;
|
||||
};
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// ATI Vendor Profile Script
|
||||
//
|
||||
// This script is responsible for setting global
|
||||
// capability strings based on the nVidia vendor.
|
||||
|
||||
if(GFXCardProfiler::getVersion() < 64.44)
|
||||
{
|
||||
$GFX::OutdatedDrivers = true;
|
||||
$GFX::OutdatedDriversLink = "<a:www.ati.com>You can get newer drivers here.</a>.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$GFX::OutdatedDrivers = false;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// nVidia Vendor Profile Script
|
||||
//
|
||||
// This script is responsible for setting global
|
||||
// capability strings based on the nVidia vendor.
|
||||
|
||||
if(GFXCardProfiler::getVersion() < 1.2)
|
||||
{
|
||||
$GFX::OutdatedDrivers = true;
|
||||
$GFX::OutdatedDriversLink = "<a:www.nvidia.com>You can get newer drivers here.</a>.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$GFX::OutdatedDrivers = false;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// nVidia Vendor Profile Script
|
||||
//
|
||||
// This script is responsible for setting global
|
||||
// capability strings based on the nVidia vendor.
|
||||
|
||||
if(GFXCardProfiler::getVersion() < 53.82)
|
||||
{
|
||||
$GFX::OutdatedDrivers = true;
|
||||
$GFX::OutdatedDriversLink = "<a:www.nvidia.com>You can get newer drivers here.</a>.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$GFX::OutdatedDrivers = false;
|
||||
}
|
||||
|
||||
// Silly card has trouble with this!
|
||||
GFXCardProfiler::setCapability("autoMipmapLevel", false);
|
||||
36
Templates/BaseGame/game/core/gfxprofile/D3D9.NVIDIA.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// nVidia Vendor Profile Script
|
||||
//
|
||||
// This script is responsible for setting global
|
||||
// capability strings based on the nVidia vendor.
|
||||
|
||||
if(GFXCardProfiler::getVersion() < 56.72)
|
||||
{
|
||||
$GFX::OutdatedDrivers = true;
|
||||
$GFX::OutdatedDriversLink = "<a:www.nvidia.com>You can get newer drivers here.</a>.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$GFX::OutdatedDrivers = false;
|
||||
}
|
||||
26
Templates/BaseGame/game/core/gfxprofile/D3D9.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Direct3D 9 Renderer Profile Script
|
||||
//
|
||||
// This script is responsible for setting global
|
||||
// capability strings based on the D3D9 renderer type.
|
||||
102
Templates/BaseGame/game/core/globals.cs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DInput keyboard, mouse, and joystick prefs
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
$pref::Input::MouseEnabled = 1;
|
||||
$pref::Input::LinkMouseSensitivity = 1;
|
||||
$pref::Input::KeyboardEnabled = 1;
|
||||
$pref::Input::KeyboardTurnSpeed = 0.1;
|
||||
$pref::Input::JoystickEnabled = 0;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Video Preferences
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Set directory paths for various data or default images.
|
||||
$pref::Video::ProfilePath = "core/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";
|
||||
$pref::Video::defaultFenceCount = 0;
|
||||
|
||||
// This disables the hardware FSAA/MSAA so that we depend completely on the FXAA
|
||||
// post effect which works on all cards and in deferred mode. Note that the new
|
||||
// Intel Hybrid graphics on laptops will fail to initialize when hardware AA is
|
||||
// enabled... so you've been warned.
|
||||
$pref::Video::disableHardwareAA = true;
|
||||
|
||||
$pref::Video::disableNormalmapping = false;
|
||||
$pref::Video::disablePixSpecular = false;
|
||||
$pref::Video::disableCubemapping = false;
|
||||
$pref::Video::disableParallaxMapping = false;
|
||||
|
||||
// The number of mipmap levels to drop on loaded textures to reduce video memory
|
||||
// usage. It will skip any textures that have been defined as not allowing down
|
||||
// scaling.
|
||||
$pref::Video::textureReductionLevel = 0;
|
||||
|
||||
$pref::Video::defaultAnisotropy = 1;
|
||||
//$pref::Video::Gamma = 1.0;
|
||||
|
||||
/// AutoDetect graphics quality levels the next startup.
|
||||
$pref::Video::autoDetect = 1;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Shader stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This is the path used by ShaderGen to cache procedural shaders. If left
|
||||
// blank ShaderGen will only cache shaders to memory and not to disk.
|
||||
$shaderGen::cachePath = "";
|
||||
|
||||
// Uncomment to disable ShaderGen, useful when debugging
|
||||
//$ShaderGen::GenNewShaders = false;
|
||||
|
||||
// Uncomment to dump disassembly for any shader that is compiled to disk. These
|
||||
// will appear as shadername_dis.txt in the same path as the shader file.
|
||||
//$gfx::disassembleAllShaders = true;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Lighting and shadowing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Uncomment to enable AdvancedLighting on the Mac (T3D 2009 Beta 3)
|
||||
//$pref::machax::enableAdvancedLighting = true;
|
||||
|
||||
$sceneLighting::cacheSize = 20000;
|
||||
$sceneLighting::purgeMethod = "lastCreated";
|
||||
$sceneLighting::cacheLighting = 1;
|
||||
|
||||
$pref::Shadows::textureScalar = 1.0;
|
||||
$pref::Shadows::disable = false;
|
||||
|
||||
// Sets the shadow filtering mode.
|
||||
// None - Disables filtering.
|
||||
// SoftShadow - Does a simple soft shadow
|
||||
// SoftShadowHighQuality
|
||||
$pref::Shadows::filterMode = "SoftShadow";
|
||||
528
Templates/BaseGame/game/core/helperFunctions.cs
Normal file
|
|
@ -0,0 +1,528 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Check if a script file exists, compiled or not.
|
||||
function isScriptFile(%path)
|
||||
{
|
||||
if( isFile(%path @ ".dso") || isFile(%path) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function loadMaterials()
|
||||
{
|
||||
// Load any materials files for which we only have DSOs.
|
||||
|
||||
for( %file = findFirstFile( "*/materials.cs.dso" );
|
||||
%file !$= "";
|
||||
%file = findNextFile( "*/materials.cs.dso" ))
|
||||
{
|
||||
// Only execute, if we don't have the source file.
|
||||
%csFileName = getSubStr( %file, 0, strlen( %file ) - 4 );
|
||||
if( !isFile( %csFileName ) )
|
||||
exec( %csFileName );
|
||||
}
|
||||
|
||||
// Load all source material files.
|
||||
|
||||
for( %file = findFirstFile( "*/materials.cs" );
|
||||
%file !$= "";
|
||||
%file = findNextFile( "*/materials.cs" ))
|
||||
{
|
||||
exec( %file );
|
||||
}
|
||||
|
||||
// Load all materials created by the material editor if
|
||||
// the folder exists
|
||||
if( IsDirectory( "materialEditor" ) )
|
||||
{
|
||||
for( %file = findFirstFile( "materialEditor/*.cs.dso" );
|
||||
%file !$= "";
|
||||
%file = findNextFile( "materialEditor/*.cs.dso" ))
|
||||
{
|
||||
// Only execute, if we don't have the source file.
|
||||
%csFileName = getSubStr( %file, 0, strlen( %file ) - 4 );
|
||||
if( !isFile( %csFileName ) )
|
||||
exec( %csFileName );
|
||||
}
|
||||
|
||||
for( %file = findFirstFile( "materialEditor/*.cs" );
|
||||
%file !$= "";
|
||||
%file = findNextFile( "materialEditor/*.cs" ))
|
||||
{
|
||||
exec( %file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reloadMaterials()
|
||||
{
|
||||
reloadTextures();
|
||||
loadMaterials();
|
||||
reInitMaterials();
|
||||
}
|
||||
|
||||
function loadDatablockFiles( %datablockFiles, %recurse )
|
||||
{
|
||||
if ( %recurse )
|
||||
{
|
||||
recursiveLoadDatablockFiles( %datablockFiles, 9999 );
|
||||
return;
|
||||
}
|
||||
|
||||
%count = %datablockFiles.count();
|
||||
for ( %i=0; %i < %count; %i++ )
|
||||
{
|
||||
%file = %datablockFiles.getKey( %i );
|
||||
if ( !isFile(%file @ ".dso") && !isFile(%file) )
|
||||
continue;
|
||||
|
||||
exec( %file );
|
||||
}
|
||||
|
||||
// Destroy the incoming list.
|
||||
//%datablockFiles.delete();
|
||||
}
|
||||
|
||||
function recursiveLoadDatablockFiles( %datablockFiles, %previousErrors )
|
||||
{
|
||||
%reloadDatablockFiles = new ArrayObject();
|
||||
|
||||
// Keep track of the number of datablocks that
|
||||
// failed during this pass.
|
||||
%failedDatablocks = 0;
|
||||
|
||||
// Try re-executing the list of datablock files.
|
||||
%count = %datablockFiles.count();
|
||||
for ( %i=0; %i < %count; %i++ )
|
||||
{
|
||||
%file = %datablockFiles.getKey( %i );
|
||||
if ( !isFile(%file @ ".dso") && !isFile(%file) )
|
||||
continue;
|
||||
|
||||
// Start counting copy constructor creation errors.
|
||||
$Con::objectCopyFailures = 0;
|
||||
|
||||
exec( %file );
|
||||
|
||||
// If errors occured then store this file for re-exec later.
|
||||
if ( $Con::objectCopyFailures > 0 )
|
||||
{
|
||||
%reloadDatablockFiles.add( %file );
|
||||
%failedDatablocks = %failedDatablocks + $Con::objectCopyFailures;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the object copy failure counter so that
|
||||
// we get console error messages again.
|
||||
$Con::objectCopyFailures = -1;
|
||||
|
||||
// Delete the old incoming list... we're done with it.
|
||||
//%datablockFiles.delete();
|
||||
|
||||
// If we still have datablocks to retry.
|
||||
%newCount = %reloadDatablockFiles.count();
|
||||
if ( %newCount > 0 )
|
||||
{
|
||||
// If the datablock failures have not been reduced
|
||||
// from the last pass then we must have a real syntax
|
||||
// error and not just a bad dependancy.
|
||||
if ( %previousErrors > %failedDatablocks )
|
||||
recursiveLoadDatablockFiles( %reloadDatablockFiles, %failedDatablocks );
|
||||
|
||||
else
|
||||
{
|
||||
// Since we must have real syntax errors do one
|
||||
// last normal exec to output error messages.
|
||||
loadDatablockFiles( %reloadDatablockFiles, false );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Cleanup the empty reload list.
|
||||
%reloadDatablockFiles.delete();
|
||||
}
|
||||
|
||||
function getPrefpath()
|
||||
{
|
||||
%temp = getUserHomeDirectory();
|
||||
echo(%temp);
|
||||
if(!isDirectory(%temp))
|
||||
{
|
||||
%temp = getUserDataDirectory();
|
||||
echo(%temp);
|
||||
if(!isDirectory(%temp))
|
||||
{
|
||||
$prefpath = "data";
|
||||
}
|
||||
else
|
||||
{
|
||||
//put it in appdata/roaming
|
||||
$prefpath = %temp @ "/" @ $appName @ "/preferences";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//put it in user/documents
|
||||
$prefPath = %temp @ "/" @ $appName @ "/preferences";
|
||||
}
|
||||
return $prefPath;
|
||||
}
|
||||
|
||||
function updateTSShapeLoadProgress(%progress, %msg)
|
||||
{
|
||||
// Check if the loading GUI is visible and use that instead of the
|
||||
// separate import progress GUI if possible
|
||||
if ( isObject(LoadingGui) && LoadingGui.isAwake() )
|
||||
{
|
||||
// Save/Restore load progress at the start/end of the import process
|
||||
if ( %progress == 0 )
|
||||
{
|
||||
ColladaImportProgress.savedProgress = LoadingProgress.getValue();
|
||||
ColladaImportProgress.savedText = LoadingProgressTxt.getValue();
|
||||
|
||||
ColladaImportProgress.msgPrefix = "Importing " @ %msg;
|
||||
%msg = "Reading file into memory...";
|
||||
}
|
||||
else if ( %progress == 1.0 )
|
||||
{
|
||||
LoadingProgress.setValue( ColladaImportProgress.savedProgress );
|
||||
LoadingProgressTxt.setValue( ColladaImportProgress.savedText );
|
||||
}
|
||||
|
||||
%msg = ColladaImportProgress.msgPrefix @ ": " @ %msg;
|
||||
|
||||
%progressCtrl = LoadingProgress;
|
||||
%textCtrl = LoadingProgressTxt;
|
||||
}
|
||||
else
|
||||
{
|
||||
//it's probably the editors using it
|
||||
if(isFunction("updateToolTSShapeLoadProgress"))
|
||||
{
|
||||
updateToolTSShapeLoadProgress(%progress, %msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Update progress indicators
|
||||
if (%progress == 0)
|
||||
{
|
||||
%progressCtrl.setValue(0.001);
|
||||
%textCtrl.setText(%msg);
|
||||
}
|
||||
else if (%progress != 1.0)
|
||||
{
|
||||
%progressCtrl.setValue(%progress);
|
||||
%textCtrl.setText(%msg);
|
||||
}
|
||||
|
||||
Canvas.repaint(33);
|
||||
}
|
||||
|
||||
/// A helper function which will return the ghosted client object
|
||||
/// from a server object when connected to a local server.
|
||||
function serverToClientObject( %serverObject )
|
||||
{
|
||||
assert( isObject( LocalClientConnection ), "serverToClientObject() - No local client connection found!" );
|
||||
assert( isObject( ServerConnection ), "serverToClientObject() - No server connection found!" );
|
||||
|
||||
%ghostId = LocalClientConnection.getGhostId( %serverObject );
|
||||
if ( %ghostId == -1 )
|
||||
return 0;
|
||||
|
||||
return ServerConnection.resolveGhostID( %ghostId );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Debug commands
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function netSimulateLag( %msDelay, %packetLossPercent )
|
||||
{
|
||||
if ( %packetLossPercent $= "" )
|
||||
%packetLossPercent = 0;
|
||||
|
||||
commandToServer( 'NetSimulateLag', %msDelay, %packetLossPercent );
|
||||
}
|
||||
|
||||
//Various client functions
|
||||
|
||||
function validateDatablockName(%name)
|
||||
{
|
||||
// remove whitespaces at beginning and end
|
||||
%name = trim( %name );
|
||||
|
||||
// remove numbers at the beginning
|
||||
%numbers = "0123456789";
|
||||
while( strlen(%name) > 0 )
|
||||
{
|
||||
// the first character
|
||||
%firstChar = getSubStr( %name, 0, 1 );
|
||||
// if the character is a number remove it
|
||||
if( strpos( %numbers, %firstChar ) != -1 )
|
||||
{
|
||||
%name = getSubStr( %name, 1, strlen(%name) -1 );
|
||||
%name = ltrim( %name );
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// replace whitespaces with underscores
|
||||
%name = strreplace( %name, " ", "_" );
|
||||
|
||||
// remove any other invalid characters
|
||||
%invalidCharacters = "-+*/%$&§=()[].?\"#,;!~<>|°^{}";
|
||||
%name = stripChars( %name, %invalidCharacters );
|
||||
|
||||
if( %name $= "" )
|
||||
%name = "Unnamed";
|
||||
|
||||
return %name;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Finds location of %word in %text, starting at %start. Works just like strPos
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
function wordPos(%text, %word, %start)
|
||||
{
|
||||
if (%start $= "") %start = 0;
|
||||
|
||||
if (strpos(%text, %word, 0) == -1) return -1;
|
||||
%count = getWordCount(%text);
|
||||
if (%start >= %count) return -1;
|
||||
for (%i = %start; %i < %count; %i++)
|
||||
{
|
||||
if (getWord( %text, %i) $= %word) return %i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Finds location of %field in %text, starting at %start. Works just like strPos
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
function fieldPos(%text, %field, %start)
|
||||
{
|
||||
if (%start $= "") %start = 0;
|
||||
|
||||
if (strpos(%text, %field, 0) == -1) return -1;
|
||||
%count = getFieldCount(%text);
|
||||
if (%start >= %count) return -1;
|
||||
for (%i = %start; %i < %count; %i++)
|
||||
{
|
||||
if (getField( %text, %i) $= %field) return %i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// returns the text in a file with "\n" at the end of each line
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
function loadFileText( %file)
|
||||
{
|
||||
%fo = new FileObject();
|
||||
%fo.openForRead(%file);
|
||||
%text = "";
|
||||
while(!%fo.isEOF())
|
||||
{
|
||||
%text = %text @ %fo.readLine();
|
||||
if (!%fo.isEOF()) %text = %text @ "\n";
|
||||
}
|
||||
|
||||
%fo.delete();
|
||||
return %text;
|
||||
}
|
||||
|
||||
function setValueSafe(%dest, %val)
|
||||
{
|
||||
%cmd = %dest.command;
|
||||
%alt = %dest.altCommand;
|
||||
%dest.command = "";
|
||||
%dest.altCommand = "";
|
||||
|
||||
%dest.setValue(%val);
|
||||
|
||||
%dest.command = %cmd;
|
||||
%dest.altCommand = %alt;
|
||||
}
|
||||
|
||||
function shareValueSafe(%source, %dest)
|
||||
{
|
||||
setValueSafe(%dest, %source.getValue());
|
||||
}
|
||||
|
||||
function shareValueSafeDelay(%source, %dest, %delayMs)
|
||||
{
|
||||
schedule(%delayMs, 0, shareValueSafe, %source, %dest);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// An Aggregate Control is a plain GuiControl that contains other controls,
|
||||
// which all share a single job or represent a single value.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// AggregateControl.setValue( ) propagates the value to any control that has an
|
||||
// internal name.
|
||||
function AggregateControl::setValue(%this, %val, %child)
|
||||
{
|
||||
for(%i = 0; %i < %this.getCount(); %i++)
|
||||
{
|
||||
%obj = %this.getObject(%i);
|
||||
if( %obj == %child )
|
||||
continue;
|
||||
|
||||
if(%obj.internalName !$= "")
|
||||
setValueSafe(%obj, %val);
|
||||
}
|
||||
}
|
||||
|
||||
// AggregateControl.getValue() uses the value of the first control that has an
|
||||
// internal name, if it has not cached a value via .setValue
|
||||
function AggregateControl::getValue(%this)
|
||||
{
|
||||
for(%i = 0; %i < %this.getCount(); %i++)
|
||||
{
|
||||
%obj = %this.getObject(%i);
|
||||
if(%obj.internalName !$= "")
|
||||
{
|
||||
//error("obj = " @ %obj.getId() @ ", " @ %obj.getName() @ ", " @ %obj.internalName );
|
||||
//error(" value = " @ %obj.getValue());
|
||||
return %obj.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AggregateControl.updateFromChild( ) is called by child controls to propagate
|
||||
// a new value, and to trigger the onAction() callback.
|
||||
function AggregateControl::updateFromChild(%this, %child)
|
||||
{
|
||||
%val = %child.getValue();
|
||||
if(%val == mCeil(%val)){
|
||||
%val = mCeil(%val);
|
||||
}else{
|
||||
if ( %val <= -100){
|
||||
%val = mCeil(%val);
|
||||
}else if ( %val <= -10){
|
||||
%val = mFloatLength(%val, 1);
|
||||
}else if ( %val < 0){
|
||||
%val = mFloatLength(%val, 2);
|
||||
}else if ( %val >= 1000){
|
||||
%val = mCeil(%val);
|
||||
}else if ( %val >= 100){
|
||||
%val = mFloatLength(%val, 1);
|
||||
}else if ( %val >= 10){
|
||||
%val = mFloatLength(%val, 2);
|
||||
}else if ( %val > 0){
|
||||
%val = mFloatLength(%val, 3);
|
||||
}
|
||||
}
|
||||
%this.setValue(%val, %child);
|
||||
%this.onAction();
|
||||
}
|
||||
|
||||
// default onAction stub, here only to prevent console spam warnings.
|
||||
function AggregateControl::onAction(%this)
|
||||
{
|
||||
}
|
||||
|
||||
// call a method on all children that have an internalName and that implement the method.
|
||||
function AggregateControl::callMethod(%this, %method, %args)
|
||||
{
|
||||
for(%i = 0; %i < %this.getCount(); %i++)
|
||||
{
|
||||
%obj = %this.getObject(%i);
|
||||
if(%obj.internalName !$= "" && %obj.isMethod(%method))
|
||||
eval(%obj @ "." @ %method @ "( " @ %args @ " );");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// A function used in order to easily parse the MissionGroup for classes . I'm pretty
|
||||
// sure at this point the function can be easily modified to search the any group as well.
|
||||
function parseMissionGroup( %className, %childGroup )
|
||||
{
|
||||
if( getWordCount( %childGroup ) == 0)
|
||||
%currentGroup = "MissionGroup";
|
||||
else
|
||||
%currentGroup = %childGroup;
|
||||
|
||||
for(%i = 0; %i < (%currentGroup).getCount(); %i++)
|
||||
{
|
||||
if( (%currentGroup).getObject(%i).getClassName() $= %className )
|
||||
return true;
|
||||
|
||||
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
|
||||
{
|
||||
if( parseMissionGroup( %className, (%currentGroup).getObject(%i).getId() ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A variation of the above used to grab ids from the mission group based on classnames
|
||||
function parseMissionGroupForIds( %className, %childGroup )
|
||||
{
|
||||
if( getWordCount( %childGroup ) == 0)
|
||||
%currentGroup = "MissionGroup";
|
||||
else
|
||||
%currentGroup = %childGroup;
|
||||
|
||||
for(%i = 0; %i < (%currentGroup).getCount(); %i++)
|
||||
{
|
||||
if( (%currentGroup).getObject(%i).getClassName() $= %className )
|
||||
%classIds = %classIds @ (%currentGroup).getObject(%i).getId() @ " ";
|
||||
|
||||
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
|
||||
%classIds = %classIds @ parseMissionGroupForIds( %className, (%currentGroup).getObject(%i).getId());
|
||||
}
|
||||
return trim( %classIds );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Altered Version of TGB's QuickEditDropDownTextEditCtrl
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function QuickEditDropDownTextEditCtrl::onRenameItem( %this )
|
||||
{
|
||||
}
|
||||
|
||||
function QuickEditDropDownTextEditCtrl::updateFromChild( %this, %ctrl )
|
||||
{
|
||||
if( %ctrl.internalName $= "PopUpMenu" )
|
||||
{
|
||||
%this->TextEdit.setText( %ctrl.getText() );
|
||||
}
|
||||
else if ( %ctrl.internalName $= "TextEdit" )
|
||||
{
|
||||
%popup = %this->PopupMenu;
|
||||
%popup.changeTextById( %popup.getSelected(), %ctrl.getText() );
|
||||
%this.onRenameItem();
|
||||
}
|
||||
}
|
||||
BIN
Templates/BaseGame/game/core/images/button.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Templates/BaseGame/game/core/images/checkbox.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
Templates/BaseGame/game/core/images/group-border.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Templates/BaseGame/game/core/images/inactive-overlay.png
Normal file
|
After Width: | Height: | Size: 131 B |
BIN
Templates/BaseGame/game/core/images/loadingbar.png
Normal file
|
After Width: | Height: | Size: 635 B |
39
Templates/BaseGame/game/core/images/materials.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton Material( BlankWhite )
|
||||
{
|
||||
diffuseMap[0] = "data/art/white";
|
||||
mapTo = "white";
|
||||
materialTag0 = "Miscellaneous";
|
||||
};
|
||||
|
||||
singleton Material( Empty )
|
||||
{
|
||||
};
|
||||
|
||||
singleton Material(WarningMaterial) {
|
||||
detailMap[0] = "missingTexture";
|
||||
diffuseColor[0] = "25 16 0";
|
||||
emissive[0] = false;
|
||||
translucent = false;
|
||||
};
|
||||
BIN
Templates/BaseGame/game/core/images/missingTexture.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
Templates/BaseGame/game/core/images/scrollBar.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
Templates/BaseGame/game/core/images/textEdit.png
Normal file
|
After Width: | Height: | Size: 250 B |
BIN
Templates/BaseGame/game/core/images/thumbHighlightButton.png
Normal file
|
After Width: | Height: | Size: 778 B |
BIN
Templates/BaseGame/game/core/images/unavailable.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
Templates/BaseGame/game/core/images/warnMat.dds
Normal file
BIN
Templates/BaseGame/game/core/images/window.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
74
Templates/BaseGame/game/core/lighting.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function initLightingSystems(%manager)
|
||||
{
|
||||
echo( "\nInitializing Lighting Systems" );
|
||||
|
||||
// First exec the scripts for the different light managers
|
||||
// in the lighting folder.
|
||||
%pattern = "./lighting/*/init.cs";
|
||||
%file = findFirstFile( %pattern );
|
||||
if ( %file $= "" )
|
||||
{
|
||||
// Try for DSOs next.
|
||||
%pattern = "./lighting/*/init.cs.dso";
|
||||
%file = findFirstFile( %pattern );
|
||||
}
|
||||
|
||||
while( %file !$= "" )
|
||||
{
|
||||
exec( %file );
|
||||
%file = findNextFile( %pattern );
|
||||
}
|
||||
|
||||
// Try the perfered one first.
|
||||
%success = setLightManager(%manager);
|
||||
|
||||
// Did we completely fail to initialize a light manager?
|
||||
if (!%success)
|
||||
{
|
||||
// If we completely failed to initialize a light
|
||||
// manager then the 3d scene cannot be rendered.
|
||||
quitWithErrorMessage( "Failed to set a light manager!" );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function onLightManagerActivate( %lmName )
|
||||
{
|
||||
// Call activation callbacks.
|
||||
%activateNewFn = "onActivate" @ getWord( %lmName, 0 ) @ "LM";
|
||||
if( isFunction( %activateNewFn ) )
|
||||
eval( %activateNewFn @ "();" );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
function onLightManagerDeactivate( %lmName )
|
||||
{
|
||||
// Call deactivation callback.
|
||||
%deactivateOldFn = "onDeactivate" @ getWord( %lmName, 0 ) @ "LM";
|
||||
if( isFunction( %deactivateOldFn ) )
|
||||
eval( %deactivateOldFn @ "();" );
|
||||
}
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
singleton ShaderData( ClearGBufferShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/deferredClearGBufferP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/deferredClearGBufferP.glsl";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( DeferredColorShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/lighting/advanced/deferredClearGBufferV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/deferredColorShaderP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/deferredColorShaderP.glsl";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
// Primary Deferred Shader
|
||||
new GFXStateBlockData( AL_DeferredShadingState : PFX_DefaultStateBlock )
|
||||
{
|
||||
cullMode = GFXCullNone;
|
||||
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendSrcAlpha;
|
||||
blendDest = GFXBlendInvSrcAlpha;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerWrapLinear;
|
||||
samplerStates[1] = SamplerWrapLinear;
|
||||
samplerStates[2] = SamplerWrapLinear;
|
||||
samplerStates[3] = SamplerWrapLinear;
|
||||
};
|
||||
|
||||
new ShaderData( AL_DeferredShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/deferredShadingP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/deferredShadingP.glsl";
|
||||
|
||||
samplerNames[0] = "colorBufferTex";
|
||||
samplerNames[1] = "lightPrePassTex";
|
||||
samplerNames[2] = "matInfoTex";
|
||||
samplerNames[3] = "prepassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_DeferredShading )
|
||||
{
|
||||
renderTime = "PFXAfterBin";
|
||||
renderBin = "SkyBin";
|
||||
shader = AL_DeferredShader;
|
||||
stateBlock = AL_DeferredShadingState;
|
||||
texture[0] = "#color";
|
||||
texture[1] = "#lightinfo";
|
||||
texture[2] = "#matinfo";
|
||||
texture[3] = "#prepass";
|
||||
|
||||
target = "$backBuffer";
|
||||
renderPriority = 10000;
|
||||
allowReflectPass = true;
|
||||
};
|
||||
|
||||
// Debug Shaders.
|
||||
new ShaderData( AL_ColorBufferShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgColorBufferP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgColorBufferP.glsl";
|
||||
|
||||
samplerNames[0] = "colorBufferTex";
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_ColorBufferVisualize )
|
||||
{
|
||||
shader = AL_ColorBufferShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#color";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
/// Toggles the visualization of the AL lighting specular power buffer.
|
||||
function toggleColorBufferViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_ColorBufferShaderVar = AL_ColorBufferVisualize.isEnabled() ? false : true;
|
||||
AL_ColorBufferVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
{
|
||||
AL_DeferredShading.disable();
|
||||
AL_ColorBufferVisualize.enable();
|
||||
}
|
||||
else if ( !%enable )
|
||||
{
|
||||
AL_ColorBufferVisualize.disable();
|
||||
AL_DeferredShading.enable();
|
||||
}
|
||||
}
|
||||
|
||||
new ShaderData( AL_SpecMapShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgSpecMapVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgSpecMapVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "matinfoTex";
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_SpecMapVisualize )
|
||||
{
|
||||
shader = AL_SpecMapShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#matinfo";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
/// Toggles the visualization of the AL lighting specular power buffer.
|
||||
function toggleSpecMapViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_SpecMapShaderVar = AL_SpecMapVisualize.isEnabled() ? false : true;
|
||||
AL_SpecMapVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_SpecMapVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_SpecMapVisualize.disable();
|
||||
}
|
||||
BIN
Templates/BaseGame/game/core/lighting/advanced/depthviz.png
Normal file
|
After Width: | Height: | Size: 551 B |
80
Templates/BaseGame/game/core/lighting/advanced/init.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Default Prefs
|
||||
|
||||
/*
|
||||
$pref::LightManager::sgAtlasMaxDynamicLights = "16";
|
||||
$pref::LightManager::sgDynamicShadowDetailSize = "0";
|
||||
$pref::LightManager::sgDynamicShadowQuality = "0";
|
||||
$pref::LightManager::sgLightingProfileAllowShadows = "1";
|
||||
$pref::LightManager::sgLightingProfileQuality = "0";
|
||||
$pref::LightManager::sgMaxBestLights = "10";
|
||||
$pref::LightManager::sgMultipleDynamicShadows = "1";
|
||||
$pref::LightManager::sgShowCacheStats = "0";
|
||||
$pref::LightManager::sgUseBloom = "";
|
||||
$pref::LightManager::sgUseDRLHighDynamicRange = "0";
|
||||
$pref::LightManager::sgUseDynamicRangeLighting = "0";
|
||||
$pref::LightManager::sgUseDynamicShadows = "1";
|
||||
$pref::LightManager::sgUseToneMapping = "";
|
||||
*/
|
||||
|
||||
exec( "./shaders.cs" );
|
||||
exec( "./lightViz.cs" );
|
||||
exec( "./shadowViz.cs" );
|
||||
exec( "./shadowViz.gui" );
|
||||
exec( "./deferredShading.cs" );
|
||||
|
||||
function onActivateAdvancedLM()
|
||||
{
|
||||
// Don't allow the offscreen target on OSX.
|
||||
if ( $platform $= "macos" )
|
||||
return;
|
||||
|
||||
// On the Xbox360 we know what will be enabled so don't do any trickery to
|
||||
// disable MSAA
|
||||
if ( $platform $= "xenon" )
|
||||
return;
|
||||
|
||||
// Enable the offscreen target so that AL will work
|
||||
// with MSAA back buffers and for HDR rendering.
|
||||
AL_FormatToken.enable();
|
||||
|
||||
// Activate Deferred Shading
|
||||
AL_DeferredShading.enable();
|
||||
}
|
||||
|
||||
function onDeactivateAdvancedLM()
|
||||
{
|
||||
// Disable the offscreen render target.
|
||||
AL_FormatToken.disable();
|
||||
|
||||
// Deactivate Deferred Shading
|
||||
AL_DeferredShading.disable();
|
||||
}
|
||||
|
||||
function setAdvancedLighting()
|
||||
{
|
||||
setLightManager( "Advanced Lighting" );
|
||||
}
|
||||
|
||||
294
Templates/BaseGame/game/core/lighting/advanced/lightViz.cs
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
new GFXStateBlockData( AL_DepthVisualizeState )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint; // depth
|
||||
samplerStates[1] = SamplerClampLinear; // viz color lookup
|
||||
};
|
||||
|
||||
new GFXStateBlockData( AL_DefaultVisualizeState )
|
||||
{
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendSrcAlpha;
|
||||
blendDest = GFXBlendInvSrcAlpha;
|
||||
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint; // #prepass
|
||||
samplerStates[1] = SamplerClampLinear; // depthviz
|
||||
};
|
||||
|
||||
new ShaderData( AL_DepthVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgDepthVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgDepthVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "prepassTex";
|
||||
samplerNames[1] = "depthViz";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_DepthVisualize )
|
||||
{
|
||||
shader = AL_DepthVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#prepass";
|
||||
texture[1] = "core/lighting/advanced/depthviz";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
function AL_DepthVisualize::onEnabled( %this )
|
||||
{
|
||||
AL_NormalsVisualize.disable();
|
||||
AL_LightColorVisualize.disable();
|
||||
AL_LightSpecularVisualize.disable();
|
||||
$AL_NormalsVisualizeVar = false;
|
||||
$AL_LightColorVisualizeVar = false;
|
||||
$AL_LightSpecularVisualizeVar = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
new ShaderData( AL_GlowVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgGlowVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgGlowVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "glowBuffer";
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_GlowVisualize )
|
||||
{
|
||||
shader = AL_GlowVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#glowbuffer";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
new ShaderData( AL_NormalsVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgNormalVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgNormalVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "prepassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_NormalsVisualize )
|
||||
{
|
||||
shader = AL_NormalsVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#prepass";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
function AL_NormalsVisualize::onEnabled( %this )
|
||||
{
|
||||
AL_DepthVisualize.disable();
|
||||
AL_LightColorVisualize.disable();
|
||||
AL_LightSpecularVisualize.disable();
|
||||
$AL_DepthVisualizeVar = false;
|
||||
$AL_LightColorVisualizeVar = false;
|
||||
$AL_LightSpecularVisualizeVar = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
new ShaderData( AL_LightColorVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgLightColorVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgLightColorVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "lightPrePassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_LightColorVisualize )
|
||||
{
|
||||
shader = AL_LightColorVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#lightinfo";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
function AL_LightColorVisualize::onEnabled( %this )
|
||||
{
|
||||
AL_NormalsVisualize.disable();
|
||||
AL_DepthVisualize.disable();
|
||||
AL_LightSpecularVisualize.disable();
|
||||
$AL_NormalsVisualizeVar = false;
|
||||
$AL_DepthVisualizeVar = false;
|
||||
$AL_LightSpecularVisualizeVar = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
new ShaderData( AL_LightSpecularVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgLightSpecularVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgLightSpecularVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "lightPrePassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_LightSpecularVisualize )
|
||||
{
|
||||
shader = AL_LightSpecularVisualizeShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#lightinfo";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
function AL_LightSpecularVisualize::onEnabled( %this )
|
||||
{
|
||||
AL_NormalsVisualize.disable();
|
||||
AL_DepthVisualize.disable();
|
||||
AL_LightColorVisualize.disable();
|
||||
$AL_NormalsVisualizeVar = false;
|
||||
$AL_DepthVisualizeVar = false;
|
||||
$AL_LightColorVisualizeVar = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL depth buffer.
|
||||
function toggleDepthViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_DepthVisualizeVar = AL_DepthVisualize.isEnabled() ? false : true;
|
||||
AL_DepthVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_DepthVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_DepthVisualize.disable();
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL depth buffer.
|
||||
function toggleGlowViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_GlowVisualizeVar = AL_GlowVisualize.isEnabled() ? false : true;
|
||||
AL_GlowVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_GlowVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_GlowVisualize.disable();
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL normals buffer.
|
||||
function toggleNormalsViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_NormalsVisualizeVar = AL_NormalsVisualize.isEnabled() ? false : true;
|
||||
AL_NormalsVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_NormalsVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_NormalsVisualize.disable();
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL lighting color buffer.
|
||||
function toggleLightColorViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_LightColorVisualizeVar = AL_LightColorVisualize.isEnabled() ? false : true;
|
||||
AL_LightColorVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_LightColorVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_LightColorVisualize.disable();
|
||||
}
|
||||
|
||||
/// Toggles the visualization of the AL lighting specular power buffer.
|
||||
function toggleLightSpecularViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_LightSpecularVisualizeVar = AL_LightSpecularVisualize.isEnabled() ? false : true;
|
||||
AL_LightSpecularVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_LightSpecularVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_LightSpecularVisualize.disable();
|
||||
}
|
||||
|
||||
function toggleBackbufferViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_BackbufferVisualizeVar = AL_DeferredShading.isEnabled() ? true : false;
|
||||
AL_DeferredShading.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_DeferredShading.disable();
|
||||
else if ( !%enable )
|
||||
AL_DeferredShading.enable();
|
||||
}
|
||||
276
Templates/BaseGame/game/core/lighting/advanced/shaders.cs
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Vector Light State
|
||||
new GFXStateBlockData( AL_VectorLightState )
|
||||
{
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendOne;
|
||||
blendDest = GFXBlendOne;
|
||||
blendOp = GFXBlendOpAdd;
|
||||
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint; // G-buffer
|
||||
mSamplerNames[0] = "prePassBuffer";
|
||||
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
|
||||
mSamplerNames[1] = "shadowMap";
|
||||
samplerStates[2] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
|
||||
mSamplerNames[2] = "dynamicShadowMap";
|
||||
samplerStates[3] = SamplerClampLinear; // SSAO Mask
|
||||
mSamplerNames[3] = "ssaoMask";
|
||||
samplerStates[4] = SamplerWrapPoint; // Random Direction Map
|
||||
|
||||
cullDefined = true;
|
||||
cullMode = GFXCullNone;
|
||||
|
||||
stencilDefined = true;
|
||||
stencilEnable = true;
|
||||
stencilFailOp = GFXStencilOpKeep;
|
||||
stencilZFailOp = GFXStencilOpKeep;
|
||||
stencilPassOp = GFXStencilOpKeep;
|
||||
stencilFunc = GFXCmpLess;
|
||||
stencilRef = 0;
|
||||
};
|
||||
|
||||
// Vector Light Material
|
||||
new ShaderData( AL_VectorLightShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/farFrustumQuadV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/vectorLightP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/farFrustumQuadV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/vectorLightP.glsl";
|
||||
|
||||
samplerNames[0] = "$prePassBuffer";
|
||||
samplerNames[1] = "$shadowMap";
|
||||
samplerNames[2] = "$dynamicShadowMap";
|
||||
samplerNames[3] = "$ssaoMask";
|
||||
samplerNames[4] = "$gTapRotationTex";
|
||||
samplerNames[5] = "$lightBuffer";
|
||||
samplerNames[6] = "$colorBuffer";
|
||||
samplerNames[7] = "$matInfoBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
new CustomMaterial( AL_VectorLightMaterial )
|
||||
{
|
||||
shader = AL_VectorLightShader;
|
||||
stateBlock = AL_VectorLightState;
|
||||
|
||||
sampler["prePassBuffer"] = "#prepass";
|
||||
sampler["shadowMap"] = "$dynamiclight";
|
||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||
sampler["ssaoMask"] = "#ssaoMask";
|
||||
sampler["lightBuffer"] = "#lightinfo";
|
||||
sampler["colorBuffer"] = "#color";
|
||||
sampler["matInfoBuffer"] = "#matinfo";
|
||||
|
||||
target = "lightinfo";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Convex-geometry light states
|
||||
new GFXStateBlockData( AL_ConvexLightState )
|
||||
{
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendOne;
|
||||
blendDest = GFXBlendOne;
|
||||
blendOp = GFXBlendOpAdd;
|
||||
|
||||
zDefined = true;
|
||||
zEnable = true;
|
||||
zWriteEnable = false;
|
||||
zFunc = GFXCmpGreaterEqual;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint; // G-buffer
|
||||
mSamplerNames[0] = "prePassBuffer";
|
||||
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not use linear, these are perspective projections)
|
||||
mSamplerNames[1] = "shadowMap";
|
||||
samplerStates[2] = SamplerClampPoint; // Shadow Map (Do not use linear, these are perspective projections)
|
||||
mSamplerNames[2] = "dynamicShadowMap";
|
||||
samplerStates[3] = SamplerClampLinear; // Cookie Map
|
||||
samplerStates[4] = SamplerWrapPoint; // Random Direction Map
|
||||
|
||||
cullDefined = true;
|
||||
cullMode = GFXCullCW;
|
||||
|
||||
stencilDefined = true;
|
||||
stencilEnable = true;
|
||||
stencilFailOp = GFXStencilOpKeep;
|
||||
stencilZFailOp = GFXStencilOpKeep;
|
||||
stencilPassOp = GFXStencilOpKeep;
|
||||
stencilFunc = GFXCmpLess;
|
||||
stencilRef = 0;
|
||||
};
|
||||
|
||||
// Point Light Material
|
||||
new ShaderData( AL_PointLightShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/convexGeometryV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/pointLightP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/pointLightP.glsl";
|
||||
|
||||
samplerNames[0] = "$prePassBuffer";
|
||||
samplerNames[1] = "$shadowMap";
|
||||
samplerNames[2] = "$dynamicShadowMap";
|
||||
samplerNames[3] = "$cookieMap";
|
||||
samplerNames[4] = "$gTapRotationTex";
|
||||
samplerNames[5] = "$lightBuffer";
|
||||
samplerNames[6] = "$colorBuffer";
|
||||
samplerNames[7] = "$matInfoBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
new CustomMaterial( AL_PointLightMaterial )
|
||||
{
|
||||
shader = AL_PointLightShader;
|
||||
stateBlock = AL_ConvexLightState;
|
||||
|
||||
sampler["prePassBuffer"] = "#prepass";
|
||||
sampler["shadowMap"] = "$dynamiclight";
|
||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||
sampler["cookieMap"] = "$dynamiclightmask";
|
||||
sampler["lightBuffer"] = "#lightinfo";
|
||||
sampler["colorBuffer"] = "#color";
|
||||
sampler["matInfoBuffer"] = "#matinfo";
|
||||
|
||||
target = "lightinfo";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
// Spot Light Material
|
||||
new ShaderData( AL_SpotLightShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/convexGeometryV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/spotLightP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/spotLightP.glsl";
|
||||
|
||||
samplerNames[0] = "$prePassBuffer";
|
||||
samplerNames[1] = "$shadowMap";
|
||||
samplerNames[2] = "$dynamicShadowMap";
|
||||
samplerNames[3] = "$cookieMap";
|
||||
samplerNames[4] = "$gTapRotationTex";
|
||||
samplerNames[5] = "$lightBuffer";
|
||||
samplerNames[6] = "$colorBuffer";
|
||||
samplerNames[7] = "$matInfoBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
new CustomMaterial( AL_SpotLightMaterial )
|
||||
{
|
||||
shader = AL_SpotLightShader;
|
||||
stateBlock = AL_ConvexLightState;
|
||||
|
||||
sampler["prePassBuffer"] = "#prepass";
|
||||
sampler["shadowMap"] = "$dynamiclight";
|
||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||
sampler["cookieMap"] = "$dynamiclightmask";
|
||||
sampler["lightBuffer"] = "#lightinfo";
|
||||
sampler["colorBuffer"] = "#color";
|
||||
sampler["matInfoBuffer"] = "#matinfo";
|
||||
|
||||
target = "lightinfo";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
/// This material is used for generating prepass
|
||||
/// materials for objects that do not have materials.
|
||||
new Material( AL_DefaultPrePassMaterial )
|
||||
{
|
||||
// We need something in the first pass else it
|
||||
// won't create a proper material instance.
|
||||
//
|
||||
// We use color here because some objects may not
|
||||
// have texture coords in their vertex format...
|
||||
// for example like terrain.
|
||||
//
|
||||
diffuseColor[0] = "1 1 1 1";
|
||||
};
|
||||
|
||||
/// This material is used for generating shadow
|
||||
/// materials for objects that do not have materials.
|
||||
new Material( AL_DefaultShadowMaterial )
|
||||
{
|
||||
// We need something in the first pass else it
|
||||
// won't create a proper material instance.
|
||||
//
|
||||
// We use color here because some objects may not
|
||||
// have texture coords in their vertex format...
|
||||
// for example like terrain.
|
||||
//
|
||||
diffuseColor[0] = "1 1 1 1";
|
||||
|
||||
// This is here mostly for terrain which uses
|
||||
// this material to create its shadow material.
|
||||
//
|
||||
// At sunset/sunrise the sun is looking thru
|
||||
// backsides of the terrain which often are not
|
||||
// closed. By changing the material to be double
|
||||
// sided we avoid holes in the shadowed geometry.
|
||||
//
|
||||
doubleSided = true;
|
||||
};
|
||||
|
||||
// Particle System Point Light Material
|
||||
new ShaderData( AL_ParticlePointLightShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/particlePointLightV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/particlePointLightP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/convexGeometryV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/pointLightP.glsl";
|
||||
|
||||
samplerNames[0] = "$prePassBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
new CustomMaterial( AL_ParticlePointLightMaterial )
|
||||
{
|
||||
shader = AL_ParticlePointLightShader;
|
||||
stateBlock = AL_ConvexLightState;
|
||||
|
||||
sampler["prePassBuffer"] = "#prepass";
|
||||
target = "lightinfo";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
116
Templates/BaseGame/game/core/lighting/advanced/shadowViz.cs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
new ShaderData( AL_ShadowVisualizeShader )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/guiMaterialV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/advanced/dbgShadowVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/gl/guiMaterialV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/advanced/gl/dbgShadowVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "$shadowMap";
|
||||
samplerNames[1] = "$depthViz";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
new CustomMaterial( AL_ShadowVisualizeMaterial )
|
||||
{
|
||||
shader = AL_ShadowVisualizeShader;
|
||||
stateBlock = AL_DepthVisualizeState;
|
||||
|
||||
sampler["shadowMap"] = "#AL_ShadowVizTexture";
|
||||
sampler["depthViz"] = "depthviz";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton GuiControlProfile( AL_ShadowLabelTextProfile )
|
||||
{
|
||||
fontColor = "0 0 0";
|
||||
autoSizeWidth = true;
|
||||
autoSizeHeight = true;
|
||||
justify = "left";
|
||||
fontSize = 14;
|
||||
};
|
||||
|
||||
/// Toggles the visualization of the pre-pass lighting buffer.
|
||||
function toggleShadowViz()
|
||||
{
|
||||
if ( AL_ShadowVizOverlayCtrl.isAwake() )
|
||||
{
|
||||
setShadowVizLight( 0 );
|
||||
Canvas.popDialog( AL_ShadowVizOverlayCtrl );
|
||||
}
|
||||
else
|
||||
{
|
||||
Canvas.pushDialog( AL_ShadowVizOverlayCtrl, 100 );
|
||||
_setShadowVizLight( EWorldEditor.getSelectedObject( 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
/// Called from the WorldEditor when an object is selected.
|
||||
function _setShadowVizLight( %light, %force )
|
||||
{
|
||||
if ( !AL_ShadowVizOverlayCtrl.isAwake() )
|
||||
return;
|
||||
|
||||
if ( AL_ShadowVizOverlayCtrl.isLocked() && !%force )
|
||||
return;
|
||||
|
||||
// Resolve the object to the client side.
|
||||
if ( isObject( %light ) )
|
||||
{
|
||||
%clientLight = serverToClientObject( %light );
|
||||
%sizeAndAspect = setShadowVizLight( %clientLight );
|
||||
}
|
||||
|
||||
AL_ShadowVizOverlayCtrl-->MatCtrl.setMaterial( "AL_ShadowVisualizeMaterial" );
|
||||
|
||||
%text = "ShadowViz";
|
||||
if ( isObject( %light ) )
|
||||
%text = %text @ " : " @ getWord( %sizeAndAspect, 0 ) @ " x " @ getWord( %sizeAndAspect, 1 );
|
||||
|
||||
AL_ShadowVizOverlayCtrl-->WindowCtrl.text = %text;
|
||||
}
|
||||
|
||||
/// For convenience, push the viz dialog and set the light manually from the console.
|
||||
function showShadowVizForLight( %light )
|
||||
{
|
||||
if ( !AL_ShadowVizOverlayCtrl.isAwake() )
|
||||
Canvas.pushDialog( AL_ShadowVizOverlayCtrl, 100 );
|
||||
_setShadowVizLight( %light, true );
|
||||
}
|
||||
|
||||
// Prevent shadowViz from changing lights in response to editor selection
|
||||
// events until unlock is called. The only way a vis light will change while locked
|
||||
// is if showShadowVizForLight is explicitly called by the user.
|
||||
function lockShadowViz()
|
||||
{
|
||||
AL_ShadowVizOverlayCtrl.islocked = true;
|
||||
}
|
||||
|
||||
function unlockShadowViz()
|
||||
{
|
||||
AL_ShadowVizOverlayCtrl.islocked = false;
|
||||
}
|
||||
78
Templates/BaseGame/game/core/lighting/advanced/shadowViz.gui
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
//---------------------------------------------------------------------------------------------
|
||||
// Torque 3D
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
//--- OBJECT WRITE BEGIN ---
|
||||
%guiContent = new GuiControl(AL_ShadowVizOverlayCtrl) {
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "1";
|
||||
Profile = "GuiModelessDialogProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "0 0";
|
||||
Extent = "1024 768";
|
||||
MinExtent = "8 8";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
noCursor = true;
|
||||
|
||||
new GuiWindowCtrl() {
|
||||
internalName = "WindowCtrl";
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "1";
|
||||
Profile = "GuiWindowProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = "50 50";
|
||||
Extent = "347 209";
|
||||
MinExtent = "150 100";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
Margin = "0 0 0 0";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "1";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "1";
|
||||
AnchorRight = "0";
|
||||
resizeWidth = "1";
|
||||
resizeHeight = "1";
|
||||
canMove = "1";
|
||||
canClose = "1";
|
||||
canMinimize = "0";
|
||||
canMaximize = "1";
|
||||
minSize = "50 50";
|
||||
EdgeSnap = "1";
|
||||
text = "ShadowViz";
|
||||
closeCommand = "toggleShadowViz();";
|
||||
|
||||
new GuiMaterialCtrl() {
|
||||
internalName = "MatCtrl";
|
||||
canSaveDynamicFields = "0";
|
||||
isContainer = "0";
|
||||
Profile = "GuiDefaultProfile";
|
||||
HorizSizing = "width";
|
||||
VertSizing = "height";
|
||||
Position = "3 23";
|
||||
Extent = "341 181";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
Docking = "Client";
|
||||
Margin = "2 2 2 2";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "1";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "1";
|
||||
AnchorRight = "0";
|
||||
materialName = "AL_ShadowVisualizeMaterial";
|
||||
};
|
||||
};
|
||||
};
|
||||
//--- OBJECT WRITE END ---
|
||||
92
Templates/BaseGame/game/core/lighting/basic/init.cs
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
exec( "./shadowFilter.cs" );
|
||||
|
||||
singleton GFXStateBlockData( BL_ProjectedShadowSBData )
|
||||
{
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendDestColor;
|
||||
blendDest = GFXBlendZero;
|
||||
|
||||
zDefined = true;
|
||||
zEnable = true;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
vertexColorEnable = true;
|
||||
};
|
||||
|
||||
singleton ShaderData( BL_ProjectedShadowShaderData )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/projectedShadowV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/projectedShadowP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/gl/projectedShadowV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/gl/projectedShadowP.glsl";
|
||||
|
||||
samplerNames[0] = "inputTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton CustomMaterial( BL_ProjectedShadowMaterial )
|
||||
{
|
||||
sampler["inputTex"] = "$miscbuff";
|
||||
|
||||
shader = BL_ProjectedShadowShaderData;
|
||||
stateBlock = BL_ProjectedShadowSBData;
|
||||
version = 2.0;
|
||||
forwardLit = true;
|
||||
};
|
||||
|
||||
function onActivateBasicLM()
|
||||
{
|
||||
// If HDR is enabled... enable the special format token.
|
||||
if ( $platform !$= "macos" && HDRPostFx.isEnabled )
|
||||
AL_FormatToken.enable();
|
||||
|
||||
// Create render pass for projected shadow.
|
||||
new RenderPassManager( BL_ProjectedShadowRPM );
|
||||
|
||||
// Create the mesh bin and add it to the manager.
|
||||
%meshBin = new RenderMeshMgr();
|
||||
BL_ProjectedShadowRPM.addManager( %meshBin );
|
||||
|
||||
// Add both to the root group so that it doesn't
|
||||
// end up in the MissionCleanup instant group.
|
||||
RootGroup.add( BL_ProjectedShadowRPM );
|
||||
RootGroup.add( %meshBin );
|
||||
}
|
||||
|
||||
function onDeactivateBasicLM()
|
||||
{
|
||||
// Delete the pass manager which also deletes the bin.
|
||||
BL_ProjectedShadowRPM.delete();
|
||||
}
|
||||
|
||||
function setBasicLighting()
|
||||
{
|
||||
setLightManager( "Basic Lighting" );
|
||||
}
|
||||
76
Templates/BaseGame/game/core/lighting/basic/shadowFilter.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
singleton ShaderData( BL_ShadowFilterShaderV )
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/lighting/basic/shadowFilterV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/basic/shadowFilterP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/lighting/basic/gl/shadowFilterV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/basic/gl/shadowFilterP.glsl";
|
||||
|
||||
samplerNames[0] = "$diffuseMap";
|
||||
|
||||
defines = "BLUR_DIR=float2(1.0,0.0)";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( BL_ShadowFilterShaderH : BL_ShadowFilterShaderV )
|
||||
{
|
||||
defines = "BLUR_DIR=float2(0.0,1.0)";
|
||||
};
|
||||
|
||||
|
||||
singleton GFXStateBlockData( BL_ShadowFilterSB : PFX_DefaultStateBlock )
|
||||
{
|
||||
colorWriteDefined=true;
|
||||
colorWriteRed=false;
|
||||
colorWriteGreen=false;
|
||||
colorWriteBlue=false;
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
};
|
||||
|
||||
// NOTE: This is ONLY used in Basic Lighting, and
|
||||
// only directly by the ProjectedShadow. It is not
|
||||
// meant to be manually enabled like other PostEffects.
|
||||
singleton PostEffect( BL_ShadowFilterPostFx )
|
||||
{
|
||||
// Blur vertically
|
||||
shader = BL_ShadowFilterShaderV;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
targetClear = "PFXTargetClear_OnDraw";
|
||||
targetClearColor = "0 0 0 0";
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
|
||||
// Blur horizontal
|
||||
new PostEffect()
|
||||
{
|
||||
shader = BL_ShadowFilterShaderH;
|
||||
stateBlock = PFX_DefaultStateBlock;
|
||||
texture[0] = "$inTex";
|
||||
target = "$outTex";
|
||||
};
|
||||
};
|
||||
32
Templates/BaseGame/game/core/lighting/shadowMaps/init.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
new ShaderData(BlurDepthShader)
|
||||
{
|
||||
DXVertexShaderFile = "data/shaders/common/lighting/shadowMap/boxFilterV.hlsl";
|
||||
DXPixelShaderFile = "data/shaders/common/lighting/shadowMap/boxFilterP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "data/shaders/common/lighting/shadowMap/gl/boxFilterV.glsl";
|
||||
OGLPixelShaderFile = "data/shaders/common/lighting/shadowMap/gl/boxFilterP.glsl";
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
95
Templates/BaseGame/game/core/main.cs
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Initialize core sub system functionality such as audio, the Canvas, PostFX,
|
||||
// rendermanager, light managers, etc.
|
||||
//
|
||||
// Note that not all of these need to be initialized before the client, although
|
||||
// the audio should and the canvas definitely needs to be. I've put things here
|
||||
// to distinguish between the purpose and functionality of the various client
|
||||
// scripts. Game specific script isn't needed until we reach the shell menus
|
||||
// and start a game or connect to a server. We get the various subsystems ready
|
||||
// to go, and then use initClient() to handle the rest of the startup sequence.
|
||||
//
|
||||
// If this is too convoluted we can reduce this complexity after futher testing
|
||||
// to find exactly which subsystems should be readied before kicking things off.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//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 = "data/shaders/common";
|
||||
|
||||
/// This is the path used by ShaderGen to cache procedural
|
||||
/// shaders. If left blank ShaderGen will only cache shaders
|
||||
/// to memory and not to disk.
|
||||
$shaderGen::cachePath = "data/shaders";
|
||||
|
||||
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
|
||||
%prefPath = getPrefpath();
|
||||
if ( isFile( %prefPath @ "/clientPrefs.cs" ) )
|
||||
exec( %prefPath @ "/clientPrefs.cs" );
|
||||
else
|
||||
exec("data/defaults.cs");
|
||||
|
||||
%der = $pref::Video::displayDevice;
|
||||
|
||||
// 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");
|
||||
|
||||
// Seed the random number generator.
|
||||
setRandomSeed();
|
||||
392
Templates/BaseGame/game/core/parseArgs.cs
Normal file
|
|
@ -0,0 +1,392 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Support functions used to manage the directory list
|
||||
function pushFront(%list, %token, %delim)
|
||||
{
|
||||
if (%list !$= "")
|
||||
return %token @ %delim @ %list;
|
||||
return %token;
|
||||
}
|
||||
|
||||
function pushBack(%list, %token, %delim)
|
||||
{
|
||||
if (%list !$= "")
|
||||
return %list @ %delim @ %token;
|
||||
return %token;
|
||||
}
|
||||
|
||||
function popFront(%list, %delim)
|
||||
{
|
||||
return nextToken(%list, unused, %delim);
|
||||
}
|
||||
|
||||
function parseArgs()
|
||||
{
|
||||
for ($i = 1; $i < $Game::argc ; $i++)
|
||||
{
|
||||
$arg = $Game::argv[$i];
|
||||
$nextArg = $Game::argv[$i+1];
|
||||
$hasNextArg = $Game::argc - $i > 1;
|
||||
$logModeSpecified = false;
|
||||
|
||||
// Check for dedicated run
|
||||
/*if( stricmp($arg,"-dedicated") == 0 )
|
||||
{
|
||||
$userDirs = $defaultGame;
|
||||
$dirCount = 1;
|
||||
$isDedicated = true;
|
||||
}*/
|
||||
|
||||
switch$ ($arg)
|
||||
{
|
||||
//--------------------
|
||||
case "-dedicated":
|
||||
$userDirs = $defaultGame;
|
||||
$dirCount = 1;
|
||||
$isDedicated = true;
|
||||
$Server::Dedicated = true;
|
||||
enableWinConsole(true);
|
||||
$argUsed[%i]++;
|
||||
|
||||
//--------------------
|
||||
case "-mission":
|
||||
$argUsed[%i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
$missionArg = $nextArg;
|
||||
$argUsed[%i+1]++;
|
||||
%i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -mission <filename>");
|
||||
|
||||
//--------------------
|
||||
case "-connect":
|
||||
$argUsed[%i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
$JoinGameAddress = $nextArg;
|
||||
$argUsed[%i+1]++;
|
||||
%i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -connect <ip_address>");
|
||||
|
||||
|
||||
//--------------------
|
||||
case "-log":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
// Turn on console logging
|
||||
if ($nextArg != 0)
|
||||
{
|
||||
// Dump existing console to logfile first.
|
||||
$nextArg += 4;
|
||||
}
|
||||
setLogMode($nextArg);
|
||||
$logModeSpecified = true;
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -log <Mode: 0,1,2>");
|
||||
|
||||
//--------------------
|
||||
case "-dir":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
// Append the mod to the end of the current list
|
||||
$userDirs = strreplace($userDirs, $nextArg, "");
|
||||
$userDirs = pushFront($userDirs, $nextArg, ";");
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
$dirCount++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -dir <dir_name>");
|
||||
|
||||
//--------------------
|
||||
// changed the default behavior of this command line arg. It now
|
||||
// defaults to ONLY loading the game, not tools
|
||||
// default auto-run already loads in tools --SRZ 11/29/07
|
||||
case "-game":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
// Set the selected dir --NOTE: we no longer allow tools with this argument
|
||||
/*
|
||||
if( $isDedicated )
|
||||
{
|
||||
$userDirs = $nextArg;
|
||||
$dirCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$userDirs = "tools;" @ $nextArg;
|
||||
$dirCount = 2;
|
||||
}
|
||||
*/
|
||||
$userDirs = $nextArg;
|
||||
$dirCount = 1;
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
error($userDirs);
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -game <game_name>");
|
||||
|
||||
//--------------------
|
||||
case "-console":
|
||||
enableWinConsole(true);
|
||||
$argUsed[$i]++;
|
||||
|
||||
//--------------------
|
||||
case "-jSave":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
echo("Saving event log to journal: " @ $nextArg);
|
||||
saveJournal($nextArg);
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -jSave <journal_name>");
|
||||
|
||||
//--------------------
|
||||
case "-jPlay":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
playJournal($nextArg);
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -jPlay <journal_name>");
|
||||
|
||||
//--------------------
|
||||
case "-jPlayToVideo":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
$VideoCapture::journalName = $nextArg;
|
||||
$VideoCapture::captureFromJournal = true;
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -jPlayToVideo <journal_name>");
|
||||
|
||||
//--------------------
|
||||
case "-vidCapFile":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
$VideoCapture::fileName = $nextArg;
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -vidCapFile <ouput_video_name>");
|
||||
|
||||
//--------------------
|
||||
case "-vidCapFPS":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
$VideoCapture::fps = $nextArg;
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -vidCapFPS <ouput_video_framerate>");
|
||||
|
||||
//--------------------
|
||||
case "-vidCapEncoder":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
$VideoCapture::encoder = $nextArg;
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -vidCapEncoder <ouput_video_encoder>");
|
||||
|
||||
//--------------------
|
||||
case "-vidCapWidth":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
$videoCapture::width = $nextArg;
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -vidCapWidth <ouput_video_width>");
|
||||
|
||||
//--------------------
|
||||
case "-vidCapHeight":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
$videoCapture::height = $nextArg;
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -vidCapHeight <ouput_video_height>");
|
||||
|
||||
//--------------------
|
||||
case "-level":
|
||||
$argUsed[$i]++;
|
||||
if ($hasNextArg)
|
||||
{
|
||||
%hasExt = strpos($nextArg, ".mis");
|
||||
if(%hasExt == -1)
|
||||
{
|
||||
$levelToLoad = $nextArg @ " ";
|
||||
|
||||
for(%i = $i + 2; %i < $Game::argc; %i++)
|
||||
{
|
||||
$arg = $Game::argv[%i];
|
||||
%hasExt = strpos($arg, ".mis");
|
||||
|
||||
if(%hasExt == -1)
|
||||
{
|
||||
$levelToLoad = $levelToLoad @ $arg @ " ";
|
||||
} else
|
||||
{
|
||||
$levelToLoad = $levelToLoad @ $arg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$levelToLoad = $nextArg;
|
||||
}
|
||||
|
||||
$argUsed[$i+1]++;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -level <level file name (no path), with or without extension>");
|
||||
|
||||
//-------------------
|
||||
case "-worldeditor":
|
||||
$startWorldEditor = true;
|
||||
$argUsed[$i]++;
|
||||
|
||||
//-------------------
|
||||
case "-guieditor":
|
||||
$startGUIEditor = true;
|
||||
$argUsed[$i]++;
|
||||
|
||||
//-------------------
|
||||
case "-help":
|
||||
$displayHelp = true;
|
||||
$argUsed[$i]++;
|
||||
|
||||
//-------------------
|
||||
case "-compileAll":
|
||||
$compileAll = true;
|
||||
$argUsed[$i]++;
|
||||
|
||||
//-------------------
|
||||
case "-compileTools":
|
||||
$compileTools = true;
|
||||
$argUsed[$i]++;
|
||||
|
||||
//-------------------
|
||||
case "-genScript":
|
||||
$genScript = true;
|
||||
$argUsed[$i]++;
|
||||
|
||||
case "-fullscreen":
|
||||
$cliFullscreen = true;
|
||||
$argUsed[%i]++;
|
||||
|
||||
case "-windowed":
|
||||
$cliFullscreen = false;
|
||||
$argUsed[%i]++;
|
||||
|
||||
case "-openGL":
|
||||
$pref::Video::displayDevice = "OpenGL";
|
||||
$argUsed[%i]++;
|
||||
|
||||
case "-directX":
|
||||
$pref::Video::displayDevice = "D3D";
|
||||
$argUsed[%i]++;
|
||||
|
||||
case "-autoVideo":
|
||||
$pref::Video::displayDevice = "";
|
||||
$argUsed[%i]++;
|
||||
|
||||
case "-prefs":
|
||||
$argUsed[%i]++;
|
||||
if ($hasNextArg) {
|
||||
exec($nextArg, true, true);
|
||||
$argUsed[%i+1]++;
|
||||
%i++;
|
||||
}
|
||||
else
|
||||
error("Error: Missing Command Line argument. Usage: -prefs <path/script.cs>");
|
||||
|
||||
|
||||
//-------------------
|
||||
default:
|
||||
$argUsed[$i]++;
|
||||
if($userDirs $= "")
|
||||
$userDirs = $arg;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
// Play journal to video file?
|
||||
if ($VideoCapture::captureFromJournal && $VideoCapture::journalName !$= "")
|
||||
{
|
||||
if ($VideoCapture::fileName $= "")
|
||||
$VideoCapture::fileName = $VideoCapture::journalName;
|
||||
|
||||
if ($VideoCapture::encoder $= "")
|
||||
$VideoCapture::encoder = "THEORA";
|
||||
|
||||
if ($VideoCapture::fps $= "")
|
||||
$VideoCapture::fps = 30;
|
||||
|
||||
if ($videoCapture::width $= "")
|
||||
$videoCapture::width = 0;
|
||||
|
||||
if ($videoCapture::height $= "")
|
||||
$videoCapture::height = 0;
|
||||
|
||||
playJournalToVideo( $VideoCapture::journalName, $VideoCapture::fileName,
|
||||
$VideoCapture::encoder, $VideoCapture::fps,
|
||||
$videoCapture::width SPC $videoCapture::height );
|
||||
}
|
||||
}
|
||||
63
Templates/BaseGame/game/core/postFx.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( PFX_PassthruShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFx/passthruP.hlsl";
|
||||
|
||||
// OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFxV.glsl";
|
||||
// OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFx/gl/passthruP.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
function PostEffect::inspectVars( %this )
|
||||
{
|
||||
%name = %this.getName();
|
||||
%globals = "$" @ %name @ "::*";
|
||||
inspectVars( %globals );
|
||||
}
|
||||
|
||||
function PostEffect::viewDisassembly( %this )
|
||||
{
|
||||
%file = %this.dumpShaderDisassembly();
|
||||
|
||||
if ( %file $= "" )
|
||||
{
|
||||
echo( "PostEffect::viewDisassembly - no shader disassembly found." );
|
||||
}
|
||||
else
|
||||
{
|
||||
echo( "PostEffect::viewDisassembly - shader disassembly file dumped ( " @ %file @ " )." );
|
||||
openFile( %file );
|
||||
}
|
||||
}
|
||||
|
||||
// Return true if we really want the effect enabled.
|
||||
// By default this is the case.
|
||||
function PostEffect::onEnabled( %this )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
226
Templates/BaseGame/game/core/profiles.cs
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Set font cache path if it doesn't already exist.
|
||||
if($Gui::fontCacheDirectory $= "")
|
||||
{
|
||||
$Gui::fontCacheDirectory = expandFilename("./fonts");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// GuiDefaultProfile is a special profile that all other profiles inherit
|
||||
// defaults from. It must exist.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
if(!isObject(GuiDefaultProfile))
|
||||
new GuiControlProfile (GuiDefaultProfile)
|
||||
{
|
||||
tab = false;
|
||||
canKeyFocus = false;
|
||||
hasBitmapArray = false;
|
||||
mouseOverSelected = false;
|
||||
|
||||
// fill color
|
||||
opaque = false;
|
||||
fillColor = "242 241 240";
|
||||
fillColorHL ="228 228 235";
|
||||
fillColorSEL = "98 100 137";
|
||||
fillColorNA = "255 255 255 ";
|
||||
|
||||
// border color
|
||||
border = 0;
|
||||
borderColor = "100 100 100";
|
||||
borderColorHL = "50 50 50 50";
|
||||
borderColorNA = "75 75 75";
|
||||
|
||||
// font
|
||||
fontType = "Arial";
|
||||
fontSize = 14;
|
||||
fontCharset = ANSI;
|
||||
|
||||
fontColor = "0 0 0";
|
||||
fontColorHL = "0 0 0";
|
||||
fontColorNA = "0 0 0";
|
||||
fontColorSEL= "255 255 255";
|
||||
|
||||
// bitmap information
|
||||
bitmap = "";
|
||||
bitmapBase = "";
|
||||
textOffset = "0 0";
|
||||
|
||||
// used by guiTextControl
|
||||
modal = true;
|
||||
justify = "left";
|
||||
autoSizeWidth = false;
|
||||
autoSizeHeight = false;
|
||||
returnTab = false;
|
||||
numbersOnly = false;
|
||||
cursorColor = "0 0 0 255";
|
||||
};
|
||||
|
||||
if(!isObject(GuiToolTipProfile))
|
||||
new GuiControlProfile (GuiToolTipProfile)
|
||||
{
|
||||
// fill color
|
||||
fillColor = "239 237 222";
|
||||
|
||||
// border color
|
||||
borderColor = "138 134 122";
|
||||
|
||||
// font
|
||||
fontType = "Arial";
|
||||
fontSize = 14;
|
||||
fontColor = "0 0 0";
|
||||
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if(!isObject(GuiWindowProfile))
|
||||
new GuiControlProfile (GuiWindowProfile)
|
||||
{
|
||||
opaque = false;
|
||||
border = 2;
|
||||
fillColor = "242 241 240";
|
||||
fillColorHL = "221 221 221";
|
||||
fillColorNA = "200 200 200";
|
||||
fontColor = "50 50 50";
|
||||
fontColorHL = "0 0 0";
|
||||
bevelColorHL = "255 255 255";
|
||||
bevelColorLL = "0 0 0";
|
||||
text = "untitled";
|
||||
bitmap = "./images/window";
|
||||
textOffset = "8 4";
|
||||
hasBitmapArray = true;
|
||||
justify = "left";
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
|
||||
if(!isObject(GuiTextEditProfile))
|
||||
new GuiControlProfile(GuiTextEditProfile)
|
||||
{
|
||||
opaque = true;
|
||||
bitmap = "./images/textEdit";
|
||||
hasBitmapArray = true;
|
||||
border = -2;
|
||||
fillColor = "242 241 240 0";
|
||||
fillColorHL = "255 255 255";
|
||||
fontColor = "0 0 0";
|
||||
fontColorHL = "255 255 255";
|
||||
fontColorSEL = "98 100 137";
|
||||
fontColorNA = "200 200 200";
|
||||
textOffset = "4 2";
|
||||
autoSizeWidth = false;
|
||||
autoSizeHeight = true;
|
||||
justify = "left";
|
||||
tab = true;
|
||||
canKeyFocus = true;
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if(!isObject(GuiScrollProfile))
|
||||
new GuiControlProfile(GuiScrollProfile)
|
||||
{
|
||||
opaque = true;
|
||||
fillcolor = "255 255 255";
|
||||
fontColor = "0 0 0";
|
||||
fontColorHL = "150 150 150";
|
||||
border = true;
|
||||
bitmap = "./images/scrollBar";
|
||||
hasBitmapArray = true;
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if(!isObject(GuiOverlayProfile))
|
||||
new GuiControlProfile(GuiOverlayProfile)
|
||||
{
|
||||
opaque = true;
|
||||
fontColor = "0 0 0";
|
||||
fontColorHL = "255 255 255";
|
||||
fillColor = "0 0 0 100";
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if(!isObject(GuiCheckBoxProfile))
|
||||
new GuiControlProfile(GuiCheckBoxProfile)
|
||||
{
|
||||
opaque = false;
|
||||
fillColor = "232 232 232";
|
||||
border = false;
|
||||
borderColor = "100 100 100";
|
||||
fontSize = 14;
|
||||
fontColor = "20 20 20";
|
||||
fontColorHL = "80 80 80";
|
||||
fontColorNA = "200 200 200";
|
||||
fixedExtent = true;
|
||||
justify = "left";
|
||||
bitmap = "./images/checkbox";
|
||||
hasBitmapArray = true;
|
||||
category = "Tools";
|
||||
};
|
||||
|
||||
if( !isObject( GuiProgressProfile ) )
|
||||
new GuiControlProfile( GuiProgressProfile )
|
||||
{
|
||||
opaque = false;
|
||||
fillColor = "0 162 255 200";
|
||||
border = true;
|
||||
borderColor = "50 50 50 200";
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if( !isObject( GuiProgressBitmapProfile ) )
|
||||
new GuiControlProfile( GuiProgressBitmapProfile )
|
||||
{
|
||||
border = false;
|
||||
hasBitmapArray = true;
|
||||
bitmap = "./images/loadingbar";
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if( !isObject( GuiProgressTextProfile ) )
|
||||
new GuiControlProfile( GuiProgressTextProfile )
|
||||
{
|
||||
fontSize = "14";
|
||||
fontType = "Arial";
|
||||
fontColor = "0 0 0";
|
||||
justify = "center";
|
||||
category = "Core";
|
||||
};
|
||||
|
||||
if( !isObject( GuiButtonProfile ) )
|
||||
new GuiControlProfile( GuiButtonProfile )
|
||||
{
|
||||
opaque = true;
|
||||
border = true;
|
||||
|
||||
fontColor = "50 50 50";
|
||||
fontColorHL = "0 0 0";
|
||||
fontColorNA = "200 200 200";
|
||||
//fontColorSEL ="0 0 0";
|
||||
fixedExtent = false;
|
||||
justify = "center";
|
||||
canKeyFocus = false;
|
||||
bitmap = "./images/button";
|
||||
hasBitmapArray = false;
|
||||
category = "Core";
|
||||
};
|
||||
125
Templates/BaseGame/game/core/renderManager.cs
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function initRenderManager()
|
||||
{
|
||||
assert( !isObject( DiffuseRenderPassManager ), "initRenderManager() - DiffuseRenderPassManager already initialized!" );
|
||||
|
||||
new RenderPassManager( DiffuseRenderPassManager );
|
||||
|
||||
// This token, and the associated render managers, ensure that driver MSAA
|
||||
// does not get used for Advanced Lighting renders. The 'AL_FormatResolve'
|
||||
// PostEffect copies the result to the backbuffer.
|
||||
new RenderFormatToken(AL_FormatToken)
|
||||
{
|
||||
enabled = "false";
|
||||
|
||||
format = getBestHDRFormat();
|
||||
depthFormat = "GFXFormatD24S8";
|
||||
aaLevel = 0; // -1 = match backbuffer
|
||||
|
||||
// The contents of the back buffer before this format token is executed
|
||||
// is provided in $inTex
|
||||
copyEffect = "AL_FormatCopy";
|
||||
|
||||
// The contents of the render target created by this format token is
|
||||
// provided in $inTex
|
||||
resolveEffect = "AL_FormatCopy";
|
||||
};
|
||||
DiffuseRenderPassManager.addManager( new RenderPassStateBin() { renderOrder = 0.001; stateToken = AL_FormatToken; } );
|
||||
|
||||
// We really need to fix the sky to render after all the
|
||||
// meshes... but that causes issues in reflections.
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(SkyBin) { bintype = "Sky"; renderOrder = 0.1; processAddOrder = 0.1; } );
|
||||
|
||||
//DiffuseRenderPassManager.addManager( new RenderVistaMgr() { bintype = "Vista"; renderOrder = 0.15; processAddOrder = 0.15; } );
|
||||
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(BeginBin) { bintype = "Begin"; renderOrder = 0.2; processAddOrder = 0.2; } );
|
||||
// Normal mesh rendering.
|
||||
DiffuseRenderPassManager.addManager( new RenderTerrainMgr(TerrainBin) { renderOrder = 0.4; processAddOrder = 0.4; basicOnly = true; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(MeshBin) { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; basicOnly = true; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderImposterMgr(ImposterBin) { renderOrder = 0.56; processAddOrder = 0.56; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(ObjectBin) { bintype = "Object"; renderOrder = 0.6; processAddOrder = 0.6; } );
|
||||
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(ShadowBin) { bintype = "Shadow"; renderOrder = 0.7; processAddOrder = 0.7; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(DecalRoadBin) { bintype = "DecalRoad"; renderOrder = 0.8; processAddOrder = 0.8; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(DecalBin) { bintype = "Decal"; renderOrder = 0.81; processAddOrder = 0.81; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderOcclusionMgr(OccluderBin){ bintype = "Occluder"; renderOrder = 0.9; processAddOrder = 0.9; } );
|
||||
|
||||
// We now render translucent objects that should handle
|
||||
// their own fogging and lighting.
|
||||
|
||||
// Note that the fog effect is triggered before this bin.
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(ObjTranslucentBin) { bintype = "ObjectTranslucent"; renderOrder = 1.0; processAddOrder = 1.0; } );
|
||||
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(WaterBin) { bintype = "Water"; renderOrder = 1.2; processAddOrder = 1.2; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(FoliageBin) { bintype = "Foliage"; renderOrder = 1.3; processAddOrder = 1.3; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderParticleMgr(ParticleBin) { renderOrder = 1.35; processAddOrder = 1.35; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderTranslucentMgr(TranslucentBin){ renderOrder = 1.4; processAddOrder = 1.4; } );
|
||||
|
||||
DiffuseRenderPassManager.addManager(new RenderObjectMgr(FogBin){ bintype = "ObjectVolumetricFog"; renderOrder = 1.45; processAddOrder = 1.45; } );
|
||||
|
||||
// Note that the GlowPostFx is triggered after this bin.
|
||||
DiffuseRenderPassManager.addManager( new RenderGlowMgr(GlowBin) { renderOrder = 1.5; processAddOrder = 1.5; } );
|
||||
|
||||
// We render any editor stuff from this bin. Note that the HDR is
|
||||
// completed before this bin to keep editor elements from tone mapping.
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(EditorBin) { bintype = "Editor"; renderOrder = 1.6; processAddOrder = 1.6; } );
|
||||
|
||||
// Resolve format change token last.
|
||||
DiffuseRenderPassManager.addManager( new RenderPassStateBin(FinalBin) { renderOrder = 1.7; stateToken = AL_FormatToken; } );
|
||||
}
|
||||
|
||||
/// This is the Default PostFX state block. Put here to prevent any missing object
|
||||
/// errors for below dependencies
|
||||
singleton GFXStateBlockData( PFX_DefaultStateBlock )
|
||||
{
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
/// This post effect is used to copy data from the non-MSAA back-buffer to the
|
||||
/// device back buffer (which could be MSAA). It must be declared here so that
|
||||
/// it is initialized when 'AL_FormatToken' is initialzed.
|
||||
singleton GFXStateBlockData( AL_FormatTokenState : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_FormatCopy )
|
||||
{
|
||||
// This PostEffect is used by 'AL_FormatToken' directly. It is never added to
|
||||
// the PostEffectManager. Do not call enable() on it.
|
||||
isEnabled = false;
|
||||
allowReflectPass = true;
|
||||
|
||||
shader = PFX_PassthruShader;
|
||||
stateBlock = AL_FormatTokenState;
|
||||
|
||||
texture[0] = "$inTex";
|
||||
target = "$backbuffer";
|
||||
};
|
||||
44
Templates/BaseGame/game/core/sfx/audioAmbience.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton SFXAmbience( AudioAmbienceDefault )
|
||||
{
|
||||
environment = AudioEnvOff;
|
||||
};
|
||||
|
||||
singleton SFXAmbience( AudioAmbienceOutside )
|
||||
{
|
||||
environment = AudioEnvPlain;
|
||||
states[ 0 ] = AudioLocationOutside;
|
||||
};
|
||||
|
||||
singleton SFXAmbience( AudioAmbienceInside )
|
||||
{
|
||||
environment = AudioEnvRoom;
|
||||
states[ 0 ] = AudioLocationInside;
|
||||
};
|
||||
|
||||
singleton SFXAmbience( AudioAmbienceUnderwater )
|
||||
{
|
||||
environment = AudioEnvUnderwater;
|
||||
states[ 0 ] = AudioLocationUnderwater;
|
||||
};
|
||||
42
Templates/BaseGame/game/core/sfx/audioData.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Game specific audio descriptions. Always declare SFXDescription's (the type of sound)
|
||||
// before SFXProfile's (the sound itself) when creating new ones
|
||||
|
||||
singleton SFXDescription(BulletFireDesc : AudioEffect )
|
||||
{
|
||||
isLooping = false;
|
||||
is3D = true;
|
||||
ReferenceDistance = 10.0;
|
||||
MaxDistance = 60.0;
|
||||
};
|
||||
|
||||
singleton SFXDescription(BulletImpactDesc : AudioEffect )
|
||||
{
|
||||
isLooping = false;
|
||||
is3D = true;
|
||||
ReferenceDistance = 10.0;
|
||||
MaxDistance = 30.0;
|
||||
volume = 0.4;
|
||||
pitch = 1.4;
|
||||
};
|
||||
143
Templates/BaseGame/game/core/sfx/audioDescriptions.cs
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Always declare SFXDescription's (the type of sound) before SFXProfile's (the
|
||||
// sound itself) when creating new ones
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 3D Sounds
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Single shot sounds
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton SFXDescription( AudioDefault3D : AudioEffect )
|
||||
{
|
||||
is3D = true;
|
||||
ReferenceDistance = 20.0;
|
||||
MaxDistance = 100.0;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioSoft3D : AudioEffect )
|
||||
{
|
||||
is3D = true;
|
||||
ReferenceDistance = 20.0;
|
||||
MaxDistance = 100.0;
|
||||
volume = 0.4;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioClose3D : AudioEffect )
|
||||
{
|
||||
is3D = true;
|
||||
ReferenceDistance = 10.0;
|
||||
MaxDistance = 60.0;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioClosest3D : AudioEffect )
|
||||
{
|
||||
is3D = true;
|
||||
ReferenceDistance = 5.0;
|
||||
MaxDistance = 10.0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Looping sounds
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton SFXDescription( AudioDefaultLoop3D : AudioEffect )
|
||||
{
|
||||
isLooping = true;
|
||||
is3D = true;
|
||||
ReferenceDistance = 20.0;
|
||||
MaxDistance = 100.0;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioCloseLoop3D : AudioEffect )
|
||||
{
|
||||
isLooping = true;
|
||||
is3D = true;
|
||||
ReferenceDistance = 18.0;
|
||||
MaxDistance = 25.0;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioClosestLoop3D : AudioEffect )
|
||||
{
|
||||
isLooping = true;
|
||||
is3D = true;
|
||||
ReferenceDistance = 5.0;
|
||||
MaxDistance = 10.0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 2d sounds
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Used for non-looping environmental sounds (like power on, power off)
|
||||
singleton SFXDescription( Audio2D : AudioEffect )
|
||||
{
|
||||
isLooping = false;
|
||||
};
|
||||
|
||||
// Used for Looping Environmental Sounds
|
||||
singleton SFXDescription( AudioLoop2D : AudioEffect )
|
||||
{
|
||||
isLooping = true;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioStream2D : AudioEffect )
|
||||
{
|
||||
isStreaming = true;
|
||||
};
|
||||
singleton SFXDescription( AudioStreamLoop2D : AudioEffect )
|
||||
{
|
||||
isLooping = true;
|
||||
isStreaming = true;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Music
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton SFXDescription( AudioMusic2D : AudioMusic )
|
||||
{
|
||||
isStreaming = true;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioMusicLoop2D : AudioMusic )
|
||||
{
|
||||
isLooping = true;
|
||||
isStreaming = true;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioMusic3D : AudioMusic )
|
||||
{
|
||||
isStreaming = true;
|
||||
is3D = true;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioMusicLoop3D : AudioMusic )
|
||||
{
|
||||
isStreaming = true;
|
||||
is3D = true;
|
||||
isLooping = true;
|
||||
};
|
||||
916
Templates/BaseGame/game/core/sfx/audioEnvironments.cs
Normal file
|
|
@ -0,0 +1,916 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Reverb environment presets.
|
||||
//
|
||||
// For customized presets, best derive from one of these presets.
|
||||
|
||||
singleton SFXEnvironment( AudioEnvOff )
|
||||
{
|
||||
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 = "1";
|
||||
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";
|
||||
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;
|
||||
};
|
||||
|
||||
singleton SFXEnvironment( AudioEnvMountains )
|
||||
{
|
||||
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";
|
||||
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;
|
||||
};
|
||||
|
||||
singleton SFXEnvironment( AudioEnvQuary )
|
||||
{
|
||||
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";
|
||||
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;
|
||||
};
|
||||
|
||||
singleton SFXEnvironment( AudioEnvPlain )
|
||||
{
|
||||
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";
|
||||
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;
|
||||
};
|
||||
|
||||
singleton SFXEnvironment( AudioEnvParkingLot )
|
||||
{
|
||||
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";
|
||||
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;
|
||||
};
|
||||
|
||||
singleton SFXEnvironment( AudioEnvSewerPipe )
|
||||
{
|
||||
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";
|
||||
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;
|
||||
};
|
||||
|
||||
singleton SFXEnvironment( AudioEnvUnderwater )
|
||||
{
|
||||
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";
|
||||
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;
|
||||
};
|
||||
|
||||
singleton SFXEnvironment( AudioEnvDrugged )
|
||||
{
|
||||
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";
|
||||
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;
|
||||
};
|
||||
|
||||
singleton SFXEnvironment( AudioEnvDizzy )
|
||||
{
|
||||
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";
|
||||
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;
|
||||
};
|
||||
|
||||
singleton SFXEnvironment( AudioEnvPsychotic )
|
||||
{
|
||||
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";
|
||||
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;
|
||||
};
|
||||
158
Templates/BaseGame/game/core/sfx/audioStates.cs
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Some state presets.
|
||||
|
||||
|
||||
/// Return the first active SFXState in the given SimSet/SimGroup.
|
||||
function sfxGetActiveStateInGroup( %group )
|
||||
{
|
||||
%count = %group.getCount();
|
||||
for( %i = 0; %i < %count; %i ++ )
|
||||
{
|
||||
%obj = %group.getObject( %i );
|
||||
if( !%obj.isMemberOfClass( "SFXState" ) )
|
||||
continue;
|
||||
|
||||
if( %obj.isActive() )
|
||||
return %obj;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Special audio state that will always and only be active when no other
|
||||
// state is active. Useful for letting slots apply specifically when no
|
||||
// other slot in a list applies.
|
||||
|
||||
singleton SFXState( AudioStateNone ) {};
|
||||
|
||||
AudioStateNone.activate();
|
||||
|
||||
function SFXState::onActivate( %this )
|
||||
{
|
||||
if( %this.getId() != AudioStateNone.getId() )
|
||||
AudioStateNone.disable();
|
||||
}
|
||||
|
||||
function SFXState::onDeactivate( %this )
|
||||
{
|
||||
if( %this.getId() != AudioStateNone.getId() )
|
||||
AudioStateNone.enable();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// AudioStateExclusive class.
|
||||
//
|
||||
// Automatically deactivates sibling SFXStates in its parent SimGroup
|
||||
// when activated.
|
||||
|
||||
function AudioStateExclusive::onActivate( %this )
|
||||
{
|
||||
Parent::onActivate( %this );
|
||||
|
||||
%group = %this.parentGroup;
|
||||
%count = %group.getCount();
|
||||
|
||||
for( %i = 0; %i < %count; %i ++ )
|
||||
{
|
||||
%obj = %group.getObject( %i );
|
||||
|
||||
if( %obj != %this && %obj.isMemberOfClass( "SFXState" ) && %obj.isActive() )
|
||||
%obj.deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Location-dependent states.
|
||||
|
||||
singleton SimGroup( AudioLocation );
|
||||
|
||||
/// State when the listener is outside.
|
||||
singleton SFXState( AudioLocationOutside )
|
||||
{
|
||||
parentGroup = AudioLocation;
|
||||
className = "AudioStateExclusive";
|
||||
};
|
||||
|
||||
/// State when the listener is submerged.
|
||||
singleton SFXState( AudioLocationUnderwater )
|
||||
{
|
||||
parentGroup = AudioLocation;
|
||||
className = "AudioStateExclusive";
|
||||
};
|
||||
|
||||
/// State when the listener is indoors.
|
||||
singleton SFXState( AudioLocationInside )
|
||||
{
|
||||
parentGroup = AudioLocation;
|
||||
className = "AudioStateExclusive";
|
||||
};
|
||||
|
||||
/// Return the currently active SFXState in AudioLocation.
|
||||
function sfxGetLocation()
|
||||
{
|
||||
return sfxGetActiveStateInGroup( AudioLocation );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Mood-dependent states.
|
||||
|
||||
singleton SimGroup( AudioMood );
|
||||
|
||||
singleton SFXState( AudioMoodNeutral )
|
||||
{
|
||||
parentGroup = AudioMood;
|
||||
className = "AudioStateExclusive";
|
||||
};
|
||||
|
||||
singleton SFXState( AudioMoodAggressive )
|
||||
{
|
||||
parentGroup = AudioMood;
|
||||
className = "AudioStateExclusive";
|
||||
};
|
||||
|
||||
singleton SFXState( AudioMoodTense )
|
||||
{
|
||||
parentGroup = AudioMood;
|
||||
className = "AudioStateExclusive";
|
||||
};
|
||||
|
||||
singleton SFXState( AudioMoodVictory )
|
||||
{
|
||||
parentGroup = AudioMood;
|
||||
className = "AudioStateExclusive";
|
||||
};
|
||||
|
||||
singleton SFXState( AudioMoodCalm )
|
||||
{
|
||||
parentGroup = AudioMood;
|
||||
className = "AudioStateExclusive";
|
||||
};
|
||||
|
||||
/// Return the currently active SFXState in AudioMood.
|
||||
function sfxGetMood()
|
||||
{
|
||||
return sfxGetActiveStateInGroup( AudioMood );
|
||||
}
|
||||
112
Templates/BaseGame/game/data/clientServer/ClientServer.cs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
|
||||
// The general flow of a gane - server's creation, loading and hosting clients, and then destruction is as follows:
|
||||
|
||||
// First, a client will always create a server in the event that they want to host a single player
|
||||
// game. Torque3D treats even single player connections as a soft multiplayer game, with some stuff
|
||||
// in the networking short-circuited to sidestep around lag and packet transmission times.
|
||||
|
||||
// initServer() is called, loading the default server scripts.
|
||||
// After that, if this is a dedicated server session, initDedicated() is called, otherwise initClient is called
|
||||
// to prep a playable client session.
|
||||
|
||||
// When a local game is started - a listen server - via calling StartGame() a server is created and then the client is
|
||||
// connected to it via createAndConnectToLocalServer().
|
||||
|
||||
function ClientServer::create( %this )
|
||||
{
|
||||
echo("\n--------- Initializing Directory: scripts ---------");
|
||||
exec( "./scripts/client/client.cs" );
|
||||
exec( "./scripts/server/server.cs" );
|
||||
|
||||
$Game::MissionGroup = "MissionGroup";
|
||||
|
||||
initServer();
|
||||
|
||||
%dbList = new ArrayObject(DatablockFilesList);
|
||||
|
||||
// Start up in either client, or dedicated server mode
|
||||
if ($Server::Dedicated)
|
||||
{
|
||||
initDedicated();
|
||||
}
|
||||
else
|
||||
{
|
||||
initClient();
|
||||
}
|
||||
}
|
||||
|
||||
function ClientServer::destroy( %this )
|
||||
{
|
||||
// Ensure that we are disconnected and/or the server is destroyed.
|
||||
// This prevents crashes due to the SceneGraph being deleted before
|
||||
// the objects it contains.
|
||||
if ($Server::Dedicated)
|
||||
destroyServer();
|
||||
else
|
||||
disconnect();
|
||||
|
||||
// Destroy the physics plugin.
|
||||
physicsDestroy();
|
||||
|
||||
sfxShutdown();
|
||||
|
||||
echo("Exporting client prefs");
|
||||
%prefPath = getPrefpath();
|
||||
export("$pref::*", %prefPath @ "/clientPrefs.cs", false);
|
||||
|
||||
echo("Exporting server prefs");
|
||||
export("$Pref::Server::*", %prefPath @ "/serverPrefs.cs", false);
|
||||
BanList::Export(%prefPath @ "/banlist.cs");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
function StartGame( %mission, %hostingType )
|
||||
{
|
||||
if( %mission $= "" )
|
||||
{
|
||||
%id = CL_levelList.getSelectedId();
|
||||
%mission = getField(CL_levelList.getRowTextById(%id), 1);
|
||||
//error("Cannot start a level with no level selected!");
|
||||
}
|
||||
|
||||
if (%hostingType !$= "")
|
||||
{
|
||||
%serverType = %hostingType;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($pref::HostMultiPlayer)
|
||||
%serverType = "MultiPlayer";
|
||||
else
|
||||
%serverType = "SinglePlayer";
|
||||
}
|
||||
|
||||
// Show the loading screen immediately.
|
||||
if ( isObject( LoadingGui ) )
|
||||
{
|
||||
Canvas.setContent("LoadingGui");
|
||||
LoadingProgress.setValue(1);
|
||||
LoadingProgressTxt.setValue("LOADING MISSION FILE");
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
createAndConnectToLocalServer( %serverType, %mission );
|
||||
}
|
||||
|
||||
function JoinGame( %serverIndex )
|
||||
{
|
||||
// The server info index is stored in the row along with the
|
||||
// rest of displayed info.
|
||||
if( setServerInfo( %serverIndex ) )
|
||||
{
|
||||
Canvas.setContent("LoadingGui");
|
||||
LoadingProgress.setValue(1);
|
||||
LoadingProgressTxt.setValue("WAITING FOR SERVER");
|
||||
Canvas.repaint();
|
||||
|
||||
%conn = new GameConnection(ServerConnection);
|
||||
%conn.setConnectArgs($pref::Player::Name);
|
||||
%conn.setJoinPassword($Client::Password);
|
||||
%conn.connect($ServerInfo::Address);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<ModuleDefinition
|
||||
ModuleId="ClientServer"
|
||||
VersionId="1"
|
||||
Description="Default module for the game."
|
||||
ScriptFile="ClientServer.cs"
|
||||
CreateFunction="create"
|
||||
DestroyFunction="destroy"
|
||||
Group="Game">
|
||||
</ModuleDefinition>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
function initClient()
|
||||
{
|
||||
echo("\n--------- Initializing " @ $appName @ ": Client Scripts ---------");
|
||||
|
||||
// Make sure this variable reflects the correct state.
|
||||
$Server::Dedicated = false;
|
||||
|
||||
// Game information used to query the master server
|
||||
$Client::GameTypeQuery = $appName;
|
||||
$Client::MissionTypeQuery = "Any";
|
||||
|
||||
exec( "data/clientServer/scripts/client/message.cs" );
|
||||
exec( "data/clientServer/scripts/client/connectionToServer.cs" );
|
||||
exec( "data/clientServer/scripts/client/levelDownload.cs" );
|
||||
exec( "data/clientServer/scripts/client/levelLoad.cs" );
|
||||
|
||||
//load prefs
|
||||
%prefPath = getPrefpath();
|
||||
if ( isFile( %prefPath @ "/clientPrefs.cs" ) )
|
||||
exec( %prefPath @ "/clientPrefs.cs" );
|
||||
else
|
||||
exec( "data/defaults.cs" );
|
||||
|
||||
loadMaterials();
|
||||
|
||||
// Copy saved script prefs into C++ code.
|
||||
setDefaultFov( $pref::Player::defaultFov );
|
||||
setZoomSpeed( $pref::Player::zoomSpeed );
|
||||
}
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Functions dealing with connecting to a server
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// GameConnection client callbacks
|
||||
//----------------------------------------------------------------------------
|
||||
// Called on the new connection object after connect() succeeds.
|
||||
function GameConnection::onConnectionAccepted(%this)
|
||||
{
|
||||
// Startup the physX world on the client before any
|
||||
// datablocks and objects are ghosted over.
|
||||
physicsInitWorld( "client" );
|
||||
}
|
||||
|
||||
function GameConnection::initialControlSet(%this)
|
||||
{
|
||||
echo ("*** Initial Control Object");
|
||||
|
||||
// The first control object has been set by the server
|
||||
// and we are now ready to go.
|
||||
|
||||
// first check if the editor is active
|
||||
if (!isToolBuild() || !isMethod("Editor", "checkActiveLoadDone") || !Editor::checkActiveLoadDone())
|
||||
{
|
||||
if (Canvas.getContent() != PlayGui.getId())
|
||||
Canvas.setContent(PlayGui);
|
||||
}
|
||||
}
|
||||
|
||||
function GameConnection::onControlObjectChange(%this)
|
||||
{
|
||||
echo ("*** Control Object Changed");
|
||||
|
||||
// Reset the current FOV to match the new object
|
||||
// and turn off any current zoom.
|
||||
resetCurrentFOV();
|
||||
turnOffZoom();
|
||||
}
|
||||
|
||||
function GameConnection::onConnectionError(%this, %msg)
|
||||
{
|
||||
// General connection error, usually raised by ghosted objects
|
||||
// initialization problems, such as missing files. We'll display
|
||||
// the server's connection error message.
|
||||
disconnectedCleanup();
|
||||
MessageBoxOK( "DISCONNECT", $ServerConnectionErrorMessage @ " (" @ %msg @ ")" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Server connection error
|
||||
//-----------------------------------------------------------------------------
|
||||
addMessageCallback( 'MsgConnectionError', handleConnectionErrorMessage );
|
||||
|
||||
function handleConnectionErrorMessage(%msgType, %msgString, %msgError)
|
||||
{
|
||||
// On connect the server transmits a message to display if there
|
||||
// are any problems with the connection. Most connection errors
|
||||
// are game version differences, so hopefully the server message
|
||||
// will tell us where to get the latest version of the game.
|
||||
$ServerConnectionErrorMessage = %msgError;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Disconnect
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function disconnect()
|
||||
{
|
||||
// We need to stop the client side simulation
|
||||
// else physics resources will not cleanup properly.
|
||||
physicsStopSimulation( "client" );
|
||||
|
||||
// Delete the connection if it's still there.
|
||||
if (isObject(ServerConnection))
|
||||
ServerConnection.delete();
|
||||
|
||||
disconnectedCleanup();
|
||||
|
||||
// Call destroyServer in case we're hosting
|
||||
destroyServer();
|
||||
}
|
||||
|
||||
function disconnectedCleanup()
|
||||
{
|
||||
// End mission, if it's running.
|
||||
|
||||
if( $Client::missionRunning )
|
||||
clientEndMission();
|
||||
|
||||
// Disable mission lighting if it's going, this is here
|
||||
// in case we're disconnected while the mission is loading.
|
||||
|
||||
$lightingMission = false;
|
||||
$sceneLighting::terminateLighting = true;
|
||||
|
||||
// Back to the launch screen
|
||||
if (isObject( MainMenuGui ))
|
||||
Canvas.setContent( MainMenuGui );
|
||||
|
||||
// Before we destroy the client physics world
|
||||
// make sure all ServerConnection objects are deleted.
|
||||
if(isObject(ServerConnection))
|
||||
{
|
||||
ServerConnection.deleteAllObjects();
|
||||
}
|
||||
|
||||
// We can now delete the client physics simulation.
|
||||
physicsDestroyWorld( "client" );
|
||||
}
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Mission Loading
|
||||
// The client portion of the client/server mission loading process
|
||||
//-----------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------
|
||||
// Loading Phases:
|
||||
// Phase 1: Transmit Datablocks
|
||||
// Transmit targets
|
||||
// Phase 2: Transmit Ghost Objects
|
||||
// Phase 3: Start Game
|
||||
//
|
||||
// The server invokes the client MissionStartPhase[1-3] function to request
|
||||
// permission to start each phase. When a client is ready for a phase,
|
||||
// it responds with MissionStartPhase[1-3]Ack.
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Phase 1
|
||||
//----------------------------------------------------------------------------
|
||||
function clientCmdMissionStartPhase1(%seq, %missionName)
|
||||
{
|
||||
// These need to come after the cls.
|
||||
echo ("*** New Mission: " @ %missionName);
|
||||
echo ("*** Phase 1: Download Datablocks & Targets");
|
||||
|
||||
//Prep the postFX stuff
|
||||
// Load the post effect presets for this mission.
|
||||
%path = filePath( %missionName ) @ "/" @ fileBase( %missionName ) @ $PostFXManager::fileExtension;
|
||||
|
||||
if ( isScriptFile( %path ) )
|
||||
{
|
||||
postFXManager::loadPresetHandler( %path );
|
||||
}
|
||||
else
|
||||
{
|
||||
PostFXManager::settingsApplyDefaultPreset();
|
||||
}
|
||||
|
||||
onMissionDownloadPhase("LOADING DATABLOCKS");
|
||||
|
||||
commandToServer('MissionStartPhase1Ack', %seq);
|
||||
}
|
||||
|
||||
function onDataBlockObjectReceived(%index, %total)
|
||||
{
|
||||
onMissionDownloadProgress(%index / %total);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Phase 2
|
||||
//----------------------------------------------------------------------------
|
||||
function clientCmdMissionStartPhase2(%seq,%missionName)
|
||||
{
|
||||
onPhaseComplete();
|
||||
echo ("*** Phase 2: Download Ghost Objects");
|
||||
|
||||
onMissionDownloadPhase("LOADING OBJECTS");
|
||||
|
||||
commandToServer('MissionStartPhase2Ack', %seq);
|
||||
}
|
||||
|
||||
function onGhostAlwaysStarted(%ghostCount)
|
||||
{
|
||||
$ghostCount = %ghostCount;
|
||||
$ghostsRecvd = 0;
|
||||
}
|
||||
|
||||
function onGhostAlwaysObjectReceived()
|
||||
{
|
||||
$ghostsRecvd++;
|
||||
onMissionDownloadProgress($ghostsRecvd / $ghostCount);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Phase 3
|
||||
//----------------------------------------------------------------------------
|
||||
function clientCmdMissionStartPhase3(%seq,%missionName)
|
||||
{
|
||||
onPhaseComplete();
|
||||
StartClientReplication();
|
||||
StartFoliageReplication();
|
||||
|
||||
// Load the static mission decals.
|
||||
if(isFile(%missionName @ ".decals"))
|
||||
decalManagerLoad( %missionName @ ".decals" );
|
||||
|
||||
echo ("*** Phase 3: Mission Lighting");
|
||||
$MSeq = %seq;
|
||||
$Client::MissionFile = %missionName;
|
||||
|
||||
// Need to light the mission before we are ready.
|
||||
// The sceneLightingComplete function will complete the handshake
|
||||
// once the scene lighting is done.
|
||||
if (lightScene("sceneLightingComplete", ""))
|
||||
{
|
||||
echo("Lighting mission....");
|
||||
schedule(1, 0, "updateLightingProgress");
|
||||
|
||||
onMissionDownloadPhase("LIGHTING MISSION");
|
||||
|
||||
$lightingMission = true;
|
||||
}
|
||||
}
|
||||
|
||||
function updateLightingProgress()
|
||||
{
|
||||
onMissionDownloadProgress($SceneLighting::lightingProgress);
|
||||
if ($lightingMission)
|
||||
$lightingProgressThread = schedule(1, 0, "updateLightingProgress");
|
||||
}
|
||||
|
||||
function sceneLightingComplete()
|
||||
{
|
||||
echo("Mission lighting done");
|
||||
$lightingMission = false;
|
||||
|
||||
onPhaseComplete("STARTING MISSION");
|
||||
|
||||
// The is also the end of the mission load cycle.
|
||||
commandToServer('MissionStartPhase3Ack', $MSeq);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Helper functions
|
||||
//----------------------------------------------------------------------------
|
||||
function connect(%server)
|
||||
{
|
||||
%conn = new GameConnection(ServerConnection);
|
||||
RootGroup.add(ServerConnection);
|
||||
%conn.setConnectArgs($pref::Player::Name);
|
||||
%conn.setJoinPassword($Client::Password);
|
||||
%conn.connect(%server);
|
||||
}
|
||||
|
||||
function onMissionDownloadPhase(%phase)
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue(0);
|
||||
LoadingProgressTxt.setValue(%phase);
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
function onMissionDownloadProgress(%progress)
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
LoadingProgress.setValue(%progress);
|
||||
Canvas.repaint(33);
|
||||
}
|
||||
|
||||
function onPhaseComplete(%text)
|
||||
{
|
||||
if ( !isObject( LoadingProgress ) )
|
||||
return;
|
||||
|
||||
if(%text !$= "")
|
||||
LoadingProgressTxt.setValue(%text);
|
||||
|
||||
LoadingProgress.setValue( 1 );
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Whether the local client is currently running a mission.
|
||||
$Client::missionRunning = false;
|
||||
|
||||
// Sequence number for currently running mission.
|
||||
$Client::missionSeq = -1;
|
||||
|
||||
|
||||
// Called when mission is started.
|
||||
function clientStartMission()
|
||||
{
|
||||
// The client recieves a mission start right before
|
||||
// being dropped into the game.
|
||||
physicsStartSimulation( "client" );
|
||||
|
||||
// Start game audio effects channels.
|
||||
|
||||
AudioChannelEffects.play();
|
||||
|
||||
// Create client mission cleanup group.
|
||||
|
||||
new SimGroup( ClientMissionCleanup );
|
||||
|
||||
// Done.
|
||||
|
||||
$Client::missionRunning = true;
|
||||
}
|
||||
|
||||
// Called when mission is ended (either through disconnect or
|
||||
// mission end client command).
|
||||
function clientEndMission()
|
||||
{
|
||||
// Stop physics simulation on client.
|
||||
physicsStopSimulation( "client" );
|
||||
|
||||
// Stop game audio effects channels.
|
||||
|
||||
AudioChannelEffects.stop();
|
||||
|
||||
// Delete all the decals.
|
||||
decalManagerClear();
|
||||
|
||||
// Delete client mission cleanup group.
|
||||
if( isObject( ClientMissionCleanup ) )
|
||||
ClientMissionCleanup.delete();
|
||||
|
||||
clearClientPaths();
|
||||
|
||||
// Done.
|
||||
$Client::missionRunning = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Mission start / end events sent from the server
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function clientCmdMissionStart(%seq)
|
||||
{
|
||||
clientStartMission();
|
||||
$Client::missionSeq = %seq;
|
||||
}
|
||||
|
||||
function clientCmdMissionEnd( %seq )
|
||||
{
|
||||
if( $Client::missionRunning && $Client::missionSeq == %seq )
|
||||
{
|
||||
clientEndMission();
|
||||
$Client::missionSeq = -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Functions that process commands sent from the server.
|
||||
|
||||
// Game event descriptions, which may or may not include text messages, can be
|
||||
// sent using the message* functions in core/scripts/server/message.cs. Those
|
||||
// functions do commandToClient with the tag ServerMessage, which invokes the
|
||||
// function below.
|
||||
|
||||
// For ServerMessage messages, the client can install callbacks that will be
|
||||
// run, according to the "type" of the message.
|
||||
|
||||
function clientCmdServerMessage(%msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10)
|
||||
{
|
||||
// Get the message type; terminates at any whitespace.
|
||||
%tag = getWord(%msgType, 0);
|
||||
|
||||
// First see if there is a callback installed that doesn't have a type;
|
||||
// if so, that callback is always executed when a message arrives.
|
||||
for (%i = 0; (%func = $MSGCB["", %i]) !$= ""; %i++) {
|
||||
call(%func, %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
|
||||
}
|
||||
|
||||
// Next look for a callback for this particular type of ServerMessage.
|
||||
if (%tag !$= "") {
|
||||
for (%i = 0; (%func = $MSGCB[%tag, %i]) !$= ""; %i++) {
|
||||
call(%func, %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called by the client to install a callback for a particular type of
|
||||
// ServerMessage.
|
||||
function addMessageCallback(%msgType, %func)
|
||||
{
|
||||
for (%i = 0; (%afunc = $MSGCB[%msgType, %i]) !$= ""; %i++) {
|
||||
// If it already exists as a callback for this type,
|
||||
// nothing to do.
|
||||
if (%afunc $= %func) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Set it up.
|
||||
$MSGCB[%msgType, %i] = %func;
|
||||
}
|
||||
|
||||
// The following is the callback that will be executed for every ServerMessage,
|
||||
// because we're going to install it without a specified type. Any type-
|
||||
// specific callbacks will be executed afterward.
|
||||
|
||||
// This just invokes onServerMessage, which can be overridden by the game
|
||||
function onServerMessage(%a, %b, %c, %d, %e, %f, %g, %h, %i)
|
||||
{
|
||||
echo("onServerMessage: ");
|
||||
if(%a !$= "") echo(" +- a: " @ %a);
|
||||
if(%b !$= "") echo(" +- b: " @ %b);
|
||||
if(%c !$= "") echo(" +- c: " @ %c);
|
||||
if(%d !$= "") echo(" +- d: " @ %d);
|
||||
if(%e !$= "") echo(" +- e: " @ %e);
|
||||
if(%f !$= "") echo(" +- f: " @ %f);
|
||||
if(%g !$= "") echo(" +- g: " @ %g);
|
||||
if(%h !$= "") echo(" +- h: " @ %h);
|
||||
if(%i !$= "") echo(" +- i: " @ %i);
|
||||
}
|
||||
|
||||
function defaultMessageCallback(%msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10)
|
||||
{
|
||||
onServerMessage(detag(%msgString));
|
||||
}
|
||||
|
||||
// Register that default message handler now.
|
||||
addMessageCallback("", defaultMessageCallback);
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function ServerPlay2D(%profile)
|
||||
{
|
||||
// Play the given sound profile on every client.
|
||||
// The sounds will be transmitted as an event, not attached to any object.
|
||||
for(%idx = 0; %idx < ClientGroup.getCount(); %idx++)
|
||||
ClientGroup.getObject(%idx).play2D(%profile);
|
||||
}
|
||||
|
||||
function ServerPlay3D(%profile,%transform)
|
||||
{
|
||||
// Play the given sound profile at the given position on every client
|
||||
// The sound will be transmitted as an event, not attached to any object.
|
||||
for(%idx = 0; %idx < ClientGroup.getCount(); %idx++)
|
||||
ClientGroup.getObject(%idx).play3D(%profile,%transform);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Misc. server commands avialable to clients
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Debug commands
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function serverCmdNetSimulateLag( %client, %msDelay, %packetLossPercent )
|
||||
{
|
||||
if ( %client.isAdmin )
|
||||
%client.setSimulatedNetParams( %packetLossPercent / 100.0, %msDelay );
|
||||
}
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This script function is called before a client connection
|
||||
// is accepted. Returning "" will accept the connection,
|
||||
// anything else will be sent back as an error to the client.
|
||||
// All the connect args are passed also to onConnectRequest
|
||||
//
|
||||
function GameConnection::onConnectRequest( %client, %netAddress, %name )
|
||||
{
|
||||
echo("Connect request from: " @ %netAddress);
|
||||
if($Server::PlayerCount >= $pref::Server::MaxPlayers)
|
||||
return "CR_SERVERFULL";
|
||||
return "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This script function is the first called on a client accept
|
||||
function GameConnection::onConnect( %this, %clientData )
|
||||
{
|
||||
// Send down the connection error info, the client is responsible for
|
||||
// displaying this message if a connection error occurs.
|
||||
messageClient(%this, 'MsgConnectionError', "", $Pref::Server::ConnectionError);
|
||||
|
||||
// Send mission information to the client
|
||||
sendLoadInfoToClient(%this);
|
||||
|
||||
// Simulated client lag for testing...
|
||||
// %client.setSimulatedNetParams(0.1, 30);
|
||||
|
||||
// Get the client's unique id:
|
||||
// %authInfo = %client.getAuthInfo();
|
||||
// %client.guid = getField(%authInfo, 3);
|
||||
%this.guid = 0;
|
||||
addToServerGuidList(%this.guid);
|
||||
|
||||
// Set admin status
|
||||
if (%this.getAddress() $= "local")
|
||||
{
|
||||
%this.isAdmin = true;
|
||||
%this.isSuperAdmin = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
%this.isAdmin = false;
|
||||
%this.isSuperAdmin = false;
|
||||
}
|
||||
|
||||
echo("CADD: "@ %this @" "@ %this.getAddress());
|
||||
|
||||
// If the mission is running, go ahead download it to the client
|
||||
if ($missionRunning)
|
||||
{
|
||||
%this.loadMission();
|
||||
}
|
||||
else if ($Server::LoadFailMsg !$= "")
|
||||
{
|
||||
messageClient(%this, 'MsgLoadFailed', $Server::LoadFailMsg);
|
||||
}
|
||||
|
||||
%this.connectData = %clientData;
|
||||
|
||||
$Server::PlayerCount++;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// A player's name could be obtained from the auth server, but for
|
||||
// now we use the one passed from the client.
|
||||
// %realName = getField( %authInfo, 0 );
|
||||
//
|
||||
function GameConnection::setPlayerName(%client,%name)
|
||||
{
|
||||
%client.sendGuid = 0;
|
||||
|
||||
// Minimum length requirements
|
||||
%name = trim( strToPlayerName( %name ) );
|
||||
if ( strlen( %name ) < 3 )
|
||||
%name = "Poser";
|
||||
|
||||
// Make sure the alias is unique, we'll hit something eventually
|
||||
if (!isNameUnique(%name))
|
||||
{
|
||||
%isUnique = false;
|
||||
for (%suffix = 1; !%isUnique; %suffix++) {
|
||||
%nameTry = %name @ "." @ %suffix;
|
||||
%isUnique = isNameUnique(%nameTry);
|
||||
}
|
||||
%name = %nameTry;
|
||||
}
|
||||
|
||||
// Tag the name with the "smurf" color:
|
||||
%client.nameBase = %name;
|
||||
%client.playerName = addTaggedString("\cp\c8" @ %name @ "\co");
|
||||
}
|
||||
|
||||
function isNameUnique(%name)
|
||||
{
|
||||
%count = ClientGroup.getCount();
|
||||
for ( %i = 0; %i < %count; %i++ )
|
||||
{
|
||||
%test = ClientGroup.getObject( %i );
|
||||
%rawName = stripChars( detag( getTaggedString( %test.playerName ) ), "\cp\co\c6\c7\c8\c9" );
|
||||
if ( strcmp( %name, %rawName ) == 0 )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This function is called when a client drops for any reason
|
||||
//
|
||||
function GameConnection::onDrop(%client, %reason)
|
||||
{
|
||||
if($missionRunning)
|
||||
theLevelInfo.onClientLeaveGame();
|
||||
|
||||
removeFromServerGuidList( %client.guid );
|
||||
|
||||
$Server::PlayerCount--;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function GameConnection::startMission(%this)
|
||||
{
|
||||
// Inform the client the mission starting
|
||||
commandToClient(%this, 'MissionStart', $missionSequence);
|
||||
}
|
||||
|
||||
|
||||
function GameConnection::endMission(%this)
|
||||
{
|
||||
// Inform the client the mission is done. Note that if this is
|
||||
// called as part of the server destruction routine, the client will
|
||||
// actually never see this comment since the client connection will
|
||||
// be destroyed before another round of command processing occurs.
|
||||
// In this case, the client will only see the disconnect from the server
|
||||
// and should manually trigger a mission cleanup.
|
||||
commandToClient(%this, 'MissionEnd', $missionSequence);
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//Firstly, set up our standard server prefs
|
||||
|
||||
// List of master servers to query, each one is tried in order
|
||||
// until one responds
|
||||
$Pref::Server::RegionMask = 2;
|
||||
$pref::Master[0] = "2:master.garagegames.com:28002";
|
||||
|
||||
// Information about the server
|
||||
$Pref::Server::Name = "Torque 3D Server";
|
||||
$Pref::Server::Info = "This is a Torque 3D server.";
|
||||
|
||||
// The connection error message is transmitted to the client immediatly
|
||||
// on connection, if any further error occures during the connection
|
||||
// process, such as network traffic mismatch, or missing files, this error
|
||||
// message is display. This message should be replaced with information
|
||||
// usefull to the client, such as the url or ftp address of where the
|
||||
// latest version of the game can be obtained.
|
||||
$Pref::Server::ConnectionError =
|
||||
"You do not have the correct version of "@$appName@" or "@
|
||||
"the related art needed to play on this server, please contact "@
|
||||
"the server administrator.";
|
||||
|
||||
// The network port is also defined by the client, this value
|
||||
// overrides pref::net::port for dedicated servers
|
||||
$Pref::Server::Port = 28000;
|
||||
|
||||
// If the password is set, clients must provide it in order
|
||||
// to connect to the server
|
||||
$Pref::Server::Password = "";
|
||||
|
||||
// Password for admin clients
|
||||
$Pref::Server::AdminPassword = "";
|
||||
|
||||
// Misc server settings.
|
||||
$Pref::Server::MaxPlayers = 64;
|
||||
$Pref::Server::TimeLimit = 20; // In minutes
|
||||
$Pref::Server::KickBanTime = 300; // specified in seconds
|
||||
$Pref::Server::BanTime = 1800; // specified in seconds
|
||||
$Pref::Server::FloodProtectionEnabled = 1;
|
||||
$Pref::Server::MaxChatLen = 120;
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Mission Loading
|
||||
// The server portion of the client/server mission loading process
|
||||
//-----------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------
|
||||
// Loading Phases:
|
||||
// Phase 1: Transmit Datablocks
|
||||
// Transmit targets
|
||||
// Phase 2: Transmit Ghost Objects
|
||||
// Phase 3: Start Game
|
||||
//
|
||||
// The server invokes the client MissionStartPhase[1-3] function to request
|
||||
// permission to start each phase. When a client is ready for a phase,
|
||||
// it responds with MissionStartPhase[1-3]Ack.
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Phase 1
|
||||
//----------------------------------------------------------------------------
|
||||
function GameConnection::loadMission(%this)
|
||||
{
|
||||
// Send over the information that will display the server info
|
||||
// when we learn it got there, we'll send the data blocks
|
||||
%this.currentPhase = 0;
|
||||
if (%this.isAIControlled())
|
||||
{
|
||||
// Cut to the chase...
|
||||
theLevelInfo.onEnterGame(%this);
|
||||
}
|
||||
else
|
||||
{
|
||||
commandToClient(%this, 'MissionStartPhase1', $missionSequence, $Server::MissionFile);
|
||||
|
||||
echo("*** Sending mission load to client: " @ $Server::MissionFile);
|
||||
}
|
||||
}
|
||||
|
||||
function serverCmdMissionStartPhase1Ack(%client, %seq)
|
||||
{
|
||||
// Make sure to ignore calls from a previous mission load
|
||||
if (%seq != $missionSequence || !$MissionRunning || %client.currentPhase != 0)
|
||||
return;
|
||||
|
||||
%client.currentPhase = 1;
|
||||
|
||||
// Start with the CRC
|
||||
%client.setMissionCRC( $missionCRC );
|
||||
|
||||
// Send over the datablocks...
|
||||
// OnDataBlocksDone will get called when have confirmation
|
||||
// that they've all been received.
|
||||
%client.transmitDataBlocks($missionSequence);
|
||||
}
|
||||
|
||||
function GameConnection::onDataBlocksDone( %this, %missionSequence )
|
||||
{
|
||||
// Make sure to ignore calls from a previous mission load
|
||||
if (%missionSequence != $missionSequence || %this.currentPhase != 1)
|
||||
return;
|
||||
|
||||
%this.currentPhase = 1.5;
|
||||
|
||||
// On to the next phase
|
||||
commandToClient(%this, 'MissionStartPhase2', $missionSequence, $Server::MissionFile);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Phase 2
|
||||
//----------------------------------------------------------------------------
|
||||
function serverCmdMissionStartPhase2Ack(%client, %seq)
|
||||
{
|
||||
// Make sure to ignore calls from a previous mission load
|
||||
if (%seq != $missionSequence || !$MissionRunning || %client.currentPhase != 1.5)
|
||||
return;
|
||||
|
||||
%client.currentPhase = 2;
|
||||
|
||||
// Update mod paths, this needs to get there before the objects.
|
||||
%client.transmitPaths();
|
||||
|
||||
// Start ghosting objects to the client
|
||||
%client.activateGhosting();
|
||||
}
|
||||
|
||||
function GameConnection::clientWantsGhostAlwaysRetry(%client)
|
||||
{
|
||||
if($MissionRunning)
|
||||
%client.activateGhosting();
|
||||
}
|
||||
|
||||
function GameConnection::onGhostAlwaysFailed(%client)
|
||||
{
|
||||
}
|
||||
|
||||
function GameConnection::onGhostAlwaysObjectsReceived(%client)
|
||||
{
|
||||
// Ready for next phase.
|
||||
commandToClient(%client, 'MissionStartPhase3', $missionSequence, $Server::MissionFile);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Phase 3
|
||||
//----------------------------------------------------------------------------
|
||||
function serverCmdMissionStartPhase3Ack(%client, %seq)
|
||||
{
|
||||
// Make sure to ignore calls from a previous mission load
|
||||
if(%seq != $missionSequence || !$MissionRunning || %client.currentPhase != 2)
|
||||
return;
|
||||
|
||||
%client.currentPhase = 3;
|
||||
|
||||
// Server is ready to drop into the game
|
||||
|
||||
//Have any special game-play handling here
|
||||
if(theLevelInfo.isMethod("onClientEnterGame"))
|
||||
{
|
||||
theLevelInfo.onClientEnterGame(%client);
|
||||
}
|
||||
else
|
||||
{
|
||||
//No Game mode class for the level info, so just spawn a default camera
|
||||
// Set the control object to the default camera
|
||||
if (!isObject(%client.camera))
|
||||
{
|
||||
if(!isObject(Observer))
|
||||
{
|
||||
datablock CameraData(Observer)
|
||||
{
|
||||
mode = "Observer";
|
||||
};
|
||||
}
|
||||
|
||||
if (isDefined("$Game::DefaultCameraClass"))
|
||||
%client.camera = spawnObject("Camera", Observer);
|
||||
}
|
||||
|
||||
// If we have a camera then set up some properties
|
||||
if (isObject(%client.camera))
|
||||
{
|
||||
MissionCleanup.add( %this.camera );
|
||||
%client.camera.scopeToClient(%client);
|
||||
|
||||
%client.setControlObject(%client.camera);
|
||||
|
||||
%client.camera.setTransform("0 0 1 0 0 0 0");
|
||||
}
|
||||
}
|
||||
|
||||
%client.startMission();
|
||||
}
|
||||
|
|
@ -0,0 +1,197 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Loading info is text displayed on the client side while the mission
|
||||
// is being loaded. This information is extracted from the mission file
|
||||
// and sent to each the client as it joins.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// clearLoadInfo
|
||||
//
|
||||
// Clears the mission info stored
|
||||
//------------------------------------------------------------------------------
|
||||
function clearLoadInfo()
|
||||
{
|
||||
if (isObject(theLevelInfo))
|
||||
theLevelInfo.delete();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// buildLoadInfo
|
||||
//
|
||||
// Extract the map description from the .mis file
|
||||
//------------------------------------------------------------------------------
|
||||
function buildLoadInfo( %mission )
|
||||
{
|
||||
clearLoadInfo();
|
||||
|
||||
%infoObject = "";
|
||||
%file = new FileObject();
|
||||
|
||||
if ( %file.openForRead( %mission ) ) {
|
||||
%inInfoBlock = false;
|
||||
|
||||
while ( !%file.isEOF() ) {
|
||||
%line = %file.readLine();
|
||||
%line = trim( %line );
|
||||
|
||||
if( %line $= "new ScriptObject(MissionInfo) {" )
|
||||
%inInfoBlock = true;
|
||||
else if( %line $= "new LevelInfo(theLevelInfo) {" )
|
||||
%inInfoBlock = true;
|
||||
else if( %inInfoBlock && %line $= "};" ) {
|
||||
%inInfoBlock = false;
|
||||
%infoObject = %infoObject @ %line;
|
||||
break;
|
||||
}
|
||||
|
||||
if( %inInfoBlock )
|
||||
%infoObject = %infoObject @ %line @ " ";
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
else
|
||||
error("Level file " @ %mission @ " not found.");
|
||||
|
||||
// Will create the object "MissionInfo"
|
||||
eval( %infoObject );
|
||||
%file.delete();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// dumpLoadInfo
|
||||
//
|
||||
// Echo the mission information to the console
|
||||
//------------------------------------------------------------------------------
|
||||
function dumpLoadInfo()
|
||||
{
|
||||
echo( "Level Name: " @ theLevelInfo.name );
|
||||
echo( "Level Description:" );
|
||||
|
||||
for( %i = 0; theLevelInfo.desc[%i] !$= ""; %i++ )
|
||||
echo (" " @ theLevelInfo.desc[%i]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// sendLoadInfoToClient
|
||||
//
|
||||
// Sends mission description to the client
|
||||
//------------------------------------------------------------------------------
|
||||
function sendLoadInfoToClient( %client )
|
||||
{
|
||||
messageClient( %client, 'MsgLoadInfo', "", theLevelInfo.levelName );
|
||||
|
||||
// Send Mission Description a line at a time
|
||||
for( %i = 0; theLevelInfo.desc[%i] !$= ""; %i++ )
|
||||
messageClient( %client, 'MsgLoadDescripition', "", theLevelInfo.desc[%i] );
|
||||
|
||||
messageClient( %client, 'MsgLoadInfoDone' );
|
||||
}
|
||||
|
||||
// A function used in order to easily parse the MissionGroup for classes . I'm pretty
|
||||
// sure at this point the function can be easily modified to search the any group as well.
|
||||
function parseMissionGroup( %className, %childGroup )
|
||||
{
|
||||
if( getWordCount( %childGroup ) == 0)
|
||||
%currentGroup = "MissionGroup";
|
||||
else
|
||||
%currentGroup = %childGroup;
|
||||
|
||||
for(%i = 0; %i < (%currentGroup).getCount(); %i++)
|
||||
{
|
||||
if( (%currentGroup).getObject(%i).getClassName() $= %className )
|
||||
return true;
|
||||
|
||||
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
|
||||
{
|
||||
if( parseMissionGroup( %className, (%currentGroup).getObject(%i).getId() ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
function parseMissionGroupForIds( %className, %childGroup )
|
||||
{
|
||||
if( getWordCount( %childGroup ) == 0)
|
||||
%currentGroup = $Game::MissionGroup;
|
||||
else
|
||||
%currentGroup = %childGroup;
|
||||
|
||||
for(%i = 0; %i < (%currentGroup).getCount(); %i++)
|
||||
{
|
||||
if( (%currentGroup).getObject(%i).getClassName() $= %className )
|
||||
%classIds = %classIds @ (%currentGroup).getObject(%i).getId() @ " ";
|
||||
|
||||
if( (%currentGroup).getObject(%i).getClassName() $= "SimGroup" )
|
||||
%classIds = %classIds @ parseMissionGroupForIds( %className, (%currentGroup).getObject(%i).getId());
|
||||
}
|
||||
return %classIds;
|
||||
}
|
||||
|
||||
function getLevelInfo( %missionFile )
|
||||
{
|
||||
clearLoadInfo();
|
||||
|
||||
%file = new FileObject();
|
||||
|
||||
%LevelInfoObject = "";
|
||||
|
||||
if ( %file.openForRead( %missionFile ) ) {
|
||||
%inInfoBlock = false;
|
||||
|
||||
while ( !%file.isEOF() ) {
|
||||
%line = %file.readLine();
|
||||
%line = trim( %line );
|
||||
|
||||
if( %line $= "new ScriptObject(LevelInfo) {" )
|
||||
%inInfoBlock = true;
|
||||
else if( %line $= "new LevelInfo(theLevelInfo) {" )
|
||||
%inInfoBlock = true;
|
||||
else if( %inInfoBlock && %line $= "};" ) {
|
||||
%inInfoBlock = false;
|
||||
%LevelInfoObject = %LevelInfoObject @ %line;
|
||||
break;
|
||||
}
|
||||
|
||||
if( %inInfoBlock )
|
||||
%LevelInfoObject = %LevelInfoObject @ %line @ " ";
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
%file.delete();
|
||||
|
||||
if( %LevelInfoObject !$= "" )
|
||||
{
|
||||
%LevelInfoObject = "%LevelInfoObject = " @ %LevelInfoObject;
|
||||
eval( %LevelInfoObject );
|
||||
|
||||
return %LevelInfoObject;
|
||||
}
|
||||
|
||||
// Didn't find our LevelInfo
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Mission Loading
|
||||
// The server portion of the client/server mission loading process
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// Server mission loading
|
||||
//-----------------------------------------------------------------------------
|
||||
// On every mission load except the first, there is a pause after
|
||||
// the initial mission info is downloaded to the client.
|
||||
$MissionLoadPause = 5000;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//This is the first call made by the server to kick the loading process off
|
||||
function loadMission( %missionName, %isFirstMission )
|
||||
{
|
||||
endMission();
|
||||
echo("*** LOADING MISSION: " @ %missionName);
|
||||
echo("*** Stage 1 load");
|
||||
|
||||
// increment the mission sequence (used for ghost sequencing)
|
||||
$missionSequence++;
|
||||
$missionRunning = false;
|
||||
$Server::MissionFile = %missionName;
|
||||
$Server::LoadFailMsg = "";
|
||||
|
||||
// Extract mission info from the mission file,
|
||||
// including the display name and stuff to send
|
||||
// to the client.
|
||||
buildLoadInfo( %missionName );
|
||||
|
||||
// Download mission info to the clients
|
||||
%count = ClientGroup.getCount();
|
||||
for( %cl = 0; %cl < %count; %cl++ )
|
||||
{
|
||||
%client = ClientGroup.getObject( %cl );
|
||||
|
||||
if (!%client.isAIControlled())
|
||||
sendLoadInfoToClient(%client);
|
||||
}
|
||||
|
||||
// Now that we've sent the LevelInfo to the clients
|
||||
// clear it so that it won't conflict with the actual
|
||||
// LevelInfo loaded in the level
|
||||
clearLoadInfo();
|
||||
|
||||
// if this isn't the first mission, allow some time for the server
|
||||
// to transmit information to the clients:
|
||||
if( %isFirstMission || $Server::ServerType $= "SinglePlayer" )
|
||||
loadMissionStage2();
|
||||
else
|
||||
schedule( $MissionLoadPause, ServerGroup, loadMissionStage2 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function loadMissionStage2()
|
||||
{
|
||||
echo("*** Stage 2 load");
|
||||
|
||||
// Create the mission group off the ServerGroup
|
||||
$instantGroup = ServerGroup;
|
||||
|
||||
// Make sure the mission exists
|
||||
%file = $Server::MissionFile;
|
||||
|
||||
if( !isFile( %file ) )
|
||||
{
|
||||
$Server::LoadFailMsg = "Could not find mission \"" @ %file @ "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate the mission CRC. The CRC is used by the clients
|
||||
// to caching mission lighting.
|
||||
$missionCRC = getFileCRC( %file );
|
||||
|
||||
// Exec the mission. The MissionGroup (loaded components) is added to the ServerGroup
|
||||
exec(%file);
|
||||
|
||||
if( !isObject(MissionGroup) )
|
||||
{
|
||||
$Server::LoadFailMsg = "No 'MissionGroup' found in mission \"" @ %file @ "\".";
|
||||
}
|
||||
}
|
||||
|
||||
if( $Server::LoadFailMsg !$= "" )
|
||||
{
|
||||
// Inform clients that are already connected
|
||||
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
|
||||
messageClient(ClientGroup.getObject(%clientIndex), 'MsgLoadFailed', $Server::LoadFailMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set mission name.
|
||||
if( isObject( theLevelInfo ) )
|
||||
$Server::MissionName = theLevelInfo.levelName;
|
||||
|
||||
// Mission cleanup group. This is where run time components will reside. The MissionCleanup
|
||||
// group will be added to the ServerGroup.
|
||||
new SimGroup( MissionCleanup );
|
||||
|
||||
// Make the MissionCleanup group the place where all new objects will automatically be added.
|
||||
$instantGroup = MissionCleanup;
|
||||
|
||||
// Construct MOD paths
|
||||
pathOnMissionLoadDone();
|
||||
|
||||
// Mission loading done...
|
||||
echo("*** Mission loaded");
|
||||
|
||||
// Start all the clients in the mission
|
||||
$missionRunning = true;
|
||||
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ )
|
||||
ClientGroup.getObject(%clientIndex).loadMission();
|
||||
|
||||
// Go ahead and launch the game
|
||||
if(TheLevelInfo.isMethod("onMissionStart"))
|
||||
TheLevelInfo.onMissionStart();
|
||||
}
|
||||
|
||||
function endMission()
|
||||
{
|
||||
if (!isObject( MissionGroup ))
|
||||
return;
|
||||
|
||||
echo("*** ENDING MISSION");
|
||||
|
||||
// Inform the game code we're done.
|
||||
TheLevelInfo.onMissionEnded();
|
||||
|
||||
// Inform the clients
|
||||
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) {
|
||||
// clear ghosts and paths from all clients
|
||||
%cl = ClientGroup.getObject( %clientIndex );
|
||||
%cl.endMission();
|
||||
%cl.resetGhosting();
|
||||
%cl.clearPaths();
|
||||
}
|
||||
|
||||
// Delete everything
|
||||
MissionGroup.delete();
|
||||
MissionCleanup.delete();
|
||||
|
||||
clearServerPaths();
|
||||
}
|
||||
|
||||
function resetMission()
|
||||
{
|
||||
echo("*** MISSION RESET");
|
||||
|
||||
// Remove any temporary mission objects
|
||||
MissionCleanup.delete();
|
||||
$instantGroup = ServerGroup;
|
||||
new SimGroup( MissionCleanup );
|
||||
$instantGroup = MissionCleanup;
|
||||
|
||||
clearServerPaths();
|
||||
//
|
||||
TheLevelInfo.onMissionReset();
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
function messageClient(%client, %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10, %a11, %a12, %a13)
|
||||
{
|
||||
commandToClient(%client, 'ServerMessage', %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10, %a11, %a12, %a13);
|
||||
}
|
||||
|
||||
function messageAll(%msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10, %a11, %a12, %a13)
|
||||
{
|
||||
%count = ClientGroup.getCount();
|
||||
for(%cl = 0; %cl < %count; %cl++)
|
||||
{
|
||||
%client = ClientGroup.getObject(%cl);
|
||||
messageClient(%client, %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10, %a11, %a12, %a13);
|
||||
}
|
||||
}
|
||||
|
||||
function messageAllExcept(%client, %team, %msgtype, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10, %a11, %a12, %a13)
|
||||
{
|
||||
//can exclude a client, a team or both. A -1 value in either field will ignore that exclusion, so
|
||||
//messageAllExcept(-1, -1, $Mesblah, 'Blah!'); will message everyone (since there shouldn't be a client -1 or client on team -1).
|
||||
%count = ClientGroup.getCount();
|
||||
for(%cl= 0; %cl < %count; %cl++)
|
||||
{
|
||||
%recipient = ClientGroup.getObject(%cl);
|
||||
if((%recipient != %client) && (%recipient.team != %team))
|
||||
messageClient(%recipient, %msgType, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10, %a11, %a12, %a13);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,291 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function initServer()
|
||||
{
|
||||
echo("\n--------- Initializing " @ $appName @ ": Server Scripts ---------");
|
||||
|
||||
//load prefs
|
||||
%prefPath = getPrefpath();
|
||||
if ( isFile( %prefPath @ "/serverPrefs.cs" ) )
|
||||
exec( %prefPath @ "/serverPrefs.cs" );
|
||||
else
|
||||
exec( "data/clientServer/scripts/server/defaults.cs" );
|
||||
|
||||
exec( "data/clientServer/scripts/server/audio.cs" );
|
||||
exec( "data/clientServer/scripts/server/commands.cs" );
|
||||
exec( "data/clientServer/scripts/server/message.cs" );
|
||||
exec( "data/clientServer/scripts/server/levelDownload.cs" );
|
||||
exec( "data/clientServer/scripts/server/levelLoad.cs" );
|
||||
exec( "data/clientServer/scripts/server/levelInfo.cs" );
|
||||
exec( "data/clientServer/scripts/server/connectionToClient.cs" );
|
||||
|
||||
// Server::Status is returned in the Game Info Query and represents the
|
||||
// current status of the server. This string sould be very short.
|
||||
$Server::Status = "Unknown";
|
||||
|
||||
// Turn on testing/debug script functions
|
||||
$Server::TestCheats = false;
|
||||
|
||||
// Specify where the mission files are.
|
||||
$Server::MissionFileSpec = "data/levels/*.mis";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
function initDedicated()
|
||||
{
|
||||
enableWinConsole(true);
|
||||
echo("\n--------- Starting Dedicated Server ---------");
|
||||
|
||||
// Make sure this variable reflects the correct state.
|
||||
$Server::Dedicated = true;
|
||||
|
||||
// The server isn't started unless a mission has been specified.
|
||||
if ($missionArg !$= "") {
|
||||
createServer("MultiPlayer", $missionArg);
|
||||
}
|
||||
else
|
||||
echo("No mission specified (use -mission filename)");
|
||||
}
|
||||
|
||||
/// Attempt to find an open port to initialize the server with
|
||||
function portInit(%port)
|
||||
{
|
||||
%failCount = 0;
|
||||
while(%failCount < 10 && !setNetPort(%port))
|
||||
{
|
||||
echo("Port init failed on port " @ %port @ " trying next port.");
|
||||
%port++; %failCount++;
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a server of the given type, load the given level, and then
|
||||
/// create a local client connection to the server.
|
||||
//
|
||||
/// @return true if successful.
|
||||
function createAndConnectToLocalServer( %serverType, %level )
|
||||
{
|
||||
if( !createServer( %serverType, %level ) )
|
||||
return false;
|
||||
|
||||
%conn = new GameConnection( ServerConnection );
|
||||
RootGroup.add( ServerConnection );
|
||||
|
||||
%conn.setConnectArgs( $pref::Player::Name );
|
||||
%conn.setJoinPassword( $Client::Password );
|
||||
|
||||
%result = %conn.connectLocal();
|
||||
if( %result !$= "" )
|
||||
{
|
||||
%conn.delete();
|
||||
destroyServer();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Create a server with either a "SinglePlayer" or "MultiPlayer" type
|
||||
/// Specify the level to load on the server
|
||||
function createServer(%serverType, %level)
|
||||
{
|
||||
// Increase the server session number. This is used to make sure we're
|
||||
// working with the server session we think we are.
|
||||
$Server::Session++;
|
||||
|
||||
if (%level $= "")
|
||||
{
|
||||
error("createServer(): level name unspecified");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure our level name is relative so that it can send
|
||||
// across the network correctly
|
||||
%level = makeRelativePath(%level, getWorkingDirectory());
|
||||
|
||||
destroyServer();
|
||||
|
||||
$missionSequence = 0;
|
||||
$Server::PlayerCount = 0;
|
||||
$Server::ServerType = %serverType;
|
||||
$Server::LoadFailMsg = "";
|
||||
$Physics::isSinglePlayer = true;
|
||||
|
||||
// Setup for multi-player, the network must have been
|
||||
// initialized before now.
|
||||
if (%serverType $= "MultiPlayer")
|
||||
{
|
||||
$Physics::isSinglePlayer = false;
|
||||
|
||||
echo("Starting multiplayer mode");
|
||||
|
||||
// Make sure the network port is set to the correct pref.
|
||||
portInit($Pref::Server::Port);
|
||||
allowConnections(true);
|
||||
|
||||
if ($pref::Net::DisplayOnMaster !$= "Never" )
|
||||
schedule(0,0,startHeartbeat);
|
||||
}
|
||||
|
||||
// Let the game initialize some things now that the
|
||||
// the server has been created
|
||||
onServerCreated();
|
||||
|
||||
loadMission(%level, true);
|
||||
|
||||
$Game::running = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function onServerCreated()
|
||||
{
|
||||
// Server::GameType is sent to the master server.
|
||||
// This variable should uniquely identify your game and/or mod.
|
||||
$Server::GameType = $appName;
|
||||
|
||||
// Server::MissionType sent to the master server. Clients can
|
||||
// filter servers based on mission type.
|
||||
// $Server::MissionType = "Deathmatch";
|
||||
|
||||
// GameStartTime is the sim time the game started. Used to calculated
|
||||
// game elapsed time.
|
||||
$Game::StartTime = 0;
|
||||
|
||||
// Create the server physics world.
|
||||
physicsInitWorld( "server" );
|
||||
|
||||
physicsStartSimulation("server");
|
||||
|
||||
%cnt = DatablockFilesList.count();
|
||||
|
||||
loadDatablockFiles( DatablockFilesList, true );
|
||||
|
||||
%cnt = DatablockFilesList.count();
|
||||
|
||||
// Keep track of when the game started
|
||||
$Game::StartTime = $Sim::Time;
|
||||
}
|
||||
|
||||
/// Shut down the server
|
||||
function destroyServer()
|
||||
{
|
||||
$Server::ServerType = "";
|
||||
$Server::Running = false;
|
||||
|
||||
allowConnections(false);
|
||||
stopHeartbeat();
|
||||
$missionRunning = false;
|
||||
|
||||
// End any running levels and shut down the physics sim
|
||||
onServerDestroyed();
|
||||
|
||||
physicsDestroy();
|
||||
|
||||
// Delete all the server objects
|
||||
if (isObject(ServerGroup))
|
||||
ServerGroup.delete();
|
||||
|
||||
// Delete all the connections:
|
||||
while (ClientGroup.getCount())
|
||||
{
|
||||
%client = ClientGroup.getObject(0);
|
||||
%client.delete();
|
||||
}
|
||||
|
||||
$Server::GuidList = "";
|
||||
|
||||
// Delete all the data blocks...
|
||||
deleteDataBlocks();
|
||||
|
||||
// Save any server settings
|
||||
echo( "Exporting server prefs..." );
|
||||
export( "$Pref::Server::*", "data/clientServer/scripts/server/prefs.cs", false );
|
||||
|
||||
// Increase the server session number. This is used to make sure we're
|
||||
// working with the server session we think we are.
|
||||
$Server::Session++;
|
||||
}
|
||||
|
||||
function onServerDestroyed()
|
||||
{
|
||||
physicsStopSimulation("server");
|
||||
|
||||
if (!isObject( MissionGroup ))
|
||||
return;
|
||||
|
||||
echo("*** ENDING MISSION");
|
||||
|
||||
// Inform the game code we're done.
|
||||
if(TheLevelInfo.isMethod("onMissionEnded"))
|
||||
TheLevelInfo.onMissionEnded();
|
||||
|
||||
// Inform the clients
|
||||
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) {
|
||||
// clear ghosts and paths from all clients
|
||||
%cl = ClientGroup.getObject( %clientIndex );
|
||||
%cl.endMission();
|
||||
%cl.resetGhosting();
|
||||
%cl.clearPaths();
|
||||
}
|
||||
|
||||
// Delete everything
|
||||
MissionGroup.delete();
|
||||
MissionCleanup.delete();
|
||||
|
||||
clearServerPaths();
|
||||
}
|
||||
|
||||
/// Guid list maintenance functions
|
||||
function addToServerGuidList( %guid )
|
||||
{
|
||||
%count = getFieldCount( $Server::GuidList );
|
||||
for ( %i = 0; %i < %count; %i++ )
|
||||
{
|
||||
if ( getField( $Server::GuidList, %i ) == %guid )
|
||||
return;
|
||||
}
|
||||
|
||||
$Server::GuidList = $Server::GuidList $= "" ? %guid : $Server::GuidList TAB %guid;
|
||||
}
|
||||
|
||||
function removeFromServerGuidList( %guid )
|
||||
{
|
||||
%count = getFieldCount( $Server::GuidList );
|
||||
for ( %i = 0; %i < %count; %i++ )
|
||||
{
|
||||
if ( getField( $Server::GuidList, %i ) == %guid )
|
||||
{
|
||||
$Server::GuidList = removeField( $Server::GuidList, %i );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// When the server is queried for information, the value of this function is
|
||||
/// returned as the status field of the query packet. This information is
|
||||
/// accessible as the ServerInfo::State variable.
|
||||
function onServerInfoQuery()
|
||||
{
|
||||
return "Doing Ok";
|
||||
}
|
||||
218
Templates/BaseGame/game/data/defaults.cs
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
$pref::Player::Name = "Visitor";
|
||||
$pref::Player::defaultFov = 75;
|
||||
$pref::Player::zoomSpeed = 0;
|
||||
|
||||
$pref::Net::LagThreshold = 400;
|
||||
$pref::Net::Port = 28000;
|
||||
|
||||
$pref::HudMessageLogSize = 40;
|
||||
$pref::ChatHudLength = 1;
|
||||
|
||||
$pref::Input::LinkMouseSensitivity = 1;
|
||||
// DInput keyboard, mouse, and joystick prefs
|
||||
$pref::Input::KeyboardEnabled = 1;
|
||||
$pref::Input::MouseEnabled = 1;
|
||||
$pref::Input::JoystickEnabled = 0;
|
||||
$pref::Input::KeyboardTurnSpeed = 0.1;
|
||||
$pref::Input::invertVerticalMouse = false;
|
||||
$pref::Input::VertMouseSensitivity = 1;
|
||||
$pref::Input::HorzMouseSensitivity = 1;
|
||||
$pref::Input::RollMouseSensitivity = 1;
|
||||
$pref::Input::ZoomVertMouseSensitivity = 0.3;
|
||||
$pref::Input::ZoomHorzMouseSensitivity = 0.3;
|
||||
|
||||
$sceneLighting::cacheSize = 20000;
|
||||
$sceneLighting::purgeMethod = "lastCreated";
|
||||
$sceneLighting::cacheLighting = 1;
|
||||
|
||||
$pref::Video::displayDevice = "D3D9";
|
||||
$pref::Video::disableVerticalSync = 1;
|
||||
$pref::Video::Resolution = "1024 768";
|
||||
$pref::Video::FullScreen = false;
|
||||
$pref::Video::BitDepth = "32";
|
||||
$pref::Video::RefreshRate = "60";
|
||||
$pref::Video::AA = "4";
|
||||
$pref::Video::defaultFenceCount = 0;
|
||||
$pref::Video::screenShotSession = 0;
|
||||
$pref::Video::screenShotFormat = "PNG";
|
||||
|
||||
/// This disables the hardware FSAA/MSAA so that
|
||||
/// we depend completely on the FXAA post effect
|
||||
/// which works on all cards and in deferred mode.
|
||||
///
|
||||
/// Note the new Intel Hybrid graphics on laptops
|
||||
/// will fail to initialize when hardware AA is
|
||||
/// enabled... so you've been warned.
|
||||
///
|
||||
$pref::Video::disableHardwareAA = true;
|
||||
|
||||
$pref::Video::disableNormalmapping = false;
|
||||
|
||||
$pref::Video::disablePixSpecular = false;
|
||||
|
||||
$pref::Video::disableCubemapping = false;
|
||||
|
||||
///
|
||||
$pref::Video::disableParallaxMapping = false;
|
||||
|
||||
$pref::Video::Gamma = 2.2;
|
||||
$pref::Video::Contrast = 1.0;
|
||||
$pref::Video::Brightness = 0;
|
||||
|
||||
/// The perfered light manager to use at startup. If blank
|
||||
/// or if the selected one doesn't work on this platfom it
|
||||
/// will try the defaults below.
|
||||
$pref::lightManager = "";
|
||||
|
||||
/// This is the default list of light managers ordered from
|
||||
/// most to least desirable for initialization.
|
||||
$lightManager::defaults = "Advanced Lighting";
|
||||
|
||||
/// A scale to apply to the camera view distance
|
||||
/// typically used for tuning performance.
|
||||
$pref::camera::distanceScale = 1.0;
|
||||
|
||||
/// Causes the system to do a one time autodetect
|
||||
/// of an SFX provider and device at startup if the
|
||||
/// provider is unset.
|
||||
$pref::SFX::autoDetect = true;
|
||||
|
||||
/// The sound provider to select at startup. Typically
|
||||
/// this is DirectSound, OpenAL, or XACT. There is also
|
||||
/// a special Null provider which acts normally, but
|
||||
/// plays no sound.
|
||||
$pref::SFX::provider = "";
|
||||
|
||||
/// The sound device to select from the provider. Each
|
||||
/// provider may have several different devices.
|
||||
$pref::SFX::device = "OpenAL";
|
||||
|
||||
/// If true the device will try to use hardware buffers
|
||||
/// and sound mixing. If not it will use software.
|
||||
$pref::SFX::useHardware = false;
|
||||
|
||||
/// If you have a software device you have a
|
||||
/// choice of how many software buffers to
|
||||
/// allow at any one time. More buffers cost
|
||||
/// more CPU time to process and mix.
|
||||
$pref::SFX::maxSoftwareBuffers = 16;
|
||||
|
||||
/// This is the playback frequency for the primary
|
||||
/// sound buffer used for mixing. Although most
|
||||
/// providers will reformat on the fly, for best
|
||||
/// quality and performance match your sound files
|
||||
/// to this setting.
|
||||
$pref::SFX::frequency = 44100;
|
||||
|
||||
/// This is the playback bitrate for the primary
|
||||
/// sound buffer used for mixing. Although most
|
||||
/// providers will reformat on the fly, for best
|
||||
/// quality and performance match your sound files
|
||||
/// to this setting.
|
||||
$pref::SFX::bitrate = 32;
|
||||
|
||||
/// The overall system volume at startup. Note that
|
||||
/// you can only scale volume down, volume does not
|
||||
/// get louder than 1.
|
||||
$pref::SFX::masterVolume = 0.8;
|
||||
|
||||
/// The startup sound channel volumes. These are
|
||||
/// used to control the overall volume of different
|
||||
/// classes of sounds.
|
||||
$pref::SFX::channelVolume1 = 1;
|
||||
$pref::SFX::channelVolume2 = 1;
|
||||
$pref::SFX::channelVolume3 = 1;
|
||||
$pref::SFX::channelVolume4 = 1;
|
||||
$pref::SFX::channelVolume5 = 1;
|
||||
$pref::SFX::channelVolume6 = 1;
|
||||
$pref::SFX::channelVolume7 = 1;
|
||||
$pref::SFX::channelVolume8 = 1;
|
||||
|
||||
$pref::SFX::channelVolume[1] = 1;
|
||||
$pref::SFX::channelVolume[2] = 1;
|
||||
$pref::SFX::channelVolume[3] = 1;
|
||||
$pref::SFX::channelVolume[4] = 1;
|
||||
|
||||
$pref::PostEffect::PreferedHDRFormat = "GFXFormatR8G8B8A8";
|
||||
|
||||
/// This is an scalar which can be used to reduce the
|
||||
/// reflection textures on all objects to save fillrate.
|
||||
$pref::Reflect::refractTexScale = 1.0;
|
||||
|
||||
/// This is the total frame in milliseconds to budget for
|
||||
/// reflection rendering. If your CPU bound and have alot
|
||||
/// of smaller reflection surfaces try reducing this time.
|
||||
$pref::Reflect::frameLimitMS = 10;
|
||||
|
||||
/// Set true to force all water objects to use static cubemap reflections.
|
||||
$pref::Water::disableTrueReflections = false;
|
||||
|
||||
// A global LOD scalar which can reduce the overall density of placed GroundCover.
|
||||
$pref::GroundCover::densityScale = 1.0;
|
||||
|
||||
/// An overall scaler on the lod switching between DTS models.
|
||||
/// Smaller numbers makes the lod switch sooner.
|
||||
$pref::TS::detailAdjust = 1.0;
|
||||
|
||||
///
|
||||
$pref::Decals::enabled = true;
|
||||
|
||||
///
|
||||
$pref::Decals::lifeTimeScale = "1";
|
||||
|
||||
/// The number of mipmap levels to drop on loaded textures
|
||||
/// to reduce video memory usage.
|
||||
///
|
||||
/// It will skip any textures that have been defined as not
|
||||
/// allowing down scaling.
|
||||
///
|
||||
$pref::Video::textureReductionLevel = 0;
|
||||
|
||||
///
|
||||
$pref::Shadows::textureScalar = 1.0;
|
||||
|
||||
///
|
||||
$pref::Shadows::disable = false;
|
||||
|
||||
/// Sets the shadow filtering mode.
|
||||
///
|
||||
/// None - Disables filtering.
|
||||
///
|
||||
/// SoftShadow - Does a simple soft shadow
|
||||
///
|
||||
/// SoftShadowHighQuality
|
||||
///
|
||||
$pref::Shadows::filterMode = "SoftShadow";
|
||||
|
||||
///
|
||||
$pref::Video::defaultAnisotropy = 1;
|
||||
|
||||
/// Radius in meters around the camera that ForestItems are affected by wind.
|
||||
/// Note that a very large number with a large number of items is not cheap.
|
||||
$pref::windEffectRadius = 25;
|
||||
|
||||
/// AutoDetect graphics quality levels the next startup.
|
||||
$pref::Video::autoDetect = 1;
|
||||
|
||||
$PostFXManager::Settings::EnableDOF = "0";
|
||||
$PostFXManager::Settings::DOF::BlurCurveFar = "";
|
||||
$PostFXManager::Settings::DOF::BlurCurveNear = "";
|
||||
$PostFXManager::Settings::DOF::BlurMax = "";
|
||||
$PostFXManager::Settings::DOF::BlurMin = "";
|
||||
$PostFXManager::Settings::DOF::EnableAutoFocus = "";
|
||||
$PostFXManager::Settings::DOF::EnableDOF = "";
|
||||
$PostFXManager::Settings::DOF::FocusRangeMax = "";
|
||||
$PostFXManager::Settings::DOF::FocusRangeMin = "";
|
||||
|
||||
$PostFXManager::Settings::EnableLightRays = "0";
|
||||
$PostFXManager::Settings::LightRays::brightScalar = "0.75";
|
||||
$PostFXManager::Settings::LightRays::decay = "1.0";
|
||||
$PostFXManager::Settings::LightRays::density = "0.94";
|
||||
$PostFXManager::Settings::LightRays::numSamples = "40";
|
||||
$PostFXManager::Settings::LightRays::weight = "5.65";
|
||||
|
||||
$PostFXManager::Settings::EnableDOF = 1;
|
||||
$pref::PostFX::EnableVignette = 1;
|
||||
$pref::PostFX::EnableLightRays = 1;
|
||||
$pref::PostFX::EnableHDR = 1;
|
||||
$pref::PostFX::EnableSSAO = 1;
|
||||
BIN
Templates/BaseGame/game/data/postFX/art/AreaMap33.dds
Normal file
BIN
Templates/BaseGame/game/data/postFX/art/caustics_1.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
Templates/BaseGame/game/data/postFX/art/caustics_2.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
Templates/BaseGame/game/data/postFX/art/noise.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Templates/BaseGame/game/data/postFX/art/null_color_ramp.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
45
Templates/BaseGame/game/data/postFX/postFX.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
// The general flow of a gane - server's creation, loading and hosting clients, and then destruction is as follows:
|
||||
|
||||
// First, a client will always create a server in the event that they want to host a single player
|
||||
// game. Torque3D treats even single player connections as a soft multiplayer game, with some stuff
|
||||
// in the networking short-circuited to sidestep around lag and packet transmission times.
|
||||
|
||||
// initServer() is called, loading the default server scripts.
|
||||
// After that, if this is a dedicated server session, initDedicated() is called, otherwise initClient is called
|
||||
// to prep a playable client session.
|
||||
|
||||
// When a local game is started - a listen server - via calling StartGame() a server is created and then the client is
|
||||
// connected to it via createAndConnectToLocalServer().
|
||||
|
||||
function PostFX::create( %this )
|
||||
{
|
||||
echo("\n--------- Initializing PostFX Directory: scripts ---------");
|
||||
|
||||
// Start up in either client, or dedicated server mode
|
||||
if (!$Server::Dedicated)
|
||||
{
|
||||
//postFX stuffs
|
||||
exec("./scripts/gui/postFxManager.gui");
|
||||
|
||||
//init the postFX
|
||||
%pattern = "./scripts/client/*.cs";
|
||||
%file = findFirstFile( %pattern );
|
||||
if ( %file $= "" )
|
||||
{
|
||||
// Try for DSOs next.
|
||||
%pattern = "./scripts/client/*.cs.dso";
|
||||
%file = findFirstFile( %pattern );
|
||||
}
|
||||
|
||||
while( %file !$= "" )
|
||||
{
|
||||
exec( %file );
|
||||
%file = findNextFile( %pattern );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function PostFX::destroy( %this )
|
||||
{
|
||||
}
|
||||
9
Templates/BaseGame/game/data/postFX/postFX.module
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<ModuleDefinition
|
||||
ModuleId="PostFX"
|
||||
VersionId="1"
|
||||
Description="Default PostFX elements"
|
||||
ScriptFile="postFX.cs"
|
||||
CreateFunction="create"
|
||||
DestroyFunction="destroy"
|
||||
Group="Game">
|
||||
</ModuleDefinition>
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( GammaShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFx/gammaP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFx/gl/gammaP.glsl";
|
||||
|
||||
samplerNames[0] = "$backBuffer";
|
||||
samplerNames[1] = "$colorCorrectionTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( GammaStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton PostEffect( GammaPostFX )
|
||||
{
|
||||
isEnabled = true;
|
||||
allowReflectPass = true;
|
||||
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "EditorBin";
|
||||
renderPriority = 9999;
|
||||
|
||||
shader = GammaShader;
|
||||
stateBlock = GammaStateBlock;
|
||||
|
||||
texture[0] = "$backBuffer";
|
||||
texture[1] = $HDRPostFX::colorCorrectionRamp;
|
||||
|
||||
targetFormat = getBestHDRFormat();
|
||||
};
|
||||
|
||||
function GammaPostFX::preProcess( %this )
|
||||
{
|
||||
if ( %this.texture[1] !$= $HDRPostFX::colorCorrectionRamp )
|
||||
%this.setTexture( 1, $HDRPostFX::colorCorrectionRamp );
|
||||
}
|
||||
|
||||
function GammaPostFX::setShaderConsts( %this )
|
||||
{
|
||||
%clampedGamma = mClamp( $pref::Video::Gamma, 2.0, 2.5);
|
||||
%this.setShaderConst( "$OneOverGamma", 1 / %clampedGamma );
|
||||
%this.setShaderConst( "$Brightness", $pref::Video::Brightness );
|
||||
%this.setShaderConst( "$Contrast", $pref::Video::Contrast );
|
||||
}
|
||||
186
Templates/BaseGame/game/data/postFX/scripts/client/MLAA.cs
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// An implementation of "Practical Morphological Anti-Aliasing" from
|
||||
// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria,
|
||||
// Fernando Navarro, and Diego Gutierrez.
|
||||
//
|
||||
// http://www.iryoku.com/mlaa/
|
||||
|
||||
// NOTE: This is currently disabled in favor of FXAA. See
|
||||
// core\scripts\client\canvas.cs if you want to re-enable it.
|
||||
|
||||
singleton GFXStateBlockData( MLAA_EdgeDetectStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
// Mark the edge pixels in stencil.
|
||||
stencilDefined = true;
|
||||
stencilEnable = true;
|
||||
stencilPassOp = GFXStencilOpReplace;
|
||||
stencilFunc = GFXCmpAlways;
|
||||
stencilRef = 1;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
};
|
||||
|
||||
singleton ShaderData( MLAA_EdgeDetectionShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFx/mlaa/offsetV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFx/mlaa/edgeDetectionP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFx/mlaa/gl/offsetV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFx/mlaa/gl/edgeDetectionP.glsl";
|
||||
|
||||
samplerNames[0] = "$colorMapG";
|
||||
samplerNames[1] = "$prepassMap";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( MLAA_BlendWeightCalculationStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
// Here we want to process only marked pixels.
|
||||
stencilDefined = true;
|
||||
stencilEnable = true;
|
||||
stencilPassOp = GFXStencilOpKeep;
|
||||
stencilFunc = GFXCmpEqual;
|
||||
stencilRef = 1;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
samplerStates[2] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton ShaderData( MLAA_BlendWeightCalculationShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFx/mlaa/passthruV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFx/mlaa/blendWeightCalculationP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFx/mlaa/gl/passthruV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFx/mlaa/gl/blendWeightCalculationP.glsl";
|
||||
|
||||
samplerNames[0] = "$edgesMap";
|
||||
samplerNames[1] = "$edgesMapL";
|
||||
samplerNames[2] = "$areaMap";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( MLAA_NeighborhoodBlendingStateBlock : PFX_DefaultStateBlock )
|
||||
{
|
||||
// Here we want to process only marked pixels too.
|
||||
stencilDefined = true;
|
||||
stencilEnable = true;
|
||||
stencilPassOp = GFXStencilOpKeep;
|
||||
stencilFunc = GFXCmpEqual;
|
||||
stencilRef = 1;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
samplerStates[2] = SamplerClampPoint;
|
||||
};
|
||||
|
||||
singleton ShaderData( MLAA_NeighborhoodBlendingShader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFx/mlaa/offsetV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/postFx/postFx/mlaa/neighborhoodBlendingP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFx/postFx/mlaa/gl/offsetV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFx/postFx/mlaa/gl/neighborhoodBlendingP.glsl";
|
||||
|
||||
samplerNames[0] = "$blendMap";
|
||||
samplerNames[1] = "$colorMapL";
|
||||
samplerNames[2] = "$colorMap";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
|
||||
singleton PostEffect( MLAAFx )
|
||||
{
|
||||
isEnabled = false;
|
||||
|
||||
allowReflectPass = false;
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
|
||||
texture[0] = "$backBuffer"; //colorMapG
|
||||
texture[1] = "#prepass"; // Used for depth detection
|
||||
|
||||
target = "$outTex";
|
||||
targetClear = PFXTargetClear_OnDraw;
|
||||
targetClearColor = "0 0 0 0";
|
||||
|
||||
stateBlock = MLAA_EdgeDetectStateBlock;
|
||||
shader = MLAA_EdgeDetectionShader;
|
||||
|
||||
// The luma calculation weights which can be user adjustable
|
||||
// per-scene if nessasary. The default value of...
|
||||
//
|
||||
// 0.2126 0.7152 0.0722
|
||||
//
|
||||
// ... is the HDTV ITU-R Recommendation BT. 709.
|
||||
lumaCoefficients = "0.2126 0.7152 0.0722";
|
||||
|
||||
// The tweakable color threshold used to select
|
||||
// the range of edge pixels to blend.
|
||||
threshold = 0.1;
|
||||
|
||||
// The depth delta threshold used to select
|
||||
// the range of edge pixels to blend.
|
||||
depthThreshold = 0.01;
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
internalName = "blendingWeightsCalculation";
|
||||
|
||||
target = "$outTex";
|
||||
targetClear = PFXTargetClear_OnDraw;
|
||||
|
||||
shader = MLAA_BlendWeightCalculationShader;
|
||||
stateBlock = MLAA_BlendWeightCalculationStateBlock;
|
||||
|
||||
texture[0] = "$inTex"; // Edges mask
|
||||
texture[1] = "$inTex"; // Edges mask
|
||||
texture[2] = "data/postFX/art/AreaMap33.dds";
|
||||
};
|
||||
|
||||
new PostEffect()
|
||||
{
|
||||
internalName = "neighborhoodBlending";
|
||||
|
||||
shader = MLAA_NeighborhoodBlendingShader;
|
||||
stateBlock = MLAA_NeighborhoodBlendingStateBlock;
|
||||
|
||||
texture[0] = "$inTex"; // Blend weights
|
||||
texture[1] = "$backBuffer";
|
||||
texture[2] = "$backBuffer";
|
||||
};
|
||||
};
|
||||
|
||||
function MLAAFx::setShaderConsts(%this)
|
||||
{
|
||||
%this.setShaderConst("$lumaCoefficients", %this.lumaCoefficients);
|
||||
%this.setShaderConst("$threshold", %this.threshold);
|
||||
%this.setShaderConst("$depthThreshold", %this.depthThreshold);
|
||||
}
|
||||