Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
CloudBaseGeometry.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cassert>
4
#include <cmath>
5
6
namespace
CloudBaseGeometry
7
{
8
// Continue the current face's gnomonic projection across the entire cloud
9
// patch. Folding terrain coordinates onto adjacent faces changes the UV
10
// slope at edges and leaves an unmapped quadrant at three-face corners.
11
// Clouds have no terrain data dependency, so they can cover that quadrant.
12
template
<
class
Vector>
13
Vector
Position
(
int
cube,
int
u,
int
v,
float
radius)
14
{
15
Vector planar;
16
switch
(cube)
17
{
18
case
0:
// prime meridian
19
planar = Vector(2.0f * (u - 1019), -2038.0f, 2.0f * (v - 1019));
20
break
;
21
case
1:
// east
22
planar = Vector(2038.0f, 2.0f * (u - 3057), 2.0f * (v - 1019));
23
break
;
24
case
2:
// west
25
planar = Vector(-2038.0f, -2.0f * (u + 1019), 2.0f * (v - 1019));
26
break
;
27
case
3:
// date line
28
planar = Vector(-2.0f * (u - 5095), 2038.0f, 2.0f * (v - 1019));
29
break
;
30
case
4:
// north
31
planar = Vector(2.0f * (u - 1019), -2.0f * (v + 1019), -2038.0f);
32
break
;
33
case
5:
// south
34
planar = Vector(2.0f * (u - 1019), 2.0f * (v - 3057), 2038.0f);
35
break
;
36
default
:
37
assert(
false
&&
"Invalid cloud cube face"
);
38
return
Vector(0.0f, 0.0f, 0.0f);
39
}
40
41
// Render positions use the opposite sign to planet coordinates.
42
const
float
scale = -radius / std::sqrt(
43
planar.x * planar.x + planar.y * planar.y + planar.z * planar.z);
44
return
Vector(planar.x * scale, planar.y * scale, planar.z * scale);
45
}
46
}
CloudBaseGeometry
Definition
CloudBaseGeometry.h:7
CloudBaseGeometry::Position
Vector Position(int cube, int u, int v, float radius)
Definition
CloudBaseGeometry.h:13
Viewscreen
CloudBaseGeometry.h
Generated on
for Rise by
1.18.0