Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

CamWnd.cpp File Reference

#include "stdafx.h"
#include "Radiant.h"
#include "XYWnd.h"
#include "CamWnd.h"
#include "qe3.h"
#include "splines/splines.h"

Include dependency graph for CamWnd.cpp:

Include dependency graph

Go to the source code of this file.

Functions

 BEGIN_MESSAGE_MAP (CCamWnd, CWnd) ON_WM_KEYDOWN() ON_WM_PAINT() ON_WM_DESTROY() ON_WM_CLOSE() ON_WM_MOUSEMOVE() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_MBUTTONDOWN() ON_WM_MBUTTONUP() ON_WM_RBUTTONDOWN() ON_WM_RBUTTONUP() ON_WM_CREATE() ON_WM_SIZE() ON_WM_NCCALCSIZE() ON_WM_KILLFOCUS() ON_WM_SETFOCUS() ON_WM_KEYUP() END_MESSAGE_MAP() LONG WINAPI CamWndProc(HWND hWnd
void DrawPathLines ()
 IMPLEMENT_DYNCREATE (CCamWnd, CWnd)
void Select_RotateTexture (int amt)
void Select_ScaleTexture (int x, int y)
void Select_ShiftTexture (int x, int y)

Variables

int g_nAngleSpeed = 300
int g_nMoveSpeed = 400
UINT uMsg
UINT WPARAM wParam


Function Documentation

BEGIN_MESSAGE_MAP CCamWnd  ,
CWnd 
 

void DrawPathLines  ) 
 

Definition at line 2503 of file XYWnd.cpp.

References brush_t, entity_t::brushes, QEGlobals_t::d_savedinfo, entities, SavedInfo_t::exclude, f, g_qeglobals, i, j, k, brush_s::maxs, brush_s::mins, NULL, num_entities, qglBegin, qglColor3f, qglEnd, qglVertex3f, qglVertex3fv, strcmp(), ValueForKey(), vec3_t, vec_t, VectorNormalize(), and VectorSubtract.

Referenced by CCamWnd::Cam_Draw(), and CXYWnd::XY_Draw().

02504 {
02505     int     i, j, k;
02506     vec3_t  mid, mid1;
02507     entity_t *se, *te;
02508     brush_t *sb, *tb;
02509     char    *psz;
02510     vec3_t  dir, s1, s2;
02511     vec_t   len, f;
02512     int     arrows;
02513     int         num_entities;
02514     char        *ent_target[MAX_MAP_ENTITIES];
02515     entity_t    *ent_entity[MAX_MAP_ENTITIES];
02516 
02517     if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS)
02518     return;
02519 
02520     num_entities = 0;
02521     for (te = entities.next ; te != &entities && num_entities != MAX_MAP_ENTITIES ; te = te->next)
02522     {
02523         ent_target[num_entities] = ValueForKey (te, "target");
02524         if (ent_target[num_entities][0])
02525         {
02526             ent_entity[num_entities] = te;
02527             num_entities++;
02528         }
02529     }
02530 
02531     for (se = entities.next ; se != &entities ; se = se->next)
02532     {
02533         psz = ValueForKey(se, "targetname");
02534     
02535         if (psz == NULL || psz[0] == '\0')
02536             continue;
02537         
02538         sb = se->brushes.onext;
02539         if (sb == &se->brushes)
02540             continue;
02541 
02542         for (k=0 ; k<num_entities ; k++)
02543         {
02544         if (strcmp (ent_target[k], psz))
02545                 continue;
02546 
02547             te = ent_entity[k];
02548             tb = te->brushes.onext;
02549             if (tb == &te->brushes)
02550                 continue;
02551 
02552             for (i=0 ; i<3 ; i++)
02553                 mid[i] = (sb->mins[i] + sb->maxs[i])*0.5; 
02554 
02555             for (i=0 ; i<3 ; i++)
02556                 mid1[i] = (tb->mins[i] + tb->maxs[i])*0.5; 
02557 
02558             VectorSubtract (mid1, mid, dir);
02559             len = VectorNormalize (dir);
02560             s1[0] = -dir[1]*8 + dir[0]*8;
02561             s2[0] = dir[1]*8 + dir[0]*8;
02562             s1[1] = dir[0]*8 + dir[1]*8;
02563             s2[1] = -dir[0]*8 + dir[1]*8;
02564 
02565             qglColor3f (se->eclass->color[0], se->eclass->color[1], se->eclass->color[2]);
02566 
02567             qglBegin(GL_LINES);
02568             qglVertex3fv(mid);
02569             qglVertex3fv(mid1);
02570 
02571             arrows = (int)(len / 256) + 1;
02572 
02573             for (i=0 ; i<arrows ; i++)
02574             {
02575                 f = len * (i + 0.5) / arrows;
02576 
02577                 for (j=0 ; j<3 ; j++)
02578                     mid1[j] = mid[j] + f*dir[j];
02579                 qglVertex3fv (mid1);
02580                 qglVertex3f (mid1[0] + s1[0], mid1[1] + s1[1], mid1[2]);
02581                 qglVertex3fv (mid1);
02582                 qglVertex3f (mid1[0] + s2[0], mid1[1] + s2[1], mid1[2]);
02583             }
02584 
02585             qglEnd();
02586         }
02587     }
02588 
02589     return;
02590 }

Here is the call graph for this function:

IMPLEMENT_DYNCREATE CCamWnd  ,
CWnd 
 

void Select_RotateTexture int  amt  ) 
 

Definition at line 1438 of file SELECT.CPP.

01439 {
01440     brush_t     *b;
01441     face_t      *f;
01442 
01443   int nFaceCount = g_ptrSelectedFaces.GetSize();
01444 
01445   if(selected_brushes.next == &selected_brushes && nFaceCount == 0)
01446     {
01447         return;
01448     }
01449 
01450     for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
01451     {
01452         for (f=b->brush_faces ; f ; f=f->next)
01453         {
01454             if (g_qeglobals.m_bBrushPrimitMode)
01455             {
01456                 // apply same scale as the spinner button of the surface inspector
01457                 float   shift[2];
01458                 float   rotate;
01459                 float   scale[2];
01460                 brushprimit_texdef_t bp; 
01461                 // compute normalized texture matrix
01462                 ConvertTexMatWithQTexture( &f->brushprimit_texdef, f->d_texture, &bp, NULL );
01463                 // compute fake shift scale rot
01464                 TexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );
01465                 // update
01466                 rotate += amt;
01467                 // compute new normalized texture matrix
01468                 FakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );
01469                 // apply to face texture matrix
01470                 ConvertTexMatWithQTexture( &bp, NULL, &f->brushprimit_texdef, f->d_texture );
01471             }
01472             else
01473             {
01474                 f->texdef.rotate += amt;
01475                 f->texdef.rotate = static_cast<int>(f->texdef.rotate) % 360;
01476             }
01477         }
01478         Brush_Build(b);
01479         if (b->patchBrush)
01480         {
01481             //Patch_RotateTexture(b->nPatchID, amt);
01482             Patch_RotateTexture(b->pPatch, amt);
01483         }
01484     }
01485     
01486     if (nFaceCount > 0)
01487     {
01488     for (int i = 0; i < nFaceCount; i++)
01489     {
01490       face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(i));
01491       brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(i));
01492           if (g_qeglobals.m_bBrushPrimitMode)
01493           {
01494               float shift[2];
01495               float rotate;
01496               float scale[2];
01497               brushprimit_texdef_t bp; 
01498               ConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &bp, NULL );
01499               TexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );
01500               rotate += amt;
01501               FakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );
01502               ConvertTexMatWithQTexture( &bp, NULL, &selFace->brushprimit_texdef, selFace->d_texture );
01503           }
01504           else
01505           {
01506               selFace->texdef.rotate += amt;
01507               selFace->texdef.rotate = static_cast<int>(selFace->texdef.rotate) % 360;
01508           }
01509           Brush_Build(selBrush);
01510     }
01511     }
01512 
01513     Sys_UpdateWindows (W_CAMERA);
01514 }

void Select_ScaleTexture int  x,
int  y
 

Definition at line 1359 of file SELECT.CPP.

01360 {
01361     brush_t     *b;
01362     face_t      *f;
01363 
01364   int nFaceCount = g_ptrSelectedFaces.GetSize();
01365 
01366   if(selected_brushes.next == &selected_brushes && nFaceCount == 0)
01367     {
01368         return;
01369     }
01370 
01371     for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
01372     {
01373         for (f=b->brush_faces ; f ; f=f->next)
01374         {
01375             if (g_qeglobals.m_bBrushPrimitMode)
01376             {
01377                 // apply same scale as the spinner button of the surface inspector
01378                 float   shift[2];
01379                 float   rotate;
01380                 float   scale[2];
01381                 brushprimit_texdef_t bp; 
01382                 // compute normalized texture matrix
01383                 ConvertTexMatWithQTexture( &f->brushprimit_texdef, f->d_texture, &bp, NULL );
01384                 // compute fake shift scale rot
01385                 TexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );
01386                 // update
01387                 scale[0]+=static_cast<float>(x)*0.1;
01388                 scale[1]+=static_cast<float>(y)*0.1;
01389                 // compute new normalized texture matrix
01390                 FakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );
01391                 // apply to face texture matrix
01392                 ConvertTexMatWithQTexture( &bp, NULL, &f->brushprimit_texdef, f->d_texture );
01393             }
01394             else
01395             {
01396                 f->texdef.scale[0] += x;
01397                 f->texdef.scale[1] += y;
01398             }
01399         }
01400         Brush_Build(b);
01401         if (b->patchBrush)
01402         {
01403             Patch_ScaleTexture(b->pPatch, x, y);
01404         }
01405     }
01406 
01407     if (nFaceCount > 0)
01408     {
01409     for (int i = 0; i < nFaceCount; i++)
01410     {
01411       face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(i));
01412       brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(i));
01413           if (g_qeglobals.m_bBrushPrimitMode)
01414           {
01415               float shift[2];
01416               float rotate;
01417               float scale[2];
01418               brushprimit_texdef_t bp; 
01419               ConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &bp, NULL );
01420               TexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );
01421               scale[0]+=static_cast<float>(x)*0.1;
01422               scale[1]+=static_cast<float>(y)*0.1;
01423               FakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );
01424               ConvertTexMatWithQTexture( &bp, NULL, &selFace->brushprimit_texdef, selFace->d_texture );
01425           }
01426           else
01427           {
01428               selFace->texdef.scale[0] += x;
01429               selFace->texdef.scale[1] += y;
01430           }
01431           Brush_Build(selBrush);
01432     }
01433     }
01434 
01435     Sys_UpdateWindows (W_CAMERA);
01436 }

void Select_ShiftTexture int  x,
int  y
 

Definition at line 1300 of file SELECT.CPP.

01301 {
01302     brush_t     *b;
01303     face_t      *f;
01304 
01305   int nFaceCount = g_ptrSelectedFaces.GetSize();
01306 
01307     if(selected_brushes.next == &selected_brushes && nFaceCount == 0)
01308         return;
01309 
01310     for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
01311     {
01312         for (f=b->brush_faces ; f ; f=f->next)
01313         {
01314             if (g_qeglobals.m_bBrushPrimitMode)
01315             {
01316                 // use face normal to compute a true translation
01317                 Select_ShiftTexture_BrushPrimit( f, x, y );
01318             }
01319             else
01320             {
01321                 f->texdef.shift[0] += x;
01322                 f->texdef.shift[1] += y;
01323             }
01324         }
01325         Brush_Build(b);
01326         if (b->patchBrush)
01327         {
01328             //Patch_ShiftTexture(b->nPatchID, x, y);
01329             Patch_ShiftTexture(b->pPatch, x, y);
01330         }
01331     }
01332 
01333     if (nFaceCount > 0)
01334     {
01335     for (int i = 0; i < nFaceCount; i++)
01336     {
01337       face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(i));
01338       brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(i));
01339         if (g_qeglobals.m_bBrushPrimitMode)
01340         {
01341 
01342               // use face normal to compute a true translation
01343         // Select_ShiftTexture_BrushPrimit( selected_face, x, y );
01344               // use camera view to compute texture shift
01345               g_pParentWnd->GetCamera()->ShiftTexture_BrushPrimit( selFace, x, y );
01346       }
01347         else
01348         {
01349             selFace->texdef.shift[0] += x;
01350               selFace->texdef.shift[1] += y;
01351         }
01352         Brush_Build(selBrush);
01353     }
01354     }
01355 
01356     Sys_UpdateWindows (W_CAMERA);
01357 }


Variable Documentation

int g_nAngleSpeed = 300
 

Definition at line 40 of file CamWnd.cpp.

int g_nMoveSpeed = 400
 

Definition at line 41 of file CamWnd.cpp.

Referenced by CCamWnd::Cam_MouseControl().

UINT uMsg
 

Definition at line 88 of file CamWnd.cpp.

Referenced by ConWndProc(), EntityListWndProc(), EntityWndProc(), FieldWndProc(), InputLineWndProc(), MainWndProc(), WCam_WndProc(), WZ_WndProc(), and XYWndProc().

UINT WPARAM wParam
 

Definition at line 88 of file CamWnd.cpp.

Referenced by AboutDlgProc(), AddCommandDlgProc(), ConWndProc(), CMainFrame::DefWindowProc(), EditCommandDlgProc(), EntityListWndProc(), EntityWndProc(), FieldWndProc(), FindBrushDlgProc(), GammaDlgProc(), InputLineWndProc(), MainWndProc(), CGroupDlg::OnChildNotify(), CMainFrame::OnCommand(), CGroupDlg::OnNotify(), ProjectDlgProc(), RotateDlgProc(), SidesDlgProc(), WCam_WndProc(), CMainFrame::WindowProc(), WZ_WndProc(), and XYWndProc().


Generated on Thu Aug 25 17:29:03 2005 for Quake III Arena by  doxygen 1.3.9.1