MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DrawShardObject

Function DrawShardObject

Descent3/renderobject.cpp:996–1042  ·  view source on GitHub ↗

Draw a shard

Source from the content-addressed store, hash-verified

994#endif
995// Draw a shard
996void DrawShardObject(object *obj) {
997 shard_info_s *si = &obj->rtype.shard_info;
998 bool flip = 0;
999 g3Point rotated_points[3];
1000 g3Point *pointlist[3];
1001 uint8_t codes_and = 0xff;
1002 g3_StartInstanceMatrix(&obj->pos, &obj->orient);
1003 // Build list of points and UVLs for this face
1004 for (int i = 0; i < 3; i++) {
1005 uint8_t c;
1006 g3Point *p = &rotated_points[i];
1007 c = g3_RotatePoint(p, &si->points[i]);
1008 codes_and &= c;
1009 p->p3_uvl.u = si->u[i];
1010 p->p3_uvl.v = si->v[i];
1011 p->p3_uvl.a = 1.0; // GameTextures[si->tmap].alpha;
1012 p->p3_flags |= PF_UV; // + PF_L; // + PF_UV2 + PF_RGBA; //has uv and l set
1013 p->p3_uvl.l = 1.0;
1014 pointlist[i] = &rotated_points[i];
1015 }
1016 // Check for backside
1017 if (!g3_CheckNormalFacing(&obj->pos, &si->normal)) {
1018 g3Point *t = pointlist[1];
1019 pointlist[1] = pointlist[2];
1020 pointlist[2] = t;
1021 }
1022 // Done with 3D
1023 g3_DoneInstance();
1024 // Check if face off screen
1025 if (codes_and)
1026 return;
1027 // Get bitmap handle
1028 int bm_handle = GetTextureBitmap(si->tmap, 0);
1029 ASSERT(bm_handle != -1);
1030 float alpha = GameTextures[si->tmap].alpha;
1031 alpha = 0.2 + alpha * 0.8; // Make less transparent
1032 // Set alpha, transparency, & lighting for this face
1033 rend_SetAlphaType(ATF_CONSTANT);
1034 rend_SetAlphaValue(alpha * 255);
1035 rend_SetLighting(LS_GOURAUD);
1036 rend_SetColorModel(CM_MONO);
1037 rend_SetOverlayType(OT_NONE);
1038 // Select texture type
1039 rend_SetTextureType(TT_LINEAR);
1040 // Draw the polygon
1041 g3_DrawPoly(3, pointlist, bm_handle);
1042}
1043// Sets up the light states for an outdoor object to be rendered
1044bool SetupTerrainObject(object *obj) {
1045 vector camlight = Terrain_sky.lightsource;

Callers 1

RenderObjectFunction · 0.85

Calls 12

g3_StartInstanceMatrixFunction · 0.85
g3_RotatePointFunction · 0.85
g3_CheckNormalFacingFunction · 0.85
g3_DoneInstanceFunction · 0.85
GetTextureBitmapFunction · 0.85
g3_DrawPolyFunction · 0.85
rend_SetAlphaTypeFunction · 0.50
rend_SetAlphaValueFunction · 0.50
rend_SetLightingFunction · 0.50
rend_SetColorModelFunction · 0.50
rend_SetOverlayTypeFunction · 0.50
rend_SetTextureTypeFunction · 0.50

Tested by

no test coverage detected