boxEnvironmentProbe.cpp
Engine/source/T3D/lighting/boxEnvironmentProbe.cpp
Public Variables
bool
For frame signal.
Public Functions
ConsoleDocClass(BoxEnvironmentProbe , "@brief An example scene object which renders <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">mesh.\n\n</a>" "This class implements <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> basic <a href="/coding/class/classsceneobject/">SceneObject</a> that can exist in the world at <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> " "3D position and <a href="/coding/file/editortool_8cpp/#editortool_8cpp_1a4cb041169a32ea3d4cacadbb955e06b4">render</a> itself. There are several valid ways <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/editortool_8cpp/#editortool_8cpp_1a4cb041169a32ea3d4cacadbb955e06b4">render</a> an " "object in Torque. This class implements the preferred rendering method which " "is <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> submit <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/structmeshrenderinst/">MeshRenderInst</a> along with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Material, vertex buffer, " "primitive buffer, and transform and allow the <a href="/coding/class/classrendermeshmgr/">RenderMeshMgr</a> handle the " "actual setup and rendering <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">you.\n\n</a>" "See the C++code <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> implementation <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">details.\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Examples\n</a>" )
Detailed Description
Public Variables
ColorI gCanvasClearColor
bool gEditingMission
For frame signal.
Public Functions
ConsoleDocClass(BoxEnvironmentProbe , "@brief An example scene object which renders <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">mesh.\n\n</a>" "This class implements <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> basic <a href="/coding/class/classsceneobject/">SceneObject</a> that can exist in the world at <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> " "3D position and <a href="/coding/file/editortool_8cpp/#editortool_8cpp_1a4cb041169a32ea3d4cacadbb955e06b4">render</a> itself. There are several valid ways <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/editortool_8cpp/#editortool_8cpp_1a4cb041169a32ea3d4cacadbb955e06b4">render</a> an " "object in Torque. This class implements the preferred rendering method which " "is <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> submit <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/structmeshrenderinst/">MeshRenderInst</a> along with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Material, vertex buffer, " "primitive buffer, and transform and allow the <a href="/coding/class/classrendermeshmgr/">RenderMeshMgr</a> handle the " "actual setup and rendering <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">you.\n\n</a>" "See the C++code <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> implementation <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">details.\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Examples\n</a>" )
IMPLEMENT_CO_NETOBJECT_V1(BoxEnvironmentProbe )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 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 "T3D/lighting/boxEnvironmentProbe.h" 25#include "math/mathIO.h" 26#include "scene/sceneRenderState.h" 27#include "console/consoleTypes.h" 28#include "core/stream/bitStream.h" 29#include "materials/baseMatInstance.h" 30#include "console/engineAPI.h" 31#include "gfx/gfxDrawUtil.h" 32#include "gfx/gfxDebugEvent.h" 33#include "gfx/gfxTransformSaver.h" 34#include "math/mathUtils.h" 35#include "gfx/bitmap/gBitmap.h" 36#include "core/stream/fileStream.h" 37#include "core/fileObject.h" 38#include "core/resourceManager.h" 39#include "console/simPersistID.h" 40#include "T3D/gameFunctions.h" 41#include "postFx/postEffect.h" 42#include "renderInstance/renderProbeMgr.h" 43#include "renderInstance/renderProbeMgr.h" 44 45#include "math/util/sphereMesh.h" 46#include "materials/materialManager.h" 47#include "math/util/matrixSet.h" 48#include "gfx/bitmap/cubemapSaver.h" 49 50#include "materials/materialFeatureTypes.h" 51 52#include "materials/shaderData.h" 53#include "gfx/gfxTextureManager.h" 54 55#include "gfx/bitmap/imageUtils.h" 56 57#include "T3D/lighting/IBLUtilities.h" 58 59extern bool gEditingMission; 60extern ColorI gCanvasClearColor; 61 62IMPLEMENT_CO_NETOBJECT_V1(BoxEnvironmentProbe); 63 64ConsoleDocClass(BoxEnvironmentProbe, 65 "@brief An example scene object which renders a mesh.\n\n" 66 "This class implements a basic SceneObject that can exist in the world at a " 67 "3D position and render itself. There are several valid ways to render an " 68 "object in Torque. This class implements the preferred rendering method which " 69 "is to submit a MeshRenderInst along with a Material, vertex buffer, " 70 "primitive buffer, and transform and allow the RenderMeshMgr handle the " 71 "actual setup and rendering for you.\n\n" 72 "See the C++ code for implementation details.\n\n" 73 "@ingroup Examples\n"); 74 75//----------------------------------------------------------------------------- 76// Object setup and teardown 77//----------------------------------------------------------------------------- 78BoxEnvironmentProbe::BoxEnvironmentProbe() : ReflectionProbe() 79{ 80 mCaptureMask = REFLECTION_PROBE_CAPTURE_TYPEMASK; 81 mProbeShapeType = ProbeRenderInst::Box; 82 mAtten = 0.0; 83} 84 85BoxEnvironmentProbe::~BoxEnvironmentProbe() 86{ 87} 88 89//----------------------------------------------------------------------------- 90// Object Editing 91//----------------------------------------------------------------------------- 92void BoxEnvironmentProbe::initPersistFields() 93{ 94 // SceneObject already handles exposing the transform 95 Parent::initPersistFields(); 96 97 addField("attenuation", TypeF32, Offset(mAtten, BoxEnvironmentProbe), "falloff percent"); 98 99 removeField("radius"); 100} 101 102void BoxEnvironmentProbe::inspectPostApply() 103{ 104 Parent::inspectPostApply(); 105 106 mDirty = true; 107 108 // Flag the network mask to send the updates 109 // to the client object 110 setMaskBits(-1); 111} 112 113bool BoxEnvironmentProbe::onAdd() 114{ 115 if (!Parent::onAdd()) 116 return false; 117 118 return true; 119} 120 121void BoxEnvironmentProbe::onRemove() 122{ 123 Parent::onRemove(); 124} 125 126U32 BoxEnvironmentProbe::packUpdate(NetConnection *conn, U32 mask, BitStream *stream) 127{ 128 // Allow the Parent to get a crack at writing its info 129 U32 retMask = Parent::packUpdate(conn, mask, stream); 130 131 if (stream->writeFlag(mask & StaticDataMask)) 132 { 133 stream->write(mAtten); 134 } 135 136 return retMask; 137} 138 139void BoxEnvironmentProbe::unpackUpdate(NetConnection *conn, BitStream *stream) 140{ 141 // Let the Parent read any info it sent 142 Parent::unpackUpdate(conn, stream); 143 144 if (stream->readFlag()) // StaticDataMask 145 { 146 stream->read(&mAtten); 147 mDirty = true; 148 } 149 150 if (mDirty) 151 { 152 updateProbeParams(); 153 } 154} 155 156//----------------------------------------------------------------------------- 157// Object Rendering 158//----------------------------------------------------------------------------- 159 160void BoxEnvironmentProbe::updateProbeParams() 161{ 162 mProbeShapeType = ProbeRenderInst::Box; 163 mProbeInfo.mAtten = mAtten; 164 165 Parent::updateProbeParams(); 166} 167 168void BoxEnvironmentProbe::setPreviewMatParameters(SceneRenderState* renderState, BaseMatInstance* mat) 169{ 170 Parent::setPreviewMatParameters(renderState, mat); 171} 172