Skip to content

Commit d72aefc

Browse files
committed
- extend draw distance, turn trees to view
1 parent 6857bbc commit d72aefc

3 files changed

Lines changed: 57 additions & 8 deletions

File tree

DriverLevelTool/driver_routines/d2_types.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ struct POLYGT4
192192
CVECTOR color;
193193
};
194194

195+
#if 0
195196
enum ModelFlags1 // collision flags?
196197
{
197198
everything = 1,
@@ -231,6 +232,31 @@ enum ModelFlags2 // effect flags?
231232
dontKnow15 = 16384, // ??? again: many sidewalks, some grass
232233
sidewalk = 32768
233234
};
235+
#else
236+
enum ModelShapeFlags
237+
{
238+
SHAPE_FLAG_SMASH_QUIET = 0x8,
239+
SHAPE_FLAG_NOCOLLIDE = 0x10,
240+
SHAPE_FLAG_SUBSURFACE = 0x80, // grass, dirt, water
241+
SHAPE_FLAG_ALLEYWAY = 0x400, // alleyway
242+
SHAPE_FLAG_SMASH_SPRITE = 0x4000,
243+
};
244+
245+
enum ModelFlags2
246+
{
247+
MODEL_FLAG_ANIMOBJ = 0x1,
248+
MODEL_FLAG_MEDIAN = 0x20,
249+
MODEL_FLAG_ALLEY = 0x80,
250+
MODEL_FLAG_HASROOF = 0x100,
251+
MODEL_FLAG_NOCOL_200 = 0x200,
252+
MODEL_FLAG_BARRIER = 0x400,
253+
MODEL_FLAG_SMASHABLE = 0x800,
254+
MODEL_FLAG_LAMP = 0x1000,
255+
MODEL_FLAG_TREE = 0x2000,
256+
MODEL_FLAG_GRASS = 0x4000,
257+
MODEL_FLAG_SIDEWALK = 0x8000,
258+
};
259+
#endif
234260

235261
struct MODEL
236262
{

DriverLevelTool/viewer/rendermodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ void CRenderModel::GenerateBuffers()
235235
UV_INFO uv = *(UV_INFO*)dec_face.uv[VERT_IDX];
236236

237237
// map to 0..1
238-
newVert.tc_u = (uv.u + 0.5f) / 256.0f; // do /2 and *2 as textures were already 4 bit
239-
newVert.tc_v = (uv.v + 0.5f) / 256.0f;
238+
newVert.tc_u = ((float)uv.u + 0.5f) / 256.0f; // do /2 and *2 as textures were already 4 bit
239+
newVert.tc_v = ((float)uv.v + 0.5f) / 256.0f;
240240
}
241241

242242
index = vertMap.grVertexIndex = vertices.append(newVert);

DriverLevelTool/viewer/viewer.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
" void main() {\n"\
3333
" vec4 lighting;\n"\
3434
" vec4 color = texture2D(s_texture, v_texcoord.xy);\n"\
35+
" if(color.r + color.g + color.b + color.a == 0.0f) discard;\n"\
3536
" lighting = vec4(color.rgb * u_ambientColor.rgb * u_ambientColor.a, color.a);\n"\
3637
" lighting.rgb += u_lightColor.rgb * u_lightColor.a * color.rgb * saturate(1.0 - dot(v_normal, u_lightDir));\n"\
3738
" fragColor = lighting;\n"\
@@ -241,7 +242,7 @@ void InitHWTexturePage(CTexturePage* tpage)
241242
// FIXME: load indexes instead?
242243

243244
for (int i = 0; i < numDetails; i++)
244-
tpage->ConvertIndexedTextureToRGBA(color_data, i, &bitmap.clut[i]);
245+
tpage->ConvertIndexedTextureToRGBA(color_data, i, &bitmap.clut[i], false, false);
245246

246247
int tpageId = tpage->GetId();
247248

@@ -259,7 +260,7 @@ void InitHWTexturePage(CTexturePage* tpage)
259260

260261
if (detail->extraCLUTs[pal])
261262
{
262-
tpage->ConvertIndexedTextureToRGBA(color_data, j, detail->extraCLUTs[pal]);
263+
tpage->ConvertIndexedTextureToRGBA(color_data, j, detail->extraCLUTs[pal], false, false);
263264
anyMatched = true;
264265
}
265266
}
@@ -296,7 +297,7 @@ void DrawLevelDriver2(const Vector3D& cameraPos)
296297
CELL_ITERATOR ci;
297298
PACKED_CELL_OBJECT* ppco;
298299

299-
int i = 441 * 2;
300+
int i = 441 * 32;
300301
int vloop = 0;
301302
int hloop = 0;
302303
int dir = 0;
@@ -313,7 +314,7 @@ void DrawLevelDriver2(const Vector3D& cameraPos)
313314
// walk through all cells
314315
while (i >= 0)
315316
{
316-
if (abs(hloop) + abs(vloop) < 64)
317+
if (abs(hloop) + abs(vloop) < 256)
317318
{
318319
// clamped vis values
319320
int vis_h = MIN(MAX(hloop, -9), 10);
@@ -348,14 +349,36 @@ void DrawLevelDriver2(const Vector3D& cameraPos)
348349
continue;
349350
}
350351

352+
ModelRef_t* ref = g_levModels.GetModelByIndex(co.type);
353+
MODEL* model = ref->model;
354+
351355
float cellRotationRad = -co.yang / 64.0f * PI_F * 2.0f;
352356

357+
bool isGround = false;
358+
359+
if(model)
360+
{
361+
if(model->flags2 == MODEL_FLAG_TREE)
362+
{
363+
cellRotationRad = DEG2RAD(g_cameraAngles.y);
364+
}
365+
366+
if ((model->shape_flags & (SHAPE_FLAG_SUBSURFACE | SHAPE_FLAG_ALLEYWAY)) ||
367+
(model->flags2 & (MODEL_FLAG_SIDEWALK | MODEL_FLAG_GRASS)))
368+
{
369+
isGround = true;
370+
}
371+
}
372+
353373
Vector3D absCellPosition(co.pos.vx * EXPORT_SCALING, co.pos.vy * -EXPORT_SCALING, co.pos.vz * EXPORT_SCALING);
354374
Matrix4x4 objectMatrix = translate(absCellPosition) * rotateY4(cellRotationRad);
355375
GR_SetMatrix(MATRIX_WORLD, objectMatrix);
356376
GR_UpdateMatrixUniforms();
357377

358-
ModelRef_t* ref = g_levModels.GetModelByIndex(co.type);
378+
if(isGround)
379+
{
380+
381+
}
359382

360383
CRenderModel* renderModel = (CRenderModel*)ref->userData;
361384

@@ -495,7 +518,7 @@ int ViewerMain(const char* filename)
495518

496519
GR_BeginScene();
497520

498-
GR_ClearColor(32, 32, 32);
521+
GR_ClearColor(128, 158, 182);
499522
GR_ClearDepth(1.0f);
500523

501524
// Control and map

0 commit comments

Comments
 (0)