FlightGear next
CameraGroup.cxx
Go to the documentation of this file.
1/*
2 * SPDX-FileName: CameraGroup.cxx
3 * SPDX-FileCopyrightText: Copyright (C) 2008 Tim Moore
4 * SPDX-FileContributor: Copyright (C) 2011 Mathias Froehlich
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#include "CameraGroup.hxx"
9
10#include <Main/fg_props.hxx>
11#include <Main/globals.hxx>
12#include "renderer.hxx"
13#include "FGEventHandler.hxx"
14#include "WindowBuilder.hxx"
16#include "splash.hxx"
17#include "sview.hxx"
18#include "VRManager.hxx"
19
20#include <simgear/math/SGRect.hxx>
21#include <simgear/props/props.hxx>
22#include <simgear/props/props_io.hxx> // for copyProperties
23#include <simgear/structure/exception.hxx>
24#include <simgear/scene/material/EffectCullVisitor.hxx>
25#include <simgear/scene/util/ProjectionMatrix.hxx>
26#include <simgear/scene/util/RenderConstants.hxx>
27#include <simgear/scene/util/SGReaderWriterOptions.hxx>
28#include <simgear/scene/util/OsgUtils.hxx>
29#include <simgear/scene/viewer/Compositor.hxx>
30#include <simgear/scene/viewer/CompositorUtil.hxx>
31
32#include <algorithm>
33#include <cstring>
34#include <string>
35
36#include <osg/Camera>
37#include <osg/Geometry>
38#include <osg/GraphicsContext>
39#include <osg/io_utils>
40#include <osg/Math>
41#include <osg/Matrix>
42#include <osg/Notify>
43#include <osg/Program>
44#include <osg/Quat>
45#include <osg/TexMat>
46#include <osg/Vec3d>
47#include <osg/Viewport>
48
49#include <osgUtil/IntersectionVisitor>
50
51#include <osgViewer/Viewer>
52#include <osgViewer/GraphicsWindow>
53#include <osgViewer/Renderer>
54
55using namespace osg;
56
57namespace {
58
59osg::Matrix
60invert(const osg::Matrix& matrix)
61{
62 return osg::Matrix::inverse(matrix);
63}
64
67double
68zoomFactor()
69{
70 double fov = fgGetDouble("/sim/current-view/field-of-view", 55);
71 if (fov < 1)
72 fov = 1;
73 return tan(55*0.5*SG_DEGREES_TO_RADIANS)/tan(fov*0.5*SG_DEGREES_TO_RADIANS);
74}
75
76osg::Vec2d
77preMult(const osg::Vec2d& v, const osg::Matrix& m)
78{
79 osg::Vec3d tmp = m.preMult(osg::Vec3(v, 0));
80 return osg::Vec2d(tmp[0], tmp[1]);
81}
82
83osg::Matrix
84relativeProjection(const osg::Matrix& P0, const osg::Matrix& R, const osg::Vec2d ref[2],
85 const osg::Matrix& pP, const osg::Matrix& pR, const osg::Vec2d pRef[2])
86{
87 // Track the way from one projection space to the other:
88 // We want
89 // P = T*S*P0
90 // where P0 is the projection template sensible for the given window size,
91 // T is a translation matrix and S a scale matrix.
92 // We need to determine T and S so that the reference points in the parents
93 // projection space match the two reference points in this cameras projection space.
94
95 // Starting from the parents camera projection space, we get into this cameras
96 // projection space by the transform matrix:
97 // P*R*inv(pP*pR) = T*S*P0*R*inv(pP*pR)
98 // So, at first compute that matrix without T*S and determine S and T from that
99
100 // Ok, now osg uses the inverse matrix multiplication order, thus:
101 osg::Matrix PtoPwithoutTS = invert(pR*pP)*R*P0;
102 // Compute the parents reference points in the current projection space
103 // without the yet unknown T and S
104 osg::Vec2d pRefInThis[2] = {
105 preMult(pRef[0], PtoPwithoutTS),
106 preMult(pRef[1], PtoPwithoutTS)
107 };
108
109 // To get the same zoom, rescale to match the parents size
110 double s = (ref[0] - ref[1]).length()/(pRefInThis[0] - pRefInThis[1]).length();
111 osg::Matrix S = osg::Matrix::scale(s, s, 1);
112
113 // For the translation offset, incorporate the now known scale
114 // and recompute the position ot the first reference point in the
115 // currents projection space without the yet unknown T.
116 pRefInThis[0] = preMult(pRef[0], PtoPwithoutTS*S);
117 // The translation is then the difference of the reference points
118 osg::Matrix T = osg::Matrix::translate(osg::Vec3d(ref[0] - pRefInThis[0], 0));
119
120 // Compose and return the desired final projection matrix
121 return P0*S*T;
122}
123
124} // anonymous namespace
125
126namespace flightgear
127{
128using namespace simgear;
129using namespace compositor;
130
131class CameraGroupListener : public SGPropertyChangeListener {
132public:
133 CameraGroupListener(CameraGroup* cg, SGPropertyNode* gnode) :
134 _groupNode(gnode),
135 _cameraGroup(cg) {
136 listenToNode("znear", 0.1f);
137 listenToNode("zfar", 1000000.0f);
138 }
139
141 unlisten("znear");
142 unlisten("zfar");
143 }
144
145 virtual void valueChanged(SGPropertyNode* prop) {
146 if (prop->getNameString() == "znear") {
147 _cameraGroup->_zNear = prop->getFloatValue();
148 } else if (prop->getNameString() == "zfar") {
149 _cameraGroup->_zFar = prop->getFloatValue();
150 }
151 }
152private:
153 void listenToNode(const std::string& name, double val) {
154 SGPropertyNode* n = _groupNode->getChild(name);
155 if (!n) {
156 n = _groupNode->getChild(name, 0 /* index */, true);
157 n->setDoubleValue(val);
158 }
159 n->addChangeListener(this);
160 valueChanged(n); // propogate initial state through
161 }
162
163 void unlisten(const std::string& name) {
164 _groupNode->getChild(name)->removeChangeListener(this);
165 }
166
167 SGPropertyNode_ptr _groupNode;
168 CameraGroup* _cameraGroup; // non-owning reference
169};
170
171struct GUIUpdateCallback : public Pass::PassUpdateCallback {
172 virtual void updatePass(Pass &pass,
173 const osg::Matrix &view_matrix,
174 const osg::Matrix &proj_matrix) {
175 // Just set both the view matrix and the projection matrix
176 pass.camera->setViewMatrix(view_matrix);
177 pass.camera->setProjectionMatrix(proj_matrix);
178 }
179};
180
181typedef std::vector<SGPropertyNode_ptr> SGPropertyNodeVec;
182
183osg::ref_ptr<CameraGroup> CameraGroup::_defaultGroup;
184
185CameraGroup::CameraGroup(osgViewer::View* view) :
186 _viewer(view)
187{
188}
189
194
195void CameraGroup::update(const osg::Vec3d& position,
196 const osg::Quat& orientation)
197{
198 const osg::Matrix masterView(osg::Matrix::translate(-position)
199 * osg::Matrix::rotate(orientation.inverse()));
200 _viewer->getCamera()->setViewMatrix(masterView);
201 const osg::Matrix& masterProj = _viewer->getCamera()->getProjectionMatrix();
202 double masterZoomFactor = zoomFactor();
203
204 for (const auto &info : _cameras) {
205 osg::Matrix view_matrix;
206 if (info->flags & (CameraInfo::SPLASH | CameraInfo::GUI))
207 view_matrix = osg::Matrix::identity();
208 else if ((info->flags & CameraInfo::VIEW_ABSOLUTE) != 0)
209 view_matrix = info->viewOffset;
210 else
211 view_matrix = masterView * info->viewOffset;
212
213 osg::Matrix proj_matrix;
214 if (info->flags & (CameraInfo::SPLASH | CameraInfo::GUI)) {
215 const osg::GraphicsContext::Traits *traits =
216 info->compositor->getGraphicsContext()->getTraits();
217 proj_matrix = osg::Matrix::ortho2D(0, traits->width, 0, traits->height);
218 } else if ((info->flags & CameraInfo::PROJECTION_ABSOLUTE) != 0) {
219 if (info->flags & CameraInfo::ENABLE_MASTER_ZOOM) {
220 if (info->relativeCameraParent) {
221 // template projection and view matrices of the current camera
222 osg::Matrix P0 = info->projOffset;
223 osg::Matrix R = view_matrix;
224
225 // The already known projection and view matrix of the parent camera
226 osg::Matrix pP = info->relativeCameraParent->projMatrix;
227 osg::Matrix pR = info->relativeCameraParent->viewMatrix;
228
229 // And the projection matrix derived from P0 so that the
230 // reference points match
231 proj_matrix = relativeProjection(P0, R, info->thisReference,
232 pP, pR, info->parentReference);
233 } else {
234 // We want to zoom, so take the original matrix and apply the
235 // zoom to it
236 proj_matrix = info->projOffset;
237 proj_matrix.postMultScale(osg::Vec3d(masterZoomFactor,
238 masterZoomFactor,
239 1));
240 }
241 } else {
242 proj_matrix = info->projOffset;
243 }
244 } else {
245 proj_matrix = masterProj * info->projOffset;
246 }
247
248 osg::Matrix new_proj_matrix = proj_matrix;
249 if ((info->flags & CameraInfo::SPLASH) == 0 &&
250 (info->flags & CameraInfo::GUI) == 0 &&
251 (info->flags & CameraInfo::FIXED_NEAR_FAR) == 0) {
252 ProjectionMatrix::clampNearFarPlanes(proj_matrix, _zNear, _zFar,
253 new_proj_matrix);
254 }
255
256 info->viewMatrix = view_matrix;
257 info->projMatrix = new_proj_matrix;
258 info->compositor->update(view_matrix, new_proj_matrix);
259 }
260}
261
262void CameraGroup::setCameraParameters(float vfov, float aspectRatio)
263{
264 if (vfov != 0.0f && aspectRatio != 0.0f) {
265 osg::Matrixd m;
266 ProjectionMatrix::makePerspective(m, vfov, 1.0 / aspectRatio,
267 _zNear, _zFar, ProjectionMatrix::STANDARD);
268 _viewer->getCamera()->setProjectionMatrix(m);
269 }
270}
271
273{
274 if (_cameras.empty())
275 return 0.0;
276
277 // The master camera is the first one added
278 const CameraInfo *info = _cameras.front();
279 if (!info)
280 return 0.0;
281 const osg::GraphicsContext::Traits *traits =
282 info->compositor->getGraphicsContext()->getTraits();
283
284 return static_cast<double>(traits->height) / traits->width;
285}
286
287CameraInfo* CameraGroup::buildCamera(SGPropertyNode* cameraNode)
288{
290 const SGPropertyNode* windowNode = cameraNode->getNode("window");
291 GraphicsWindow* window = 0;
292 int cameraFlags = CameraInfo::DO_INTERSECTION_TEST;
293 if (windowNode) {
294 // New style window declaration / definition
295 window = wBuild->buildWindow(windowNode);
296 } else {
297 // Old style: suck window params out of camera block
298 window = wBuild->buildWindow(cameraNode);
299 }
300 if (!window) {
301 return nullptr;
302 }
303
304 // Set the projection matrix near/far behaviour
305 ProjectionMatrix::Type proj_type = ProjectionMatrix::STANDARD;
306
307 // Set vr-mirror flag so camera switches to VR mirror when appropriate.
308 if (cameraNode->getBoolValue("vr-mirror", false))
309 cameraFlags |= CameraInfo::VR_MIRROR;
310
311 osg::Matrix vOff;
312 const SGPropertyNode* viewNode = cameraNode->getNode("view");
313 if (viewNode) {
314 double heading = viewNode->getDoubleValue("heading-deg", 0.0);
315 double pitch = viewNode->getDoubleValue("pitch-deg", 0.0);
316 double roll = viewNode->getDoubleValue("roll-deg", 0.0);
317 double x = viewNode->getDoubleValue("x", 0.0);
318 double y = viewNode->getDoubleValue("y", 0.0);
319 double z = viewNode->getDoubleValue("z", 0.0);
320 // Build a view matrix, which is the inverse of a model
321 // orientation matrix.
322 vOff = (Matrix::translate(-x, -y, -z)
323 * Matrix::rotate(-DegreesToRadians(heading),
324 Vec3d(0.0, 1.0, 0.0),
325 -DegreesToRadians(pitch),
326 Vec3d(1.0, 0.0, 0.0),
327 -DegreesToRadians(roll),
328 Vec3d(0.0, 0.0, 1.0)));
329 if (viewNode->getBoolValue("absolute", false))
330 cameraFlags |= CameraInfo::VIEW_ABSOLUTE;
331 } else {
332 // Old heading parameter, works in the opposite direction
333 double heading = cameraNode->getDoubleValue("heading-deg", 0.0);
334 vOff.makeRotate(DegreesToRadians(heading), osg::Vec3(0, 1, 0));
335 }
336 // Configuring the physical dimensions of a monitor
337 SGPropertyNode* viewportNode = cameraNode->getNode("viewport", true);
338 double physicalWidth = viewportNode->getDoubleValue("width", 1024);
339 double physicalHeight = viewportNode->getDoubleValue("height", 768);
340 double bezelHeightTop = 0;
341 double bezelHeightBottom = 0;
342 double bezelWidthLeft = 0;
343 double bezelWidthRight = 0;
344 const SGPropertyNode* physicalDimensionsNode = 0;
345 if ((physicalDimensionsNode = cameraNode->getNode("physical-dimensions")) != 0) {
346 physicalWidth = physicalDimensionsNode->getDoubleValue("width", physicalWidth);
347 physicalHeight = physicalDimensionsNode->getDoubleValue("height", physicalHeight);
348 const SGPropertyNode* bezelNode = 0;
349 if ((bezelNode = physicalDimensionsNode->getNode("bezel")) != 0) {
350 bezelHeightTop = bezelNode->getDoubleValue("top", bezelHeightTop);
351 bezelHeightBottom = bezelNode->getDoubleValue("bottom", bezelHeightBottom);
352 bezelWidthLeft = bezelNode->getDoubleValue("left", bezelWidthLeft);
353 bezelWidthRight = bezelNode->getDoubleValue("right", bezelWidthRight);
354 }
355 }
356 osg::Matrix pOff;
357 CameraInfo *parentInfo = nullptr;
358 osg::Vec2d parentReference[2];
359 osg::Vec2d thisReference[2];
360 SGPropertyNode* projectionNode = 0;
361 if ((projectionNode = cameraNode->getNode("perspective")) != 0) {
362 double fovy = projectionNode->getDoubleValue("fovy-deg", 55.0);
363 double aspectRatio = projectionNode->getDoubleValue("aspect-ratio",
364 1.0);
365 double zNear = projectionNode->getDoubleValue("near", 0.0);
366 double zFar = projectionNode->getDoubleValue("far", zNear + 20000);
367 double offsetX = projectionNode->getDoubleValue("offset-x", 0.0);
368 double offsetY = projectionNode->getDoubleValue("offset-y", 0.0);
369 double tan_fovy = tan(DegreesToRadians(fovy*0.5));
370 double right = tan_fovy * aspectRatio * zNear + offsetX;
371 double left = -tan_fovy * aspectRatio * zNear + offsetX;
372 double top = tan_fovy * zNear + offsetY;
373 double bottom = -tan_fovy * zNear + offsetY;
374 ProjectionMatrix::makeFrustum(pOff,
375 left, right,
376 bottom, top,
377 zNear, zFar,
378 proj_type);
379 cameraFlags |= CameraInfo::PROJECTION_ABSOLUTE;
380 if (projectionNode->getBoolValue("fixed-near-far", true))
381 cameraFlags |= CameraInfo::FIXED_NEAR_FAR;
382 } else if ((projectionNode = cameraNode->getNode("frustum")) != 0
383 || (projectionNode = cameraNode->getNode("ortho")) != 0) {
384 double top = projectionNode->getDoubleValue("top", 0.0);
385 double bottom = projectionNode->getDoubleValue("bottom", 0.0);
386 double left = projectionNode->getDoubleValue("left", 0.0);
387 double right = projectionNode->getDoubleValue("right", 0.0);
388 double zNear = projectionNode->getDoubleValue("near", 0.0);
389 double zFar = projectionNode->getDoubleValue("far", zNear + 20000);
390 if (cameraNode->getNode("frustum")) {
391 ProjectionMatrix::makeFrustum(pOff,
392 left, right,
393 bottom, top,
394 zNear, zFar,
395 proj_type);
396 cameraFlags |= CameraInfo::PROJECTION_ABSOLUTE;
397 } else {
398 ProjectionMatrix::makeOrtho(pOff,
399 left, right,
400 bottom, top,
401 zNear, zFar,
402 proj_type);
404 }
405 if (projectionNode->getBoolValue("fixed-near-far", true))
406 cameraFlags |= CameraInfo::FIXED_NEAR_FAR;
407 } else if ((projectionNode = cameraNode->getNode("master-perspective")) != 0) {
408 double zNear = projectionNode->getDoubleValue("eye-distance", 0.4*physicalWidth);
409 double xoff = projectionNode->getDoubleValue("x-offset", 0);
410 double yoff = projectionNode->getDoubleValue("y-offset", 0);
411 double left = -0.5*physicalWidth - xoff;
412 double right = 0.5*physicalWidth - xoff;
413 double bottom = -0.5*physicalHeight - yoff;
414 double top = 0.5*physicalHeight - yoff;
415 ProjectionMatrix::makeFrustum(pOff,
416 left, right,
417 bottom, top,
418 zNear, zNear + 20000.0,
419 proj_type);
421 } else if ((projectionNode = cameraNode->getNode("right-of-perspective"))
422 || (projectionNode = cameraNode->getNode("left-of-perspective"))
423 || (projectionNode = cameraNode->getNode("above-perspective"))
424 || (projectionNode = cameraNode->getNode("below-perspective"))
425 || (projectionNode = cameraNode->getNode("reference-points-perspective"))) {
426 std::string name = projectionNode->getStringValue("parent-camera");
427 auto it = std::find_if(_cameras.begin(), _cameras.end(),
428 [&name](const auto &c) { return c->name == name; });
429 if (it == _cameras.end()) {
430 SG_LOG(SG_VIEW, SG_ALERT, "CameraGroup::buildCamera: "
431 "failed to find parent camera for relative camera!");
432 return nullptr;
433 }
434 parentInfo = (*it);
435 if (projectionNode->getNameString() == "right-of-perspective") {
436 double tmp = (parentInfo->physicalWidth + 2*parentInfo->bezelWidthRight)/parentInfo->physicalWidth;
437 parentReference[0] = osg::Vec2d(tmp, -1);
438 parentReference[1] = osg::Vec2d(tmp, 1);
439 tmp = (physicalWidth + 2*bezelWidthLeft)/physicalWidth;
440 thisReference[0] = osg::Vec2d(-tmp, -1);
441 thisReference[1] = osg::Vec2d(-tmp, 1);
442 } else if (projectionNode->getNameString() == "left-of-perspective") {
443 double tmp = (parentInfo->physicalWidth + 2*parentInfo->bezelWidthLeft)/parentInfo->physicalWidth;
444 parentReference[0] = osg::Vec2d(-tmp, -1);
445 parentReference[1] = osg::Vec2d(-tmp, 1);
446 tmp = (physicalWidth + 2*bezelWidthRight)/physicalWidth;
447 thisReference[0] = osg::Vec2d(tmp, -1);
448 thisReference[1] = osg::Vec2d(tmp, 1);
449 } else if (projectionNode->getNameString() == "above-perspective") {
450 double tmp = (parentInfo->physicalHeight + 2*parentInfo->bezelHeightTop)/parentInfo->physicalHeight;
451 parentReference[0] = osg::Vec2d(-1, tmp);
452 parentReference[1] = osg::Vec2d(1, tmp);
453 tmp = (physicalHeight + 2*bezelHeightBottom)/physicalHeight;
454 thisReference[0] = osg::Vec2d(-1, -tmp);
455 thisReference[1] = osg::Vec2d(1, -tmp);
456 } else if (projectionNode->getNameString() == "below-perspective") {
457 double tmp = (parentInfo->physicalHeight + 2*parentInfo->bezelHeightBottom)/parentInfo->physicalHeight;
458 parentReference[0] = osg::Vec2d(-1, -tmp);
459 parentReference[1] = osg::Vec2d(1, -tmp);
460 tmp = (physicalHeight + 2*bezelHeightTop)/physicalHeight;
461 thisReference[0] = osg::Vec2d(-1, tmp);
462 thisReference[1] = osg::Vec2d(1, tmp);
463 } else if (projectionNode->getNameString() == "reference-points-perspective") {
464 SGPropertyNode* parentNode = projectionNode->getNode("parent", true);
465 SGPropertyNode* thisNode = projectionNode->getNode("this", true);
466 SGPropertyNode* pointNode;
467
468 pointNode = parentNode->getNode("point", 0, true);
469 parentReference[0][0] = pointNode->getDoubleValue("x", 0)*2/parentInfo->physicalWidth;
470 parentReference[0][1] = pointNode->getDoubleValue("y", 0)*2/parentInfo->physicalHeight;
471 pointNode = parentNode->getNode("point", 1, true);
472 parentReference[1][0] = pointNode->getDoubleValue("x", 0)*2/parentInfo->physicalWidth;
473 parentReference[1][1] = pointNode->getDoubleValue("y", 0)*2/parentInfo->physicalHeight;
474
475 pointNode = thisNode->getNode("point", 0, true);
476 thisReference[0][0] = pointNode->getDoubleValue("x", 0)*2/physicalWidth;
477 thisReference[0][1] = pointNode->getDoubleValue("y", 0)*2/physicalHeight;
478 pointNode = thisNode->getNode("point", 1, true);
479 thisReference[1][0] = pointNode->getDoubleValue("x", 0)*2/physicalWidth;
480 thisReference[1][1] = pointNode->getDoubleValue("y", 0)*2/physicalHeight;
481 }
482
483 ProjectionMatrix::makePerspective(pOff, 45, physicalWidth/physicalHeight,
484 1, 20000, proj_type);
486 } else {
487 // old style shear parameters
488 double shearx = cameraNode->getDoubleValue("shear-x", 0);
489 double sheary = cameraNode->getDoubleValue("shear-y", 0);
490 pOff.makeTranslate(-shearx, -sheary, 0);
491 }
492
493 CameraInfo *info = new CameraInfo(cameraFlags);
494 _cameras.push_back(info);
495 info->name = cameraNode->getStringValue("name");
496 info->physicalWidth = physicalWidth;
497 info->physicalHeight = physicalHeight;
498 info->bezelHeightTop = bezelHeightTop;
499 info->bezelHeightBottom = bezelHeightBottom;
500 info->bezelWidthLeft = bezelWidthLeft;
501 info->bezelWidthRight = bezelWidthRight;
502 info->relativeCameraParent = parentInfo;
503 info->parentReference[0] = parentReference[0];
504 info->parentReference[1] = parentReference[1];
505 info->thisReference[0] = thisReference[0];
506 info->thisReference[1] = thisReference[1];
507 info->viewOffset = vOff;
508 info->projOffset = pOff;
509 info->mvr.views = cameraNode->getIntValue("mvr-views", 1);
510 info->mvr.viewIdGlobalStr = cameraNode->getStringValue("mvr-view-id-global", "");
511 info->mvr.viewIdStr[0] = cameraNode->getStringValue("mvr-view-id-vert", "0");
512 info->mvr.viewIdStr[1] = cameraNode->getStringValue("mvr-view-id-geom", "0");
513 info->mvr.viewIdStr[2] = cameraNode->getStringValue("mvr-view-id-frag", "0");
514 info->mvr.cells = cameraNode->getIntValue("mvr-cells", 1);
515
516 osg::Viewport *viewport = new osg::Viewport(
517 viewportNode->getDoubleValue("x"),
518 viewportNode->getDoubleValue("y"),
519 // If no width or height has been specified, fill the entire window
520 viewportNode->getDoubleValue("width", window->gc->getTraits()->width),
521 viewportNode->getDoubleValue("height",window->gc->getTraits()->height));
522
523 std::string compositor_path = cameraNode->getStringValue("compositor", "");
524 if (compositor_path.empty()) {
525 compositor_path = fgGetString("/sim/rendering/default-compositor",
526 "Compositor/default");
527 } else {
528 // Store the custom path in case we need to reload later
529 info->compositor_path = compositor_path;
530 }
531
532 osg::ref_ptr<SGReaderWriterOptions> options =
533 SGReaderWriterOptions::fromPath(globals->get_fg_root());
534 options->setPropertyNode(globals->get_props());
535
536 SViewSetCompositorParams(options, compositor_path);
537
538 Compositor *compositor = nullptr;
539 if (info->flags & CameraInfo::VR_MIRROR)
540 compositor = buildVRMirrorCompositor(window->gc, viewport);
541 if (!compositor)
542 compositor = Compositor::create(_viewer,
543 window->gc,
544 viewport,
545 compositor_path,
546 options,
547 &info->mvr);
548
549 if (compositor) {
550 info->compositor.reset(compositor);
551 } else {
552 throw sg_exception(std::string("Failed to create Compositor in path '") +
553 compositor_path + "'");
554 }
555
556 return info;
557}
558
560{
561 for (auto it = _cameras.begin(); it != _cameras.end(); ++it) {
562 if (*it == info) {
563 _cameras.erase(it);
564 return;
565 }
566 }
567}
568
569void CameraGroup::buildSplashCamera(SGPropertyNode* cameraNode,
570 GraphicsWindow* window)
571{
573 const SGPropertyNode* windowNode = (cameraNode
574 ? cameraNode->getNode("window")
575 : 0);
576 if (!window && windowNode) {
577 // New style window declaration / definition
578 window = wBuild->buildWindow(windowNode);
579 }
580
581 if (!window) { // buildWindow can fail
582 SG_LOG(SG_VIEW, SG_WARN, "CameraGroup::buildSplashCamera: failed to build a window");
583 return;
584 }
585
586 Camera* camera = new Camera;
587 camera->setName("SplashCamera");
588 camera->setAllowEventFocus(false);
589 camera->setGraphicsContext(window->gc.get());
590 // If a viewport isn't set on the camera, then it's hard to dig it
591 // out of the SceneView objects in the viewer, and the coordinates
592 // of mouse events are somewhat bizzare.
593 osg::Viewport* viewport = new osg::Viewport(
594 0, 0, window->gc->getTraits()->width, window->gc->getTraits()->height);
595 camera->setViewport(viewport);
596 camera->setClearMask(0);
597 camera->setInheritanceMask(CullSettings::ALL_VARIABLES
598 & ~(CullSettings::COMPUTE_NEAR_FAR_MODE
599 | CullSettings::CULLING_MODE
600 | CullSettings::CLEAR_MASK
601 ));
602 camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
603 camera->setCullingMode(osg::CullSettings::NO_CULLING);
604 camera->setProjectionResizePolicy(osg::Camera::FIXED);
605
606 // The camera group will always update the camera
607 camera->setReferenceFrame(Transform::ABSOLUTE_RF);
608
609 // XXX Camera needs to be drawn just before GUI; eventually the render order
610 // should be assigned by a camera manager.
611 camera->setRenderOrder(osg::Camera::POST_RENDER, 9999);
612
613 // Add splash screen!
614 camera->addChild(globals->get_renderer()->getSplash());
615
616 Pass* pass = new Pass;
617 pass->camera = camera;
618 pass->useMastersSceneData = false;
619
620 // For now we just build a simple Compositor directly from C++ space that
621 // encapsulates a single osg::Camera. This could be improved by letting
622 // users change the Compositor config in XML space, for example to be able
623 // to add post-processing to a HUD.
624 // However, since many other parts of FG require direct access to the GUI
625 // osg::Camera object, this is fine for now.
626 Compositor* compositor = new Compositor(_viewer, window->gc, viewport);
627 compositor->addPass(pass);
628
629 const int cameraFlags = CameraInfo::SPLASH;
630 CameraInfo* info = new CameraInfo(cameraFlags);
631 info->name = "Splash camera";
632 info->viewOffset = osg::Matrix::identity();
633 info->projOffset = osg::Matrix::identity();
634 info->compositor.reset(compositor);
635 _cameras.push_back(info);
636
637 // Disable statistics for the splash camera.
638 camera->setStats(0);
639}
640
641void CameraGroup::buildGUICamera(SGPropertyNode* cameraNode,
642 GraphicsWindow* window)
643{
645 const SGPropertyNode* windowNode = (cameraNode
646 ? cameraNode->getNode("window")
647 : 0);
648 if (!window && windowNode) {
649 // New style window declaration / definition
650 window = wBuild->buildWindow(windowNode);
651 }
652
653 if (!window) { // buildWindow can fail
654 SG_LOG(SG_VIEW, SG_WARN, "CameraGroup::buildGUICamera: failed to build a window");
655 return;
656 }
657
658 // Mark the window as containing the GUI
659 window->flags |= GraphicsWindow::GUI;
660
661 Camera* camera = new Camera;
662 camera->setName( "GUICamera" );
663 camera->setAllowEventFocus(false);
664 camera->setGraphicsContext(window->gc.get());
665 // If a viewport isn't set on the camera, then it's hard to dig it
666 // out of the SceneView objects in the viewer, and the coordinates
667 // of mouse events are somewhat bizzare.
668 osg::Viewport *viewport = new osg::Viewport(
669 0, 0, window->gc->getTraits()->width, window->gc->getTraits()->height);
670 camera->setViewport(viewport);
671 camera->setClearMask(0);
672 camera->setInheritanceMask(CullSettings::ALL_VARIABLES
673 & ~(CullSettings::COMPUTE_NEAR_FAR_MODE
674 | CullSettings::CULLING_MODE
675 | CullSettings::CLEAR_MASK
676 ));
677 camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
678 camera->setCullingMode(osg::CullSettings::NO_CULLING);
679 camera->setProjectionResizePolicy(osg::Camera::FIXED);
680
681 // OSG is buggy and treats draw buffer target as separate from FBO
682 // state. Be explicit about drawing to back buffer to reduce chance of
683 // inheriting a GL_NONE, which is particularly likely with single target
684 // CSM passes and stereo.
685 camera->setDrawBuffer(GL_BACK);
686 camera->setReadBuffer(GL_BACK);
687
688 // The camera group will always update the camera
689 camera->setReferenceFrame(Transform::ABSOLUTE_RF);
690
691 // Draw all nodes in the order they are added to the GUI camera
692 camera->getOrCreateStateSet()
693 ->setRenderBinDetails( 0,
694 "PreOrderBin",
695 osg::StateSet::OVERRIDE_RENDERBIN_DETAILS );
696
697 // XXX Camera needs to be drawn last; eventually the render order
698 // should be assigned by a camera manager.
699 camera->setRenderOrder(osg::Camera::POST_RENDER, 10000);
700
701 Pass *pass = new Pass;
702 pass->camera = camera;
703 pass->useMastersSceneData = false;
704 pass->update_callback = new GUIUpdateCallback;
705
706 // For now we just build a simple Compositor directly from C++ space that
707 // encapsulates a single osg::Camera. This could be improved by letting
708 // users change the Compositor config in XML space, for example to be able
709 // to add post-processing to a HUD.
710 // However, since many other parts of FG require direct access to the GUI
711 // osg::Camera object, this is fine for now.
712 Compositor *compositor = new Compositor(_viewer, window->gc, viewport);
713 compositor->addPass(pass);
714
715 const int cameraFlags = CameraInfo::GUI | CameraInfo::DO_INTERSECTION_TEST;
716 CameraInfo* info = new CameraInfo(cameraFlags);
717 info->name = "GUI camera";
718 info->viewOffset = osg::Matrix::identity();
719 info->projOffset = osg::Matrix::identity();
720 info->compositor.reset(compositor);
721 _cameras.push_back(info);
722
723 // Disable statistics for the GUI camera.
724 camera->setStats(0);
725}
726
727Compositor *CameraGroup::buildVRMirrorCompositor(osg::GraphicsContext* gc,
728 osg::Viewport *viewport)
729{
730#ifdef ENABLE_OSGXR
731 if (VRManager::instance()->getUseMirror()) {
732 Camera* camera = new Camera;
733 camera->setName("VRMirror");
734 camera->setAllowEventFocus(false);
735 camera->setGraphicsContext(gc);
736 camera->setViewport(viewport);
737 camera->setClearMask(0);
738 camera->setInheritanceMask(CullSettings::ALL_VARIABLES
739 & ~(CullSettings::COMPUTE_NEAR_FAR_MODE
740 | CullSettings::CULLING_MODE
741 | CullSettings::CLEAR_MASK
742 ));
743 camera->setComputeNearFarMode(CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
744 camera->setCullingMode(CullSettings::NO_CULLING);
745 camera->setProjectionResizePolicy(Camera::FIXED);
746
747 // OSG is buggy and treats draw buffer target as separate from FBO
748 // state. Be explicit about drawing to back buffer to reduce chance of
749 // inheriting a GL_NONE, which is particularly likely with single target
750 // CSM passes and stereo.
751 camera->setDrawBuffer(GL_BACK);
752 camera->setReadBuffer(GL_BACK);
753
754 // The camera group will always update the camera
755 camera->setReferenceFrame(Transform::ABSOLUTE_RF);
756
757 // Mirror camera needs to be drawn after VR cameras and before GUI
758 camera->setRenderOrder(Camera::POST_RENDER, 9000);
759
760 // Let osgXR do the mirror camera setup
761 VRManager::instance()->setupMirrorCamera(camera);
762
763 Pass *pass = new Pass;
764 pass->camera = camera;
765 pass->useMastersSceneData = false;
766
767 // We just build a simple Compositor directly from C++ space that
768 // encapsulates a single osg::Camera.
769 Compositor *compositor = new Compositor(_viewer, gc, viewport);
770 compositor->addPass(pass);
771
772 return compositor;
773 }
774#endif
775 return nullptr;
776}
777
779 SGPropertyNode* gnode)
780{
781 CameraGroup* cgroup = new CameraGroup(view);
782 cgroup->_listener.reset(new CameraGroupListener(cgroup, gnode));
783
784 for (int i = 0; i < gnode->nChildren(); ++i) {
785 SGPropertyNode* pNode = gnode->getChild(i);
786 std::string name = pNode->getNameString();
787 if (name == "camera") {
788 cgroup->buildCamera(pNode);
789 } else if (name == "window") {
791 } else if (name == "splash") {
792 cgroup->buildSplashCamera(pNode);
793 } else if (name == "gui") {
794 cgroup->buildGUICamera(pNode);
795 }
796 }
797
798 return cgroup;
799}
800
801void CameraGroup::setCameraCullMasks(osg::Node::NodeMask nm)
802{
803 for (auto& info : _cameras) {
804 if (info->flags & CameraInfo::GUI)
805 continue;
806 info->compositor->setCullMask(nm);
807 }
808}
809
811{
812 for (auto& info : _cameras) {
813 if (info->flags & CameraInfo::GUI)
814 continue;
815 info->compositor->setLODScale(scale);
816 }
817}
818
820{
821 for (const auto &info : _cameras)
822 info->compositor->resized();
823}
824
826{
827 auto result = std::find_if(_cameras.begin(), _cameras.end(),
828 [](const osg::ref_ptr<CameraInfo> &i) {
829 return (i->flags & CameraInfo::GUI) != 0;
830 });
831 if (result == _cameras.end())
832 return 0;
833 return (*result);
834}
835
836osg::Camera* getGUICamera(CameraGroup* cgroup)
837{
838 return cgroup->getGUICamera()->compositor->getPass(0)->camera;
839}
840
845
846static bool
848 const CameraInfo *cinfo,
849 const osg::Vec2d &windowPos,
850 osgUtil::LineSegmentIntersector::Intersections &intersections)
851{
853 return false;
854
855 const osg::Viewport *viewport = cinfo->compositor->getViewport();
856 SGRect<double> viewportRect(viewport->x(), viewport->y(),
857 viewport->x() + viewport->width() - 1.0,
858 viewport->y() + viewport->height()- 1.0);
859 double epsilon = 0.5;
860 if (!viewportRect.contains(windowPos.x(), windowPos.y(), epsilon))
861 return false;
862
863 osg::Vec4d start(windowPos.x(), windowPos.y(), 0.0, 1.0);
864 osg::Vec4d end(windowPos.x(), windowPos.y(), 1.0, 1.0);
865 osg::Matrix windowMat = viewport->computeWindowMatrix();
866 osg::Matrix invViewMat = osg::Matrix::inverse(cinfo->viewMatrix);
867 osg::Matrix invProjMat = osg::Matrix::inverse(cinfo->projMatrix * windowMat);
868 start = start * invProjMat;
869 end = end * invProjMat;
870 start /= start.w();
871 end /= end.w();
872 start = start * invViewMat;
873 end = end * invViewMat;
874
875 osg::ref_ptr<osgUtil::LineSegmentIntersector> picker =
876 new osgUtil::LineSegmentIntersector(osgUtil::Intersector::MODEL,
877 osg::Vec3d(start.x(), start.y(), start.z()),
878 osg::Vec3d(end.x(), end.y(), end.z()));
879 osgUtil::IntersectionVisitor iv(picker);
880 iv.setTraversalMask(simgear::PICK_BIT);
881
882 const_cast<CameraGroup*>(cgroup)->getView()->getSceneData()->accept(iv);
883 if (picker->containsIntersections()) {
884 intersections = picker->getIntersections();
885 return true;
886 }
887
888 return false;
889}
890
892 const osg::Vec2d& windowPos,
893 osgUtil::LineSegmentIntersector::Intersections& intersections)
894{
895 // Find camera that contains event
896 for (const auto &cinfo : cgroup->_cameras) {
897 // Skip the splash and GUI cameras
898 if (cinfo->flags & (CameraInfo::SPLASH | CameraInfo::GUI))
899 continue;
900
901 if (computeCameraIntersection(cgroup, cinfo, windowPos, intersections))
902 return true;
903 }
904
905 intersections.clear();
906 return false;
907}
908
909void warpGUIPointer(CameraGroup* cgroup, int x, int y)
910{
911 using osgViewer::GraphicsWindow;
912 osg::Camera* guiCamera = getGUICamera(cgroup);
913 if (!guiCamera)
914 return;
915 osg::Viewport* vport = guiCamera->getViewport();
917 = dynamic_cast<GraphicsWindow*>(guiCamera->getGraphicsContext());
918 if (!gw)
919 return;
920 globals->get_renderer()->getEventHandler()->setMouseWarped();
921 // Translate the warp request into the viewport of the GUI camera,
922 // send the request to the window, then transform the coordinates
923 // for the Viewer's event queue.
924 double wx = x + vport->x();
925 double wyUp = vport->height() + vport->y() - y;
926 double wy;
927 const osg::GraphicsContext::Traits* traits = gw->getTraits();
928 if (gw->getEventQueue()->getCurrentEventState()->getMouseYOrientation()
929 == osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS) {
930 wy = traits->height - wyUp;
931 } else {
932 wy = wyUp;
933 }
934 gw->getEventQueue()->mouseWarped(wx, wy);
935 gw->requestWarpPointer(wx, wy);
936 osgGA::GUIEventAdapter* eventState
937 = cgroup->getView()->getEventQueue()->getCurrentEventState();
938 double viewerX
939 = (eventState->getXmin()
940 + ((wx / double(traits->width))
941 * (eventState->getXmax() - eventState->getXmin())));
942 double viewerY
943 = (eventState->getYmin()
944 + ((wyUp / double(traits->height))
945 * (eventState->getYmax() - eventState->getYmin())));
946 cgroup->getView()->getEventQueue()->mouseWarped(viewerX, viewerY);
947}
948
950{
951 auto viewer_base = globals->get_renderer()->getViewerBase();
952 bool should_restart_threading = viewer_base->areThreadsRunning();
953 if (should_restart_threading) {
954 viewer_base->stopThreading();
955 }
956
957 // Prevent the camera render orders increasing indefinitely with each reload
958 Compositor::resetOrderOffset();
959
960 for (auto &info : cgroup->_cameras) {
961 // Ignore the splash & GUI camera
962 if (info->flags & (CameraInfo::SPLASH | CameraInfo::GUI))
963 continue;
964 // Get the viewport and the graphics context from the old Compositor
965 osg::ref_ptr<osg::Viewport> viewport = info->compositor->getViewport();
966 osg::ref_ptr<osg::GraphicsContext> gc =
967 info->compositor->getGraphicsContext();
968 osg::ref_ptr<SGReaderWriterOptions> options =
969 SGReaderWriterOptions::fromPath(globals->get_fg_root());
970 options->setPropertyNode(globals->get_props());
971
972 if (info->reloadCompositorCallback.valid())
973 info->reloadCompositorCallback->preReloadCompositor(cgroup, info);
974
975 // Force deletion
976 info->compositor.reset(nullptr);
977 // Then replace it with a new instance
978 std::string compositor_path = info->compositor_path.empty() ?
979 fgGetString("/sim/rendering/default-compositor", "Compositor/default") :
980 info->compositor_path;
981 Compositor *compositor = nullptr;
982 if (info->flags & CameraInfo::VR_MIRROR)
983 compositor = cgroup->buildVRMirrorCompositor(gc, viewport);
984 if (!compositor)
985 compositor = Compositor::create(cgroup->_viewer,
986 gc,
987 viewport,
988 compositor_path,
989 options,
990 &info->mvr);
991 info->compositor.reset(compositor);
992
993 if (info->reloadCompositorCallback.valid())
994 info->reloadCompositorCallback->postReloadCompositor(cgroup, info);
995 }
996
997 if (should_restart_threading) {
998 viewer_base->startThreading();
999 }
1000 fgSetBool("/sim/rendering/compositor-reload-required", false);
1001 fgSetBool("/sim/signals/compositor-reload", true);
1002}
1003
1004void CameraGroup::buildDefaultGroup(osgViewer::View* viewer)
1005{
1006 // Look for windows, camera groups, and the old syntax of
1007 // top-level cameras
1008 SGPropertyNode* renderingNode = fgGetNode("/sim/rendering");
1009 SGPropertyNode* cgroupNode = renderingNode->getNode("camera-group", true);
1010 bool oldSyntax = !cgroupNode->hasChild("camera");
1011 if (oldSyntax) {
1012 for (int i = 0; i < renderingNode->nChildren(); ++i) {
1013 SGPropertyNode* propNode = renderingNode->getChild(i);
1014 const std::string propName = propNode->getNameString();
1015 if (propName == "window" || propName == "camera") {
1016 SGPropertyNode* copiedNode
1017 = cgroupNode->getNode(propName, propNode->getIndex(), true);
1018 copyProperties(propNode, copiedNode);
1019 }
1020 }
1021
1022 SGPropertyNodeVec cameras(cgroupNode->getChildren("camera"));
1023 SGPropertyNode* masterCamera = 0;
1024 SGPropertyNodeVec::const_iterator it;
1025 for (it = cameras.begin(); it != cameras.end(); ++it) {
1026 if ((*it)->getDoubleValue("shear-x", 0.0) == 0.0
1027 && (*it)->getDoubleValue("shear-y", 0.0) == 0.0) {
1028 masterCamera = it->ptr();
1029 break;
1030 }
1031 }
1032 if (!masterCamera) {
1033 masterCamera = cgroupNode->getChild("camera", cameras.size(), true);
1034 setValue(masterCamera->getNode("window/name", true),
1036 // Use VR mirror compositor when VR is enabled.
1037 setValue(masterCamera->getNode("vr-mirror", true), true);
1038 }
1039 SGPropertyNode* nameNode = masterCamera->getNode("window/name");
1040 if (nameNode)
1041 setValue(cgroupNode->getNode("gui/window/name", true),
1042 nameNode->getStringValue());
1043 }
1044
1045 SGPropertyNode* splashWindowNameNode = cgroupNode->getNode("splash/window/name");
1046 if (!splashWindowNameNode) {
1047 // Find the first camera with a window name
1048 SGPropertyNodeVec cameras(cgroupNode->getChildren("camera"));
1049 for (auto it = cameras.begin(); it != cameras.end(); ++it) {
1050 SGPropertyNode* nameNode = (*it)->getNode("window/name");
1051 if (nameNode) {
1052 // Use that window name for the splash
1053 setValue(cgroupNode->getNode("splash/window/name", true),
1054 nameNode->getStringValue());
1055 break;
1056 }
1057 }
1058 }
1059
1060 CameraGroup* cgroup = buildCameraGroup(viewer, cgroupNode);
1061 setDefault(cgroup);
1062}
1063
1064} // of namespace flightgear
static double scale(int center, int deadband, int min, int max, int value)
bool options(int, char **)
Definition JSBSim.cpp:568
#define i(x)
#define iv(x)
CameraGroupListener(CameraGroup *cg, SGPropertyNode *gnode)
virtual void valueChanged(SGPropertyNode *prop)
const CameraList & getCameras()
void buildGUICamera(SGPropertyNode *cameraNode, GraphicsWindow *window=0)
Create a camera from properties that will draw the GUI and add it to the camera group.
void buildSplashCamera(SGPropertyNode *cameraNode, GraphicsWindow *window=0)
Create a camera from properties that will draw the splash screen and add it to the camera group.
CameraInfo * getGUICamera() const
simgear::compositor::Compositor * buildVRMirrorCompositor(osg::GraphicsContext *gc, osg::Viewport *viewport)
Create a compositor for a VR mirror.
void removeCamera(CameraInfo *info)
Remove a camera from the camera group.
std::vector< osg::ref_ptr< CameraInfo > > CameraList
void resized()
Update camera properties after a resize event.
static osg::ref_ptr< CameraGroup > _defaultGroup
double getMasterAspectRatio() const
get aspect ratio of master camera's viewport
std::unique_ptr< CameraGroupListener > _listener
static CameraGroup * buildCameraGroup(osgViewer::View *viewer, SGPropertyNode *node)
Build a complete CameraGroup from a property node.
static void buildDefaultGroup(osgViewer::View *view)
Set the default CameraGroup, which is the only one that matters at this time.
CameraInfo * buildCamera(SGPropertyNode *cameraNode)
Create an osg::Camera from a property node and add it to the camera group.
static void setDefault(CameraGroup *group)
osg::ref_ptr< osgViewer::View > _viewer
void setCameraCullMasks(osg::Node::NodeMask nm)
Set the cull mask on all non-GUI cameras.
void setCameraParameters(float vfov, float aspectRatio)
Set the parameters of the viewer's master camera.
void setLODScale(float scale)
Set the LOD scale on all non-GUI cameras.
CameraGroup(osgViewer::View *viewer)
Create a camera group associated with an osgViewer::Viewer.
osgViewer::View * getView()
Get the camera group's Viewer.
void update(const osg::Vec3d &position, const osg::Quat &orientation)
Update the view for the camera group.
A window with a graphics context and an integer ID.
unsigned flags
Flags for the window.
osg::ref_ptr< osg::GraphicsContext > gc
The OSG graphics context for this window.
@ GUI
The GUI (and 2D cockpit) will be drawn on this window.
Singleton Builder class for creating a GraphicsWindow from property nodes.
static WindowBuilder * getWindowBuilder()
Get the singleton window builder.
GraphicsWindow * buildWindow(const SGPropertyNode *winNode)
Create a window from its property node description.
std::string fgGetString(const char *name, const char *defaultValue)
Get a string value for a property.
Definition fg_props.cxx:556
FGGlobals * globals
Definition globals.cxx:142
#define R
const double P0(101325.0)
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
std::vector< SGPropertyNode_ptr > SGPropertyNodeVec
static bool computeCameraIntersection(const CameraGroup *cgroup, const CameraInfo *cinfo, const osg::Vec2d &windowPos, osgUtil::LineSegmentIntersector::Intersections &intersections)
const char * name
osg::Camera * getGUICamera(CameraGroup *cgroup)
Get the osg::Camera that draws the GUI, if any, from a camera group.
void reloadCompositors(CameraGroup *cgroup)
Force a reload of all Compositor instances in the CameraGroup, except the one used by the GUI camera.
const char DEFAULT_WINDOW_NAME[]
void warpGUIPointer(CameraGroup *cgroup, int x, int y)
Warp the pointer to coordinates in the GUI camera of a camera group.
bool computeIntersections(const CameraGroup *cgroup, const osg::Vec2d &windowPos, osgUtil::LineSegmentIntersector::Intersections &intersections)
Choose a camera using an event and do intersection testing on its view of the scene.
Definition AIBase.hxx:25
bool fgSetBool(char const *name, bool val)
Set a bool value for a property.
Definition proptest.cpp:24
double fgGetDouble(const char *name, double defaultValue)
Get a double value for a property.
Definition proptest.cpp:30
SGPropertyNode * fgGetNode(const char *path, bool create)
Get a property node.
Definition proptest.cpp:27
A wrapper around osg::Camera that contains some extra information.
@ GUI
Camera draws the GUI.
@ VIEW_ABSOLUTE
The camera view is absolute, not relative to the master camera.
@ DO_INTERSECTION_TEST
scene intersection tests this camera.
@ SPLASH
For splash screen.
@ ENABLE_MASTER_ZOOM
Can apply the zoom algorithm.
@ ORTHO
The projection is orthographic.
@ VR_MIRROR
Switch to a mirror of VR.
@ PROJECTION_ABSOLUTE
The projection is absolute.
@ FIXED_NEAR_FAR
take the near far values in the projection for real.
simgear::compositor::Compositor::MVRInfo mvr
Multiview rendering properties.
const CameraInfo * relativeCameraParent
Non-owning reference to the parent camera for relative camera configurations.
unsigned flags
Properties of the camera.
std::string compositor_path
Compositor path.
osg::Vec2d thisReference[2]
The reference points in the current projection space.
osg::Matrix viewMatrix
Current view and projection matrices for this camera.
std::unique_ptr< simgear::compositor::Compositor > compositor
The Compositor used to manage the pipeline of this camera.
osg::Matrix viewOffset
View offset from the viewer master camera.
osg::Matrix projOffset
Projection offset from the viewer master camera.
osg::Vec2d parentReference[2]
The reference points in the parents projection space.
std::string name
The name as given in the config file.
double physicalWidth
Physical size parameters.
virtual void updatePass(Pass &pass, const osg::Matrix &view_matrix, const osg::Matrix &proj_matrix)
void SViewSetCompositorParams(osg::ref_ptr< simgear::SGReaderWriterOptions > options, const std::string &compositor_path)
Definition sview.cxx:1840