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