HoviTron Video Pipeline
Public Member Functions | Data Fields
RenderingParameters Class Reference

Class that encapsulates the rendering parameters (RVS internal parameters + virtual camera parameters). More...

#include <RenderingParameters.h>

Public Member Functions

void init (int view, WindowAbstract *window, VulkanWrapper *wraps)
 
 ~RenderingParameters ()
 
void updateSpaceTransform (glm::vec3 translation, glm::vec3 rotation)
 
void updateSpaceTransform (glm::vec3 translation, glm::vec3 rotation, glm::vec4 fov, int view)
 
const InputProvider::Extrinsics getVirtualExtrinsics (int view)
 
const InputProvider::Intrinsics getVirtualIntrinsics (int view)
 
void setStartingPt (glm::vec3 startPos, glm::vec3 startRot)
 
const glm::vec3 getStartingPosition ()
 
const glm::vec3 getStartingRotation ()
 

Data Fields

float blendingFactor = 5.0
 
float pixelThreshold = 30
 
const glm::mat3x3 conversionToOMAF = { 0,-1,0, 0,0,1, -1,0,0 }
 
float maxMult = 10
 
float scaleFactor = 1.0
 
std::vector< glm::vec2 > virtualViewDef
 
InputProvider::ProjectionType projectionType = InputProvider::ProjectionType::PROJECTION_INVALID
 
float max_depth = 0.0
 
float min_depth = FLT_MAX
 
float farPlaneHeadset = 10
 
float nearPlaneHeadset = 0.1
 

Detailed Description

Class that encapsulates the rendering parameters (RVS internal parameters + virtual camera parameters).

Class that encapsulates the rendering parameters (RVS internal parameters + virtual camera parameters). If the HVT_UDP_CONTROL macro is used, a UDP server is created on a new thread. This allow some parameters to be modified using UDP messages.

Definition at line 108 of file RenderingParameters.h.

Constructor & Destructor Documentation

◆ ~RenderingParameters()

RenderingParameters::~RenderingParameters ( )

Clean up the ressources

Definition at line 58 of file RenderingParameters.cpp.

59{
60#ifdef HVT_UDP_CONTROL
61 serverIsActive = false;
62 serverThread.join();
63#endif
64}

Member Function Documentation

◆ getStartingPosition()

const glm::vec3 RenderingParameters::getStartingPosition ( )

Return starting position

Definition at line 160 of file RenderingParameters.cpp.

161{
162#ifdef HVT_UDP_CONTROL
163 startPosMut.lock();
164#endif
165 const glm::vec3 res = glm::vec3(startingPosition);
166#ifdef HVT_UDP_CONTROL
167 startPosMut.unlock();
168#endif
169 return res;
170}

◆ getStartingRotation()

const glm::vec3 RenderingParameters::getStartingRotation ( )

Return starting rotation

Definition at line 172 of file RenderingParameters.cpp.

173{
174#ifdef HVT_UDP_CONTROL
175 startPosMut.lock();
176#endif
177 const glm::vec3 res = glm::vec3(startingRotation);
178#ifdef HVT_UDP_CONTROL
179 startPosMut.unlock();
180#endif
181 return res;
182}

◆ getVirtualExtrinsics()

const InputProvider::Extrinsics RenderingParameters::getVirtualExtrinsics ( int  view)

Return the extrinsics for the requested view

Definition at line 103 of file RenderingParameters.cpp.

