RDK Decals
Windows only

IRhRdkDecal

IRhRdkDecal is an abstract decal interface. It provides access to all the properties of a Decal.

CRhRdkObjectDataAccess

CRhRdkObjectDataAccess is a wrapper around an object or layer which makes it easy to get RDK-specific information from that object or layer. When the wrapped object is a Rhino object, it can be used for accessing the object’s decals using the following methods:

  • AddDecal() Adds a new decal to the object.
  • RemoveDecal() Remove a particular decal from the object.
  • RemoveAllDecals() Removes all decals from the object.
  • NewDecalIterator() Obtains an iterator for accessing the object’s decals.

A particularly important property of decals is the decal CRC. This value identifies a decal by its state. Multiple decals which would be exactly the same would have the same CRC and are culled from the system. If you store this value with the intention of using it to find the decal again later, you must update your stored value whenever the decal state changes.

The following is an example of how to access decals already on an object. It uses NewDecalIterator() to get IRhRdkDecal and lists decal information on every object in the document. To keep the example short it does not list every piece of information available from IRhRdkDecal but should be enough to get you started:

using OI = CRhinoObjectIterator;

int objCount = 1;

CRhinoObjectIterator it(*pDoc, OI::undeleted_objects, OI::active_and_reference_objects);
const auto* pObject = it.First();
while (nullptr != pObject)
{
	CRhRdkObjectDataAccess da(pObject);

	auto* pDI = da.NewDecalIterator();
	if (nullptr != pDI)
	{
		const auto* pDecal = pDI->NextDecal();
		while (nullptr != pDecal)
		{
			const auto m = pDecal->Mapping();

			const wchar_t* wszMapping = L"";
			switch (m)
			{
			case IRhRdkDecal::mapUV:          wszMapping = L"UV";          break;
			case IRhRdkDecal::mapPlanar:      wszMapping = L"Planar";      break;
			case IRhRdkDecal::mapCylindrical: wszMapping = L"Cylindrical"; break;
			case IRhRdkDecal::mapSpherical:   wszMapping = L"Spherical";   break;
			}

			const auto pt = pDecal->Origin();
			RhinoApp().Print(L"Object %u: Decal %08X, mapping: %s, origin: (%.1f, %.1f, %.1f)",
			                 objCount, pDecal->CRC(), wszMapping, pt.x, pt.y, pt.z);

			if ((IRhRdkDecal::mapSpherical == m) || (IRhRdkDecal::mapCylindrical == m))
			{
				RhinoApp().Print(L", Radius: %.1f", pDecal->Radius());

				if (IRhRdkDecal::mapCylindrical == m)
				{
					RhinoApp().Print(L", Height: %.1f", pDecal->Height());
				}
			}

			RhinoApp().Print(L"\n");

			pDecal = pDI->NextDecal();
		}

		delete pDI;
	}

	pObject = it.Next();

	objCount++;
}