Unit CastleScene

Description

Rendering of scenes (TCastleScene).

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TCastleScene Complete loading, processing and rendering of a scene.
Class TCastleSceneList  
Class TCastleRootTransform Root of transformations and scenes (tree of TCastleTransform and TCastleScene).
Class TCastleAbstractPrimitive Base class to express primitives that can be easily added and adjusted inside TCastleViewport.
Class TCastleText Text that is displayed and transformed as TCastleTransform, inside TCastleViewport, and can be manipulated in 3D.
Class TCastleBox Box with configurable size, position and material.
Class TCastleSphere Sphere with configurable size, position and material.
Class TCastlePlane Plane with configurable size, position and material.
Class TCastleCone Cone with configurable size, position and material.
Class TCastleCylinder Cylinder with configurable size, position and material.
Class TCastleImageTransform Image (that you can place within TCastleViewport) with configurable size and repeat.
Class TCastleBackground Background, a skybox with a color gradient to represent sky and ground behind.
Class TCastleFog Control fog in 3D world.
Class TCastleAbstractLight Base class to express lights that can be easily added and adjusted inside TCastleViewport.
Class TCastlePointLight Point light is a point in 3D space that shines uniformly in all directions.
Class TCastleDirectionalLight Directional light shines along a direction in 3D space, simulating a light source far away (like a sun).
Class TCastleSpotLight Spot light shines a cone of light, from a given location, along a direction (-Z in local coordinates).

Types

TBeforeShapeRenderProc = procedure (Shape: TShape) of object;
TRenderingAttributesEvent = TCastleRenderOptionsEvent deprecated 'use TCastleRenderOptionsEvent';
TSceneRenderingAttributes = TCastleRenderOptions deprecated 'use TCastleRenderOptions';
TPrepareResourcesOption = CastleTransform.TPrepareResourcesOption;
TPrepareResourcesOptions = CastleTransform.TPrepareResourcesOptions;
TFrustumCulling = (...);
TCastleSceneClass = class of TCastleScene;
TTriangle4List = specialize TStructList<TTriangle4>;
TUseHeadlight = (...);
TPrimitiveMaterial = (...);

Constants

prRenderSelf = CastleTransform.prRenderSelf;
prRenderClones = CastleTransform.prRenderClones;
prBackground = CastleTransform.prBackground;
prBoundingBox = CastleTransform.prBoundingBox;
prShadowVolume = CastleTransform.prShadowVolume;
bsNone = CastleRenderOptions.bsNone;
bs2D = CastleRenderOptions.bs2D;
bs3D = CastleRenderOptions.bs3D;
weNormal = CastleRenderOptions.weNormal;
weWireframeOnly = CastleRenderOptions.weWireframeOnly;
weSolidWireframe = CastleRenderOptions.weSolidWireframe;
weSilhouette = CastleRenderOptions.weSilhouette;
paDefault = CastleSceneCore.paDefault;
paForceLooping = CastleSceneCore.paForceLooping;
paForceNotLooping = CastleSceneCore.paForceNotLooping;
paLooping = CastleSceneCore.paLooping;
paNotLooping = CastleSceneCore.paNotLooping;
ssRendering = CastleSceneCore.ssRendering;
ssDynamicCollisions = CastleSceneCore.ssDynamicCollisions;
ssVisibleTriangles = CastleSceneCore.ssVisibleTriangles;
ssStaticCollisions = CastleSceneCore.ssStaticCollisions;

Variables

GLContextCache: TGLRendererContextCache;
InternalEnableRendering: Boolean = true;
DynamicBatching: Boolean = false;

Description

Types

TBeforeShapeRenderProc = procedure (Shape: TShape) of object;
 
TRenderingAttributesEvent = TCastleRenderOptionsEvent deprecated 'use TCastleRenderOptionsEvent';

Warning: this symbol is deprecated: use TCastleRenderOptionsEvent

 
TSceneRenderingAttributes = TCastleRenderOptions deprecated 'use TCastleRenderOptions';