104{
105 InputProvider::Extrinsics pose = { .position = {0,0,0}, .rotation = {0,0,0} };
106
107 //TODO move that at a better place
108 glm::vec3 averagePos = { 0,0,0 };
109 for (int i = 0; i < virtualExtrinsics.size(); i++) {
110 averagePos += virtualExtrinsics[i].position;
111 }
112 averagePos /= virtualExtrinsics.size();
113
114 if (virtualMode == VirtualMode::Static1) {
115#ifdef HVT_UDP_CONTROL
116 mutex.lock();
117#endif
118 pose.position = staticPosition[0] + (virtualExtrinsics[view].position - averagePos );
119 pose.rotation = quatToEuler(staticQuaternion[0]);
120#ifdef HVT_UDP_CONTROL
121 mutex.unlock();
122#endif
123 //pose.rotation = static[0];
124 }
125 else if (virtualMode == VirtualMode::Static2) {
126#ifdef HVT_UDP_CONTROL
127 mutex.lock();
128#endif
129 pose.position = staticPosition[1] + (virtualExtrinsics[view].position - averagePos );
130 pose.rotation = quatToEuler(staticQuaternion[1]);
131#ifdef HVT_UDP_CONTROL
132 mutex.unlock();
133#endif
134 }
135 else {
136 assert(virtualExtrinsics.size() > view);
137 pose = virtualExtrinsics[view];
138 }
139 return pose;
140}

◆ getVirtualIntrinsics()

const InputProvider::Intrinsics RenderingParameters::getVirtualIntrinsics ( int  view)

Return the intrinsics for the requested view

Definition at line 142 of file RenderingParameters.cpp.

143{
144 assert(virtualIntrasics.size() > view);
145 return virtualIntrasics[view];
146}

◆ init()

void RenderingParameters::init ( int  view,
WindowAbstract window,
VulkanWrapper wraps 
)

Init the parameters

Definition at line 27 of file RenderingParameters.cpp.

28{
29#endif
30 window = wind;
31 wrapper = wraps;
32
33 virtualExtrinsics.resize(viewNum);
34 virtualIntrasics.resize(viewNum);
35 virtualViewDef.resize(viewNum);
36
37 staticPosition.resize(staticPoses);
38 staticQuaternion.resize(staticPoses);
39
40 for (int i = 0; i < viewNum; i++) {
41 auto ext = window->getSwapchainExtent(i);
42 virtualViewDef[i] = glm::vec2(ext.width, ext.height);
43 virtualExtrinsics[i].position = glm::vec3(0, 0, 0);
44 virtualExtrinsics[i].rotation = glm::vec3(0, 0, 0);
45 projectionType = InputProvider::ProjectionType::PROJECTION_PERSPECTIVE;
47 virtualIntrasics[i] = intra;
48 std::get<InputProvider::PerspectiveIntrinsics>(virtualIntrasics[i]).principle = glm::vec2(ext.width, ext.height) / 2.0f;
49 std::get<InputProvider::PerspectiveIntrinsics>(virtualIntrasics[i]).focals = glm::vec2(ext.width, ext.width) / 2.0f;
50 virtualIntrasics.push_back(intra);
51 }
52#ifdef HVT_UDP_CONTROL
53 setupUDPServer();
54#endif // HVT_UDP_CONTROL
55
56}
std::vector< glm::vec2 > virtualViewDef
InputProvider::ProjectionType projectionType
virtual vk::Extent2D getSwapchainExtent(int view)
Intrinsics parameters of a perspective projection.
Definition: InputProvider.h:59

◆ setStartingPt()

void RenderingParameters::setStartingPt ( glm::vec3  startPos,
glm::vec3  startRot 
)

Set an offset to the system

Definition at line 148 of file RenderingParameters.cpp.

149{
150#ifdef HVT_UDP_CONTROL
151 startPosMut.lock();
152#endif
153 startingPosition = startPos;
154 startingRotation = startRot;
155#ifdef HVT_UDP_CONTROL
156 startPosMut.unlock();
157#endif
158}

◆ updateSpaceTransform() [1/2]

void RenderingParameters::updateSpaceTransform ( glm::vec3  translation,
glm::vec3  rotation 
)

Update the extrinsics for the virtual camera

Definition at line 66 of file RenderingParameters.cpp.

67{
68 for (int i = 0; i < virtualExtrinsics.size(); i++) {
69 virtualExtrinsics[i].position = translation;//glm::vec3(translation[0], translation[1], translation[2]);
70 virtualExtrinsics[i].rotation = rotation;//glm::vec3(rotation[0], rotation[1], rotation[2]);
71 }
72}

◆ updateSpaceTransform() [2/2]

void RenderingParameters::updateSpaceTransform ( glm::vec3  translation,
glm::vec3  rotation,
glm::vec4  fov,
int  view 
)

Update the extrinsics (translation and rotation) and the intrasics ( focals and principle point and using info in fov) for the virtual camera corresponding to the view

Definition at line 74 of file RenderingParameters.cpp.

75{
76 virtualExtrinsics[view].position = translation;// glm::vec3(translation[0], translation[1], translation[2]);
77 virtualExtrinsics[view].rotation = rotation;//glm::vec3(rotation[0], rotation[1], rotation[2]);
78
79 auto tl = std::tan(fov[0]); //left
80 auto tr = std::tan(fov[1]); //right
81 auto tt = std::tan(fov[2]); //top
82 auto tb = std::tan(fov[3]); //down
83
84 auto tw = tr - tl;
85 auto th = tt - tb;
86
87 auto x0 = (-tl) / tw;
88 auto y0 = (-tb) / th;
89
90 if (projectionType == InputProvider::ProjectionType::PROJECTION_PERSPECTIVE) {
91 std::get<InputProvider::PerspectiveIntrinsics>(virtualIntrasics[view]).focals.x = virtualViewDef[view].x / tw;
92 std::get<InputProvider::PerspectiveIntrinsics>(virtualIntrasics[view]).focals.y = virtualViewDef[view].y / th;
93
94
95 std::get<InputProvider::PerspectiveIntrinsics>(virtualIntrasics[view]).principle.x = x0 * virtualViewDef[view].x;
96 std::get<InputProvider::PerspectiveIntrinsics>(virtualIntrasics[view]).principle.y = (1 - y0) * virtualViewDef[view].y;
97 }
98 else {
99 throw std::runtime_error("Unsupported projection type for virtual parameter"); //TODO support this (Should not be complicated since fov are already the angle that we need for ver_range and hor_range)
100 }
101}

Field Documentation

◆ blendingFactor

float RenderingParameters::blendingFactor = 5.0

Blending factor

Definition at line 122 of file RenderingParameters.h.

◆ conversionToOMAF

const glm::mat3x3 RenderingParameters::conversionToOMAF = { 0,-1,0, 0,0,1, -1,0,0 }

Matrix to convert from OpenXR to OMAF

Definition at line 126 of file RenderingParameters.h.

◆ farPlaneHeadset

float RenderingParameters::farPlaneHeadset = 10

far plane for the headset

Definition at line 150 of file RenderingParameters.h.

◆ max_depth

float RenderingParameters::max_depth = 0.0

max depthand min depth for depth extension

Definition at line 145 of file RenderingParameters.h.

◆ maxMult

float RenderingParameters::maxMult = 10

Factor to multiply the depth to avoid problem when virtual camera is to far from the camera array

Definition at line 129 of file RenderingParameters.h.

◆ min_depth

float RenderingParameters::min_depth = FLT_MAX

min depth for depth extension

Definition at line 147 of file RenderingParameters.h.

◆ nearPlaneHeadset

float RenderingParameters::nearPlaneHeadset = 0.1

near plane for the headset

Definition at line 152 of file RenderingParameters.h.

◆ pixelThreshold

float RenderingParameters::pixelThreshold = 30

Pixel threshold

Definition at line 124 of file RenderingParameters.h.

◆ projectionType

InputProvider::ProjectionType RenderingParameters::projectionType = InputProvider::ProjectionType::PROJECTION_INVALID

Define the projection type for the virtual view

Definition at line 142 of file RenderingParameters.h.

◆ scaleFactor

float RenderingParameters::scaleFactor = 1.0

Factor to scale the scene (don't use when depth is needed)

Definition at line 131 of file RenderingParameters.h.

◆ virtualViewDef

std::vector<glm::vec2> RenderingParameters::virtualViewDef

Definition of the virtual view that should be rendered

Definition at line 140 of file RenderingParameters.h.


The documentation for this class was generated from the following files: