interiorDebug.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "torqueConfig.h"
  23. #ifndef TORQUE_SHIPPING
  24. #include "interior/interior.h"
  25. #include "interior/interiorInstance.h"
  26. #include "console/console.h"
  27. #include "core/color.h"
  28. #include "math/mMatrix.h"
  29. #include "gfx/bitmap/gBitmap.h"
  30. #include "gfx/primBuilder.h"
  31. #include "gfx/gfxShader.h"
  32. #include "materials/matInstance.h"
  33. #include "materials/materialList.h"
  34. #include "materials/shaderData.h"
  35. #include "renderInstance/renderPassManager.h"
  36. #include "shaderGen/shaderGenVars.h"
  37. static U8 interiorDebugColors[14][3] =
  38. {
  39. { 0xFF, 0xFF, 0xFF },
  40. { 0x00, 0x00, 0xFF },
  41. { 0x00, 0xFF, 0x00 },
  42. { 0xFF, 0x00, 0x00 },
  43. { 0xFF, 0xFF, 0x00 },
  44. { 0xFF, 0x00, 0xFF },
  45. { 0x00, 0xFF, 0xFF },
  46. { 0x80, 0x80, 0x80 },
  47. { 0xFF, 0x80, 0x80 },
  48. { 0x80, 0xFF, 0x80 },
  49. { 0x80, 0x80, 0xFF },
  50. { 0x80, 0xFF, 0xFF },
  51. { 0xFF, 0x80, 0xFF },
  52. { 0xFF, 0x80, 0x80 }
  53. };
  54. namespace
  55. {
  56. void lineLoopFromStrip(Vector<ItrPaddedPoint>& points,
  57. Vector<U32>& windings,
  58. U32 windingStart,
  59. U32 windingCount)
  60. {
  61. PrimBuild::begin(GFXLineStrip, windingCount + 1);
  62. PrimBuild::vertex3fv(points[windings[windingStart]].point);
  63. S32 skip = windingStart + 1;
  64. while (skip < (windingStart + windingCount))
  65. {
  66. PrimBuild::vertex3fv(points[windings[skip]].point);
  67. skip += 2;
  68. }
  69. skip -= 1;
  70. while (skip > windingStart)
  71. {
  72. if (skip < (windingStart + windingCount))
  73. PrimBuild::vertex3fv(points[windings[skip]].point);
  74. skip -= 2;
  75. }
  76. PrimBuild::vertex3fv(points[windings[windingStart]].point);
  77. PrimBuild::end();
  78. }
  79. void lineStrip(Vector<ItrPaddedPoint>& points,
  80. Vector<U32>& windings,
  81. U32 windingStart,
  82. U32 windingCount)
  83. {
  84. U32 end = 2;
  85. while (end < windingCount)
  86. {
  87. // Even
  88. PrimBuild::begin(GFXLineStrip, 4);
  89. PrimBuild::vertex3fv(points[windings[windingStart + end - 2]].point);
  90. PrimBuild::vertex3fv(points[windings[windingStart + end - 1]].point);
  91. PrimBuild::vertex3fv(points[windings[windingStart + end - 0]].point);
  92. PrimBuild::vertex3fv(points[windings[windingStart + end - 2]].point);
  93. PrimBuild::end();
  94. end++;
  95. if (end >= windingCount)
  96. break;
  97. // Odd
  98. PrimBuild::begin(GFXLineStrip, 4);
  99. PrimBuild::vertex3fv(points[windings[windingStart + end - 1]].point);
  100. PrimBuild::vertex3fv(points[windings[windingStart + end - 2]].point);
  101. PrimBuild::vertex3fv(points[windings[windingStart + end - 0]].point);
  102. PrimBuild::vertex3fv(points[windings[windingStart + end - 1]].point);
  103. PrimBuild::end();
  104. end++;
  105. }
  106. }
  107. } // namespace {}
  108. void Interior::debugRender(const ZoneVisDeterminer& zoneVis, SceneData &sgData, InteriorInstance *intInst, MatrixF& modelview)
  109. {
  110. // We use this shader to color things
  111. if ( mDebugShader == NULL )
  112. {
  113. ShaderData *shaderData = NULL;
  114. AssertFatal( Sim::findObject( "_DebugInterior_", shaderData ), "Unable to find ShaderData _DebugInterior_" );
  115. mDebugShader = shaderData ? shaderData->getShader() : NULL;
  116. if ( mDebugShader )
  117. {
  118. mDebugShaderConsts = mDebugShader->allocConstBuffer();
  119. mDebugShaderModelViewSC = mDebugShader->getShaderConstHandle(ShaderGenVars::modelview);
  120. mDebugShaderShadeColorSC = mDebugShader->getShaderConstHandle("$shadeColor");
  121. }
  122. }
  123. // We use this to override the texture that the interior defines.
  124. if (mDebugTexture.isNull())
  125. {
  126. // Allocate a small white bitmap
  127. GBitmap temp(16, 16);
  128. mDebugTexture.set(&temp, &GFXDefaultStaticDiffuseProfile, false, "Blank Texture");
  129. }
  130. // Set up our buffers
  131. GFX->setVertexBuffer( mVertBuff );
  132. GFX->setPrimitiveBuffer( mPrimBuff );
  133. // Set the modelview matrix for the shaders
  134. mDebugShaderConsts->setSafe(mDebugShaderModelViewSC, modelview);
  135. GFX->disableShaders();
  136. switch (smRenderMode)
  137. {
  138. case NormalRenderLines:
  139. debugNormalRenderLines(zoneVis);
  140. break;
  141. case ShowDetail:
  142. debugShowDetail(zoneVis);
  143. break;
  144. case ShowAmbiguous:
  145. debugShowAmbiguous(zoneVis);
  146. break;
  147. case ShowLightmaps:
  148. debugShowLightmaps(zoneVis, sgData, intInst);
  149. break;
  150. case ShowPortalZones:
  151. debugShowPortalZones(zoneVis);
  152. break;
  153. case ShowCollisionFans:
  154. debugShowCollisionFans(zoneVis);
  155. break;
  156. case ShowOrphan:
  157. debugShowOrphan(zoneVis);
  158. break;
  159. case ShowStrips:
  160. debugShowStrips(zoneVis);
  161. break;
  162. case ShowTexturesOnly:
  163. debugShowTexturesOnly(zoneVis, sgData, intInst);
  164. break;
  165. case ShowNullSurfaces:
  166. debugShowNullSurfaces(zoneVis, sgData, intInst);
  167. break;
  168. case ShowLargeTextures:
  169. debugShowLargeTextures(zoneVis, sgData, intInst);
  170. break;
  171. case ShowOutsideVisible:
  172. debugShowOutsideVisible(zoneVis);
  173. break;
  174. case ShowHullSurfaces:
  175. debugShowHullSurfaces();
  176. break;
  177. case ShowVehicleHullSurfaces:
  178. debugShowVehicleHullSurfaces(zoneVis, sgData, intInst);
  179. break;
  180. case ShowDetailLevel:
  181. debugShowDetailLevel(zoneVis);
  182. break;
  183. case ShowVertexColors:
  184. // debugShowVertexColors(pMaterials);
  185. break;
  186. default:
  187. AssertWarn(false, "Warning! Misunderstood debug render mode. Defaulting to ShowDetail");
  188. debugShowDetail(zoneVis);
  189. break;
  190. }
  191. }
  192. void Interior::preDebugRender()
  193. {
  194. // Set up our rendering states.
  195. if( mDebugShader )
  196. {
  197. // Set our shader
  198. GFX->setShader( mDebugShader );
  199. // Set a "blank" texture
  200. GFX->setTexture( 0, mDebugTexture );
  201. // Set a state block to enable our texture
  202. GFX->setStateBlock(mInteriorDebugTextureSB);
  203. }
  204. }
  205. void Interior::debugNormalRenderLines(const ZoneVisDeterminer& zoneVis)
  206. {
  207. // Set our "base debug states" (no texture)
  208. GFX->setStateBlock(mInteriorDebugNoneSB);
  209. for (U32 i = 0; i < mZones.size(); i++)
  210. {
  211. if (zoneVis.isZoneVisible(i) == false)
  212. continue;
  213. for( U32 j=0; j<mZones[i].surfaceCount; j++ )
  214. {
  215. U32 surfaceIndex = mZoneSurfaces[mZones[i].surfaceStart + j];
  216. Surface& rSurface = mSurfaces[ surfaceIndex ];
  217. PrimBuild::color3f(0.0f, 0.0f, 0.0f);
  218. lineLoopFromStrip(mPoints, mWindings, rSurface.windingStart, rSurface.windingCount);
  219. }
  220. }
  221. }
  222. void Interior::debugShowSurfaceFlag(const ZoneVisDeterminer& zoneVis, const U32 flag, const ColorF& c)
  223. {
  224. preDebugRender();
  225. for (U32 i = 0; i < mZones.size(); i++)
  226. {
  227. if (zoneVis.isZoneVisible(i) == false)
  228. continue;
  229. for( U32 j=0; j<mZones[i].surfaceCount; j++ )
  230. {
  231. U32 surfaceIndex = mZoneSurfaces[mZones[i].surfaceStart + j];
  232. Surface& rSurface = mSurfaces[ surfaceIndex ];
  233. ColorF col(0.0f, 0.0f, 0.0f);
  234. if (rSurface.surfaceFlags & flag)
  235. col = c;
  236. else
  237. {
  238. if (smFocusedDebug == true)
  239. continue;
  240. else
  241. col.set(1.0f, 1.0f, 1.0f);
  242. }
  243. mDebugShaderConsts->setSafe(mDebugShaderShadeColorSC, col);
  244. GFX->setShaderConstBuffer(mDebugShaderConsts);
  245. GFXPrimitive* info = &rSurface.surfaceInfo;
  246. GFX->drawIndexedPrimitive( info->type, info->startVertex, info->minIndex, info->numVertices, info->startIndex, info->numPrimitives );
  247. }
  248. }
  249. GFX->disableShaders();
  250. debugNormalRenderLines(zoneVis);
  251. }
  252. void Interior::debugShowDetail(const ZoneVisDeterminer& zoneVis)
  253. {
  254. debugShowSurfaceFlag(zoneVis, SurfaceDetail, ColorF(1.0f, 0.0f, 0.0f));
  255. }
  256. void Interior::debugShowAmbiguous(const ZoneVisDeterminer& zoneVis)
  257. {
  258. debugShowSurfaceFlag(zoneVis, SurfaceAmbiguous, ColorF(0.0f, 1.0f, 0.0f));
  259. }
  260. void Interior::debugShowOrphan(const ZoneVisDeterminer& zoneVis)
  261. {
  262. debugShowSurfaceFlag(zoneVis, SurfaceOrphan, ColorF(0.0f, 0.0f, 1.0f));
  263. }
  264. void Interior::debugShowOutsideVisible(const ZoneVisDeterminer& zoneVis)
  265. {
  266. debugShowSurfaceFlag(zoneVis, SurfaceOutsideVisible, ColorF(1.0f, 0.0f, 0.0f));
  267. }
  268. void Interior::debugShowPortalZones(const ZoneVisDeterminer& zoneVis)
  269. {
  270. preDebugRender();
  271. for (U32 i = 0; i < mZones.size(); i++)
  272. {
  273. U8* color;
  274. if (i == 0)
  275. color = interiorDebugColors[0];
  276. else
  277. color = interiorDebugColors[(i % 13) + 1];
  278. for (U32 j = mZones[i].surfaceStart; j < mZones[i].surfaceStart + mZones[i].surfaceCount; j++)
  279. {
  280. Surface& rSurface = mSurfaces[mZoneSurfaces[j]];
  281. ColorF c((F32) color[0] / 255.0f, (F32) color[1] / 255.0f, (F32) color[2] / 255.0f);
  282. mDebugShaderConsts->setSafe(mDebugShaderShadeColorSC, c);
  283. GFX->setShaderConstBuffer(mDebugShaderConsts);
  284. GFXPrimitive* info = &rSurface.surfaceInfo;
  285. GFX->drawIndexedPrimitive( info->type, info->startVertex, info->minIndex, info->numVertices, info->startIndex, info->numPrimitives );
  286. }
  287. }
  288. GFX->disableShaders();
  289. debugRenderPortals();
  290. debugNormalRenderLines(zoneVis);
  291. }
  292. // Render portals
  293. void Interior::debugRenderPortals()
  294. {
  295. // Set our portal rendering state block
  296. GFX->setStateBlock(mInteriorDebugPortalSB);
  297. for (U32 i = 0; i < mPortals.size(); i++)
  298. {
  299. const Portal& rPortal = mPortals[i];
  300. for (U16 j = 0; j < rPortal.triFanCount; j++)
  301. {
  302. const TriFan& rFan = mWindingIndices[rPortal.triFanStart + j];
  303. U32 k;
  304. PrimBuild::color4f(0.75f, 0.5f, 0.75f, 0.45f);
  305. PrimBuild::begin(GFXTriangleFan, rFan.windingCount);
  306. for (k = 0; k < rFan.windingCount; k++)
  307. PrimBuild::vertex3fv(mPoints[mWindings[rFan.windingStart + k]].point);
  308. PrimBuild::end();
  309. PrimBuild::color4f(0, 0, 1, 1);
  310. PrimBuild::begin(GFXLineStrip, rFan.windingCount+1);
  311. for (k = 0; k < rFan.windingCount; k++)
  312. PrimBuild::vertex3fv(mPoints[mWindings[rFan.windingStart + k]].point);
  313. PrimBuild::vertex3fv(mPoints[mWindings[rFan.windingStart]].point);
  314. PrimBuild::end();
  315. }
  316. }
  317. }
  318. void Interior::debugShowCollisionFans(const ZoneVisDeterminer& zoneVis)
  319. {
  320. // Set our "base debug states" (no texture)
  321. GFX->setStateBlock(mInteriorDebugNoneSB);
  322. for (U32 i = 0; i < mZones.size(); i++)
  323. {
  324. if (zoneVis.isZoneVisible(i) == false)
  325. continue;
  326. for( U32 j=0; j<mZones[i].surfaceCount; j++ )
  327. {
  328. U32 surfaceIndex = mZoneSurfaces[mZones[i].surfaceStart + j];
  329. Surface& rSurface = mSurfaces[ surfaceIndex ];
  330. U32 numIndices;
  331. U32 fanIndices[32];
  332. collisionFanFromSurface(rSurface, fanIndices, &numIndices);
  333. // Filled brush
  334. PrimBuild::color3f(1.0f, 1.0f, 1.0f);
  335. PrimBuild::begin(GFXTriangleFan, numIndices);
  336. for (U32 i = 0; i < numIndices; i++)
  337. PrimBuild::vertex3fv(mPoints[fanIndices[i]].point);
  338. PrimBuild::end();
  339. // Outline
  340. PrimBuild::color3f(0.0f, 0.0f, 0.0f);
  341. PrimBuild::begin(GFXLineStrip, numIndices+1);
  342. for (U32 i = 0; i < numIndices; i++)
  343. PrimBuild::vertex3fv(mPoints[fanIndices[i]].point);
  344. if (numIndices > 0)
  345. PrimBuild::vertex3fv(mPoints[fanIndices[0]].point);
  346. PrimBuild::end();
  347. // Normal
  348. PrimBuild::color3f(1, 0, 0);
  349. PrimBuild::begin(GFXLineList, numIndices * 2);
  350. for (U32 j = 0; j < numIndices; j++)
  351. {
  352. Point3F up = mPoints[fanIndices[j]].point;
  353. Point3F norm = getPlane(rSurface.planeIndex);
  354. if (planeIsFlipped(rSurface.planeIndex))
  355. up -= norm * 0.4f;
  356. else
  357. up += norm * 0.4f;
  358. PrimBuild::vertex3fv(mPoints[fanIndices[j]].point);
  359. PrimBuild::vertex3fv(up);
  360. }
  361. PrimBuild::end();
  362. }
  363. }
  364. }
  365. // This doesn't show strip (they don't go to the card that way)
  366. // But it does show the batches of primitives we send.
  367. void Interior::debugShowStrips(const ZoneVisDeterminer& zoneVis)
  368. {
  369. // Set up our rendering states.
  370. preDebugRender();
  371. for (U32 i = 0; i < mZones.size(); i++)
  372. {
  373. if (zoneVis.isZoneVisible(i) == false)
  374. continue;
  375. for( U32 j=0; j<mZoneRNList[i].renderNodeList.size(); j++ )
  376. {
  377. RenderNode &node = mZoneRNList[i].renderNodeList[j];
  378. U32 index = (i+j) % 14;
  379. ColorF col((F32)interiorDebugColors[index][0] / 255.0f, (F32)interiorDebugColors[index][1] / 255.0f,
  380. (F32)interiorDebugColors[index][2] / 255.0f);
  381. mDebugShaderConsts->setSafe(mDebugShaderShadeColorSC, col);
  382. GFX->setShaderConstBuffer(mDebugShaderConsts);
  383. GFX->drawPrimitive(node.primInfoIndex);
  384. }
  385. }
  386. GFX->disableShaders();
  387. debugNormalRenderLines(zoneVis);
  388. }
  389. void Interior::debugShowDetailLevel(const ZoneVisDeterminer& zoneVis)
  390. {
  391. // Set up our rendering states.
  392. preDebugRender();
  393. U32 index = getDetailLevel();
  394. ColorF col((F32)interiorDebugColors[index][0] / 255.0f, (F32)interiorDebugColors[index][1] / 255.0f,
  395. (F32)interiorDebugColors[index][2] / 255.0f);
  396. mDebugShaderConsts->setSafe(mDebugShaderShadeColorSC, col);
  397. GFX->setShaderConstBuffer(mDebugShaderConsts);
  398. for (U32 i = 0; i < mZones.size(); i++)
  399. {
  400. if (zoneVis.isZoneVisible(i) == false)
  401. continue;
  402. for( U32 j=0; j<mZoneRNList[i].renderNodeList.size(); j++ )
  403. {
  404. RenderNode &node = mZoneRNList[i].renderNodeList[j];
  405. GFX->drawPrimitive(node.primInfoIndex);
  406. }
  407. }
  408. GFX->disableShaders();
  409. debugNormalRenderLines(zoneVis);
  410. }
  411. void Interior::debugShowHullSurfaces()
  412. {
  413. // Set our "base debug states" (no texture)
  414. GFX->setStateBlock(mInteriorDebugNoneSB);
  415. for (U32 i = 0; i < mConvexHulls.size(); i++)
  416. {
  417. const ConvexHull& rHull = mConvexHulls[i];
  418. for (U32 j = rHull.surfaceStart; j < rHull.surfaceCount + rHull.surfaceStart; j++)
  419. {
  420. U32 index = mHullSurfaceIndices[j];
  421. if (!isNullSurfaceIndex(index))
  422. {
  423. const Interior::Surface& rSurface = mSurfaces[index];
  424. U32 fanVerts[32];
  425. U32 numVerts;
  426. collisionFanFromSurface(rSurface, fanVerts, &numVerts);
  427. PrimBuild::color3i(interiorDebugColors[(i%13)+1][0], interiorDebugColors[(i%13)+1][1],
  428. interiorDebugColors[(i%13)+1][2]);
  429. Point3F center(0, 0, 0);
  430. PrimBuild::begin(GFXTriangleFan, numVerts);
  431. for (U32 k = 0; k < numVerts; k++)
  432. {
  433. PrimBuild::vertex3fv(mPoints[fanVerts[k]].point);
  434. center += mPoints[fanVerts[k]].point;
  435. }
  436. PrimBuild::end();
  437. center /= F32(numVerts);
  438. PrimBuild::color3f(0, 0, 0);
  439. lineLoopFromStrip(mPoints, mWindings, rSurface.windingStart, rSurface.windingCount);
  440. PlaneF plane;
  441. plane.set(mPoints[fanVerts[0]].point, mPoints[fanVerts[1]].point, mPoints[fanVerts[2]].point);
  442. PrimBuild::begin(GFXLineList, 2);
  443. PrimBuild::vertex3fv(center);
  444. PrimBuild::vertex3fv(center + (plane * 0.25));
  445. PrimBuild::end();
  446. }
  447. }
  448. }
  449. }
  450. void Interior::debugDefaultRender(const ZoneVisDeterminer& zoneVis, SceneData &sgData, InteriorInstance *intInst)
  451. {
  452. // Set up a state block with two textures enabled
  453. GFX->setStateBlock(mInteriorDebugTwoTextureSB);
  454. for( U32 i=0; i<getNumZones(); i++ )
  455. {
  456. if (zoneVis.isZoneVisible(i) == false)
  457. continue;
  458. for( U32 j=0; j<mZoneRNList[i].renderNodeList.size(); j++ )
  459. {
  460. RenderNode &node = mZoneRNList[i].renderNodeList[j];
  461. static U16 curBaseTexIndex = 0;
  462. // setup base map
  463. if( node.baseTexIndex != U16_MAX )
  464. curBaseTexIndex = node.baseTexIndex;
  465. // setup lightmap
  466. if( node.lightMapIndex != U8(-1) )
  467. sgData.lightmap = gInteriorLMManager.getHandle(mLMHandle, intInst->getLMHandle(), node.lightMapIndex );
  468. GFX->setTexture( 0, mMaterialList->getDiffuseTexture( curBaseTexIndex ));
  469. GFX->setTexture(1, sgData.lightmap);
  470. GFX->drawPrimitive( node.primInfoIndex );
  471. }
  472. }
  473. }
  474. void Interior::debugShowNullSurfaces(const ZoneVisDeterminer& zoneVis, SceneData &sgData, InteriorInstance *intInst)
  475. {
  476. debugDefaultRender(zoneVis, sgData, intInst);
  477. PrimBuild::color3f(1.0f, 0.0f, 0.0f);
  478. for (U32 i = 0; i < mNullSurfaces.size(); i++)
  479. {
  480. const NullSurface& rSurface = mNullSurfaces[i];
  481. PrimBuild::begin(GFXTriangleFan, rSurface.windingCount);
  482. for (U32 k = 0; k < rSurface.windingCount; k++)
  483. {
  484. PrimBuild::vertex3fv(mPoints[mWindings[rSurface.windingStart+k]].point);
  485. }
  486. PrimBuild::end();
  487. }
  488. }
  489. void Interior::debugShowVehicleHullSurfaces(const ZoneVisDeterminer& zoneVis, SceneData &sgData,
  490. InteriorInstance *intInst)
  491. {
  492. debugDefaultRender(zoneVis, sgData, intInst);
  493. PrimBuild::color3f(1.0f, 0.0f, 0.0f);
  494. for (U32 i = 0; i < mVehicleNullSurfaces.size(); i++)
  495. {
  496. const NullSurface& rSurface = mNullSurfaces[i];
  497. PrimBuild::begin(GFXTriangleFan, rSurface.windingCount);
  498. for (U32 k = 0; k < rSurface.windingCount; k++)
  499. {
  500. PrimBuild::vertex3fv(mPoints[mWindings[rSurface.windingStart+k]].point);
  501. }
  502. }
  503. }
  504. void Interior::debugShowTexturesOnly(const ZoneVisDeterminer& zoneVis, SceneData &sgData,
  505. InteriorInstance *intInst)
  506. {
  507. // Set up a state block with one texture unit enabled
  508. GFX->setStateBlock(mInteriorDebugTextureSB);
  509. for( U32 i=0; i<getNumZones(); i++ )
  510. {
  511. if (zoneVis.isZoneVisible(i) == false)
  512. continue;
  513. for( U32 j=0; j<mZoneRNList[i].renderNodeList.size(); j++ )
  514. {
  515. RenderNode &node = mZoneRNList[i].renderNodeList[j];
  516. static U16 curBaseTexIndex = 0;
  517. // setup base map
  518. if ( node.baseTexIndex != U16_MAX )
  519. curBaseTexIndex = node.baseTexIndex;
  520. GFX->setTexture( 0, mMaterialList->getDiffuseTexture( curBaseTexIndex ));
  521. GFX->drawPrimitive( node.primInfoIndex );
  522. }
  523. }
  524. }
  525. void Interior::debugShowLargeTextures(const ZoneVisDeterminer& zoneVis, SceneData &sgData,
  526. InteriorInstance *intInst)
  527. {
  528. preDebugRender();
  529. for( U32 i=0; i<getNumZones(); i++ )
  530. {
  531. if (zoneVis.isZoneVisible(i) == false)
  532. continue;
  533. for( U32 j=0; j<mZoneRNList[i].renderNodeList.size(); j++ )
  534. {
  535. RenderNode &node = mZoneRNList[i].renderNodeList[j];
  536. static U16 curBaseTexIndex = 0;
  537. // setup base map
  538. if( node.baseTexIndex != U16_MAX )
  539. curBaseTexIndex = node.baseTexIndex;
  540. GFXTexHandle t = mMaterialList->getDiffuseTexture( curBaseTexIndex );
  541. ColorF texSizeColor(1.0f, 1.0f, 1.0f, 1.0f);
  542. if (t)
  543. {
  544. U32 width = t.getWidth();
  545. U32 height = t.getHeight();
  546. if (width <= 256 && height <= 256)
  547. texSizeColor = ColorF(0.25f, 0.25f, 1.0f); // small texture
  548. else if (width <= 512 && height <= 512)
  549. texSizeColor = ColorF(0.25f, 1.0f, 0.25f); // medium texture
  550. else
  551. texSizeColor = ColorF(1.0f, 0.25f, 0.25f); // large texture
  552. }
  553. mDebugShaderConsts->setSafe(mDebugShaderShadeColorSC, texSizeColor);
  554. GFX->setShaderConstBuffer(mDebugShaderConsts);
  555. GFX->setTexture( 0, t);
  556. GFX->drawPrimitive( node.primInfoIndex );
  557. }
  558. }
  559. }
  560. void Interior::debugShowLightmaps(const ZoneVisDeterminer& zoneVis, SceneData &sgData, InteriorInstance *intInst)
  561. {
  562. GFX->setTexture(0, mDebugTexture);
  563. // Set up a state block with two textures enabled
  564. GFX->setStateBlock(mInteriorDebugTwoTextureSB);
  565. for( U32 i=0; i<getNumZones(); i++ )
  566. {
  567. if (zoneVis.isZoneVisible(i) == false)
  568. continue;
  569. for( U32 j=0; j<mZoneRNList[i].renderNodeList.size(); j++ )
  570. {
  571. RenderNode &node = mZoneRNList[i].renderNodeList[j];
  572. // setup lightmap
  573. if( node.lightMapIndex != U8(-1) )
  574. sgData.lightmap = gInteriorLMManager.getHandle(mLMHandle, intInst->getLMHandle(), node.lightMapIndex );
  575. GFX->setTexture(1, sgData.lightmap);
  576. GFX->drawPrimitive( node.primInfoIndex );
  577. }
  578. }
  579. }
  580. #endif