3DCoat  3D-COAT 4.9.xx
3DCoat is the one application that has all the tools you need to take your 3D idea from a block of digital clay all the way to a production ready, fully textured organic or hard surface model.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
OpenSubdiv::v3_4_3::Far::PatchParam Struct Reference

Patch parameterization. More...

#include <patchParam.h>

Public Member Functions

void Set (Index faceid, short u, short v, unsigned short depth, bool nonquad, unsigned short boundary, unsigned short transition, bool regular=false)
 Sets the values of the bit fields. More...
 
void Clear ()
 Resets everything to 0. More...
 
Index GetFaceId () const
 Returns the faceid. More...
 
unsigned short GetU () const
 Returns the log2 value of the u parameter at the first corner of the patch. More...
 
unsigned short GetV () const
 Returns the log2 value of the v parameter at the first corner of the patch. More...
 
unsigned short GetTransition () const
 Returns the transition edge encoding for the patch. More...
 
unsigned short GetBoundary () const
 Returns the boundary edge encoding for the patch. More...
 
bool NonQuadRoot () const
 True if the parent base face is a non-quad. More...
 
unsigned short GetDepth () const
 Returns the level of subdivision of the patch. More...
 
float GetParamFraction () const
 Returns the fraction of unit parametric space covered by this face. More...
 
template<typename REAL >
void Normalize (REAL &u, REAL &v) const
 A (u,v) pair in the fraction of parametric space covered by this face is mapped into a normalized parametric space. More...
 
template<typename REAL >
void Unnormalize (REAL &u, REAL &v) const
 A (u,v) pair in a normalized parametric space is mapped back into the fraction of parametric space covered by this face. More...
 
bool IsTriangleRotated () const
 Returns if a triangular patch is parametrically rotated 180 degrees. More...
 
bool IsRegular () const
 Returns whether the patch is regular. More...
 

Detailed Description

Patch parameterization.

Topological refinement splits coarse mesh faces into refined faces.

This patch parameterzation describes the relationship between one of these refined faces and its corresponding coarse face. It is used both for refined faces that are represented as full limit surface parametric patches as well as for refined faces represented as simple triangles or quads. This parameterization is needed to interpolate primvar data across a refined face.

The U,V and refinement level parameters describe the scale and offset needed to map a location on the patch between levels of refinement. The encoding of these values exploits the quad-tree organization of the faces produced by subdivision. We encode the U,V origin of the patch using two 10-bit integer values and the refinement level as a 4-bit integer. This is sufficient to represent up through 10 levels of refinement.

Special consideration must be given to the refined faces resulting from irregular coarse faces. We adopt a convention similar to Ptex texture mapping and define the parameterization for these faces in terms of the regular faces resulting from the first topological splitting of the irregular coarse face.

When computing the basis functions needed to evaluate the limit surface parametric patch representing a refined face, we also need to know which edges of the patch are interpolated boundaries. These edges are encoded as a boundary bitmask identifying the boundary edges of the patch in sequential order starting from the first vertex of the refined face.

A sparse topological refinement (like feature adaptive refinement) can produce refined faces that are adjacent to faces at the next level of subdivision. We identify these transitional edges with a transition bitmask using the same encoding as the boundary bitmask.

For triangular subdivision schemes we specify the parameterization using a similar method. Alternate triangles at a given level of refinement are parameterized from their opposite corners and encoded as occupying the opposite diagonal of the quad-tree hierarchy. The third barycentric coordinate is dependent on and can be derived from the other two coordinates. This encoding also takes inspiration from the Ptex texture mapping specification.

Bitfield layout :

Field0 Bits Content
faceId 28 the faceId of the patch
transition 4 transition edge mask encoding
Field1 Bits Content
level 4 the subdivision level of the patch
nonquad 1 whether patch is refined from a non-quad face
regular 1 whether patch is regular
unused 1 unused
boundary 5 boundary edge mask encoding
v 10 log2 value of u parameter at first patch corner
u 10 log2 value of v parameter at first patch corner

Note : the bitfield is not expanded in the struct due to differences in how GPU & CPU compilers pack bit-fields and endian-ness.

Quad Patch Parameterization

(0,1)                           (1,1)
  +-------+-------+---------------+
  |       |       |               |
  |   L2  |   L2  |               |
  |0,3    |1,3    |               |
  +-------+-------+       L1      |
  |       |       |               |
  |   L2  |   L2  |               |
  |0,2    |1,2    |1,1            |
  +-------+-------+---------------+
  |               |               |
  |               |               |
  |               |               |
  |       L1      |       L1      |
  |               |               |
  |               |               |
  |0,0            |1,0            |
  +---------------+---------------+
