UVWTag Manual
A UVWTag stores UVW coordinates for a (polygon) object. For each polygon a set of four UVW coordinates is stored ( UVWStruct ). The class UVWTag is based on VariableTag so the typical workflows on handling tags apply, see BaseTag and VariableTag Manual .
UVWTag
objects are an instance of
Tuvw
.
A UVWTag is typically attached to a polygon object.
UVWTag instances are created with the usual tools.
A UVW tag with projection-based UVs can be created with:
There are two ways to edit the data stored inside a UVWTag . The "slow" way is to access every set of UVW coordinate independently. The "fast" way works with a data handle that allows direct access to the internal memory.
The UVW coordinates stored in a UVWTag can be accessed with:
The fast access to the UVW coordinates stored in the UVWTag is provided by a data handle and static functions:
// get points in world space CPolygon polygon = polygons[i]; const 向量 a = mg * points[polygon. a ]; const 向量 b = mg * points[polygon. b ]; const 向量 c = mg * points[polygon. c ]; const 向量 d = mg * points[polygon. d ];
// define UV coordinates based on the world space position // CalculateUVCoordinates() is a custom function CalculateUVCoordinates(a, uvwData. a ); CalculateUVCoordinates(b, uvwData. b ); CalculateUVCoordinates(c, uvwData. c ); CalculateUVCoordinates(d, uvwData. d ); UVWTag::Set (handle, i, uvwData); } polyObject-> 消息 ( MSG_UPDATE );
Pin are stored by UV tag, you can access them with:
// Retrieves the fist uvwtag UVWTag * uvTag = static_cast< UVWTag * > (obj-> GetTag ( Tuvw )); if (uvTag == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// Retrieves the Pin Selection Stored in the uvTag const BaseSelect & pinSelection = uvTag-> GetPinSelection (); if (pinSelection. GetCount () == 0) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// Retrieves the current Point Selection stored in the PointObject BaseSelect * ptSelect = ToPoint (obj)->GetPointS(); if (ptSelect == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); ptSelect-> DeselectAll ();
// Convert UV Point baseSelect to PointObject BaseSelect // UV Points are indexed by 4 * polygon + point where @c polygon is the polygon index and c point is the point index between 0 and 3 (a, b, c, d). const CPolygon * polys = ToPoly (obj)->GetPolygonR(); Int32 seg = 0, smin, smax, idx; while (pinSelection. GetRange (seg++, LIMIT<Int32>::MAX , &smin, &smax)) { // For each sequance of range for (idx = smin; idx <= smax; idx++) { // Retrieves the polygon ID and the Cpolygon ID Int32 polyId = idx / 4; Int32 cpolyPtId = idx % 4;
// Retrieve the real PtID from the Cpolygon Int32 ptId = polys[polyId][cpolyPtId]; ptSelect-> 选择 (ptId); } } EventAdd ();
// This example sets the UV Point pinned to the current active Point Selection. // Get object BaseObject * const obj = doc-> GetActiveObject (); if (obj == nullptr || ! obj-> IsInstanceOf ( Opoint )) return maxon::IllegalArgumentError( MAXON_SOURCE_LOCATION , "Should be a Point Object" _s);
// Retrieves the fist uvwtag UVWTag * uvTag = static_cast< UVWTag * > (obj-> GetTag ( Tuvw )); if (uvTag == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// Retrieves the current Point Selection stored in the PointObject BaseSelect * ptSelect = ToPoint (obj)->GetPointS(); if (ptSelect == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// Allocate a new pinSelection To Set AutoAlloc<BaseSelect> pinsToSet;
// Convert PointObject BaseSelect to Uv Point baseSelect // UV Points are indexed by 4 * polygon + point where c polygon is the polygon index and c point is the point index between 0 and 3 (a, b, c, d). // Retrieves the read array of all Cpolygon const CPolygon * poly = ToPoly (obj)->GetPolygonR(); if (poly == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// Retrieves an array of the selection state const maxon::AutoMem<UChar> ptArray = ptSelect-> ToArray ( ToPoint (obj)->GetPointCount()); if (ptArray == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); for ( Int32 i = 0; i < ToPoly (obj)->GetPolygonCount(); ++i) { const CPolygon * pp = poly + i; if (pp == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); if (ptArray[pp-> a ]) pinsToSet-> 选择 (i * 4 + 0); if (ptArray[pp-> b ]) pinsToSet-> 选择 (i * 4 + 1); if (ptArray[pp-> c ]) pinsToSet-> 选择 (i * 4 + 2); if (ptArray[pp-> d ]) pinsToSet-> 选择 (i * 4 + 3); }
// Clears the current Pin Selection uvTag-> ClearPinSelection ();
// Adds the built selection to the current pin selection uvTag-> AddToPinSelection (pinsToSet); EventAdd ();
// This example removes from the UV Point pinned, the current active Point Selection. // Get object BaseObject * const obj = doc-> GetActiveObject (); if (obj == nullptr || ! obj-> IsInstanceOf ( Opoint )) return maxon::IllegalArgumentError( MAXON_SOURCE_LOCATION , "Should be a Point Object" _s);
// Retrieves the fist uvwtag UVWTag * uvTag = static_cast< UVWTag * > (obj-> GetTag ( Tuvw )); if (uvTag == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// Retrieves the current Point Selection stored in the PointObject BaseSelect * ptSelect = ToPoint (obj)->GetPointS(); if (ptSelect == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// Allocate a new pinSelection To Set AutoAlloc<BaseSelect> pinsToSet;
// Convert PointObject BaseSelect to Uv Point baseSelect // UV Points are indexed by 4 * polygon + point where c polygon is the polygon index and c point is the point index between 0 and 3 (a, b, c, d). // Retrieves the read array of all Cpolygon const CPolygon * poly = ToPoly (obj)->GetPolygonR(); if (poly == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// Retrieves an array of the selection state const maxon::AutoMem<UChar> ptArray = ptSelect-> ToArray ( ToPoint (obj)->GetPointCount()); if (ptArray == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); for ( Int32 i = 0; i < ToPoly (obj)->GetPolygonCount(); ++i) { const CPolygon * pp = poly + i; if (pp == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); if (ptArray[pp-> a ]) pinsToSet-> 选择 (i * 4 + 0); if (ptArray[pp-> b ]) pinsToSet-> 选择 (i * 4 + 1); if (ptArray[pp-> c ]) pinsToSet-> 选择 (i * 4 + 2); if (ptArray[pp-> d ]) pinsToSet-> 选择 (i * 4 + 3); }
// Removes the built selection to the current pin selection uvTag-> RemoveFromPinSelection (pinsToSet); EventAdd ();
While it's not stored directly in the UVWTag you may need to retrieve UV seems of an object:
// Retrieves the current Edge Selection stored in the Polygon Object BaseSelect * edgeSelect = ToPoly (obj)->GetEdgeS(); if (edgeSelect == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// Deselect all the currently selected edge edgeSelect-> DeselectAll ();
// Copies the UV seams to the Polygon Edge selection. uvSeams-> CopyTo (edgeSelect); EventAdd ();