tsForestItemData.h
Engine/source/forest/ts/tsForestItemData.h
Classes:
class
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 _TSFORESTITEMDATA_H_ 25#define _TSFORESTITEMDATA_H_ 26 27#ifndef _FORESTITEM_H_ 28#include "forest/forestItem.h" 29#endif 30#ifndef _TSSHAPE_H_ 31#include "ts/tsShape.h" 32#endif 33#ifndef _RESOURCEMANAGER_H_ 34#include "core/resourceManager.h" 35#endif 36 37 38class TSShapeInstance; 39class TSLastDetail; 40 41 42class TSForestItemData : public ForestItemData 43{ 44protected: 45 46 typedef ForestItemData Parent; 47 48 bool mIsClientObject; 49 50 // This is setup during forest creation. 51 mutable TSShapeInstance *mShapeInstance; 52 53 Resource<TSShape> mShape; 54 55 Vector<S32> mCollisionDetails; 56 Vector<S32> mLOSDetails; 57 58 TSShapeInstance* _getShapeInstance() const; 59 60 void _loadShape(); 61 62 void _onResourceChanged( const Torque::Path &path ); 63 64 void _checkLastDetail(); 65 66 void _updateCollisionDetails(); 67 68 // ForestItemData 69 void _preload() { _loadShape(); } 70 71public: 72 73 DECLARE_CONOBJECT(TSForestItemData); 74 TSForestItemData(); 75 virtual ~TSForestItemData(); 76 77 bool preload( bool server, String &errorBuffer ); 78 void onRemove(); 79 bool onAdd(); 80 81 virtual void inspectPostApply(); 82 83 TSLastDetail* getLastDetail() const; 84 85 // JCF: need access to this to build convex(s) in ForestConvex 86 TSShapeInstance* getShapeInstance() const { return _getShapeInstance(); } 87 88 const Vector<S32>& getCollisionDetails() const { return mCollisionDetails; } 89 const Vector<S32>& getLOSDetails() const { return mLOSDetails; } 90 91 // ForestItemData 92 const Box3F& getObjBox() const { return mShape ? mShape->mBounds : Box3F::Zero; } 93 bool render( TSRenderState *rdata, const ForestItem& item ) const; 94 ForestCellBatch* allocateBatch() const; 95 bool canBillboard( const SceneRenderState *state, const ForestItem &item, F32 distToCamera ) const; 96 bool buildPolyList( const ForestItem& item, AbstractPolyList *polyList, const Box3F *box ) const { return false; } 97}; 98 99#endif // _TSFORESTITEMDATA_H_ 100