afxMooring_T3D.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #include "afx/arcaneFX.h"
  25. #include "gfx/gfxTransformSaver.h"
  26. #include "gfx/primBuilder.h"
  27. #include "afx/afxChoreographer.h"
  28. #include "afx/ce/afxMooring.h"
  29. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  30. void afxMooring::prepRenderImage(SceneRenderState* state)
  31. {
  32. if (!mDataBlock->display_axis_marker)
  33. return;
  34. ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
  35. ri->renderDelegate.bind(this, &afxMooring::_renderAxisLines);
  36. ri->type = RenderPassManager::RIT_ObjectTranslucent;
  37. ri->translucentSort = true;
  38. ri->defaultKey = (U32)(dsize_t)mDataBlock;
  39. ri->sortDistSq = getWorldBox().getSqDistanceToPoint( state->getCameraPosition() );
  40. state->getRenderPass()->addInst(ri);
  41. }
  42. void afxMooring::_renderAxisLines(ObjectRenderInst *ri, SceneRenderState* state, BaseMatInstance* overrideMat)
  43. {
  44. if (overrideMat)
  45. return;
  46. if (axis_sb.isNull())
  47. {
  48. GFXStateBlockDesc desc;
  49. desc.blendDefined = true;
  50. desc.blendEnable = false;
  51. desc.cullDefined = true;
  52. desc.cullMode = GFXCullNone;
  53. desc.zDefined = true;
  54. desc.zWriteEnable = false;
  55. axis_sb = GFX->createStateBlock(desc);
  56. }
  57. GFX->setStateBlock(axis_sb);
  58. GFXTransformSaver saver;
  59. GFX->multWorld(getRenderTransform());
  60. PrimBuild::begin(GFXLineList, 6);
  61. PrimBuild::color(LinearColorF(1.0, 0.0, 0.0));
  62. PrimBuild::vertex3f(-0.5, 0.0, 0.0);
  63. PrimBuild::vertex3f( 0.5, 0.0, 0.0);
  64. PrimBuild::color(LinearColorF(0.0, 1.0, 0.0));
  65. PrimBuild::vertex3f( 0.0, -0.5, 0.0);
  66. PrimBuild::vertex3f( 0.0, 0.5, 0.0);
  67. PrimBuild::color(LinearColorF(0.0, 0.0, 1.0));
  68. PrimBuild::vertex3f( 0.0, 0.0, -0.5);
  69. PrimBuild::vertex3f( 0.0, 0.0, 0.5);
  70. PrimBuild::end();
  71. }
  72. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//