mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-06 23:59:18 +08:00
Merge pull request #337 from IvanPragma/camera
Changing camera attributes from python layer
This commit is contained in:
commit
197eca46ce
@ -1,6 +1,7 @@
|
|||||||
### 1.6.6 (20394)
|
### 1.6.6 (20394)
|
||||||
- Beginning work on moving to new asset system.
|
- Beginning work on moving to new asset system.
|
||||||
- Added Tamil language (Thanks Ryan!)
|
- Added Tamil language (Thanks Ryan!)
|
||||||
|
- Added methods for changing camera attributes to the _ba module.
|
||||||
|
|
||||||
### 1.6.5 (20394)
|
### 1.6.5 (20394)
|
||||||
- Added co-op support to server builds (thanks Dliwk!)
|
- Added co-op support to server builds (thanks Dliwk!)
|
||||||
|
|||||||
@ -26,3 +26,6 @@
|
|||||||
|
|
||||||
### Ritiek Malhotra
|
### Ritiek Malhotra
|
||||||
- Just <3 BombSquad
|
- Just <3 BombSquad
|
||||||
|
|
||||||
|
### Ivan Ms
|
||||||
|
- Few camera features
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
291441930138756424684870937756526517762
|
206834682288822241335693999070871022992
|
||||||
@ -2008,6 +2008,22 @@ def get_appconfig_default_value(key: str) -> Any:
|
|||||||
return _uninferrable()
|
return _uninferrable()
|
||||||
|
|
||||||
|
|
||||||
|
def get_camera_position() -> tuple[float, ...]:
|
||||||
|
"""get_camera_position() -> tuple[float, ...]
|
||||||
|
|
||||||
|
(internal)
|
||||||
|
"""
|
||||||
|
return (0.0, 0.0, 0.0)
|
||||||
|
|
||||||
|
|
||||||
|
def get_camera_target() -> tuple[float, ...]:
|
||||||
|
"""get_camera_target() -> tuple[float, ...]
|
||||||
|
|
||||||
|
(internal)
|
||||||
|
"""
|
||||||
|
return (0.0, 0.0, 0.0)
|
||||||
|
|
||||||
|
|
||||||
def get_chat_messages() -> list[str]:
|
def get_chat_messages() -> list[str]:
|
||||||
"""get_chat_messages() -> list[str]
|
"""get_chat_messages() -> list[str]
|
||||||
|
|
||||||
@ -3485,6 +3501,30 @@ def set_authenticate_clients(enable: bool) -> None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def set_camera_manual(value: bool) -> None:
|
||||||
|
"""set_camera_manual(value: bool) -> None
|
||||||
|
|
||||||
|
(internal)
|
||||||
|
"""
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def set_camera_position(x: float, y: float, z: float) -> None:
|
||||||
|
"""set_camera_position(x: float, y: float, z: float) -> None
|
||||||
|
|
||||||
|
(internal)
|
||||||
|
"""
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def set_camera_target(x: float, y: float, z: float) -> None:
|
||||||
|
"""set_camera_target(x: float, y: float, z: float) -> None
|
||||||
|
|
||||||
|
(internal)
|
||||||
|
"""
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def set_debug_speed_exponent(speed: int) -> None:
|
def set_debug_speed_exponent(speed: int) -> None:
|
||||||
"""set_debug_speed_exponent(speed: int) -> None
|
"""set_debug_speed_exponent(speed: int) -> None
|
||||||
|
|
||||||
|
|||||||
@ -672,9 +672,8 @@ void Joystick::HandleSDLEvent(const SDL_Event* e) {
|
|||||||
e2.jaxis.axis = static_cast_check_fit<uint8_t>(analog_lr_);
|
e2.jaxis.axis = static_cast_check_fit<uint8_t>(analog_lr_);
|
||||||
dpad_right_held_ = (e->type == SDL_JOYBUTTONDOWN);
|
dpad_right_held_ = (e->type == SDL_JOYBUTTONDOWN);
|
||||||
e2.jaxis.value = static_cast_check_fit<int16_t>(
|
e2.jaxis.value = static_cast_check_fit<int16_t>(
|
||||||
dpad_right_held_ ? (dpad_left_held_ ? 0 : 32767)
|
dpad_right_held_ ? (dpad_left_held_ ? 0 : 32767)
|
||||||
: dpad_left_held_ ? -32767
|
: dpad_left_held_ ? -32767 : 0);
|
||||||
: 0);
|
|
||||||
e = &e2;
|
e = &e2;
|
||||||
} else if (e->jbutton.button == left_button_
|
} else if (e->jbutton.button == left_button_
|
||||||
|| e->jbutton.button == left_button2_) {
|
|| e->jbutton.button == left_button2_) {
|
||||||
@ -682,9 +681,8 @@ void Joystick::HandleSDLEvent(const SDL_Event* e) {
|
|||||||
e2.jaxis.axis = static_cast_check_fit<uint8_t>(analog_lr_);
|
e2.jaxis.axis = static_cast_check_fit<uint8_t>(analog_lr_);
|
||||||
dpad_left_held_ = (e->type == SDL_JOYBUTTONDOWN);
|
dpad_left_held_ = (e->type == SDL_JOYBUTTONDOWN);
|
||||||
e2.jaxis.value = static_cast_check_fit<int16_t>(
|
e2.jaxis.value = static_cast_check_fit<int16_t>(
|
||||||
dpad_right_held_ ? (dpad_left_held_ ? 0 : 32767)
|
dpad_right_held_ ? (dpad_left_held_ ? 0 : 32767)
|
||||||
: dpad_left_held_ ? -32767
|
: dpad_left_held_ ? -32767 : 0);
|
||||||
: 0);
|
|
||||||
e = &e2;
|
e = &e2;
|
||||||
} else if (e->jbutton.button == up_button_
|
} else if (e->jbutton.button == up_button_
|
||||||
|| e->jbutton.button == up_button2_) {
|
|| e->jbutton.button == up_button2_) {
|
||||||
@ -692,9 +690,8 @@ void Joystick::HandleSDLEvent(const SDL_Event* e) {
|
|||||||
e2.jaxis.axis = static_cast_check_fit<uint8_t>(analog_ud_);
|
e2.jaxis.axis = static_cast_check_fit<uint8_t>(analog_ud_);
|
||||||
dpad_up_held_ = (e->type == SDL_JOYBUTTONDOWN);
|
dpad_up_held_ = (e->type == SDL_JOYBUTTONDOWN);
|
||||||
e2.jaxis.value = static_cast_check_fit<int16_t>(
|
e2.jaxis.value = static_cast_check_fit<int16_t>(
|
||||||
dpad_up_held_ ? (dpad_down_held_ ? 0 : -32767)
|
dpad_up_held_ ? (dpad_down_held_ ? 0 : -32767)
|
||||||
: dpad_down_held_ ? 32767
|
: dpad_down_held_ ? 32767 : 0);
|
||||||
: 0);
|
|
||||||
e = &e2;
|
e = &e2;
|
||||||
} else if (e->jbutton.button == down_button_
|
} else if (e->jbutton.button == down_button_
|
||||||
|| e->jbutton.button == down_button2_) {
|
|| e->jbutton.button == down_button2_) {
|
||||||
@ -702,9 +699,8 @@ void Joystick::HandleSDLEvent(const SDL_Event* e) {
|
|||||||
e2.jaxis.axis = static_cast_check_fit<uint8_t>(analog_ud_);
|
e2.jaxis.axis = static_cast_check_fit<uint8_t>(analog_ud_);
|
||||||
dpad_down_held_ = (e->type == SDL_JOYBUTTONDOWN);
|
dpad_down_held_ = (e->type == SDL_JOYBUTTONDOWN);
|
||||||
e2.jaxis.value = static_cast_check_fit<int16_t>(
|
e2.jaxis.value = static_cast_check_fit<int16_t>(
|
||||||
dpad_up_held_ ? (dpad_down_held_ ? 0 : -32767)
|
dpad_up_held_ ? (dpad_down_held_ ? 0 : -32767)
|
||||||
: dpad_down_held_ ? 32767
|
: dpad_down_held_ ? 32767 : 0);
|
||||||
: 0);
|
|
||||||
e = &e2;
|
e = &e2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
#include "ballistica/python/methods/python_methods_graphics.h"
|
#include "ballistica/python/methods/python_methods_graphics.h"
|
||||||
|
|
||||||
#include "ballistica/game/game.h"
|
#include "ballistica/game/game.h"
|
||||||
|
#include "ballistica/graphics/camera.h"
|
||||||
#include "ballistica/graphics/graphics.h"
|
#include "ballistica/graphics/graphics.h"
|
||||||
#include "ballistica/graphics/text/text_graphics.h"
|
#include "ballistica/graphics/text/text_graphics.h"
|
||||||
#include "ballistica/platform/platform.h"
|
#include "ballistica/platform/platform.h"
|
||||||
@ -16,6 +17,84 @@ namespace ballistica {
|
|||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma ide diagnostic ignored "hicpp-signed-bitwise"
|
#pragma ide diagnostic ignored "hicpp-signed-bitwise"
|
||||||
|
|
||||||
|
auto PyGetCameraPosition(PyObject* self, PyObject* args, PyObject* keywds)
|
||||||
|
-> PyObject* {
|
||||||
|
BA_PYTHON_TRY;
|
||||||
|
Platform::SetLastPyCall("get_camera_position");
|
||||||
|
float x = 0.0f;
|
||||||
|
float y = 0.0f;
|
||||||
|
float z = 0.0f;
|
||||||
|
Camera* cam = g_graphics->camera();
|
||||||
|
cam->get_position(&x, &y, &z);
|
||||||
|
return Py_BuildValue("(fff)", x, y, z);
|
||||||
|
BA_PYTHON_CATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto PyGetCameraTarget(PyObject* self, PyObject* args, PyObject* keywds)
|
||||||
|
-> PyObject* {
|
||||||
|
BA_PYTHON_TRY;
|
||||||
|
Platform::SetLastPyCall("get_camera_target");
|
||||||
|
float x = 0.0f;
|
||||||
|
float y = 0.0f;
|
||||||
|
float z = 0.0f;
|
||||||
|
Camera* cam = g_graphics->camera();
|
||||||
|
cam->target_smoothed(&x, &y, &z);
|
||||||
|
return Py_BuildValue("(fff)", x, y, z);
|
||||||
|
BA_PYTHON_CATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto PySetCameraPosition(PyObject* self, PyObject* args, PyObject* keywds)
|
||||||
|
-> PyObject* {
|
||||||
|
BA_PYTHON_TRY;
|
||||||
|
Platform::SetLastPyCall("set_camera_position");
|
||||||
|
float x = 0.0f;
|
||||||
|
float y = 0.0f;
|
||||||
|
float z = 0.0f;
|
||||||
|
static const char* kwlist[] = {"x", "y", "z", nullptr};
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(args, keywds, "fff",
|
||||||
|
const_cast<char**>(kwlist), &x, &y, &z)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
assert(g_game);
|
||||||
|
g_graphics->camera()->SetPosition(x, y, z);
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
BA_PYTHON_CATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto PySetCameraTarget(PyObject* self, PyObject* args, PyObject* keywds)
|
||||||
|
-> PyObject* {
|
||||||
|
BA_PYTHON_TRY;
|
||||||
|
Platform::SetLastPyCall("set_camera_target");
|
||||||
|
float x = 0.0f;
|
||||||
|
float y = 0.0f;
|
||||||
|
float z = 0.0f;
|
||||||
|
static const char* kwlist[] = {"x", "y", "z", nullptr};
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(args, keywds, "fff",
|
||||||
|
const_cast<char**>(kwlist), &x, &y, &z)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
assert(g_game);
|
||||||
|
g_graphics->camera()->SetTarget(x, y, z);
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
BA_PYTHON_CATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto PySetCameraManual(PyObject* self, PyObject* args, PyObject* keywds)
|
||||||
|
-> PyObject* {
|
||||||
|
BA_PYTHON_TRY;
|
||||||
|
Platform::SetLastPyCall("set_camera_manual");
|
||||||
|
bool value = false;
|
||||||
|
static const char* kwlist[] = {"value", nullptr};
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(args, keywds, "b",
|
||||||
|
const_cast<char**>(kwlist), &value)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
assert(g_game);
|
||||||
|
g_graphics->camera()->SetManual(value);
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
BA_PYTHON_CATCH;
|
||||||
|
}
|
||||||
|
|
||||||
auto PyCharStr(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
|
auto PyCharStr(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
|
||||||
BA_PYTHON_TRY;
|
BA_PYTHON_TRY;
|
||||||
Platform::SetLastPyCall("charstr");
|
Platform::SetLastPyCall("charstr");
|
||||||
@ -232,6 +311,36 @@ auto PythonMethodsGraphics::GetMethods() -> std::vector<PyMethodDef> {
|
|||||||
"Return the currently selected display resolution for fullscreen\n"
|
"Return the currently selected display resolution for fullscreen\n"
|
||||||
"display. Returns None if resolutions cannot be directly set."},
|
"display. Returns None if resolutions cannot be directly set."},
|
||||||
|
|
||||||
|
{"get_camera_position", (PyCFunction)PyGetCameraPosition,
|
||||||
|
METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"get_camera_position() -> tuple[float, ...]\n"
|
||||||
|
"\n"
|
||||||
|
"(internal)"},
|
||||||
|
|
||||||
|
{"get_camera_target", (PyCFunction)PyGetCameraTarget,
|
||||||
|
METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"get_camera_target() -> tuple[float, ...]\n"
|
||||||
|
"\n"
|
||||||
|
"(internal)"},
|
||||||
|
|
||||||
|
{"set_camera_position", (PyCFunction)PySetCameraPosition,
|
||||||
|
METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"set_camera_position(x: float, y: float, z: float) -> None\n"
|
||||||
|
"\n"
|
||||||
|
"(internal)"},
|
||||||
|
|
||||||
|
{"set_camera_target", (PyCFunction)PySetCameraTarget,
|
||||||
|
METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"set_camera_target(x: float, y: float, z: float) -> None\n"
|
||||||
|
"\n"
|
||||||
|
"(internal)"},
|
||||||
|
|
||||||
|
{"set_camera_manual", (PyCFunction)PySetCameraManual,
|
||||||
|
METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"set_camera_manual(value: bool) -> None\n"
|
||||||
|
"\n"
|
||||||
|
"(internal)"},
|
||||||
|
|
||||||
{"has_gamma_control", PyHasGammaControl, METH_VARARGS,
|
{"has_gamma_control", PyHasGammaControl, METH_VARARGS,
|
||||||
"has_gamma_control() -> bool\n"
|
"has_gamma_control() -> bool\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|||||||
@ -214,8 +214,8 @@ void ImageNode::Draw(FrameDef* frame_def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RenderPass& pass(*(vr_use_fixed ? frame_def->GetOverlayFixedPass()
|
RenderPass& pass(*(vr_use_fixed ? frame_def->GetOverlayFixedPass()
|
||||||
: front_ ? frame_def->overlay_front_pass()
|
: front_ ? frame_def->overlay_front_pass()
|
||||||
: frame_def->overlay_pass()));
|
: frame_def->overlay_pass()));
|
||||||
|
|
||||||
// If the pass we're drawing into changes dimensions, recalc.
|
// If the pass we're drawing into changes dimensions, recalc.
|
||||||
// Otherwise we break if a window is resized.
|
// Otherwise we break if a window is resized.
|
||||||
|
|||||||
@ -219,9 +219,9 @@ void TerrainNode::Draw(FrameDef* frame_def) {
|
|||||||
if (vr_only_ && !IsVRMode()) {
|
if (vr_only_ && !IsVRMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ObjectComponent c(overlay_ ? frame_def->overlay_3d_pass()
|
ObjectComponent c(overlay_ ? frame_def->overlay_3d_pass()
|
||||||
: background_ ? frame_def->beauty_pass_bg()
|
: background_ ? frame_def->beauty_pass_bg()
|
||||||
: frame_def->beauty_pass());
|
: frame_def->beauty_pass());
|
||||||
c.SetWorldSpace(true);
|
c.SetWorldSpace(true);
|
||||||
c.SetTexture(color_texture_);
|
c.SetTexture(color_texture_);
|
||||||
if (lighting_) {
|
if (lighting_) {
|
||||||
|
|||||||
@ -379,11 +379,11 @@ void TextNode::Draw(FrameDef* frame_def) {
|
|||||||
|
|
||||||
// make sure we're up to date
|
// make sure we're up to date
|
||||||
Update();
|
Update();
|
||||||
RenderPass& pass(*(in_world_
|
RenderPass& pass(
|
||||||
? frame_def->overlay_3d_pass()
|
*(in_world_ ? frame_def->overlay_3d_pass()
|
||||||
: (vr_use_fixed ? frame_def->GetOverlayFixedPass()
|
: (vr_use_fixed ? frame_def->GetOverlayFixedPass()
|
||||||
: front_ ? frame_def->overlay_front_pass()
|
: front_ ? frame_def->overlay_front_pass()
|
||||||
: frame_def->overlay_pass())));
|
: frame_def->overlay_pass())));
|
||||||
if (big_) {
|
if (big_) {
|
||||||
if (text_group_dirty_) {
|
if (text_group_dirty_) {
|
||||||
TextMesh::HAlign h_align;
|
TextMesh::HAlign h_align;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user