Skip to content

Commit

Permalink
Add original camera restriction values for specific targets
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed Feb 12, 2024
1 parent f8524d4 commit 6bc292c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 49 deletions.
24 changes: 20 additions & 4 deletions Source/Game/CameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ const float CAMERA_MOUSE_DEAD_THRESHOLD = 0.5f;
//Multiplier of delta speed from center to edge of area
const float CAMERA_MOUSE_DELTA_FACTOR = 1.5f;

const float CAMERA_ZOOM_GROUND_MAX = 100.0f;
const float CAMERA_MIN_HEIGHT = 200.0f;
#if defined(GPX) || 0
//Original game values
const float CAMERA_MAX_HEIGHT = 2000.0f;
const float CAMERA_THETA_MIN = static_cast<float>(XM_PI/10.0);
const float CAMERA_THETA_MAX = static_cast<float>(XM_PI/3.0);
#else
const float CAMERA_MAX_HEIGHT = 5000.0f;
const float CAMERA_THETA_MIN = static_cast<float>(XM_PI/5.0);
const float CAMERA_THETA_MAX = static_cast<float>(XM_PI/2.85);
#endif
const float CAMERA_ZOOM_MAX = CAMERA_MAX_HEIGHT / 2.0f;
const float CAMERA_ZOOM_MIN = CAMERA_MIN_HEIGHT + 100.0f;
const float CAMERA_ZOOM_TERRAIN_THRESOLD1 = CAMERA_ZOOM_MIN + CAMERA_ZOOM_GROUND_MAX;
const float CAMERA_ZOOM_TERRAIN_THRESOLD2 = CAMERA_ZOOM_MAX;

