Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/scripting/JSInterface_GameView.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
REGISTER_BOOLEAN_SCRIPT_SETTING(Culling); | REGISTER_BOOLEAN_SCRIPT_SETTING(Culling); | ||||
REGISTER_BOOLEAN_SCRIPT_SETTING(LockCullCamera); | REGISTER_BOOLEAN_SCRIPT_SETTING(LockCullCamera); | ||||
REGISTER_BOOLEAN_SCRIPT_SETTING(ConstrainCamera); | REGISTER_BOOLEAN_SCRIPT_SETTING(ConstrainCamera); | ||||
} | } | ||||
#undef REGISTER_BOOLEAN_SCRIPT_SETTING | #undef REGISTER_BOOLEAN_SCRIPT_SETTING | ||||
JS::Value GetCameraPosition(const ScriptRequest& rq) | |||||
{ | |||||
CVector3D pos(-1, -1, -1); | |||||
if (g_Game && g_Game->GetView()) | |||||
pos = g_Game->GetView()->GetCameraPosition(); | |||||
JS::RootedValue val(rq.cx); | |||||
Script::CreateObject(rq, &val, "x", pos.X, "y", pos.X, "z", pos.Z); | |||||
return val; | |||||
} | |||||
JS::Value GetCameraRotation(const ScriptRequest& rq) | |||||
{ | |||||
CVector3D pos(-1, -1, -1); | |||||
if (g_Game && g_Game->GetView()) | |||||
pos = g_Game->GetView()->GetCamera()->GetOrientation().GetIn(); | |||||
JS::RootedValue val(rq.cx); | |||||
Script::CreateObject(rq, &val, "x", pos.X, "y", pos.Y, "z", pos.Z); | |||||
return val; | |||||
} | |||||
JS::Value GetCameraPivot(const ScriptRequest& rq) | JS::Value GetCameraPivot(const ScriptRequest& rq) | ||||
{ | { | ||||
CVector3D pivot(-1, -1, -1); | CVector3D pivot(-1, -1, -1); | ||||
if (g_Game && g_Game->GetView()) | if (g_Game && g_Game->GetView()) | ||||
pivot = g_Game->GetView()->GetCameraPivot(); | pivot = g_Game->GetView()->GetCameraPivot(); | ||||
JS::RootedValue pivotValue(rq.cx); | JS::RootedValue pivotValue(rq.cx); | ||||
Script::CreateObject(rq, &pivotValue, "x", pivot.X, "z", pivot.Z); | Script::CreateObject(rq, &pivotValue, "x", pivot.X, "z", pivot.Z); | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | CFixedVector3D GetTerrainAtScreenPoint(int x, int y) | ||||
CVector3D pos = g_Game->GetView()->GetCamera()->GetWorldCoordinates(x, y, true); | CVector3D pos = g_Game->GetView()->GetCamera()->GetWorldCoordinates(x, y, true); | ||||
return CFixedVector3D(fixed::FromFloat(pos.X), fixed::FromFloat(pos.Y), fixed::FromFloat(pos.Z)); | return CFixedVector3D(fixed::FromFloat(pos.X), fixed::FromFloat(pos.Y), fixed::FromFloat(pos.Z)); | ||||
} | } | ||||
void RegisterScriptFunctions(const ScriptRequest& rq) | void RegisterScriptFunctions(const ScriptRequest& rq) | ||||
{ | { | ||||
RegisterScriptFunctions_Settings(rq); | RegisterScriptFunctions_Settings(rq); | ||||
ScriptFunction::Register<&GetCameraPosition>(rq, "GetCameraPosition"); | |||||
ScriptFunction::Register<&GetCameraRotation>(rq, "GetCameraRotation"); | |||||
ScriptFunction::Register<&GetCameraPivot>(rq, "GetCameraPivot"); | ScriptFunction::Register<&GetCameraPivot>(rq, "GetCameraPivot"); | ||||
ScriptFunction::Register<&CameraMoveTo>(rq, "CameraMoveTo"); | ScriptFunction::Register<&CameraMoveTo>(rq, "CameraMoveTo"); | ||||
ScriptFunction::Register<&SetCameraTarget>(rq, "SetCameraTarget"); | ScriptFunction::Register<&SetCameraTarget>(rq, "SetCameraTarget"); | ||||
ScriptFunction::Register<&SetCameraData>(rq, "SetCameraData"); | ScriptFunction::Register<&SetCameraData>(rq, "SetCameraData"); | ||||
ScriptFunction::Register<&CameraFollow>(rq, "CameraFollow"); | ScriptFunction::Register<&CameraFollow>(rq, "CameraFollow"); | ||||
ScriptFunction::Register<&CameraFollowFPS>(rq, "CameraFollowFPS"); | ScriptFunction::Register<&CameraFollowFPS>(rq, "CameraFollowFPS"); | ||||
ScriptFunction::Register<&GetFollowedEntity>(rq, "GetFollowedEntity"); | ScriptFunction::Register<&GetFollowedEntity>(rq, "GetFollowedEntity"); | ||||
ScriptFunction::Register<&GetTerrainAtScreenPoint>(rq, "GetTerrainAtScreenPoint"); | ScriptFunction::Register<&GetTerrainAtScreenPoint>(rq, "GetTerrainAtScreenPoint"); | ||||
} | } | ||||
} | } |
Wildfire Games · Phabricator