Unit CastleScene

Description

Rendering of scenes (TCastleScene).

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TSceneRenderingAttributes Rendering attributes, available for every scene through TCastleScene.Attributes.
Class TCastleScene Complete loading, processing and rendering of a scene.
Class TCastleSceneList  

Functions and Procedures

procedure Register;

Types

TWireframeEffect = (...);
TBeforeShapeRenderProc = procedure (Shape: TShape) of object;
TRenderingAttributesEvent = procedure (Attributes: TSceneRenderingAttributes) of object;
TPrepareResourcesOption = CastleTransform.TPrepareResourcesOption;
TPrepareResourcesOptions = CastleTransform.TPrepareResourcesOptions;
TFrustumCulling = (...);
TTriangle4List = specialize TStructList<TTriangle4>;

Constants

prRender = CastleTransform.prRender;
prBackground = CastleTransform.prBackground;
prBoundingBox = CastleTransform.prBoundingBox;
prShadowVolume = CastleTransform.prShadowVolume;
bsNone = CastleBoxes.bsNone;
bs2D = CastleBoxes.bs2D;
bs3D = CastleBoxes.bs3D;
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;

Description

Functions and Procedures

procedure Register;
 

Types

TWireframeEffect = (...);

Values for TSceneRenderingAttributes.WireframeEffect.

Generally, two other attributes may affect the way wireframe is rendered: TSceneRenderingAttributes.WireframeColor and TSceneRenderingAttributes.LineWidth, quite self-explanatory.

Values
  • weNormal: Default setting, model polygons are simply passed to OpenGL. Whether this results in filled or wireframe look, depends on OpenGL glPolygonMode setting, filled by default.
  • weWireframeOnly: The model is rendered in wireframe mode.

    LineWidth is used as wireframe line width (regardless of TSceneRenderingAttributes.Mode).

    Depending on TSceneRenderingAttributes.Mode value:

    • If <> rmFull then WireframeColor is used as wireframe line color.

    • If rmFull, then lines are colored and potentially lighted and textured just like their corresponding triangles would be colored. So you can control lighting using Lighting, UseSceneLights etc. attributes, and you can control texturing by EnableTextures attribute.

  • weSolidWireframe: The model is rendered as normal, with it's wireframe version visible on top. This is most often called "solid wireframe", since the intention is too see wireframe version of the model but still render shapes solid (e.g. filled polygons with depth test).

    Scene.Attributes.WireframeColor and Scene.Attributes.LineWidth determine the color and width of lines.

    This is often used together with the Attributes.Mode set to rmSolidColor. In such case, Then TRenderingAttributes.SolidColor determinesthe fill color.

  • weSilhouette: The model is rendered as normal, with silhouette outlined around it. This works quite like weSolidWireframe, except that weSolidWireframe makes the wireframe mesh slightly in front the model, while weSilhouette makes the wireframe mesh slightly at the back of the model. This way only the silhouette is visible from the wireframe rendering.

    Scene.Attributes.WireframeColor and Scene.Attributes.LineWidth determine the color and width of silhouette lines.

    This is often used together with the Attributes.Mode set to rmSolidColor. In such case, Then TRenderingAttributes.SolidColor determinesthe fill color.

TBeforeShapeRenderProc = procedure (Shape: TShape) of object;
 
TRenderingAttributesEvent = procedure (Attributes: TSceneRenderingAttributes) of object;
 
TPrepareResourcesOption = CastleTransform.TPrepareResourcesOption;
 
TPrepareResourcesOptions = CastleTransform.TPrepareResourcesOptions;
 
TFrustumCulling = (...);

Possible checks done while frustum culling.

This is used for 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.
TTriangle4List = specialize TStructList<TTriangle4>;
 

Constants

prRender = CastleTransform.prRender;
 
prBackground = CastleTransform.prBackground;
 
prBoundingBox = CastleTransform.prBoundingBox;
 
prShadowVolume = CastleTransform.prShadowVolume;
 
bsNone = CastleBoxes.bsNone;
 
bs2D = CastleBoxes.bs2D;
 
bs3D = CastleBoxes.bs3D;
 
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.


Generated by PasDoc 0.15.0.