mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 12:54:30 +02:00
Checkpoint
This commit is contained in:
parent
b50c8120bd
commit
4acbb81413
3 changed files with 22 additions and 16 deletions
|
@ -62,13 +62,14 @@ public:
|
||||||
gpu::FramebufferPointer destFramebuffer;
|
gpu::FramebufferPointer destFramebuffer;
|
||||||
destFramebuffer = textureCache->getSpectatorCameraFramebuffer(); // FIXME: Change the destination based on some unimplemented config var
|
destFramebuffer = textureCache->getSpectatorCameraFramebuffer(); // FIXME: Change the destination based on some unimplemented config var
|
||||||
if (destFramebuffer) {
|
if (destFramebuffer) {
|
||||||
// Caching/restoring the old values doesn't seem to be needed. Is it because we happen to be last in the pipeline (which would be a bug waiting to happen)?
|
|
||||||
_cachedArgsPointer->_blitFramebuffer = args->_blitFramebuffer;
|
_cachedArgsPointer->_blitFramebuffer = args->_blitFramebuffer;
|
||||||
_cachedArgsPointer->_viewport = args->_viewport;
|
_cachedArgsPointer->_viewport = args->_viewport;
|
||||||
_cachedArgsPointer->_displayMode = args->_displayMode;
|
_cachedArgsPointer->_displayMode = args->_displayMode;
|
||||||
|
_cachedArgsPointer->_renderMode = args->_renderMode;
|
||||||
args->_blitFramebuffer = destFramebuffer;
|
args->_blitFramebuffer = destFramebuffer;
|
||||||
args->_viewport = glm::ivec4(0, 0, destFramebuffer->getWidth(), destFramebuffer->getHeight());
|
args->_viewport = glm::ivec4(0, 0, destFramebuffer->getWidth(), destFramebuffer->getHeight());
|
||||||
args->_displayMode = RenderArgs::MONO;
|
args->_displayMode = RenderArgs::MONO;
|
||||||
|
args->_renderMode = RenderArgs::SECONDARY_CAMERA_RENDER_MODE;
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
batch.disableContextStereo();
|
batch.disableContextStereo();
|
||||||
|
@ -77,6 +78,9 @@ public:
|
||||||
auto srcViewFrustum = args->getViewFrustum();
|
auto srcViewFrustum = args->getViewFrustum();
|
||||||
srcViewFrustum.setPosition(_position);
|
srcViewFrustum.setPosition(_position);
|
||||||
srcViewFrustum.setOrientation(_orientation);
|
srcViewFrustum.setOrientation(_orientation);
|
||||||
|
// Without calculating the bound planes, the secondary camera will use the same culling frustum as the main camera,
|
||||||
|
// which is not what we want here.
|
||||||
|
srcViewFrustum.calculate();
|
||||||
args->pushViewFrustum(srcViewFrustum);
|
args->pushViewFrustum(srcViewFrustum);
|
||||||
cachedArgs = _cachedArgsPointer;
|
cachedArgs = _cachedArgsPointer;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +101,7 @@ public:
|
||||||
args->_viewport = cachedArgs->_viewport;
|
args->_viewport = cachedArgs->_viewport;
|
||||||
args->popViewFrustum();
|
args->popViewFrustum();
|
||||||
args->_displayMode = cachedArgs->_displayMode;
|
args->_displayMode = cachedArgs->_displayMode;
|
||||||
|
args->_renderMode = cachedArgs->_renderMode;
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
batch.restoreContextStereo();
|
batch.restoreContextStereo();
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
|
|
||||||
class RenderArgs {
|
class RenderArgs {
|
||||||
public:
|
public:
|
||||||
enum RenderMode { DEFAULT_RENDER_MODE, SHADOW_RENDER_MODE, DIFFUSE_RENDER_MODE, NORMAL_RENDER_MODE, MIRROR_RENDER_MODE };
|
enum RenderMode { DEFAULT_RENDER_MODE, SHADOW_RENDER_MODE, DIFFUSE_RENDER_MODE, NORMAL_RENDER_MODE, MIRROR_RENDER_MODE, SECONDARY_CAMERA_RENDER_MODE };
|
||||||
enum DisplayMode { MONO, STEREO_MONITOR, STEREO_HMD };
|
enum DisplayMode { MONO, STEREO_MONITOR, STEREO_HMD };
|
||||||
enum DebugFlags {
|
enum DebugFlags {
|
||||||
RENDER_DEBUG_NONE = 0,
|
RENDER_DEBUG_NONE = 0,
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Function Name: inFrontOf(), flip()
|
// Function Name: inFrontOf()
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
// Spectator camera utility functions and variables.
|
// Spectator camera utility functions and variables.
|
||||||
|
@ -31,8 +31,6 @@
|
||||||
return Vec3.sum(position || MyAvatar.position,
|
return Vec3.sum(position || MyAvatar.position,
|
||||||
Vec3.multiply(distance, Quat.getForward(orientation || MyAvatar.orientation)));
|
Vec3.multiply(distance, Quat.getForward(orientation || MyAvatar.orientation)));
|
||||||
}
|
}
|
||||||
var aroundY = Quat.fromPitchYawRollDegrees(0, 180, 0);
|
|
||||||
function flip(rotation) { return Quat.multiply(rotation, aroundY); }
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Function Name: updateRenderFromCamera()
|
// Function Name: updateRenderFromCamera()
|
||||||
|
@ -73,10 +71,6 @@
|
||||||
lastCameraPosition = cameraData.position;
|
lastCameraPosition = cameraData.position;
|
||||||
beginSpectatorFrameRenderConfig.position = Vec3.sum(inFrontOf(0.17, lastCameraPosition, lastCameraRotation), {x: 0, y: 0.02, z: 0});
|
beginSpectatorFrameRenderConfig.position = Vec3.sum(inFrontOf(0.17, lastCameraPosition, lastCameraRotation), {x: 0, y: 0.02, z: 0});
|
||||||
}
|
}
|
||||||
if (cameraIsDynamic) {
|
|
||||||
// BUG: image3d overlays don't retain their locations properly when parented to a dynamic object
|
|
||||||
Overlays.editOverlay(viewFinderOverlay, { orientation: flip(cameraData.rotation) });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -85,6 +79,8 @@
|
||||||
// Relevant Variables:
|
// Relevant Variables:
|
||||||
// isUpdateRenderWired: Bool storing whether or not the camera's update
|
// isUpdateRenderWired: Bool storing whether or not the camera's update
|
||||||
// function is wired.
|
// function is wired.
|
||||||
|
// windowAspectRatio: The ratio of the Interface windows's sizeX/sizeY
|
||||||
|
// previewAspectRatio: The ratio of the camera preview's sizeX/sizeY
|
||||||
//
|
//
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// None
|
// None
|
||||||
|
@ -94,10 +90,15 @@
|
||||||
// spawn the camera entity.
|
// spawn the camera entity.
|
||||||
//
|
//
|
||||||
var isUpdateRenderWired = false;
|
var isUpdateRenderWired = false;
|
||||||
|
var windowAspectRatio;
|
||||||
|
var previewAspectRatio = 16/9;
|
||||||
function spectatorCameraOn() {
|
function spectatorCameraOn() {
|
||||||
// Set the special texture size based on the window in which it will eventually be displayed.
|
// Set the special texture size based on the window in which it will eventually be displayed.
|
||||||
var size = Controller.getViewportDimensions(); // FIXME: Need a signal to hook into when the dimensions change.
|
var size = Controller.getViewportDimensions(); // FIXME: Need a signal to hook into when the dimensions change.
|
||||||
spectatorFrameRenderConfig.resetSizeSpectatorCamera(size.x, size.y);
|
var sizeX = Window.innerWidth;
|
||||||
|
var sizeY = Window.innerHeight;
|
||||||
|
windowAspectRatio = sizeX/sizeY;
|
||||||
|
spectatorFrameRenderConfig.resetSizeSpectatorCamera(sizeX, sizeY);
|
||||||
spectatorFrameRenderConfig.enabled = beginSpectatorFrameRenderConfig.enabled = true;
|
spectatorFrameRenderConfig.enabled = beginSpectatorFrameRenderConfig.enabled = true;
|
||||||
var cameraRotation = MyAvatar.orientation, cameraPosition = inFrontOf(1, Vec3.sum(MyAvatar.position, { x: 0, y: 0.3, z: 0 }));
|
var cameraRotation = MyAvatar.orientation, cameraPosition = inFrontOf(1, Vec3.sum(MyAvatar.position, { x: 0, y: 0.3, z: 0 }));
|
||||||
Script.update.connect(updateRenderFromCamera);
|
Script.update.connect(updateRenderFromCamera);
|
||||||
|
@ -132,14 +133,14 @@
|
||||||
parentID: camera,
|
parentID: camera,
|
||||||
alpha: 1,
|
alpha: 1,
|
||||||
position: { x: 0.007, y: 0.15, z: -0.005 },
|
position: { x: 0.007, y: 0.15, z: -0.005 },
|
||||||
scale: -0.16,
|
dimensions: { x: 0.16, y: -0.16 * windowAspectRatio / previewAspectRatio, z: 0 }
|
||||||
|
// FIXME: This stretches the preview.
|
||||||
|
// FIXME: We shouldn't need the negative dimension.
|
||||||
|
// e.g., This isn't necessary using an ordinary .jpg with lettering, above.
|
||||||
|
// Must be something about the view frustum projection matrix?
|
||||||
|
// But don't go changing that in (c++ code) without getting all the way to a desktop display!
|
||||||
});
|
});
|
||||||
Entities.editEntity(camera, { position: cameraPosition, rotation: cameraRotation });
|
Entities.editEntity(camera, { position: cameraPosition, rotation: cameraRotation });
|
||||||
// FIXME: We shouldn't need the flip and the negative scale.
|
|
||||||
// e.g., This isn't necessary using an ordinary .jpg with lettering, above.
|
|
||||||
// Must be something about the view frustum projection matrix?
|
|
||||||
// But don't go changing that in (c++ code) without getting all the way to a desktop display!
|
|
||||||
Overlays.editOverlay(viewFinderOverlay, { orientation: flip(cameraRotation) });
|
|
||||||
setDisplay(monitorShowsCameraView);
|
setDisplay(monitorShowsCameraView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue