mirror of
https://github.com/ZDoom/Raze.git
synced 2024-12-02 00:53:16 +00:00
- main 3D render function.
This commit is contained in:
parent
15eae9c4a2
commit
629737bd72
7 changed files with 108 additions and 5 deletions
|
@ -217,6 +217,8 @@ EXTERN tspriteptr_t tsprite;
|
|||
extern sectortype sectorbackup[MAXSECTORS];
|
||||
extern walltype wallbackup[MAXWALLS];
|
||||
|
||||
extern bool inpreparemirror;
|
||||
|
||||
|
||||
static inline tspriteptr_t renderMakeTSpriteFromSprite(tspriteptr_t const tspr, uint16_t const spritenum)
|
||||
{
|
||||
|
|
|
@ -211,7 +211,7 @@ int16_t searchsector, searchwall, searchstat; //search output
|
|||
// When aiming at a 2-sided wall, 1 if aiming at the bottom part, 0 else
|
||||
int16_t searchbottomwall, searchisbottom;
|
||||
|
||||
char inpreparemirror = 0;
|
||||
bool inpreparemirror = 0;
|
||||
static int32_t mirrorsx1, mirrorsy1, mirrorsx2, mirrorsy2;
|
||||
|
||||
#define MAXSETVIEW 4
|
||||
|
|
|
@ -106,8 +106,6 @@ extern int32_t searchx, searchy;
|
|||
extern int16_t searchsector, searchwall, searchstat;
|
||||
extern int16_t searchbottomwall, searchisbottom;
|
||||
|
||||
extern char inpreparemirror;
|
||||
|
||||
extern int16_t sectorborder[256];
|
||||
extern int32_t hitallsprites;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ set( PCH_SOURCES
|
|||
src/fonts.cpp
|
||||
src/screenflash.cpp
|
||||
src/precache.cpp
|
||||
src/render.cpp
|
||||
)
|
||||
|
||||
add_game_library2( whaven )
|
||||
|
|
|
@ -281,7 +281,7 @@ void GameInterface::DrawBackground()
|
|||
}
|
||||
}
|
||||
|
||||
inline bool playrunning()
|
||||
bool playrunning()
|
||||
{
|
||||
return (paused == 0 || multiplayer/* || demoplay/record*/);
|
||||
}
|
||||
|
|
101
source/games/whaven/src/render.cpp
Normal file
101
source/games/whaven/src/render.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
#include "ns.h"
|
||||
#include "wh.h"
|
||||
#include "automap.h"
|
||||
#include "mmulti.h"
|
||||
#include "glbackend/glbackend.h"
|
||||
#include "raze_music.h"
|
||||
|
||||
BEGIN_WH_NS
|
||||
|
||||
|
||||
void drawscreen(int num, int dasmoothratio) {
|
||||
|
||||
PLAYER& plr = player[num];
|
||||
|
||||
int cposx = plr.x;
|
||||
int cposy = plr.y;
|
||||
int cposz = plr.z;
|
||||
float cang = plr.ang;
|
||||
float choriz = plr.horiz + plr.jumphoriz;
|
||||
|
||||
if (!paused)
|
||||
{
|
||||
auto& prevloc = gPrevPlayerLoc[num];
|
||||
|
||||
int ix = prevloc.x;
|
||||
int iy = prevloc.y;
|
||||
int iz = prevloc.z;
|
||||
float iHoriz = prevloc.horiz;
|
||||
float inAngle = prevloc.ang;
|
||||
|
||||
ix += mulscale(cposx - prevloc.x, dasmoothratio, 16);
|
||||
iy += mulscale(cposy - prevloc.y, dasmoothratio, 16);
|
||||
iz += mulscale(cposz - prevloc.z, dasmoothratio, 16);
|
||||
iHoriz += ((choriz - prevloc.horiz) * dasmoothratio) / 65536.0f;
|
||||
inAngle += ((BClampAngle(cang - prevloc.ang + 1024) - 1024) * dasmoothratio) / 65536.0f;
|
||||
|
||||
cposx = ix;
|
||||
cposy = iy;
|
||||
cposz = iz;
|
||||
|
||||
choriz = iHoriz;
|
||||
cang = inAngle;
|
||||
}
|
||||
|
||||
// wango
|
||||
if ((gotpic[FLOORMIRROR >> 3] & (1 << (FLOORMIRROR & 7))) != 0) {
|
||||
int dist = 0x7fffffff;
|
||||
int i = 0, j;
|
||||
for (int k = floormirrorcnt - 1; k >= 0; k--) {
|
||||
int sect = floormirrorsector[k];
|
||||
if((gotsector[sect >> 3] & (1 << (sect & 7))) == 0) continue;
|
||||
j = klabs(wall[sector[sect].wallptr].x - plr.x);
|
||||
j += klabs(wall[sector[sect].wallptr].y - plr.y);
|
||||
if (j < dist) {
|
||||
dist = j; i = k;
|
||||
}
|
||||
}
|
||||
|
||||
// Todo: render this with 30% light only.
|
||||
inpreparemirror = true;
|
||||
renderSetRollAngle(1024);
|
||||
renderDrawRoomsQ16(cposx, cposy, cposz, FloatToFixed(cang), FloatToFixed(201 - choriz), floormirrorsector[i]);
|
||||
analyzesprites(plr, dasmoothratio);
|
||||
renderDrawMasks();
|
||||
renderSetRollAngle(0);
|
||||
inpreparemirror = false;
|
||||
|
||||
gotpic[FLOORMIRROR >> 3] &= ~(1 << (FLOORMIRROR & 7));
|
||||
}
|
||||
|
||||
int ceilz, floorz;
|
||||
getzsofslope(plr.sector, cposx, cposy, &ceilz, &floorz);
|
||||
int lz = 4 << 8;
|
||||
if (cposz < ceilz + lz)
|
||||
cposz = ceilz + lz;
|
||||
if (cposz > floorz - lz)
|
||||
cposz = floorz - lz;
|
||||
|
||||
renderDrawRoomsQ16(cposx, cposy, cposz, FloatToFixed(cang), FloatToFixed(choriz), plr.sector);
|
||||
analyzesprites(plr, dasmoothratio);
|
||||
renderDrawMasks();
|
||||
|
||||
if (automapMode != am_off)
|
||||
{
|
||||
DrawOverheadMap(cposx, cposy, int(cang));
|
||||
}
|
||||
}
|
||||
|
||||
void GameInterface::Render()
|
||||
{
|
||||
double const smoothRatio = playrunning() ? I_GetTimeFrac() * MaxSmoothRatio : MaxSmoothRatio;
|
||||
|
||||
drawscreen(pyrn, FloatToFixed(smoothRatio));
|
||||
if (!paused && isWh2() && attacktheme && !Mus_IsPlaying())
|
||||
{
|
||||
startsong(krand() % 2);
|
||||
attacktheme = 0;
|
||||
}
|
||||
}
|
||||
|
||||
END_WH_NS
|
|
@ -510,6 +510,7 @@ void InitFonts();
|
|||
void sfxInit(void);
|
||||
|
||||
void IntroMovie(const CompletionFunc& completion);
|
||||
bool playrunning();
|
||||
|
||||
|
||||
#include "item.h"
|
||||
|
@ -538,7 +539,7 @@ struct GameInterface : public ::GameInterface
|
|||
//void UpdateSounds() override;
|
||||
void Startup() override;
|
||||
void DrawBackground() override;
|
||||
//void Render() override;
|
||||
void Render() override;
|
||||
void Ticker() override;
|
||||
const char* GenericCheat(int player, int cheat) override;
|
||||
const char* CheckCheatMode() override;
|
||||
|
|
Loading…
Reference in a new issue