(0,0)                           (1,0)
Triangle Patch Parameterization

(0,1)                           (1,1)  (0,1,0)
  +-------+-------+---------------+       +
  | \     | \     | \             |       | \
  |L2 \   |L2 \   |   \           |       |   \
  |0,3  \ |1,3  \ |     \         |       | L2  \
  +-------+-------+       \       |       +-------+
  | \     | \     |   L1    \     |       | \  L2 | \
  |L2 \   |L2 \   |           \   |       |   \   |   \
  |0,2  \ |1,2  \ |1,1          \ |       | L2  \ | L2  \
  +-------+-------+---------------+       +-------+-------+
  | \             | \             |       | \             | \
  |   \           |   \           |       |   \           |   \
  |     \         |     \         |       |     \    L1   |     \
  |       \       |       \       |       |       \       |       \
  |   L1    \     |   L1    \     |       |   L1    \     |   L1    \
  |           \   |           \   |       |           \   |           \
  |0,0          \ |1,0          \ |       |             \ |             \
  +---------------+---------------+       +---------------+---------------+
(0,0)                           (1,0)  (0,0,1)                         (1,0,0)

Member Function Documentation

void OpenSubdiv::v3_4_3::Far::PatchParam::Clear ( )
inline

Resets everything to 0.

unsigned short OpenSubdiv::v3_4_3::Far::PatchParam::GetBoundary ( ) const
inline

Returns the boundary edge encoding for the patch.

unsigned short OpenSubdiv::v3_4_3::Far::PatchParam::GetDepth ( ) const
inline

Returns the level of subdivision of the patch.

Index OpenSubdiv::v3_4_3::Far::PatchParam::GetFaceId ( ) const
inline

Returns the faceid.

float OpenSubdiv::v3_4_3::Far::PatchParam::GetParamFraction ( ) const
inline

Returns the fraction of unit parametric space covered by this face.

unsigned short OpenSubdiv::v3_4_3::Far::PatchParam::GetTransition ( ) const
inline

Returns the transition edge encoding for the patch.

unsigned short OpenSubdiv::v3_4_3::Far::PatchParam::GetU ( ) const
inline

Returns the log2 value of the u parameter at the first corner of the patch.

unsigned short OpenSubdiv::v3_4_3::Far::PatchParam::GetV ( ) const
inline

Returns the log2 value of the v parameter at the first corner of the patch.

bool OpenSubdiv::v3_4_3::Far::PatchParam::IsRegular ( ) const
inline

Returns whether the patch is regular.

Referenced by OpenSubdiv::v3_4_3::Far::PatchTable::EvaluateBasisFaceVarying().

bool OpenSubdiv::v3_4_3::Far::PatchParam::IsTriangleRotated ( ) const
inline

Returns if a triangular patch is parametrically rotated 180 degrees.

bool OpenSubdiv::v3_4_3::Far::PatchParam::NonQuadRoot ( ) const
inline

True if the parent base face is a non-quad.

template<typename REAL >
void OpenSubdiv::v3_4_3::Far::PatchParam::Normalize ( REAL &  u,
REAL &  v 
) const
inline

A (u,v) pair in the fraction of parametric space covered by this face is mapped into a normalized parametric space.

Parameters
uu parameter
vv parameter
void OpenSubdiv::v3_4_3::Far::PatchParam::Set ( Index  faceid,
short  u,
short  v,
unsigned short  depth,
bool  nonquad,
unsigned short  boundary,
unsigned short  transition,
bool  regular = false 
)
inline

Sets the values of the bit fields.

Parameters
faceidface index
uvalue of the u parameter for the first corner of the face
vvalue of the v parameter for the first corner of the face
depthsubdivision level of the patch
nonquadtrue if the root face is not a quad
boundary5-bits identifying boundary edges (and verts for tris)
transition4-bits identifying transition edges
regularwhether the patch is regular
template<typename REAL >
void OpenSubdiv::v3_4_3::Far::PatchParam::Unnormalize ( REAL &  u,
REAL &  v 
) const
inline

A (u,v) pair in a normalized parametric space is mapped back into the fraction of parametric space covered by this face.

Parameters
uu parameter
vv parameter

The documentation for this struct was generated from the following file: