123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- #include "T3D/lighting/boxEnvironmentProbe.h"
- #include "math/mathIO.h"
- #include "scene/sceneRenderState.h"
- #include "console/consoleTypes.h"
- #include "core/stream/bitStream.h"
- #include "materials/baseMatInstance.h"
- #include "console/engineAPI.h"
- #include "gfx/gfxDrawUtil.h"
- #include "gfx/gfxDebugEvent.h"
- #include "gfx/gfxTransformSaver.h"
- #include "math/mathUtils.h"
- #include "gfx/bitmap/gBitmap.h"
- #include "core/stream/fileStream.h"
- #include "core/fileObject.h"
- #include "core/resourceManager.h"
- #include "console/simPersistID.h"
- #include "T3D/gameFunctions.h"
- #include "postFx/postEffect.h"
- #include "renderInstance/renderProbeMgr.h"
- #include "renderInstance/renderProbeMgr.h"
- #include "math/util/sphereMesh.h"
- #include "materials/materialManager.h"
- #include "math/util/matrixSet.h"
- #include "gfx/bitmap/cubemapSaver.h"
- #include "materials/materialFeatureTypes.h"
- #include "materials/shaderData.h"
- #include "gfx/gfxTextureManager.h"
- #include "gfx/bitmap/imageUtils.h"
- #include "T3D/lighting/IBLUtilities.h"
- extern bool gEditingMission;
- extern ColorI gCanvasClearColor;
- IMPLEMENT_CO_NETOBJECT_V1(BoxEnvironmentProbe);
- ConsoleDocClass(BoxEnvironmentProbe,
- "@brief An example scene object which renders a mesh.\n\n"
- "This class implements a basic SceneObject that can exist in the world at a "
- "3D position and render itself. There are several valid ways to render an "
- "object in Torque. This class implements the preferred rendering method which "
- "is to submit a MeshRenderInst along with a Material, vertex buffer, "
- "primitive buffer, and transform and allow the RenderMeshMgr handle the "
- "actual setup and rendering for you.\n\n"
- "See the C++ code for implementation details.\n\n"
- "@ingroup Examples\n");
- //-----------------------------------------------------------------------------
- // Object setup and teardown
- //-----------------------------------------------------------------------------
- BoxEnvironmentProbe::BoxEnvironmentProbe() : ReflectionProbe()
- {
- mCaptureMask = REFLECTION_PROBE_CAPTURE_TYPEMASK;
- mProbeShapeType = ProbeInfo::Box;
- mAtten = 0.0;
- }
- BoxEnvironmentProbe::~BoxEnvironmentProbe()
- {
- }
- //-----------------------------------------------------------------------------
- // Object Editing
- //-----------------------------------------------------------------------------
- void BoxEnvironmentProbe::initPersistFields()
- {
- // SceneObject already handles exposing the transform
- Parent::initPersistFields();
- addField("attenuation", TypeF32, Offset(mAtten, BoxEnvironmentProbe), "falloff percent");
- removeField("radius");
- }
- void BoxEnvironmentProbe::inspectPostApply()
- {
- Parent::inspectPostApply();
- mDirty = true;
- // Flag the network mask to send the updates
- // to the client object
- setMaskBits(-1);
- }
- bool BoxEnvironmentProbe::onAdd()
- {
- if (!Parent::onAdd())
- return false;
- return true;
- }
- void BoxEnvironmentProbe::onRemove()
- {
- Parent::onRemove();
- }
- U32 BoxEnvironmentProbe::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
- {
- // Allow the Parent to get a crack at writing its info
- U32 retMask = Parent::packUpdate(conn, mask, stream);
- if (stream->writeFlag(mask & StaticDataMask))
- {
- stream->write(mAtten);
- }
- return retMask;
- }
- void BoxEnvironmentProbe::unpackUpdate(NetConnection *conn, BitStream *stream)
- {
- // Let the Parent read any info it sent
- Parent::unpackUpdate(conn, stream);
- if (stream->readFlag()) // StaticDataMask
- {
- stream->read(&mAtten);
- mDirty = true;
- }
- if (mDirty)
- {
- updateProbeParams();
- }
- }
- //-----------------------------------------------------------------------------
- // Object Rendering
- //-----------------------------------------------------------------------------
- void BoxEnvironmentProbe::updateProbeParams()
- {
- mProbeShapeType = ProbeInfo::Box;
- mProbeInfo.mAtten = mAtten;
- Parent::updateProbeParams();
- }
- void BoxEnvironmentProbe::setPreviewMatParameters(SceneRenderState* renderState, BaseMatInstance* mat)
- {
- Parent::setPreviewMatParameters(renderState, mat);
- }
|