MeshTex  3.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
MeshEntity Class Reference

Wrapper for a biquadratic Bezier patch mesh entity from Radiant. More...

#include <MeshEntity.h>

List of all members.

Classes

struct  GeneralFunctionFactors
 Type for defining how to manipulate control point or surface values according to some linear combination of various values. More...
struct  RefSliceDescriptor
 Type for choosing a reference slice of a known kind (row or column) and indicating how to use it for reference. More...
struct  RefSliceDescriptorInt
 Type for internal representation of a reference slice of a given kind (row or column), specifying the slice and indicating how to use it for reference. More...
struct  SliceDesignation
 Type for choosing a particular slice of a known kind (row or column). More...
struct  SlicePatchContext
 Type for orienting a slice within a particular patch. More...
struct  SliceTexInfo
 Type for describing the application of a texture along a given slice, on a specified texture axis. More...
class  TexInfoCallbackMethod
 An instance of this class can be used as a MeshEntity::TexInfoCallback, in situations where the callback is a method to be invoked on a target object. More...

Public Types

enum  TextureAxisSelection { S_TEX_AXIS_ONLY, T_TEX_AXIS_ONLY, ALL_TEX_AXES }
 Values that represent the texture axes an operation should manipulate. More...
enum  SliceType { ROW_SLICE_TYPE = 0, COL_SLICE_TYPE = 1, NUM_SLICE_TYPES = 2 }
 Values that represent the kinds of patch mesh slices. More...
typedef Callback1< const char
*, void > 
MessageCallback
 Type for info/warning/error callbacks.
typedef Callback2< float,
float, void > 
TexInfoCallback
 Type for texture scale info callbacks.

Public Member Functions

Lifecycle
 MeshEntity (scene::Node &mesh, const MessageCallback &infoReportCallback, const MessageCallback &warningReportCallback, const MessageCallback &errorReportCallback)
 Constructor.
 ~MeshEntity ()
 Destructor.
Interrogation
bool IsValid () const
 Query if the patch mesh is valid, in the characteristics that this wrapper class cares about.
void GetInfo (const int *refRow, const int *refCol, const TexInfoCallback *rowTexInfoCallback, const TexInfoCallback *colTexInfoCallback)
 Get information about the patch mesh.
Simple modification
void MinAlign (TextureAxisSelection axes)
 For each of the specified texture axes, shift the lowest-valued texture coordinates off of the mesh until an integral texture coordinate (texture boundary) is on the mesh edge.
void MaxAlign (TextureAxisSelection axes)
 For each of the specified texture axes, shift the highest-valued texture coordinates off of the mesh until an integral texture coordinate (texture boundary) is on the mesh edge.
void MinMaxAlignAutoScale (TextureAxisSelection axes)
 For each of the specified texture axes, perform either MinMaxAlignStretch or MinMaxAlignShrink; the chosen operation will be the one with the least absolute change in the value of the texture scale.
void MinMaxAlignStretch (TextureAxisSelection axes)
 For each of the specified texture axes, align a texture boundary to one edge of the mesh, then increase the texture scale to align a texture boundary to the other edge of the mesh as well.
void MinMaxAlignShrink (TextureAxisSelection axes)
 For each of the specified texture axes, align a texture boundary to one edge of the mesh, then decrease the texture scale to align a texture boundary to the other edge of the mesh as well.
Complex modification
void SetScale (SliceType sliceType, const SliceDesignation *alignSlice, const RefSliceDescriptor *refSlice, bool naturalScale, float naturalScaleOrTiles)
 Set the texture scaling along the rows or columns of the mesh.
void GeneralFunction (const GeneralFunctionFactors *sFactors, const GeneralFunctionFactors *tFactors, const SliceDesignation *alignRow, const SliceDesignation *alignCol, const RefSliceDescriptor *refRow, const RefSliceDescriptor *refCol, bool surfaceValues)
 Set the mesh's texture coordinates according to a linear combination of factors.

Private Types

enum  TextureAxis { S_TEX_AXIS = 0, T_TEX_AXIS = 1, NUM_TEX_AXES = 2 }
 Values that represent the kinds of texture axis. More...
enum  PositionAxis { X_POS_AXIS = 0, Y_POS_AXIS = 1, Z_POS_AXIS = 2, NUM_POS_AXES = 3 }
 Values that represent the kinds of position (spatial) axis. More...
enum  ScaleOperation { STRETCH_SCALE_OP, SHRINK_SCALE_OP }
 Values that represent ways of scaling a texture to make it aligned. More...
typedef bool(MeshEntity::* InternalImpl )(TextureAxis axis)
 Function signature for a private method that applies a preset transformation on a given texture axis.

Private Member Functions

Unimplemented to prevent copy/assignment
 MeshEntity (const MeshEntity &)
const MeshEntityoperator= (const MeshEntity &)
Internal state refresh
void UpdatePosMinMax (PositionAxis axis)
 Update the internally stored information for the min and max extent of the mesh on the specified worldspace axis.
void UpdateTexMinMax (TextureAxis axis)
 Update the internally stored information for the min and max extent of the mesh on the specified texture axis.
Radiant state management
void CreateUndoPoint ()
 Interface to the Radiant undo buffer; save the current state of the mesh to allow rollback to this point by an undo operation.
void CommitChanges ()
 Commit the changes to the mesh so that they will be reflected in Radiant.
Argument resolution
int InternalSliceDesignation (const SliceDesignation *sliceDesignation, SliceType sliceType)
 Convert from SliceDesignation to a slice number.
RefSliceDescriptorIntInternalRefSliceDescriptor (const RefSliceDescriptor *refSlice, SliceType sliceType, RefSliceDescriptorInt &refSliceInt)
 Convert from RefSliceDescriptor to RefSliceDescriptorInt.
Subroutines for interrogation
float GetSliceTexScale (SliceType sliceType, int slice, TextureAxis axis, float tiles)
 Given a slice and a number of times that its texture should tile along it, find the appropriate texture scale.
bool GetSliceTexInfo (SliceType sliceType, int slice, TextureAxis axis, SliceTexInfo &info)
 Populate the SliceTexInfo for the indicated slice and texture axis.
void ReportSliceTexInfo (SliceType sliceType, int slice, TextureAxis axis, char *messageBuffer, unsigned messageBufferSize, const TexInfoCallback *texInfoCallback)
 Take the information from GetSliceTexInfo and sanitize it for reporting.
Subroutines for simple modification
void ProcessForAxes (InternalImpl internalImpl, TextureAxisSelection axes)
 Apply some function with the InternalImpl signature to each of the designated texture axes.
void Shift (TextureAxis axis, float shift)
 Add an offset to all control point values for the given texture axis.
void Scale (TextureAxis axis, float scale)
 On the given texture axis, find the distance of all control point values from the current minimum value and multiply that distance by the given scale factor.
bool MinAlignInt (TextureAxis axis)
 Implementation of MinAlign for a single texture axis.
bool MaxAlignInt (TextureAxis axis)
 Implementation of MaxAlign for a single texture axis.
bool MinMaxAlignAutoScaleInt (TextureAxis axis)
 Implementation of MinMaxAlignAutoScale for a single texture axis.
bool MinMaxAlignScale (TextureAxis axis, ScaleOperation op)
 The meat of MinMaxAlignStretchInt and MinMaxAlignShrinkInt.
bool MinMaxAlignStretchInt (TextureAxis axis)
 Implementation of MinMaxAlignStretch for a single texture axis.
bool MinMaxAlignShrinkInt (TextureAxis axis)
 Implementation of MinMaxAlignShrink for a single texture axis.
Surface measurement
float SliceParametricSpeedComponent (PositionAxis axis, float t, const SlicePatchContext &context)
 Calculate the d(x, y, or z)/dt of a patch slice, evaluated at a given t (parameter for the Bezier function, between 0 and 1).
float SliceParametricSpeed (float t, const SlicePatchContext &context)
 Calculates the rate of change in worldspace units of a patch slice, evaluated at a given t (parameter for the Bezier function, between 0 and 1).
float EstimateSegmentLength (float startPosition, float endPosition, const SlicePatchContext &context)
 Estimate the surface length of a slice segment, using ten point Gauss-Legendre integration of the parametric speed function.
float RefineSegmentLength (float startPosition, float endPosition, const SlicePatchContext &context, float segmentLengthEstimate, float maxError)
 Recursively improve the estimate of the surface length of a slice segment, by estimating the length of its halves, until the change between estimates is equal to or less than an acceptable error threshold.
Subroutines for complex modification
void GenControlTexFromSurface (TextureAxis axis, const Matrix< float > &surfaceValues)
 Derive control point texture coordinates (on a given texture axis) from a set of mesh surface texture coordinates.
void CopyControlTexFromValues (TextureAxis axis, const Matrix< float > &values)
 Overwrite control point texture coordinates (on a given texture axis) with the input texture coordinates.
void GenSurfaceFromControlTex (TextureAxis axis, Matrix< float > &surfaceValues)
 Derive a set of surface texture coordinates (on a given texture axis) from the control point texture coordinates.
void CopyValuesFromControlTex (TextureAxis axis, Matrix< float > &values)
 Copy the control point texture coordinates (on a given texture axis) to the output texture coordinates parameter.
void GenScaledDistanceValues (SliceType sliceType, int alignSlice, const RefSliceDescriptorInt *refSlice, bool rawScale, float rawScaleOrTiles, Matrix< float > &values)
 Generate a set of values based on surface slice lengths and some amount of desired scaling or tiling.
void GeneralFunctionInt (const GeneralFunctionFactors &factors, TextureAxis axis, int alignRow, int alignCol, bool surfaceValues, const Matrix< float > &rowDistances, const Matrix< float > &colDistances)
 Generate coordinates for a specified texture axis based on a linear combination of factors.

Static Private Member Functions

template<typename Element >
static Element & MatrixElement (Matrix< Element > &matrix, SliceType sliceType, int slice, int index)
 Utility template function for accessing a matrix element from code that operates on either kind of slice.

Private Attributes

scene::Node & _mesh
 Handle for the Node object in Radiant that is the patch mesh entity.
bool _valid
 Flag to indicate whether this object was properly generated from the supplied entity.
PatchControlMatrix _meshData
 The control points of the mesh.
const MessageCallback _infoReportCallback
 Callback function used to report information about the mesh.
const MessageCallback _warningReportCallback
 Callback function used to deliver warning messages.
const MessageCallback _errorReportCallback
 Callback function used to deliver error messages when operations on the mesh fail.
float _naturalTexUnits [NUM_TEX_AXES]
 The number of grid units that would constitute a "natural" scale along each texture axis, using the mesh's current texture.
unsigned _numSlices [NUM_SLICE_TYPES]
 The number of mesh slices of each kind (row or column).
bool _texMinMaxDirty [NUM_TEX_AXES]
 Whether the values for a texture axis have been modified since the last time their min/max/aligned state was calculated.
float _texMin [NUM_TEX_AXES]
 The minimum values, across the entire mesh, for each texture axis.
float _texMax [NUM_TEX_AXES]
 The maximum values, across the entire mesh, for each texture axis.
bool _texMinAligned [NUM_TEX_AXES]
 Whether the minimum value for a texture axis is on a texture boundary.
bool _texMaxAligned [NUM_TEX_AXES]
 Whether the maximum value for a texture axis is on a texture boundary.
float _posMin [NUM_POS_AXES]
 The minimum values, across the entire mesh, for each position axis.
float _posMax [NUM_POS_AXES]
 The maximum values, across the entire mesh, for each position axis.

Static Private Attributes

static TextureAxis _naturalAxis [NUM_SLICE_TYPES]
 For a given slice kind, which texture axis (S or T) normally changes along it.
static bool _radiantScaleInverted [NUM_SLICE_TYPES] = { false, true }
 For a given slice kind, whether Radiant's "natural" scale along a texture axis is backwards compared to the progression of the indices of the orthogonal slices.
static bool _radiantTilesInverted [NUM_SLICE_TYPES] = { false, false }
 For a given slice kind, whether Radiant's interpretation of tiling along a texture axis is backwards compared to the progression of the indices of the orthogonal slices.
static const char * _infoSliceFormatString [NUM_SLICE_TYPES]
 Message format strings for describing texture mapping on a slice.
static const char * _infoSliceInfscaleFormatString [NUM_SLICE_TYPES]
 Message format strings for describing texture mapping on a slice in the unusual case where the scale value is infinite.
static const char * _warningSliceInfscaleFormatString [NUM_SLICE_TYPES]
 Message format strings for warning that a scale value is infinite and cannot be transferred to the Set S/T Scale dialog.
static const char * _errorBadSliceString [NUM_SLICE_TYPES]
 Message format strings for an illegal slice number error.
static const char * _errorSliceZeroscaleString [NUM_SLICE_TYPES]
 Message format strings for a scale = 0 error.
static const char * _errorSliceZerotilesString [NUM_SLICE_TYPES]
 Message format strings for a tiles = 0 error.

Detailed Description

Wrapper for a biquadratic Bezier patch mesh entity from Radiant.

Instantiate this for a given patch mesh, then use the methods to interrogate or modify the mesh. It is intended that this object be instantiated, used, and then discarded before resuming other Radiant operations, as the implementation assumes that several basic mesh characteristics will remain constant for the life of this object.


Member Typedef Documentation

typedef Callback1<const char *, void> MeshEntity::MessageCallback

Type for info/warning/error callbacks.

The callback takes a const char* argument (the message string); it has no return value.

typedef Callback2<float, float, void> MeshEntity::TexInfoCallback

Type for texture scale info callbacks.

The callback takes two float arguments (scale and tiles); it has no return value.


Member Enumeration Documentation

Values that represent the kinds of position (spatial) axis.

Enumerator:
X_POS_AXIS 

X position axis.

Y_POS_AXIS 

Y position axis.

Z_POS_AXIS 

Z position axis.

NUM_POS_AXES 

number of kinds of position axis

Values that represent ways of scaling a texture to make it aligned.

Enumerator:
STRETCH_SCALE_OP 

scale by stretching

SHRINK_SCALE_OP 

scale by shrinking

Values that represent the kinds of patch mesh slices.

Note that the assigned integer values are significant; do not change.

Enumerator:
ROW_SLICE_TYPE 

row

COL_SLICE_TYPE 

column

NUM_SLICE_TYPES 

number of kinds of slice

Values that represent the kinds of texture axis.

Enumerator:
S_TEX_AXIS 

S texture axis.

T_TEX_AXIS 

T texture axis.

NUM_TEX_AXES 

number of kinds of texture axis

Values that represent the texture axes an operation should manipulate.

Enumerator:
S_TEX_AXIS_ONLY 

manipulate the S values

T_TEX_AXIS_ONLY 

manipulate the T values

ALL_TEX_AXES 

manipulate both S and T values


Constructor & Destructor Documentation

MeshEntity::MeshEntity ( scene::Node &  mesh,
const MessageCallback infoReportCallback,
const MessageCallback warningReportCallback,
const MessageCallback errorReportCallback 
)

Constructor.

If the constructor is unable to process the input mesh, then the internal valid flag (queryable through IsValid) is set false, and the errorReportCallback is invoked.

Parameters:
meshThe patch mesh to construct a wrapper for.
infoReportCallbackCallback for future informational messages.
warningReportCallbackCallback for future warning messages.
errorReportCallbackCallback for future error messages.
MeshEntity::~MeshEntity ( )

Destructor.

Note that this only destroys the wrapper object, not the patch mesh itself.


Member Function Documentation

void MeshEntity::CopyControlTexFromValues ( TextureAxis  axis,
const Matrix< float > &  values 
)
private

Overwrite control point texture coordinates (on a given texture axis) with the input texture coordinates.

Parameters:
axisThe texture axis of interest.
valuesThe input texture coordinates.
void MeshEntity::CopyValuesFromControlTex ( TextureAxis  axis,
Matrix< float > &  values 
)
private

Copy the control point texture coordinates (on a given texture axis) to the output texture coordinates parameter.

Parameters:
axisThe texture axis of interest.
[out]valuesThe output texture coordinates.
float MeshEntity::EstimateSegmentLength ( float  startPosition,
float  endPosition,
const SlicePatchContext context 
)
private

Estimate the surface length of a slice segment, using ten point Gauss-Legendre integration of the parametric speed function.

The value returned will always be positive (absolute value).

Parameters:
startPositionBezier parameter value for the start point of the slice segment.
endPositionBezier parameter value for the end point of the slice segment.
contextThe slice and patch.
Returns:
Estimate of segment length.
void MeshEntity::GenControlTexFromSurface ( TextureAxis  axis,
const Matrix< float > &  surfaceValues 
)
private

Derive control point texture coordinates (on a given texture axis) from a set of mesh surface texture coordinates.

Parameters:
axisThe texture axis of interest.
surfaceValuesThe surface texture coordinates.
void MeshEntity::GeneralFunction ( const GeneralFunctionFactors sFactors,
const GeneralFunctionFactors tFactors,
const SliceDesignation alignRow,
const SliceDesignation alignCol,
const RefSliceDescriptor refRow,
const RefSliceDescriptor refCol,
bool  surfaceValues 
)

Set the mesh's texture coordinates according to a linear combination of factors.

This equation can be used to set the texture coordinates at the control points themselves, or to directly set the texture coordinates at the locations on the mesh surface that correspond to each half-patch interval.

An alignment row is used as the zero-point for any calculations of row number or of distance along a column surface when processing the equation. An alignment column is similarly used. (Note that the number identifying the alignment row/column is the real number used to index into the mesh; it's not the modified number as affected by the alignment column/row when processing the equation. We don't want to be stuck in a chicken-and-egg situation.)

Calculations of distance along row/col surface may optionally be affected by a designated reference row/col. The reference row/col can be used as a source of end-to-end distance only, in which case the proportional spacing of the control points within the affected row/col will determine the distance value to be used for each control point. Or, the distance value for every control point in the reference row/col can be copied to each corresponding control point in the other rows/cols.

Parameters:
sFactorsFactors to determine the S texture coords; NULL if S axis unaffected.
tFactorsFactors to determine the T texture coords; NULL if T axis unaffected.
alignRowPointer to zero-point row; if NULL, row 0 is assumed.
alignColPointer to zero-point column; if NULL, column 0 is assumed.
refRowPointer to reference row description, including how to use the reference; NULL if no reference.
refColPointer to reference column description, including how to use the reference; NULL if no reference.
surfaceValuestrue if calculations are for S/T values on the mesh surface; false if calculations are for S/T values at the control points.
void MeshEntity::GeneralFunctionInt ( const GeneralFunctionFactors factors,
TextureAxis  axis,
int  alignRow,
int  alignCol,
bool  surfaceValues,
const Matrix< float > &  rowDistances,
const Matrix< float > &  colDistances 
)
private

Generate coordinates for a specified texture axis based on a linear combination of factors.

This method does the final work for the GeneralFunction public method.

Parameters:
factorsFactors to determine the texture coords.
axisThe texture axis to process.
alignRowZero-point row.
alignColZero-point column.
surfaceValuestrue if calculations are for S/T values on the mesh surface; false if calculations are for S/T values at the control points.
rowDistancesSurface distance-along-row values (measured from alignment column) for spots corresponding to each control point.
colDistancesSurface distance-along-column values (measured from alignment row) for spots corresponding to each control point.
void MeshEntity::GenScaledDistanceValues ( SliceType  sliceType,
int  alignSlice,
const RefSliceDescriptorInt refSlice,
bool  rawScale,
float  rawScaleOrTiles,
Matrix< float > &  values 
)
private

Generate a set of values based on surface slice lengths and some amount of desired scaling or tiling.

This method does a great deal of the work for the SetScale public method; refer to that method's comment header for more details about the alignment slice and reference slice inputs. The main difference from the SetScale input parameters is that the scale/tiles factor has been processed some. It has been flipped if necessary to account for Radiant's internal scale/tiles orientation differing from the sensible external orientation. And natural scaling has been converted to raw scaling, which is the actual desired divisor to get texture coordinates from worldspace lengths.

Parameters:
sliceTypeProcess rows or colums.
alignSlicePointer to alignment slice description; if NULL, slice 0 is assumed.
refSlicePointer to reference slice description, including how to use the reference; NULL if no reference.
rawScaletrue if rawScaleOrTiles is a scale factor; false if rawScaleOrTiles is a number of tiles.
rawScaleOrTilesScaling determinant, interpreted according to the rawScale parameter.
[out]valuesThe generated values.
void MeshEntity::GenSurfaceFromControlTex ( TextureAxis  axis,
Matrix< float > &  surfaceValues 
)
private

Derive a set of surface texture coordinates (on a given texture axis) from the control point texture coordinates.

Parameters:
axisThe texture axis of interest.
[out]surfaceValuesThe surface texture coordinates.
void MeshEntity::GetInfo ( const int *  refRow,
const int *  refCol,
const TexInfoCallback rowTexInfoCallback,
const TexInfoCallback colTexInfoCallback 
)

Get information about the patch mesh.

A message string describing general mesh information (number of rows/cols, min/max texture coords, extent in worldspace) will be composed and sent to the infoReportCallback that was specified when this wrapper object was constructed.

