示例#1
0
/*
============
Select_Ray

If the origin is inside a brush, that brush will be ignored.
============
*/
void Select_Ray (vec3_t origin, vec3_t dir, int flags)
{
	trace_t	t;

	t = Test_Ray (origin, dir, flags);
	if (!t.brush)
		return;

	if (flags == SF_SINGLEFACE)
	{
		selected_face = t.face;
		selected_face_brush = t.brush;
		Sys_UpdateWindows (W_ALL);
		g_qeglobals.d_select_mode = sel_brush;
		Texture_SetTexture (&t.face->texdef);
    UpdateSurfaceDialog();
		return;
	}

	// move the brush to the other list

	g_qeglobals.d_select_mode = sel_brush;

	if (t.selected)
	{		
		Brush_RemoveFromList (t.brush);
		Brush_AddToList (t.brush, &active_brushes);
	} else
	{
		Select_Brush (t.brush, !(GetKeyState(VK_MENU) & 0x8000));
	}

	Sys_UpdateWindows (W_ALL);
}
示例#2
0
/*
============
Select_Ray

If the origin is inside a brush, that brush will be ignored.
============
*/
void Select_Ray( vec3_t origin, vec3_t dir, int flags )
{
	trace_t t;
	
	t = Test_Ray( origin, dir, flags );
	if ( !t.brush )
		return;
		
	if ( flags == SF_SINGLEFACE )
	{
		int nCount = g_SelectedFaces.GetSize();
		bool bOk = true;
		for ( int i = 0; i < nCount; i++ )
		{
			if ( t.face == reinterpret_cast<face_s*>( g_SelectedFaces.GetAt( i ) ) )
			{
				bOk = false;
				// need to move remove i'th entry
				g_SelectedFaces.RemoveAt( i, 1 );
				g_SelectedFaceBrushes.RemoveAt( i, 1 );
			}
		}
		if ( bOk )
		{
			g_SelectedFaces.Add( t.face );
			g_SelectedFaceBrushes.Add( t.brush );
		}
		//selected_face = t.face;
		//selected_face_brush = t.brush;
		Sys_UpdateWindows( W_ALL );
		clearSelection();
		// Texture_SetTexture requires a brushprimit_texdef fitted to the default width=2 height=2 texture
		brushprimit_texdef_s brushprimit_texdef;
		ConvertTexMatWithQTexture( &t.face->brushprimit_texdef, t.face->d_texture, &brushprimit_texdef, NULL );
		Texture_SetTexture( &t.face->texdef, &brushprimit_texdef, false, false );
		UpdateSurfaceDialog();
		return;
	}
	
	// move the brush to the other list
	
	clearSelection();
	
	if ( t.selected )
	{
		Brush_RemoveFromList( t.brush );
		Brush_AddToList( t.brush, &active_brushes );
		UpdatePatchInspector();
	}
	else
	{
		Select_Brush( t.brush, !( GetKeyState( VK_MENU ) & 0x8000 ) );
	}
	
	Sys_UpdateWindows( W_ALL );
}
void WINAPI QERApp_SetCurrentTexture(LPCSTR strName)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	//++timo hu ?? tex is not initialized ?? can be any value ..
  texdef_t tex;
  //++timo added a brushprimit_texdef ..
  // smthg to be done here
  brushprimit_texdef_t brushprimit_tex;
  //strcpy(tex.name, strName);
  tex.SetName(strName);
  Texture_SetTexture(&tex,&brushprimit_tex);
}
示例#4
0
void WINAPI QERApp_ReloadShaders()
{
	brush_t *b;
	face_t *f;

	QERApp_FreeShaders();
	// now we must reload the shader information from shaderfiles
	LoadShaders();
	// refresh the map visuals: replace our old shader objects by the new ones
	// on brush faces we have the shader name in texdef.name
	// on patches we have the shader name in PatchShaders
	// while we walk through the map data, we DecRef the old shaders and push the new ones in
	// if all goes well, most of our old shaders will get deleted on the way

	// FIXME: bug 104655, when we come accross a patch, we use the above array since the d_texture is lost
	// NOTE: both face_t and patchMesh_t store pointers to the shader and qtexture_t
	// in an ideal world they would only store shader and access the qtexture_t through it
	// reassign all current shaders
	for (b=active_brushes.next ; b != NULL && b != &active_brushes ; b=b->next)
  {
    if (b->patchBrush)
			SetShader(b->pPatch);
    else
		  for (f=b->brush_faces ; f ; f=f->next)
				SetShader(f);
  }
	for (b=selected_brushes.next ; b != NULL && b != &selected_brushes ; b=b->next)
  {
    if (b->patchBrush)
			SetShader(b->pPatch);
    else
		  for (f=b->brush_faces ; f ; f=f->next)
				SetShader(f);
  }
	// current shader
	// NOTE: we are kinda making it loop on itself, it will update the pShader and scroll the texture window
	Texture_SetTexture( &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef );

}
示例#5
0
/*
================
Drag_Begin
================
*/
void Drag_Begin( int x, int y, int buttons,
				const idVec3 &xaxis, const idVec3 &yaxis, const idVec3 &origin, const idVec3 &dir ) {
	qertrace_t	t;

	drag_ok = false;
	VectorCopy(vec3_origin, pressdelta);
	VectorCopy(vec3_origin, vPressStart);

	drag_first = true;

	// shift LBUTTON = select entire brush
	if (buttons == (MK_LBUTTON | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint) {
		int nFlag = ( ::GetAsyncKeyState( VK_MENU ) != 0 ) ? SF_CYCLE : 0;
		if (dir[0] == 0 || dir[1] == 0 || dir[2] == 0) {		// extremely low chance of this happening from camera
			Select_Ray(origin, dir, nFlag | SF_ENTITIES_FIRST); // hack for XY
		}
		else {
			Select_Ray(origin, dir, nFlag);
		}

		return;
	}

	// ctrl-shift LBUTTON = select single face
	if (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint) {
		if ( radiant_entityMode.GetBool() ) {
			return;
		}

		// _D3XP disabled
		//Select_Deselect( ( ::GetAsyncKeyState( VK_MENU ) == 0 ) );
		Select_Ray(origin, dir, SF_SINGLEFACE);
		return;
	}

	// LBUTTON + all other modifiers = manipulate selection
	if (buttons & MK_LBUTTON) {
		Drag_Setup(x, y, buttons, xaxis, yaxis, origin, dir);
		return;
	}

	if ( radiant_entityMode.GetBool() ) {
		return;
	}

	int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;

	// middle button = grab texture
	if (buttons == nMouseButton) {
		t = Test_Ray(origin, dir, false);
		if (t.face) {
			g_qeglobals.d_new_brush_bottom = t.brush->mins;
			g_qeglobals.d_new_brush_top = t.brush->maxs;

			// use a local brushprimit_texdef fitted to a default 2x2 texture
			brushprimit_texdef_t bp_local;
			if (t.brush && t.brush->pPatch) {
				texdef_t localtd;
				memset(&bp_local.coords, 0, sizeof(bp_local.coords));
				bp_local.coords[0][0] = 1.0f;
				bp_local.coords[1][1] = 1.0f;
				localtd.SetName(t.brush->pPatch->d_texture->GetName());
				Texture_SetTexture(&localtd, &bp_local, false, true);
				Select_CopyPatchTextureCoords ( t.brush->pPatch );
			} else {
				Select_ProjectFaceOntoPatch( t.face );
				ConvertTexMatWithQTexture(&t.face->brushprimit_texdef, t.face->d_texture, &bp_local, NULL);
				Texture_SetTexture(&t.face->texdef, &bp_local, false, true);
			}
			UpdateSurfaceDialog();
			UpdatePatchInspector();
			UpdateLightInspector();
		}
		else {
			Sys_Status("Did not select a texture\n");
		}

		return;
	}

	// ctrl-middle button = set entire brush to texture
	if (buttons == (nMouseButton | MK_CONTROL)) {
		t = Test_Ray(origin, dir, false);
		if (t.brush) {
			if (t.brush->brush_faces->texdef.name[0] == '(') {
				Sys_Status("Can't change an entity texture\n");
			}
			else {
				Brush_SetTexture
				(
					t.brush,
					&g_qeglobals.d_texturewin.texdef,
					&g_qeglobals.d_texturewin.brushprimit_texdef,
					false
				);
				Sys_UpdateWindows(W_ALL);
			}
		}
		else {
			Sys_Status("Didn't hit a btrush\n");
		}

		return;
	}

	// ctrl-shift-middle button = set single face to texture
	if (buttons == (nMouseButton | MK_SHIFT | MK_CONTROL)) {
		t = Test_Ray(origin, dir, false);
		if (t.brush) {
			if (t.brush->brush_faces->texdef.name[0] == '(') {
				Sys_Status("Can't change an entity texture\n");
			}
			else {
				SetFaceTexdef
				(
					t.brush,
					t.face,
					&g_qeglobals.d_texturewin.texdef,
					&g_qeglobals.d_texturewin.brushprimit_texdef
				);
				Brush_Build(t.brush);
				Sys_UpdateWindows(W_ALL);
			}
		}
		else {
			Sys_Status("Didn't hit a btrush\n");
		}

		return;
	}

	if (buttons == (nMouseButton | MK_SHIFT)) {
		Sys_Status("Set brush face texture info\n");
		t = Test_Ray(origin, dir, false);
		if (t.brush && !t.brush->owner->eclass->fixedsize) {
/*
			if (t.brush->brush_faces->texdef.name[0] == '(') {
				if (t.brush->owner->eclass->nShowFlags & ECLASS_LIGHT) {
					CString		strBuff;
					idMaterial	*pTex = declManager->FindMaterial(g_qeglobals.d_texturewin.texdef.name);
					if (pTex) {
						idVec3	vColor = pTex->getColor();

						float	fLargest = 0.0f;
						for (int i = 0; i < 3; i++) {
							if (vColor[i] > fLargest) {
								fLargest = vColor[i];
							}
						}

						if (fLargest == 0.0f) {
							vColor[0] = vColor[1] = vColor[2] = 1.0f;
						}
						else {
							float	fScale = 1.0f / fLargest;
							for (int i = 0; i < 3; i++) {
								vColor[i] *= fScale;
							}
						}

						strBuff.Format("%f %f %f", pTex->getColor().x, pTex->getColor().y, pTex->getColor().z);
						SetKeyValue(t.brush->owner, "_color", strBuff.GetBuffer(0));
						Sys_UpdateWindows(W_ALL);
					}
				}
				else {
					Sys_Status("Can't select an entity brush face\n");
				}
			}

			else {
*/
				// strcpy(t.face->texdef.name,g_qeglobals.d_texturewin.texdef.name);
				t.face->texdef.SetName(g_qeglobals.d_texturewin.texdef.name);
				Brush_Build(t.brush);
				Sys_UpdateWindows(W_ALL);
//			}
		}
		else {
			Sys_Status("Didn't hit a brush\n");
		}

		return;
	}
}
示例#6
0
/*
===========
Drag_Begin
//++timo test three button mouse and three button emulation here ?
===========
*/
void Drag_Begin (int x, int y, int buttons,
		   vec3_t xaxis, vec3_t yaxis,
		   vec3_t origin, vec3_t dir)
{
	trace_t	t;

	drag_ok = false;
	VectorCopy (vec3_origin, pressdelta);
	VectorCopy (vec3_origin, vPressStart);

	drag_first = true;
	peLink = NULL;

	// shift LBUTTON = select entire brush
	if (buttons == (MK_LBUTTON | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint)
	{
    int nFlag = (static_cast<bool>(::GetAsyncKeyState(VK_MENU))) ? SF_CYCLE : 0;
		if (dir[0] == 0 || dir[1] == 0 || dir[2] == 0)  // extremely low chance of this happening from camera
			Select_Ray (origin, dir, nFlag | SF_ENTITIES_FIRST);	// hack for XY
		else
			Select_Ray (origin, dir, nFlag);
		return;
	}

	// ctrl-shift LBUTTON = select single face
	if (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint)
	{
		Sys_Printf ("Face Selection?\n"); 
		Select_Deselect (!static_cast<bool>(::GetAsyncKeyState(VK_MENU)));
		Select_Ray (origin, dir, SF_SINGLEFACE);
		return;
	}


	// LBUTTON + all other modifiers = manipulate selection
	if (buttons & MK_LBUTTON)
	{
		//
		Drag_Setup (x, y, buttons, xaxis, yaxis, origin, dir);
		return;
	}

	// JONATHAN: stuff to add here
	int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;
	// middle button = grab texture
	if (buttons == nMouseButton)
	{
		t = Test_Ray (origin, dir, false);
		if (t.face)
		{
			//++timo clean
#if 0
//			g_qeglobals.d_new_brush_bottom_z = t.brush->mins[2];
//			g_qeglobals.d_new_brush_top_z = t.brush->maxs[2];
			// g_pParentWnd->ActiveXY()->GetViewType()
			// cf VIEWTYPE definition: enum VIEWTYPE {YZ, XZ, XY};
			// we fit our work zone to the brush
			int nViewType = g_pParentWnd->ActiveXY()->GetViewType();
			int nDim1 = (nViewType == YZ) ? 1 : 0;
			int nDim2 = (nViewType == XY) ? 1 : 2;
			g_qeglobals.d_work_min[nDim1] = t.brush->mins[nDim1];
			g_qeglobals.d_work_max[nDim1] = t.brush->maxs[nDim1];
			g_qeglobals.d_work_min[nDim2] = t.brush->mins[nDim2];
			g_qeglobals.d_work_max[nDim2] = t.brush->maxs[nDim2];
#endif
			// JONATHAN:: On ALT-Middle mouse
			//					Fit texture to face
			SHORT altdown = (GetKeyState(VK_MENU) & 0x8000);
			if (altdown)
			{
				// Fit Texture to brush face				
				Face_FitTexture(t.face,	1, 1);
				// Build Brush to apply update
				Brush_Build(t.brush); //?
				// Update Camera View
				Sys_UpdateWindows (W_CAMERA);
			}
			else
			{
				UpdateWorkzone_ForBrush( t.brush );

				// use a local brushprimit_texdef fitted to a default 2x2 texture
				brushprimit_texdef_t bp_local;
				ConvertTexMatWithQTexture( &t.face->brushprimit_texdef, t.face->d_texture, &bp_local, NULL );
				Texture_SetTexture ( &t.face->texdef, &bp_local, false, GETPLUGINTEXDEF(t.face));
				UpdateSurfaceDialog();
				UpdatePatchInspector();
			}
		}
		else
			Sys_Printf ("Did not select a texture\n");
		return;
	}

	// ctrl-middle button = set entire brush to texture
	if (buttons == (nMouseButton|MK_CONTROL) )
	{
		t = Test_Ray (origin, dir, false);
		if (t.brush)
		{
			if (t.brush->brush_faces->texdef.name[0] == '(')
				Sys_Printf ("Can't change an entity texture\n");
			else
			{
				Brush_SetTexture (t.brush, &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, false, static_cast<IPluginTexdef *>( g_qeglobals.d_texturewin.pTexdef ) );
				Sys_UpdateWindows (W_ALL);
			}
		}
		else
			Sys_Printf ("Didn't hit a btrush\n");
		return;
	}

	// JONATHAN:HERE 
	// ctrl-shift-middle button = set single face to texture
	if (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL) )
	{
		t = Test_Ray (origin, dir, false);
		if (t.brush)
		{
			if (t.brush->brush_faces->texdef.name[0] == '(')
				Sys_Printf ("Can't change an entity texture\n");
			else
			{
				SetFaceTexdef (t.brush, t.face, &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef);
				Brush_Build( t.brush );
				Sys_UpdateWindows (W_ALL);
			}
		}
		else
			Sys_Printf ("Didn't hit a btrush\n");
		return;
	}

	if (buttons == (nMouseButton | MK_SHIFT))
	{
		Sys_Printf("Set brush face texture info\n");
		t = Test_Ray (origin, dir, false);
		if (t.brush)
		{
			if (t.brush->brush_faces->texdef.name[0] == '(')
      {
        if (t.brush->owner->eclass->nShowFlags & ECLASS_LIGHT)
        {
          CString strBuff;
					qtexture_t* pTex = g_qeglobals.d_texturewin.pShader->getTexture();
          if (pTex)
          {
            vec3_t vColor;
            VectorCopy(pTex->color, vColor);

            float fLargest = 0.0f;
            for (int i = 0; i < 3; i++)
            {
		          if (vColor[i] > fLargest)
			          fLargest = vColor[i];
            }
		        
		        if (fLargest == 0.0f)
		        {
              vColor[0] = vColor[1] = vColor[2] = 1.0f;
            }
		        else
		        {
			        float fScale = 1.0f / fLargest;
              for (int i = 0; i < 3; i++)
              {
                vColor[i] *= fScale;
              }
            }
            strBuff.Format("%f %f %f",pTex->color[0], pTex->color[1], pTex->color[2]);
            SetKeyValue(t.brush->owner, "_color", strBuff.GetBuffer(0));
				    Sys_UpdateWindows (W_ALL);
          }
        }
        else
        {
				  Sys_Printf ("Can't select an entity brush face\n");
        }
      }
			else
			{
      	//strcpy(t.face->texdef.name,g_qeglobals.d_texturewin.texdef.name);
      	t.face->texdef.SetName(g_qeglobals.d_texturewin.texdef.name);
				Brush_Build(t.brush);
				Sys_UpdateWindows (W_ALL);
			}
		}
		else
			Sys_Printf ("Didn't hit a brush\n");
		return;
	}

}
示例#7
0
/*
===========
Drag_Begin
===========
*/
void Drag_Begin (int x, int y, int buttons,
		   vec3_t xaxis, vec3_t yaxis,
		   vec3_t origin, vec3_t dir)
{
	trace_t	t;

	drag_ok = false;
	VectorCopy (vec3_origin, pressdelta);
	VectorCopy (vec3_origin, vPressStart);

	drag_first = true;
	peLink = NULL;

	// shift LBUTTON = select entire brush
	if (buttons == (MK_LBUTTON | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint)
	{
    int nFlag = (static_cast<bool>(::GetAsyncKeyState(VK_MENU))) ? SF_CYCLE : 0;
		if (dir[0] == 0 || dir[1] == 0 || dir[2] == 0)  // extremely low chance of this happening from camera
			Select_Ray (origin, dir, nFlag | SF_ENTITIES_FIRST);	// hack for XY
		else
			Select_Ray (origin, dir, nFlag);
		return;
	}

	// ctrl-shift LBUTTON = select single face
	if (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint)
	{
		Select_Deselect ();
		Select_Ray (origin, dir, SF_SINGLEFACE);
		return;
	}

	// LBUTTON + all other modifiers = manipulate selection
	if (buttons & MK_LBUTTON)
	{
		Drag_Setup (x, y, buttons, xaxis, yaxis, origin, dir);
		return;
	}

  int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;
	// middle button = grab texture
	if (buttons == nMouseButton)
	{
		t = Test_Ray (origin, dir, false);
		if (t.face)
		{
			g_qeglobals.d_new_brush_bottom_z = t.brush->mins[2];
			g_qeglobals.d_new_brush_top_z = t.brush->maxs[2];
			Texture_SetTexture (&t.face->texdef);
      UpdateSurfaceDialog();
	  UpdatePatchInspector();
		}
		else
			Sys_Printf ("Did not select a texture\n");
		return;
	}

	// ctrl-middle button = set entire brush to texture
	if (buttons == (nMouseButton|MK_CONTROL) )
	{
		t = Test_Ray (origin, dir, false);
		if (t.brush)
		{
			if (t.brush->brush_faces->texdef.name[0] == '(')
				Sys_Printf ("Can't change an entity texture\n");
			else
			{					
				Brush_SetTexture (t.brush, &g_qeglobals.d_texturewin.texdef, false, false);
				Sys_UpdateWindows (W_ALL);
			}
		}
		else
			Sys_Printf ("Didn't hit a btrush\n");
		return;
	}

	// ctrl-shift-middle button = set single face to texture
	if (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL) )
	{
		t = Test_Ray (origin, dir, false);
		if (t.brush)
		{
			if (t.brush->brush_faces->texdef.name[0] == '(')
				Sys_Printf ("Can't change an entity texture\n");
			else
			{									
				SetFaceTexdef (t.brush, t.face, &g_qeglobals.d_texturewin.texdef, false, false);
				Brush_Build( t.brush );
				Sys_UpdateWindows (W_ALL);
			}
		}
		else
			Sys_Printf ("Didn't hit a btrush\n");
		return;
	}

	// shift-middle = (if light) 
	//						set face texture info (err...whatever),
	//					else
	//						set brush to texture but preserve any system faces
	//
	if (buttons == (nMouseButton | MK_SHIFT))
	{
		Sys_Printf("Set brush face texture info\n");
		t = Test_Ray (origin, dir, false);
		if (t.brush)
		{
			if (t.brush->brush_faces->texdef.name[0] == '(')
			{
				if (strcmpi(t.brush->owner->eclass->name, "light") == 0)
				{
					CString strBuff;
					qtexture_t* pTex = Texture_ForName(g_qeglobals.d_texturewin.texdef.name);
					if (pTex)
					{
						vec3_t vColor;
						VectorCopy(pTex->color, vColor);
						
						float fLargest = 0.0f;
						for (int i = 0; i < 3; i++)
						{
							if (vColor[i] > fLargest)
								fLargest = vColor[i];
						}
						
						if (fLargest == 0.0f)
						{
							vColor[0] = vColor[1] = vColor[2] = 1.0f;
						}
						else
						{
							float fScale = 1.0f / fLargest;
							for (int i = 0; i < 3; i++)
							{
								vColor[i] *= fScale;
							}
						}
						strBuff.Format("%f %f %f",pTex->color[0], pTex->color[1], pTex->color[2]);
						SetKeyValue(t.brush->owner, "_color", strBuff.GetBuffer(0));
						Sys_UpdateWindows (W_ALL);
					}
				}
				else
				{
					Sys_Printf ("Can't select an entity brush face\n");
				}
			}
			else
			{
				Brush_SetTexture (t.brush, &g_qeglobals.d_texturewin.texdef, false, true);
				Sys_UpdateWindows (W_ALL);
			}
		}
		else
			Sys_Printf ("Didn't hit a brush\n");
		return;
	}

}