About
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
.
Access
A UVWTag is typically attached to a polygon object.
- Note
- A polygon object can host multiple UVW tags.
Allocation/Deallocation
UVWTag instances are created with the usual tools.
- UVWTag::Alloc(): Creates a new UVWTag.
- UVWTag::Free(): Destroys the given UVWTag.
A UVW tag with projection-based UVs can be created with:
- GenerateUVW(): Returns a UVWTag with UVs defined by the projection settings of the given TextureTag.
BaseTag*
const foundTag =
object->GetTag(
Tuvw);
UVWTag* uvwTag = static_cast<UVWTag*>(foundTag);
if (uvwTag == nullptr)
{
{
PolygonObject*
const polyObject =
static_cast<PolygonObject*
>(
object);
const Int32 polyCount = polyObject->GetPolygonCount();
uvwTag = UVWTag::Alloc(polyCount);
if (uvwTag == nullptr)
polyObject->InsertTag(uvwTag);
}
}
PyObject * object
Definition: asdl.h:7
#define Opolygon
Polygon - PolygonObject.
Definition: ge_prepass.h:1041
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define Tuvw
UVW data - UVWTag.
Definition: ge_prepass.h:1429
maxon::Int32 Int32
Definition: ge_sys_math.h:51
Access Data
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.
Slow
The UVW coordinates stored in a UVWTag can be accessed with:
- UVWTag::GetSlow(): Returns the UVW coordinates for the given polygon index.
- UVWTag::SetSlow(): Sets the UVW coordinates for the given polygon index.
- UVWTag::CpySlow(): Copies the UVW coordinates for the given index from the given UVWTag.
{
const UVWStruct uvwData = uvwTag->GetSlow(
i);
}
Py_ssize_t i
Definition: abstract.h:645
Py_ssize_t count
Definition: abstract.h:640
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
Fast
The fast access to the UVW coordinates stored in the UVWTag is provided by a data handle and static functions:
- UVWTag::GetDataAddressR(): Returns a handle to the read-only UVW coordinates.
- UVWTag::GetDataAddressW(): Returns a handle to the writeable UWV coordinates.
- UVWTag::Get(): Returns the UVW coordinates for the given polygon index.
- UVWTag::Set(): Sets the UVW coordinates for the given polygon index.
- UVWTag::Copy(): Copies the UVW coordinates for the given index from the given UVW handle.
UVWHandle handle = uvwTag->GetDataAddressW();
{
UVWStruct uvwData;
CPolygon polygon = polygons[
i];
const Vector a = mg * points[polygon.a];
const Vector b = mg * points[polygon.b];
const Vector c = mg * points[polygon.c];
const Vector d = mg * points[polygon.d];
CalculateUVCoordinates(a, uvwData.a);
CalculateUVCoordinates(b, uvwData.b);
CalculateUVCoordinates(
c, uvwData.c);
CalculateUVCoordinates(d, uvwData.d);
}
#define Set(a0, a1, a2, a3, a4, a5)
Definition: Python-ast.h:586
Py_UNICODE c
Definition: unicodeobject.h:1200
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
Definition: c4d_baselist.h:372
void * UVWHandle
Handle for UVW data. See also: UVWTag.
Definition: operatingsystem.h:464
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:140
Pin
Pin are stored by UV tag, you can access them with:
- UVWTag::GetPinSelection(): Returns the pined UV point selection.
- UVWTag::AddToPinSelection(): Adds the passed UV Point selection to the pined UV point selection.
- UVWTag::RemoveFromPinSelection(): Removes the passed UV Point selection to the pined UV point selection.
BaseObject*
const obj =
doc->GetActiveObject();
UVWTag* uvTag =
static_cast<UVWTag*
>(
obj->GetTag(
Tuvw));
if (uvTag == nullptr)
const BaseSelect& pinSelection = uvTag->GetPinSelection();
if (pinSelection.GetCount() == 0)
if (ptSelect == nullptr)
ptSelect->DeselectAll();
Int32 seg = 0, smin, smax, idx;
{
for (idx = smin; idx <= smax; idx++)
{
Int32 cpolyPtId = idx % 4;
Int32 ptId = polys[polyId][cpolyPtId];
ptSelect->Select(ptId);
}
}
Definition: apibasemath.h:34
BaseSelect * GetWritablePointS()
const CPolygon * GetPolygonR() const
Definition: c4d_baseobject.h:1927
PyObject * obj
Definition: complexobject.h:60
#define Opoint
Point - PointObject.
Definition: ge_prepass.h:1090
MAXON_ATTRIBUTE_FORCE_INLINE const PolygonObject * ToPoly(const T *op)
Casts a BaseObject* to a PolygonObject*.
Definition: c4d_baseobject.h:2392
MAXON_ATTRIBUTE_FORCE_INLINE const PointObject * ToPoint(const T *op)
Casts a BaseObject* to a PointObject*.
Definition: c4d_baseobject.h:2379
void EventAdd(EVENT eventflag=EVENT::NONE)
const char * doc
Definition: pyerrors.h:226
BaseObject*
const obj =
doc->GetActiveObject();
UVWTag* uvTag =
static_cast<UVWTag*
>(
obj->GetTag(
Tuvw));
if (uvTag == nullptr)
if (ptSelect == nullptr)
AutoAlloc<BaseSelect> pinsToSet;
if (poly == nullptr)
if (ptArray == nullptr)
{
const CPolygon* pp = poly +
i;
if (pp == nullptr)
if (ptArray[pp->a])
pinsToSet->Select(
i * 4 + 0);
if (ptArray[pp->b])
pinsToSet->Select(
i * 4 + 1);
if (ptArray[pp->c])
pinsToSet->Select(
i * 4 + 2);
if (ptArray[pp->d])
pinsToSet->Select(
i * 4 + 3);
}
uvTag->ClearPinSelection();
uvTag->AddToPinSelection(pinsToSet);
const BaseSelect * GetPointS() const
Int32 GetPolygonCount() const
Definition: c4d_baseobject.h:1941
BaseObject*
const obj =
doc->GetActiveObject();
UVWTag* uvTag =
static_cast<UVWTag*
>(
obj->GetTag(
Tuvw));
if (uvTag == nullptr)
if (ptSelect == nullptr)
AutoAlloc<BaseSelect> pinsToSet;
if (poly == nullptr)
if (ptArray == nullptr)
{
const CPolygon* pp = poly +
i;
if (pp == nullptr)
if (ptArray[pp->a])
pinsToSet->Select(
i * 4 + 0);
if (ptArray[pp->b])
pinsToSet->Select(
i * 4 + 1);
if (ptArray[pp->c])
pinsToSet->Select(
i * 4 + 2);
if (ptArray[pp->d])
pinsToSet->Select(
i * 4 + 3);
}
uvTag->RemoveFromPinSelection(pinsToSet);
While it's not stored directly in the UVWTag you may need to retrieve UV seems of an object:
BaseObject*
const obj =
doc->GetActiveObject();
if (uvSeams == nullptr || uvSeams->GetCount() == 0)
if (edgeSelect == nullptr)
edgeSelect->DeselectAll();
uvSeams->CopyTo(edgeSelect);
EdgeBaseSelect * GetWritableEdgeS()
const EdgeBaseSelect * GetUVSeams(const BaseObject *obj)
Further Reading