Hi,
I have a SceneHook
which I use to draw some information related to Opolygon
objects in the scene.
Up to now, I was only looking at the "original" objects in de scene, but am now looking how to add support for deformed objects.
I have looked through the documentation and found BaseObject::GetCache
, GetDeformedCache
, and cannot really wrap my head around the explanation.
Would there be any example available that demonstrates how to access the cache?
There are different scenarios I have in mind:
Scenario 1:
I iterate over all objects in a scene, and want to collect all deformed objects' cache, ignoring any other object, including the original input object for the deformation/SDS
BaseObject* obj = doc->GetFirstObject();
while (obj)
{
if (obj->IsInstanceOf(Opolygon))
{
// ignore
}
else
{
maxon::BaseArray<BaseObject*> deformed;
DoRecursion(obj, deformed);
for (const auto& defobj : deformed)
{
// process these
}
}
// get next object
if (obj->GetDown())
{
obj = obj->GetDown();
}
else
{
while (!obj->GetNext() && obj->GetUp())
obj = obj->GetUp();
obj = obj->GetNext();
}
}
void DoRecursion(BaseObject *op, maxon::BaseArray<BaseObject*>& deformed)
{
BaseObject* tp = op->GetDeformCache();
if (tp)
{
DoRecursion(tp, deformed);
}
else
{
tp = op->GetCache(nullptr);
if (tp)
{
DoRecursion(tp, deformed);
}
else
{
if (!op->GetBit(BIT_CONTROLOBJECT))
{
if (op->IsInstanceOf(Opolygon))
{
// --------------------------
// HERE IS THE DEFORMED POLYGON OBJECT
// --------------------------
iferr(deformed.Append(op))
{ return; }
}
}
}
}
for (tp = op->GetDown(); tp; tp = tp->GetNext())
{
DoRecursion(tp, deformed);
}
}
This seems to work, except that I ignore any polygon object which is not an input of a deform/SDS.
So, how to distinguish between a polygon object which is an input and one which isn't an input for deform/SDS?
Scenario 2:
Assume I want to iterate over each object in the scene, and want to collect the pair of polygon object and it's deformed cache. This in order to draw a line form each of the deformed points to the original points of the object.
How to find back the relation "original object" <-> "deformed object".
Thanks in advance,
Daniel