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

Method UpdateAnimStateView

editor/AnimStatesDialog.cpp:470–532  ·  view source on GitHub ↗

Draws the object based on the current animation state

Source from the content-addressed store, hash-verified

468
469// Draws the object based on the current animation state
470void CAnimStatesDialog::UpdateAnimStateView() {
471 int mc = m_current_state;
472 int anim = m_current_anim;
473 CWnd *objectwnd;
474 RECT rect;
475 int x, y, bm_handle, w, h;
476 static int frame = 0;
477 grHardwareSurface surf;
478
479 if (m_anim[mc].elem[anim].used != 1)
480 return;
481
482 // Bail out if the "to" frame is less than the "from" frame (ie backwards)
483 if (m_anim[mc].elem[anim].to < m_anim[mc].elem[anim].from)
484 return;
485
486 float frame_diff = (float)abs(m_anim[mc].elem[anim].to - m_anim[mc].elem[anim].from);
487 float frame_start = m_anim[mc].elem[anim].from;
488
489 frame++;
490 if (frame == NUM_ANIM_FRAMES)
491 frame = 0;
492
493 objectwnd = GetDlgItem(IDC_ANIMSTATE_VIEW);
494 objectwnd->GetWindowRect(&rect);
495 ScreenToClient(&rect);
496
497 Desktop_surf->attach_to_window((unsigned)m_hWnd);
498
499 w = rect.right - rect.left;
500 h = rect.bottom - rect.top;
501
502 bm_handle = m_render_handle; // GetObjectImage(m_current_id);
503
504 vector zero_vector;
505 vector view_vector = {0, 0, -20};
506 matrix id_matrix, rot_matrix;
507 poly_model *pm = GetPolymodelPointer(bm_handle);
508
509 vm_MakeZero(&zero_vector);
510 vm_MakeIdentity(&id_matrix);
511
512 float norm_angles[MAX_SUBOBJECTS];
513 float keyframe = frame_start + frame_diff * ((float)frame / (float)NUM_ANIM_FRAMES);
514
515 SetNormalizedTimeAnim(keyframe, norm_angles, pm);
516
517 vm_AnglesToMatrix(&rot_matrix, 0, m_SpinFrame * 400, 0);
518 view_vector.z = -(fabs(pm->maxs.z - pm->mins.z) * 2);
519
520 surf.create(128, 128, BPP_16);
521 grViewport *vport = new grViewport(&surf);
522 StartEditorFrame(vport, &view_vector, &id_matrix, D3_DEFAULT_ZOOM);
523 DrawPolygonModel(&zero_vector, &rot_matrix, bm_handle, norm_angles, 0, 1.0, 1.0, 1.0);
524 EndEditorFrame();
525
526 x = rect.left + ((rect.right - rect.left) / 2) - surf.width() / 2;
527 y = rect.top + ((rect.bottom - rect.top) / 2) - surf.height() / 2;

Callers

nothing calls this directly

Calls 14

GetPolymodelPointerFunction · 0.85
vm_MakeZeroFunction · 0.85
SetNormalizedTimeAnimFunction · 0.85
StartEditorFrameFunction · 0.85
DrawPolygonModelFunction · 0.85
EndEditorFrameFunction · 0.85
attach_to_windowMethod · 0.80
vm_MakeIdentityFunction · 0.50
vm_AnglesToMatrixFunction · 0.50
createMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected