accumulationVolume.h
Engine/source/T3D/accumulationVolume.h
Classes:
class
A volume in space that blocks visibility.
Detailed Description
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#ifndef _ACCUMULATIONVOLUME_H_ 25#define _ACCUMULATIONVOLUME_H_ 26 27#ifndef _SCENEPOLYHEDRALSPACE_H_ 28#include "scene/scenePolyhedralSpace.h" 29#endif 30 31#ifndef _MSILHOUETTEEXTRACTOR_H_ 32#include "math/mSilhouetteExtractor.h" 33#endif 34 35#ifndef _GFXDEVICE_H_ 36#include "gfx/gfxDevice.h" 37#endif 38 39/// A volume in space that blocks visibility. 40class AccumulationVolume : public ScenePolyhedralSpace 41{ 42 public: 43 44 typedef ScenePolyhedralSpace Parent; 45 46 protected: 47 48 typedef SilhouetteExtractorPerspective< PolyhedronType> SilhouetteExtractorType; 49 50 /// Whether the volume's transform has changed and we need to recompute 51 /// transform-based data. 52 bool mTransformDirty; 53 54 /// World-space points of the volume's polyhedron. 55 Vector< Point3F> mWSPoints; 56 57 /// Silhouette extractor when using perspective projections. 58 SilhouetteExtractorType mSilhouetteExtractor; 59 60 mutable Vector< SceneObject*> mVolumeQueryList; 61 62 // Name (path) of the accumulation texture. 63 String mTextureName; 64 65 // SceneSpace. 66 virtual void _renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat ); 67 68 public: 69 70 GFXTexHandle mAccuTexture; 71 72 AccumulationVolume(); 73 ~AccumulationVolume(); 74 75 // SimObject. 76 DECLARE_CONOBJECT( AccumulationVolume ); 77 DECLARE_DESCRIPTION( "Allows objects in an area to have accumulation effect applied." ); 78 DECLARE_CATEGORY( "3D Scene" ); 79 80 virtual bool onAdd(); 81 virtual void onRemove(); 82 void inspectPostApply(); 83 void setTexture( const String& name ); 84 85 // Static Functions. 86 static void consoleInit(); 87 static void initPersistFields(); 88 static Vector< SimObjectPtr<SceneObject> > smAccuObjects; 89 static Vector< SimObjectPtr<AccumulationVolume> > smAccuVolumes; 90 static void addObject(SimObjectPtr<SceneObject> object); 91 static void removeObject(SimObjectPtr<SceneObject> object); 92 static void refreshVolumes(); 93 static bool _setTexture( void *object, const char *index, const char *data ); 94 static void updateObject(SceneObject* object); 95 96 // Network 97 U32 packUpdate( NetConnection *, U32 mask, BitStream *stream ); 98 void unpackUpdate( NetConnection *, BitStream *stream ); 99 100 // SceneObject. 101 virtual void buildSilhouette( const SceneCameraState& cameraState, Vector< Point3F>& outPoints ); 102 virtual void setTransform( const MatrixF& mat ); 103}; 104 105#endif // !_AccumulationVolume_H_ 106