| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
#include "stdafx.h" |
|---|
| 29 |
#include <gtk/gtk.h> |
|---|
| 30 |
#include <GL/gl.h> |
|---|
| 31 |
|
|---|
| 32 |
extern void DrawPathLines(); |
|---|
| 33 |
extern void Select_ShiftTexture(int x, int y); |
|---|
| 34 |
extern void Select_RotateTexture(int amt); |
|---|
| 35 |
extern void DrawAlternatePoint(vec3_t v, float scale); |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
extern int g_nPatchClickedView; |
|---|
| 39 |
|
|---|
| 40 |
brush_t* g_pSplitList = NULL; |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
CamWnd::CamWnd () |
|---|
| 46 |
: GLWindow (TRUE), m_XORRectangle(m_pWidget) |
|---|
| 47 |
{ |
|---|
| 48 |
m_nNumTransBrushes = 0; |
|---|
| 49 |
memset(&m_Camera, 0, sizeof(camera_t)); |
|---|
| 50 |
m_pSide_select = NULL; |
|---|
| 51 |
m_bClipMode = false; |
|---|
| 52 |
m_bFreeMove = false; |
|---|
| 53 |
Cam_Init(); |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
CamWnd::~CamWnd () |
|---|
| 57 |
{ |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
void CamWnd::OnCreate () |
|---|
| 61 |
{ |
|---|
| 62 |
if (!MakeCurrent ()) |
|---|
| 63 |
Error ("glMakeCurrent failed"); |
|---|
| 64 |
|
|---|
| 65 |
gtk_glwidget_create_font (m_pWidget); |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
Sys_Printf ("GL_VENDOR: %s\n", qglGetString (GL_VENDOR)); |
|---|
| 69 |
Sys_Printf ("GL_RENDERER: %s\n", qglGetString (GL_RENDERER)); |
|---|
| 70 |
Sys_Printf ("GL_VERSION: %s\n", qglGetString (GL_VERSION)); |
|---|
| 71 |
Sys_Printf ("GL_EXTENSIONS: %s\n", qglGetString (GL_EXTENSIONS)); |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
g_qeglobals.bTextureCompressionSupported = 0; |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
if (Sys_QGL_ExtensionSupported ("GL_ARB_texture_compression")) |
|---|
| 90 |
{ |
|---|
| 91 |
g_qeglobals.bTextureCompressionSupported = 1; |
|---|
| 92 |
g_qeglobals.m_bOpenGLCompressionSupported = 1; |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
if (Sys_QGL_ExtensionSupported ("GL_EXT_texture_compression_s3tc")) |
|---|
| 99 |
{ |
|---|
| 100 |
g_qeglobals.bTextureCompressionSupported = 1; |
|---|
| 101 |
g_qeglobals.m_bS3CompressionSupported = 1; |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
g_qeglobals.m_bOpenGLReady = true; |
|---|
| 105 |
|
|---|
| 106 |
g_PrefsDlg.UpdateTextureCompression(); |
|---|
| 107 |
|
|---|
| 108 |
#ifdef ATIHACK_812 |
|---|
| 109 |
g_PrefsDlg.UpdateATIHack(); |
|---|
| 110 |
#endif |
|---|
| 111 |
|
|---|
| 112 |
g_qeglobals_gui.d_camera = m_pWidget; |
|---|
| 113 |
} |
|---|
| 114 |
|
|---|
| 115 |
void CamWnd::Cam_Init () |
|---|
| 116 |
{ |
|---|
| 117 |
m_Camera.timing = false; |
|---|
| 118 |
m_Camera.origin[0] = 0.f; |
|---|
| 119 |
m_Camera.origin[1] = 20.f; |
|---|
| 120 |
m_Camera.origin[2] = 46.f; |
|---|
| 121 |
m_Camera.color[0] = 0.3f; |
|---|
| 122 |
m_Camera.color[1] = 0.3f; |
|---|
| 123 |
m_Camera.color[2] = 0.3f; |
|---|
| 124 |
m_nCambuttonstate = 0; |
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
void CamWnd::OnSize(int cx, int cy) |
|---|
| 128 |
{ |
|---|
| 129 |
m_Camera.width = cx; |
|---|
| 130 |
m_Camera.height = cy; |
|---|
| 131 |
gtk_widget_queue_draw(m_pWidget); |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
rectangle_t rectangle_from_area_cam() |
|---|
| 135 |
{ |
|---|
| 136 |
const float left = MIN(g_qeglobals.d_vAreaTL[0], g_qeglobals.d_vAreaBR[0]); |
|---|
| 137 |
const float top = MAX(g_qeglobals.d_vAreaTL[1], g_qeglobals.d_vAreaBR[1]); |
|---|
| 138 |
const float right = MAX(g_qeglobals.d_vAreaTL[0], g_qeglobals.d_vAreaBR[0]); |
|---|
| 139 |
const float bottom = MIN(g_qeglobals.d_vAreaTL[1], g_qeglobals.d_vAreaBR[1]); |
|---|
| 140 |
return rectangle_t(left, bottom, right - left, top - bottom); |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
void update_xor_rectangle(XORRectangle& xor_rectangle) |
|---|
| 144 |
{ |
|---|
| 145 |
rectangle_t rectangle; |
|---|
| 146 |
if ((g_qeglobals.d_select_mode == sel_area)) |
|---|
| 147 |
rectangle = rectangle_from_area_cam(); |
|---|
| 148 |
xor_rectangle.set(rectangle); |
|---|
| 149 |
} |
|---|
| 150 |
|
|---|
| 151 |
void CamWnd::OnMouseMove(guint32 flags, int pointx, int pointy) |
|---|
| 152 |
{ |
|---|
| 153 |
int height = m_pWidget->allocation.height; |
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
if (HasCapture () && Sys_AltDown () && |
|---|
| 159 |
!((flags & MK_SHIFT) || (flags & MK_CONTROL))) |
|---|
| 160 |
{ |
|---|
| 161 |
if (flags & MK_CONTROL) |
|---|
| 162 |
Select_RotateTexture(pointy - m_ptLastCursorY); |
|---|
| 163 |
else |
|---|
| 164 |
if (flags & MK_SHIFT) |
|---|
| 165 |
Select_ScaleTexture(pointx - m_ptLastCursorX, m_ptLastCursorY - pointy); |
|---|
| 166 |
else |
|---|
| 167 |
Select_ShiftTexture(pointx - m_ptLastCursorX, m_ptLastCursorY - pointy); |
|---|
| 168 |
} |
|---|
| 169 |
else |
|---|
| 170 |
{ |
|---|
| 171 |
Cam_MouseMoved(pointx, height - 1 - pointy, flags); |
|---|
| 172 |
} |
|---|
| 173 |
m_ptLastCursorX = pointx; |
|---|
| 174 |
m_ptLastCursorY = pointy; |
|---|
| 175 |
|
|---|
| 176 |
update_xor_rectangle(m_XORRectangle); |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
void CamWnd::OnMouseWheel(bool bUp) |
|---|
| 180 |
{ |
|---|
| 181 |
if (bUp) |
|---|
| 182 |
VectorMA (m_Camera.origin, g_PrefsDlg.m_nMoveSpeed, m_Camera.forward, m_Camera.origin); |
|---|
| 183 |
else |
|---|
| 184 |
VectorMA (m_Camera.origin, -g_PrefsDlg.m_nMoveSpeed, m_Camera.forward, m_Camera.origin); |
|---|
| 185 |
|
|---|
| 186 |
int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); |
|---|
| 187 |
Sys_UpdateWindows (nUpdate); |
|---|
| 188 |
g_pParentWnd->OnTimer (); |
|---|
| 189 |
} |
|---|
| 190 |
|
|---|
| 191 |
void CamWnd::OnLButtonDown(guint32 nFlags, int pointx, int pointy) |
|---|
| 192 |
{ |
|---|
| 193 |
m_ptLastCursorX = pointx; |
|---|
| 194 |
m_ptLastCursorY = pointy; |
|---|
| 195 |
OriginalMouseDown(nFlags, pointx, pointy); |
|---|
| 196 |
} |
|---|
| 197 |
|
|---|
| 198 |
void CamWnd::OnLButtonUp(guint32 nFlags, int pointx, int pointy) |
|---|
| 199 |
{ |
|---|
| 200 |
OriginalMouseUp(nFlags, pointx, pointy); |
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
void CamWnd::OnMButtonDown(guint32 nFlags, int pointx, int pointy) |
|---|
| 204 |
{ |
|---|
| 205 |
OriginalMouseDown(nFlags, pointx, pointy); |
|---|
| 206 |
} |
|---|
| 207 |
|
|---|
| 208 |
void CamWnd::OnMButtonUp(guint32 nFlags, int pointx, int pointy) |
|---|
| 209 |
{ |
|---|
| 210 |
OriginalMouseUp(nFlags, pointx, pointy); |
|---|
| 211 |
} |
|---|
| 212 |
|
|---|
| 213 |
void CamWnd::OnRButtonDown(guint32 nFlags, int pointx, int pointy) |
|---|
| 214 |
{ |
|---|
| 215 |
OriginalMouseDown(nFlags, pointx, pointy); |
|---|
| 216 |
} |
|---|
| 217 |
|
|---|
| 218 |
void CamWnd::OnRButtonUp(guint32 nFlags, int pointx, int pointy) |
|---|
| 219 |
{ |
|---|
| 220 |
OriginalMouseUp(nFlags, pointx, pointy); |
|---|
| 221 |
} |
|---|
| 222 |
|
|---|
| 223 |
void CamWnd::OriginalMouseUp(guint32 nFlags, int pointx, int pointy) |
|---|
| 224 |
{ |
|---|
| 225 |
int height = m_pWidget->allocation.height; |
|---|
| 226 |
|
|---|
| 227 |
if(g_qeglobals.d_select_mode == sel_facets_on || g_qeglobals.d_select_mode == sel_facets_off) |
|---|
| 228 |
{ |
|---|
| 229 |
g_qeglobals.d_select_mode = sel_brush; |
|---|
| 230 |
} |
|---|
| 231 |
|
|---|
| 232 |
Cam_MouseUp(pointx, height - 1 - pointy, nFlags); |
|---|
| 233 |
ReleaseCapture (); |
|---|
| 234 |
|
|---|
| 235 |
update_xor_rectangle(m_XORRectangle); |
|---|
| 236 |
} |
|---|
| 237 |
|
|---|
| 238 |
void CamWnd::OriginalMouseDown(guint32 nFlags, int pointx, int pointy) |
|---|
| 239 |
{ |
|---|
| 240 |
int height = m_pWidget->allocation.height; |
|---|
| 241 |
|
|---|
| 242 |
SetFocus(); |
|---|
| 243 |
SetCapture(); |
|---|
| 244 |
Cam_MouseDown (pointx, height - 1 - pointy, nFlags); |
|---|
| 245 |
|
|---|
| 246 |
update_xor_rectangle(m_XORRectangle); |
|---|
| 247 |
} |
|---|
| 248 |
|
|---|
| 249 |
void CamWnd::Cam_BuildMatrix() |
|---|
| 250 |
{ |
|---|
| 251 |
float ya; |
|---|
| 252 |
float matrix[4][4]; |
|---|
| 253 |
int i; |
|---|
| 254 |
|
|---|
| 255 |
if (!m_bFreeMove) |
|---|
| 256 |
{ |
|---|
| 257 |
ya = m_Camera.angles[1]/180*Q_PI; |
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 |
m_Camera.forward[0] = cos(ya); |
|---|
| 261 |
m_Camera.forward[1] = sin(ya); |
|---|
| 262 |
m_Camera.forward[2] = 0; |
|---|
| 263 |
m_Camera.right[0] = m_Camera.forward[1]; |
|---|
| 264 |
m_Camera.right[1] = -m_Camera.forward[0]; |
|---|
| 265 |
} |
|---|
| 266 |
else |
|---|
| 267 |
{ |
|---|
| 268 |
AngleVectors( m_Camera.angles, m_Camera.forward, m_Camera.right, NULL ); |
|---|
| 269 |
m_Camera.forward[2] = -m_Camera.forward[2]; |
|---|
| 270 |
} |
|---|
| 271 |
|
|---|
| 272 |
memcpy(matrix, m_Camera.projection, sizeof(m4x4_t)); |
|---|
| 273 |
m4x4_multiply_by_m4x4(&matrix[0][0], &m_Camera.modelview[0][0]); |
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
for (i=0 ; i<3 ; i++) |
|---|
| 278 |
{ |
|---|
| 279 |
m_Camera.vright[i] = matrix[i][0]; |
|---|
| 280 |
m_Camera.vup[i] = matrix[i][1]; |
|---|
| 281 |
m_Camera.vpn[i] = matrix[i][2]; |
|---|
| 282 |
} |
|---|
| 283 |
|
|---|
| 284 |
VectorNormalize (m_Camera.vright, m_Camera.vright); |
|---|
| 285 |
VectorNormalize (m_Camera.vup, m_Camera.vup); |
|---|
| 286 |
VectorNormalize (m_Camera.vpn, m_Camera.vpn); |
|---|
| 287 |
} |
|---|
| 288 |
|
|---|
| 289 |
void CamWnd::Cam_ChangeFloor (qboolean up) |
|---|
| 290 |
{ |
|---|
| 291 |
brush_t *b; |
|---|
| 292 |
float d, bestd, current; |
|---|
| 293 |
vec3_t start, dir; |
|---|
| 294 |
|
|---|
| 295 |
start[0] = m_Camera.origin[0]; |
|---|
| 296 |
start[1] = m_Camera.origin[1]; |
|---|
| 297 |
start[2] = g_MaxWorldCoord; |
|---|
| 298 |
dir[0] = dir[1] = 0; |
|---|
| 299 |
dir[2] = -1; |
|---|
| 300 |
|
|---|
| 301 |
current = g_MaxWorldCoord - (m_Camera.origin[2] - 48); |
|---|
| 302 |
if (up) |
|---|
| 303 |
bestd = 0; |
|---|
| 304 |
else |
|---|
| 305 |
bestd = 2*g_MaxWorldCoord; |
|---|
| 306 |
|
|---|
| 307 |
for (b=active_brushes.next ; b != &active_brushes ; b=b->next) |
|---|
| 308 |
{ |
|---|
| 309 |
if (!Brush_Ray (start, dir, b, &d)) |
|---|
| 310 |
continue; |
|---|
| 311 |
if (up && d < current && d > bestd) |
|---|
| 312 |
bestd = d; |
|---|
| 313 |
if (!up && d > current && d < bestd) |
|---|
| 314 |
bestd = d; |
|---|
| 315 |
} |
|---|
| 316 |
|
|---|
| 317 |
if (bestd == 0 || bestd == 2*g_MaxWorldCoord) |
|---|
| 318 |
return; |
|---|
| 319 |
|
|---|
| 320 |
m_Camera.origin[2] += current - bestd; |
|---|
| 321 |
Sys_UpdateWindows (W_CAMERA|W_Z_OVERLAY); |
|---|
| 322 |
} |
|---|
| 323 |
|
|---|
| 324 |
void CamWnd::Cam_PositionDrag() |
|---|
| 325 |
{ |
|---|
| 326 |
int x, y; |
|---|
| 327 |
|
|---|
| 328 |
Sys_GetCursorPos (&x, &y); |
|---|
| 329 |
if (x != m_ptCursorX || y != m_ptCursorY) |
|---|
| 330 |
{ |
|---|
| 331 |
x -= m_ptCursorX; |
|---|
| 332 |
VectorMA (m_Camera.origin, x, m_Camera.vright, m_Camera.origin); |
|---|
| 333 |
y -= m_ptCursorY; |
|---|
| 334 |
m_Camera.origin[2] -= y; |
|---|
| 335 |
Sys_SetCursorPos(m_ptCursorX, m_ptCursorY); |
|---|
| 336 |
Sys_UpdateWindows (W_CAMERA | W_XY_OVERLAY); |
|---|
| 337 |
} |
|---|
| 338 |
} |
|---|
| 339 |
|
|---|
| 340 |
void CamWnd::Cam_MouseControl (float dtime) |
|---|
| 341 |
{ |
|---|
| 342 |
Cam_KeyControl (dtime); |
|---|
| 343 |
|
|---|
| 344 |
if( g_PrefsDlg.m_bCamFreeLook ) |
|---|
| 345 |
{ |
|---|
| 346 |
int dx, dy; |
|---|
| 347 |
gint x, y; |
|---|
| 348 |
|
|---|
| 349 |
if( !m_bFreeMove || m_nCambuttonstate == MK_CONTROL ) |
|---|
| 350 |
return; |
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 |
Sys_GetCursorPos(&m_ptCursorX, &m_ptCursorY); |
|---|
| 354 |
|
|---|
| 355 |
dx = m_ptLastCamCursorX - m_ptCursorX; |
|---|
| 356 |
dy = m_ptLastCamCursorY - m_ptCursorY; |
|---|
| 357 |
|
|---|
| 358 |
gdk_window_get_origin( m_pWidget->window, &x, &y); |
|---|
| 359 |
|
|---|
| 360 |
m_ptLastCamCursorX = x + (m_Camera.width / 2); |
|---|
| 361 |
m_ptLastCamCursorY = y + (m_Camera.height / 2); |
|---|
| 362 |
|
|---|
| 363 |
Sys_SetCursorPos(m_ptLastCamCursorX, m_ptLastCamCursorY); |
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 |
if(!g_PrefsDlg.m_bCamFreeLookStrafe) { |
|---|
| 367 |
if (g_PrefsDlg.m_bCamInverseMouse) |
|---|
| 368 |
m_Camera.angles[PITCH] -= dy * dtime * g_PrefsDlg.m_nAngleSpeed; |
|---|
| 369 |
else |
|---|
| 370 |
m_Camera.angles[PITCH] += dy * dtime * g_PrefsDlg.m_nAngleSpeed; |
|---|
| 371 |
} else { |
|---|
| 372 |
VectorMA (m_Camera.origin, dy * (float) (g_PrefsDlg.m_nMoveSpeed / 6.0f), m_Camera.forward, m_Camera.origin); |
|---|
| 373 |
} |
|---|
| 374 |
|
|---|
| 375 |
m_Camera.angles[YAW] += dx * dtime * g_PrefsDlg.m_nAngleSpeed; |
|---|
| 376 |
|
|---|
| 377 |
if (m_Camera.angles[PITCH] > 90) |
|---|
| 378 |
m_Camera.angles[PITCH] = 90; |
|---|
| 379 |
else if (m_Camera.angles[PITCH] < -90) |
|---|
| 380 |
m_Camera.angles[PITCH] = -90; |
|---|
| 381 |
|
|---|
| 382 |
if (m_Camera.angles[YAW] >= 360) |
|---|
| 383 |
m_Camera.angles[YAW] = 0; |
|---|
| 384 |
else if (m_Camera.angles[YAW] <= -360) |
|---|
| 385 |
m_Camera.angles[YAW] = 0; |
|---|
| 386 |
|
|---|
| 387 |
if( dx || dy || m_Camera.movementflags ) |
|---|
| 388 |
{ |
|---|
| 389 |
int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); |
|---|
| 390 |
Sys_UpdateWindows (nUpdate); |
|---|
| 391 |
g_pParentWnd->OnTimer (); |
|---|
| 392 |
} |
|---|
| 393 |
} |
|---|
| 394 |
else |
|---|
| 395 |
{ |
|---|
| 396 |
int xl, xh; |
|---|
| 397 |
int yl, yh; |
|---|
| 398 |
float xf, yf; |
|---|
| 399 |
|
|---|
| 400 |
if (g_PrefsDlg.m_nMouseButtons == 2) |
|---|
| 401 |
{ |
|---|
| 402 |
if (m_nCambuttonstate != (MK_RBUTTON | MK_SHIFT)) |
|---|
| 403 |
return; |
|---|
| 404 |
} |
|---|
| 405 |
else |
|---|
| 406 |
{ |
|---|
| 407 |
if (m_nCambuttonstate != MK_RBUTTON) |
|---|
| 408 |
return; |
|---|
| 409 |
} |
|---|
| 410 |
|
|---|
| 411 |
xf = (float)(m_ptButtonX - m_Camera.width/2) / (m_Camera.width/2); |
|---|
| 412 |
yf = (float)(m_ptButtonY - m_Camera.height/2) / (m_Camera.height/2); |
|---|
| 413 |
|
|---|
| 414 |
xl = m_Camera.width/3; |
|---|
| 415 |
xh = xl*2; |
|---|
| 416 |
yl = m_Camera.height/3; |
|---|
| 417 |
yh = yl*2; |
|---|
| 418 |
|
|---|
| 419 |
xf *= 1.0 - fabs(yf); |
|---|
| 420 |
if (xf < 0) |
|---|
| 421 |
{ |
|---|
| 422 |
xf += 0.1f; |
|---|
| 423 |
if (xf > 0) |
|---|
| 424 |
xf = 0; |
|---|
| 425 |
} |
|---|
| 426 |
else |
|---|
| 427 |
{ |
|---|
| 428 |
xf -= 0.1f; |
|---|
| 429 |
if (xf < 0) |
|---|
| 430 |
xf = 0; |
|---|
| 431 |
} |
|---|
| 432 |
|
|---|
| 433 |
VectorMA (m_Camera.origin, yf*dtime*g_PrefsDlg.m_nMoveSpeed, m_Camera.forward, m_Camera.origin); |
|---|
| 434 |
m_Camera.angles[YAW] += xf*-dtime*g_PrefsDlg.m_nAngleSpeed; |
|---|
| 435 |
|
|---|
| 436 |
int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); |
|---|
| 437 |
Sys_UpdateWindows (nUpdate); |
|---|
| 438 |
g_pParentWnd->OnTimer (); |
|---|
| 439 |
} |
|---|
| 440 |
} |
|---|
| 441 |
|
|---|
| 442 |
void CamWnd::Cam_KeyControl (float dtime) { |
|---|
| 443 |
|
|---|
| 444 |
|
|---|
| 445 |
if (m_Camera.movementflags & MOVE_ROTLEFT) |
|---|
| 446 |
m_Camera.angles[YAW] += 15*dtime*g_PrefsDlg.m_nAngleSpeed; |
|---|
| 447 |
if (m_Camera.movementflags & MOVE_ROTRIGHT) |
|---|
| 448 |
m_Camera.angles[YAW] -= 15*dtime*g_PrefsDlg.m_nAngleSpeed; |
|---|
| 449 |
|
|---|
| 450 |
|
|---|
| 451 |
if (m_Camera.movementflags & MOVE_FORWARD) |
|---|
| 452 |
VectorMA (m_Camera.origin, dtime*g_PrefsDlg.m_nMoveSpeed, m_Camera.forward, m_Camera.origin); |
|---|
| 453 |
if (m_Camera.movementflags & MOVE_BACK) |
|---|
| 454 |
VectorMA (m_Camera.origin, -dtime*g_PrefsDlg.m_nMoveSpeed, m_Camera.forward, m_Camera.origin); |
|---|
| 455 |
if (m_Camera.movementflags & MOVE_STRAFELEFT) |
|---|
| 456 |
VectorMA (m_Camera.origin, -dtime*g_PrefsDlg.m_nMoveSpeed, m_Camera.right, m_Camera.origin); |
|---|
| 457 |
if (m_Camera.movementflags & MOVE_STRAFERIGHT) |
|---|
| 458 |
VectorMA (m_Camera.origin, dtime*g_PrefsDlg.m_nMoveSpeed, m_Camera.right, m_Camera.origin); |
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
if( !m_bFreeMove && m_Camera.movementflags ) |
|---|
| 462 |
{ |
|---|
| 463 |
int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); |
|---|
| 464 |
Sys_UpdateWindows (nUpdate); |
|---|
| 465 |
g_pParentWnd->OnTimer (); |
|---|
| 466 |
} |
|---|
| 467 |
} |
|---|
| 468 |
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 |
static gint camwindow_focusout(GtkWidget* widget, GdkEventKey* event, gpointer data) |
|---|
| 472 |
{ |
|---|
| 473 |
g_pParentWnd->GetCamWnd ()->ToggleFreeMove(); |
|---|
| 474 |
return FALSE; |
|---|
| 475 |
} |
|---|
| 476 |
|
|---|
| 477 |
void CamWnd::ToggleFreeMove() |
|---|
| 478 |
{ |
|---|
| 479 |
GdkWindow *window; |
|---|
| 480 |
GtkWidget *widget; |
|---|
| 481 |
|
|---|
| 482 |
m_bFreeMove = !m_bFreeMove; |
|---|
| 483 |
Camera()->movementflags = 0; |
|---|
| 484 |
m_ptLastCamCursorX = m_ptCursorX; |
|---|
| 485 |
m_ptLastCamCursorY = m_ptCursorY; |
|---|
| 486 |
|
|---|
| 487 |
if (g_pParentWnd->CurrentStyle() == MainFrame::eFloating) |
|---|
| 488 |
{ |
|---|
| 489 |
widget = g_pParentWnd->GetCamWnd ()->m_pParent; |
|---|
| 490 |
window = widget->window; |
|---|
| 491 |
} |
|---|
| 492 |
else |
|---|
| 493 |
{ |
|---|
| 494 |
widget = g_pParentWnd->m_pWidget; |
|---|
| 495 |
window = widget->window; |
|---|
| 496 |
} |
|---|
| 497 |
|
|---|
| 498 |
if (m_bFreeMove) |
|---|
| 499 |
{ |
|---|
| 500 |
|
|---|
| 501 |
SetFocus(); |
|---|
| 502 |
SetCapture(); |
|---|
| 503 |
|
|---|
| 504 |
{ |
|---|
| 505 |
GdkPixmap *pixmap; |
|---|
| 506 |
GdkBitmap *mask; |
|---|
| 507 |
char buffer [(32 * 32)/8]; |
|---|
| 508 |
memset (buffer, 0, (32 * 32)/8); |
|---|
| 509 |
GdkColor white = {0, 0xffff, 0xffff, 0xffff}; |
|---|
| 510 |
GdkColor black = {0, 0x0000, 0x0000, 0x0000}; |
|---|
| 511 |
pixmap = gdk_bitmap_create_from_data (NULL, buffer, 32, 32); |
|---|
| 512 |
mask = gdk_bitmap_create_from_data (NULL, buffer, 32, 32); |
|---|
| 513 |
GdkCursor *cursor = gdk_cursor_new_from_pixmap (pixmap, mask, &white, &black, 1, 1); |
|---|
| 514 |
|
|---|
| 515 |
gdk_window_set_cursor (window, cursor); |
|---|
| 516 |
gdk_cursor_unref (cursor); |
|---|
| 517 |
gdk_drawable_unref (pixmap); |
|---|
| 518 |
gdk_drawable_unref (mask); |
|---|
| 519 |
} |
|---|
| 520 |
|
|---|
| 521 |
|
|---|
| 522 |
|
|---|
| 523 |
|
|---|
| 524 |
m_FocusOutHandler_id = gtk_signal_connect (GTK_OBJECT (widget), "focus_out_event", |
|---|
| 525 |
GTK_SIGNAL_FUNC (camwindow_focusout), g_pParentWnd); |
|---|
| 526 |
|
|---|
| 527 |
{ |
|---|
| 528 |
GdkEventMask mask = (GdkEventMask)(GDK_POINTER_MOTION_MASK |
|---|
| 529 |
| GDK_POINTER_MOTION_HINT_MASK |
|---|
| 530 |
| GDK_BUTTON_MOTION_MASK |
|---|
| 531 |
| GDK_BUTTON1_MOTION_MASK |
|---|
| 532 |
| GDK_BUTTON2_MOTION_MASK |
|---|
| 533 |
| GDK_BUTTON3_MOTION_MASK |
|---|
| 534 |
| GDK_BUTTON_PRESS_MASK |
|---|
| 535 |
| GDK_BUTTON_RELEASE_MASK); |
|---|
| 536 |
|
|---|
| 537 |
gdk_pointer_grab(widget->window, TRUE, mask, widget->window, NULL, GDK_CURRENT_TIME); |
|---|
| 538 |
} |
|---|
| 539 |
} |
|---|
| 540 |
else |
|---|
| 541 |
{ |
|---|
| 542 |
gdk_pointer_ungrab(GDK_CURRENT_TIME); |
|---|
| 543 |
|
|---|
| 544 |
gtk_signal_disconnect (GTK_OBJECT (widget), m_FocusOutHandler_id); |
|---|
| 545 |
|
|---|
| 546 |
GdkCursor *cursor = gdk_cursor_new (GDK_LEFT_PTR); |
|---|
| 547 |
gdk_window_set_cursor (window, cursor); |
|---|
| 548 |
gdk_cursor_unref (cursor); |
|---|
| 549 |
|
|---|
| 550 |
ReleaseCapture(); |
|---|
| 551 |
} |
|---|
| 552 |
|
|---|
| 553 |
int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); |
|---|
| 554 |
Sys_UpdateWindows (nUpdate); |
|---|
| 555 |
g_pParentWnd->OnTimer (); |
|---|
| 556 |
} |
|---|
| 557 |
|
|---|
| 558 |
void CamWnd::Cam_MouseDown(int x, int y, int buttons) |
|---|
| 559 |
{ |
|---|
| 560 |
vec3_t dir; |
|---|
| 561 |
float f, r, u; |
|---|
| 562 |
int i; |
|---|
| 563 |
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
u = (float)( y - ( m_Camera.height * .5f ) ) / ( m_Camera.width * .5f ); |
|---|
| 569 |
r = (float)( x - ( m_Camera.width * .5f ) ) / ( m_Camera.width * .5f ); |
|---|
| 570 |
f = 1; |
|---|
| 571 |
|
|---|
| 572 |
for (i=0 ; i<3 ; i++) |
|---|
| 573 |
dir[i] = m_Camera.vpn[i] * f + m_Camera.vright[i] * r + m_Camera.vup[i] * u; |
|---|
| 574 |
VectorNormalize (dir, dir); |
|---|
| 575 |
|
|---|
| 576 |
Sys_GetCursorPos(&m_ptCursorX, &m_ptCursorY); |
|---|
| 577 |
|
|---|
| 578 |
m_nCambuttonstate = buttons; |
|---|
| 579 |
m_ptButtonX = x; |
|---|
| 580 |
m_ptButtonY = y; |
|---|
| 581 |
|
|---|
| 582 |
|
|---|
| 583 |
|
|---|
| 584 |
|
|---|
| 585 |
|
|---|
| 586 |
|
|---|
| 587 |
int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON; |
|---|
| 588 |
if ((buttons == MK_LBUTTON) |
|---|
| 589 |
|| (buttons == (MK_LBUTTON | MK_SHIFT)) |
|---|
| 590 |
|| (buttons == (MK_LBUTTON | MK_CONTROL)) |
|---|
| 591 |
|| (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT)) |
|---|
| 592 |
|| (buttons == nMouseButton) |
|---|
| 593 |
|| (buttons == (nMouseButton|MK_SHIFT)) |
|---|
| 594 |
|| (buttons == (nMouseButton|MK_CONTROL)) |
|---|
| 595 |
|| (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL))) |
|---|
| 596 |
{ |
|---|
| 597 |
if (g_PrefsDlg.m_nMouseButtons == 2 && (buttons == (MK_RBUTTON | MK_SHIFT))) |
|---|
| 598 |
{ |
|---|
| 599 |
if (g_PrefsDlg.m_bCamFreeLook) |
|---|
| 600 |
ToggleFreeMove(); |
|---|
| 601 |
else |
|---|
| 602 |
Cam_MouseControl (0.1f); |
|---|
| 603 |
} |
|---|
| 604 |
else |
|---|
| 605 |
{ |
|---|
| 606 |
|
|---|
| 607 |
Patch_SetView(W_CAMERA); |
|---|
| 608 |
Drag_Begin (x, y, buttons, m_Camera.vright, m_Camera.vup, m_Camera.origin, dir, true); |
|---|
| 609 |
} |
|---|
| 610 |
return; |
|---|
| 611 |
} |
|---|
| 612 |
|
|---|
| 613 |
if (buttons == MK_RBUTTON) |
|---|
| 614 |
{ |
|---|
| 615 |
if (g_PrefsDlg.m_bCamFreeLook) |
|---|
| 616 |
ToggleFreeMove(); |
|---|
| 617 |
else |
|---|
| 618 |
Cam_MouseControl (0.1f); |
|---|
| 619 |
return; |
|---|
| 620 |
} |
|---|
| 621 |
} |
|---|
| 622 |
|
|---|
| 623 |
void CamWnd::Cam_MouseUp (int x, int y, int buttons) |
|---|
| 624 |
{ |
|---|
| 625 |
m_nCambuttonstate = 0; |
|---|
| 626 |
Drag_MouseUp (buttons); |
|---|
| 627 |
} |
|---|
| 628 |
|
|---|
| 629 |
void CamWnd::Cam_MouseMoved (int x, int y, int buttons) |
|---|
| 630 |
{ |
|---|
| 631 |
m_nCambuttonstate = buttons; |
|---|
| 632 |
if (!buttons) |
|---|
| 633 |
return; |
|---|
| 634 |
|
|---|
| 635 |
if( g_PrefsDlg.m_nCamDragMultiSelect ) |
|---|
| 636 |
{ |
|---|
| 637 |
if (g_qeglobals.d_select_mode == sel_brush_on || g_qeglobals.d_select_mode == sel_brush_off) |
|---|
| 638 |
{ |
|---|
| 639 |
bool bDoDragMultiSelect = FALSE; |
|---|
| 640 |
|
|---|
| 641 |
if( g_PrefsDlg.m_nCamDragMultiSelect == 1 && buttons == (MK_LBUTTON|MK_SHIFT) ) |
|---|
| 642 |
bDoDragMultiSelect = TRUE; |
|---|
| 643 |
else if( g_PrefsDlg.m_nCamDragMultiSelect == 2 && buttons == (MK_LBUTTON|MK_CONTROL) && Sys_AltDown() ) |
|---|
| 644 |
bDoDragMultiSelect = TRUE; |
|---|
| 645 |
|
|---|
| 646 |
if( bDoDragMultiSelect ) |
|---|
| 647 |
{ |
|---|
| 648 |
vec3_t dir; |
|---|
| 649 |
float f, r, u; |
|---|
| 650 |
int i; |
|---|
| 651 |
|
|---|
| 652 |
|
|---|
| 653 |
|
|---|
| 654 |
|
|---|
| 655 |
u = (float)( y - ( m_Camera.height * .5f ) ) / ( m_Camera.width * .5f ); |
|---|
| 656 |
r = (float)( x - ( m_Camera.width * .5f ) ) / ( m_Camera.width * .5f ); |
|---|
| 657 |
f = 1; |
|---|
| 658 |
|
|---|
| 659 |
for (i=0 ; i<3 ; i++) |
|---|
| 660 |
dir[i] = m_Camera.vpn[i] * f + m_Camera.vright[i] * r + m_Camera.vup[i] * u; |
|---|
| 661 |
VectorNormalize (dir,dir); |
|---|
| 662 |
|
|---|
| 663 |
switch( g_qeglobals.d_select_mode ) |
|---|
| 664 |
{ |
|---|
| 665 |
case sel_brush_on: |
|---|
| 666 |
Select_Ray( m_Camera.origin, dir, (SF_DRAG_ON|SF_CAMERA) ); |
|---|
| 667 |
break; |
|---|
| 668 |
|
|---|
| 669 |
case sel_brush_off: |
|---|
| 670 |
Select_Ray( m_Camera.origin, dir, (SF_DRAG_OFF|SF_CAMERA) ); |
|---|
| 671 |
break; |
|---|
| 672 |
|
|---|
| 673 |
default: |
|---|
| 674 |
break; |
|---|
| 675 |
} |
|---|
| 676 |
return; |
|---|
| 677 |
} |
|---|
| 678 |
} |
|---|
| 679 |
else if (g_qeglobals.d_select_mode == sel_facets_on || g_qeglobals.d_select_mode == sel_facets_off) |
|---|
| 680 |
{ |
|---|
| 681 |
if( buttons == (MK_LBUTTON|MK_CONTROL|MK_SHIFT) ) |
|---|
| 682 |
{ |
|---|
| 683 |
vec3_t dir; |
|---|
| 684 |
float f, r, u; |
|---|
| 685 |
int i; |
|---|
| 686 |
|
|---|
| 687 |
|
|---|
| 688 |
|
|---|
| 689 |
|
|---|
| 690 |
u = (float)( y - ( m_Camera.height * .5f ) ) / ( m_Camera.width * .5f ); |
|---|
| 691 |
r = (float)( x - ( m_Camera.width * .5f ) ) / ( m_Camera.width * .5f ); |
|---|
| 692 |
f = 1; |
|---|
| 693 |
|
|---|
| 694 |
for (i=0 ; i<3 ; i++) |
|---|
| 695 |
dir[i] = m_Camera.vpn[i] * f + m_Camera.vright[i] * r + m_Camera.vup[i] * u; |
|---|
| 696 |
VectorNormalize (dir,dir); |
|---|
| 697 |
|
|---|
| 698 |
switch( g_qeglobals.d_select_mode ) |
|---|
| 699 |
{ |
|---|
| 700 |
case sel_facets_on: |
|---|
| 701 |
Select_Ray( m_Camera.origin, dir, (SF_SINGLEFACE|SF_DRAG_ON|SF_CAMERA) ); |
|---|
| 702 |
break; |
|---|
| 703 |
|
|---|
| 704 |
case sel_facets_off: |
|---|
| 705 |
Select_Ray( m_Camera.origin, dir, (SF_SINGLEFACE|SF_DRAG_OFF|SF_CAMERA) ); |
|---|
| 706 |
break; |
|---|
| 707 |
|
|---|
| 708 |
default: |
|---|
| 709 |
break; |
|---|
| 710 |
} |
|---|
| 711 |
return; |
|---|
| 712 |
} |
|---|
| 713 |
} |
|---|
| 714 |
} |
|---|
| 715 |
|
|---|
| 716 |
m_ptButtonX = x; |
|---|
| 717 |
m_ptButtonY = y; |
|---|
| 718 |
|
|---|
| 719 |
if ( (m_bFreeMove && (buttons & MK_CONTROL) && !(buttons & MK_SHIFT)) || (!m_bFreeMove && (buttons == (MK_RBUTTON|MK_CONTROL))) ) |
|---|
| 720 |
{ |
|---|
| 721 |
Cam_PositionDrag (); |
|---|
| 722 |
Sys_UpdateWindows (W_XY|W_CAMERA|W_Z); |
|---|
| 723 |
return; |
|---|
| 724 |
} |
|---|
| 725 |
|
|---|
| 726 |
Sys_GetCursorPos(&m_ptCursorX, &m_ptCursorY); |
|---|
| 727 |
|
|---|
| 728 |
if (buttons & (MK_LBUTTON | MK_MBUTTON) ) |
|---|
| 729 |
{ |
|---|
| 730 |
Drag_MouseMoved (x, y, buttons); |
|---|
| 731 |
if(g_qeglobals.d_select_mode != sel_area) |
|---|
| 732 |
Sys_UpdateWindows (W_XY|W_CAMERA|W_Z); |
|---|
| 733 |
} |
|---|
| 734 |
} |
|---|
| 735 |
|
|---|
| 736 |
void CamWnd::InitCull() |
|---|
| 737 |
{ |
|---|
| 738 |
int i; |
|---|
| 739 |
|
|---|
| 740 |
VectorSubtract (m_Camera.vpn, m_Camera.vright, m_vCull1); |
|---|
| 741 |
VectorAdd (m_Camera.vpn, m_Camera.vright, m_vCull2); |
|---|
| 742 |
|
|---|
| 743 |
for (i=0 ; i<3 ; i++) |
|---|
| 744 |
{ |
|---|
| 745 |
if (m_vCull1[i] > 0) |
|---|
| 746 |
m_nCullv1[i] = 3+i; |
|---|
| 747 |
else |
|---|
| 748 |
m_nCullv1[i] = i; |
|---|
| 749 |
if (m_vCull2[i] > 0) |
|---|
| 750 |
m_nCullv2[i] = 3+i; |
|---|
| 751 |
else |
|---|
| 752 |
m_nCullv2[i] = i; |
|---|
| 753 |
} |
|---|
| 754 |
} |
|---|
| 755 |
|
|---|
| 756 |
qboolean CamWnd::CullBrush (brush_t *b) |
|---|
| 757 |
{ |
|---|
| 758 |
int i; |
|---|
| 759 |
vec3_t point; |
|---|
| 760 |
float d; |
|---|
| 761 |
|
|---|
| 762 |
if (g_PrefsDlg.m_bCubicClipping) |
|---|
| 763 |
{ |
|---|
| 764 |
float fLevel = g_PrefsDlg.m_nCubicScale * 64; |
|---|
| 765 |
|
|---|
| 766 |
point[0] = m_Camera.origin[0] - fLevel; |
|---|
| 767 |
point[1] = m_Camera.origin[1] - fLevel; |
|---|
| 768 |
point[2] = m_Camera.origin[2] - fLevel; |
|---|
| 769 |
|
|---|
| 770 |
for (i=0; i<3; i++) |
|---|
| 771 |
if (b->mins[i] < point[i] && b->maxs[i] < point[i]) |
|---|
| 772 |
return true; |
|---|
| 773 |
|
|---|
| 774 |
point[0] = m_Camera.origin[0] + fLevel; |
|---|
| 775 |
point[1] = m_Camera.origin[1] + fLevel; |
|---|
| 776 |
point[2] = m_Camera.origin[2] + fLevel; |
|---|
| 777 |
|
|---|
| 778 |
for (i=0; i<3; i++) |
|---|
| 779 |
if (b->mins[i] > point[i] && b->maxs[i] > point[i]) |
|---|
| 780 |
return true; |
|---|
| 781 |
} |
|---|
| 782 |
|
|---|
| 783 |
for (i=0 ; i<3 ; i++) |
|---|
| 784 |
point[i] = b->mins[m_nCullv1[i]] - m_Camera.origin[i]; |
|---|
| 785 |
|
|---|
| 786 |
d = DotProduct (point, m_vCull1); |
|---|
| 787 |
if (d < -1) |
|---|
| 788 |
return true; |
|---|
| 789 |
|
|---|
| 790 |
for (i=0 ; i<3 ; i++) |
|---|
| 791 |
point[i] = b->mins[m_nCullv2[i]] - m_Camera.origin[i]; |
|---|
| 792 |
|
|---|
| 793 |
d = DotProduct (point, m_vCull2); |
|---|
| 794 |
if (d < -1) |
|---|
| 795 |
return true; |
|---|
| 796 |
|
|---|
| 797 |
return false; |
|---|
| 798 |
} |
|---|
| 799 |
|
|---|
| 800 |
|
|---|
| 801 |
|
|---|
| 802 |
|
|---|
| 803 |
void CamWnd::ProjectCamera(const vec3_t A, vec_t B[2]) |
|---|
| 804 |
{ |
|---|
| 805 |
|
|---|
| 806 |
vec_t P1[4],P2[4],P3[4]; |
|---|
| 807 |
VectorCopy(A,P1); P1[3] = 1; |
|---|
| 808 |
|
|---|
| 809 |
GLMatMul(m_Camera.modelview , P1, P2); |
|---|
| 810 |
GLMatMul(m_Camera.projection, P2, P3); |
|---|
| 811 |
|
|---|
| 812 |
|
|---|
| 813 |
B[0] = (float)m_Camera.width * ( P3[0] + 1.0 ) / 2.0; |
|---|
| 814 |
B[1] = (float)m_Camera.height * ( P3[1] + 1.0 ) / 2.0; |
|---|
| 815 |
|
|---|
| 816 |
} |
|---|
| 817 |
|
|---|
| 818 |
|
|---|
| 819 |
|
|---|
| 820 |
|
|---|
| 821 |
|
|---|
| 822 |
|
|---|
| 823 |
|
|---|
| 824 |
|
|---|
| 825 |
|
|---|
| 826 |
|
|---|
| 827 |
|
|---|
| 828 |
|
|---|
| 829 |
|
|---|
| 830 |
|
|---|
| 831 |
|
|---|
| 832 |
|
|---|
| 833 |
void CamWnd::MatchViewAxes(const vec3_t P, const vec3_t vec, int &axis, float &sgn) |
|---|
| 834 |
{ |
|---|
| 835 |
|
|---|
| 836 |
vec_t A[2],B[2],V[2]; |
|---|
| 837 |
ProjectCamera(P,A); |
|---|
| 838 |
vec3_t Q; |
|---|
| 839 |
VectorAdd(P,vec,Q); |
|---|
| 840 |
ProjectCamera(Q,B); |
|---|
| 841 |
|
|---|
| 842 |
V[0] = B[0] - A[0]; |
|---|
| 843 |
V[1] = B[1] - A[1]; |
|---|
| 844 |
if (fabs(V[0])>fabs(V[1])) |
|---|
| 845 |
{ |
|---|
| 846 |
|
|---|
| 847 |
axis = 0; |
|---|
| 848 |
if (V[0]>0) |
|---|
| 849 |
sgn = +1; |
|---|
| 850 |
else |
|---|
| 851 |
sgn = -1; |
|---|
| 852 |
} |
|---|
| 853 |
else |
|---|
| 854 |
{ |
|---|
| 855 |
|
|---|
| 856 |
axis = 1; |
|---|
| 857 |
if (V[1]>0) |
|---|
| 858 |
sgn = +1; |
|---|
| 859 |
else |
|---|
| 860 |
sgn = -1; |
|---|
| 861 |
} |
|---|
| 862 |
} |
|---|
| 863 |
|
|---|
| 864 |
#if 0 |
|---|
| 865 |
void CamWnd::DrawLightRadius(brush_t* pBrush) |
|---|
| 866 |
{ |
|---|
| 867 |
|
|---|
| 868 |
int nRadius = Brush_LightRadius(pBrush); |
|---|
| 869 |
if (nRadius > 0) |
|---|
| 870 |
{ |
|---|
| 871 |
Brush_SetLightColor(pBrush); |
|---|
| 872 |
qglEnable (GL_BLEND); |
|---|
| 873 |
qglPolygonMode (GL_FRONT_AND_BACK, GL_LINE); |
|---|
| 874 |
qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|---|
| 875 |
qglDisable (GL_TEXTURE_2D); |
|---|
| 876 |
|
|---|
| 877 |
qglEnable(GL_TEXTURE_2D); |
|---|
| 878 |
qglDisable(GL_BLEND); |
|---|
| 879 |
qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); |
|---|
| 880 |
} |
|---|
| 881 |
} |
|---|
| 882 |
#endif |
|---|
| 883 |
|
|---|
| 884 |
extern void DrawPatchMesh(patchMesh_t *pm); |
|---|
| 885 |
extern void DrawPatchControls(patchMesh_t *pm); |
|---|
| 886 |
extern void Brush_DrawFacingAngle (brush_t *b, entity_t *e); |
|---|
| 887 |
extern void Brush_DrawModel(brush_t *b, bool bTextured = false); |
|---|
| 888 |
extern void DrawModelOrigin(brush_t *b); |
|---|
| 889 |
extern void DrawModelBBox(brush_t *b); |
|---|
| 890 |
|
|---|
| 891 |
void CamWnd::Cam_DrawBrush(brush_t *b, int mode) |
|---|
| 892 |
{ |
|---|
| 893 |
int nGLState = m_Camera.draw_glstate; |
|---|
| 894 |
int nModelMode = g_PrefsDlg.m_nEntityShowState; |
|---|
| 895 |
|
|---|
| 896 |
GLfloat material[4], identity[4]; |
|---|
| 897 |
VectorSet(identity, 0.8f, 0.8f, 0.8f); |
|---|
| 898 |
IShader *pShader; |
|---|
| 899 |
|
|---|
| 900 |
|
|---|
| 901 |
if (b->owner->eclass->fixedsize && b->owner->eclass->nShowFlags & ECLASS_LIGHT && g_PrefsDlg.m_bNewLightDraw) |
|---|
| 902 |
{ |
|---|
| 903 |
switch (mode) |
|---|
| 904 |
{ |
|---|
| 905 |
case DRAW_SOLID: |
|---|
| 906 |
VectorCopy(b->owner->color, material); |
|---|
| 907 |
VectorScale(material, 0.8f, material); |
|---|
| 908 |
material[3] = 1.0f; |
|---|
| 909 |
|
|---|
| 910 |
qglColor4fv(material); |
|---|
| 911 |
|
|---|
| 912 |
if (g_PrefsDlg.m_bNewLightDraw) |
|---|
| 913 |
DrawLight(b->owner, nGLState, (IsBrushSelected(b)) ? g_PrefsDlg.m_nLightRadiuses : 0, 0); |
|---|
| 914 |
|
|---|
| 915 |
break; |
|---|
| 916 |
} |
|---|
| 917 |
} |
|---|
| 918 |
|
|---|
| 919 |
|
|---|
| 920 |
else if(b->owner->eclass->fixedsize && b->owner->model.pRender |
|---|
| 921 |
&& !(!IsBrushSelected(b) && (nModelMode & ENTITY_SELECTED_ONLY))) |
|---|
| 922 |
{ |
|---|
| 923 |
switch (mode) |
|---|
| 924 |
{ |
|---|
| 925 |
case DRAW_TEXTURED: |
|---|
| 926 |
if (!(nModelMode & ENTITY_WIREFRAME) && nModelMode != ENTITY_BOX) |
|---|
| 927 |
{ |
|---|
| 928 |
VectorCopy(b->owner->eclass->color, material); |
|---|
| 929 |
material[3] = identity[3] = 1.0f; |
|---|
| 930 |
|
|---|
| 931 |
qglEnable(GL_CULL_FACE); |
|---|
| 932 |
|
|---|
| 933 |
if(!(nGLState & DRAW_GL_TEXTURE_2D)) qglColor4fv(material); |
|---|
| 934 |
else qglColor4fv(identity); |
|---|
| 935 |
if(nGLState & DRAW_GL_LIGHTING) qglShadeModel(GL_SMOOTH); |
|---|
| 936 |
|
|---|
| 937 |
b->owner->model.pRender->Draw(nGLState, DRAW_RF_CAM); |
|---|
| 938 |
} |
|---|
| 939 |
break; |
|---|
| 940 |
case DRAW_WIRE: |
|---|
| 941 |
VectorCopy(b->owner->eclass->color, material); |
|---|
| 942 |
material[3] = 1.0f; |
|---|
| 943 |
qglColor4fv(material); |
|---|
| 944 |
|
|---|
| 945 |
|
|---|
| 946 |
if(nModelMode & ENTITY_WIREFRAME) |
|---|
| 947 |
b->owner->model.pRender->Draw(nGLState, DRAW_RF_CAM); |
|---|
| 948 |
|
|---|
| 949 |
|
|---|
| 950 |
if(!(b->owner->eclass->nShowFlags & ECLASS_MISCMODEL) ) |
|---|
| 951 |
{ |
|---|
| 952 |
qglColor4fv(material); |
|---|
| 953 |
aabb_draw(b->owner->model.pRender->GetAABB(), DRAW_GL_WIRE); |
|---|
| 954 |
} |
|---|
| 955 |
else if(nModelMode & ENTITY_BOXED) |
|---|
| 956 |
{ |
|---|
| 957 |
aabb_draw(b->owner->model.pRender->GetAABB(), DRAW_GL_WIRE); |
|---|
| 958 |
} |
|---|
| 959 |
|
|---|
| 960 |
|
|---|
| 961 |
|
|---|
| 962 |
|
|---|
| 963 |
} |
|---|
| 964 |
} |
|---|
| 965 |
|
|---|
| 966 |
|
|---|
| 967 |
else if (b->patchBrush) |
|---|
| 968 |
{ |
|---|
| 969 |
bool bTrans = (b->pPatch->pShader->getTrans() < 1.0f); |
|---|
| 970 |
switch(mode) |
|---|
| 971 |
{ |
|---|
| 972 |
case DRAW_TEXTURED: |
|---|
| 973 |
if (!g_bPatchWireFrame && ((nGLState & DRAW_GL_BLEND && bTrans) || (!(nGLState & DRAW_GL_BLEND) && !bTrans))) |
|---|
| 974 |
{ |
|---|
| 975 |
qglDisable(GL_CULL_FACE); |
|---|
| 976 |
|
|---|
| 977 |
pShader = b->pPatch->pShader; |
|---|
| 978 |
VectorCopy(pShader->getTexture()->color, material); |
|---|
| 979 |
material[3] = identity[3] = pShader->getTrans(); |
|---|
| 980 |
|
|---|
| 981 |
if(nGLState & DRAW_GL_TEXTURE_2D) { |
|---|
| 982 |
qglColor4fv(identity); |
|---|
| 983 |
qglBindTexture(GL_TEXTURE_2D, pShader->getTexture()->texture_number); |
|---|
| 984 |
} |
|---|
| 985 |
else |
|---|
| 986 |
qglColor4fv(material); |
|---|
| 987 |
if(nGLState & DRAW_GL_LIGHTING) qglShadeModel(GL_SMOOTH); |
|---|
| 988 |
|
|---|
| 989 |
DrawPatchMesh(b->pPatch); |
|---|
| 990 |
} |
|---|
| 991 |
break; |
|---|
| 992 |
case DRAW_WIRE: |
|---|
| 993 |
if (g_bPatchWireFrame) |
|---|
| 994 |
{ |
|---|
| 995 |
VectorCopy(b->pPatch->pShader->getTexture()->color, material); |
|---|
| 996 |
material[3] = 1.0; |
|---|
| 997 |
qglColor4fv(material); |
|---|
| 998 |
DrawPatchMesh(b->pPatch); |
|---|
| 999 |
} |
|---|
| 1000 |
if ( b->pPatch->bSelected && (g_qeglobals.d_select_mode == sel_curvepoint |
|---|
| 1001 |
|| g_qeglobals.d_select_mode == sel_area |
|---|
| 1002 |
|| g_bPatchBendMode)) |
|---|
| 1003 |
DrawPatchControls(b->pPatch); |
|---|
| 1004 |
} |
|---|
| 1005 |
} |
|---|
| 1006 |
|
|---|
| 1007 |
|
|---|
| 1008 |
else if(b->owner->eclass->fixedsize) |
|---|
| 1009 |
{ |
|---|
| 1010 |
switch(mode) |
|---|
| 1011 |
{ |
|---|
| 1012 |
case DRAW_SOLID: |
|---|
| 1013 |
VectorCopy(b->owner->eclass->color, material); |
|---|
| 1014 |
VectorScale(material, 0.8f, material); |
|---|
| 1015 |
material[3] = 1.0f; |
|---|
| 1016 |
qglColor4fv(material); |
|---|
| 1017 |
|
|---|
| 1018 |
qglEnable(GL_CULL_FACE); |
|---|
| 1019 |
qglShadeModel(GL_FLAT); |
|---|
| 1020 |
Brush_Draw(b); |
|---|
| 1021 |
break; |
|---|
| 1022 |
case DRAW_WIRE: |
|---|
| 1023 |
&n |
|---|