Castle Game Engine: CastleScene

# Unit CastleScene
Description | Uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables
## Description VRML/X3D complete scene handling and OpenGL rendering (TCastleScene). ## Uses SysUtils Classes CastleVectors CastleBoxes X3DNodes CastleClassUtils CastleUtils CastleSceneCore CastleRenderer GL GLU GLExt CastleBackground CastleGLUtils CastleShapeOctree CastleGLShadowVolumes X3DFields CastleTriangles CastleRendererLights CastleShapes CastleFrustum Castle3D CastleGLShaders FGL CastleGenericLists ## Overview ### Classes, Interfaces, Objects and Records
Name | Description
--- | ---
Class `TSceneRenderingAttributes` |
Class `TGLShape` | TShape descendant for usage within TCastleScene.
Class `TCastleScene` | Complete handling and rendering of a 3D VRML/X3D scene.
Class `TCastleSceneList` |
### Functions and Procedures
`procedure Register;`
### Types
`TTestShapeVisibility = function (Shape: TGLShape): boolean of object;`
`TWireframeEffect = (...);`
`TBeforeShapeRenderProc = procedure (Shape: TShape) of object;`
`TRenderingAttributesEvent = procedure (Attributes: TSceneRenderingAttributes) of object;`
`TPrepareResourcesOption = Castle3D.TPrepareResourcesOption;`
`TPrepareResourcesOptions = Castle3D.TPrepareResourcesOptions;`
`TFrustumCulling = (...);`
`TTriangle4SingleList = specialize TGenericStructList<TTriangle4Single>;`
### Constants
`prRender = Castle3D.prRender;`
`prBackground = Castle3D.prBackground;`
`prBoundingBox = Castle3D.prBoundingBox;`
`prTrianglesListShadowCasters = Castle3D.prTrianglesListShadowCasters;`
`prManifoldAndBorderEdges = Castle3D.prManifoldAndBorderEdges;`
`prShadowVolume = [prTrianglesListShadowCasters, prManifoldAndBorderEdges];`
### Variables
`GLContextCache: TGLRendererContextCache;`
## Description ### Functions and Procedures
`procedure Register;`
### Types
`TTestShapeVisibility = function (Shape: TGLShape): boolean of object;`
`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). WireframeColor and LineWidth are used as wireframe line color/width (regardless of current scene Attributes.Mode value). This usually gives best results when Attributes.Mode = rmPureGeometry. Then current glColor sets the color of the solid model (and, like said before, WireframeColor sets wireframe 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. WireframeColor and LineWidth are used as silhouette line color/width (regardless of current scene Attributes.Mode value). This is sometimes sensible to use with Attributes.Mode = rmPureGeometry. Then current glColor sets the color of the solid model (and, like said before, WireframeColor sets wireframe color).
`TBeforeShapeRenderProc = procedure (Shape: TShape) of object;`
`TRenderingAttributesEvent = procedure (Attributes: TSceneRenderingAttributes) of object;`
`TPrepareResourcesOption = Castle3D.TPrepareResourcesOption;`
`TPrepareResourcesOptions = Castle3D.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.
`TTriangle4SingleList = specialize TGenericStructList<TTriangle4Single>;`
### Constants
`prRender = Castle3D.prRender;`
`prBackground = Castle3D.prBackground;`
`prBoundingBox = Castle3D.prBoundingBox;`
`prTrianglesListShadowCasters = Castle3D.prTrianglesListShadowCasters;`
`prManifoldAndBorderEdges = Castle3D.prManifoldAndBorderEdges;`
`prShadowVolume = [prTrianglesListShadowCasters, prManifoldAndBorderEdges];`
Options to pass to TCastleScene.PrepareResources to make sure that rendering with shadow volumes is as fast as possible. For now this actually could be equal to prManifoldEdges (prTrianglesListShadowCasters has to be prepared while preparing ManifoldEdges edges anyway). But for the future shadow volumes optimizations, it's best to use this constant.
### 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.13.0 on 2013-08-17 21:27:13