afxMooring_T3D.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.ffLighting = false;
  54. desc.zDefined = true;
  55. desc.zWriteEnable = false;
  56. axis_sb = GFX->createStateBlock(desc);
  57. }
  58. GFX->setStateBlock(axis_sb);
  59. GFXTransformSaver saver;
  60. GFX->multWorld(getRenderTransform());
  61. PrimBuild::begin(GFXLineList, 6);
  62. PrimBuild::color(LinearColorF(1.0, 0.0, 0.0));
  63. PrimBuild::vertex3f(-0.5, 0.0, 0.0);
  64. PrimBuild::vertex3f( 0.5, 0.0, 0.0);
  65. PrimBuild::color(LinearColorF(0.0, 1.0, 0.0));
  66. PrimBuild::vertex3f( 0.0, -0.5, 0.0);
  67. PrimBuild::vertex3f( 0.0, 0.5, 0.0);
  68. PrimBuild::color(LinearColorF(0.0, 0.0, 1.0));
  69. PrimBuild::vertex3f( 0.0, 0.0, -0.5);
  70. PrimBuild::vertex3f( 0.0, 0.0, 0.5);
  71. PrimBuild::end();
  72. }
  73. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//