MLRClipper.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #include "MLRHeaders.hpp"
  5. extern DWORD gShowBirdView, gEnableDetailTexture, gEnableMultiTexture, gEnableLightMaps;
  6. DrawShapeInformation::DrawShapeInformation()
  7. {
  8. shape = NULL;
  9. state = NULL;
  10. shapeToWorld = NULL;
  11. worldToShape = NULL;
  12. activeLights = NULL;
  13. nrOfActiveLights = 0;
  14. clippingFlags.SetClippingState(0);
  15. };
  16. DrawScalableShapeInformation::DrawScalableShapeInformation() : DrawShapeInformation()
  17. {
  18. scaling = NULL;
  19. paintMe = NULL;
  20. }
  21. DrawEffectInformation::DrawEffectInformation()
  22. {
  23. effect = NULL;
  24. state = NULL;
  25. effectToWorld = NULL;
  26. #if 0
  27. activeLights = NULL;
  28. nrOfActiveLights = 0;
  29. #endif
  30. clippingFlags.SetClippingState(0);
  31. };
  32. DrawScreenQuadsInformation::DrawScreenQuadsInformation()
  33. {
  34. coords = NULL;
  35. colors = NULL;
  36. texCoords = NULL;
  37. onOrOff = NULL;
  38. nrOfQuads = 0;
  39. };
  40. //#############################################################################
  41. //########################### MLRClipper ################################
  42. //#############################################################################
  43. MLRClipper::ClassData*
  44. MLRClipper::DefaultData = NULL;
  45. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. //
  47. void
  48. MLRClipper::InitializeClass()
  49. {
  50. Verify(!DefaultData);
  51. Verify(gos_GetCurrentHeap() == StaticHeap);
  52. DefaultData =
  53. new ClassData(
  54. MLRClipperClassID,
  55. "MidLevelRenderer::MLRClipper",
  56. RegisteredClass::DefaultData
  57. );
  58. Register_Object(DefaultData);
  59. }
  60. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61. //
  62. void
  63. MLRClipper::TerminateClass()
  64. {
  65. Unregister_Object(DefaultData);
  66. delete DefaultData;
  67. DefaultData = NULL;
  68. }
  69. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  70. //
  71. MLRClipper::MLRClipper(AndyDisplay *ad, MLRSorter *s):
  72. RegisteredClass(DefaultData), display(ad)
  73. {
  74. Verify(gos_GetCurrentHeap() == Heap);
  75. frameRate = 0;
  76. usedTime = 0.0f;
  77. nowTime = 0.0f;
  78. sorter = s;
  79. // camMatrix;
  80. }
  81. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. //
  83. MLRClipper::~MLRClipper()
  84. {
  85. if(sorter)
  86. {
  87. Unregister_Object(sorter);
  88. delete sorter;
  89. }
  90. }
  91. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  92. //
  93. void
  94. MLRClipper::StartDraw (
  95. const LinearMatrix4D &camera_to_world,
  96. const Matrix4D &cameraToClip,
  97. const RGBAColor &,
  98. const RGBAColor *background_color,
  99. const MLRState &default_state,
  100. const Scalar *z_value
  101. )
  102. {
  103. Check_Object(this);
  104. //
  105. // No detail under software rasterizer
  106. //
  107. if(Environment.Renderer == 3)
  108. {
  109. gEnableDetailTexture = 0;
  110. }
  111. MLRState::SetAGPAvailable(TRUE==gos_GetMachineInformation(gos_Info_HasAGPAvailable));
  112. MLRState::SetMaxUV(static_cast<float>(gos_GetMachineInformation(gos_Info_GetMaximumUVSize, 256)));
  113. if(MLRState::GetHasMaxUVs() && MLRState::GetMaxUV() < 128.0f)
  114. {
  115. gEnableLightMaps = 0;
  116. }
  117. if(gEnableMultiTexture!=0)
  118. {
  119. MLRState::SetMultitextureLightMap(TRUE==gos_GetMachineInformation(gos_Info_CanMultitextureLightMap));
  120. MLRState::SetMultitextureSpecularMap(TRUE==gos_GetMachineInformation(gos_Info_CanMultitextureSpecularMap));
  121. }
  122. else
  123. {
  124. MLRState::SetMultitextureLightMap(false);
  125. MLRState::SetMultitextureSpecularMap(false);
  126. }
  127. //
  128. // Make viewport the whole screen
  129. //
  130. gos_PushCurrentHeap(Heap);
  131. Scalar z = 1.0f;
  132. DWORD back_color = 0;
  133. bool
  134. fill = false,
  135. clear = false;
  136. if (z_value)
  137. {
  138. Check_Pointer(z_value);
  139. z = *z_value;
  140. fill = true;
  141. }
  142. if (background_color)
  143. {
  144. Check_Pointer(background_color);
  145. back_color = GOSCopyColor(background_color);
  146. clear = true;
  147. }
  148. MLRState::fogColor = back_color;
  149. /* Already done in MC2
  150. gos_SetupViewport(
  151. fill,
  152. z,
  153. clear,
  154. back_color,
  155. 1.0,
  156. 1.0,
  157. 0.0,
  158. 0.0
  159. );
  160. */
  161. gos_SetRenderState( gos_State_Texture, 0 );
  162. gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_OneZero );
  163. gos_SetRenderState( gos_State_Clipping, 0 );
  164. gos_SetRenderState( gos_State_ZWrite, 1 );
  165. gos_SetRenderState( gos_State_Filter, gos_FilterTriLinear );
  166. gos_SetRenderState( gos_State_ZCompare, 1 );
  167. gos_SetRenderState( gos_State_WireframeMode, 0 );
  168. gos_SetRenderState( gos_State_Specular, 0 );
  169. gos_SetRenderState( gos_State_Dither, 0 );
  170. gos_SetRenderState( gos_State_ShadeMode, gos_ShadeGouraud );
  171. gos_SetRenderState( gos_State_TextureMapBlend, gos_BlendModulateAlpha );
  172. gos_SetRenderState( gos_State_AlphaTest, 0 );
  173. gos_SetRenderState( gos_State_Fog, 0 );
  174. sorter->SetFarClipReciprocal((1.0f-cameraToClip(2, 2))/cameraToClip(3, 2));
  175. sorter->StartDraw(default_state);
  176. cameraToWorldMatrix = camera_to_world;
  177. worldToCameraMatrix.Invert(cameraToWorldMatrix);
  178. #ifdef LAB_ONLY
  179. if(gShowBirdView)
  180. {
  181. static YawPitchRange Camera_Direction(-Pi_Over_6, 0.0f, 15.0f);
  182. static Vector2DOf<Scalar> Camera_Shift(0.0f, 0.0f);
  183. static LinearMatrix4D birdsEye = LinearMatrix4D::Identity;
  184. //
  185. //---------------
  186. // Read the mouse
  187. //---------------
  188. //
  189. int
  190. x_delta,
  191. y_delta;
  192. DWORD
  193. buttons;
  194. gos_GetMouseInfo(NULL, NULL, &x_delta, &y_delta, NULL, &buttons);
  195. Scalar
  196. x_speed = x_delta * 0.01f,
  197. y_speed = y_delta * 0.01f;
  198. //
  199. //------------------------------------------------------
  200. // If the left Ctrl button is held down, move the camera
  201. //------------------------------------------------------
  202. //
  203. gosEnum_KeyStatus status = gos_GetKeyStatus(KEY_LCONTROL);
  204. if (status != KEY_FREE && status != KEY_RELEASED)
  205. {
  206. Camera_Direction.pitch += y_speed;
  207. Camera_Direction.yaw -= x_speed;
  208. }
  209. //
  210. //------------------------------------------------------
  211. // If the left Shift button is held down, pan the camera
  212. //------------------------------------------------------
  213. //
  214. status = gos_GetKeyStatus(KEY_LSHIFT);
  215. if (status != KEY_FREE && status != KEY_RELEASED)
  216. {
  217. Camera_Shift.x += x_speed;
  218. Camera_Shift.y += y_speed;
  219. }
  220. //
  221. //----------------------------------------------------------------
  222. // If the left Alt button is held down, zoom the camera in and out
  223. //----------------------------------------------------------------
  224. //
  225. status = gos_GetKeyStatus(KEY_LMENU);
  226. if (status != KEY_FREE && status != KEY_RELEASED)
  227. {
  228. Camera_Direction.range *= 1.0f + 3.0f*y_speed;
  229. Camera_Direction.range = Camera_Direction.range > 0.0f ? Camera_Direction.range : 0.0f;
  230. }
  231. //
  232. //----------------------
  233. // Set the camera matrix
  234. //----------------------
  235. //
  236. birdsEye.BuildRotation(
  237. EulerAngles(Camera_Direction.pitch, Camera_Direction.yaw, 0.0f)
  238. );
  239. UnitVector3D
  240. world_left,
  241. world_up;
  242. birdsEye.GetLocalLeftInWorld(&world_left);
  243. birdsEye.GetLocalUpInWorld(&world_up);
  244. Point3D translation(Camera_Direction);
  245. translation.AddScaled(translation, world_left, Camera_Shift.x);
  246. translation.AddScaled(translation, world_up, Camera_Shift.y);
  247. birdsEye.BuildTranslation(translation);
  248. LinearMatrix4D worldToBird = LinearMatrix4D::Identity;
  249. worldToBird.Multiply(worldToCameraMatrix, birdsEye);
  250. worldToCameraMatrix = worldToBird;
  251. // push the far clip out
  252. Scalar near_clip, far_clip, left_clip, right_clip, top_clip, bottom_clip;
  253. Matrix4D birdToClip;
  254. cameraToClip.GetPerspective(&near_clip, &far_clip, &left_clip, &right_clip, &top_clip, &bottom_clip);
  255. birdToClip.SetPerspective(
  256. near_clip,
  257. far_clip+2*Camera_Direction.range,
  258. left_clip,
  259. right_clip,
  260. top_clip,
  261. bottom_clip
  262. );
  263. worldToClipMatrix.Multiply(worldToCameraMatrix, birdToClip);
  264. }
  265. else
  266. #endif
  267. worldToClipMatrix.Multiply(worldToCameraMatrix, cameraToClip);
  268. cameraPosition = cameraToWorldMatrix;
  269. // Tell_Value(cameraPosition);
  270. sorter->Reset();
  271. allVerticesToDraw.Reset();
  272. #ifdef CalDraw
  273. ToBeDrawnPrimitive::allVerticesToDraw = &allVerticesToDraw;
  274. #endif
  275. MLRPrimitiveBase::InitializeDraw();
  276. #ifdef LAB_ONLY
  277. if(gShowBirdView)
  278. {
  279. DrawShapeInformation drawShapeInfo;
  280. Scalar near_clip, far_clip, left_clip, right_clip, top_clip, bottom_clip;
  281. RGBAColor fruCol(0.0f, 0.5f, 0.0f, 0.5f);
  282. MLRState fruState;
  283. cameraToClip.GetPerspective(&near_clip, &far_clip, &left_clip, &right_clip, &top_clip, &bottom_clip);
  284. drawShapeInfo.shape = new MLRShape(1);
  285. Register_Object(drawShapeInfo.shape);
  286. fruState.SetTextureHandle(0);
  287. fruState.SetRenderDeltaMask(MLRState::TextureMask);
  288. #ifdef OLDFOG
  289. fruState.SetFogMode(MLRState::DisableFogMode);
  290. #else
  291. fruState.SetFogMode(0);
  292. #endif
  293. fruState.SetZBufferCompareOn();
  294. fruState.SetZBufferWriteOn();
  295. fruState.SetBackFaceOff();
  296. fruState.SetWireFrameMode(MLRState::WireFrameAddMode);
  297. fruState.SetFilterMode(MLRState::BiLinearFilterMode);
  298. fruState.SetAlphaMode(MLRState::AlphaInvAlphaMode);
  299. fruState.SetPriority(MLRState::PriorityCount-1);
  300. MLRPrimitiveBase *primitive =
  301. CreateIndexedViewFrustrum_Color_NoLit(
  302. near_clip, far_clip, left_clip, right_clip, top_clip, bottom_clip, fruCol, &fruState
  303. );
  304. drawShapeInfo.shape->Add(primitive);
  305. drawShapeInfo.clippingFlags.SetClippingState(0x3f);
  306. drawShapeInfo.shapeToWorld = &cameraToWorldMatrix;
  307. drawShapeInfo.worldToShape = &worldToCameraMatrix;
  308. DrawShape(&drawShapeInfo);
  309. drawShapeInfo.shape->DetachReference();
  310. gos_SetRenderState( gos_State_Fog, 0);
  311. }
  312. #endif
  313. gos_PopCurrentHeap();
  314. //
  315. // End timing function
  316. //
  317. }
  318. static AffineMatrix4D scaledShapeToWorld;
  319. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  320. //
  321. void
  322. MLRClipper::DrawShape (DrawShapeInformation *dInfo)
  323. {
  324. Check_Object(this);
  325. //
  326. // Statistic timing function
  327. //
  328. gos_PushCurrentHeap(Heap);
  329. MLRShape *shape = dInfo->shape;
  330. MLRPrimitiveBase *primitive = NULL;
  331. if(dInfo->nrOfActiveLights > Limits::Max_Number_Of_Lights_Per_Primitive)
  332. {
  333. dInfo->nrOfActiveLights = Limits::Max_Number_Of_Lights_Per_Primitive;
  334. }
  335. shape->shapeToClipMatrix.Multiply(*dInfo->shapeToWorld, worldToClipMatrix);
  336. shape->worldToShape = dInfo->worldToShape;
  337. shape->InitializePrimitives(true, dInfo->state);
  338. int i, j;
  339. Point3D sp;
  340. int nrOfLightMaps = 0;
  341. sp.Multiply(cameraPosition, *shape->worldToShape);
  342. for(i=0;i<dInfo->nrOfActiveLights;i++)
  343. {
  344. dInfo->activeLights[i]->SetLightToShapeMatrix(*shape->worldToShape);
  345. nrOfLightMaps += (dInfo->activeLights[i]->GetLightMap()) ? 1 : 0;
  346. }
  347. if(!gEnableLightMaps)
  348. {
  349. nrOfLightMaps = 0;
  350. }
  351. gos_GetViewport( &ViewportScalars::MulX, &ViewportScalars::MulY, &ViewportScalars::AddX, &ViewportScalars::AddY );
  352. #ifdef LAB_ONLY
  353. if(gShowBirdView)
  354. {
  355. dInfo->clippingFlags = 0x3f;
  356. #ifdef OLDFOG
  357. dInfo->state.SetFogMode(MLRState::DisableFogMode);
  358. #else
  359. dInfo->state.SetFogMode(0);
  360. #endif
  361. dInfo->state.SetRenderPermissionMask (
  362. dInfo->state.GetRenderPermissionMask() & ~MLRState::FogMask
  363. );
  364. }
  365. #endif
  366. for(i=0;i<shape->numPrimitives;i++)
  367. {
  368. primitive = shape->allPrimitives[i];
  369. Check_Object(primitive);
  370. if(primitive->GetCurrentState().GetDrawNowMode()==MLRState::DrawNowOffMode)
  371. {
  372. ToBeDrawnPrimitive *tbdp = sorter->GetCurrentTBDP();
  373. Check_Pointer(tbdp);
  374. tbdp->primitive = primitive;
  375. tbdp->state = primitive->GetCurrentState();
  376. tbdp->cameraPosition = sp;
  377. tbdp->clippingFlags = dInfo->clippingFlags;
  378. Check_Object(&tbdp->shapeToClipMatrix);
  379. tbdp->shapeToClipMatrix = shape->shapeToClipMatrix;
  380. tbdp->worldToShape = *shape->worldToShape;
  381. Verify(dInfo->nrOfActiveLights <= Limits::Max_Number_Of_Lights_Per_Primitive);
  382. tbdp->nrOfActiveLights = dInfo->nrOfActiveLights;
  383. for(j=0;j<tbdp->nrOfActiveLights;j++)
  384. {
  385. Check_Object(dInfo->activeLights[j]);
  386. tbdp->activeLights[j] = dInfo->activeLights[j];
  387. }
  388. sorter->IncreaseTBDPCounter();
  389. }
  390. else
  391. {
  392. if(nrOfLightMaps)
  393. {
  394. MLRLightMap::SetDrawData
  395. (
  396. &allVerticesToDraw,
  397. &shape->shapeToClipMatrix,
  398. dInfo->clippingFlags,
  399. dInfo->state
  400. );
  401. }
  402. if(primitive->FindBackFace(sp))
  403. {
  404. primitive->Lighting(dInfo->activeLights, dInfo->nrOfActiveLights);
  405. if(dInfo->clippingFlags.GetClippingState() != 0)
  406. {
  407. if(primitive->TransformAndClip(&shape->shapeToClipMatrix, dInfo->clippingFlags, &allVerticesToDraw))
  408. {
  409. if(primitive->GetVisible())
  410. {
  411. for(j=0;j<primitive->GetNumPasses();j++)
  412. {
  413. sorter->DrawPrimitive(primitive, j);
  414. }
  415. }
  416. }
  417. }
  418. else
  419. {
  420. primitive->TransformNoClip(&shape->shapeToClipMatrix, &allVerticesToDraw);
  421. for(j=0;j<primitive->GetNumPasses();j++)
  422. {
  423. sorter->DrawPrimitive(primitive, j);
  424. }
  425. }
  426. #ifdef LAB_ONLY
  427. Set_Statistic(Number_Of_Primitives, Number_Of_Primitives+1);
  428. if(primitive->IsDerivedFrom(MLRIndexedPrimitiveBase::DefaultData))
  429. {
  430. Point3D *coords;
  431. unsigned short *indices;
  432. int nr;
  433. (Cast_Pointer(MLRIndexedPrimitiveBase*, primitive))->GetIndexData(&indices, &nr);
  434. NumAllIndices += nr;
  435. primitive->GetCoordData(&coords, &nr);
  436. NumAllVertices += nr;
  437. Set_Statistic(Index_Over_Vertex_Ratio, (Scalar)NumAllIndices/(Scalar)NumAllVertices);
  438. }
  439. #endif
  440. if(nrOfLightMaps)
  441. {
  442. MLRLightMap::DrawLightMaps(sorter);
  443. }
  444. }
  445. }
  446. }
  447. //
  448. // End timing function
  449. //
  450. gos_PopCurrentHeap();
  451. }
  452. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  453. //
  454. void
  455. MLRClipper::DrawScalableShape (DrawScalableShapeInformation *dInfo)
  456. {
  457. Check_Object(this);
  458. //
  459. // Statistic timing function
  460. //
  461. MLRShape *shape = dInfo->shape;
  462. MLRPrimitiveBase *primitive = NULL;
  463. shape->shapeToClipMatrix.Multiply(*dInfo->shapeToWorld, worldToClipMatrix);
  464. shape->worldToShape = dInfo->worldToShape;
  465. shape->InitializePrimitives(true, dInfo->state, 1);
  466. if(dInfo->scaling != NULL)
  467. {
  468. LinearMatrix4D scale = LinearMatrix4D::Identity;
  469. scale(0,0) = dInfo->scaling->x;
  470. scale(1,1) = dInfo->scaling->y;
  471. scale(2,2) = dInfo->scaling->z;
  472. scaledShapeToWorld.Multiply(scale, *dInfo->shapeToWorld);
  473. shape->shapeToClipMatrix.Multiply(scaledShapeToWorld, worldToClipMatrix);
  474. }
  475. else
  476. {
  477. shape->shapeToClipMatrix.Multiply(*dInfo->shapeToWorld, worldToClipMatrix);
  478. }
  479. shape->worldToShape = NULL;
  480. int i;
  481. gos_GetViewport( &ViewportScalars::MulX, &ViewportScalars::MulY, &ViewportScalars::AddX, &ViewportScalars::AddY );
  482. #ifdef LAB_ONLY
  483. if(gShowBirdView)
  484. {
  485. dInfo->clippingFlags = 0x3f;
  486. }
  487. #endif
  488. for(i=0;i<shape->numPrimitives;i++)
  489. {
  490. primitive = shape->allPrimitives[i];
  491. Check_Object(primitive);
  492. if(dInfo->paintMe)
  493. {
  494. primitive->PaintMe(dInfo->paintMe);
  495. }
  496. if(dInfo->clippingFlags.GetClippingState() != 0)
  497. {
  498. if(primitive->TransformAndClip(&shape->shapeToClipMatrix, dInfo->clippingFlags, &allVerticesToDraw))
  499. {
  500. if(primitive->GetVisible())
  501. {
  502. if(primitive->GetCurrentState().GetDrawNowMode()==MLRState::DrawNowOnMode)
  503. {
  504. sorter->DrawPrimitive(primitive);
  505. }
  506. else
  507. {
  508. sorter->AddPrimitive(primitive);
  509. }
  510. #ifdef LAB_ONLY
  511. Set_Statistic(Number_Of_Primitives, Number_Of_Primitives+1);
  512. #endif
  513. }
  514. }
  515. }
  516. else
  517. {
  518. primitive->TransformNoClip(&shape->shapeToClipMatrix, &allVerticesToDraw);
  519. if(primitive->GetCurrentState().GetDrawNowMode()==MLRState::DrawNowOnMode)
  520. {
  521. sorter->DrawPrimitive(primitive);
  522. }
  523. else
  524. {
  525. sorter->AddPrimitive(primitive);
  526. }
  527. #ifdef LAB_ONLY
  528. Set_Statistic(Number_Of_Primitives, Number_Of_Primitives+1);
  529. #endif
  530. }
  531. }
  532. //
  533. // End timing function
  534. //
  535. }
  536. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  537. //
  538. void
  539. MLRClipper::DrawEffect (DrawEffectInformation *dInfo)
  540. {
  541. //
  542. // Statistic timing function
  543. //
  544. Check_Object(this);
  545. Check_Object(dInfo);
  546. Check_Object(dInfo->effect);
  547. #ifdef LAB_ONLY
  548. if(gShowBirdView)
  549. {
  550. dInfo->clippingFlags = 0x3f;
  551. }
  552. #endif
  553. dInfo->effect->SetEffectToClipMatrix(dInfo->effectToWorld, &worldToClipMatrix);
  554. gos_GetViewport( &ViewportScalars::MulX, &ViewportScalars::MulY, &ViewportScalars::AddX, &ViewportScalars::AddY );
  555. dInfo->effect->Draw(dInfo, &allVerticesToDraw, sorter);
  556. //
  557. // End timing function
  558. //
  559. }
  560. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  561. //
  562. void
  563. MLRClipper::DrawScreenQuads (DrawScreenQuadsInformation *dInfo)
  564. {
  565. //
  566. // Statistic timing function
  567. //
  568. Check_Object(this);
  569. Check_Object(dInfo);
  570. gos_GetViewport( &ViewportScalars::MulX, &ViewportScalars::MulY, &ViewportScalars::AddX, &ViewportScalars::AddY );
  571. GOSVertex *vertices = allVerticesToDraw.GetActualVertexPool();
  572. int i, j;
  573. dInfo->currentNrOfQuads = 0;
  574. for(i=0,j=0;i<dInfo->nrOfQuads;i++)
  575. {
  576. if(dInfo->onOrOff[i] == true)
  577. {
  578. dInfo->currentNrOfQuads += 4;
  579. for(;j<dInfo->currentNrOfQuads;j++)
  580. {
  581. int offset = (i<<2) + (j&3);
  582. Verify(dInfo->coords[offset].x >= 0.0f && dInfo->coords[offset].x <= dInfo->coords[offset].w );
  583. Verify(dInfo->coords[offset].y >= 0.0f && dInfo->coords[offset].y <= dInfo->coords[offset].w );
  584. Verify(dInfo->coords[offset].z >= 0.0f && dInfo->coords[offset].z <= dInfo->coords[offset].w );
  585. vertices[j].x = (1.0f-dInfo->coords[offset].x)*ViewportScalars::MulX + ViewportScalars::AddX;
  586. vertices[j].y = (1.0f-dInfo->coords[offset].y)*ViewportScalars::MulY + ViewportScalars::AddY;
  587. vertices[j].z = dInfo->coords[offset].z;
  588. vertices[j].rhw = dInfo->coords[offset].w;
  589. vertices[j].argb = GOSCopyColor(dInfo->colors + offset);
  590. vertices[j].u = dInfo->texCoords[offset][0];
  591. vertices[j].v = dInfo->texCoords[offset][1];
  592. }
  593. }
  594. }
  595. if(j>0)
  596. {
  597. allVerticesToDraw.Increase(j);
  598. sorter->AddScreenQuads(vertices, dInfo);
  599. }
  600. //
  601. // End timing function
  602. //
  603. }
  604. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  605. //
  606. void
  607. MLRClipper::Clear (unsigned int flags)
  608. {
  609. Check_Object(this);
  610. }