VR-Forces 4.1 Class Documentation
DtSpeedTreeDrawable.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2009 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: DtSpeedTreeDrawable.h,v $ $Revision: 1.11 $ $State: Exp $
7 *******************************************************************************/
8 
12 
13 #pragma once
14 #include <vrvSt/vrvSt.h>
15 #include <vlutil/vlExceptions.h>
16 #include <osg/Drawable>
17 
18 namespace makVrv
19 {
20 
21  class DtDe;
22  class DtSpeedTreeForest;
23  class DtSpeedTreeProfile;
24 
27  class DT_DLL_VRVST DtSpeedTreeDrawable : public osg::Drawable
28  {
29  public:
30 
34  {
36  : mySptFilePath()
37  , myScale(1.0f)
38  , myRotation(0.0f)
39  {
40  myPositionArray[0] = myPositionArray[1] = myPositionArray[2] = 0.0f;
41  }
42 
44  {
45  }
46 
49  std::string mySptFilePath;
50 
52  float myPositionArray[3];
53 
55  float myScale;
56 
58  float myRotation;
59  };
60 
61  typedef std::vector<TreeInstanceRecord> TreeInstanceRecordVector;
62 
63  friend class DtSpeedTreeProfile;
64 
67  DtSpeedTreeDrawable(DtDe& de, DtSpeedTreeForest* forestModel,
68  const std::string& speedTreeDataPathRoot, int randomSeed);
69 
72  const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY );
73 
74  virtual osg::Object* cloneType() const { throw DtCorruptedState("Unable to clone"); } \
75  virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new DtSpeedTreeDrawable (*this,copyop); } \
76  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const DtSpeedTreeDrawable *>(obj)!=NULL; } \
77  virtual const char* libraryName() const { return "vrvSt"; }\
78  virtual const char* className() const { return "DtSpeedTreeForestDrawable"; }
79 
81  virtual ~DtSpeedTreeDrawable();
82 
84  virtual void setProfile(int profile);
85 
87  virtual void drawImplementation(osg::RenderInfo&) const;
88 
90  virtual void setTreesHaveChanged(bool bFlag);
91 
93  virtual bool treesHaveChanged() const;
94 
95 
99  virtual osg::BoundingBox computeBound() const;
100 
103  virtual void setTreeClippingPlane(float fFar);
104 
107  virtual void setTreeLodDistances(float fNear, float fFar);
108 
110  virtual DtSpeedTreeForest* forest();
111 
115  virtual void releaseGLObjects(osg::State* state = 0) const;
116 
117  protected:
118 
121  void rebuildForest(DtSpeedTreeProfile* profile);
122 
123  DtSpeedTreeProfile* getCurrentProfile(unsigned int contextId) const;
124  void setCurrentProfile(unsigned int contextId, DtSpeedTreeProfile* profile);
125 
126  void flushGLObjects(unsigned int contextID) const;
127 
128  //Create a profile with context active
129  void createProfile(unsigned int contextId);
130  void populateForest( DtSpeedTreeProfile* profile, const TreeInstanceRecordVector& recordVector );
131  bool addTree(const TreeInstanceRecord& record );
132 
133  protected:
134 
138  typedef std::map<unsigned int, DtSpeedTreeProfile*> ContextSpecificForestMap;
142 
144 
145  float myFarPlane;
146  float myNearLod;
147  float myFarLod;
148 
149  };
150 }

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)