Warning: this symbol is deprecated: use TCastleRenderOptions

 
TPrepareResourcesOption = CastleTransform.TPrepareResourcesOption;
 
TPrepareResourcesOptions = CastleTransform.TPrepareResourcesOptions;
 
TFrustumCulling = (...);

Possible checks done while frustum culling.

This is used by TCastleScene.FrustumCulling (what checks should be done when shapes octree is not available) and TCastleScene.OctreeFrustumCulling (what checks should be done when shapes octree is available).

In the second case, checks done by TFrustumCulling are applied after octree traverse. That is, octree already eliminated some shapes, and fully included some other shapes while traversing. TFrustumCulling are used in this case only as a "last resort", to check only the shapes in octree leaves that are in "possibly-colliding" state with frustum.

Generally, more checks mean that more shapes may be eliminated but also that we waste more time on checks themselves. What is optimal depends on given 3D model, and how you expect the player to view it (e.g. if player usually sees the whole model, then TFrustumCulling checks may be useless waste of time; OTOH, if player stands inside the model composed from many shapes then TFrustumCulling may help).

Values
  • fcNone: No checks.

    Setting this as TCastleScene.FrustumCulling turns off frustum culling entirely, which is usually not a wise thing to do. Setting this as TCastleScene.OctreeFrustumCulling means that frustum culling is only done during octree traversal (we only visit octree nodes possibly colliding with frustum), this is also not optimal.

  • fcSphere: Check shape's bounding sphere for collision with frustum.
  • fcBox: Check shape's bounding box for collision with frustum.
  • fcBoth: Check shape's bounding sphere, and then box, for collision with frustum. This is the most rigoristic check, but usually this is a waste of time: in most cases, when bounding sphere collides, then bounding box collides too.
TCastleSceneClass = class of TCastleScene;
 
TTriangle4List = specialize TStructList<TTriangle4>;
 
TUseHeadlight = (...);

Possible value of TCastleRootTransform.UseHeadlight.

Values
TPrimitiveMaterial = (...);

Primitive material type, used by TCastleAbstractPrimitive.Material.

Values
  • pmPhysical
  • pmPhong
  • pmUnlit

Constants

prRenderSelf = CastleTransform.prRenderSelf;
 
prRenderClones = CastleTransform.prRenderClones;
 
prBackground = CastleTransform.prBackground;
 
prBoundingBox = CastleTransform.prBoundingBox;
 
prShadowVolume = CastleTransform.prShadowVolume;
 
bsNone = CastleRenderOptions.bsNone;

We recommend using CastleRenderOptions unit to get these types. But for backward compatibility, they are also available here.

bs2D = CastleRenderOptions.bs2D;
 
bs3D = CastleRenderOptions.bs3D;
 
weNormal = CastleRenderOptions.weNormal;
 
weWireframeOnly = CastleRenderOptions.weWireframeOnly;
 
weSolidWireframe = CastleRenderOptions.weSolidWireframe;
 
weSilhouette = CastleRenderOptions.weSilhouette;
 
paDefault = CastleSceneCore.paDefault;
 
paForceLooping = CastleSceneCore.paForceLooping;
 
paForceNotLooping = CastleSceneCore.paForceNotLooping;
 
paLooping = CastleSceneCore.paLooping;
 
paNotLooping = CastleSceneCore.paNotLooping;
 
ssRendering = CastleSceneCore.ssRendering;
 
ssDynamicCollisions = CastleSceneCore.ssDynamicCollisions;
 
ssVisibleTriangles = CastleSceneCore.ssVisibleTriangles;
 
ssStaticCollisions = CastleSceneCore.ssStaticCollisions;
 

Variables

GLContextCache: TGLRendererContextCache;

Global OpenGL context cache. This caches common things, like textures, shapes, and much more. Our OpenGL resources are currently shared across all OpenGL contexts, and they all automatically share this cache.

InternalEnableRendering: Boolean = true;
 
DynamicBatching: Boolean = false;

Combine (right before rendering) multiple shapes with a similar appearance into one. This can drastically reduce the number of "draw calls", making rendering much faster.


Generated by PasDoc 0.16.0.