View on GitHub

Vistle

Distributed Data-parallel Scientific Visualization in VR

rfbext.h
Go to the documentation of this file.
1
11#ifndef PROTOCOL_EXTENSIONS_H
12#define PROTOCOL_EXTENSIONS_H
13
14#include <cstring> // memset
15#include "depthquant.h"
16#include "export.h"
17
18#include <vistle/core/message.h>
19
20namespace vistle {
21
22const size_t RhrMessageSize = 840;
23
25enum {
32};
33
36 rfbMsg(uint8_t type): type(type), modificationCount(0) {}
37
38 uint8_t type;
40};
41
43
47 : rfbMsg(rfbMatrices), last(0), eye(rfbEyeMiddle), viewNum(-1), width(0), height(0), requestNumber(0), time(0.)
48 {
49 memset(model, '\0', sizeof(model));
50 memset(view, '\0', sizeof(view));
51 memset(proj, '\0', sizeof(proj));
52 memset(head, '\0', sizeof(head));
53 }
54
55 uint8_t last;
56 uint8_t eye;
57 int16_t viewNum;
58 uint16_t width, height;
59 uint32_t requestNumber;
60 double time;
61 double model[16];
62 double view[16];
63 double proj[16];
64 double head[16];
65
66 bool operator==(const matricesMsg &other) const
67 {
68 if (eye != other.eye)
69 return false;
70 if (viewNum != other.viewNum)
71 return false;
72 if (width != other.width)
73 return false;
74 if (height != other.height)
75 return false;
76
77 for (int i = 0; i < 16; ++i) {
78 if (model[i] != other.model[i])
79 return false;
80 if (view[i] != other.view[i])
81 return false;
82 if (proj[i] != other.proj[i])
83 return false;
84 if (head[i] != other.head[i])
85 return false;
86 }
87
88 return true;
89 }
90};
91static_assert(sizeof(matricesMsg) < RhrMessageSize, "RHR message too large");
92
95 lightsMsg(): rfbMsg(rfbLights), viewNum(-1)
96 {
97 memset(pad, '\0', sizeof(pad));
98
99 lights[0].diffuse[0] = lights[0].diffuse[1] = lights[0].diffuse[2] = lights[0].diffuse[3] = 1;
100 lights[0].specular[0] = lights[0].specular[1] = lights[0].specular[2] = lights[0].specular[3] = 1;
101 }
102
104 static const int NumLights = 4;
105
107 struct Light {
108 // as in OpenGL
109 uint8_t enabled;
110
111 uint8_t pad[7];
112
113 double position[4];
114
115 double ambient[4];
116 double diffuse[4];
117 double specular[4];
118
119 double spot_direction[3];
120 double spot_cutoff;
122
123 double attenuation[3];
124
126 {
127 memset(this, '\0', sizeof(*this));
128
129 position[2] = 1;
130
131 ambient[3] = 1;
132
133 spot_direction[2] = -1;
134 spot_cutoff = 180;
135
136 attenuation[0] = 1;
137 }
138
139 bool operator!=(const Light &o) const
140 {
141 if (enabled != o.enabled)
142 return true;
143
144 for (int i = 0; i < 4; ++i) {
145 if (position[i] != o.position[i])
146 return true;
147 if (ambient[i] != o.ambient[i])
148 return true;
149 if (diffuse[i] != o.diffuse[i])
150 return true;
151 if (specular[i] != o.specular[i])
152 return true;
153 }
154
155 for (int i = 0; i < 3; ++i) {
156 if (spot_direction[i] != o.spot_direction[i])
157 return true;
158 if (attenuation[i] != o.attenuation[i])
159 return true;
160 }
161
162 if (spot_cutoff != o.spot_cutoff)
163 return true;
164 if (spot_exponent != o.spot_exponent)
165 return true;
166
167 return false;
168 }
169 };
170
171 int16_t viewNum;
172 uint8_t pad[5];
173
175 Light lights[NumLights];
176
177 bool operator!=(const lightsMsg &o) const
178 {
179 if (viewNum != o.viewNum)
180 return true;
181 for (int i = 0; i < NumLights; ++i) {
182 if (lights[i] != o.lights[i])
183 return true;
184 }
185 return false;
186 }
187};
188static_assert(sizeof(lightsMsg) < RhrMessageSize, "RHR message too large");
189
192 boundsMsg(): rfbMsg(rfbBounds), sendreply(0), radius(-1.)
193 {
194 memset(pad, '\0', sizeof(pad));
195 memset(center, '\0', sizeof(center));
196 }
197
198 uint8_t sendreply;
199 uint8_t pad[6];
200 double center[3];
201 double radius;
202};
203static_assert(sizeof(boundsMsg) < RhrMessageSize, "RHR message too large");
204
210};
211
213
225};
226
228struct V_RHREXPORT tileMsg: public rfbMsg {
230 : rfbMsg(rfbTile)
231 , flags(rfbTileNone)
232 , format(rfbColorRGBA)
233 , compression(rfbTileRaw)
234 , eye(rfbEyeMiddle)
235 , frameNumber(0)
236 , requestNumber(0)
237 , size(0)
238 , x(0)
239 , y(0)
240 , viewNum(-1)
241 , width(0)
242 , height(0)
243 , totalwidth(0)
244 , totalheight(0)
245 , timestep(-1)
246 , unzippedsize(0)
247 , requestTime(0.)
248 {
249 memset(model, '\0', sizeof(model));
250 memset(view, '\0', sizeof(view));
251 memset(proj, '\0', sizeof(proj));
252 memset(proj, '\0', sizeof(head));
253 }
254
255 uint8_t flags;
256 uint8_t format;
257 uint8_t compression;
258 uint8_t eye;
259 uint32_t frameNumber;
260 uint32_t requestNumber;
261 uint32_t size;
262 uint16_t x;
263 uint16_t y;
264 int16_t viewNum;
265 uint16_t width;
266 uint16_t height;
267 uint16_t totalwidth;
268 uint16_t totalheight;
269 int32_t timestep;
270 int32_t unzippedsize;
271 double head[16];
272 double view[16];
273 double proj[16];
274 double model[16];
275 double requestTime;
276};
277static_assert(sizeof(tileMsg) < RhrMessageSize, "RHR message too large");
278
281 animationMsg(): rfbMsg(rfbAnimation), total(0), current(-1) {}
282
283 int32_t total;
284 int32_t current;
285 double time;
286};
287static_assert(sizeof(animationMsg) < RhrMessageSize, "RHR message too large");
288
290 variantMsg(): rfbMsg(rfbVariant), configureVisibility(0), visible(0), remove(0)
291 {
292 memset(name, '\0', sizeof(name));
293 }
294
296 uint32_t visible;
297 uint32_t remove;
298 char name[200];
299};
300static_assert(sizeof(variantMsg) < RhrMessageSize, "RHR message too large");
301
304
305namespace message {
306
307class V_RHREXPORT RemoteRenderMessage: public MessageBase<RemoteRenderMessage, REMOTERENDERING> {
308public:
309 RemoteRenderMessage(const RhrSubMessage &rhr, size_t payloadSize = 0);
310 const RhrSubMessage &rhr() const;
311 RhrSubMessage &rhr();
312
313private:
314 std::array<char, RhrMessageSize> m_rhr;
315};
316
317} // namespace message
318
319} // namespace vistle
320#endif
Definition: rfbext.h:307
Depth quantization for remote hybrid rendering.
#define V_RHREXPORT
Definition: export.h:9
@ rfbTile
send image tile from server to client
Definition: rfbext.h:28
@ rfbAnimation
current/total animation time steps
Definition: rfbext.h:30
@ rfbMatrices
send matrices from client to server
Definition: rfbext.h:26
@ rfbVariant
control visibility of variants
Definition: rfbext.h:31
@ rfbBounds
send scene bounds from server to client
Definition: rfbext.h:29
@ rfbLights
send lighting parameters from client to server
Definition: rfbext.h:27
rfbTileCompressions
Definition: rfbext.h:214
@ rfbTileRaw
Definition: rfbext.h:215
@ rfbTilePredictRGBA
Definition: rfbext.h:223
@ rfbTileDepthZfp
Definition: rfbext.h:220
@ rfbTileJpeg
Definition: rfbext.h:221
@ rfbTileDepthPredictPlanar
Definition: rfbext.h:217
@ rfbTilePredictRGB
Definition: rfbext.h:222
@ rfbTileDepthQuantize
Definition: rfbext.h:218
@ rfbTileClear
Definition: rfbext.h:224
@ rfbTileDepthPredict
Definition: rfbext.h:216
@ rfbTileDepthQuantizePlanar
Definition: rfbext.h:219
rfbMsg RhrSubMessage
header for remote hybrid rendering message
Definition: rfbext.h:300
rfbTileFormats
Definition: rfbext.h:212
@ rfbDepth8Bit
Definition: rfbext.h:212
@ rfbDepth16Bit
Definition: rfbext.h:212
@ rfbColorRGBA
Definition: rfbext.h:212
@ rfbDepth32Bit
Definition: rfbext.h:212
@ rfbDepth24Bit
Definition: rfbext.h:212
@ rfbDepthFloat
Definition: rfbext.h:212
rfbTileFlags
Definition: rfbext.h:205
@ rfbTileRequest
Definition: rfbext.h:209
@ rfbTileFirst
Definition: rfbext.h:207
@ rfbTileNone
Definition: rfbext.h:206
@ rfbTileLast
Definition: rfbext.h:208
@ rfbEyeRight
Definition: rfbext.h:42
@ rfbEyeLeft
Definition: rfbext.h:42
@ rfbEyeMiddle
Definition: rfbext.h:42
const size_t RhrMessageSize
Definition: rfbext.h:22
animation time step on client or no. of animation steps on server changed
Definition: rfbext.h:280
animationMsg()
Definition: rfbext.h:281
double time
time of request - for latency measurement
Definition: rfbext.h:285
int32_t current
timestep currently displayed
Definition: rfbext.h:284
int32_t total
total number of animation timesteps
Definition: rfbext.h:283
send scene bounding sphere from server to client
Definition: rfbext.h:191
double radius
radius of bounding sphere
Definition: rfbext.h:201
boundsMsg()
Definition: rfbext.h:192
uint8_t sendreply
request reply with scene bounding sphere
Definition: rfbext.h:198
store parameters for one OpenGL light source
Definition: rfbext.h:107
double ambient[4]
contribution to ambient lighting (RGBA)
Definition: rfbext.h:115
bool operator!=(const Light &o) const
Definition: rfbext.h:139
Light()
attunuation: 0: constant, 1: linear, 2: quadratic
Definition: rfbext.h:125
double spot_direction[3]
direction of spot light
Definition: rfbext.h:119
uint8_t enabled
whether the light source is enabled
Definition: rfbext.h:109
double position[4]
position
Definition: rfbext.h:113
double spot_cutoff
cut-off coefficient for spot light
Definition: rfbext.h:120
double diffuse[4]
contribution to diffuse lighting (RGBA)
Definition: rfbext.h:116
double specular[4]
contribution to specular highlights (RGBA)
Definition: rfbext.h:117
double attenuation[3]
Definition: rfbext.h:123
double spot_exponent
cut-off exponenent for spot light
Definition: rfbext.h:121
send lighting parameters from client to server
Definition: rfbext.h:94
lightsMsg()
Definition: rfbext.h:95
Light lights[NumLights]
all light sources
Definition: rfbext.h:175
int16_t viewNum
number of window that these lights apply to
Definition: rfbext.h:171
bool operator!=(const lightsMsg &o) const
Definition: rfbext.h:177
send matrices from client to server
Definition: rfbext.h:45
uint8_t eye
0: middle, 1: left, 2: right
Definition: rfbext.h:56
bool operator==(const matricesMsg &other) const
Definition: rfbext.h:66
double model[16]
model matrix
Definition: rfbext.h:61
uint8_t last
1 if this is the last view requested for this frame
Definition: rfbext.h:55
uint16_t width
Definition: rfbext.h:58
double proj[16]
projection matrix
Definition: rfbext.h:63
double head[16]
head matrix
Definition: rfbext.h:64
int16_t viewNum
number of window/view that these matrices apply to
Definition: rfbext.h:57
double view[16]
view matrix
Definition: rfbext.h:62
uint32_t requestNumber
number of render request
Definition: rfbext.h:59
matricesMsg()
Definition: rfbext.h:46
double time
time of request - for latency measurement
Definition: rfbext.h:60
uint16_t height
dimensions of requested viewport
Definition: rfbext.h:58
basic RFB message header
Definition: rfbext.h:35
rfbMsg(uint8_t type)
Definition: rfbext.h:36
uint8_t type
type of RFB message
Definition: rfbext.h:38
uint32_t modificationCount
number of remote scenegraph modifications
Definition: rfbext.h:39
send image tile from server to client
Definition: rfbext.h:228
uint32_t requestNumber
number of request this tile is in response to, copied from matrices request
Definition: rfbext.h:260
tileMsg()
Definition: rfbext.h:229
uint32_t frameNumber
number of frame this tile belongs to
Definition: rfbext.h:259
uint8_t compression
compression,
Definition: rfbext.h:257
uint16_t y
y coordinate of depth sub-image
Definition: rfbext.h:263
uint8_t format
depth format,
Definition: rfbext.h:256
uint8_t eye
0: middle, 1: left, 2: right
Definition: rfbext.h:258
uint32_t size
size of payload,
Definition: rfbext.h:261
uint16_t totalheight
total height of image
Definition: rfbext.h:268
uint16_t height
height of depth sub-image
Definition: rfbext.h:266
double requestTime
time copied from matrices request
Definition: rfbext.h:275
uint16_t totalwidth
total width of image
Definition: rfbext.h:267
uint8_t flags
request depth buffer update
Definition: rfbext.h:255
int32_t unzippedsize
number of rendered timestep
Definition: rfbext.h:270
int16_t viewNum
viewNum this tile belongs to
Definition: rfbext.h:264
uint16_t x
x coordinate of depth sub-image
Definition: rfbext.h:262
uint16_t width
width of depth sub-image
Definition: rfbext.h:265
int32_t timestep
Definition: rfbext.h:269
Definition: rfbext.h:289
uint32_t configureVisibility
Definition: rfbext.h:295
uint32_t visible
Definition: rfbext.h:296
variantMsg()
Definition: rfbext.h:290
uint32_t remove
Definition: rfbext.h:297