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 MaterialInfo: TX3DMaterialInfoAbstract; |
Create material information instance for material of this triangle. See TX3DMaterialInfoAbstract for usage description.
Returns Nil when no Material node is defined, this can happen only for VRML >= 2.0.
Returned TX3DMaterialInfoAbstract is valid only as long as the Material node (for VRML 1.0 or 2.0) on which it was based.
|
 |
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 Normal field. Like them, it is a normal vector in local coordinates.
This assumes that Position actally lies within the triangle.
|
Generated by PasDoc 0.13.0 on 2013-08-17 21:27:17
|