Urho3D
Public Member Functions | Private Member Functions | Private Attributes | Friends
Urho3D::View Class Reference

3D rendering view. Includes the main view(s) and any auxiliary views, but not shadow cameras. More...

#include <View.h>

Inheritance diagram for Urho3D::View:
Urho3D::Object Urho3D::RefCounted

List of all members.

Public Member Functions

 View (Context *context)
 Construct.
virtual ~View ()
 Destruct.
bool Define (RenderSurface *renderTarget, Viewport *viewport)
 Define with rendertarget and viewport. Return true if successful.
void Update (const FrameInfo &frame)
 Update and cull objects and construct rendering batches.
void Render ()
 Render batches.
GraphicsGetGraphics () const
 Return graphics subsystem.
RendererGetRenderer () const
 Return renderer subsystem.
SceneGetScene () const
 Return scene.
OctreeGetOctree () const
 Return octree.
CameraGetCamera () const
 Return camera.
RenderSurfaceGetRenderTarget () const
 Return the rendertarget. 0 if using the backbuffer.
const PODVector< Drawable * > & GetGeometries () const
 Return geometry objects.
const PODVector< Drawable * > & GetOccluders () const
 Return occluder objects.
const PODVector< Light * > & GetLights () const
 Return lights.
const Vector< LightBatchQueue > & GetLightQueues () const
 Return light batch queues.
- Public Member Functions inherited from Urho3D::Object
 Object (Context *context)
 Construct.
virtual ~Object ()
 Destruct. Clean up self from event sender & receiver structures.
virtual ShortStringHash GetType () const =0
 Return type hash.
virtual const StringGetTypeName () const =0
 Return type name.
virtual void OnEvent (Object *sender, StringHash eventType, VariantMap &eventData)
 Handle event.
void SubscribeToEvent (StringHash eventType, EventHandler *handler)
 Subscribe to an event that can be sent by any sender.
void SubscribeToEvent (Object *sender, StringHash eventType, EventHandler *handler)
 Subscribe to a specific sender's event.
void UnsubscribeFromEvent (StringHash eventType)
 Unsubscribe from an event.
void UnsubscribeFromEvent (Object *sender, StringHash eventType)
 Unsubscribe from a specific sender's event.
void UnsubscribeFromEvents (Object *sender)
 Unsubscribe from a specific sender's events.
void UnsubscribeFromAllEvents ()
 Unsubscribe from all events.
void UnsubscribeFromAllEventsExcept (const PODVector< StringHash > &exceptions, bool onlyUserData)
 Unsubscribe from all events except those listed, and optionally only those with userdata (script registered events.)
void SendEvent (StringHash eventType)
 Send event to all subscribers.
void SendEvent (StringHash eventType, VariantMap &eventData)
 Send event with parameters to all subscribers.
ContextGetContext () const
 Return execution context.
ObjectGetSubsystem (ShortStringHash type) const
 Return subsystem by type.
ObjectGetEventSender () const
 Return active event sender. Null outside event handling.
EventHandlerGetEventHandler () const
 Return active event handler. Null outside event handling.
bool HasSubscribedToEvent (StringHash eventType) const
 Return whether has subscribed to an event without specific sender.
bool HasSubscribedToEvent (Object *sender, StringHash eventType) const
 Return whether has subscribed to a specific sender's event.
template<class T >
T * GetSubsystem () const
 Template version of returning a subsystem.
- Public Member Functions inherited from Urho3D::RefCounted
 RefCounted ()
 Construct. Allocate the reference count structure and set an initial self weak reference.
virtual ~RefCounted ()
 Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
void AddRef ()
 Increment reference count. Can also be called outside of a SharedPtr for traditional reference counting.
void ReleaseRef ()
 Decrement reference count and delete self if no more references. Can also be called outside of a SharedPtr for traditional reference counting.
int Refs () const
 Return reference count.
int WeakRefs () const
 Return weak reference count.
RefCountRefCountPtr ()
 Return pointer to the reference count structure.

Private Member Functions

 OBJECT (View)
void GetDrawables ()
 Query the octree for drawable objects.
void GetBatches ()
 Construct batches from the drawable objects.
void UpdateGeometries ()
 Update geometries and sort batches.
void GetLitBatches (Drawable *drawable, LightBatchQueue &lightQueue, BatchQueue *alphaQueue, bool useLitBase)
 Get pixel lit batches for a certain light and drawable.
void ExecuteRenderPathCommands ()
 Execute render commands.
void SetRenderTargets (const RenderPathCommand &command)
 Set rendertargets for current render command.
void SetTextures (const RenderPathCommand &command)
 Set textures for current render command.
void RenderQuad (const RenderPathCommand &command)
 Perform a quad rendering command.
bool CheckViewportRead (const RenderPathCommand &command)
 Check if a command reads the rendered scene.
void AllocateScreenBuffers ()
 Allocate needed screen buffers.
void BlitFramebuffer (Texture2D *source, RenderSurface *destination, bool depthWrite)
 Blit the viewport from one surface to another.
void DrawFullscreenQuad (bool nearQuad)
 Draw a fullscreen quad. Shaders and renderstates must have been set beforehand.
void UpdateOccluders (PODVector< Drawable * > &occluders, Camera *camera)
 Query for occluders as seen from a camera.
void DrawOccluders (OcclusionBuffer *buffer, const PODVector< Drawable * > &occluders)
 Draw occluders to occlusion buffer.
void ProcessLight (LightQueryResult &query, unsigned threadIndex)
 Query for lit geometries and shadow casters for a light.
void ProcessShadowCasters (LightQueryResult &query, const PODVector< Drawable * > &drawables, unsigned splitIndex)
 Process shadow casters' visibilities and build their combined view- or projection-space bounding box.
void SetupShadowCameras (LightQueryResult &query)
 Set up initial shadow camera view(s).
void SetupDirLightShadowCamera (Camera *shadowCamera, Light *light, float nearSplit, float farSplit)
 Set up a directional light shadow camera.
void FinalizeShadowCamera (Camera *shadowCamera, Light *light, const IntRect &shadowViewport, const BoundingBox &shadowCasterBox)
 Finalize shadow camera view after shadow casters and the shadow map are known.
void QuantizeDirLightShadowCamera (Camera *shadowCamera, Light *light, const IntRect &shadowViewport, const BoundingBox &viewBox)
 Quantize a directional light shadow camera view to eliminate swimming.
bool IsShadowCasterVisible (Drawable *drawable, BoundingBox lightViewBox, Camera *shadowCamera, const Matrix3x4 &lightView, const Frustum &lightViewFrustum, const BoundingBox &lightViewFrustumBox)
 Check visibility of one shadow caster.
IntRect GetShadowMapViewport (Light *light, unsigned splitIndex, Texture2D *shadowMap)
 Return the viewport for a shadow map split.
void FindZone (Drawable *drawable)
 Find and set a new zone for a drawable when it has moved.
ZoneGetZone (Drawable *drawable)
 Return the drawable's zone, or camera zone if it has override mode enabled.
unsigned GetLightMask (Drawable *drawable)
 Return the drawable's light mask, considering also its zone.
unsigned GetShadowMask (Drawable *drawable)
 Return the drawable's shadow mask, considering also its zone.
unsigned long long GetVertexLightQueueHash (const PODVector< Light * > &vertexLights)
 Return hash code for a vertex light queue.
TechniqueGetTechnique (Drawable *drawable, Material *material)
 Return material technique, considering the drawable's LOD distance.
void CheckMaterialForAuxView (Material *material)
 Check if material should render an auxiliary view (if it has a camera attached.)
void AddBatchToQueue (BatchQueue &queue, Batch &batch, Technique *tech, bool allowInstancing=true, bool allowShadows=true)
 Choose shaders for a batch and add it to queue.
void PrepareInstancingBuffer ()
 Prepare instancing buffer by filling it with all instance transforms.
void SetupLightVolumeBatch (Batch &batch)
 Set up a light volume rendering batch.
void RenderShadowMap (const LightBatchQueue &queue)
 Render a shadow map.
RenderSurfaceGetDepthStencil (RenderSurface *renderTarget)
 Return the proper depth-stencil surface to use for a rendertarget.

Private Attributes

WeakPtr< Graphicsgraphics_
 Graphics subsystem.
WeakPtr< Rendererrenderer_
 Renderer subsystem.
Scenescene_
 Scene to use.
Octreeoctree_
 Octree to use.
Cameracamera_
 Camera to use.
NodecameraNode_
 Camera's scene node.
ZonecameraZone_
 Zone the camera is inside, or default zone if not assigned.
ZonefarClipZone_
 Zone at far clip plane.
OcclusionBufferocclusionBuffer_
 Occlusion buffer for the main camera.
RenderSurfacerenderTarget_
 Destination color rendertarget.
RenderSurfacecurrentRenderTarget_
 Effective color rendertarget to use, may be different if screenbuffers are used.
IntRect viewRect_
 Viewport rectangle.
IntVector2 viewSize_
 Viewport size.
IntVector2 rtSize_
 Rendertarget size.
FrameInfo frame_
 Information of the frame being rendered.
BoundingBox sceneBox_
 Combined bounding box of visible geometries.
unsigned writeBuffer_
 Write screenbuffer index.
unsigned readBuffer_
 Read screenbuffer index.
float minZ_
 Minimum Z value of the visible scene.
float maxZ_
 Maximum Z value of the visible scene.
int materialQuality_
 Material quality level.
int maxOccluderTriangles_
 Maximum number of occluder triangles.
int highestZonePriority_
 Highest zone priority currently visible.
bool cameraZoneOverride_
 Camera zone's override flag.
bool drawShadows_
 Draw shadows flag.
bool deferred_
 Deferred flag. Inferred from the existence of a light volume command in the renderpath.
const RenderPathrenderPath_
 Renderpath.
PODVector< Texture2D * > screenBuffers_
 Intermediate screen buffers used in pingpong copies and OpenGL deferred framebuffer blit.
Vector< PODVector< Drawable * > > tempDrawables_
 Per-thread octree query results.
PODVector< Zone * > zones_
 Visible zones.
PODVector< Drawable * > geometries_
 Visible geometry objects.
PODVector< Drawable * > shadowGeometries_
 Geometry objects visible in shadow maps.
PODVector< Drawable * > nonThreadedGeometries_
 Geometry objects that will be updated in the main thread.
PODVector< Drawable * > threadedGeometries_
 Geometry objects that will be updated in worker threads.
PODVector< Drawable * > occluders_
 Occluder objects.
PODVector< Light * > lights_
 Lights.
PODVector< ShaderVariation * > lightVS_
 Light volume vertex shaders.
PODVector< ShaderVariation * > lightPS_
 Light volume pixel shaders.
HashSet< Drawable * > maxLightsDrawables_
 Drawables that limit their maximum light count.
HashMap< StringHash, Texture2D * > renderTargets_
 Rendertargets defined by the renderpath.
Vector< LightQueryResultlightQueryResults_
 Intermediate light processing results.
Vector< ScenePassInfoscenePasses_
 Info for scene render passes defined by the renderpath.
Vector< LightBatchQueuelightQueues_
 Per-pixel light queues.
HashMap< unsigned long long,
LightBatchQueue
vertexLightQueues_
 Per-vertex light queues.
HashMap< StringHash, BatchQueuebatchQueues_
 Batch queues.

Friends

void CheckVisibilityWork (const WorkItem *item, unsigned threadIndex)
void ProcessLightWork (const WorkItem *item, unsigned threadIndex)

Additional Inherited Members

- Protected Attributes inherited from Urho3D::Object
Contextcontext_
 Execution context.

Detailed Description

3D rendering view. Includes the main view(s) and any auxiliary views, but not shadow cameras.


Member Function Documentation

void Urho3D::View::AllocateScreenBuffers ( )
private

Allocate needed screen buffers.

Todo:
If the last copy is optimized away, this allocates an extra buffer unnecessarily
void Urho3D::View::ExecuteRenderPathCommands ( )
private

Execute render commands.

Todo:
Does not copy the depth buffer
void Urho3D::View::RenderShadowMap ( const LightBatchQueue queue)
private

Render a shadow map.

Todo:
Should remove this adjustment and find a more flexible solution

The documentation for this class was generated from the following files: