Start checkpoint rendering

This commit is contained in:
Miloslav Ciz 2024-10-07 15:52:39 +02:00
parent e23fb2657a
commit 2c5162b635
5 changed files with 157 additions and 84 deletions

View file

@ -34,6 +34,9 @@
=========== BUGS =================
- drawing dithered transparent objects fills z-buffer in the transparent parts
and then the geometry behind it isn't drawn
=========== HANDLED ==============
- EFFICINT MAP DRAWING:

View file

@ -60,6 +60,9 @@ LCR_MAP_BLOCK(LCR_BLOCK_RAMP_STEEP,4,4,6,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_T
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_CURVED_PLAT,4,5,6,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_FLIP_V | LCR_BLOCK_TRANSFORM_ROT_180),
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_CURVED_PLAT,3,5,6,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_FLIP_V | LCR_BLOCK_TRANSFORM_ROT_180),
LCR_MAP_BLOCK(LCR_BLOCK_CHECKPOINT_0,3,2,4,LCR_BLOCK_MATERIAL_CONCRETE,0),
/*
LCR_MAP_BLOCK(LCR_BLOCK_FULL,2,1,9,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,2,5,1,0,0),
@ -74,7 +77,6 @@ LCR_MAP_BLOCK(LCR_BLOCK_CORNER,1,1,4,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,15,0,0,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,1,15,0,0),
/*
LCR_MAP_BLOCK(LCR_BLOCK_FULL,25,0,0,LCR_BLOCK_MATERIAL_ICE,0),
LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,1,15,0,0),

14
map.h
View file

@ -516,6 +516,20 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
switch (blockType)
{
case LCR_BLOCK_CHECKPOINT_0:
case LCR_BLOCK_CHECKPOINT_1:
ADD(3,0,3) ADD(6,2,0) ADD(0,2,0)
ADD(3,0,3) ADD(6,2,6) ADD(6,2,0)
ADD(3,0,3) ADD(0,2,0) ADD(0,2,6)
ADD(3,0,3) ADD(0,2,6) ADD(6,2,6)
ADD(3,4,3) ADD(0,2,0) ADD(6,2,0)
ADD(3,4,3) ADD(6,2,0) ADD(6,2,6)
ADD(3,4,3) ADD(0,2,6) ADD(0,2,0)
ADD(3,4,3) ADD(6,2,6) ADD(0,2,6)
break;
case LCR_BLOCK_FULL:
case LCR_BLOCK_BOTTOM:
case LCR_BLOCK_LEFT:

View file

@ -35,6 +35,17 @@
kinda hotfixes it -- later try to discover source of this bug. TODO */
#define _LCR_MAP_MODEL_SCALE 1034
#define LCR_RENDERER_MAT_CP0 0x0f
#define LCR_RENDERER_MAT_CP1 0x0e
#define LCR_RENDERER_MAT_FIN 0x0d
struct
{
S3L_Scene scene;
@ -128,7 +139,6 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
else if (pixel->modelIndex == 8)
{
// car model
LCR_loadImage(LCR_IMAGE_CAR);
for (int i = 0; i < 6; ++i)
@ -156,8 +166,24 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
pixel->modelIndex]];
uint8_t type = triData[pixel->triangleIndex] >> 4;
uint8_t mat = triData[pixel->triangleIndex] & 0x0f;
LCR_loadImage(triData[pixel->triangleIndex] & 0x0f);
switch (mat)
{
case LCR_RENDERER_MAT_CP0:
LCR_renderer.flatAndTransparent = LCR_SETTING_CHECKPOINT0_COLOR;
break;
case LCR_RENDERER_MAT_CP1:
LCR_renderer.flatAndTransparent = LCR_SETTING_CHECKPOINT1_COLOR;
break;
case LCR_RENDERER_MAT_FIN:
LCR_renderer.flatAndTransparent = LCR_SETTING_FINISH_COLOR;
break;
default:
LCR_loadImage(mat);
if (type == 0) // floor?
{
@ -206,6 +232,9 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
LCR_renderer.triUVs[2 + i] += shiftBy;
LCR_renderer.triUVs[4 + i] += shiftBy;
}
break;
}
}
}
@ -680,9 +709,18 @@ uint8_t _LCR_buildMapModel(void)
// don't add triangles completely at the floor or ceiling of the map
if (!edgeBits)
{
#define VERT(n,c) LCR_renderer.mapVerts[3 * n + c]
uint8_t triData;
if (blockType == LCR_BLOCK_CHECKPOINT_0)
triData = LCR_RENDERER_MAT_CP0;
else if (blockType == LCR_BLOCK_FINISH)
triData = LCR_RENDERER_MAT_FIN;
else
{
uint8_t blockMat = LCR_mapBlockGetMaterial(block);
uint8_t triData =
#define VERT(n,c) LCR_renderer.mapVerts[3 * n + c]
triData =
(((VERT(triIndices[0],0) == VERT(triIndices[1],0)) &&
(VERT(triIndices[1],0) == VERT(triIndices[2],0))) << 4) |
(((VERT(triIndices[0],2) == VERT(triIndices[1],2)) &&
@ -727,6 +765,7 @@ uint8_t _LCR_buildMapModel(void)
break;
}
}
}
_LCR_rendererAddMapTri(triIndices[0],triIndices[1],triIndices[2],
triData);

View file

@ -126,6 +126,21 @@
#define LCR_SETTING_GHOST_COLOR 0xff00
#endif
#ifndef LCR_SETTING_CHECKPOINT0_COLOR
/** Color of untaken checkpoint (in RGB565). */
#define LCR_SETTING_CHECKPOINT0_COLOR 0x0f00
#endif
#ifndef LCR_SETTING_CHECKPOINT1_COLOR
/** Color of taken checkpoint (in RGB565). */
#define LCR_SETTING_CHECKPOINT1_COLOR 0xf000
#endif
#ifndef LCR_SETTING_FINISH_COLOR
/** Color of finish block (in RGB565). */
#define LCR_SETTING_FINISH_COLOR 0x00f0
#endif
#ifndef LCR_SETTING_SMOOTH_ANIMATIONS
/** Whether to smooth out animations (car physics, camera movement etc.). */
#define LCR_SETTING_SMOOTH_ANIMATIONS 1