SelectedFace.cpp 4.6 KB

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