Makes the graphics menu in the stock UI mostly functional again

Adds sanity check to editing of gameasset script action in asset browser
Updates module template file
Updates visualizers
Fixes checking of popup menu items
Adds stub for TerrainMaterialAsset
This commit is contained in:
Areloch 2019-08-29 00:22:33 -05:00
parent 07b8619bf3
commit d720eb8ccd
163 changed files with 10289 additions and 711 deletions

View file

@ -0,0 +1,105 @@
//This is our create function. It's pointed to, by name, via a field defined in
//the ExampleModule.module file, which contains our module definition. It is called
//when the module is initially loaded by the engine. Generally, only common, base-level
//stuff is created(or destroyed, in the companion function), like things utilized or
//shared on both the client and server, or things that need to be loaded before anything
//else.
function ExampleModule::onCreate(%this)
{
}
//Similar to the create function, this is defined in thye module file, and called
//when the module is destroyed, usually as part of the game shutting down.
function ExampleModule::onDestroy(%this)
{
}
//This is called when the server part of the application is initially created. Torque3D
//assumes, even in a single player context, that there is ultimately a 'server' and a 'client'
//So during initial launch and startup of the engine, the server side is initialized in
//core/clientServer/scripts/server/server.cs - in the initServer() function where this is called.
//This is called on all modules that have this function defined. This is important for
//any persistant parts of the server that always need to run such as gameplay scripts
//
//Importantly, when the gane session server is created, several functions are called to as part of the gamemode logic
//The script below contains the callbacks so the gamemode can actually be set up, but the server-side callbacks in question:
//ExampleGameMode::onMissionStart
//ExampleGameMode::onMissionEnded
//ExampleGameMode::onMissionReset
//Are called during the startup, shut down, and resetting of any and all active gamemodes, as informed by the loaded scenes
//when the game server is processed.
//These callbacks are activated in core/clientServer/scripts/server/levelLoad.cs
function FPSGameplay::initServer(%this)
{
//This script contains our ExampleGameMode logic
exec("./scripts/ExampleGamemodeScript.cs");
}
//This is called when a game session server is actually created so the game may be played. It's called
//from core/clientServer/scripts/server/server.cs - in the createServer() function, which is called when
//A game session is actually launched, and the server is generated so game clients can connect to it.
//This is utilized to set up common things that need to be set up each time the game session server is
//created, such as common variables, datablocks to be transmitted to the client, etc.
function ExampleModule::onCreateGameServer(%this)
{
//In particular, the default client/server module handles the transmission of datablocks from
//server to client automatically as part of the connection and prepping process alongside
//validation and tramission of level objects. It does this in an abstracted way by adding
//the file paths to a master DatablockFilesList array as per below. When the server is created in
//onServerCreated(), it loads the datablocks via this array, and when when the server goes
//to pass data to the client, it iterates over this list and processes it, ensuring all datablocks
//are the most up to date possible for transmission to the connecting client
%this.registerDatablock("./datablocks/ExampleDatablock.cs");
}
//This is called when a game session server is destroyed, when the game shuts down. It's called from
//core/clientServer/scripts/server/server.cs - in the destroyServer() function, which just cleans up anything
//The module may have set up as part of the game server being created.
function ExampleModule::onDestroyGameServer(%this)
{
}
//Similar to initServer, this is called during the initial launch of the application and the client component
//is set up. The difference is that the client may not actually be created, such as in the case for dedicated servers
//Where no UI or gameplay interface is required. It's called from core/clientServer/scripts/client/client.cs -
//in the initClient() function. It sets up common elements that the client will always need, such as scripts, GUIs
//and the like
function ExampleModule::initClient(%this)
{
//client scripts
//Here, we exec out keybind scripts so the player is able to move when they get into a game
exec("./scripts/default.keybinds.cs");
%prefPath = getPrefpath();
if(isFile(%prefPath @ "/keybinds.cs"))
exec(%prefPath @ "/keybinds.cs");
exec("./scripts/inputCommands.cs");
}
//This is called when a game session client successfuly connects to a game server.
//It's called from core/clientServer/scripts/client/connectionToServer.cs - in the GameConnection::onConnectionAccepted() function
//It's used for any client-side specific game session stuff that the client needs to load or pass to the server, such as profile data
//account progress, preferences, etc.
//
//When a client is connected, the gamemode logic also has a callback activated - ExampleGameMode::onClientEnterGame().
function ExampleModule::onCreateClientConnection(%this)
{
//This will push our keybind movemap onto the input stack, so we can control our camera in our ExampleGameMode
ExampleMoveMap.push();
}
//This is called when a client game session disconnects from a game server
//It's called from core/clientServer/scripts/client/connectionToServer.cs - in the disconnectedCleanup() function
//It's used to clean up and potentially write out any client-side stuff that needs housekeeping when disconnecting for any reason.
//It will be called if the connection is manually terminated, or lost due to any sort of connection issue.
//
//When a client disconnects, the gamemode logic has a callback activated - ExampleGameMode::onClientLeaveGame().
function ExampleModule::onDestroyClientConnection(%this)
{
//This will pop the keybind, cleaning it up from the input stack, as it no longer applies
ExampleMoveMap.pop();
}

