47 vl::Log::error(
"Portal::computeNormal() error, no portal geometry defined.\n");
52 vl::Log::error(
"Portal::computeNormal() error, no sector bound to this portal.\n");
69 for(
size_t i=0; i<actors()->size(); ++i)
71 actors()->at(i)->computeBounds();
72 aabb += actors()->at(i)->boundingBox();
79 for(
unsigned i=0; i<callbacks().size(); ++i)
80 callbacks()[i]->operator()(cam,psm,
this,p);
87 computePortalNormals();
88 for(
unsigned i=0; i<mSectors.size(); ++i)
90 if (mSectors[i]->volumes().empty())
92 for(
unsigned j=0; j<mSectors[i]->portals().size(); ++j)
93 if (!mSectors[i]->portals()[j]->targetSector())
100 std::map<Portal*, ref<Actor> >::iterator it = mPortalActorMap.find(portal);
101 if (it == mPortalActorMap.end())
103 const fvec4 portal_color =
fvec4(1,0,0,0.25f);
115 for(
unsigned int i=0; i<portal->
geometry().size(); ++i)
118 #if defined(VL_OPENGL) 122 mPortalActorMap[portal] = actor;
123 mTempActors.push_back(actor);
126 mTempActors.push_back(it->second);
131 for(
unsigned i=0; i<mSectors.size(); ++i)
132 for(
size_t j=0; j<mSectors[i]->actors()->size(); ++j)
133 list.
push_back( mSectors[i]->actors()->at(j) );
138 if (cullingEnabled())
140 Sector* start = computeStartingSector(camera);
147 mFrustumStack.clear();
149 mFrustumStack.push_back(camera->
frustum());
154 std::sort(mTempActors.begin(), mTempActors.end());
155 std::vector< ref<Actor> >::iterator new_end = std::unique(mTempActors.begin(), mTempActors.end());
156 for(std::vector<
ref<Actor> >::iterator it = mTempActors.begin(); it != new_end; ++it)
167 for(
size_t j=0; j<sector->
actors()->
size(); ++j)
169 if (isEnabled(sector->
actors()->
at(j)))
173 for(
unsigned i=0; visible && i<mFrustumStack.size(); ++i)
176 mTempActors.push_back( sector->
actors()->
at(j) );
180 for(
unsigned j=0; j<sector->
portals().size(); ++j)
183 renderPortal(sector->
portals()[j].get());
186 if(!sector->
portals()[j]->isOpen())
196 if ( target_sec != prev )
199 for(
unsigned i=0; visible && i<mFrustumStack.size(); ++i)
200 visible = visible & !mFrustumStack[i].cull( sector->
portals()[j]->geometry() );
206 portal_frustum.
planes().resize(sector->
portals()[j]->geometry().size());
208 for(
unsigned i=0; i<sector->
portals()[j]->geometry().size(); ++i)
210 int i2 = (i+1) % sector->
portals()[j]->geometry().size();
220 mFrustumStack.push_back(portal_frustum);
222 visitSector(sector, sector->
portals()[j]->targetSector(), eye, camera);
223 mFrustumStack.pop_back();
231 for(
unsigned i=0; i<mSectors.size(); ++i)
232 for(
unsigned j=0; j<mSectors[i]->portals().size(); ++j)
233 mSectors[i]->portals()[j]->computeNormal();
239 for(
unsigned i=0; i<mSectors.size(); ++i)
241 for(
unsigned j=0; j<mSectors[i]->volumes().size(); ++j)
243 if (sectors()[i]->volumes()[j].isInside(eye))
244 return sectors()[i].get();
247 return externalSector();
Associates a Renderable object to an Effect and Transform.
Sector * computeStartingSector(const Camera *camera)
The SceneManagerPortals calss implements a portal-based hidden surface removal algorithm to efficentl...
const Vector3 & normalize(T_Scalar *len=NULL)
LineWidth * gocLineWidth()
void visitSector(Sector *prev, Sector *sector, const vec3 &eye, const Camera *camera)
Vector4< float > fvec4
A 4 components vector with float precision.
A simple String formatting class.
The Plane class defines a plane using a normal and an origin.
void computePortalNormals()
Compute the normal of the sectors.
void setPlane(unsigned i, const Plane &plane)
A set of planes defining a frustum used for culling purposes (frustum culling).
bool computeNormal()
Computes the normal of the portal polygon.
std::vector< Plane > & planes()
AABB computeBoundingBox()
Returns the bounding box of all the Actors in the sector.
If enabled, blend the incoming RGBA color values with the values in the color buffers, see also BlendFunc for more information.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
void setVertexArray(ArrayAbstract *data)
Conventional vertex array.
ActorCollection * actors()
The Actor object contained in a sector. An actor can be part of multiple sectors. ...
fvec3 cross(const fvec3 &v1, const fvec3 &v2)
std::vector< fvec3 > & geometry()
The set of points defining the shape of the portal. The points must define a planar convex polygon an...
const T * at(size_t i) const
size_t size() const
Returns the number of elements of an array.
The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.
Visualization Library main namespace.
float dot(float a, float b)
const Frustum & frustum() const
The view frustum of the camera used to perform frustum culling.
void set(float linewidth)
void extractActors(ActorCollection &list)
Appends to the given list all the Actors contained in the scene regardless of their visibility...
The AABB class implements an axis-aligned bounding box using vl::real precision.
const mat4 & modelingMatrix() const
Returns the Camera's modelingMatrix() (inverse of the view matrix).
void renderPortal(Portal *portal)
const AABB & boundingBox() const
Returns the bounding box (not guaranteed to be up to date) that contains this Actor.
void extractVisibleActors(ActorCollection &list, const Camera *camera)
Appends to the given list all the visible Actors using the portal culling algorithm.
Shader * shader(int lodi=0, int pass=0)
Utility function, same as 'lod(lodi)->at(pass);'.
Defines the sequence of Shader objects used to render an Actor.
Defines an area containg a set if Actors that is connected to other Sector[s] through its Portal[s]...
Vector3< T_Scalar > getT() const
T_VectorType & at(size_t i)
Defined as a simple subclass of Collection<Actor>, see Collection for more information.
fvec3 vec3
Defined as: 'typedef fvec3 vec3'. See also VL_PIPELINE_PRECISION.
void executeCallbacks(const Camera *cam, SceneManagerPortals *psm, Portal *p)
void computeBounds()
Computes the bounding box and bounding sphere of an Actor if boundsDirty().
void setValue(const fvec4 &color)
void initialize()
Calls computePortalNormals() and performs some error checking.
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Wraps the OpenGL function glDrawArrays().
void enable(EEnable capability)
A planar convex polygon used to define the visibility from one Sector to another. ...
std::vector< ref< Portal > > & portals()
The portals within a sector that connect it to other sectors.
Collection< DrawCall > & drawCalls()
Returns the list of DrawCall objects bound to a Geometry.