18 #include "precompiled.h"
116 double p = pow((
double)
m_Smoothness, 10.0 * (
double)time);
130 void Wrap(
float min,
float max)
132 double t = fmod(
m_Target - min, (
double)(max - min));
313 #define IMPLEMENT_BOOLEAN_SETTING(NAME) \
314 bool CGameView::Get##NAME##Enabled() \
319 void CGameView::Set##NAME##Enabled(bool Enabled) \
328 #undef IMPLEMENT_BOOLEAN_SETTING
513 for (
ssize_t j=0; j<patchesPerSide; j++) {
514 for (
ssize_t i=0; i<patchesPerSide; i++) {
519 float waterHeight =
g_Renderer.GetWaterManager()->m_WaterHeight + 0.001f;
520 if(bounds[1].
Y < waterHeight) {
521 bounds[1].Y = waterHeight;
533 nPatch = pTerrain->
GetPatch(i-1,j-1);
539 nPatch = pTerrain->
GetPatch(i+1,j-1);
548 nPatch = pTerrain->
GetPatch(i-1,j+1);
554 nPatch = pTerrain->
GetPatch(i+1,j+1);
561 for (
ssize_t j=0; j<patchesPerSide; j++)
563 for (
ssize_t i=0; i<patchesPerSide; i++)
597 for (
size_t i = 0; i < units.size(); ++i)
606 g_Renderer.GetWaterManager()->UnloadWaterTextures();
644 const float filtered_ground = std::max(filtered_near_ground, filtered_pivot_ground);
649 const float min_height = (m->
HeightMin + ground - filtered_ground);
651 const float target_height = std::max(pivot_height, min_height);
652 const float height = (nearPoint.
Y - filtered_ground);
653 const float diff = target_height - height;
654 if (fabsf(diff) < 0.0001f)
692 static int mouse_last_x = 0;
693 static int mouse_last_y = 0;
708 float moveRightward = 0.f;
709 float moveForward = 0.f;
721 else if (g_mouse_x <= 3 && g_mouse_x >= 0)
726 else if (g_mouse_y <= 3 && g_mouse_y >= 0)
755 if (moveRightward || moveForward)
772 if (cmpPosition && cmpPosition->
IsInWorld() &&
853 float r = pTerrain->
GetMaxX() / 2;
855 float dist = (desiredPivot - center).
Length();
857 desiredPivot = center + (desiredPivot - center).Normalized() * (r -
CAMERA_EDGE_MARGIN);
1022 float dist = delta.
Dot(forwards);
1083 std::string hotkey =
static_cast<const char*
>(ev->
ev.
user.
data1);
1085 if (hotkey ==
"wireframe")
1107 else if (hotkey ==
"camera.zoom.wheel.in")
1112 else if (hotkey ==
"camera.zoom.wheel.out")
1117 else if (hotkey ==
"camera.rotate.wheel.cw")
1122 else if (hotkey ==
"camera.rotate.wheel.ccw")
1127 else if (hotkey ==
"camera.scroll.speed.increase")
1132 else if (hotkey ==
"camera.scroll.speed.decrease")
1137 else if (hotkey ==
"camera.rotate.speed.increase")
1143 else if (hotkey ==
"camera.rotate.speed.decrease")
1149 else if (hotkey ==
"camera.zoom.speed.increase")
1154 else if (hotkey ==
"camera.zoom.speed.decrease")
1159 else if (hotkey ==
"camera.reset")
The container that holds the rules, resources and attributes of the game.
void Translate(float x, float y, float z)
float ViewScrollSpeedModifier
CCamera CullCamera
this camera controls the frustum that is used for culling and shadow calculations ...
float ViewRotateYSpeedWheel
static void SetupCameraMatrixSmooth(CGameViewImpl *m, CMatrix3D *orientation)
CLightEnv CachedLightEnv
Cache global lighting environment.
CCinemaManager * GetCinema()
void MakeDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags)
bool FollowFirstPerson
Whether to follow FollowEntity in first-person mode.
CVector3D GetSmoothPivot(CCamera &camera) const
CUnitManager & GetUnitManager()
Get a reference to the unit manager object.
const ssize_t TERRAIN_TILE_SIZE
metres [world space units] per tile in x and z
static void SetupCameraMatrixSmoothRot(CGameViewImpl *m, CMatrix3D *orientation)
virtual void EnumerateObjects(const CFrustum &frustum, SceneCollector *c)
Send all objects that can be seen when rendering the given frustum to the scene collector.
CLightEnv g_LightEnv
File : World.cpp Project : engine Description : Contains the CWorld Class implementation.
float GetAxisValue(int axis)
Returns current value of the given joystick axis, in the range [-1, +1].
void CachePlayerColours()
Retrieving player colours from scripts is slow, so this updates an internal cache of all players' col...
#define CFG_GET_VAL(name, type, destination)
const std::string & GetLightingModel() const
void CameraFollow(entity_id_t entity, bool firstPerson)
float Dot(const CVector3D &vector) const
void ClampSmoothly(float min, float max)
bool IsBoxVisible(const CVector3D &position, const CBoundingBoxAligned &bounds) const
CVector3D Rotate(const CVector3D &vec) const
float GetExactGroundLevel(float x, float z) const
#define RENDERDATA_UPDATE_COLOR
bool g_mouse_active
Indicates whether the mouse is focused on the game window (mouse positions should usually be consider...
void AddSmoothly(float value)
virtual CMatrix3D GetInterpolatedTransform(float frameOffset, bool forceFloating)=0
Get the current interpolated transform matrix, for rendering.
void RenderSubmit(SceneCollector &collector, const CFrustum &frustum, bool culling)
float ViewZoomSpeedModifier
T Clamp(T val, T min, T max)
low-level aka "lib"
void SetCameraProjection()
virtual bool IsInWorld()=0
Returns true if the entity currently exists at a defined position in the world.
virtual bool GetLosCircular()=0
Returns whether the LOS is restricted to a circular map.
float GetLastFrameOffset() const
Returns the last frame offset passed to Interpolate(), i.e.
void SetViewport(const SViewPort &vp)
const entity_id_t SYSTEM_ENTITY
Entity ID for singleton 'system' components.
virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player, bool forceRetainInFog=false)=0
Returns the visibility status of the given entity, with respect to the given player.
void ResetCameraAngleZoom()
This interface accepts renderable objects.
CTerrain * GetTerrain()
Get the pointer to the terrain object.
#define IMPLEMENT_BOOLEAN_SETTING(NAME)
void RotateY(float angle)
int LoadTerrainTextures()
bool ConstrainCamera
Whether the camera movement should be constrained by min/max limits and terrain avoidance.
bool Update(const float deltaRealTime)
CCinemaManager TrackManager
entity_id_t FollowEntity
Entity for the camera to follow, or INVALID_ENTITY if none.
void Update(const float deltaRealTime)
Updates all the view information (i.e.
int LoadWaterTextures()
LoadWaterTextures: Load water textures from within the progressive load framework.
CGameViewImpl(CGame *game)
CSkeletonAnimManager SkeletonAnimManager
bool Culling
When true, culling is enabled so that only models that have a chance of being visible are sent to the...
InReaction game_view_handler(const SDL_Event_ *ev)
CColladaManager ColladaManager
CGame * g_Game
Globally accessible pointer to the CGame object.
bool IsEnabled()
Returns true if initialised and the joystick is present and enabled by configuration.
void Wrap(float min, float max)
virtual CTerritoryTexture & GetTerritoryTexture()
Return the territory texture to be used for rendering this scene.
A simplified syntax for accessing entity components.
virtual void GetInterpolatedPosition2D(float frameOffset, float &x, float &z, float &rotY)=0
Get the current interpolated 2D position and orientation, for rendering.
void SetViewPort(const SViewPort &viewport)
CSimulation2 * GetSimulation2()
Get the pointer to the simulation2 object.
CObjectManager ObjectManager
void SetValueSmoothly(float value)
float GetFilteredGroundLevel(float x, float z, float radius) const
entity_id_t GetFollowedEntity()
float ViewRotateSpeedModifier
void UpdateFrustum(const CBoundingBoxAligned &scissor=CBoundingBoxAligned(CVector3D(-1.0f,-1.0f,-1.0f), CVector3D(1.0f, 1.0f, 1.0f)))
CGameView * GetView()
Get the pointer to the game view object.
static const float CAMERA_EDGE_MARGIN
NONCOPYABLE(CGameViewImpl)
CPatch * GetPatch(ssize_t i, ssize_t j) const
virtual CLOSTexture & GetLOSTexture()
Return the LOS texture to be used for rendering this scene.
bool IsGameStarted() const
Get m_GameStarted.
const std::vector< CUnit * > & GetUnits() const
CVector3D GetLeft() const
CObjectManager & GetObjectManager() const
CWorld * GetWorld()
Get the pointer to the game world object.
Maintains the LOS (fog-of-war / shroud-of-darkness) texture, used for rendering and for the minimap...
bool HotkeyIsPressed(const CStr &keyname)
void FromAxisAngle(const CVector3D &axis, float angle)
void RegMemFun(T *this_, int(T::*func)(void), const wchar_t *description, int estimated_duration_ms)
InReaction HandleEvent(const SDL_Event_ *ev)
static void FocusHeight(CGameViewImpl *m, bool smooth)
CVector3D GetTranslation() const
void SetValue(float value)
Class CLightEnv: description of a lighting environment - contains all the necessary parameters for re...
const CBoundingBoxAligned & GetWorldBounds()
Returns the world-space axis-aligned bounds of this object.
static float Length(const SVec3 v)
ssize_t GetPatchesPerSide() const
const entity_id_t INVALID_ENTITY
Invalid entity ID.
u32 entity_id_t
Entity ID type.
virtual void Submit(CPatch *patch)=0
Submit a terrain patch that is part of the scene.
bool LockCullCamera
When true, the cull camera is locked in place.
CCamera ViewCamera
this camera controls the eye position when rendering
CSmoothedValue(float value, float smoothness, float minDelta)
void MoveCameraTarget(const CVector3D &target)
Maintains the territory boundary texture, used for rendering and for the minimap. ...
CTerritoryTexture TerritoryTexture
void ResetCameraTarget(const CVector3D &target)
A value with exponential decay towards the target value.
void SetProjection(float nearp, float farp, float fov)
void RotateX(float angle)
void setDrawState(bool value)
static void SetupCameraMatrixNonSmooth(CGameViewImpl *m, CMatrix3D *orientation)