Ejemplo n.º 1
0
//----------------------------------------------------------------------------
void Node::GetVisibleSetRenderObject(Culler& rCuller, Bool noCull)
{
	const Camera* pCamera = rCuller.GetCamera();

	// Add this RenderObject if it's not culled. (Its bounding volume is
	// smaller or equal the bounding volume of this node).
	if (mspRenderObject && ((pCamera->GetLayerMask() & mLayerMask) != 0))
	{
		if (GetQuantity() == 0)
		{
			const Vector3F& rCamPos = rCuller.GetCamera()->GetLocation();
			Vector3F pos = mspRenderObjectWorldBound->GetCenter() - rCamPos;

			rCuller.Insert(mspRenderObject, &World, pos);
		}
		else
		{
			UInt savePlaneState = rCuller.GetPlaneState();
			if (noCull || rCuller.IsVisible(mspRenderObjectWorldBound, true))
			{
				const Vector3F& rCamPos = rCuller.GetCamera()->GetLocation();
				Vector3F pos = mspRenderObjectWorldBound->GetCenter() - rCamPos;

				rCuller.Insert(mspRenderObject, &World, pos);
			}

			rCuller.SetPlaneState(savePlaneState);
		}
	}
}
Ejemplo n.º 2
0
//----------------------------------------------------------------------------
void Portal::GetVisibleSet (Culler& culler, bool noCull)
{
    // Visit only the adjacent region if the portal is open.
    if (!Open)
    {
        return;
    }

    // Traverse only through visible portals.
    if (!culler.IsVisible(mNumVertices, mWorldVertices, true))
    {
        return;
    }

    // It is possible that this portal is visited along a path of portals
    // from the current room containing the camera.  Such portals might
    // have a back-facing polygon relative to the camera.  It is not possible
    // to see through these, so cull them.
    const Camera* camera = culler.GetCamera();
    if (mWorldPlane.WhichSide(camera->GetPosition()) < 0)
    {
        return;
    }

    // Save the current frustum.
    float saveFrustum[6];
    const float* frustum = culler.GetFrustum();
    for (int j = 0; j < 6; ++j)
    {
        saveFrustum[j] = frustum[j];
    }

    // If the observer can see through the portal, the culler's frustum may
    // be reduced in size based on the portal geometry.
    float reducedFrustum[6];
    if (ReducedFrustum(culler, reducedFrustum))
    {
        // Use the reduced frustum for drawing the adjacent region.
        culler.SetFrustum(reducedFrustum);

        // Visit the adjacent region and any nonculled objects in it.
        AdjacentRegion->GetVisibleSet(culler, noCull);

        // Restore the previous frustum.
        culler.SetFrustum(saveFrustum);
    }
}
Ejemplo n.º 3
0
//----------------------------------------------------------------------------
void Spatial::OnGetVisibleSet (Culler& culler, bool noCull)
{
    if (Culling == CULL_ALWAYS)
    {
        return;
    }

    if (Culling == CULL_NEVER)
    {
        noCull = true;
    }

    unsigned int savePlaneState = culler.GetPlaneState();
    if (noCull || culler.IsVisible(WorldBound))
    {
        GetVisibleSet(culler, noCull);
    }
    culler.SetPlaneState(savePlaneState);
}