View file

@ -0,0 +1,25 @@
<ModuleDefinition
canSave="true"
canSaveDynamicFields="true"
ModuleId="ExampleModule"
VersionId="1"
Group="Game"
scriptFile="ExampleModule.cs"
CreateFunction="onCreate"
DestroyFunction="onDestroy">
<DeclaredAssets
canSave="true"
canSaveDynamicFields="true"
Extension="asset.taml"
Recurse="true" />
<AutoloadAssets
canSave="true"
canSaveDynamicFields="true"
AssetType="ComponentAsset"
Recurse="true" />
<AutoloadAssets
canSave="true"
canSaveDynamicFields="true"
AssetType="GUIAsset"
Recurse="true" />
</ModuleDefinition>

View file

@ -0,0 +1,7 @@
<GUIAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="ExampleGUI"
scriptFile="@assetFile=ExampleGUI.gui"
GUIFile="@assetFile=ExampleGUI.gui"
VersionId="1" />

View file

@ -0,0 +1,9 @@
function ExampleGUI::onWake(%this)
{
}
function ExampleGUI::onSleep(%this)
{
}

View file

@ -0,0 +1,7 @@
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(ExampleGUI)
{
position = "0 0";
extent = "100 100";
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,9 @@
<ComponentAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="ExampleComponent"
componentName="ExampleComponent"
componentClass="Component"
description="An example script component."
scriptFile="@assetFile=ExampleComponent.cs"
VersionId="1" />

View file

@ -0,0 +1,26 @@
//onAdd is called when the component is created and then added to it's owner entity.
//You would also add any script-defined component fields via addComponentField().
function ExampleComponent::onAdd(%this)
{
}
//onAdd is called when the component is removed and deleted from it's owner entity.
function ExampleComponent::onRemove(%this)
{
}
//onClientConnect is called any time a new client connects to the server.
function ExampleComponent::onClientConnect(%this, %client)
{
}
//onClientDisconnect is called any time a client disconnects from the server.
function ExampleComponent::onClientDisonnect(%this, %client)
{
}
//update is called when the component does an update tick.
function ExampleComponent::Update(%this)
{
}

View file

@ -0,0 +1,8 @@
<LevelAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="ExampleLevel"
LevelFile="ExampleLevel.mis"
LevelName="Example Level"
LevelDescription="An example level asset"
VersionId="1" />

View file

@ -0,0 +1,99 @@
//--- OBJECT WRITE BEGIN ---
new Scene(EditorTemplateLevel) {
canSave = "1";
canSaveDynamicFields = "1";
cdTrack = "2";
CTF_scoreLimit = "5";
enabled = "1";
musicTrack = "lush";
gameModeName="ExampleGameMode";
new LevelInfo(TheLevelInfo) {
nearClip = "0.1";
visibleDistance = "1000";
visibleGhostDistance = "0";
decalBias = "0.0015";
fogColor = "0.6 0.6 0.7 1";
fogDensity = "0";
fogDensityOffset = "700";
fogAtmosphereHeight = "0";
canvasClearColor = "0 0 0 255";
ambientLightBlendPhase = "1";
ambientLightBlendCurve = "0 0 -1 -1";
advancedLightmapSupport = "0";
soundAmbience = "AudioAmbienceDefault";
soundDistanceModel = "Linear";
canSave = "1";
canSaveDynamicFields = "1";
desc0 = "A blank room template that acts as a starting point.";
enabled = "1";
levelName = "Blank Room Template";
};
new SkyBox(theSky) {
Material = "BlankSkyMat";
drawBottom = "0";
fogBandHeight = "0";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
canSave = "1";
canSaveDynamicFields = "1";
};
new Sun(theSun) {
azimuth = "230.396";
elevation = "45";
color = "0.968628 0.901961 0.901961 1";
ambient = "0.337255 0.533333 0.619608 1";
brightness = "1";
castShadows = "1";
staticRefreshFreq = "250";
dynamicRefreshFreq = "8";
coronaEnabled = "1";
coronaScale = "0.5";
coronaTint = "1 1 1 1";
coronaUseLightColor = "1";
flareScale = "1";
attenuationRatio = "0 1 1";
shadowType = "PSSM";
texSize = "1024";
overDarkFactor = "3000 1500 750 250";
shadowDistance = "200";
shadowSoftness = "0.25";
numSplits = "4";
logWeight = "0.9";
fadeStartDistance = "0";
lastSplitTerrainOnly = "0";
representedInLightmap = "0";
shadowDarkenColor = "0 0 0 -1";
includeLightmappedGeometryInShadow = "0";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
canSave = "1";
canSaveDynamicFields = "1";
bias = "0.1";
Blur = "1";
enabled = "1";
height = "1024";
lightBleedFactor = "0.8";
minVariance = "0";
pointShadowType = "PointShadowType_Paraboloid";
shadowBox = "-100 -100 -100 100 100 100";
splitFadeDistances = "1 1 1 1";
width = "3072";
};
new GroundPlane() {
squareSize = "128";
scaleU = "25";
scaleV = "25";
Material = "Grid_512_Grey";
canSave = "1";
canSaveDynamicFields = "1";
enabled = "1";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
};
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,6 @@
<PostEffectAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="ExamplePostEffect"
scriptFile="@assetFile=ExamplePostEffect.cs"
VersionId="1" />

View file

@ -0,0 +1,96 @@
//-----------------------------------------------------------------------------
// 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( ExamplePostEffect_Shader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
DXPixelShaderFile = $Core:modulePath @ "ExamplePostEffectP.hlsl";
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
OGLPixelShaderFile = $Core:modulePath @ "ExamplePostEffectP.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};
singleton GFXStateBlockData( ExamplePostEffect_StateBlock )
{
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;
samplerStates[1] = SamplerClampLinear;
samplerStates[2] = SamplerClampLinear;
samplerStates[3] = SamplerClampLinear;
blendDefined = true;
blendDest = GFXBlendOne;
blendSrc = GFXBlendZero;
zDefined = true;
zEnable = false;
zWriteEnable = false;
cullDefined = true;
cullMode = GFXCullNone;
};
function ExamplePostEffect::setShaderConsts( %this )
{
}
function ExamplePostEffect::preProcess( %this )
{
}
function ExamplePostEffect::onEnabled( %this )
{
return true;
}
function ExamplePostEffect::onDisabled( %this )
{
}
singleton PostEffect( ExamplePostEffect )
{
isEnabled = false;
allowReflectPass = false;
// Resolve the HDR before we render any editor stuff
// and before we resolve the scene to the backbuffer.
renderTime = "PFXBeforeBin";
renderBin = "EditorBin";
renderPriority = 9999;
// The bright pass generates a bloomed version of
// the scene for pixels which are brighter than a
// fixed threshold value.
//
// This is then used in the final HDR combine pass
// at the end of this post effect chain.
shader = ExamplePostEffect_Shader;
stateBlock = ExamplePostEffect_StateBlock;
texture[0] = "$backBuffer";
target = "$outTex";
targetFormat = "GFXFormatR16G16B16A16F";
targetScale = "1 1";
};

View file

@ -0,0 +1,6 @@
<ScriptAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="ExampleGamemodeScript"
scriptFile="@assetFile=ExampleGamemodeScript.cs"
VersionId="1" />

View file

@ -0,0 +1,128 @@
//-----------------------------------------------------------------------------
// The server has started up so do some game start up
//-----------------------------------------------------------------------------
//This file implements game mode logic for an Example gamemode. The primary functions:
//ExampleGameMode::onMissionStart
//ExampleGameMode::onMissionReset
//ExampleGameMode::onMissionEnd
//Are the primary hooks for the server to start, restart and end any active gamemodes
//onMissionStart, for example is called from core/clientServer/scripts/server/levelLoad.cs
//It's called once the server has successfully loaded the level, and has parsed
//through any active scenes to get GameModeNames defined by them. It then iterates
//over them and calls these callbacks to envoke gamemode behaviors. This allows multiple
//gamemodes to be in effect at one time. Modules can implement as many gamemodes as you want.
//
//For levels that can be reused for multiple gammodes, the general setup would be a primary level file
//with the Scene in it having the main geometry, weapons, terrain, etc. You would then have subScenes that
//each contain what's necessary for the given gamemode, such as a subScene that just adds the flags and capture
//triggers for a CTF mode. The subscene would then have it's GameModeName defined to run the CTF gamemode logic
//and the levelLoad code will execute it.
//This function is called when the level finishes loading. It sets up the initial configuration, variables and
//spawning and dynamic objects, timers or rules needed for the gamemode to run
function ExampleGameMode::onMissionStart()
{
//set up the game and game variables
ExampleGameMode::initGameVars();
if ($Game::Running)
{
error("onMissionStart: End the game first!");
return;
}
// Start the game timer
if ($Game::Duration)
$Game::Schedule = schedule($Game::Duration * 1000, "onGameDurationEnd");
$Game::Running = true;
$Game = ExampleGameMode;
}
//This function is called when the level ends. It can be envoked due to the gamemode ending
//but is also kicked off when the game server is shut down as a form of cleanup for anything the gamemode
//created or is managing like the above mentioned dynamic objects or timers
function ExampleGameMode::onMissionEnded()
{
if (!$Game::Running)
{
error("onMissionEnded: No game running!");
return;
}
// Stop any game timers
cancel($Game::Schedule);
$Game::Running = false;
$Game = "";
}
//This function is called in the event the server resets and is used to re-initialize the gamemode
function ExampleGameMode::onMissionReset()
{
// Called by resetMission(), after all the temporary mission objects
// have been deleted.
ExampleGameMode::initGameVars();
}
//This sets up our gamemode's duration time
function ExampleGameMode::initGameVars()
{
// Set the gameplay parameters
$Game::Duration = 30 * 60;
}
//This is called when the timer runs out, allowing the gamemode to end
function ExampleGameMode::onGameDurationEnd()
{
//we don't end if we're currently editing the level
if ($Game::Duration && !(EditorIsActive() && GuiEditorIsActive()))
ExampleGameMode::onMissionEnded();
}
//This is called when a client enters the game server. It's used to spawn a player object
//set up any client-specific properties such as saved configs, values, their name, etc
//These callbacks are activated in core/clientServer/scripts/server/levelDownload.cs
function ExampleGameMode::onClientEnterGame(%client)
{
//Set the player name based on the client's connection data
%client.setPlayerName(%client.connectData);
//In this example, we just spawn a camera
if (!isObject(%client.camera))
{
if(!isObject(Observer))
{
datablock CameraData(Observer)
{
mode = "Observer";
};
}
%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");
}
}
//This is called when the player leaves the game server. It's used to clean up anything that
//was spawned or setup for the client when it connected, in onClientEnterGame
//These callbacks are activated in core/clientServer/scripts/server/levelDownload.cs
function ExampleGameMode::onClientLeaveGame(%client)
{
// Cleanup the camera
if (isObject(%client.camera))
%client.camera.delete();
}

View file

@ -0,0 +1,73 @@
//-----------------------------------------------------------------------------
// 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( ExampleMoveMap ) )
ExampleMoveMap.delete();
new ActionMap(ExampleMoveMap);
//------------------------------------------------------------------------------
// Non-remapable binds
//------------------------------------------------------------------------------
ExampleMoveMap.bind( keyboard, F2, showPlayerList );
ExampleMoveMap.bind(keyboard, "ctrl h", hideHUDs);
ExampleMoveMap.bind(keyboard, "alt p", doScreenShotHudless);
ExampleMoveMap.bindCmd(keyboard, "escape", "", "disconnect();");
//------------------------------------------------------------------------------
// Movement Keys
//------------------------------------------------------------------------------
ExampleMoveMap.bind( keyboard, a, moveleft );
ExampleMoveMap.bind( keyboard, d, moveright );
ExampleMoveMap.bind( keyboard, left, moveleft );
ExampleMoveMap.bind( keyboard, right, moveright );
ExampleMoveMap.bind( keyboard, w, moveforward );
ExampleMoveMap.bind( keyboard, s, movebackward );
ExampleMoveMap.bind( keyboard, up, moveforward );
ExampleMoveMap.bind( keyboard, down, movebackward );
ExampleMoveMap.bind( keyboard, e, moveup );
ExampleMoveMap.bind( keyboard, c, movedown );
ExampleMoveMap.bind( keyboard, space, jump );
ExampleMoveMap.bind( mouse, xaxis, yaw );
ExampleMoveMap.bind( mouse, yaxis, pitch );
ExampleMoveMap.bind( gamepad, thumbrx, "D", "-0.23 0.23", gamepadYaw );
ExampleMoveMap.bind( gamepad, thumbry, "D", "-0.23 0.23", gamepadPitch );
ExampleMoveMap.bind( gamepad, thumblx, "D", "-0.23 0.23", gamePadMoveX );
ExampleMoveMap.bind( gamepad, thumbly, "D", "-0.23 0.23", gamePadMoveY );
ExampleMoveMap.bind( gamepad, btn_a, jump );
ExampleMoveMap.bindCmd( gamepad, btn_back, "disconnect();", "" );
//------------------------------------------------------------------------------
// Misc.
//------------------------------------------------------------------------------
GlobalActionMap.bind(keyboard, "tilde", toggleConsole);
GlobalActionMap.bindCmd(keyboard, "alt k", "cls();","");
GlobalActionMap.bindCmd(keyboard, "alt enter", "", "Canvas.attemptFullscreenToggle();");
GlobalActionMap.bindCmd(keyboard, "F1", "", "contextHelp();");
ExampleMoveMap.bindCmd(keyboard, "n", "toggleNetGraph();", "");

View file

@ -0,0 +1,204 @@
//-----------------------------------------------------------------------------
// 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 escapeFromGame()
{
disconnect();
}
$movementSpeed = 1; // m/s
function setSpeed(%speed)
{
if(%speed)
$movementSpeed = %speed;
}
function moveleft(%val)
{
$mvLeftAction = %val * $movementSpeed;
}
function moveright(%val)
{
$mvRightAction = %val * $movementSpeed;
}
function moveforward(%val)
{
$mvForwardAction = %val * $movementSpeed;
}
function movebackward(%val)
{
$mvBackwardAction = %val * $movementSpeed;
}
function moveup(%val)
{
%object = ServerConnection.getControlObject();
if(%object.isInNamespaceHierarchy("Camera"))
$mvUpAction = %val * $movementSpeed;
}
function movedown(%val)
{
%object = ServerConnection.getControlObject();
if(%object.isInNamespaceHierarchy("Camera"))
$mvDownAction = %val * $movementSpeed;
}
function turnLeft( %val )
{
$mvYawRightSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function turnRight( %val )
{
$mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function panUp( %val )
{
$mvPitchDownSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function panDown( %val )
{
$mvPitchUpSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function getMouseAdjustAmount(%val)
{
// based on a default camera FOV of 90'
return(%val * ($cameraFov / 90) * 0.01) * $pref::Input::LinkMouseSensitivity;
}
function getGamepadAdjustAmount(%val)
{
// based on a default camera FOV of 90'
return(%val * ($cameraFov / 90) * 0.01) * 10.0;
}
function yaw(%val)
{
%yawAdj = getMouseAdjustAmount(%val);
if(ServerConnection.isControlObjectRotDampedCamera())
{
// Clamp and scale
%yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
%yawAdj *= 0.5;
}
$mvYaw += %yawAdj;
}
function pitch(%val)
{
%pitchAdj = getMouseAdjustAmount(%val);
if(ServerConnection.isControlObjectRotDampedCamera())
{
// Clamp and scale
%pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
%pitchAdj *= 0.5;
}
$mvPitch += %pitchAdj;
}
function jump(%val)
{
$mvTriggerCount2++;
}
function gamePadMoveX( %val )
{
if(%val > 0)
{
$mvRightAction = %val * $movementSpeed;
$mvLeftAction = 0;
}
else
{
$mvRightAction = 0;
$mvLeftAction = -%val * $movementSpeed;
}
}
function gamePadMoveY( %val )
{
if(%val > 0)
{
$mvForwardAction = %val * $movementSpeed;
$mvBackwardAction = 0;
}
else
{
$mvForwardAction = 0;
$mvBackwardAction = -%val * $movementSpeed;
}
}
function gamepadYaw(%val)
{
%yawAdj = getGamepadAdjustAmount(%val);
if(ServerConnection.isControlObjectRotDampedCamera())
{
// Clamp and scale
%yawAdj = mClamp(%yawAdj, -m2Pi()+0.01, m2Pi()-0.01);
%yawAdj *= 0.5;
}
if(%yawAdj > 0)
{
$mvYawLeftSpeed = %yawAdj;
$mvYawRightSpeed = 0;
}
else
{
$mvYawLeftSpeed = 0;
$mvYawRightSpeed = -%yawAdj;
}
}
function gamepadPitch(%val)
{
%pitchAdj = getGamepadAdjustAmount(%val);
if(ServerConnection.isControlObjectRotDampedCamera())
{
// Clamp and scale
%pitchAdj = mClamp(%pitchAdj, -m2Pi()+0.01, m2Pi()-0.01);
%pitchAdj *= 0.5;
}
if(%pitchAdj > 0)
{
$mvPitchDownSpeed = %pitchAdj;
$mvPitchUpSpeed = 0;
}
else
{
$mvPitchDownSpeed = 0;
$mvPitchUpSpeed = -%pitchAdj;
}
}

View file

@ -0,0 +1,7 @@
<CppAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="ExampleCppObject"
codeFile="@assetFile=data/ExampleModule/source/ExampleCppObject.cpp"
headerFile="@assetFile=data/ExampleModule/source/ExampleCppObject.h"
VersionId="1" />

View file

@ -0,0 +1,18 @@
#include "core/module.h"
#include "console/engineAPI.h"
MODULE_BEGIN(ExampleModule_Module)
MODULE_INIT_AFTER(Sim)
MODULE_SHUTDOWN_BEFORE(Sim)
MODULE_INIT
{
// Setup anything needed when the engine initializes here
}
MODULE_SHUTDOWN
{
// Cleanup anything that was initialized before here
}
MODULE_END;