Class TCastleScene
Unit
Declaration
type TCastleScene = class(TCastleSceneCore)
Description
Complete loading, processing and rendering of a scene. This is a descendant of TCastleSceneCore that adds efficient rendering.
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleTransform
- TX3DEventsEngine
- TCastleSceneCore
- TCastleScene
Overview
Fields
InternalVisibilityTest: TTestShapeVisibility; |
Methods
function CreateShape(const AGeometry: TAbstractGeometryNode; const AState: TX3DGraphTraverseState; const ParentInfo: PTraversingInfo): TShape; override; |
|
procedure InternalInvalidateBackgroundRenderer; override; |
|
procedure LocalRender(const Params: TRenderParams); override; |
|
procedure LocalRenderShadowVolume(const Params: TRenderParams; const ShadowVolumeRenderer: TBaseShadowVolumeRenderer); override; |
|
procedure ChangeWorld(const Value: TCastleAbstractRootTransform); override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure GLContextClose; override; |
|
procedure PrepareResources(const Options: TPrepareResourcesOptions; const ProgressStep: boolean; const Params: TPrepareParams); override; |
|
procedure BeforeNodesFree(const InternalChangedAll: boolean = false); override; |
|
procedure Setup2D; |
|
procedure FreeResources(Resources: TSceneFreeResources); override; |
|
function Attributes: TCastleRenderOptions; deprecated 'use RenderOptions'; |
|
procedure ViewChangedSuddenly; override; |
|
procedure InternalCameraChanged; override; |
|
function ScreenEffects(Index: Integer): TGLSLProgram; |
|
function ScreenEffectsCount: Integer; |
|
function ScreenEffectsNeedDepth: boolean; |
|
function Clone(const AOwner: TComponent): TCastleScene; |
|
function WasVisible: Boolean; |
Properties
property FrustumCulling: TFrustumCulling
read FFrustumCulling write SetFrustumCulling default fcBox; deprecated 'use simpler ShapeFrustumCulling'; |
|
property OctreeFrustumCulling: TFrustumCulling
read FOctreeFrustumCulling write SetOctreeFrustumCulling default fcBox; deprecated 'use simpler ShapeFrustumCulling'; |
|
property ShapeFrustumCulling: Boolean
read FShapeFrustumCulling write SetShapeFrustumCulling default true; |
|
property SceneFrustumCulling: Boolean
read FSceneFrustumCulling write FSceneFrustumCulling default true; |
|
property ReceiveShadowVolumes: boolean
read FReceiveShadowVolumes write FReceiveShadowVolumes default true; |
|
property DistanceCulling: Single
read FDistanceCulling write SetDistanceCulling default 0; |
|
property RenderOptions: TCastleRenderOptions read GetRenderOptions; |
|
property CastGlobalLights: Boolean
read FCastGlobalLights write SetCastGlobalLights default false; |
Description
Fields
InternalVisibilityTest: TTestShapeVisibility; |
|
Internal override test visibility. |
Methods
function CreateShape(const AGeometry: TAbstractGeometryNode; const AState: TX3DGraphTraverseState; const ParentInfo: PTraversingInfo): TShape; override; |
|
procedure InternalInvalidateBackgroundRenderer; override; |
|
procedure LocalRender(const Params: TRenderParams); override; |
|
procedure LocalRenderShadowVolume(const Params: TRenderParams; const ShadowVolumeRenderer: TBaseShadowVolumeRenderer); override; |
|
Render shadow volume (sides and caps) of this scene, for shadow volume algorithm. Uses ShadowVolumeRenderer for rendering, and to detect if rendering is necessary at all. It will calculate current bounding box (looking at ParentTransform, ParentTransformIsIdentity and LocalBoundingBox method). It always uses silhouette optimization. This is the usual, fast method of rendering shadow volumes. Will not do anything (treat scene like not casting shadows, like CastShadowVolumes = false) if the model is not perfect 2-manifold, i.e. has some BorderEdges (although we could handle some BorderEdges for some points of view, this could leading to rendering artifacts). All shadow quads are generated from scene triangles transformed by ParentTransform. We must be able to correctly detect front and back facing triangles with respect to light position, so ShadowVolumeRenderer.LightPosition and "this scene transformed by ParentTransform" must be in the same coordinate system. If ParentTransformIsIdentity then ParentTransform value is ignored and everything works like ParentTransform = identity matrix (and is a little faster in this special case). Uses TrianglesListShadowCasters and ManifoldEdges and BorderEdges (so you may prefer to prepare it before, e.g. by calling PrepareResources with prShadowVolume included). We look at some RenderOptions, like RenderOptions.Blending, because transparent triangles have to be handled a little differently, and when RenderOptions.Blending = false then all triangles are forced to be opaque. In other words, this takes RenderOptions into account, to cooperate with our Render method. ShadowVolumeRenderer.LightPosition is the light position. ShadowVolumeRenderer.LightPosition[3] must be 1 (to indicate positional light) or 0 (a directional light). It's expected that ShadowVolumeRenderer is already initialized by ShadowVolumeRenderer.InitFrustumAndLight. Faces (both shadow quads and caps) are rendered such that CCW <=> you're looking at it from outside (i.e. it's considered front face of this shadow volume). |
procedure ChangeWorld(const Value: TCastleAbstractRootTransform); override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure GLContextClose; override; |
|
Destroy any associations of this object with current OpenGL context. For example, release any allocated texture names. Generally speaking, destroys everything that is allocated by PrepareResources call. It's harmless to call this method when there are already no associations with current OpenGL context. This is called automatically from the destructor. |
procedure PrepareResources(const Options: TPrepareResourcesOptions; const ProgressStep: boolean; const Params: TPrepareParams); override; |
|
procedure BeforeNodesFree(const InternalChangedAll: boolean = false); override; |
|
procedure Setup2D; |
|
Adjust parameters for rendering 2D scenes. Sets BlendingSort := bs2D, which is good when your transparent objects have proper order along the Z axis (useful e.g. for Spine animations). |
procedure FreeResources(Resources: TSceneFreeResources); override; |
|
function Attributes: TCastleRenderOptions; deprecated 'use RenderOptions'; |
|
Warning: this symbol is deprecated: use RenderOptions |
procedure ViewChangedSuddenly; override; |
|
procedure InternalCameraChanged; override; |
|
function ScreenEffects(Index: Integer): TGLSLProgram; |
|
Screen effects information, used by TCastleViewport.ScreenEffects. ScreenEffectsCount may actually prepare screen effects. |
function ScreenEffectsCount: Integer; |
|
function ScreenEffectsNeedDepth: boolean; |
|
function Clone(const AOwner: TComponent): TCastleScene; |
|
Create a scene with the same contents (X3D scene graph) as this one. The created scene has exactly the same class as this one (we use ClassType.Create to call a virtual constructor). Note that this does not copy other scene attributes, like ProcessEvents or Spatial or rendering attributes in RenderOptions. |
function WasVisible: Boolean; |
|
Whether the scene was (potentially, at least partially) visible in the last rendering event. The "was visible" means that "some shape was visible", that is: some shape passed frustum culling and occlusion culling (see https://castle-engine.io/occlusion_query ) tests. For this method it doesn't matter if the scene contains some lights that only make some other scenes brighter. Or if the scene contains some background that affects TCastleViewport skybox. Only the visibility of shapes matters. If this scene instance is used multiple times within some viewport, or when multiple viewports render the same scene, then it is enough that at least one shape in one of the scene instances was visible last frame. |
Properties
property FrustumCulling: TFrustumCulling
read FFrustumCulling write SetFrustumCulling default fcBox; deprecated 'use simpler ShapeFrustumCulling'; |
|
Warning: this symbol is deprecated: use simpler ShapeFrustumCulling
What kind of per-shape frustum culling do when ShapeFrustumCulling is |
property OctreeFrustumCulling: TFrustumCulling
read FOctreeFrustumCulling write SetOctreeFrustumCulling default fcBox; deprecated 'use simpler ShapeFrustumCulling'; |
|
Warning: this symbol is deprecated: use simpler ShapeFrustumCulling
What kind of per-shape frustum culling do when ShapeFrustumCulling is |
property ShapeFrustumCulling: Boolean
read FShapeFrustumCulling write SetShapeFrustumCulling default true; |
|
Improve performance of rendering by checking for each shape whether it is inside frustum (camera pyramid of view) before rendering. This is almost always a good idea. Exception may be when, in the most common scene position, all the shapes are inside the frustum, or all the shapes are outside the frustum. In this case this check is wasting time, and it matters if you have a lot of shapes. In such case, SceneFrustumCulling will be enough. |
property ReceiveShadowVolumes: boolean
read FReceiveShadowVolumes write FReceiveShadowVolumes default true; |
|
Does this scene receive shadows by shadow volumes. |
property DistanceCulling: Single
read FDistanceCulling write SetDistanceCulling default 0; |
|
Cull shapes farther than this distance. Ignored if <= 0. |
property RenderOptions: TCastleRenderOptions read GetRenderOptions; |
|
Rendering options. You are free to change them at any time. |
property CastGlobalLights: Boolean
read FCastGlobalLights write SetCastGlobalLights default false; |
|
Lights defines by given scene shine on everything in the viewport, including all other TCastleScene. |
Generated by PasDoc 0.16.0.