Unit CastleNURBS

Description

Warning: this symbol is deprecated: soon this unit will be renamed to CastleInternalNurbs; you should use NURBS only through the X3D nodes, like TNurbsCurveNode or TNurbsPatchSurfaceNode

Common utilities for NURBS curves and surfaces.

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TNurbsBasisCalculator Calculate NURBS basis functions.
Class TNurbsCurveCalculator Calculate point on a NURBS curve.
Class TNurbsSurfaceCalculator Calculate point on a NURBS surface.
Class EInvalidPiecewiseBezierCount  

Functions and Procedures

function ActualTessellation(const Tessellation: Integer; const Dimension: Cardinal): Cardinal;
function NurbsCurvePoint(const Points: TVector3List; const U: Single; const Order: Cardinal; const Knot, Weight: TDoubleList; const Tangent: PVector3): TVector3;
function NurbsSurfacePoint(const Points: TVector3List; const UDimension, VDimension: Cardinal; const U, V: Single; const UOrder, VOrder: Cardinal; const UKnot, VKnot, Weight: TDoubleList; const Normal: PVector3): TVector3;
procedure NurbsKnotIfNeeded(Knot: TDoubleList; const Dimension, Order: Cardinal; const Kind: TNurbsKnotKind);
function NurbsBoundingBox(Point: TVector3List; Weight: TDoubleList): TBox3D; overload;
function NurbsBoundingBox(Point: TVector3List; Weight: TSingleList): TBox3D; overload;
function NurbsBoundingBox(Point: TVector3List; Weight: TDoubleList; const Transform: TMatrix4): TBox3D; overload;
function NurbsBoundingBox(Point: TVector3List; Weight: TSingleList; const Transform: TMatrix4): TBox3D; overload;

Types

TDoubleArray = array of Double;
TNurbsKnotKind = (...);

Description

Functions and Procedures

function ActualTessellation(const Tessellation: Integer; const Dimension: Cardinal): Cardinal;

Calculate the tessellation (number of NURBS points generated). This follows X3D spec for "an implementation subdividing the surface into an equal number of subdivision steps". Give value of tessellation field, and count of controlPoints.

Returned value is for sure > 0 (never exactly 0).

function NurbsCurvePoint(const Points: TVector3List; const U: Single; const Order: Cardinal; const Knot, Weight: TDoubleList; const Tangent: PVector3): TVector3;

Return point on NURBS curve.

Requires:

  • Points.Count > 0 (not exactly 0).

  • Order >= 2 (X3D and VRML 97 spec require this too).

  • Knot must have exactly PointsCount + Order items.

  • U is between Knot.First and Knot.Last.

Weight will be used only if it has the same length as Points.Count. Otherwise, weight = 1.0 (that is, defining non-rational curve) will be used (this follows X3D spec).

Tangent, if non-nil, will be set to the direction at given point of the curve, pointing from the smaller to larger knot values. It will be normalized. This can be directly useful to generate orientations by X3D NurbsOrientationInterpolator node.

function NurbsSurfacePoint(const Points: TVector3List; const UDimension, VDimension: Cardinal; const U, V: Single; const UOrder, VOrder: Cardinal; const UKnot, VKnot, Weight: TDoubleList; const Normal: PVector3): TVector3;

Return point on NURBS surface.

Requires:

  • UDimension, VDimension > 0 (not exactly 0).

  • Points.Count must match UDimension * VDimension.

  • Order >= 2 (X3D and VRML 97 spec require this too).

  • Each xKnot must have exactly xDimension + Order items.

Weight will be used only if it has the same length as UDimension * VDimension. Otherwise, weight = 1.0 (that is, defining non-rational curve) will be used (this follows X3D spec).

Normal, if non-nil, will be set to the normal at given point of the surface. It will be normalized. You can use this to pass these normals to rendering. Or to generate normals for X3D NurbsSurfaceInterpolator node.

procedure NurbsKnotIfNeeded(Knot: TDoubleList; const Dimension, Order: Cardinal; const Kind: TNurbsKnotKind);

Calculate a default knot, if Knot doesn't already have required number of items. After this, it's guaranteed that Knot.Count is Dimension + Order (just as required by NurbsCurvePoint, NurbsSurfacePoint).

Exceptions raised
EInvalidPiecewiseBezierCount
When you use nkPiecewiseBezier with invalid control points count (Dimension) and Order.
function NurbsBoundingBox(Point: TVector3List; Weight: TDoubleList): TBox3D; overload;
 
function NurbsBoundingBox(Point: TVector3List; Weight: TSingleList): TBox3D; overload;
 
function NurbsBoundingBox(Point: TVector3List; Weight: TDoubleList; const Transform: TMatrix4): TBox3D; overload;
 
function NurbsBoundingBox(Point: TVector3List; Weight: TSingleList; const Transform: TMatrix4): TBox3D; overload;
 

Types

TDoubleArray = array of Double;
 
TNurbsKnotKind = (...);

Type of NURBS knot vector to generate.

Values
  • nkPeriodicUniform: All knot values are evenly spaced, all knots are single. This is good for periodic curves.
  • nkEndpointUniform: Starting and ending knots have Order multiplicity, rest is evenly spaced. The curve hits endpoints.
  • nkPiecewiseBezier: NURBS curve will effectively become a piecewise Bezier curve. The order of NURBS curve will determine the order of Bezier curve, for example NURBS curve with order = 4 results in a cubic Bezier curve.

Generated by PasDoc 0.16.0.