Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers
|
Object TTriangle
Unit
X3DTriangles
Declaration
type TTriangle = object(T3DTriangle)
Description
Triangle in VRML/X3D model. This is the most basic item for our VRML/X3D collision detection routines, returned by octrees descending from TBaseTrianglesOctree.
Hierarchy
Overview
Fields
Methods
Description
Fields
 |
MailboxSavedTag: TMailboxTag; |
|
Tag of an object (like a ray or a line segment) for which we have saved an intersection result. Intersection result is in MailboxIsIntersection, MailboxIntersection, MailboxIntersectionDistance.
To make things correct, we obviously assume that every segment and ray have different tags. Also, tag -1 is reserved. In practice, we simply initialize MailboxSavedTag to -1, and each new segment/ray get consecutive tags starting from 0.
History: a naive implementation at the beginning was not using tags, instead I had MailboxState (empty, ray or segment) and I was storing ray/line vectors (2 TVector3Single values). This had much larger size (6 * SizeOf(Single) + SizeOf(enum) = 28 bytes) than tag, which is important (3D models have easily thousands of TTriangle). And it took longer to compare and assign, so it was working much slower.
|
 |
MailboxIsIntersection: boolean; |
|
|
 |
MailboxIntersectionDistance: Single; |
|
|
Methods
 |
procedure UpdateWorld; |
|
|
 |
function State: TX3DGraphTraverseState; |
|
State of this shape, containing various information about 3D shape. This is a shortcut of TShape(Shape).State.
|
 |
function SegmentDirCollision( out Intersection: TVector3Single; out IntersectionDistance: Single; const Odc0, OdcVector: TVector3Single; const SegmentTag: TMailboxTag): boolean; |
|
Check collisions between TTriangle and ray/segment.
Always use these routines to check for collisions, to use mailboxes if possible. Mailboxes are used only if this was compiled with TRIANGLE_OCTREE_USE_MAILBOX defined.
Increments TriangleCollisionTestsCounter if actual test was done (that is, if we couldn't use mailbox to get the result quickier).
|
 |
function ShapeNode: TAbstractShapeNode; |
|
X3D shape node of this triangle. May be Nil in case of VRML 1.0.
|
 |
function Material: TMaterialNode; |
|
X3D material node of this triangle. May be Nil in case material is not set, or in VRML 1.0.
|
 |
function MaterialNode: TMaterialNode; deprecated 'use Material'; |
|
Warning: this symbol is deprecated: use Material |
 |
function MaterialInfo: TMaterialInfo; |
|
Material information for the material of this triangle. See TMaterialInfo for usage description. Returns Nil when no node determines material properties (which indicates white unlit look).
Returned TMaterialInfo is valid only as long as the underlying Material or CommonSurfaceShader node exists. Do not free it yourself, it will be automatically freed.
|
 |
function Transparency: Single; |
|
Return transparency of this triangle's material. Equivalent to MaterialInfo.Transparency, although a little faster.
|
 |
function IsTransparent: boolean; |
|
Returns True for triangles that are transparent.
|
 |
function IgnoreForShadowRays: boolean; |
|
Returns True for triangles that should be ignored by shadow rays. Returns True for transparent triangles (with Material.Transparency > 0) and non-shadow-casting triangles (with Appearance.shadowCaster = FALSE).
See also
- TBaseTrianglesOctree.IgnoreForShadowRays
- Ignore (return
True) transparent triangles (with Material.Transparency > 0) and non-shadow-casting triangles (with Appearance.shadowCaster = FALSE).
|
 |
function ITexCoord(const Point: TVector3Single): TVector4Single; |
|
For a given position (in world coordinates), return the texture coordinate at this point. It is an interpolated texture coordinate from our per-vertex texture coordinates in TexCoord field.
This assumes that Position actually lies within the triangle.
The ITexCoord2D returns the same, but cut to the first 2 texture coordinate components. Usable for normal 2D textures.
|
 |
function INormal(const Point: TVector3Single): TVector3Single; |
|
For a given position (in world coordinates), return the smooth normal vector at this point. It is an interpolated normal from our per-vertex normals in the Normal field, thus is supports also the case when you have smooth shading (normals change throughout the triangle).
Like the Normal field, the returned vector is a normal vector in the local coordinates. Use INormalWorldSpace to get a normal vector in scene coordinates.
This assumes that Position actally lies within the triangle.
|
 |
function INormalWorldSpace(const Point: TVector3Single): TVector3Single; |
|
For a given position (in world coordinates), return the smooth normal vector at this point, with the resulting normal vector in world coordinates.
See also
- INormal
- For a given position (in world coordinates), return the smooth normal vector at this point.
|
Generated by PasDoc 0.14.0.
|