Class TShape
Unit
Declaration
type TShape = class(TShapeTree)
Description
Shape is a geometry node Geometry instance and it's State. For VRML >= 2.0, this usually corresponds to a single instance of actual VRML Shape
node. It allows to perform many operations that need to know both geometry and it's current state (parent Shape node, current transformation and such).
This class caches results of methods LocalBoundingBox, BoundingBox, and most others (see TShapeValidities for hints). This means that things work fast, but this also means that you must manually call Changed when you changed some properties of Geometry or contents of State.
But note that you can't change Geometry or State to different objects — they are readonly properties.
Also note that if you're using TCastleSceneCore class then you don't have to worry about calling Changed of items in TCastleSceneCore.Shapes. All you have to do is to call appropriate Changed*
methods of TCastleSceneCore.
Hierarchy
- TObject
- TShapeTree
- TShape
Overview
Methods
constructor Create(const AParentScene: TX3DEventsEngine; const AOriginalGeometry: TAbstractGeometryNode; const AOriginalState: TX3DGraphTraverseState; const ParentInfo: PTraversingInfo); |
|
destructor Destroy; override; |
|
function Geometry: TAbstractGeometryNode; |
|
function State: TX3DGraphTraverseState; |
|
function LocalBoundingBox: TBox3D; |
|
function BoundingBox: TBox3D; |
|
function VerticesCount: Cardinal; overload; |
|
function TrianglesCount: Cardinal; overload; |
|
function VerticesCount(const Ignored: Boolean): Cardinal; overload; deprecated 'use VerticesCount without Boolean argument, it is ignored now'; |
|
function TrianglesCount(const Ignored: Boolean): Cardinal; overload; deprecated 'use TrianglesCount without Boolean argument, it is ignored now'; |
|
function GeometryArrays: TGeometryArrays; |
|
function BoundingSphereCenter: TVector3; |
|
function BoundingSphereRadiusSqr: Single; |
|
function BoundingSphereRadius: Single; |
|
function FrustumBoundingSphereCollisionPossible( const Frustum: TFrustum): TFrustumCollisionPossible; |
|
function FrustumBoundingSphereCollisionPossibleSimple( const Frustum: TFrustum): boolean; |
|
procedure Changed(const InactiveOnly: boolean; const Changes: TX3DChanges); virtual; |
|
function InternalOctreeTriangles: TTriangleOctree; |
|
function InternalTriangleOctreeLimits: POctreeLimits; |
|
function AlphaChannel: TAlphaChannel; |
|
function Blending: boolean; deprecated 'use "AlphaChannel = acBlending"'; |
|
function Transparent: boolean; deprecated 'use "AlphaChannel = acBlending"'; |
|
function Visible: boolean; |
|
function Collidable: boolean; |
|
function RayCollision( const Tag: TMailboxTag; out Intersection: TVector3; out IntersectionDistance: Single; const RayOrigin, RayDirection: TVector3; const ReturnClosestIntersection: boolean; const TriangleToIgnore: PTriangle; const IgnoreMarginAtStart: boolean; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): PTriangle; |
|
function SegmentCollision( const Tag: TMailboxTag; out Intersection: TVector3; out IntersectionDistance: Single; const Pos1, Pos2: TVector3; const ReturnClosestIntersection: boolean; const TriangleToIgnore: PTriangle; const IgnoreMarginAtStart: boolean; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): PTriangle; |
|
function NormalsSmooth(const FromCcw: boolean): TVector3List; |
|
function NormalsFlat(const FromCcw: boolean): TVector3List; |
|
function NormalsCreaseAngle(const FromCcw: boolean; const CreaseAngle: Single): TVector3List; |
|
function EnumerateTextures(const Enumerate: TEnumerateShapeTexturesFunction): Pointer; override; |
|
function UsesTexture(Node: TAbstractTextureNode): boolean; |
|
function ShadowCaster: boolean; |
|
procedure Triangulate(const TriangleEvent: TTriangleEvent; const FrontFaceAlwaysCcw: Boolean = false); |
|
procedure LocalTriangulate(const TriangleEvent: TTriangleEvent; const FrontFaceAlwaysCcw: Boolean = false); |
|
function DebugInfoWithoutChildren: String; override; |
|
function NiceName: string; |
|
function Node: TAbstractShapeNode; |
|
function GeometryParentNodeName: String; deprecated 'use GeometryParentNode.X3DName'; |
|
function GeometryGrandParentNodeName: String; deprecated 'use GeometryGrandParentNode.X3DName'; |
|
function GeometryGrandGrandParentNodeName: String; deprecated 'use GeometryGrandGrandParentNode.X3DName'; |
|
function InternalMaterialProperty: TMaterialProperty; |
|
function MaterialProperty: TMaterialProperty; deprecated 'use InternalMaterialProperty, or (better) do not use it at all -- this is internal'; |
Properties
property OriginalGeometry: TAbstractGeometryNode read FOriginalGeometry; |
|
property OriginalState: TX3DGraphTraverseState read FOriginalState; |
|
property InternalSpatial: TShapeSpatialStructures read FSpatial write SetSpatial; |
|
property DynamicGeometry: Boolean read FDynamicGeometry; |
|
property GeometryParentNode: TX3DNode read FGeometryParentNode; |
|
property GeometryGrandParentNode: TX3DNode read FGeometryGrandParentNode; |
|
property GeometryGrandGrandParentNode: TX3DNode read FGeometryGrandGrandParentNode; |
Description
Methods
constructor Create(const AParentScene: TX3DEventsEngine; const AOriginalGeometry: TAbstractGeometryNode; const AOriginalState: TX3DGraphTraverseState; const ParentInfo: PTraversingInfo); |
|
Constructor. Parameters
|
destructor Destroy; override; |
|
This item has no description. |
function Geometry: TAbstractGeometryNode; |
|
Geometry of this shape. This may come from initial VRML/X3D node graph (see OriginalGeometry), or it may be processed by TAbstractGeometryNode.Proxy for easier handling. |
function State: TX3DGraphTraverseState; |
|
State of this shape. This may come from initial VRML/X3D node graph (see OriginalState), or it may be processed by TAbstractGeometryNode.Proxy for easier handling. Owned by this TShape class. |
function LocalBoundingBox: TBox3D; |
|
Bounding box in local shape coordinates, i.e. disregarging all transformations (any TTransformNode, TCastleTransform) done on top of shape. |
function BoundingBox: TBox3D; |
|
Bounding box in scene coordinates, i.e. in the local coordinates of TCastleSceneCore that owns this shape. The idea is that TCastleSceneCore.LocalBoundingBox is calculated just by summing up the Shape.BoundingBox for each shape. So transformations done using TTransformNode are accounted here. Parent TCastleTransform are not accounted here. |
function VerticesCount: Cardinal; overload; |
|
This item has no description. |
function TrianglesCount: Cardinal; overload; |
|
This item has no description. |
function GeometryArrays: TGeometryArrays; |
|
Decompose the geometry into primitives, with arrays of per-vertex data. |
function BoundingSphereCenter: TVector3; |
|
Calculates bounding sphere based on BoundingBox. In the future this may be changed to use BoundingSphere method of TAbstractGeometryNode, when I will implement it. For now, BoundingSphere is always worse approximation of bounding volume than BoundingBox (i.e. BoundingSphere is always larger) but it may be useful in some cases when detecting collision versus bounding sphere is much faster than detecting them versus bounding box. BoundingSphereRadiusSqr = 0 and |
function BoundingSphereRadiusSqr: Single; |
|
This item has no description. |
function BoundingSphereRadius: Single; |
|
This item has no description. |
function FrustumBoundingSphereCollisionPossible( const Frustum: TFrustum): TFrustumCollisionPossible; |
|
Exactly equivalent to getting BoundingSphereCenter and BoundingSphereRadiusSqr and then using TFrustum.SphereCollisionPossible. But it may be a little faster since it avoids some small speed problems (like copying memory contents when you get values of BoundingSphereXxx properties and checking twice are BoundingSphereXxx calculated). |
function FrustumBoundingSphereCollisionPossibleSimple( const Frustum: TFrustum): boolean; |
|
Exactly equivalent to getting BoundingSphereCenter and BoundingSphereRadiusSqr and then using TFrustum.SphereCollisionPossibleSimple. But it may be a little faster since it avoids some small speed problems. |
procedure Changed(const InactiveOnly: boolean; const Changes: TX3DChanges); virtual; |
|
Notify this shape that you changed a field inside one of it's nodes (automatically done by TCastleSceneCore). This should be called when fields within Shape.Geometry, Shape.State.Last*, Shape.State.ShapeNode or such change. Pass InactiveOnly = Including chTransform in Changes means something more than general chTransform (which means that transformation of children changed, which implicates many things — not only shape changes). Here, chTransform in Changes means that only the transformation of TShape.State changed (so only on fields ignored by EqualsNoTransform). |
function InternalOctreeTriangles: TTriangleOctree; |
|
The dynamic octree containing all triangles. It contains only triangles within this shape. There is no distinction here between collidable / visible (as for TCastleSceneCore octrees), since only the whole shape may be marked as visible and/or collidable, not particular triangles. The triangles are specified in local coordinate system of this shape (that is, they are independent from transformation within State.Transform). This allows the tree to remain unmodified when transformation of this shape changes. This is automatically managed (initialized, updated, and used) by parent TCastleSceneCore. You usually don't need to know about this octree from outside. To initialize this, add ssTriangles to InternalSpatial property, otherwise it's Parent TCastleSceneCore will take care to keep this octree always updated. Parent TCastleSceneCore will also take care of actually using this octree: TCastleSceneCore.OctreeCollisions methods actually use the octrees of specific shapes at the bottom. |
function InternalTriangleOctreeLimits: POctreeLimits; |
|
Properties of created triangle octrees. See TriangleOctree unit comments for description. Default value comes from DefLocalTriangleOctreeLimits. They are used only when the octree is created, so usually you want to set them right before changing InternalSpatial from [] to something else. |
function AlphaChannel: TAlphaChannel; |
|
How should the alpha of the resulting calculation be used. Should we use alpha blending (partial transparency), or alpha test (yes-or-no transparency) or none of it (shape is simply opaque). This is determined looking at the TAppearanceNode.AlphaChannel field. By default, it is acAuto, which in turn means that the final value of this method (which cannot be acAuto) is calculated looking at material, color, texture nodes data (including at texture images contents). |
function Blending: boolean; deprecated 'use "AlphaChannel = acBlending"'; |
|
Warning: this symbol is deprecated: use "AlphaChannel = acBlending" This item has no description. |
function Transparent: boolean; deprecated 'use "AlphaChannel = acBlending"'; |
|
Warning: this symbol is deprecated: use "AlphaChannel = acBlending" This item has no description. |
function Visible: boolean; |
|
Is the shape visible. Most shapes are visible, except when placed in TCollisionNode.Proxy (which allows to define invisible shapes, only for collision purposes). |
function Collidable: boolean; |
|
Is the shape collidable. Most shapes are collidable. One exception is when TAbstractShapeNode.Collision is set to scNone, which disables collisions. Another exception is when the shape is placed inside TCollisionNode children, and then you use TCollisionNode.Enabled to turn off collisions, or TCollisionNode.Proxy to provide alternative geometry for collisions. |
function RayCollision( const Tag: TMailboxTag; out Intersection: TVector3; out IntersectionDistance: Single; const RayOrigin, RayDirection: TVector3; const ReturnClosestIntersection: boolean; const TriangleToIgnore: PTriangle; const IgnoreMarginAtStart: boolean; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): PTriangle; |
|
Equivalent to using OctreeTriangles.RayCollision, except this wil use the mailbox. |
function SegmentCollision( const Tag: TMailboxTag; out Intersection: TVector3; out IntersectionDistance: Single; const Pos1, Pos2: TVector3; const ReturnClosestIntersection: boolean; const TriangleToIgnore: PTriangle; const IgnoreMarginAtStart: boolean; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): PTriangle; |
|
Equivalent to using OctreeTriangles.SegmentCollision, except this wil use the mailbox. |
function NormalsSmooth(const FromCcw: boolean): TVector3List; |
|
Create normals suitable for this shape. You can call this only when Geometry is coordinate-based X3D geometry, implementing Coord and having non-empty coordinates (that is, Geometry.Coord returns For
The normals here are cached. So using these methods makes condiderable speedup if the shape will not change (Changed method) and will need normals many times (e.g. will be rendered many times). |
function NormalsFlat(const FromCcw: boolean): TVector3List; |
|
This item has no description. |
function NormalsCreaseAngle(const FromCcw: boolean; const CreaseAngle: Single): TVector3List; |
|
This item has no description. |
function EnumerateTextures(const Enumerate: TEnumerateShapeTexturesFunction): Pointer; override; |
|
This item has no description. Showing description inherited from TShapeTree.EnumerateTextures. Enumerate all single texture nodes (possibly) used by the shapes. This looks into all shapes (not only active, so e.g. it looks into all Switch/LOD children, not only the chosen one). This checks all possible ways how a texture may be used by a shape, so it looks at material fields, shaders (ComposedShader, CommonSurfaceShader) and more. If Enumerate callbacks returns non-nil for some texture, returns it immediately, and stops further processing. |
function UsesTexture(Node: TAbstractTextureNode): boolean; |
|
Is the texture node Node possibly used by this shape. This is equivalent to checking does EnumerateShapeTextures return this shape. |
function ShadowCaster: boolean; |
|
Check is shape a shadow caster. Looks at Shape's Appearance.shadowCaster field (see https://castle-engine.io/x3d_extensions.php#section_ext_shadow_caster). |
procedure Triangulate(const TriangleEvent: TTriangleEvent; const FrontFaceAlwaysCcw: Boolean = false); |
|
Triangulate shape. Calls TriangleEvent callback for each triangle. LocalTriangulate returns coordinates in local shape transformation (that is, not transformed by State.Transform yet).
Parameters
|
procedure LocalTriangulate(const TriangleEvent: TTriangleEvent; const FrontFaceAlwaysCcw: Boolean = false); |
|
This item has no description. |
function DebugInfoWithoutChildren: String; override; |
|
This item has no description. Showing description inherited from TShapeTree.DebugInfoWithoutChildren. Describe this shape, not recursively. |
function NiceName: string; |
|
This item has no description. |
function Node: TAbstractShapeNode; |
|
Shape node in X3D graph. This is always non-nil for X3D, VRML 2 and all model formats that are imported as X3D, like glTF, Spine, sprite sheets and more. This is |
function GeometryParentNodeName: String; deprecated 'use GeometryParentNode.X3DName'; |
|
Warning: this symbol is deprecated: use GeometryParentNode.X3DName This item has no description. |
function GeometryGrandParentNodeName: String; deprecated 'use GeometryGrandParentNode.X3DName'; |
|
Warning: this symbol is deprecated: use GeometryGrandParentNode.X3DName This item has no description. |
function InternalMaterialProperty: TMaterialProperty; |
|
Material property associated with this shape's material/texture. |
Properties
property OriginalGeometry: TAbstractGeometryNode read FOriginalGeometry; |
|
Original geometry node, that you get from a VRML/X3D graph. |
property OriginalState: TX3DGraphTraverseState read FOriginalState; |
|
Original state, that you get from a VRML/X3D graph. |
property InternalSpatial: TShapeSpatialStructures read FSpatial write SetSpatial; |
|
Which spatial structrues (octrees, for now) should be created and managed. This works analogous to TCastleSceneCore.Spatial, but this manages octrees within this TShape. Parent TCastleSceneCore will take care to keep this value updated, you should only set TCastleSceneCore.Spatial from the outside. |
property DynamicGeometry: Boolean read FDynamicGeometry; |
|
Local geometry changes very often (like every frame). This is automatically detected and set to |
property GeometryParentNode: TX3DNode read FGeometryParentNode; |
|
Parent, grand-parent, grand-grand-parent nodes determined during traversing of the X3D node graph. Note that Only in old VRML 1.0 and Inventor model formats the All these nodes ( |
property GeometryGrandParentNode: TX3DNode read FGeometryGrandParentNode; |
|
This item has no description. |
property GeometryGrandGrandParentNode: TX3DNode read FGeometryGrandGrandParentNode; |
|
This item has no description. |
Generated by PasDoc 0.16.0-snapshot.