Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <vlGraphics/Actor.hpp>
00033
00034 using namespace vl;
00035
00036
00037
00038
00039 Actor::~Actor()
00040 {
00041 dispatchOnActorDelete();
00042 deleteOcclusionQuery();
00043 }
00044
00045 void Actor::setLODs(Renderable* lod0, Renderable* lod1, Renderable* lod2, Renderable* lod3, Renderable* lod4, Renderable* lod5)
00046 {
00047 if (lod0) { VL_CHECK(0<VL_MAX_ACTOR_LOD) setLod(0,lod0); }
00048 if (lod1) { VL_CHECK(1<VL_MAX_ACTOR_LOD) setLod(1,lod1); }
00049 if (lod2) { VL_CHECK(2<VL_MAX_ACTOR_LOD) setLod(2,lod2); }
00050 if (lod3) { VL_CHECK(3<VL_MAX_ACTOR_LOD) setLod(3,lod3); }
00051 if (lod4) { VL_CHECK(4<VL_MAX_ACTOR_LOD) setLod(4,lod4); }
00052 if (lod5) { VL_CHECK(5<VL_MAX_ACTOR_LOD) setLod(5,lod5); }
00053 }
00054
00055 int Actor::evaluateLOD(Camera* camera)
00056 {
00057 if (mLODEvaluator)
00058 return mLODEvaluator->evaluate(this, camera);
00059 else
00060 return 0;
00061 }
00062
00063 void Actor::createOcclusionQuery()
00064 {
00065 VL_CHECK_OGL();
00066 if (!mOcclusionQuery && Has_Occlusion_Query)
00067 glGenQueries(1, &mOcclusionQuery);
00068 VL_CHECK_OGL();
00069 VL_CHECK(mOcclusionQuery)
00070 }
00071
00072 void Actor::deleteOcclusionQuery()
00073 {
00074 if(Has_Occlusion_Query)
00075 {
00076 if (mOcclusionQuery)
00077 {
00078 glDeleteQueries(1, &mOcclusionQuery);
00079 mOcclusionQuery = 0;
00080 }
00081 }
00082 }
00083
00084 bool Actor::boundsDirty() const
00085 {
00086
00087 bool dirty = lod(0)->boundsDirty() || lod(0)->boundsUpdateTick() != mBoundsUpdateTick;
00088
00089
00090 dirty |= transform() && transform()->worldMatrixUpdateTick() != mTransformUpdateTick;
00091
00092 return dirty;
00093 }
00094
00095 void Actor::computeBounds()
00096 {
00097 if ( lod(0) == NULL )
00098 return;
00099
00100 bool geom_update = lod(0)->boundsDirty() || lod(0)->boundsUpdateTick() != mBoundsUpdateTick;
00101
00102 if ( transform() && (geom_update || transform()->worldMatrixUpdateTick() != mTransformUpdateTick) )
00103 {
00104 lod(0)->boundingBox().transformed( mAABB, transform()->worldMatrix() );
00105 mTransformUpdateTick = transform()->worldMatrixUpdateTick();
00106 mSphere = mAABB.isNull() ? Sphere() : mAABB;
00107 mBoundsUpdateTick = lod(0)->boundsUpdateTick();
00108 }
00109 else
00110 if (geom_update)
00111 {
00112 mAABB = lod(0)->boundingBox();
00113 mSphere = mAABB.isNull() ? Sphere() : mAABB;
00114 mBoundsUpdateTick = lod(0)->boundsUpdateTick();
00115 }
00116 }
00117
00118 void Actor::setUniform(Uniform* uniform) { gocUniformSet()->setUniform(uniform); }
00119
00120 const std::vector< ref<Uniform> >& Actor::uniforms() const { return getUniformSet()->uniforms(); }
00121
00122 std::vector< ref<Uniform> >& Actor::uniforms() { return gocUniformSet()->uniforms(); }
00123
00124 void Actor::eraseUniform(const char* name) { if(getUniformSet()) getUniformSet()->eraseUniform(name); }
00125
00126 void Actor::eraseUniform(const Uniform* uniform) { if(getUniformSet()) getUniformSet()->eraseUniform(uniform); }
00127
00128 void Actor::eraseAllUniforms() { if(getUniformSet()) getUniformSet()->eraseAllUniforms(); }
00129
00130 Uniform* Actor::gocUniform(const char* name) { return gocUniformSet()->gocUniform(name); }
00131
00132 Uniform* Actor::getUniform(const char* name) { if (getUniformSet()) return getUniformSet()->getUniform(name); else return NULL; }
00133
00134 const Uniform* Actor::getUniform(const char* name) const { if (getUniformSet()) return getUniformSet()->getUniform(name); else return NULL; }
00135