void SetCameraPosition(cCamera *UCamera,const MatXf& Matrix)
{
MatXf ml=MatXf::ID;
Expand Down Expand Up @@ -76,18 +93,17 @@ void CameraCoordinate::interpolateHermite(const CameraCoordinate coords[4], floa

void CameraCoordinate::check(bool restricted)
{
float z = FieldCluster::ZeroGround;//(float)(vMap.GetAlt(vMap.XCYCL(round(position().x)),vMap.YCYCL(xm::round(position().y))) >> VX_FRACTION);
float zm = 100;
static float z = FieldCluster::ZeroGround;//(float)(vMap.GetAlt(vMap.XCYCL(round(position().x)),vMap.YCYCL(xm::round(position().y))) >> VX_FRACTION);

position_.z = z;

if(distance() < CAMERA_ZOOM_TERRAIN_THRESOLD1)
position_.z = z;
else if(distance() > CAMERA_ZOOM_TERRAIN_THRESOLD2)
position_.z = zm;
position_.z = CAMERA_ZOOM_GROUND_MAX;
else{
float t = (distance() - CAMERA_ZOOM_TERRAIN_THRESOLD1)/(CAMERA_ZOOM_TERRAIN_THRESOLD2 - CAMERA_ZOOM_TERRAIN_THRESOLD1);
position_.z = z + t*(zm - z);
position_.z = z + t*(CAMERA_ZOOM_GROUND_MAX - z);
}

float scroll_border = (distance() - CAMERA_ZOOM_MIN)/(CAMERA_ZOOM_MAX - CAMERA_ZOOM_MIN)*CAMERA_WORLD_SCROLL_BORDER;
Expand Down
24 changes: 3 additions & 21 deletions Source/Game/Scripts/Config.cppi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//////////////////////////////////////////////////////////////////////////////////////////////
// XScript definition
// Section: GameConfig
// Number of variables: 156
// Number of variables: 147
// This is computer generated code, don't try to change it
//////////////////////////////////////////////////////////////////////////////////////////////
char const* MainModelPath = "RESOURCE\\MODELS\\MAIN";
Expand Down Expand Up @@ -37,16 +37,7 @@ float CAMERA_ZOOM_MOUSE_MULT = 300.f;
float CAMERA_ZOOM_SPEED_DAMP = 0.7f;
float CAMERA_ZOOM_SPEED_MASS = 2.f;
float CAMERA_FOLLOW_AVERAGE_TAU = 0.1f;
float CAMERA_MAX_HEIGHT = 5000.f;
float CAMERA_MIN_HEIGHT = 200.f;
float CAMERA_DEFAULT_HEIGHT = 500.f;
float CAMERA_MOVE_ZOOM_SCALE = 500.f;
float CAMERA_ZOOM_MIN = 300.f;
float CAMERA_ZOOM_MAX = 2500.f;
float CAMERA_THETA_MIN = 0.62831853f;
float CAMERA_THETA_MAX = 1.10231321f;
float CAMERA_ZOOM_TERRAIN_THRESOLD1 = 300.f;
float CAMERA_ZOOM_TERRAIN_THRESOLD2 = 5000.f;
float CAMERA_WORLD_SCROLL_BORDER = 200.f;
int CAMERA_REPLAY_DURATION = 4000;
float fSoundWidthPower = 0.5f;
Expand Down Expand Up @@ -283,8 +274,8 @@ struct GameConfig_ParameterSection : ParameterSection
GameConfig_ParameterSection() : ParameterSection("GameConfig")
{
add_dependency(".\\Scripts\\Config.prm");
description = 911353322;
reserve(156);
description = 300575160;
reserve(147);
add(&MainModelPath, "MainModelPath", 3964076972);
add(&MainIconPath, "MainIconPath", 607302846);
add(&MainFontPath, "MainFontPath", 2303156941);
Expand Down Expand Up @@ -318,16 +309,7 @@ struct GameConfig_ParameterSection : ParameterSection
add(&CAMERA_ZOOM_SPEED_DAMP, "CAMERA_ZOOM_SPEED_DAMP", 2872307499);
add(&CAMERA_ZOOM_SPEED_MASS, "CAMERA_ZOOM_SPEED_MASS", 3904040745);
add(&CAMERA_FOLLOW_AVERAGE_TAU, "CAMERA_FOLLOW_AVERAGE_TAU", 474877919);
add(&CAMERA_MAX_HEIGHT, "CAMERA_MAX_HEIGHT", 1464480313);
add(&CAMERA_MIN_HEIGHT, "CAMERA_MIN_HEIGHT", 3075093338);
add(&CAMERA_DEFAULT_HEIGHT, "CAMERA_DEFAULT_HEIGHT", 1616833279);
add(&CAMERA_MOVE_ZOOM_SCALE, "CAMERA_MOVE_ZOOM_SCALE", 641674670);
add(&CAMERA_ZOOM_MIN, "CAMERA_ZOOM_MIN", 4004499475);
add(&CAMERA_ZOOM_MAX, "CAMERA_ZOOM_MAX", 581947408);
add(&CAMERA_THETA_MIN, "CAMERA_THETA_MIN", 660596487);
add(&CAMERA_THETA_MAX, "CAMERA_THETA_MAX", 3948930820);
add(&CAMERA_ZOOM_TERRAIN_THRESOLD1, "CAMERA_ZOOM_TERRAIN_THRESOLD1", 2692298187);
add(&CAMERA_ZOOM_TERRAIN_THRESOLD2, "CAMERA_ZOOM_TERRAIN_THRESOLD2", 2524526027);
add(&CAMERA_WORLD_SCROLL_BORDER, "CAMERA_WORLD_SCROLL_BORDER", 293303500);
add(&CAMERA_REPLAY_DURATION, "CAMERA_REPLAY_DURATION", 2253522128);
add(&fSoundWidthPower, "fSoundWidthPower", 1475050467);
Expand Down
11 changes: 1 addition & 10 deletions Source/Game/Scripts/Config.hi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//////////////////////////////////////////////////////////////////////////////////////////////
// XScript declaration
// Section: GameConfig
// Number of variables: 156
// Number of variables: 147
// This is computer generated code, don't try to change it
//////////////////////////////////////////////////////////////////////////////////////////////
extern char const* MainModelPath;
Expand Down Expand Up @@ -37,16 +37,7 @@ extern float CAMERA_ZOOM_MOUSE_MULT;
extern float CAMERA_ZOOM_SPEED_DAMP;
extern float CAMERA_ZOOM_SPEED_MASS;
extern float CAMERA_FOLLOW_AVERAGE_TAU;
extern float CAMERA_MAX_HEIGHT;
extern float CAMERA_MIN_HEIGHT;
extern float CAMERA_DEFAULT_HEIGHT;
extern float CAMERA_MOVE_ZOOM_SCALE;
extern float CAMERA_ZOOM_MIN;
extern float CAMERA_ZOOM_MAX;
extern float CAMERA_THETA_MIN;
extern float CAMERA_THETA_MAX;
extern float CAMERA_ZOOM_TERRAIN_THRESOLD1;
extern float CAMERA_ZOOM_TERRAIN_THRESOLD2;
extern float CAMERA_WORLD_SCROLL_BORDER;
extern int CAMERA_REPLAY_DURATION;
extern float fSoundWidthPower;
Expand Down
14 changes: 0 additions & 14 deletions Source/Scripts/Config.prm
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,9 @@ float CAMERA_ZOOM_SPEED_DELTA = 10.0f;
float CAMERA_ZOOM_MOUSE_MULT = 300.0f;
float CAMERA_ZOOM_SPEED_DAMP = 0.7f;
float CAMERA_ZOOM_SPEED_MASS = 2.0f;

float CAMERA_FOLLOW_AVERAGE_TAU = 0.1;

//ограничения
float CAMERA_MAX_HEIGHT = 5000.0f;
float CAMERA_MIN_HEIGHT = 200.0f;
float CAMERA_DEFAULT_HEIGHT = 500.0f;
float CAMERA_MOVE_ZOOM_SCALE = 500.0f;

float CAMERA_ZOOM_MIN = 300.0f;
float CAMERA_ZOOM_MAX = 2500.0f;
float CAMERA_THETA_MIN = _PI/5.0f;
float CAMERA_THETA_MAX = _PI/2.85f;

float CAMERA_ZOOM_TERRAIN_THRESOLD1 = CAMERA_MIN_HEIGHT + 100.0f;
float CAMERA_ZOOM_TERRAIN_THRESOLD2 = CAMERA_MAX_HEIGHT;

float CAMERA_WORLD_SCROLL_BORDER = 200.0f;

int CAMERA_REPLAY_DURATION = 4000;
Expand Down

0 comments on commit 6bc292c

Please sign in to comment.