Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

SelectedFace.cpp (4713B)


      1 /*
      2 ===========================================================================
      3 Copyright (C) 1999-2005 Id Software, Inc.
      4 
      5 This file is part of Quake III Arena source code.
      6 
      7 Quake III Arena source code is free software; you can redistribute it
      8 and/or modify it under the terms of the GNU General Public License as
      9 published by the Free Software Foundation; either version 2 of the License,
     10 or (at your option) any later version.
     11 
     12 Quake III Arena source code is distributed in the hope that it will be
     13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 GNU General Public License for more details.
     16 
     17 You should have received a copy of the GNU General Public License
     18 along with Foobar; if not, write to the Free Software
     19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20 ===========================================================================
     21 */
     22 //-----------------------------------------------------------------------------
     23 //
     24 // $LogFile$
     25 // $Revision: 1.1.1.4 $
     26 // $Author: ttimo $
     27 // $Date: 2000/01/18 00:18:13 $
     28 // $Log: SelectedFace.cpp,v $
     29 // Revision 1.1.1.4  2000/01/18 00:18:13  ttimo
     30 // merging in for RC
     31 //
     32 // Revision 1.3  2000/01/17 23:53:43  TBesset
     33 // ready for merge in sourceforge (RC candidate)
     34 //
     35 // Revision 1.2  2000/01/07 16:40:12  TBesset
     36 // merged from BSP frontend
     37 //
     38 // Revision 1.1.1.3  1999/12/29 18:31:45  TBesset
     39 // Q3Radiant public version
     40 //
     41 // Revision 1.1.1.1.2.1  1999/12/29 21:39:41  TBesset
     42 // updated to update3 from Robert
     43 //
     44 // Revision 1.1.1.3  1999/12/29 18:31:45  TBesset
     45 // Q3Radiant public version
     46 //
     47 // Revision 1.2  1999/11/22 17:46:47  Timo & Christine
     48 // merged EARadiant into the main tree
     49 // bug fixes for Q3Plugin / EAPlugin
     50 // export for Robert
     51 //
     52 // Revision 1.1.4.2  1999/11/14 16:26:13  Timo & Christine
     53 // first beta of the ritualmap surface plugin
     54 //
     55 // Revision 1.1.4.1  1999/11/03 20:38:02  Timo & Christine
     56 // MEAN plugin for Q3Radiant, alpha version
     57 //
     58 // Revision 1.1.2.1  1999/10/27 08:34:28  Timo & Christine
     59 // preview version of the texture tools plugin is ready
     60 // ( TexTool.dll plugin is in Q3Plugin module )
     61 // plugins can draw in their own window using Radiant's qgl bindings
     62 //
     63 //
     64 // DESCRIPTION:
     65 // Quick interface hack for selected face interface
     66 // this one really needs more work, but I'm in a hurry with TexTool
     67 
     68 #include "stdafx.h"
     69 
     70 HGLRC WINAPI QERApp_GetQeglobalsHGLRC()
     71 {
     72 	return g_qeglobals.d_hglrcBase;
     73 }
     74 
     75 // pWinding is supposed to have MAX_POINTS_ON_WINDING
     76 int WINAPI QERApp_GetFaceInfo(_QERFaceData *pFaceData, winding_t *pWinding)
     77 {
     78 	int size;
     79 
     80 	if (g_ptrSelectedFaces.GetSize() > 0)
     81 	{
     82 		if (!g_qeglobals.m_bBrushPrimitMode)
     83 		{
     84 			Sys_Printf("Warning: unexpected QERApp_GetFaceInfo out of brush primitive mode\n");
     85 			return 0;
     86 		}
     87 		//++timo NOTE: let's put only what we need for now
     88     face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
     89 		strcpy( pFaceData->m_TextureName, selFace->texdef.name );
     90 		VectorCopy( selFace->planepts[0], pFaceData->m_v1 );
     91 		VectorCopy( selFace->planepts[1], pFaceData->m_v2 );
     92 		VectorCopy( selFace->planepts[2], pFaceData->m_v3 );
     93 		pFaceData->m_bBPrimit = true;
     94 		memcpy( &pFaceData->brushprimit_texdef, &selFace->brushprimit_texdef, sizeof(brushprimit_texdef_t) );
     95 		size = (int)((winding_t *)0)->points[selFace->face_winding->numpoints];
     96 		memcpy( pWinding, selFace->face_winding, size );
     97 		return 1;
     98 	}
     99 	return 0;
    100 }
    101 
    102 int WINAPI QERApp_SetFaceInfo(_QERFaceData *pFaceData)
    103 {
    104 	if (g_ptrSelectedFaces.GetSize() > 0)
    105 	{
    106 		if (!g_qeglobals.m_bBrushPrimitMode)
    107 		{
    108 			Sys_Printf("Warning: unexpected QERApp_SetFaceInfo out of brush primitive mode\n");
    109 			return 0;
    110 		}
    111     face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
    112     brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(0));
    113 		//strcpy( selected_face->texdef.name, pFaceData->m_TextureName );
    114 		selFace->texdef.SetName(pFaceData->m_TextureName);
    115 		VectorCopy( pFaceData->m_v1, selFace->planepts[0] );
    116 		VectorCopy( pFaceData->m_v2, selFace->planepts[1] );
    117 		VectorCopy( pFaceData->m_v3, selFace->planepts[2] );
    118 		memcpy( &selFace->brushprimit_texdef, &pFaceData->brushprimit_texdef, sizeof(brushprimit_texdef_t) );
    119 		Brush_Build( selBrush );
    120 		Sys_UpdateWindows(W_ALL);
    121 		return 1;
    122 	}
    123 	return 0;
    124 }
    125 
    126 void WINAPI QERApp_GetTextureSize( int Size[2] )
    127 {
    128 	if (g_ptrSelectedFaces.GetSize() > 0)
    129 	{
    130     face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
    131 		Size[0] = selFace->d_texture->width;
    132 		Size[1] = selFace->d_texture->height;
    133 	}
    134 	else
    135 		Sys_Printf("WARNING: unexpected call to QERApp_GetTextureSize with no selected_face\n");
    136 }