mirror of
https://github.com/overte-org/overte.git
synced 2025-08-13 05:00:25 +02:00
change camera pos/orientation through config
This commit is contained in:
parent
3a0cc4e975
commit
fa9d866369
2 changed files with 19 additions and 7 deletions
|
@ -28,21 +28,29 @@ void SelfieRenderTaskConfig::resetSize(int width, int height) {
|
|||
}
|
||||
|
||||
class BeginSelfieFrame {
|
||||
glm::vec3 _position{};
|
||||
glm::quat _orientation{};
|
||||
public:
|
||||
using Config = BeginSelfieFrameConfig;
|
||||
using JobModel = render::Job::Model<BeginSelfieFrame>;
|
||||
using JobModel = render::Job::Model<BeginSelfieFrame, Config>;
|
||||
|
||||
void configure(const Config& config) {
|
||||
qDebug() << "FIXME pos" << config.position << "orient" << config.orientation;
|
||||
_position = config.position;
|
||||
_orientation = config.orientation;
|
||||
}
|
||||
|
||||
void run(const render::RenderContextPointer& renderContext) {
|
||||
auto args = renderContext->args;
|
||||
auto textureCache = DependencyManager::get<TextureCache>();
|
||||
auto destFramebuffer = textureCache->getSelfieFramebuffer();
|
||||
// Why don't we have to reset these values? Is it because we happen to be last in the pipeline (which would be a bug waiting to happen)?
|
||||
args->_blitFramebuffer = destFramebuffer;
|
||||
args->_viewport = glm::ivec4(0, 0, destFramebuffer->getWidth(), destFramebuffer->getHeight());
|
||||
|
||||
auto srcViewFrustum = args->getViewFrustum();
|
||||
auto srcPos = srcViewFrustum.getPosition();
|
||||
srcPos.x += 2.0f;
|
||||
srcViewFrustum.setPosition(srcPos);
|
||||
srcViewFrustum.setPosition(_position);
|
||||
srcViewFrustum.setOrientation(_orientation);
|
||||
args->pushViewFrustum(srcViewFrustum);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ function addTwo() {
|
|||
//url: "http://1.bp.blogspot.com/-1GABEq__054/T03B00j_OII/AAAAAAAAAa8/jo55LcvEPHI/s1600/Winning.jpg",
|
||||
position: offset(),
|
||||
size: 1,
|
||||
scale: -5.0,
|
||||
scale: 5.0,
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1,
|
||||
solid: true,
|
||||
|
@ -36,17 +36,21 @@ function addTwo() {
|
|||
|
||||
var newOverlay = addTwo();
|
||||
var config = Render.getConfig("SelfieFrame");
|
||||
var config2 = Render.getConfig("BeginSelfie");
|
||||
function updateCamera() {
|
||||
//config.position = offset();
|
||||
//config.orientation = MyAvatar.orientation;
|
||||
config2.position = offset();
|
||||
config2.orientation = MyAvatar.orientation;
|
||||
//print('fixme pos/orient', JSON.stringify(config.position), JSON.stringify(config.orientation));
|
||||
}
|
||||
var size = Controller.getViewportDimensions();
|
||||
config.resetSize(size.x, size.y);
|
||||
Script.update.connect(updateCamera);
|
||||
config.enabled = true;
|
||||
config2.enabled = true;
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
config.enabled = false;
|
||||
config2.enabled = false;
|
||||
Script.update.disconnect(updateCamera);
|
||||
Overlays.deleteOverlay(newOverlay);
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue