00001 #include <gfx/CLODTerrainDrawable>
00002
00003 using namespace gfx;
00004 using namespace demeter;
00005 using namespace osg;
00006
00007 DemeterDrawable::DemeterDrawable()
00008 {
00009 _useDisplayList = false;
00010 }
00011
00012 DemeterDrawable::DemeterDrawable(const DemeterDrawable& other,const osg::CopyOp& copyop):Drawable()
00013 {
00014 *this = other;
00015 }
00016
00017 DemeterDrawable::~DemeterDrawable()
00018 {
00019 m_RefTerrain->unref();
00020 }
00021
00022 DemeterDrawable& DemeterDrawable::operator = (const DemeterDrawable& other)
00023 {
00024 m_RefTerrain = other.m_RefTerrain;
00025 return *this;
00026 }
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 void DemeterDrawable::SetTerrain(CLODTerrainRenderer* pTerrain)
00038 {
00039 m_RefTerrain = pTerrain;
00040 }
00041
00042
00043
00044
00045
00046
00047
00048
00049 void DemeterDrawable::setUseDisplayList(const bool flag)
00050 {
00051 if (flag)
00052 Logln("CLODTerrainDrawable: Attempt to use display lists with DemeterDrawable ignored (not supported)");
00053 _useDisplayList = false;
00054 }
00055
00056 void DemeterDrawable::drawImplementation(State& state) const
00057 {
00058 CLODTerrainRenderer* pTerrain = m_RefTerrain.get();
00059 if (pTerrain)
00060 {
00061 pTerrain->ModelViewMatrixChanged();
00062 pTerrain->Render();
00063 pTerrain->DisableTextures();
00064 }
00065 }
00066
00067 bool DemeterDrawable::computeBound() const
00068 {
00069
00070 if (m_RefTerrain.valid())
00071 {
00072 _bbox._min.x() = _bbox._min.y() = _bbox._min.z() = 0.0f;
00073 _bbox._max.x() = m_RefTerrain->GetWidth();
00074 _bbox._max.y() = m_RefTerrain->GetHeight();
00075 _bbox._max.z() = m_RefTerrain->GetMaxElevation();
00076 _bbox_computed = true;
00077 }
00078 return true;
00079 }
00080