Quake II RTX doxygen  1.0 dev
sky.c File Reference
#include "sw.h"

Go to the source code of this file.

Functions

void R_InitSkyBox (void)
 
void R_EmitSkyBox (void)
 
void R_SetSky (const char *name, float rotate, vec3_t axis)
 

Variables

static int r_skyframe
 
static mface_t r_skyfaces [6]
 
static cplane_t r_skyplanes [6]
 
static mtexinfo_t r_skytexinfo [6]
 
static mvertex_t r_skyverts [8]
 
static medge_t r_skyedges [12]
 
static msurfedge_t r_skysurfedges [24]
 
static const char r_skysidenames [6][3] = { "rt", "bk", "lf", "ft", "up", "dn" }
 
static const int r_skysideimage [6] = { 5, 2, 4, 1, 0, 3 }
 
static const int box_planes [12]
 
static const int box_surfedges [24]
 
static const int box_surfverts [24]
 
static const int box_edges [24]
 
static const int box_flags [6]
 
static const vec3_t box_axis [6][2]
 
static const vec3_t box_verts [8]
 

Function Documentation

◆ R_EmitSkyBox()

void R_EmitSkyBox ( void  )

Definition at line 116 of file sky.c.

117 {
118  int i, j;
119  int oldkey;
120 
121  if (insubmodel)
122  return; // submodels should never have skies
123  if (r_skyframe == r_framecount)
124  return; // already set this frame
125 
127 
128  // set the eight fake vertexes
129  for (i = 0; i < 8; i++)
130  for (j = 0; j < 3; j++)
131  r_skyverts[i].point[j] = r_origin[j] + box_verts[i][j] * 128;
132 
133  // set the six fake planes
134  for (i = 0; i < 6; i++)
135  if (box_planes[i * 2 + 1] > 0)
136  r_skyplanes[i].dist = r_origin[box_planes[i * 2]] + 128;
137  else
138  r_skyplanes[i].dist = r_origin[box_planes[i * 2]] - 128;
139 
140  // fix texture offsets
141  for (i = 0; i < 6; i++) {
142  r_skytexinfo[i].offset[0] = -DotProduct(r_origin, r_skytexinfo[i].axis[0]);
143  r_skytexinfo[i].offset[1] = -DotProduct(r_origin, r_skytexinfo[i].axis[1]);
144  }
145 
146  // emit the six faces
147  oldkey = r_currentkey;
148  r_currentkey = 0x7ffffff0;
149  for (i = 0; i < 6; i++) {
150  R_RenderFace(&r_skyfaces[i], 15);
151  }
152  r_currentkey = oldkey; // bsp sorting order
153 }

Referenced by R_RenderFace().

◆ R_InitSkyBox()

void R_InitSkyBox ( void  )

Definition at line 77 of file sky.c.

78 {
79  int i;
80 
81  for (i = 0; i < 6; i++) {
82  r_skyplanes[i].normal[box_planes[i * 2]] = 1;
83  r_skyplanes[i].dist = box_planes[i * 2 + 1];
84 
85  VectorCopy(box_axis[i][0], r_skytexinfo[i].axis[0]);
86  VectorCopy(box_axis[i][1], r_skytexinfo[i].axis[1]);
87 
88  r_skyfaces[i].plane = &r_skyplanes[i];
89  r_skyfaces[i].drawflags = box_flags[i] | DSURF_SKY;
90  r_skyfaces[i].numsurfedges = 4;
91  r_skyfaces[i].firstsurfedge = &r_skysurfedges[i * 4];
92  r_skyfaces[i].texinfo = &r_skytexinfo[i];
93  r_skyfaces[i].texturemins[0] = -128;
94  r_skyfaces[i].texturemins[1] = -128;
95  r_skyfaces[i].extents[0] = 256;
96  r_skyfaces[i].extents[1] = 256;
97  }
98 
99  for (i = 0; i < 24; i++) {
100  r_skysurfedges[i].edge = &r_skyedges[box_surfedges[i] - 1];
101  r_skysurfedges[i].vert = box_surfverts[i];
102  }
103 
104  for (i = 0; i < 12; i++) {
105  r_skyedges[i].v[0] = &r_skyverts[box_edges[i * 2 + 0] - 1];
106  r_skyedges[i].v[1] = &r_skyverts[box_edges[i * 2 + 1] - 1];
107  r_skyedges[i].cachededgeoffset = 0;
108  }
109 }

Referenced by R_Init().

◆ R_SetSky()

void R_SetSky ( const char *  name,
float  rotate,
vec3_t  axis 
)

Definition at line 160 of file sky.c.

161 {
162  int i;
163  char path[MAX_QPATH];
164 
165 // sky_rotate = rotate;
166 // VectorCopy(axis, sky_axis);
167 
168  for (i = 0; i < 6; i++) {
169  Q_concat(path, sizeof(path), "env/", name,
170  r_skysidenames[r_skysideimage[i]], ".tga", NULL);
171  FS_NormalizePath(path, path);
172  r_skytexinfo[i].image = IMG_Find(path, IT_SKY, IF_NONE);
173  }
174 }

Variable Documentation

◆ box_axis

const vec3_t box_axis[6][2]
static
Initial value:
= {
{ {0, -1, 0}, { -1, 0, 0} },
{ {0, 1, 0}, {0, 0, -1} },
{ {0, -1, 0}, {1, 0, 0} },
{ {1, 0, 0}, {0, 0, -1} },
{ {0, -1, 0}, {0, 0, -1} },
{ { -1, 0, 0}, {0, 0, -1} }
}

Definition at line 53 of file sky.c.

Referenced by R_InitSkyBox().

◆ box_edges

const int box_edges[24]
static
Initial value:
= {
1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 2, 7, 8, 8, 6, 5, 7, 8, 3, 7, 4
}

Definition at line 47 of file sky.c.

Referenced by R_InitSkyBox().

◆ box_flags

const int box_flags[6]
static
Initial value:
= {
0, 0, 1, 1, 1, 0
}

Definition at line 50 of file sky.c.

Referenced by R_InitSkyBox().

◆ box_planes

const int box_planes[12]
static
Initial value:
= {
2, -128, 0, -128, 2, 128, 1, 128, 0, 128, 1, -128
}

Definition at line 38 of file sky.c.

Referenced by R_EmitSkyBox(), and R_InitSkyBox().

◆ box_surfedges

const int box_surfedges[24]
static
Initial value:
= {
1, 2, 3, 4, 1, 5, 6, 7, 8, 9, 6, 10, 2, 7, 9, 11, 12, 3, 11, 8, 12, 10, 5, 4
}

Definition at line 41 of file sky.c.

Referenced by R_InitSkyBox().

◆ box_surfverts

const int box_surfverts[24]
static
Initial value:
= {
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1
}

Definition at line 44 of file sky.c.

Referenced by R_InitSkyBox().

◆ box_verts

const vec3_t box_verts[8]
static
Initial value:
= {
{ -1, -1, -1},
{ -1, 1, -1},
{1, 1, -1},
{1, -1, -1},
{ -1, -1, 1},
{ -1, 1, 1},
{1, -1, 1},
{1, 1, 1}
}

Definition at line 61 of file sky.c.

Referenced by R_EmitSkyBox().

◆ r_skyedges

medge_t r_skyedges[12]
static

Definition at line 30 of file sky.c.

Referenced by R_InitSkyBox().

◆ r_skyfaces

mface_t r_skyfaces[6]
static

Definition at line 26 of file sky.c.

Referenced by R_EmitSkyBox(), and R_InitSkyBox().

◆ r_skyframe

int r_skyframe
static

Definition at line 25 of file sky.c.

Referenced by R_EmitSkyBox().

◆ r_skyplanes

cplane_t r_skyplanes[6]
static

Definition at line 27 of file sky.c.

Referenced by R_EmitSkyBox(), and R_InitSkyBox().

◆ r_skysideimage

const int r_skysideimage[6] = { 5, 2, 4, 1, 0, 3 }
static

Definition at line 35 of file sky.c.

Referenced by R_SetSky().

◆ r_skysidenames

const char r_skysidenames[6][3] = { "rt", "bk", "lf", "ft", "up", "dn" }
static

Definition at line 34 of file sky.c.

Referenced by R_SetSky().

◆ r_skysurfedges

msurfedge_t r_skysurfedges[24]
static

Definition at line 31 of file sky.c.

Referenced by R_InitSkyBox().

◆ r_skytexinfo

mtexinfo_t r_skytexinfo[6]
static

Definition at line 28 of file sky.c.

Referenced by R_EmitSkyBox(), R_InitSkyBox(), and R_SetSky().

◆ r_skyverts

mvertex_t r_skyverts[8]
static

Definition at line 29 of file sky.c.

Referenced by R_EmitSkyBox(), and R_InitSkyBox().

r_origin
vec3_t r_origin
Definition: main.c:52
box_edges
static const int box_edges[24]
Definition: sky.c:47
r_skyedges
static medge_t r_skyedges[12]
Definition: sky.c:30
box_surfverts
static const int box_surfverts[24]
Definition: sky.c:44
box_planes
static const int box_planes[12]
Definition: sky.c:38
r_framecount
int r_framecount
Definition: main.c:64
R_RenderFace
void R_RenderFace(mface_t *fa, int clipflags)
Definition: raster.c:328
box_flags
static const int box_flags[6]
Definition: sky.c:50
r_skyplanes
static cplane_t r_skyplanes[6]
Definition: sky.c:27
DSURF_SKY
#define DSURF_SKY
Definition: sw.h:43
box_axis
static const vec3_t box_axis[6][2]
Definition: sky.c:53
r_skyverts
static mvertex_t r_skyverts[8]
Definition: sky.c:29
r_skysurfedges
static msurfedge_t r_skysurfedges[24]
Definition: sky.c:31
box_verts
static const vec3_t box_verts[8]
Definition: sky.c:61
IMG_Find
image_t * IMG_Find(const char *name, imagetype_t type, imageflags_t flags)
Definition: images.c:1122
r_currentkey
int r_currentkey
Definition: edge.c:46
r_skysideimage
static const int r_skysideimage[6]
Definition: sky.c:35
r_skyframe
static int r_skyframe
Definition: sky.c:25
insubmodel
qboolean insubmodel
Definition: bsp.c:25
Q_concat
size_t Q_concat(char *dest, size_t size,...)
Definition: shared.c:758
box_surfedges
static const int box_surfedges[24]
Definition: sky.c:41
r_skytexinfo
static mtexinfo_t r_skytexinfo[6]
Definition: sky.c:28
r_skysidenames
static const char r_skysidenames[6][3]
Definition: sky.c:34
FS_NormalizePath
size_t FS_NormalizePath(char *out, const char *in)
Definition: files.c:331
r_skyfaces
static mface_t r_skyfaces[6]
Definition: sky.c:26