Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / blend_wnd.cpp
blob1886be84a6144e8e899dcc55d663eddda354bfcb
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "std_afx.h"
18 #include "blend_wnd.h"
19 #include <nel/misc/common.h>
20 #include <nel/3d/animation_playlist.h>
22 using namespace NL3D;
23 using namespace NLMISC;
25 #define COLOR_BLEND_ENABLE (RGB(192, 43, 223))
26 #define COLOR_BLEND_DISABLE (RGB(140, 113, 142))
27 #define SEGMENT_COUNT 10
29 // ***************************************************************************
31 CBlendWnd::CBlendWnd()
35 // ***************************************************************************
37 void CBlendWnd::MakePoint (const RECT& src, POINT& dst, float x, float y)
39 float widthClient=(float)src.right-(float)src.left;
40 float heightClient=(float)src.bottom-(float)src.top;
41 dst.x=src.left+(int)(widthClient*x);
42 dst.y=src.top+(int)(heightClient*y);
45 // ***************************************************************************
47 void CBlendWnd::MakeRect (const RECT& src, RECT& dst, float x, float y, float width, float height)
49 float widthClient=(float)src.right-(float)src.left;
50 float heightClient=(float)src.bottom-(float)src.top;
51 dst.left=src.left+(int)(widthClient*x);
52 dst.top=src.top+(int)(heightClient*y);
53 dst.right=src.left+(int)(widthClient*(x+width));
54 dst.bottom=src.top+(int)(heightClient*(y+height));
57 // ***************************************************************************
59 void CBlendWnd::OnPaint (const RECT& client, CDC* pDc, float StartBlend, float EndBlend, float StartBlendTime, float EndBlendTime,
60 float Smoothness, float StartTime, float EndTime, bool enabled)
62 // Get the good color
63 COLORREF color=(enabled?COLOR_BLEND_ENABLE:COLOR_BLEND_DISABLE);
65 // *** Paint the left rect
67 // Offset start
68 float offsetLeft=(StartBlendTime-StartTime)/(EndTime-StartTime);
69 clamp (offsetLeft, 0, 1);
71 // Fill the background
72 pDc->FillSolidRect(&client, GetSysColor (COLOR_SCROLLBAR));
74 // Make a rect for left
75 RECT left;
76 MakeRect (client, left, 0.f, 1.f-StartBlend, offsetLeft, StartBlend);
77 pDc->FillSolidRect(&left, color);
79 // *** Paint the right rect
81 // Offset start
82 float offsetRight=(EndBlendTime-StartTime)/(EndTime-StartTime);
83 clamp (offsetRight, 0, 1);
85 // Make a rect for left
86 RECT right;
87 MakeRect (client, right, offsetRight, 1.f-EndBlend, 1.f-offsetRight, EndBlend);
88 pDc->FillSolidRect(&right, color);
90 // *** Paint the inter zone
92 // Set pen and brush color
93 CPen myPen (PS_NULL, 0, color);
94 CBrush myBrush (color);
95 CPen* oldPen=NULL;
96 CBrush* oldBrush=NULL;
98 // Then initialize it
99 oldPen=pDc->SelectObject (&myPen);
100 oldBrush=pDc->SelectObject (&myBrush);
102 for (uint i=0; i<SEGMENT_COUNT; i++)
104 // Offset of the polygon
105 float firstOffset=offsetLeft+(float)i*(offsetRight-offsetLeft)/(float)SEGMENT_COUNT;
106 float nextOffset=offsetLeft+(float)(i+1)*(offsetRight-offsetLeft)/(float)SEGMENT_COUNT;
108 // Get time
109 float firstTime=StartBlendTime+(float)i*(EndBlendTime-StartBlendTime)/(float)SEGMENT_COUNT;
110 float nextTime=StartBlendTime+(float)(i+1)*(EndBlendTime-StartBlendTime)/(float)SEGMENT_COUNT;
112 // Get the values
113 float firstValue=CAnimationPlaylist::getWeightValue (StartBlendTime, EndBlendTime, firstTime, StartBlend, EndBlend, Smoothness);
114 float nextValue=CAnimationPlaylist::getWeightValue (StartBlendTime, EndBlendTime, nextTime, StartBlend, EndBlend, Smoothness);
116 // Setup polygon points
117 POINT polygon[4];
118 MakePoint (client, polygon[0], firstOffset, 1.f);
119 MakePoint (client, polygon[1], firstOffset, 1.f-firstValue);
120 MakePoint (client, polygon[2], nextOffset, 1.f-nextValue);
121 MakePoint (client, polygon[3], nextOffset, 1.f);
123 // Draw the polygon
124 pDc->Polygon (polygon, 4);
127 // Draw limit line
128 CPen myBlackPen (PS_SOLID, 1, RGB(0,0,0));
129 pDc->SelectObject (&myBlackPen);
131 POINT p0;
132 POINT p1;
133 //MakePoint (client, p0, offsetLeft, 1.f-StartBlend);
134 MakePoint (client, p0, offsetLeft, 0.f);
135 MakePoint (client, p1, offsetLeft, 1.f);
136 pDc->MoveTo (p0);
137 pDc->LineTo (p1);
138 //MakePoint (client, p0, offsetRight, 1.f-EndBlend);
139 MakePoint (client, p0, offsetRight, 0.f);
140 MakePoint (client, p1, offsetRight, 1.f);
141 pDc->MoveTo (p0);
142 pDc->LineTo (p1);
144 // Make frame
145 pDc->MoveTo (client.left, client.top);
146 pDc->LineTo (client.right, client.top);
147 pDc->LineTo (client.right, client.bottom);
148 pDc->LineTo (client.left, client.bottom);
149 pDc->LineTo (client.left, client.top);
151 // Then reselect old object
152 pDc->SelectObject (oldPen);
153 pDc->SelectObject (oldBrush);
156 // ***************************************************************************