2019-08-31 19:18:15 -07:00
|
|
|
/*
|
2022-07-07 09:10:14 -07:00
|
|
|
* Copyright (c) 2016-2022 Vera Visions LLC.
|
2019-08-31 19:18:15 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2022-07-07 09:10:14 -07:00
|
|
|
*/
|
2019-03-21 13:50:51 -07:00
|
|
|
|
2020-03-23 23:26:49 -07:00
|
|
|
/*QUAKED env_cubemap (0 0 1) (-8 -8 -8) (8 8 8)
|
2019-09-06 20:37:06 -07:00
|
|
|
Specifies a location for which a cubemap will be generated when the
|
|
|
|
buildcubemaps console command is executed.
|
2020-10-25 04:38:41 -07:00
|
|
|
|
2021-07-14 02:49:30 -07:00
|
|
|
-------- KEYS --------
|
2021-07-17 12:04:34 -07:00
|
|
|
"scale" : Texture dimension at which to render the cubemap. Default is "32".
|
2021-07-14 02:49:30 -07:00
|
|
|
|
|
|
|
-------- TRIVIA --------
|
2020-10-25 04:38:41 -07:00
|
|
|
This entity was introduced in Half-Life 2 (2004).
|
2019-03-21 13:50:51 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
int g_iCubeProcess;
|
|
|
|
entity g_eCubeCycle;
|
|
|
|
vector g_vecCubePos;
|
2022-02-17 22:16:35 -08:00
|
|
|
float g_dCubeSize;
|
2019-03-21 13:50:51 -07:00
|
|
|
|
|
|
|
void CMap_Check(void);
|
|
|
|
void CMap_Shoot(void);
|
|
|
|
|
2019-09-01 21:29:18 -07:00
|
|
|
class
|
2021-10-19 16:18:36 -07:00
|
|
|
env_cubemap:NSEntity
|
2019-09-01 21:29:18 -07:00
|
|
|
{
|
2022-12-06 15:04:07 -08:00
|
|
|
public:
|
|
|
|
void env_cubemap(void);
|
|
|
|
virtual void SpawnKey(string,string);
|
2019-03-21 13:50:51 -07:00
|
|
|
|
2022-12-06 15:04:07 -08:00
|
|
|
private:
|
|
|
|
int m_iSize;
|
2019-03-21 13:50:51 -07:00
|
|
|
};
|
|
|
|
|
2019-09-01 21:29:18 -07:00
|
|
|
void
|
|
|
|
env_cubemap::SpawnKey(string strField, string strKey)
|
2019-03-21 13:50:51 -07:00
|
|
|
{
|
|
|
|
switch (strField) {
|
2019-09-01 21:29:18 -07:00
|
|
|
case "scale":
|
|
|
|
m_iSize = stoi(strKey);
|
|
|
|
if (m_iSize <= 16) {
|
|
|
|
m_iSize = 16;
|
|
|
|
} else if (m_iSize <= 32) {
|
|
|
|
m_iSize = 32;
|
|
|
|
} else if (m_iSize <= 64) {
|
|
|
|
m_iSize = 64;
|
|
|
|
} else if (m_iSize <= 128) {
|
|
|
|
m_iSize = 128;
|
|
|
|
} else {
|
|
|
|
m_iSize = 256;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2021-10-19 16:18:36 -07:00
|
|
|
super::SpawnKey(strField, strKey);
|
2019-03-21 13:50:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-01 21:29:18 -07:00
|
|
|
void
|
|
|
|
env_cubemap::env_cubemap(void)
|
2019-03-21 13:50:51 -07:00
|
|
|
{
|
|
|
|
m_iSize = 32;
|
2022-06-03 15:22:33 -07:00
|
|
|
isCSQC = true;
|
2019-03-21 13:50:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CMap_Check
|
|
|
|
|
|
|
|
Checks whether or not a specific cubemap file was dumped, goes to the next
|
|
|
|
=================
|
|
|
|
*/
|
2019-09-01 21:29:18 -07:00
|
|
|
void
|
|
|
|
CMap_Shoot(void)
|
2019-03-21 13:50:51 -07:00
|
|
|
{
|
|
|
|
string strReflectcube;
|
2019-09-01 21:29:18 -07:00
|
|
|
if (self.owner) {
|
2019-03-21 13:50:51 -07:00
|
|
|
env_cubemap tmp = (env_cubemap) self.owner;
|
2019-09-01 21:29:18 -07:00
|
|
|
print("^3Cubemap processing...\n");
|
2019-03-21 13:50:51 -07:00
|
|
|
g_vecCubePos = tmp.origin;
|
2022-02-17 22:16:35 -08:00
|
|
|
g_dCubeSize = (float)tmp.m_iSize;
|
2022-08-05 21:15:19 -07:00
|
|
|
|
|
|
|
g_view.SetClientAngle([0,0,0]);
|
|
|
|
g_view.SetCameraAngle([0,0,0]);
|
2022-03-22 16:38:31 -07:00
|
|
|
|
2019-03-21 13:50:51 -07:00
|
|
|
strReflectcube = sprintf(
|
2022-04-25 15:25:35 -07:00
|
|
|
"env/%s_%d_%d_%d",
|
2019-09-01 21:29:18 -07:00
|
|
|
mapname,
|
|
|
|
g_vecCubePos[0],
|
|
|
|
g_vecCubePos[1],
|
|
|
|
g_vecCubePos[2]);
|
2019-03-21 13:50:51 -07:00
|
|
|
localcmd(sprintf(
|
2022-02-17 22:16:35 -08:00
|
|
|
"screenshot_cubemap %S %i\n",
|
2019-09-01 21:29:18 -07:00
|
|
|
strReflectcube,
|
|
|
|
tmp.m_iSize));
|
2019-03-21 13:50:51 -07:00
|
|
|
self.think = CMap_Check;
|
2022-04-17 13:50:14 -07:00
|
|
|
self.nextthink = time + 0.25f;
|
2019-03-21 13:50:51 -07:00
|
|
|
} else {
|
2019-09-01 21:29:18 -07:00
|
|
|
print("^2Cubemaps done...\n");
|
2020-03-23 09:25:03 -07:00
|
|
|
localcmd("vid_reload\n");
|
2019-03-21 13:50:51 -07:00
|
|
|
g_iCubeProcess = FALSE;
|
2019-09-01 21:29:18 -07:00
|
|
|
remove(self);
|
2019-03-21 13:50:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CMap_Check
|
|
|
|
|
|
|
|
Checks whether or not a specific cubemap file was dumped, goes to the next
|
|
|
|
=================
|
|
|
|
*/
|
2019-09-01 21:29:18 -07:00
|
|
|
void
|
|
|
|
CMap_Check(void)
|
2019-03-21 13:50:51 -07:00
|
|
|
{
|
2019-10-08 13:14:18 -07:00
|
|
|
self.owner = find(self.owner, classname, "env_cubemap");
|
|
|
|
self.think = CMap_Shoot;
|
2022-04-17 13:50:14 -07:00
|
|
|
self.nextthink = time + 0.1f; /* because sigh */
|
2019-03-21 13:50:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CMap_Build
|
|
|
|
|
2019-03-22 19:16:34 -07:00
|
|
|
Called upon 'buildcubemaps'
|
2019-03-21 13:50:51 -07:00
|
|
|
=================
|
|
|
|
*/
|
2019-09-01 21:29:18 -07:00
|
|
|
void
|
|
|
|
CMap_Build(void)
|
2019-03-21 13:50:51 -07:00
|
|
|
{
|
2022-03-22 16:38:31 -07:00
|
|
|
/* prevent command spam */
|
2019-03-21 13:50:51 -07:00
|
|
|
if (g_iCubeProcess == TRUE) {
|
2022-03-22 16:38:31 -07:00
|
|
|
return;
|
2019-03-21 13:50:51 -07:00
|
|
|
}
|
|
|
|
|
2020-03-03 13:47:01 -08:00
|
|
|
localcmd("r_speeds 0\n");
|
|
|
|
localcmd("show_fps 0\n");
|
|
|
|
localcmd("r_showfields 0\n");
|
|
|
|
localcmd("r_showshaders 0\n");
|
|
|
|
localcmd("r_showbboxes 0\n");
|
|
|
|
localcmd("r_wireframe 0\n");
|
|
|
|
localcmd("r_hdr_irisadaptation 0\n");
|
2020-03-23 09:25:03 -07:00
|
|
|
localcmd("r_postprocshader \"\"0\n");
|
2019-03-21 13:50:51 -07:00
|
|
|
print("^4Building cubemaps...\n");
|
|
|
|
g_eCubeCycle = spawn();
|
|
|
|
g_eCubeCycle.owner = find(world, classname, "env_cubemap");
|
|
|
|
|
|
|
|
if (g_eCubeCycle.owner) {
|
|
|
|
g_eCubeCycle.think = CMap_Shoot;
|
|
|
|
g_eCubeCycle.nextthink = time;
|
|
|
|
g_iCubeProcess = TRUE;
|
|
|
|
}
|
|
|
|
}
|