mirror of
https://github.com/overte-org/overte.git
synced 2025-06-19 07:40:16 +02:00
Improve naming and API
This commit is contained in:
parent
947a3bf8a8
commit
9bd80ec2bf
4 changed files with 49 additions and 59 deletions
|
@ -1946,7 +1946,7 @@ void Application::initializeGL() {
|
||||||
render::CullFunctor cullFunctor = LODManager::shouldRender;
|
render::CullFunctor cullFunctor = LODManager::shouldRender;
|
||||||
static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
|
static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
|
||||||
bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
|
bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
|
||||||
_renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraFrame", cullFunctor);
|
_renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor);
|
||||||
_renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);
|
_renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);
|
||||||
_renderEngine->load();
|
_renderEngine->load();
|
||||||
_renderEngine->registerScene(_main3DScene);
|
_renderEngine->registerScene(_main3DScene);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
#include "SecondaryCamera.h"
|
#include "SecondaryCamera.h"
|
||||||
#include <TextureCache.h>
|
#include <TextureCache.h>
|
||||||
#include <gpu/Context.h>
|
#include <gpu/Context.h>
|
||||||
|
@ -28,19 +29,7 @@ void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecondaryCameraRenderTaskConfig::resetSize(int width, int height) { // FIXME: Add an arg here for "destinationFramebuffer"
|
class SecondaryCameraJob { // Changes renderContext for our framebuffer and view.
|
||||||
bool wasEnabled = isEnabled();
|
|
||||||
setEnabled(false);
|
|
||||||
auto textureCache = DependencyManager::get<TextureCache>();
|
|
||||||
textureCache->resetSpectatorCameraFramebuffer(width, height); // FIXME: Call the correct reset function based on the "destinationFramebuffer" arg
|
|
||||||
setEnabled(wasEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SecondaryCameraRenderTaskConfig::resetSizeSpectatorCamera(int width, int height) { // Carefully adjust the framebuffer / texture.
|
|
||||||
resetSize(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
class BeginSecondaryCameraFrame { // Changes renderContext for our framebuffer and view.
|
|
||||||
QUuid _attachedEntityId{};
|
QUuid _attachedEntityId{};
|
||||||
glm::vec3 _position{};
|
glm::vec3 _position{};
|
||||||
glm::quat _orientation{};
|
glm::quat _orientation{};
|
||||||
|
@ -50,9 +39,9 @@ class BeginSecondaryCameraFrame { // Changes renderContext for our framebuffer
|
||||||
EntityPropertyFlags _attachedEntityPropertyFlags;
|
EntityPropertyFlags _attachedEntityPropertyFlags;
|
||||||
QSharedPointer<EntityScriptingInterface> _entityScriptingInterface;
|
QSharedPointer<EntityScriptingInterface> _entityScriptingInterface;
|
||||||
public:
|
public:
|
||||||
using Config = BeginSecondaryCameraFrameConfig;
|
using Config = SecondaryCameraJobConfig;
|
||||||
using JobModel = render::Job::ModelO<BeginSecondaryCameraFrame, RenderArgsPointer, Config>;
|
using JobModel = render::Job::ModelO<SecondaryCameraJob, RenderArgsPointer, Config>;
|
||||||
BeginSecondaryCameraFrame() {
|
SecondaryCameraJob() {
|
||||||
_cachedArgsPointer = std::make_shared<RenderArgs>(_cachedArgs);
|
_cachedArgsPointer = std::make_shared<RenderArgs>(_cachedArgs);
|
||||||
_entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
_entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||||
_attachedEntityPropertyFlags += PROP_POSITION;
|
_attachedEntityPropertyFlags += PROP_POSITION;
|
||||||
|
@ -113,6 +102,23 @@ protected:
|
||||||
RenderArgsPointer _cachedArgsPointer;
|
RenderArgsPointer _cachedArgsPointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void SecondaryCameraJobConfig::enableSecondaryCameraRenderConfigs(bool enabled) {
|
||||||
|
qApp->getRenderEngine()->getConfiguration()->getConfig<SecondaryCameraRenderTask>()->setEnabled(enabled);
|
||||||
|
setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SecondaryCameraJobConfig::resetSizeSpectatorCamera(int width, int height) { // Carefully adjust the framebuffer / texture.
|
||||||
|
qApp->getRenderEngine()->getConfiguration()->getConfig<SecondaryCameraRenderTask>()->resetSize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SecondaryCameraRenderTaskConfig::resetSize(int width, int height) { // FIXME: Add an arg here for "destinationFramebuffer"
|
||||||
|
bool wasEnabled = isEnabled();
|
||||||
|
setEnabled(false);
|
||||||
|
auto textureCache = DependencyManager::get<TextureCache>();
|
||||||
|
textureCache->resetSpectatorCameraFramebuffer(width, height); // FIXME: Call the correct reset function based on the "destinationFramebuffer" arg
|
||||||
|
setEnabled(wasEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
class EndSecondaryCameraFrame { // Restores renderContext.
|
class EndSecondaryCameraFrame { // Restores renderContext.
|
||||||
public:
|
public:
|
||||||
using JobModel = render::Job::ModelI<EndSecondaryCameraFrame, RenderArgsPointer>;
|
using JobModel = render::Job::ModelI<EndSecondaryCameraFrame, RenderArgsPointer>;
|
||||||
|
@ -133,7 +139,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor) {
|
void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor) {
|
||||||
const auto cachedArg = task.addJob<BeginSecondaryCameraFrame>("BeginSecondaryCamera");
|
const auto cachedArg = task.addJob<SecondaryCameraJob>("SecondaryCamera");
|
||||||
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor);
|
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor);
|
||||||
assert(items.canCast<RenderFetchCullSortTask::Output>());
|
assert(items.canCast<RenderFetchCullSortTask::Output>());
|
||||||
task.addJob<RenderDeferredTask>("RenderDeferredTask", items);
|
task.addJob<RenderDeferredTask>("RenderDeferredTask", items);
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred = true);
|
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred = true);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BeginSecondaryCameraFrameConfig : public render::Task::Config { // Exposes secondary camera parameters to JavaScript.
|
class SecondaryCameraJobConfig : 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(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
|
||||||
|
@ -43,21 +43,21 @@ public:
|
||||||
float vFoV{ 45.0f };
|
float vFoV{ 45.0f };
|
||||||
float nearClipPlaneDistance{ 0.1f };
|
float nearClipPlaneDistance{ 0.1f };
|
||||||
float farClipPlaneDistance{ 100.0f };
|
float farClipPlaneDistance{ 100.0f };
|
||||||
BeginSecondaryCameraFrameConfig() : render::Task::Config(false) {}
|
SecondaryCameraJobConfig() : render::Task::Config(false) {}
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
public slots:
|
||||||
|
void enableSecondaryCameraRenderConfigs(bool enabled);
|
||||||
|
void resetSizeSpectatorCamera(int width, int height);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SecondaryCameraRenderTaskConfig : public render::Task::Config {
|
class SecondaryCameraRenderTaskConfig : public render::Task::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SecondaryCameraRenderTaskConfig() : render::Task::Config(false) {}
|
SecondaryCameraRenderTaskConfig() : render::Task::Config(false) {}
|
||||||
private:
|
|
||||||
void resetSize(int width, int height);
|
void resetSize(int width, int height);
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
public slots:
|
|
||||||
void resetSizeSpectatorCamera(int width, int height);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SecondaryCameraRenderTask {
|
class SecondaryCameraRenderTask {
|
||||||
|
|
|
@ -28,33 +28,6 @@
|
||||||
Vec3.multiply(distance, Quat.getForward(orientation || MyAvatar.orientation)));
|
Vec3.multiply(distance, Quat.getForward(orientation || MyAvatar.orientation)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function Name: updateRenderFromCamera()
|
|
||||||
//
|
|
||||||
// Description:
|
|
||||||
// -The update function for the spectator camera. Modifies the camera's position
|
|
||||||
// and orientation.
|
|
||||||
//
|
|
||||||
// Relevant Variables:
|
|
||||||
// -spectatorFrameRenderConfig: The render configuration of the spectator camera
|
|
||||||
// render job. It controls the rendered texture size of the spectator camera.
|
|
||||||
// -beginSpectatorFrameRenderConfig: The render configuration of the spectator camera
|
|
||||||
// render job. It controls the orientation and position of the secondary camera whose viewport is rendered to
|
|
||||||
// the texture.
|
|
||||||
// -viewFinderOverlay: The in-world overlay that displays the spectator camera's view.
|
|
||||||
// -camera: The in-world entity that corresponds to the spectator camera.
|
|
||||||
// -cameraIsDynamic: "false" for now while we figure out why dynamic, parented overlays
|
|
||||||
// drift with respect to their parent.
|
|
||||||
var spectatorFrameRenderConfig = Render.getConfig("SecondaryCameraFrame");
|
|
||||||
var beginSpectatorFrameRenderConfig = Render.getConfig("BeginSecondaryCamera");
|
|
||||||
var viewFinderOverlay = false;
|
|
||||||
var camera = false;
|
|
||||||
var cameraIsDynamic = false;
|
|
||||||
function updateRenderFromCamera() {
|
|
||||||
var cameraData = Entities.getEntityProperties(camera, ['position', 'rotation']);
|
|
||||||
beginSpectatorFrameRenderConfig.orientation = cameraData.rotation;
|
|
||||||
beginSpectatorFrameRenderConfig.position = cameraData.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function Name: spectatorCameraOn()
|
// Function Name: spectatorCameraOn()
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -62,6 +35,13 @@
|
||||||
// spawn the camera entity.
|
// spawn the camera entity.
|
||||||
//
|
//
|
||||||
// Relevant Variables:
|
// Relevant Variables:
|
||||||
|
// -spectatorCameraConfig: The render configuration of the spectator camera
|
||||||
|
// render job. It controls the orientation and position of the secondary camera whose viewport is rendered to
|
||||||
|
// the texture, as well as the rendered texture size.
|
||||||
|
// -viewFinderOverlay: The in-world overlay that displays the spectator camera's view.
|
||||||
|
// -camera: The in-world entity that corresponds to the spectator camera.
|
||||||
|
// -cameraIsDynamic: "false" for now while we figure out why dynamic, parented overlays
|
||||||
|
// drift with respect to their parent.
|
||||||
// -vFoV: The vertical field of view of the spectator camera.
|
// -vFoV: The vertical field of view of the spectator camera.
|
||||||
// -nearClipPlaneDistance: The near clip plane distance of the spectator camera (aka "camera").
|
// -nearClipPlaneDistance: The near clip plane distance of the spectator camera (aka "camera").
|
||||||
// -farClipPlaneDistance: The far clip plane distance of the spectator camera.
|
// -farClipPlaneDistance: The far clip plane distance of the spectator camera.
|
||||||
|
@ -71,6 +51,10 @@
|
||||||
// -viewFinderOverlayDim: The x, y, and z dimensions of the viewFinderOverlay.
|
// -viewFinderOverlayDim: The x, y, and z dimensions of the viewFinderOverlay.
|
||||||
// -camera: The camera model which is grabbable.
|
// -camera: The camera model which is grabbable.
|
||||||
// -viewFinderOverlay: The preview of what the spectator camera is viewing, placed inside the glass pane.
|
// -viewFinderOverlay: The preview of what the spectator camera is viewing, placed inside the glass pane.
|
||||||
|
var spectatorCameraConfig = Render.getConfig("SecondaryCamera");
|
||||||
|
var viewFinderOverlay = false;
|
||||||
|
var camera = false;
|
||||||
|
var cameraIsDynamic = false;
|
||||||
var vFoV = 45.0;
|
var vFoV = 45.0;
|
||||||
var nearClipPlaneDistance = 0.1;
|
var nearClipPlaneDistance = 0.1;
|
||||||
var farClipPlaneDistance = 100.0;
|
var farClipPlaneDistance = 100.0;
|
||||||
|
@ -83,11 +67,11 @@
|
||||||
var viewFinderOverlayDim = { x: glassPaneWidth, y: -glassPaneWidth, z: 0 };
|
var viewFinderOverlayDim = { x: glassPaneWidth, y: -glassPaneWidth, z: 0 };
|
||||||
function spectatorCameraOn() {
|
function spectatorCameraOn() {
|
||||||
// Sets the special texture size based on the window it is displayed in, which doesn't include the menu bar
|
// Sets the special texture size based on the window it is displayed in, which doesn't include the menu bar
|
||||||
spectatorFrameRenderConfig.resetSizeSpectatorCamera(Window.innerWidth, Window.innerHeight);
|
spectatorCameraConfig.enableSecondaryCameraRenderConfigs(true);
|
||||||
spectatorFrameRenderConfig.enabled = beginSpectatorFrameRenderConfig.enabled = true;
|
spectatorCameraConfig.resetSizeSpectatorCamera(Window.innerWidth, Window.innerHeight);
|
||||||
beginSpectatorFrameRenderConfig.vFoV = vFoV;
|
spectatorCameraConfig.vFoV = vFoV;
|
||||||
beginSpectatorFrameRenderConfig.nearClipPlaneDistance = nearClipPlaneDistance;
|
spectatorCameraConfig.nearClipPlaneDistance = nearClipPlaneDistance;
|
||||||
beginSpectatorFrameRenderConfig.farClipPlaneDistance = farClipPlaneDistance;
|
spectatorCameraConfig.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 }));
|
||||||
camera = Entities.addEntity({
|
camera = Entities.addEntity({
|
||||||
"angularDamping": 1,
|
"angularDamping": 1,
|
||||||
|
@ -107,7 +91,7 @@
|
||||||
"type": "Model",
|
"type": "Model",
|
||||||
"userData": "{\"grabbableKey\":{\"grabbable\":true}}"
|
"userData": "{\"grabbableKey\":{\"grabbable\":true}}"
|
||||||
}, true);
|
}, true);
|
||||||
beginSpectatorFrameRenderConfig.attachedEntityId = camera;
|
spectatorCameraConfig.attachedEntityId = camera;
|
||||||
updateOverlay();
|
updateOverlay();
|
||||||
setDisplay(monitorShowsCameraView);
|
setDisplay(monitorShowsCameraView);
|
||||||
}
|
}
|
||||||
|
@ -118,8 +102,8 @@
|
||||||
// -Call this function to shut down the spectator camera and
|
// -Call this function to shut down the spectator camera and
|
||||||
// destroy the camera entity.
|
// destroy the camera entity.
|
||||||
function spectatorCameraOff() {
|
function spectatorCameraOff() {
|
||||||
spectatorFrameRenderConfig.enabled = beginSpectatorFrameRenderConfig.enabled = false;
|
spectatorCameraConfig.attachedEntityId = false;
|
||||||
beginSpectatorFrameRenderConfig.attachedEntityId = false;
|
spectatorCameraConfig.enableSecondaryCameraRenderConfigs(false);
|
||||||
if (camera) {
|
if (camera) {
|
||||||
Entities.deleteEntity(camera);
|
Entities.deleteEntity(camera);
|
||||||
}
|
}
|
||||||
|
@ -292,7 +276,7 @@
|
||||||
viewFinderOverlayDim = { x: glassPaneWidth, y: -glassPaneWidth, z: 0 };
|
viewFinderOverlayDim = { x: glassPaneWidth, y: -glassPaneWidth, z: 0 };
|
||||||
}
|
}
|
||||||
updateOverlay();
|
updateOverlay();
|
||||||
spectatorFrameRenderConfig.resetSizeSpectatorCamera(geometryChanged.width, geometryChanged.height);
|
spectatorCameraConfig.resetSizeSpectatorCamera(geometryChanged.width, geometryChanged.height);
|
||||||
setDisplay(monitorShowsCameraView);
|
setDisplay(monitorShowsCameraView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue