mirror of
https://github.com/overte-org/overte.git
synced 2025-04-29 20:22:40 +02:00
Initial commit
This commit is contained in:
parent
e66b4f1761
commit
8d89ea75f5
3 changed files with 20 additions and 3 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include "SecondaryCamera.h"
|
#include "SecondaryCamera.h"
|
||||||
#include <TextureCache.h>
|
#include <TextureCache.h>
|
||||||
#include <gpu/Context.h>
|
#include <gpu/Context.h>
|
||||||
|
#include <EntityScriptingInterface.h>
|
||||||
|
|
||||||
using RenderArgsPointer = std::shared_ptr<RenderArgs>;
|
using RenderArgsPointer = std::shared_ptr<RenderArgs>;
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ void SecondaryCameraRenderTaskConfig::resetSizeSpectatorCamera(int width, int he
|
||||||
}
|
}
|
||||||
|
|
||||||
class BeginSecondaryCameraFrame { // Changes renderContext for our framebuffer and view.
|
class BeginSecondaryCameraFrame { // Changes renderContext for our framebuffer and view.
|
||||||
|
QUuid _attachedEntityId{};
|
||||||
glm::vec3 _position{};
|
glm::vec3 _position{};
|
||||||
glm::quat _orientation{};
|
glm::quat _orientation{};
|
||||||
float _vFoV{};
|
float _vFoV{};
|
||||||
|
@ -54,8 +56,20 @@ public:
|
||||||
|
|
||||||
void configure(const Config& config) {
|
void configure(const Config& config) {
|
||||||
if (config.enabled || config.alwaysEnabled) {
|
if (config.enabled || config.alwaysEnabled) {
|
||||||
_position = config.position;
|
_attachedEntityId = config.attachedEntityId;
|
||||||
_orientation = config.orientation;
|
if (_attachedEntityId != QUuid()) {
|
||||||
|
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||||
|
EntityPropertyFlags entityPropertyFlags;
|
||||||
|
entityPropertyFlags += PROP_POSITION;
|
||||||
|
entityPropertyFlags += PROP_ROTATION;
|
||||||
|
EntityItemProperties entityProperties = entityScriptingInterface->getEntityProperties(config.attachedEntityId, entityPropertyFlags);
|
||||||
|
|
||||||
|
_position = entityProperties.getPosition();
|
||||||
|
_orientation = entityProperties.getRotation();
|
||||||
|
} else {
|
||||||
|
_position = config.position;
|
||||||
|
_orientation = config.orientation;
|
||||||
|
}
|
||||||
_vFoV = config.vFoV;
|
_vFoV = config.vFoV;
|
||||||
_nearClipPlaneDistance = config.nearClipPlaneDistance;
|
_nearClipPlaneDistance = config.nearClipPlaneDistance;
|
||||||
_farClipPlaneDistance = config.farClipPlaneDistance;
|
_farClipPlaneDistance = config.farClipPlaneDistance;
|
||||||
|
|
|
@ -30,12 +30,14 @@ public:
|
||||||
|
|
||||||
class BeginSecondaryCameraFrameConfig : public render::Task::Config { // Exposes secondary camera parameters to JavaScript.
|
class BeginSecondaryCameraFrameConfig : public render::Task::Config { // Exposes secondary camera parameters to JavaScript.
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QUuid attachedEntityId MEMBER attachedEntityId NOTIFY dirty) // entity whose properties define camera position and orientation
|
||||||
Q_PROPERTY(glm::vec3 position MEMBER position NOTIFY dirty) // of viewpoint to render from
|
Q_PROPERTY(glm::vec3 position MEMBER position NOTIFY dirty) // of viewpoint to render from
|
||||||
Q_PROPERTY(glm::quat orientation MEMBER orientation NOTIFY dirty) // of viewpoint to render from
|
Q_PROPERTY(glm::quat orientation MEMBER orientation NOTIFY dirty) // of viewpoint to render from
|
||||||
Q_PROPERTY(float vFoV MEMBER vFoV NOTIFY dirty) // Secondary camera's vertical field of view. In degrees.
|
Q_PROPERTY(float vFoV MEMBER vFoV NOTIFY dirty) // Secondary camera's vertical field of view. In degrees.
|
||||||
Q_PROPERTY(float nearClipPlaneDistance MEMBER nearClipPlaneDistance NOTIFY dirty) // Secondary camera's near clip plane distance. In meters.
|
Q_PROPERTY(float nearClipPlaneDistance MEMBER nearClipPlaneDistance NOTIFY dirty) // Secondary camera's near clip plane distance. In meters.
|
||||||
Q_PROPERTY(float farClipPlaneDistance MEMBER farClipPlaneDistance NOTIFY dirty) // Secondary camera's far clip plane distance. In meters.
|
Q_PROPERTY(float farClipPlaneDistance MEMBER farClipPlaneDistance NOTIFY dirty) // Secondary camera's far clip plane distance. In meters.
|
||||||
public:
|
public:
|
||||||
|
QUuid attachedEntityId{};
|
||||||
glm::vec3 position{};
|
glm::vec3 position{};
|
||||||
glm::quat orientation{};
|
glm::quat orientation{};
|
||||||
float vFoV{ 45.0f };
|
float vFoV{ 45.0f };
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
beginSpectatorFrameRenderConfig.nearClipPlaneDistance = nearClipPlaneDistance;
|
beginSpectatorFrameRenderConfig.nearClipPlaneDistance = nearClipPlaneDistance;
|
||||||
beginSpectatorFrameRenderConfig.farClipPlaneDistance = farClipPlaneDistance;
|
beginSpectatorFrameRenderConfig.farClipPlaneDistance = farClipPlaneDistance;
|
||||||
cameraRotation = MyAvatar.orientation, cameraPosition = inFrontOf(1, Vec3.sum(MyAvatar.position, { x: 0, y: 0.3, z: 0 }));
|
cameraRotation = MyAvatar.orientation, cameraPosition = inFrontOf(1, Vec3.sum(MyAvatar.position, { x: 0, y: 0.3, z: 0 }));
|
||||||
cameraUpdateInterval = Script.setInterval(updateRenderFromCamera, 11); // Update every 11ms (90.9hz)
|
//cameraUpdateInterval = Script.setInterval(updateRenderFromCamera, 11); // Update every 11ms (90.9hz)
|
||||||
camera = Entities.addEntity({
|
camera = Entities.addEntity({
|
||||||
"angularDamping": 1,
|
"angularDamping": 1,
|
||||||
"damping": 1,
|
"damping": 1,
|
||||||
|
@ -112,6 +112,7 @@
|
||||||
"type": "Model",
|
"type": "Model",
|
||||||
"userData": "{\"grabbableKey\":{\"grabbable\":true}}"
|
"userData": "{\"grabbableKey\":{\"grabbable\":true}}"
|
||||||
}, true);
|
}, true);
|
||||||
|
beginSpectatorFrameRenderConfig.attachedEntityId = camera;
|
||||||
updateOverlay();
|
updateOverlay();
|
||||||
setDisplay(monitorShowsCameraView);
|
setDisplay(monitorShowsCameraView);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue