xywnd.cpp
来自「quake3工具源码。包括生成bsp文件」· C++ 代码 · 共 2,569 行 · 第 1/5 页
CPP
2,569 行
qglVertex2f (xe, y);
}
qglEnd ();
}
// draw coordinate text if needed
if ( g_qeglobals.d_savedinfo.show_coordinates)
{
//glColor4f(0, 0, 0, 0);
qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT]);
for (x=xb ; x<xe ; x+=stepSize)
{
qglRasterPos2f (x, m_vOrigin[nDim2] + h - 6 / m_fScale);
sprintf (text, "%i",(int)x);
qglCallLists (strlen(text), GL_UNSIGNED_BYTE, text);
}
for (y=yb ; y<ye ; y+=stepSize)
{
qglRasterPos2f (m_vOrigin[nDim1] - w + 1, y);
sprintf (text, "%i",(int)y);
qglCallLists (strlen(text), GL_UNSIGNED_BYTE, text);
}
if (Active())
qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME]);
qglRasterPos2f ( m_vOrigin[nDim1] - w + 35 / m_fScale, m_vOrigin[nDim2] + h - 20 / m_fScale );
char cView[20];
if (m_nViewType == XY)
strcpy(cView, "XY Top");
else
if (m_nViewType == XZ)
strcpy(cView, "XZ Front");
else
strcpy(cView, "YZ Side");
qglCallLists (strlen(cView), GL_UNSIGNED_BYTE, cView);
}
/*
if (true)
{
qglColor3f(g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR]);
qglBegin (GL_LINES);
qglVertex2f (x, yb);
qglVertex2f (x, ye);
qglEnd();
}
*/
}
/*
==============
XY_DrawBlockGrid
==============
*/
void CXYWnd::XY_DrawBlockGrid()
{
float x, y, xb, xe, yb, ye;
int w, h;
char text[32];
qglDisable(GL_TEXTURE_2D);
qglDisable(GL_TEXTURE_1D);
qglDisable(GL_DEPTH_TEST);
qglDisable(GL_BLEND);
w = m_nWidth / 2 / m_fScale;
h = m_nHeight / 2 / m_fScale;
int nDim1 = (m_nViewType == YZ) ? 1 : 0;
int nDim2 = (m_nViewType == XY) ? 1 : 2;
xb = m_vOrigin[nDim1] - w;
if (xb < region_mins[nDim1])
xb = region_mins[nDim1];
xb = 1024 * floor (xb/1024);
xe = m_vOrigin[nDim1] + w;
if (xe > region_maxs[nDim1])
xe = region_maxs[nDim1];
xe = 1024 * ceil (xe/1024);
yb = m_vOrigin[nDim2] - h;
if (yb < region_mins[nDim2])
yb = region_mins[nDim2];
yb = 1024 * floor (yb/1024);
ye = m_vOrigin[nDim2] + h;
if (ye > region_maxs[nDim2])
ye = region_maxs[nDim2];
ye = 1024 * ceil (ye/1024);
// draw major blocks
qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK]);
qglLineWidth (2);
qglBegin (GL_LINES);
for (x=xb ; x<=xe ; x+=1024)
{
qglVertex2f (x, yb);
qglVertex2f (x, ye);
}
for (y=yb ; y<=ye ; y+=1024)
{
qglVertex2f (xb, y);
qglVertex2f (xe, y);
}
qglEnd ();
qglLineWidth (1);
// draw coordinate text if needed
for (x=xb ; x<xe ; x+=1024)
for (y=yb ; y<ye ; y+=1024)
{
qglRasterPos2f (x+512, y+512);
sprintf (text, "%i,%i",(int)floor(x/1024), (int)floor(y/1024) );
qglCallLists (strlen(text), GL_UNSIGNED_BYTE, text);
}
qglColor4f(0, 0, 0, 0);
}
void CXYWnd::DrawRotateIcon()
{
float x, y;
if (m_nViewType == XY)
{
x = g_vRotateOrigin[0];
y = g_vRotateOrigin[1];
}
else if (m_nViewType == YZ)
{
x = g_vRotateOrigin[1];
y = g_vRotateOrigin[2];
}
else
{
x = g_vRotateOrigin[0];
y = g_vRotateOrigin[2];
}
qglEnable (GL_BLEND);
qglDisable (GL_TEXTURE_2D);
qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
qglDisable (GL_CULL_FACE);
qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
qglColor4f (0.8, 0.1, 0.9, 0.25);
qglBegin(GL_QUADS);
qglVertex3f (x-4,y-4,0);
qglVertex3f (x+4,y-4,0);
qglVertex3f (x+4,y+4,0);
qglVertex3f (x-4,y+4,0);
qglEnd ();
qglDisable (GL_BLEND);
qglColor4f (1.0, 0.2, 1.0, 1);
qglBegin(GL_POINTS);
qglVertex3f (x,y,0);
qglEnd ();
#if 0
qglBegin(GL_LINES);
qglVertex3f (x-6,y+6,0);
qglVertex3f (x+6,y+6,0);
qglVertex3f (x-6,y-6,0);
qglVertex3f (x+6,y-6,0);
qglEnd ();
#endif
}
void CXYWnd::DrawCameraIcon()
{
float x, y, a;
if (m_nViewType == XY)
{
x = g_pParentWnd->GetCamera()->Camera().origin[0];
y = g_pParentWnd->GetCamera()->Camera().origin[1];
a = g_pParentWnd->GetCamera()->Camera().angles[YAW]/180*Q_PI;
}
else if (m_nViewType == YZ)
{
x = g_pParentWnd->GetCamera()->Camera().origin[1];
y = g_pParentWnd->GetCamera()->Camera().origin[2];
a = g_pParentWnd->GetCamera()->Camera().angles[PITCH]/180*Q_PI;
}
else
{
x = g_pParentWnd->GetCamera()->Camera().origin[0];
y = g_pParentWnd->GetCamera()->Camera().origin[2];
a = g_pParentWnd->GetCamera()->Camera().angles[PITCH]/180*Q_PI;
}
qglColor3f (0.0, 0.0, 1.0);
qglBegin(GL_LINE_STRIP);
qglVertex3f (x-16,y,0);
qglVertex3f (x,y+8,0);
qglVertex3f (x+16,y,0);
qglVertex3f (x,y-8,0);
qglVertex3f (x-16,y,0);
qglVertex3f (x+16,y,0);
qglEnd ();
qglBegin(GL_LINE_STRIP);
qglVertex3f (x+48*cos(a+Q_PI/4), y+48*sin(a+Q_PI/4), 0);
qglVertex3f (x, y, 0);
qglVertex3f (x+48*cos(a-Q_PI/4), y+48*sin(a-Q_PI/4), 0);
qglEnd ();
#if 0
char text[128];
qglRasterPos2f (x+64, y+64);
sprintf (text, "%f",g_pParentWnd->GetCamera()->Camera().angles[YAW]);
qglCallLists (strlen(text), GL_UNSIGNED_BYTE, text);
#endif
}
void CXYWnd::DrawZIcon (void)
{
if (m_nViewType == XY)
{
float x = z.origin[0];
float y = z.origin[1];
qglEnable (GL_BLEND);
qglDisable (GL_TEXTURE_2D);
qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
qglDisable (GL_CULL_FACE);
qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
qglColor4f (0.0, 0.0, 1.0, 0.25);
qglBegin(GL_QUADS);
qglVertex3f (x-8,y-8,0);
qglVertex3f (x+8,y-8,0);
qglVertex3f (x+8,y+8,0);
qglVertex3f (x-8,y+8,0);
qglEnd ();
qglDisable (GL_BLEND);
qglColor4f (0.0, 0.0, 1.0, 1);
qglBegin(GL_LINE_LOOP);
qglVertex3f (x-8,y-8,0);
qglVertex3f (x+8,y-8,0);
qglVertex3f (x+8,y+8,0);
qglVertex3f (x-8,y+8,0);
qglEnd ();
qglBegin(GL_LINE_STRIP);
qglVertex3f (x-4,y+4,0);
qglVertex3f (x+4,y+4,0);
qglVertex3f (x-4,y-4,0);
qglVertex3f (x+4,y-4,0);
qglEnd ();
}
}
/*
==================
FilterBrush
==================
*/
BOOL FilterBrush(brush_t *pb)
{
if (!pb->owner)
return FALSE; // during construction
if (pb->hiddenBrush)
{
return TRUE;
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CAULK)
{
// filter out the brush only if all faces are caulk
// if not don't hide the whole brush, proceed on a per-face basis (Cam_Draw)
//++timo TODO: set this as a preference .. show caulk: hide any brush with caulk // don't draw caulk faces
face_t *f;
f=pb->brush_faces;
while (f)
{
if (!strstr(f->texdef.name, "caulk"))
break;
f = f->next;
}
if (!f)
return TRUE;
#if 0
if (strstr(pb->brush_faces->texdef.name, "caulk"))
return TRUE;
#endif
//++timo FIXME: .. same deal here?
if (strstr(pb->brush_faces->texdef.name, "donotenter"))
return TRUE;
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_HINT)
{
if (strstr(pb->brush_faces->texdef.name, "hint"))
return TRUE;
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLIP)
{
if (strstr(pb->brush_faces->texdef.name, "clip"))
return TRUE;
if (strstr(pb->brush_faces->texdef.name, "skip"))
return TRUE;
//if (!strncmp(pb->brush_faces->texdef.name, "clip", 4))
// return TRUE;
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WATER)
{
for (face_t* f = pb->brush_faces ; f ; f=f->next)
{
if (f->texdef.contents & (CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA))
return TRUE;
}
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_DETAIL)
{
if (pb->brush_faces->texdef.contents & CONTENTS_DETAIL)
return TRUE;
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CURVES)
{
if (pb->patchBrush)
return TRUE;
}
if (pb->owner == world_entity)
{
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD)
return TRUE;
return FALSE;
}
else
{
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT)
{
return (strncmp(pb->owner->eclass->name, "func_group", 10));
}
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTS)
{
return (pb->owner->eclass->nShowFlags & ECLASS_LIGHT);
//if (!strncmp(pb->owner->eclass->name, "light", 5))
// return TRUE;
}
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS)
{
return (pb->owner->eclass->nShowFlags & ECLASS_PATH);
//if (!strncmp(pb->owner->eclass->name, "path", 4))
// return TRUE;
}
return FALSE;
}
/*
=============================================================
PATH LINES
=============================================================
*/
/*
==================
DrawPathLines
Draws connections between entities.
Needs to consider all entities, not just ones on screen,
because the lines can be visible when neither end is.
Called for both camera view and xy view.
==================
*/
void DrawPathLines (void)
{
int i, j, k;
vec3_t mid, mid1;
entity_t *se, *te;
brush_t *sb, *tb;
char *psz;
vec3_t dir, s1, s2;
vec_t len, f;
int arrows;
int num_entities;
char *ent_target[MAX_MAP_ENTITIES];
entity_t *ent_entity[MAX_MAP_ENTITIES];
if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS)
return;
num_entities = 0;
for (te = entities.next ; te != &entities && num_entities != MAX_MAP_ENTITIES ; te = te->next)
{
ent_target[num_entities] = ValueForKey (te, "target");
if (ent_target[num_entities][0])
{
ent_entity[num_entities] = te;
num_entities++;
}
}
for (se = entities.next ; se != &entities ; se = se->next)
{
psz = ValueForKey(se, "targetname");
if (psz == NULL || psz[0] == '\0')
continue;
sb = se->brushes.onext;
if (sb == &se->brushes)
continue;
for (k=0 ; k<num_entities ; k++)
{
if (strcmp (ent_target[k], psz))
continue;
te = ent_entity[k];
tb = te->brushes.onext;
if (tb == &te->brushes)
continue;
for (i=0 ; i<3 ; i++)
mid[i] = (sb->mins[i] + sb->maxs[i])*0.5;
for (i=0 ; i<3 ; i++)
mid1[i] = (tb->mins[i] + tb->maxs[i])*0.5;
VectorSubtract (mid1, mid, dir);
len = VectorNormalize (dir);
s1[0] = -dir[1]*8 + dir[0]*8;
s2[0] = dir[1]*8 + dir[0]*8;
s1[1] = dir[0]*8 + dir[1]*8;
s2[1] = -dir[0]*8 + dir[1]*8;
qglColor3f (se->eclass->color[0], se->eclass->color[1], se->eclass->color[2]);
qglBegin(GL_LINES);
qglVertex3fv(mid);
qglVertex3fv(mid1);
arrows = (int)(len / 256) + 1;
for (i=0 ; i<arrows ; i++)
{
f = len * (i + 0.5) / arrows;
for (j=0 ; j<3 ; j++)
mid1[j] = mid[j] + f*dir[j];
qglVertex3fv (mid1);
qglVertex3f (mid1[0] + s1[0], mid1[1] + s1[1], mid1[2]);
qglVertex3fv (mid1);
qglVertex3f (mid1[0] + s2[0], mid1[1] + s2[1], mid1[2]);
}
qglEnd();
}
}
return;
}
//=============================================================
// can be greatly simplified but per usual i am in a hurry
// which is not an excuse, just a fact
void CXYWnd::PaintSizeInfo(int nDim1, int nDim2, vec3_t vMinBounds, vec3_t vMaxBounds)
{
vec3_t vSize;
VectorSubtract(vMaxBounds, vMinBounds, vSize);
qglColor3f(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] * .65,
g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] * .65,
g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] * .65);
if (m_nViewType == XY)
{
qglBegin (GL_LINES);
qglVertex3f(vMinBounds[nDim1], vMinBounds[nDim2] - 6.0f / m_fScale, 0.0f);
qglVertex3f(vMinBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale, 0.0f);
qglVertex3
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?