Overte C++ Documentation
SecondaryCamera.h
1 //
2 // SecondaryCamera.h
3 // interface/src
4 //
5 // Created by Samuel Gateau, Howard Stearns, and Zach Fox on 2017-06-08.
6 // Copyright 2013 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #pragma once
13 #ifndef hifi_SecondaryCamera_h
14 #define hifi_SecondaryCamera_h
15 
16 #include <render/RenderFetchCullSortTask.h>
17 #include <TextureCache.h>
18 #include <ViewFrustum.h>
19 
20 class SecondaryCameraJobConfig : public render::Task::Config { // Exposes secondary camera parameters to JavaScript.
21  Q_OBJECT
22  Q_PROPERTY(QUuid attachedEntityId MEMBER attachedEntityId NOTIFY dirty) // entity whose properties define camera position and orientation
23  Q_PROPERTY(QUuid portalEntranceEntityId MEMBER portalEntranceEntityId NOTIFY dirty) // entity whose properties define a portal's entrance position and orientation
24  Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPosition) // of viewpoint to render from
25  Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation) // of viewpoint to render from
26  Q_PROPERTY(float vFoV MEMBER vFoV NOTIFY dirty) // Secondary camera's vertical field of view. In degrees.
27  Q_PROPERTY(float nearClipPlaneDistance MEMBER nearClipPlaneDistance NOTIFY dirty) // Secondary camera's near clip plane distance. In meters.
28  Q_PROPERTY(float farClipPlaneDistance MEMBER farClipPlaneDistance NOTIFY dirty) // Secondary camera's far clip plane distance. In meters.
29  Q_PROPERTY(bool mirrorProjection MEMBER mirrorProjection NOTIFY dirty) // Flag to use attached mirror entity to build frustum for the mirror and set mirrored camera position/orientation.
30  Q_PROPERTY(bool portalProjection MEMBER portalProjection NOTIFY dirty) // Flag to use attached portal entity to build frustum for the portal and set portal camera position/orientation.
31 public:
32  QUuid attachedEntityId;
33  QUuid portalEntranceEntityId;
34  glm::vec3 position;
35  glm::quat orientation;
36  float vFoV { DEFAULT_FIELD_OF_VIEW_DEGREES };
37  float nearClipPlaneDistance { DEFAULT_NEAR_CLIP };
38  float farClipPlaneDistance { DEFAULT_FAR_CLIP };
39  int textureWidth { TextureCache::DEFAULT_SPECTATOR_CAM_WIDTH };
40  int textureHeight { TextureCache::DEFAULT_SPECTATOR_CAM_HEIGHT };
41  bool mirrorProjection { false };
42  bool portalProjection { false };
43 
44  SecondaryCameraJobConfig() : render::Task::Config(false) {}
45 signals:
46  void dirty();
47 public slots:
48  glm::vec3 getPosition() { return position; }
49  void setPosition(glm::vec3 pos);
50  glm::quat getOrientation() { return orientation; }
51  void setOrientation(glm::quat orient);
52  void enableSecondaryCameraRenderConfigs(bool enabled);
53  void resetSizeSpectatorCamera(int width, int height);
54 };
55 
56 class SecondaryCameraRenderTaskConfig : public render::Task::Config {
57  Q_OBJECT
58 public:
59  SecondaryCameraRenderTaskConfig() : render::Task::Config(false) {}
60 };
61 
62 class SecondaryCameraRenderTask {
63 public:
64  using Config = SecondaryCameraRenderTaskConfig;
65  using JobModel = render::Task::Model<SecondaryCameraRenderTask, Config>;
66  SecondaryCameraRenderTask() {}
67  void configure(const Config& config) {}
68  void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor);
69 };
70 
71 #endif