| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- // RingSizePropPage.cpp : implementation file
- //
- #include "stdafx.h"
- #include "w3dview.h"
- #include "ringsizeproppage.h"
- #include "colorutils.h"
- #include "utils.h"
- #include "scaledialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- IMPLEMENT_DYNCREATE(RingSizePropPageClass, CPropertyPage)
- /////////////////////////////////////////////////////////////
- // Local prototypes
- /////////////////////////////////////////////////////////////
- static bool Is_LERP (float last_value, float last_time, float curr_value, float curr_time, float next_value, float next_time);
- /////////////////////////////////////////////////////////////
- //
- // RingSizePropPageClass
- //
- /////////////////////////////////////////////////////////////
- RingSizePropPageClass::RingSizePropPageClass (RingRenderObjClass *ring)
- : m_RenderObj (ring),
- m_bValid (true),
- m_InnerScaleXBar (NULL),
- m_InnerScaleYBar (NULL),
- m_OuterScaleXBar (NULL),
- m_OuterScaleYBar (NULL),
- m_InnerSize (0.5F, 0.5F),
- m_OuterSize (1.0F, 1.0F),
- CPropertyPage(RingSizePropPageClass::IDD)
- {
- //{{AFX_DATA_INIT(RingSizePropPageClass)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
-
- Initialize ();
- return ;
- }
- /////////////////////////////////////////////////////////////
- //
- // ~RingSizePropPageClass
- //
- /////////////////////////////////////////////////////////////
- RingSizePropPageClass::~RingSizePropPageClass (void)
- {
- return ;
- }
- /////////////////////////////////////////////////////////////
- //
- // DoDataExchange
- //
- /////////////////////////////////////////////////////////////
- void
- RingSizePropPageClass::DoDataExchange (CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(RingSizePropPageClass)
- DDX_Control(pDX, IDC_INNER_SIZE_X_SPIN, m_InnerSizeXSpin);
- DDX_Control(pDX, IDC_INNER_SIZE_Y_SPIN, m_InnerSizeYSpin);
- DDX_Control(pDX, IDC_OUTER_SIZE_X_SPIN, m_OuterSizeXSpin);
- DDX_Control(pDX, IDC_OUTER_SIZE_Y_SPIN, m_OuterSizeYSpin);
- //}}AFX_DATA_MAP
- return ;
- }
- BEGIN_MESSAGE_MAP(RingSizePropPageClass, CPropertyPage)
- //{{AFX_MSG_MAP(RingSizePropPageClass)
- ON_WM_DESTROY()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////
- //
- // Initialize
- //
- /////////////////////////////////////////////////////////////
- void
- RingSizePropPageClass::Initialize (void)
- {
- m_InnerScaleChannel.Reset ();
- m_OrigInnerScaleChannel.Reset ();
- m_OuterScaleChannel.Reset ();
- m_OrigOuterScaleChannel.Reset ();
- if (m_RenderObj != NULL) {
- m_InnerSize = m_RenderObj->Get_Inner_Extent ();
- m_OuterSize = m_RenderObj->Get_Outer_Extent ();
- m_InnerScaleChannel = m_RenderObj->Get_Inner_Scale_Channel ();
- m_OrigInnerScaleChannel = m_RenderObj->Get_Inner_Scale_Channel ();
- m_OuterScaleChannel = m_RenderObj->Get_Outer_Scale_Channel ();
- m_OrigOuterScaleChannel = m_RenderObj->Get_Outer_Scale_Channel ();
- if (m_OrigInnerScaleChannel.Get_Key_Count () == 0) {
- m_InnerScaleChannel.Add_Key (m_RenderObj->Get_Inner_Scale (), 0);
- m_OrigInnerScaleChannel.Add_Key (m_RenderObj->Get_Inner_Scale (), 0);
- }
- if (m_OrigOuterScaleChannel.Get_Key_Count () == 0) {
- m_OuterScaleChannel.Add_Key (m_RenderObj->Get_Outer_Scale (), 0);
- m_OrigOuterScaleChannel.Add_Key (m_RenderObj->Get_Outer_Scale (), 0);
- }
- }
- return ;
- }
- /////////////////////////////////////////////////////////////
- //
- // OnInitDialog
- //
- /////////////////////////////////////////////////////////////
- BOOL
- RingSizePropPageClass::OnInitDialog (void)
- {
- // Allow the base class to process this message
- CPropertyPage::OnInitDialog ();
-
- m_InnerScaleXBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_INNER_SCALE_BAR_X));
- m_InnerScaleYBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_INNER_SCALE_BAR_Y));
- m_OuterScaleXBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_OUTER_SCALE_BAR_X));
- m_OuterScaleYBar = ColorBarClass::Get_Color_Bar (::GetDlgItem (m_hWnd, IDC_OUTER_SCALE_BAR_Y));
- //
- // Setup the spinners
- //
- ::Initialize_Spinner (m_InnerSizeXSpin, m_InnerSize.X, 0, 10000);
- ::Initialize_Spinner (m_InnerSizeYSpin, m_InnerSize.Y, 0, 10000);
- ::Initialize_Spinner (m_OuterSizeXSpin, m_OuterSize.X, 0, 10000);
- ::Initialize_Spinner (m_OuterSizeYSpin, m_OuterSize.Y, 0, 10000);
- //
- // Setup the timelines
- //
- m_InnerScaleXBar->Set_Range (0, 1);
- m_InnerScaleYBar->Set_Range (0, 1);
- m_OuterScaleXBar->Set_Range (0, 1);
- m_OuterScaleYBar->Set_Range (0, 1);
- //
- // Insert the starting points
- //
- m_InnerScaleXBar->Modify_Point (0, 0, 0, 0, 0);
- m_InnerScaleYBar->Modify_Point (0, 0, 0, 0, 0);
- m_OuterScaleXBar->Modify_Point (0, 0, 0, 0, 0);
- m_OuterScaleYBar->Modify_Point (0, 0, 0, 0, 0);
- m_InnerScaleXBar->Set_Graph_Percent (0, m_OrigInnerScaleChannel[0].Get_Value ().X);
- m_InnerScaleYBar->Set_Graph_Percent (0, m_OrigInnerScaleChannel[0].Get_Value ().Y);
- m_OuterScaleXBar->Set_Graph_Percent (0, m_OrigOuterScaleChannel[0].Get_Value ().X);
- m_OuterScaleYBar->Set_Graph_Percent (0, m_OrigOuterScaleChannel[0].Get_Value ().Y);
- //
- // Set-up the inner-scale timelines
- //
- int x_index = 1;
- int y_index = 1;
- for (int index = 1; index < m_OrigInnerScaleChannel.Get_Key_Count (); index ++) {
- const LERPAnimationChannelClass<Vector2>::KeyClass &prev_value = m_OrigInnerScaleChannel.Get_Key (index - 1);
- const LERPAnimationChannelClass<Vector2>::KeyClass &curr_value = m_OrigInnerScaleChannel.Get_Key (index);
-
- //
- // Find out which channels are unique (we toss the others)
- //
- bool unique_x = false;
- bool unique_y = false;
- if (index == (m_OrigInnerScaleChannel.Get_Key_Count () - 1)) {
- unique_x = (curr_value.Get_Value ().X != prev_value.Get_Value ().X);
- unique_y = (curr_value.Get_Value ().Y != prev_value.Get_Value ().Y);
- } else {
- const LERPAnimationChannelClass<Vector2>::KeyClass &next_value = m_OrigInnerScaleChannel[index + 1];
- //
- // Check to ensure the X-value isn't just a LERP of the 2 adjacent keys.
- //
- unique_x = (::Is_LERP ( prev_value.Get_Value ().X,
- prev_value.Get_Time (),
- curr_value.Get_Value ().X,
- curr_value.Get_Time (),
- next_value.Get_Value ().X,
- next_value.Get_Time ()) == false);
- //
- // Check to ensure the Y-value isn't just a LERP of the 2 adjacent keys.
- //
- unique_y = (::Is_LERP ( prev_value.Get_Value ().Y,
- prev_value.Get_Time (),
- curr_value.Get_Value ().Y,
- curr_value.Get_Time (),
- next_value.Get_Value ().Y,
- next_value.Get_Time ()) == false);
- }
- //
- // Insert a key for each unique axis
- //
- if (unique_x) {
- m_InnerScaleXBar->Modify_Point (x_index, curr_value.Get_Time (), 0, 0, 0);
- m_InnerScaleXBar->Set_Graph_Percent (x_index, curr_value.Get_Value ().X);
- x_index ++;
- }
- if (unique_y) {
- m_InnerScaleYBar->Modify_Point (y_index, curr_value.Get_Time (), 0, 0, 0);
- m_InnerScaleYBar->Set_Graph_Percent (y_index, curr_value.Get_Value ().Y);
- y_index ++;
- }
- // One of the keys MUST be unique...
- ASSERT (unique_x || unique_y);
- }
- //
- // Set-up the outer-scale timelines
- //
- x_index = 1;
- y_index = 1;
- for (index = 1; index < m_OrigOuterScaleChannel.Get_Key_Count (); index ++) {
- const LERPAnimationChannelClass<Vector2>::KeyClass &prev_value = m_OrigOuterScaleChannel.Get_Key (index - 1);
- const LERPAnimationChannelClass<Vector2>::KeyClass &curr_value = m_OrigOuterScaleChannel.Get_Key (index);
-
- //
- // Find out which channels are unique (we toss the others)
- //
- bool unique_x = false;
- bool unique_y = false;
- if (index == (m_OrigOuterScaleChannel.Get_Key_Count () - 1)) {
- unique_x = (curr_value.Get_Value ().X != prev_value.Get_Value ().X);
- unique_y = (curr_value.Get_Value ().Y != prev_value.Get_Value ().Y);
- } else {
- const LERPAnimationChannelClass<Vector2>::KeyClass &next_value = m_OrigOuterScaleChannel[index + 1];
- //
- // Check to ensure the X-value isn't just a LERP of the 2 adjacent keys.
- //
- unique_x = (::Is_LERP ( prev_value.Get_Value ().X,
- prev_value.Get_Time (),
- curr_value.Get_Value ().X,
- curr_value.Get_Time (),
- next_value.Get_Value ().X,
- next_value.Get_Time ()) == false);
- //
- // Check to ensure the Y-value isn't just a LERP of the 2 adjacent keys.
- //
- unique_y = (::Is_LERP ( prev_value.Get_Value ().Y,
- prev_value.Get_Time (),
- curr_value.Get_Value ().Y,
- curr_value.Get_Time (),
- next_value.Get_Value ().Y,
- next_value.Get_Time ()) == false);
- }
- //
- // Insert a key for each unique axis
- //
- if (unique_x) {
- m_OuterScaleXBar->Modify_Point (x_index, curr_value.Get_Time (), 0, 0, 0);
- m_OuterScaleXBar->Set_Graph_Percent (x_index, curr_value.Get_Value ().X);
- x_index ++;
- }
- if (unique_y) {
- m_OuterScaleYBar->Modify_Point (y_index, curr_value.Get_Time (), 0, 0, 0);
- m_OuterScaleYBar->Set_Graph_Percent (y_index, curr_value.Get_Value ().Y);
- y_index ++;
- }
- // One of the keys MUST be unique...
- ASSERT (unique_x || unique_y);
- }
- //
- // Ensure our initial 'current' values are up-to-date
- //
- Update_Inner_Scale_Array ();
- Update_Outer_Scale_Array ();
- return TRUE;
- }
- /////////////////////////////////////////////////////////////
- //
- // OnApply
- //
- /////////////////////////////////////////////////////////////
- BOOL
- RingSizePropPageClass::OnApply (void)
- {
- // Allow the base class to process this message
- return CPropertyPage::OnApply ();
- }
- /////////////////////////////////////////////////////////////
- //
- // OnDestroy
- //
- /////////////////////////////////////////////////////////////
- void
- RingSizePropPageClass::OnDestroy (void)
- {
- CPropertyPage::OnDestroy();
- return ;
- }
- /////////////////////////////////////////////////////////////
- //
- // OnNotify
- //
- /////////////////////////////////////////////////////////////
- BOOL
- RingSizePropPageClass::OnNotify
- (
- WPARAM wParam,
- LPARAM lParam,
- LRESULT *pResult
- )
- {
- CBR_NMHDR *color_bar_hdr = (CBR_NMHDR *)lParam;
- //
- // Which control sent the notification?
- //
- switch (color_bar_hdr->hdr.idFrom)
- {
- case IDC_INNER_SCALE_BAR_X:
- case IDC_INNER_SCALE_BAR_Y:
- case IDC_OUTER_SCALE_BAR_X:
- case IDC_OUTER_SCALE_BAR_Y:
- {
- //
- // Determine the timeline bar which sent the notification
- //
- ColorBarClass *timeline = NULL;
- if (color_bar_hdr->hdr.idFrom == IDC_INNER_SCALE_BAR_X) {
- timeline = m_InnerScaleXBar;
- } else if (color_bar_hdr->hdr.idFrom == IDC_INNER_SCALE_BAR_Y) {
- timeline = m_InnerScaleYBar;
- } else if (color_bar_hdr->hdr.idFrom == IDC_OUTER_SCALE_BAR_X) {
- timeline = m_OuterScaleXBar;
- } else if (color_bar_hdr->hdr.idFrom == IDC_OUTER_SCALE_BAR_Y) {
- timeline = m_OuterScaleYBar;
- }
- bool update = (color_bar_hdr->hdr.code == CBRN_MOVING_POINT) ||
- (color_bar_hdr->hdr.code == CBRN_DELETED_POINT);
- if (color_bar_hdr->hdr.code == CBRN_DBLCLK_POINT) {
- //
- // Allow the user to edit the keyframe
- //
- float scale = timeline->Get_Graph_Percent (color_bar_hdr->key_index);
- ScaleDialogClass dialog (scale, this);
- if (dialog.DoModal () == IDOK) {
- //
- // Update the timeline
- //
- timeline->Set_Graph_Percent (color_bar_hdr->key_index, dialog.Get_Scale ());
- update = true;
- }
- }
-
- //
- // Update the object
- //
- if (update) {
- if ( color_bar_hdr->hdr.idFrom == IDC_INNER_SCALE_BAR_X ||
- color_bar_hdr->hdr.idFrom == IDC_INNER_SCALE_BAR_Y)
- {
- Update_Inner_Scale_Array ();
- } else if ( color_bar_hdr->hdr.idFrom == IDC_OUTER_SCALE_BAR_X ||
- color_bar_hdr->hdr.idFrom == IDC_OUTER_SCALE_BAR_Y)
- {
- Update_Outer_Scale_Array ();
- }
- SetModified ();
- }
- }
- break;
- case IDC_INNER_SIZE_X_SPIN:
- case IDC_INNER_SIZE_Y_SPIN:
- {
- // Update the object
- m_InnerSize.X = ::GetDlgItemFloat (m_hWnd, IDC_INNER_SIZE_X_EDIT);
- m_InnerSize.Y = ::GetDlgItemFloat (m_hWnd, IDC_INNER_SIZE_Y_EDIT);
- m_RenderObj->Set_Inner_Extent (m_InnerSize);
- SetModified ();
- }
- break;
- case IDC_OUTER_SIZE_X_SPIN:
- case IDC_OUTER_SIZE_Y_SPIN:
- {
- // Update the object
- m_OuterSize.X = ::GetDlgItemFloat (m_hWnd, IDC_OUTER_SIZE_X_EDIT);
- m_OuterSize.Y = ::GetDlgItemFloat (m_hWnd, IDC_OUTER_SIZE_Y_EDIT);
- m_RenderObj->Set_Outer_Extent (m_OuterSize);
- SetModified ();
- }
- break;
- }
-
- return CPropertyPage::OnNotify (wParam, lParam, pResult);
- }
- /////////////////////////////////////////////////////////////
- //
- // OnCommand
- //
- /////////////////////////////////////////////////////////////
- BOOL
- RingSizePropPageClass::OnCommand
- (
- WPARAM wParam,
- LPARAM lParam
- )
- {
- switch (LOWORD (wParam))
- {
- case IDC_INNER_SIZE_X_EDIT:
- case IDC_INNER_SIZE_Y_EDIT:
- {
- // Update the object
- if ((HIWORD (wParam) == EN_KILLFOCUS) &&
- SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY))
- {
- SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
- // Update the object
- m_InnerSize.X = ::GetDlgItemFloat (m_hWnd, IDC_INNER_SIZE_X_EDIT);
- m_InnerSize.Y = ::GetDlgItemFloat (m_hWnd, IDC_INNER_SIZE_Y_EDIT);
- m_RenderObj->Set_Inner_Extent (m_InnerSize);
- SetModified ();
- } else if (HIWORD (wParam) == EN_CHANGE) {
- SetModified ();
- }
- }
- break;
- case IDC_OUTER_SIZE_X_EDIT:
- case IDC_OUTER_SIZE_Y_EDIT:
- {
- // Update the object
- if ((HIWORD (wParam) == EN_KILLFOCUS) &&
- SendDlgItemMessage (LOWORD (wParam), EM_GETMODIFY))
- {
- SendDlgItemMessage (LOWORD (wParam), EM_SETMODIFY, (WPARAM)0);
- // Update the object
- m_OuterSize.X = ::GetDlgItemFloat (m_hWnd, IDC_OUTER_SIZE_X_EDIT);
- m_OuterSize.Y = ::GetDlgItemFloat (m_hWnd, IDC_OUTER_SIZE_Y_EDIT);
- m_RenderObj->Set_Outer_Extent (m_OuterSize);
- SetModified ();
- } else if (HIWORD (wParam) == EN_CHANGE) {
- SetModified ();
- }
- }
- break;
- }
- return CPropertyPage::OnCommand (wParam, lParam);
- }
- /////////////////////////////////////////////////////////////
- //
- // OnCancel
- //
- /////////////////////////////////////////////////////////////
- void
- RingSizePropPageClass::OnCancel (void)
- {
- //
- // Reset the object to its original state
- //
- m_RenderObj->Set_Inner_Scale_Channel (m_OrigInnerScaleChannel);
- m_RenderObj->Set_Outer_Scale_Channel (m_OrigOuterScaleChannel);
- CPropertyPage::OnCancel ();
- return ;
- }
- /////////////////////////////////////////////////////////////
- //
- // Update_Inner_Scale_Array
- //
- /////////////////////////////////////////////////////////////
- void
- RingSizePropPageClass::Update_Inner_Scale_Array (void)
- {
- m_InnerScaleChannel.Reset ();
- float position = 0;
- float red = 0;
- float green = 0;
- float blue = 0;
- //
- // Allocate arrays we can store the 3 separate timelines in
- //
- int max_x = m_InnerScaleXBar->Get_Point_Count ();
- int max_y = m_InnerScaleYBar->Get_Point_Count ();
- LERPAnimationChannelClass<float> x_values;
- LERPAnimationChannelClass<float> y_values;
-
- //
- // Build the X-axis timline
- //
- for (int index = 0; index < max_x; index++) {
- m_InnerScaleXBar->Get_Point (index, &position, &red, &green, &blue);
- x_values.Add_Key (m_InnerScaleXBar->Get_Graph_Percent (index), position);
- }
- //
- // Build the Y-axis timline
- //
- for (index = 0; index < max_y; index++) {
- m_InnerScaleYBar->Get_Point (index, &position, &red, &green, &blue);
- y_values.Add_Key (m_InnerScaleYBar->Get_Graph_Percent (index), position);
- }
- //
- // Combine the 3 separate time lines into one time line
- //
- int x_index = 0;
- int y_index = 0;
- int list_index = 0;
- float x_val = x_values[0].Get_Value ();
- float y_val = y_values[0].Get_Value ();
- while ( x_index < max_x ||
- y_index < max_y)
- {
- //
- // Find the smallest time
- //
- float time = 2.0F;
- float x_time = time;
- float y_time = time;
- if (x_index < max_x) {
- x_time = x_values[x_index].Get_Time ();
- }
- if (y_index < max_y) {
- y_time = y_values[y_index].Get_Time ();
- }
- time = min (x_time, time);
- time = min (y_time, time);
- if (x_time == time) {
- x_index ++;
- }
- if (y_time == time) {
- y_index ++;
- }
- //
- // Evaluate X
- //
- x_val = x_values.Evaluate (time);
- y_val = y_values.Evaluate (time);
- //
- // Add this scalar to the list
- //
- m_InnerScaleChannel.Add_Key (Vector2 (x_val, y_val), time);
- }
- //
- // Update the object
- //
- m_RenderObj->Set_Inner_Scale_Channel (m_InnerScaleChannel);
- m_RenderObj->Restart_Animation ();
- return ;
- }
- /////////////////////////////////////////////////////////////
- //
- // Update_Outer_Scale_Array
- //
- /////////////////////////////////////////////////////////////
- void
- RingSizePropPageClass::Update_Outer_Scale_Array (void)
- {
- m_OuterScaleChannel.Reset ();
- float position = 0;
- float red = 0;
- float green = 0;
- float blue = 0;
- //
- // Allocate arrays we can store the 3 separate timelines in
- //
- int max_x = m_OuterScaleXBar->Get_Point_Count ();
- int max_y = m_OuterScaleYBar->Get_Point_Count ();
- LERPAnimationChannelClass<float> x_values;
- LERPAnimationChannelClass<float> y_values;
-
- //
- // Build the X-axis timline
- //
- for (int index = 0; index < max_x; index++) {
- m_OuterScaleXBar->Get_Point (index, &position, &red, &green, &blue);
- x_values.Add_Key (m_OuterScaleXBar->Get_Graph_Percent (index), position);
- }
- //
- // Build the Y-axis timline
- //
- for (index = 0; index < max_y; index++) {
- m_OuterScaleYBar->Get_Point (index, &position, &red, &green, &blue);
- y_values.Add_Key (m_OuterScaleYBar->Get_Graph_Percent (index), position);
- }
- //
- // Combine the 3 separate time lines into one time line
- //
- int x_index = 0;
- int y_index = 0;
- int list_index = 0;
- float x_val = x_values[0].Get_Value ();
- float y_val = y_values[0].Get_Value ();
- while ( x_index < max_x ||
- y_index < max_y)
- {
- //
- // Find the smallest time
- //
- float time = 2.0F;
- float x_time = time;
- float y_time = time;
- if (x_index < max_x) {
- x_time = x_values[x_index].Get_Time ();
- }
- if (y_index < max_y) {
- y_time = y_values[y_index].Get_Time ();
- }
- time = min (x_time, time);
- time = min (y_time, time);
- if (x_time == time) {
- x_index ++;
- }
- if (y_time == time) {
- y_index ++;
- }
- //
- // Evaluate X
- //
- x_val = x_values.Evaluate (time);
- y_val = y_values.Evaluate (time);
- //
- // Add this scalar to the list
- //
- m_OuterScaleChannel.Add_Key (Vector2 (x_val, y_val), time);
- }
- //
- // Update the object
- //
- m_RenderObj->Set_Outer_Scale_Channel (m_OuterScaleChannel);
- m_RenderObj->Restart_Animation ();
- return ;
- }
- /////////////////////////////////////////////////////////////
- //
- // Is_LERP
- //
- /////////////////////////////////////////////////////////////
- bool
- Is_LERP
- (
- float last_value,
- float last_time,
- float curr_value,
- float curr_time,
- float next_value,
- float next_time
- )
- {
- float percent = (curr_time - last_time) / (next_time - last_time);
- float interpolated_value = last_value + ((next_value-last_value) * percent);
- return bool(WWMath::Fabs (interpolated_value - curr_value) < WWMATH_EPSILON);
- }
|