gameFunctions.cpp
Engine/source/T3D/gameFunctions.cpp
Namespaces:
Camera and FOV info.
Public Variables
bool
For frame signal.
Public Functions
ConsoleFunctionGroupBegin(Containers , "Spatial query functions. <<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>>Server side only!</<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>>" )
ConsoleFunctionGroupEnd(Containers )
DefineConsoleFunction(containerFindFirst , const char * , (U32 typeMask, Point3F origin, Point3F size) , "(int mask, <a href="/coding/class/classpoint3f/">Point3F</a> point, float x, float y, float z)" "@brief Find objects matching the bitmask type within a box centered at point, with extents x, y , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">z.\n\n</a>" " @returns The first object found, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a2594a51175f310ed96ad6cd7d6514878">if</a> nothing was found. Thereafter, you can get more " "results using containerFindNext()." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">containerFindNext\n</a>" " @ingroup Game" )
DefineConsoleFunction(containerFindNext , const char * , () , "()" "@brief Get more results from a previous call <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> containerFindFirst().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@note You must call containerFindFirst() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> begin the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">search.\n</a>" "@returns The next object found, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a2594a51175f310ed96ad6cd7d6514878">if</a> nothing else was <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">found.\n</a>" " @see containerFindFirst()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup Game" )
DefineEngineFunction(setDefaultFov , void , (F32 defaultFOV) , "@brief Set the default FOV <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">camera.\n</a>" "@param defaultFOV The default field of view in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">degrees\n</a>" "@ingroup CameraSystem" )
DefineEngineFunction(setFov , void , (F32 FOV) , "@brief Set the FOV of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">camera.\n</a>" "@param FOV The camera's <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> FOV in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">degrees\n</a>" "@ingroup CameraSystem" )
DefineEngineFunction(setZoomSpeed , void , (S32 speed) , "@brief Set the zoom speed of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">camera.\n</a>" "This affects how quickly the camera changes from one field of view " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">another.\n</a>" "@param speed The camera's zoom speed in ms per 90deg FOV <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">change\n</a>" "@ingroup CameraSystem" )
Gets the camera field of view angle.
bool
GameGetCameraTransform(MatrixF * mat, Point3F * velocity)
Gets the position, rotation, and velocity of the camera.
bool
GameProcessCameraQuery(CameraQuery * query)
Does the same thing as GameGetCameraTransform, but fills in other data including information about the far and near clipping planes.
Actually renders the world.
GameSetCameraFov(F32 fov)
Sets the field of view angle of the camera.
Sets where the camera fov will be change to.
Update the camera fov to be closer to the target fov.
Detailed Description
Public Variables
S32 gEaseBack
S32 gEaseBounce
S32 gEaseCircular
S32 gEaseCubic
S32 gEaseElastic
S32 gEaseExponential
S32 gEaseIn
S32 gEaseInOut
S32 gEaseLinear
S32 gEaseOut
S32 gEaseQuadratic
S32 gEaseQuartic
S32 gEaseQuintic
S32 gEaseSinusoidal
bool gEditingMission
For frame signal.
MODULE_END
MODULE_INIT
MODULE_SHUTDOWN
U32 sgServerQueryIndex
SimpleQueryList sgServerQueryList
Public Functions
ConsoleFunctionGroupBegin(Containers , "Spatial query functions. <<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>>Server side only!</<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>>" )
ConsoleFunctionGroupEnd(Containers )
DefineConsoleFunction(containerFindFirst , const char * , (U32 typeMask, Point3F origin, Point3F size) , "(int mask, <a href="/coding/class/classpoint3f/">Point3F</a> point, float x, float y, float z)" "@brief Find objects matching the bitmask type within a box centered at point, with extents x, y , <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">z.\n\n</a>" " @returns The first object found, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a2594a51175f310ed96ad6cd7d6514878">if</a> nothing was found. Thereafter, you can get more " "results using containerFindNext()." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">containerFindNext\n</a>" " @ingroup Game" )
DefineConsoleFunction(containerFindNext , const char * , () , "()" "@brief Get more results from a previous call <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> containerFindFirst().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@note You must call containerFindFirst() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> begin the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">search.\n</a>" "@returns The next object found, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a2594a51175f310ed96ad6cd7d6514878">if</a> nothing else was <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">found.\n</a>" " @see containerFindFirst()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup Game" )
DefineEngineFunction(setDefaultFov , void , (F32 defaultFOV) , "@brief Set the default FOV <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">camera.\n</a>" "@param defaultFOV The default field of view in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">degrees\n</a>" "@ingroup CameraSystem" )
DefineEngineFunction(setFov , void , (F32 FOV) , "@brief Set the FOV of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">camera.\n</a>" "@param FOV The camera's <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> FOV in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">degrees\n</a>" "@ingroup CameraSystem" )
DefineEngineFunction(setZoomSpeed , void , (S32 speed) , "@brief Set the zoom speed of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">camera.\n</a>" "This affects how quickly the camera changes from one field of view " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">another.\n</a>" "@param speed The camera's zoom speed in ms per 90deg FOV <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">change\n</a>" "@ingroup CameraSystem" )
GameGetCameraFov()
Gets the camera field of view angle.
GameGetCameraTransform(MatrixF * mat, Point3F * velocity)
Gets the position, rotation, and velocity of the camera.
GameProcessCameraQuery(CameraQuery * query)
Does the same thing as GameGetCameraTransform, but fills in other data including information about the far and near clipping planes.
GameRenderWorld()
Actually renders the world.
This is the function that will render the scene ONLY - new guis, no damage flashes.
GameSetCameraFov(F32 fov)
Sets the field of view angle of the camera.
GameSetCameraTargetFov(F32 fov)
Sets where the camera fov will be change to.
This is for non-instantaneous zooms/retractions.
GameUpdateCameraFov()
Update the camera fov to be closer to the target fov.
notify(GameSetCameraFov )
Process3D()
RegisterGameFunctions()
ShowInit()
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "platform/platform.h" 25#include "T3D/gameFunctions.h" 26#include "T3D/gameBase/gameConnection.h" 27#include "T3D/camera.h" 28#include "T3D/sfx/sfx3DWorld.h" 29#include "console/consoleTypes.h" 30#include "gui/3d/guiTSControl.h" 31#include "core/util/journal/process.h" 32#include "materials/materialManager.h" 33#include "math/mEase.h" 34#include "core/module.h" 35#include "console/engineAPI.h" 36#include "platform/output/IDisplayDevice.h" 37 38static void RegisterGameFunctions(); 39static void Process3D(); 40 41MODULE_BEGIN( 3D ) 42 43 MODULE_INIT_AFTER( Process ) 44 MODULE_INIT_AFTER( Scene ) 45 46 MODULE_SHUTDOWN_BEFORE( Process ) 47 MODULE_SHUTDOWN_BEFORE( Sim ) 48 MODULE_SHUTDOWN_AFTER( Scene ) 49 50 MODULE_INIT 51 { 52 Process::notify(Process3D, PROCESS_TIME_ORDER); 53 54 GameConnection::smFovUpdate.notify(GameSetCameraFov); 55 56 RegisterGameFunctions(); 57 } 58 59 MODULE_SHUTDOWN 60 { 61 GameConnection::smFovUpdate.remove(GameSetCameraFov); 62 63 Process::remove(Process3D); 64 } 65 66MODULE_END; 67 68 69static S32 gEaseInOut = Ease::InOut; 70static S32 gEaseIn = Ease::In; 71static S32 gEaseOut = Ease::Out; 72 73static S32 gEaseLinear = Ease::Linear; 74static S32 gEaseQuadratic= Ease::Quadratic; 75static S32 gEaseCubic= Ease::Cubic; 76static S32 gEaseQuartic = Ease::Quartic; 77static S32 gEaseQuintic = Ease::Quintic; 78static S32 gEaseSinusoidal= Ease::Sinusoidal; 79static S32 gEaseExponential = Ease::Exponential; 80static S32 gEaseCircular = Ease::Circular; 81static S32 gEaseElastic = Ease::Elastic; 82static S32 gEaseBack = Ease::Back; 83static S32 gEaseBounce = Ease::Bounce; 84 85 86extern bool gEditingMission; 87 88extern void ShowInit(); 89 90//------------------------------------------------------------------------------ 91/// Camera and FOV info 92namespace CameraAndFOV{ 93 94 const U32 MaxZoomSpeed = 2000; ///< max number of ms to reach target FOV 95 96 static F32 sConsoleCameraFov = 90.f; ///< updated to camera FOV each frame 97 static F32 sDefaultFov = 90.f; ///< normal FOV 98 static F32 sCameraFov = 90.f; ///< current camera FOV 99 static F32 sTargetFov = 90.f; ///< the desired FOV 100 static F32 sLastCameraUpdateTime = 0; ///< last time camera was updated 101 static S32 sZoomSpeed = 500; ///< ms per 90deg fov change 102 103 /// A scale to apply to the normal visible distance 104 /// typically used for tuning performance. 105 static F32 sVisDistanceScale = 1.0f; 106 107} // namespace {} 108 109// query 110static SimpleQueryList sgServerQueryList; 111static U32 sgServerQueryIndex = 0; 112 113//SERVER FUNCTIONS ONLY 114ConsoleFunctionGroupBegin( Containers, "Spatial query functions. <b>Server side only!</b>"); 115 116DefineConsoleFunction( containerFindFirst, const char*, (U32 typeMask, Point3F origin, Point3F size), , "(int mask, Point3F point, float x, float y, float z)" 117 "@brief Find objects matching the bitmask type within a box centered at point, with extents x, y, z.\n\n" 118 "@returns The first object found, or an empty string if nothing was found. Thereafter, you can get more " 119 "results using containerFindNext()." 120 "@see containerFindNext\n" 121 "@ingroup Game") 122{ 123 //find out what we're looking for 124 125 //build the container volume 126 Box3F queryBox; 127 queryBox.minExtents = origin; 128 queryBox.maxExtents = origin; 129 queryBox.minExtents -= size; 130 queryBox.maxExtents += size; 131 132 //initialize the list, and do the query 133 sgServerQueryList.mList.clear(); 134 gServerContainer.findObjects(queryBox, typeMask, SimpleQueryList::insertionCallback, &sgServerQueryList); 135 136 //return the first element 137 sgServerQueryIndex = 0; 138 static const U32 bufSize = 100; 139 char *buff = Con::getReturnBuffer(bufSize); 140 if (sgServerQueryList.mList.size()) 141 dSprintf(buff, bufSize, "%d", sgServerQueryList.mList[sgServerQueryIndex++]->getId()); 142 else 143 buff[0] = '\0'; 144 145 return buff; 146} 147 148DefineConsoleFunction( containerFindNext, const char*, (), , "()" 149 "@brief Get more results from a previous call to containerFindFirst().\n\n" 150 "@note You must call containerFindFirst() to begin the search.\n" 151 "@returns The next object found, or an empty string if nothing else was found.\n" 152 "@see containerFindFirst()\n" 153 "@ingroup Game") 154{ 155 //return the next element 156 static const U32 bufSize = 100; 157 char *buff = Con::getReturnBuffer(bufSize); 158 if (sgServerQueryIndex < sgServerQueryList.mList.size()) 159 dSprintf(buff, bufSize, "%d", sgServerQueryList.mList[sgServerQueryIndex++]->getId()); 160 else 161 buff[0] = '\0'; 162 163 return buff; 164} 165 166ConsoleFunctionGroupEnd( Containers ); 167 168//------------------------------------------------------------------------------ 169 170bool GameGetCameraTransform(MatrixF *mat, Point3F *velocity) 171{ 172 // Return the position and velocity of the control object 173 GameConnection* connection = GameConnection::getConnectionToServer(); 174 return connection && connection->getControlCameraTransform(0, mat) && 175 connection->getControlCameraVelocity(velocity); 176} 177 178//------------------------------------------------------------------------------ 179DefineEngineFunction( setDefaultFov, void, ( F32 defaultFOV ),, 180 "@brief Set the default FOV for a camera.\n" 181 "@param defaultFOV The default field of view in degrees\n" 182 "@ingroup CameraSystem") 183{ 184 CameraAndFOV::sDefaultFov = mClampF(defaultFOV, MinCameraFov, MaxCameraFov); 185 if(CameraAndFOV::sCameraFov == CameraAndFOV::sTargetFov) 186 CameraAndFOV::sTargetFov = CameraAndFOV::sDefaultFov; 187} 188 189DefineEngineFunction( setZoomSpeed, void, ( S32 speed ),, 190 "@brief Set the zoom speed of the camera.\n" 191 "This affects how quickly the camera changes from one field of view " 192 "to another.\n" 193 "@param speed The camera's zoom speed in ms per 90deg FOV change\n" 194 "@ingroup CameraSystem") 195{ 196 CameraAndFOV::sZoomSpeed = mClamp(speed, 0, CameraAndFOV::MaxZoomSpeed); 197} 198 199DefineEngineFunction( setFov, void, ( F32 FOV ),, 200 "@brief Set the FOV of the camera.\n" 201 "@param FOV The camera's new FOV in degrees\n" 202 "@ingroup CameraSystem") 203{ 204 CameraAndFOV::sTargetFov = mClampF(FOV, MinCameraFov, MaxCameraFov); 205} 206 207F32 GameGetCameraFov() 208{ 209 return(CameraAndFOV::sCameraFov); 210} 211 212void GameSetCameraFov(F32 fov) 213{ 214 CameraAndFOV::sTargetFov = CameraAndFOV::sCameraFov = fov; 215} 216 217void GameSetCameraTargetFov(F32 fov) 218{ 219 CameraAndFOV::sTargetFov = fov; 220} 221 222void GameUpdateCameraFov() 223{ 224 F32 time = F32(Platform::getVirtualMilliseconds()); 225 226 // need to update fov? 227 if(CameraAndFOV::sTargetFov != CameraAndFOV::sCameraFov) 228 { 229 F32 delta = time - CameraAndFOV::sLastCameraUpdateTime; 230 231 // snap zoom? 232 if((CameraAndFOV::sZoomSpeed == 0) || (delta <= 0.0f)) 233 CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov; 234 else 235 { 236 // gZoomSpeed is time in ms to zoom 90deg 237 F32 step = 90.f * (delta / F32(CameraAndFOV::sZoomSpeed)); 238 239 if(CameraAndFOV::sCameraFov > CameraAndFOV::sTargetFov) 240 { 241 CameraAndFOV::sCameraFov -= step; 242 if(CameraAndFOV::sCameraFov < CameraAndFOV::sTargetFov) 243 CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov; 244 } 245 else 246 { 247 CameraAndFOV::sCameraFov += step; 248 if(CameraAndFOV::sCameraFov > CameraAndFOV::sTargetFov) 249 CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov; 250 } 251 } 252 } 253 254 // the game connection controls the vertical and the horizontal 255 GameConnection * connection = GameConnection::getConnectionToServer(); 256 if(connection) 257 { 258 // check if fov is valid on control object 259 if(connection->isValidControlCameraFov(CameraAndFOV::sCameraFov)) 260 connection->setControlCameraFov(CameraAndFOV::sCameraFov); 261 else 262 { 263 // will set to the closest fov (fails only on invalid control object) 264 if(connection->setControlCameraFov(CameraAndFOV::sCameraFov)) 265 { 266 F32 setFov = CameraAndFOV::sCameraFov; 267 connection->getControlCameraFov(&setFov); 268 CameraAndFOV::sTargetFov =CameraAndFOV::sCameraFov = setFov; 269 } 270 } 271 } 272 273 // update the console variable 274 CameraAndFOV::sConsoleCameraFov = CameraAndFOV::sCameraFov; 275 CameraAndFOV::sLastCameraUpdateTime = time; 276} 277//-------------------------------------------------------------------------- 278 279#ifdef TORQUE_DEBUG 280// ConsoleFunction(dumpTSShapes, void, 1, 1, "dumpTSShapes();") 281// { 282// argc, argv; 283 284// FindMatch match("*.dts", 4096); 285// gResourceManager->findMatches(&match); 286 287// for (U32 i = 0; i < match.numMatches(); i++) 288// { 289// U32 j; 290// Resource<TSShape> shape = ResourceManager::get().load(match.matchList[i]); 291// if (bool(shape) == false) 292// Con::errorf(" aaa Couldn't load: %s", match.matchList[i]); 293 294// U32 numMeshes = 0, numSkins = 0; 295// for (j = 0; j < shape->meshes.size(); j++) 296// if (shape->meshes[j]) 297// numMeshes++; 298// for (j = 0; j < shape->skins.size(); j++) 299// if (shape->skins[j]) 300// numSkins++; 301 302// Con::printf(" aaa Shape: %s (%d meshes, %d skins)", match.matchList[i], numMeshes, numSkins); 303// Con::printf(" aaa Meshes"); 304// for (j = 0; j < shape->meshes.size(); j++) 305// { 306// if (shape->meshes[j]) 307// Con::printf(" aaa %d -> nf: %d, nmf: %d, nvpf: %d (%d, %d, %d, %d, %d)", 308// shape->meshes[j]->meshType & TSMesh::TypeMask, 309// shape->meshes[j]->numFrames, 310// shape->meshes[j]->numMatFrames, 311// shape->meshes[j]->vertsPerFrame, 312// shape->meshes[j]->verts.size(), 313// shape->meshes[j]->norms.size(), 314// shape->meshes[j]->tverts.size(), 315// shape->meshes[j]->primitives.size(), 316// shape->meshes[j]->indices.size()); 317// } 318// Con::printf(" aaa Skins"); 319// for (j = 0; j < shape->skins.size(); j++) 320// { 321// if (shape->skins[j]) 322// Con::printf(" aaa %d -> nf: %d, nmf: %d, nvpf: %d (%d, %d, %d, %d, %d)", 323// shape->skins[j]->meshType & TSMesh::TypeMask, 324// shape->skins[j]->numFrames, 325// shape->skins[j]->numMatFrames, 326// shape->skins[j]->vertsPerFrame, 327// shape->skins[j]->verts.size(), 328// shape->skins[j]->norms.size(), 329// shape->skins[j]->tverts.size(), 330// shape->skins[j]->primitives.size(), 331// shape->skins[j]->indices.size()); 332// } 333// } 334// } 335#endif 336 337bool GameProcessCameraQuery(CameraQuery *query) 338{ 339 GameConnection* connection = GameConnection::getConnectionToServer(); 340 341 if (connection && connection->getControlCameraTransform(0.032f, &query->cameraMatrix)) 342 { 343 query->object = dynamic_cast<GameBase*>(connection->getCameraObject()); 344 query->nearPlane = gClientSceneGraph->getNearClip(); 345 346 // Scale the normal visible distance by the performance 347 // tuning scale which we never let over 1. 348 CameraAndFOV::sVisDistanceScale = mClampF( CameraAndFOV::sVisDistanceScale, 0.01f, 1.0f ); 349 query->farPlane = gClientSceneGraph->getVisibleDistance() * CameraAndFOV::sVisDistanceScale; 350 351 // Provide some default values 352 query->stereoTargets[0] = 0; 353 query->stereoTargets[1] = 0; 354 query->eyeOffset[0] = Point3F::Zero; 355 query->eyeOffset[1] = Point3F::Zero; 356 query->hasFovPort = false; 357 query->hasStereoTargets = false; 358 query->displayDevice = NULL; 359 360 F32 cameraFov = 0.0f; 361 bool fovSet = false; 362 363 // Try to use the connection's display deivce, if any, but only if the editor 364 // is not open 365 if(!gEditingMission && connection->hasDisplayDevice()) 366 { 367 IDisplayDevice* display = connection->getDisplayDevice(); 368 369 query->displayDevice = display; 370 371 // Note: all eye values are invalid until this is called 372 display->setDrawCanvas(query->drawCanvas); 373 374 display->setCurrentConnection(connection); 375 376 // Display may activate AFTER so we need to call this again just in case 377 display->onStartFrame(); 378 379 // The connection's display device may want to set the eye offset 380 if(display->providesEyeOffsets()) 381 { 382 display->getEyeOffsets(query->eyeOffset); 383 } 384 385 // Grab field of view for both eyes 386 if (display->providesFovPorts()) 387 { 388 display->getFovPorts(query->fovPort); 389 fovSet = true; 390 query->hasFovPort = true; 391 } 392 393 // Grab the latest overriding render view transforms 394 connection->getControlCameraEyeTransforms(display, query->eyeTransforms); 395 connection->getControlCameraHeadTransform(display, &query->headMatrix); 396 397 display->getStereoViewports(query->stereoViewports); 398 display->getStereoTargets(query->stereoTargets); 399 query->hasStereoTargets = true; 400 } 401 else 402 { 403 query->eyeTransforms[0] = query->cameraMatrix; 404 query->eyeTransforms[1] = query->cameraMatrix; 405 query->headMatrix = query->cameraMatrix; 406 } 407 408 // Use the connection's FOV settings if requried 409 if(!connection->getControlCameraFov(&cameraFov)) 410 { 411 return false; 412 } 413 414 query->fov = mDegToRad(cameraFov); 415 return true; 416 } 417 return false; 418} 419 420void GameRenderWorld() 421{ 422 PROFILE_START(GameRenderWorld); 423 FrameAllocator::setWaterMark(0); 424 425 gClientSceneGraph->renderScene( SPT_Diffuse ); 426 427 // renderScene leaves some states dirty, which causes problems if GameTSCtrl is the last Gui object rendered 428 GFX->updateStates(); 429 430 AssertFatal(FrameAllocator::getWaterMark() == 0, 431 "Error, someone didn't reset the water mark on the frame allocator!"); 432 FrameAllocator::setWaterMark(0); 433 PROFILE_END(); 434} 435 436 437static void Process3D() 438{ 439 MATMGR->updateTime(); 440 441 // Update the SFX world, if there is one. 442 443 if( gSFX3DWorld ) 444 gSFX3DWorld->update(); 445} 446 447static void RegisterGameFunctions() 448{ 449 Con::addVariable( "$pref::Camera::distanceScale", TypeF32, &CameraAndFOV::sVisDistanceScale, 450 "A scale to apply to the normal visible distance, typically used for tuning performance.\n" 451 "@ingroup Game"); 452 Con::addVariable( "$cameraFov", TypeF32, &CameraAndFOV::sConsoleCameraFov, 453 "The camera's Field of View.\n\n" 454 "@ingroup Game" ); 455 456 // Stuff game types into the console 457 Con::setIntVariable("$TypeMasks::StaticObjectType", StaticObjectType); 458 Con::setIntVariable("$TypeMasks::EnvironmentObjectType", EnvironmentObjectType); 459 Con::setIntVariable("$TypeMasks::TerrainObjectType", TerrainObjectType); 460 Con::setIntVariable("$TypeMasks::WaterObjectType", WaterObjectType); 461 Con::setIntVariable("$TypeMasks::TriggerObjectType", TriggerObjectType); 462 Con::setIntVariable("$TypeMasks::MarkerObjectType", MarkerObjectType); 463 Con::setIntVariable("$TypeMasks::GameBaseObjectType", GameBaseObjectType); 464 Con::setIntVariable("$TypeMasks::ShapeBaseObjectType", ShapeBaseObjectType); 465 Con::setIntVariable("$TypeMasks::CameraObjectType", CameraObjectType); 466 Con::setIntVariable("$TypeMasks::StaticShapeObjectType", StaticShapeObjectType); 467 Con::setIntVariable("$TypeMasks::DynamicShapeObjectType", DynamicShapeObjectType); 468 Con::setIntVariable("$TypeMasks::PlayerObjectType", PlayerObjectType); 469 Con::setIntVariable("$TypeMasks::ItemObjectType", ItemObjectType); 470 Con::setIntVariable("$TypeMasks::VehicleObjectType", VehicleObjectType); 471 Con::setIntVariable("$TypeMasks::VehicleBlockerObjectType", VehicleBlockerObjectType); 472 Con::setIntVariable("$TypeMasks::ProjectileObjectType", ProjectileObjectType); 473 Con::setIntVariable("$TypeMasks::ExplosionObjectType", ExplosionObjectType); 474 Con::setIntVariable("$TypeMasks::CorpseObjectType", CorpseObjectType); 475 Con::setIntVariable("$TypeMasks::DebrisObjectType", DebrisObjectType); 476 Con::setIntVariable("$TypeMasks::PhysicalZoneObjectType", PhysicalZoneObjectType); 477 Con::setIntVariable("$TypeMasks::LightObjectType", LightObjectType); 478 479 Con::addVariable("Ease::InOut", TypeS32, &gEaseInOut, 480 "InOut ease for curve movement.\n" 481 "@ingroup Game"); 482 Con::addVariable("Ease::In", TypeS32, &gEaseIn, 483 "In ease for curve movement.\n" 484 "@ingroup Game"); 485 Con::addVariable("Ease::Out", TypeS32, &gEaseOut, 486 "Out ease for curve movement.\n" 487 "@ingroup Game"); 488 489 Con::addVariable("Ease::Linear", TypeS32, &gEaseLinear, 490 "Linear ease for curve movement.\n" 491 "@ingroup Game"); 492 Con::addVariable("Ease::Quadratic", TypeS32, &gEaseQuadratic, 493 "Quadratic ease for curve movement.\n" 494 "@ingroup Game"); 495 Con::addVariable("Ease::Cubic", TypeS32, &gEaseCubic, 496 "Cubic ease for curve movement.\n" 497 "@ingroup Game"); 498 Con::addVariable("Ease::Quartic", TypeS32, &gEaseQuartic, 499 "Quartic ease for curve movement.\n" 500 "@ingroup Game"); 501 Con::addVariable("Ease::Quintic", TypeS32, &gEaseQuintic, 502 "Quintic ease for curve movement.\n" 503 "@ingroup Game"); 504 Con::addVariable("Ease::Sinusoidal", TypeS32, &gEaseSinusoidal, 505 "Sinusoidal ease for curve movement.\n" 506 "@ingroup Game"); 507 Con::addVariable("Ease::Exponential", TypeS32, &gEaseExponential, 508 "Exponential ease for curve movement.\n" 509 "@ingroup Game"); 510 Con::addVariable("Ease::Circular", TypeS32, &gEaseCircular, 511 "Circular ease for curve movement.\n" 512 "@ingroup Game"); 513 Con::addVariable("Ease::Elastic", TypeS32, &gEaseElastic, 514 "Elastic ease for curve movement.\n" 515 "@ingroup Game"); 516 Con::addVariable("Ease::Back", TypeS32, &gEaseBack, 517 "Backwards ease for curve movement.\n" 518 "@ingroup Game"); 519 Con::addVariable("Ease::Bounce", TypeS32, &gEaseBounce, 520 "Bounce ease for curve movement.\n" 521 "@ingroup Game"); 522} 523
