aboutsummaryrefslogtreecommitdiffstats
path: root/q3radiant/SelectedFace.cpp
blob: c1bd18bb841c8be7c11df75f65d9e364c8d553a4 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/
//-----------------------------------------------------------------------------
//
// $LogFile$
// $Revision: 1.1.1.4 $
// $Author: ttimo $
// $Date: 2000/01/18 00:18:13 $
// $Log: SelectedFace.cpp,v $
// Revision 1.1.1.4  2000/01/18 00:18:13  ttimo
// merging in for RC
//
// Revision 1.3  2000/01/17 23:53:43  TBesset
// ready for merge in sourceforge (RC candidate)
//
// Revision 1.2  2000/01/07 16:40:12  TBesset
// merged from BSP frontend
//
// Revision 1.1.1.3  1999/12/29 18:31:45  TBesset
// Q3Radiant public version
//
// Revision 1.1.1.1.2.1  1999/12/29 21:39:41  TBesset
// updated to update3 from Robert
//
// Revision 1.1.1.3  1999/12/29 18:31:45  TBesset
// Q3Radiant public version
//
// Revision 1.2  1999/11/22 17:46:47  Timo & Christine
// merged EARadiant into the main tree
// bug fixes for Q3Plugin / EAPlugin
// export for Robert
//
// Revision 1.1.4.2  1999/11/14 16:26:13  Timo & Christine
// first beta of the ritualmap surface plugin
//
// Revision 1.1.4.1  1999/11/03 20:38:02  Timo & Christine
// MEAN plugin for Q3Radiant, alpha version
//
// Revision 1.1.2.1  1999/10/27 08:34:28  Timo & Christine
// preview version of the texture tools plugin is ready
// ( TexTool.dll plugin is in Q3Plugin module )
// plugins can draw in their own window using Radiant's qgl bindings
//
//
// DESCRIPTION:
// Quick interface hack for selected face interface
// this one really needs more work, but I'm in a hurry with TexTool

#include "stdafx.h"

HGLRC WINAPI QERApp_GetQeglobalsHGLRC()
{
	return g_qeglobals.d_hglrcBase;
}

// pWinding is supposed to have MAX_POINTS_ON_WINDING
int WINAPI QERApp_GetFaceInfo(_QERFaceData *pFaceData, winding_t *pWinding)
{
	int size;

	if (g_ptrSelectedFaces.GetSize() > 0)
	{
		if (!g_qeglobals.m_bBrushPrimitMode)
		{
			Sys_Printf("Warning: unexpected QERApp_GetFaceInfo out of brush primitive mode\n");
			return 0;
		}
		//++timo NOTE: let's put only what we need for now
    face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
		strcpy( pFaceData->m_TextureName, selFace->texdef.name );
		VectorCopy( selFace->planepts[0], pFaceData->m_v1 );
		VectorCopy( selFace->planepts[1], pFaceData->m_v2 );
		VectorCopy( selFace->planepts[2], pFaceData->m_v3 );
		pFaceData->m_bBPrimit = true;
		memcpy( &pFaceData->brushprimit_texdef, &selFace->brushprimit_texdef, sizeof(brushprimit_texdef_t) );
		size = (int)((winding_t *)0)->points[selFace->face_winding->numpoints];
		memcpy( pWinding, selFace->face_winding, size );
		return 1;
	}
	return 0;
}

int WINAPI QERApp_SetFaceInfo(_QERFaceData *pFaceData)
{
	if (g_ptrSelectedFaces.GetSize() > 0)
	{
		if (!g_qeglobals.m_bBrushPrimitMode)
		{
			Sys_Printf("Warning: unexpected QERApp_SetFaceInfo out of brush primitive mode\n");
			return 0;
		}
    face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
    brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(0));
		//strcpy( selected_face->texdef.name, pFaceData->m_TextureName );
		selFace->texdef.SetName(pFaceData->m_TextureName);
		VectorCopy( pFaceData->m_v1, selFace->planepts[0] );
		VectorCopy( pFaceData->m_v2, selFace->planepts[1] );
		VectorCopy( pFaceData->m_v3, selFace->planepts[2] );
		memcpy( &selFace->brushprimit_texdef, &pFaceData->brushprimit_texdef, sizeof(brushprimit_texdef_t) );
		Brush_Build( selBrush );
		Sys_UpdateWindows(W_ALL);
		return 1;
	}
	return 0;
}

void WINAPI QERApp_GetTextureSize( int Size[2] )
{
	if (g_ptrSelectedFaces.GetSize() > 0)
	{
    face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
		Size[0] = selFace->d_texture->width;
		Size[1] = selFace->d_texture->height;
	}
	else
		Sys_Printf("WARNING: unexpected call to QERApp_GetTextureSize with no selected_face\n");
}