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 Params: TPrepareParams); override; deprecated 'this is internal; use TCastleViewport.PrepareResources to prepare transformations'; |
|
procedure BeforeNodesFree(const InternalChangedAll: boolean = false); override; |
|
function HasColliderMesh: Boolean; override; |
|
procedure ColliderMesh(const TriangleEvent: TTriangleEvent); override; |
|
procedure FreeResources(Resources: TSceneFreeResources); override; |
|
function Attributes: TCastleRenderOptions; deprecated 'use RenderOptions'; |
|
procedure InternalCameraChanged; override; |
|
function InternalScreenEffectsCount: Integer; |
|
function InternalScreenEffectsNeedDepth: boolean; |
|
function Clone(const AOwner: TComponent): TCastleScene; |
|
function WasVisible: Boolean; |
Properties
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 FRenderOptions; |
|
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; |
|
This item has no description. Showing description inherited from TCastleSceneCore.CreateShape. Create TShape (or descendant) instance suitable for this TCastleSceneCore descendant. In this class, this simply creates new TShape instance. If you make a descendant of TCastleSceneCore, you may need to store some per-shape information, and then it may be useful to have your own TShape descendant to carry this information. So you can override this to create your own descendant, and then you're sure that all leafs within Shapes tree are created using this. Example: TCastleScene uses this to create TGLShape. |
procedure InternalInvalidateBackgroundRenderer; override; |
|
This item has no description. |
procedure LocalRender(const Params: TRenderParams); override; |
|
This item has no description. Showing description inherited from TCastleTransform.LocalRender. Collect the things to be rendered now. Override this method if you need to perform custom rendering, by direct OpenGL(ES) calls. Never call this method yourself – the rendering of TCastleViewport will call it when needed. Warning: It is an advanced topic how to make such rendering work, and make it work in a cross-platform way. You will need to understand how OpenGL(ES) works, and you will need to account for how the engine renders things too, to not conflict with the engine – e.g. you will have to use RenderContext for some things. If you're not ready for this, then you're better off not overriding this method, instead just rely on the engine built-in rendering, done by TCastleScene and other components. This method gets parameters (Params) including a full transformation of this scene. In return, it should add the things to be rendered in this frame using Params.AddRenderEvent. Internally: TCastleScene also adds X3D shapes to be rendered to TRenderParams.Collector. But you should not need to deal with TRenderParams.Collector in your own code. TODO: The names |
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 always uses silhouette optimization. This is the usual, fast method of rendering shadow volumes. 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; |
|
This item has no description. Showing description inherited from TCastleTransform.ChangeWorld. Called when the current World that contains this object changes. In the usual case, World corresponds to a TCastleViewport.Items instance, and when this method is called it means that object is added/removed from a viewport. You can ignore this when called with Value equal to current World. Note that each TCastleTransform instance can only be part of one world (TCastleAbstractRootTransform) at a time. Although we may be present many times within the same world. Always remove the TCastleTransform from previous world before adding it to a new one. |
constructor Create(AOwner: TComponent); override; |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override; |
|
This item has no description. Showing description inherited from TCastleTransform.Update. Continuously occuring event, for various tasks. Executed only on instances that have Exists (no need to check this in overridden Update implementation). |
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. |
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 Params: TPrepareParams); override; deprecated 'this is internal; use TCastleViewport.PrepareResources to prepare transformations'; |
|
Warning: this symbol is deprecated: this is internal; use TCastleViewport.PrepareResources to prepare transformations This item has no description. Showing description inherited from TCastleTransform.PrepareResources. Prepare resources, making various methods (like rendering and such) to execute fast. It is usually simpler to call TCastleViewport.PrepareResources then this method. Calling It is best to call this when the rendering context is initailized, e.g. at Application.OnInitialize or later. Calling this method before the rendering context is initialized (e.g. from initializaton section of some unit) will have to skip some preparations, thus reducing the effectiveness of this method. But it is allowed to call this at any time, regardless of the context being initialized, just like e.g. TCastleContainer.LoadSettings (which may call this, to warmup cache). This makes sure that appropriate methods execute as fast as possible. It's never required to call this method — everything will be prepared "as needed" anyway. But if you allow everything to be prepared "as needed", then e.g. the first Render call may take a long time because it may have to prepare resources that will be reused in next Render calls. This may make your program seem slow at the beginning (when rendering resources are being prepared, so at the first frame, or a couple of first animation frames). To avoid this, call this method, showing the user something like "now we're preparing the resources — please wait".
TODO: It is not possible to call this now without TPrepareParams, and to get params you need to access deprecated TCastleViewport.PrepareParams. We advise to call TCastleViewport.PrepareResources instead. We'd like to get rid of TPrepareParams eventually. |
procedure BeforeNodesFree(const InternalChangedAll: boolean = false); override; |
|
This item has no description. Showing description inherited from TCastleSceneCore.BeforeNodesFree. Release all internal associations with your VRML/X3D nodes. In particular, this will release OpenGL resources connected to your nodes. You should always call this before you (may) free some nodes in RootNode. You have to call ChangedAll or Load at sometime after The InternalChangedAll parameter is for internal use. It is set to |
function HasColliderMesh: Boolean; override; |
|
Does this transform have a collision mesh that TCastleMeshCollider can use. |
procedure ColliderMesh(const TriangleEvent: TTriangleEvent); override; |
|
Enumerate triangles for a collision mesh that TCastleMeshCollider can use. |
procedure FreeResources(Resources: TSceneFreeResources); override; |
|
This item has no description. Showing description inherited from TCastleSceneCore.FreeResources. Frees some scene resources, to conserve memory. See TSceneFreeResources documentation. |
function Attributes: TCastleRenderOptions; deprecated 'use RenderOptions'; |
|
Warning: this symbol is deprecated: use RenderOptions This item has no description. |
procedure InternalCameraChanged; override; |
|
This item has no description. |
function InternalScreenEffectsCount: Integer; |
|
This item has no description. |
function InternalScreenEffectsNeedDepth: boolean; |
|
This item has no description. |
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 properties, like ProcessEvents or RenderOptions contents. |
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, distance culling and occlusion culling (see https://castle-engine.io/occlusion_culling ) tests. The result of this method is not affected by:
To summarize and emphasize: for this method, only the visibility of shapes within this scene 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. TODO: For now, occlusion culling doesn't affect this, i.e. if the scene is not visible because occlusion culling. |
Properties
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 FRenderOptions; |
|
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-snapshot.