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

Method OnDraw

Descent3/pilot.cpp:3526–3604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3524}
3525
3526void UI3DWindow::OnDraw() {
3527 AudioStream::Frame();
3528
3529 static polymodel_effect pefx;
3530
3531 vector viewer_eye = {0, 0, 0};
3532 matrix viewer_orient = IDENTITY_MATRIX;
3533 viewer_eye.z = -ship_pos.cam_dist;
3534
3535 // 3d start frame
3536 //@@@@@StartFrame(m_X,m_Y,m_X+m_W-1,m_Y+m_H-1);
3537 g3_StartFrame(&viewer_eye, &viewer_orient, D3_DEFAULT_ZOOM);
3538 rend_SetFlatColor(0);
3539
3540 if (ship_model == -1) {
3541 mprintf(0, "Shipmodel is -1\n");
3542 return;
3543 }
3544
3545 float normalized_time[MAX_SUBOBJECTS];
3546 float light_scalar, size;
3547 PageInPolymodel(ship_model, OBJ_PLAYER, &size);
3548 poly_model *pm = GetPolymodelPointer(ship_model);
3549 vector view_pos;
3550 vector light_vec;
3551 matrix view_orient = IDENTITY_MATRIX;
3552 matrix rot_mat = IDENTITY_MATRIX;
3553 matrix final_mat = IDENTITY_MATRIX;
3554
3555 // draw model.
3556 SetNormalizedTimeAnim(0, normalized_time, pm);
3557
3558 view_pos = pm->anim_size_offset;
3559
3560 // move 30 degrees a sec
3561 float new_time = timer_GetTime();
3562
3563 vm_AnglesToMatrix(&rot_mat, 0, (new_time - ship_pos.last_time) * (65535 / 360) * 30, 0);
3564 vm_MatrixMul(&view_orient, &rot_mat, &ship_pos.last_frame);
3565 vm_Orthogonalize(&view_orient);
3566 ship_pos.last_frame = view_orient;
3567
3568 light_vec.x = 0.0f;
3569 light_vec.y = -1.0f;
3570 light_vec.z = -1.0f;
3571 light_scalar = 0.8f;
3572 vm_NormalizeVector(&light_vec);
3573
3574 rend_SetZBufferState(1);
3575 rend_SetAlphaType(AT_CONSTANT_TEXTURE);
3576 rend_SetAlphaValue(255);
3577 rend_SetLighting(LS_NONE);
3578 rend_SetColorModel(CM_MONO);
3579 rend_SetOverlayType(OT_NONE);
3580
3581 if (ship_pos.bm_handle > BAD_BITMAP_HANDLE) {
3582 if (ship_pos.texture_changed) {
3583 memset(&pefx, 0, sizeof(pefx));

Callers

nothing calls this directly

Calls 15

g3_StartFrameFunction · 0.85
PageInPolymodelFunction · 0.85
GetPolymodelPointerFunction · 0.85
SetNormalizedTimeAnimFunction · 0.85
vm_NormalizeVectorFunction · 0.85
SetPolymodelEffectFunction · 0.85
DrawPolygonModelFunction · 0.85
g3_EndFrameFunction · 0.85
rend_SetFlatColorFunction · 0.50
vm_AnglesToMatrixFunction · 0.50
vm_MatrixMulFunction · 0.50
vm_OrthogonalizeFunction · 0.50

Tested by

no test coverage detected