Optionally this method can do additional reporting on a specific "reference row" and "reference column". If a reference row and/or column is specified, then information about the reference slice(s) will be added to the information message. If a reference row/col is specified AND a corresponding row/col TexInfoCallback is specified, then the scale and tiling values for the reference slice will also be passed to the relevant callback.

Parameters:
refRowPointer to reference row number; NULL if none.
refColPointer to reference column number; NULL if none.
rowTexInfoCallbackPointer to callback for reference row info; NULL if none.
colTexInfoCallbackPointer to callback for reference column info; NULL if none.
bool MeshEntity::GetSliceTexInfo ( SliceType  sliceType,
int  slice,
TextureAxis  axis,
SliceTexInfo info 
)
private

Populate the SliceTexInfo for the indicated slice and texture axis.

Parameters:
sliceTypeSlice kind (row or column).
sliceSlice number, among slices of that kind in mesh.
axisThe texture axis of interest.
[out]infoInformation on scale, tiles, and min/max for the specified texture axis.
Returns:
true on success, false if slice cannot be processed.
float MeshEntity::GetSliceTexScale ( SliceType  sliceType,
int  slice,
TextureAxis  axis,
float  tiles 
)
private

Given a slice and a number of times that its texture should tile along it, find the appropriate texture scale.

This result is determined by the surface length along the slice.

Parameters:
sliceTypeSlice kind (row or column).
sliceSlice number, among slices of that kind in mesh.
axisThe texture axis of interest.
tilesNumber of times the texture tiles.
Returns:
The texture scale corresponding to the tiling amount.
MeshEntity::RefSliceDescriptorInt * MeshEntity::InternalRefSliceDescriptor ( const RefSliceDescriptor refSlice,
SliceType  sliceType,
RefSliceDescriptorInt refSliceInt 
)
private

Convert from RefSliceDescriptor to RefSliceDescriptorInt.

Interpret max slice if necessary. Populate specified RefSliceDescriptorInt if input is non-NULL and return pointer to it; otherwise return NULL.

Parameters:
refSlicePointer to reference slice description; may be NULL.
sliceTypeSlice kind (row or column).
[out]refSliceIntRefSliceDescriptorInt to populate.
Returns:
NULL if input RefSliceDescriptor is NULL; else, pointer to populated RefSliceDescriptorInt.
int MeshEntity::InternalSliceDesignation ( const SliceDesignation sliceDesignation,
SliceType  sliceType 
)
private

Convert from SliceDesignation to a slice number.

Interpret max slice if necessary, and fall back to slice 0 if unspecified.

Parameters:
sliceDesignationPointer to slice description; may be NULL.
sliceTypeSlice kind (row or column).
Returns:
The slice number.
bool MeshEntity::IsValid ( ) const

Query if the patch mesh is valid, in the characteristics that this wrapper class cares about.

If not valid then the results of operations on this wrapper object are undefined.

Returns:
true if valid, false if not.
template<typename Element >
static Element& MeshEntity::MatrixElement ( Matrix< Element > &  matrix,
SliceType  sliceType,
int  slice,
int  index 
)
inlinestaticprivate

Utility template function for accessing a matrix element from code that operates on either kind of slice.

Parameters:
matrixThe matrix holding the mesh control points.
sliceTypeSlice kind (row or column).
sliceSlice number, among slices of that type in mesh.
indexElement index along the slice.
Returns:
The matrix element; can be used as lvalue or rvalue.
void MeshEntity::MaxAlign ( TextureAxisSelection  axes)

For each of the specified texture axes, shift the highest-valued texture coordinates off of the mesh until an integral texture coordinate (texture boundary) is on the mesh edge.

Parameters:
axesThe texture axes to align.
bool MeshEntity::MaxAlignInt ( TextureAxis  axis)
private

Implementation of MaxAlign for a single texture axis.

Parameters:
axisThe texture axis to affect.
Returns:
true if the mesh was changed, false if not.
void MeshEntity::MinAlign ( TextureAxisSelection  axes)

For each of the specified texture axes, shift the lowest-valued texture coordinates off of the mesh until an integral texture coordinate (texture boundary) is on the mesh edge.

Parameters:
axesThe texture axes to align.
bool MeshEntity::MinAlignInt ( TextureAxis  axis)
private

Implementation of MinAlign for a single texture axis.

Parameters:
axisThe texture axis to affect.
Returns:
true if the mesh was changed, false if not.
void MeshEntity::MinMaxAlignAutoScale ( TextureAxisSelection  axes)

For each of the specified texture axes, perform either MinMaxAlignStretch or MinMaxAlignShrink; the chosen operation will be the one with the least absolute change in the value of the texture scale.

Parameters:
axesThe texture axes to align.
bool MeshEntity::MinMaxAlignAutoScaleInt ( TextureAxis  axis)
private

Implementation of MinMaxAlignAutoScale for a single texture axis.

Parameters:
axisThe texture axis to affect.
Returns:
true if the mesh was changed, false if not.
bool MeshEntity::MinMaxAlignScale ( TextureAxis  axis,
ScaleOperation  op 
)
private

The meat of MinMaxAlignStretchInt and MinMaxAlignShrinkInt.

Parameters:
axisThe texture axis to affect.
opWhether to stretch or shrink.
Returns:
true if the mesh was changed, false if not.
void MeshEntity::MinMaxAlignShrink ( TextureAxisSelection  axes)

For each of the specified texture axes, align a texture boundary to one edge of the mesh, then decrease the texture scale to align a texture boundary to the other edge of the mesh as well.

Parameters:
axesThe texture axes to align.
bool MeshEntity::MinMaxAlignShrinkInt ( TextureAxis  axis)
private

Implementation of MinMaxAlignShrink for a single texture axis.

Parameters:
axisThe texture axis to affect.
Returns:
true if the mesh was changed, false if not.
void MeshEntity::MinMaxAlignStretch ( TextureAxisSelection  axes)

For each of the specified texture axes, align a texture boundary to one edge of the mesh, then increase the texture scale to align a texture boundary to the other edge of the mesh as well.

Parameters:
axesThe texture axes to align.
bool MeshEntity::MinMaxAlignStretchInt ( TextureAxis  axis)
private

Implementation of MinMaxAlignStretch for a single texture axis.

Parameters:
axisThe texture axis to affect.
Returns:
true if the mesh was changed, false if not.
void MeshEntity::ProcessForAxes ( InternalImpl  internalImpl,
TextureAxisSelection  axes 
)
private

Apply some function with the InternalImpl signature to each of the designated texture axes.

The undo point and state commit operations are handled here for such functions.

Parameters:
internalImplThe function to apply.
axesThe texture axes to affect.
float MeshEntity::RefineSegmentLength ( float  startPosition,
float  endPosition,
const SlicePatchContext context,
float  segmentLengthEstimate,
float  maxError 
)
private

Recursively improve the estimate of the surface length of a slice segment, by estimating the length of its halves, until the change between estimates is equal to or less than an acceptable error threshold.

Parameters:
startPositionBezier parameter value for the start point of the slice segment.
endPositionBezier parameter value for the end point of the slice segment.
contextThe slice and patch.
segmentLengthEstimateStarting estimate for segment legnth.
maxErrorMax acceptable variance between estimates.
Returns:
Improved estimate of segment length.
void MeshEntity::ReportSliceTexInfo ( SliceType  sliceType,
int  slice,
TextureAxis  axis,
char *  messageBuffer,
unsigned  messageBufferSize,
const TexInfoCallback texInfoCallback 
)
private

Take the information from GetSliceTexInfo and sanitize it for reporting.

Optionally print to a provided message buffer and/or supply data to a provided TexInfoCallback.

Parameters:
sliceTypeSlice kind (row or column).
sliceSlice number, among slices of that kind in mesh.
axisThe texture axis of interest.
messageBufferBuffer for message data; NULL if none.
messageBufferSizeSize of the message buffer.
texInfoCallbackCallback for passing texture scale/tiles info; NULL if none.
void MeshEntity::Scale ( TextureAxis  axis,
float  scale 
)
private

On the given texture axis, find the distance of all control point values from the current minimum value and multiply that distance by the given scale factor.

Parameters:
axisThe texture axis to affect.
scaleThe scale factor.
void MeshEntity::SetScale ( SliceType  sliceType,
const SliceDesignation alignSlice,
const RefSliceDescriptor refSlice,
bool  naturalScale,
float  naturalScaleOrTiles 
)

Set the texture scaling along the rows or columns of the mesh.

This affects only the texture axis that is naturally associated with rows (S) or columns (T) according to the chosen sliceType.

The scaling may be input either as a multiple of the natural scale that Radiant would choose for this texture, or as the number of tiles of the texture that should fit on the mesh's row/column.

Among the slices perpendicular to the direction of scaling, an alignment slice is used to fix the position of the texture boundary.

A reference slice may optionally be chosen among the slices parallel to the scaling direction. If a reference slice is not specified, then the texture coordinates are independently determined for each slice. If a reference slice is specified, its texture coordinates are calculated first and used to affect the other slices. The reference slice's amount of texture tiling will be re-used for all other slices; optionally, the texture coordinate at each control point within the reference slice can be copied to the corresponding control point in every other slice.

Parameters:
sliceTypeChoose to scale along rows or columns.
alignSlicePointer to alignment slice description; if NULL, slice 0 is assumed.
refSlicePointer to reference slice description, including how to use the reference; NULL if no reference.
naturalScaletrue if naturalScaleOrTiles is a factor of the Radiant natural scale; false if naturalScaleOrTiles is a number of tiles.
naturalScaleOrTilesScaling determinant, interpreted according to the naturalScale parameter.
void MeshEntity::Shift ( TextureAxis  axis,
float  shift 
)
private

Add an offset to all control point values for the given texture axis.

Parameters:
axisThe texture axis to affect.
shiftThe offset to add.
float MeshEntity::SliceParametricSpeed ( float  t,
const SlicePatchContext context 
)
private

Calculates the rate of change in worldspace units of a patch slice, evaluated at a given t (parameter for the Bezier function, between 0 and 1).

Parameters:
tBezier parameter.
contextThe slice and patch.
Returns:
Path length.
float MeshEntity::SliceParametricSpeedComponent ( PositionAxis  axis,
float  t,
const SlicePatchContext context 
)
private

Calculate the d(x, y, or z)/dt of a patch slice, evaluated at a given t (parameter for the Bezier function, between 0 and 1).

Parameters:
axisThe worldspace axis of interest.
tBezier parameter.
contextThe slice and patch.
Returns:
d(x, y, or z)/dt at the given t.
void MeshEntity::UpdatePosMinMax ( PositionAxis  axis)
private

Update the internally stored information for the min and max extent of the mesh on the specified worldspace axis.

Parameters:
axisThe worldspace axis.
void MeshEntity::UpdateTexMinMax ( TextureAxis  axis)
private

Update the internally stored information for the min and max extent of the mesh on the specified texture axis.

Parameters:
axisThe texture axis.

Member Data Documentation

const char * MeshEntity::_errorBadSliceString
staticprivate
Initial value:
{ ERROR_BAD_ROW, ERROR_BAD_COL }

Message format strings for an illegal slice number error.

const char * MeshEntity::_errorSliceZeroscaleString
staticprivate
Initial value:
{ ERROR_ROW_ZEROSCALE, ERROR_COL_ZEROSCALE }

Message format strings for a scale = 0 error.

const char * MeshEntity::_errorSliceZerotilesString
staticprivate
Initial value:
{ ERROR_ROW_ZEROTILES, ERROR_COL_ZEROTILES }

Message format strings for a tiles = 0 error.

const char * MeshEntity::_infoSliceFormatString
staticprivate
Initial value:
{ INFO_ROW_FORMAT, INFO_COL_FORMAT }

Message format strings for describing texture mapping on a slice.

const char * MeshEntity::_infoSliceInfscaleFormatString
staticprivate
Initial value:
{ INFO_ROW_INFSCALE_FORMAT, INFO_COL_INFSCALE_FORMAT }

Message format strings for describing texture mapping on a slice in the unusual case where the scale value is infinite.

PatchControlMatrix MeshEntity::_meshData
private

The control points of the mesh.

Modifying the data in this matrix will modify the mesh entity directly; it is NOT a copy of the entity's data.

MeshEntity::TextureAxis MeshEntity::_naturalAxis
staticprivate
Initial value:

For a given slice kind, which texture axis (S or T) normally changes along it.

float MeshEntity::_naturalTexUnits[NUM_TEX_AXES]
private

The number of grid units that would constitute a "natural" scale along each texture axis, using the mesh's current texture.

Radiant's natural scale is 1/2 as many grid units as there are texture pixels.

const char * MeshEntity::_warningSliceInfscaleFormatString
staticprivate
Initial value:
{ WARNING_ROW_INFSCALE, WARNING_COL_INFSCALE }

Message format strings for warning that a scale value is infinite and cannot be transferred to the Set S/T Scale dialog.


The documentation for this class was generated from the following files: