Hello there, I would like to take this opportunity to wish you a very Happy New Year 2020.
I'm working on a project and I'm stuck on the following problem:
The Cinema 4D Bend Deformer object can be applied only on geometry, but I'm searching solution to create a similar deformation effect, that can be applied on a group of Light objects. I have tried a lot off methods and without any success.
Below you find a summary of the code that I'm currently using:
Code:
AutoAlloc<BaseObject> containertPtr(Onull);
AutoAlloc<BaseObject> parentlighstPtr(Onull);
AutoAlloc<BaseObject> recPtr(Osplinerectangle);
AutoAlloc<BaseObject> bendPtr(Obend);
if (!containertPtr || !recPtr || !parentPtr || !bendPtr)
return false;
// Set names
containertPtr->SetName("Container");
parentPtr->SetName("Lights");
recPtr->SetName("Rectangle");
// Variables
Int32 Count = 7;
Float Xpos, Ypos,
Width = 150.0,
Height = 250.0,
interval = 40.0;
Ypos = Height / 2;
// Rectangle object
recPtr->SetParameter(PRIM_RECTANGLE_WIDTH, Width, DESCFLAGS_SET_0);
recPtr->SetParameter(PRIM_RECTANGLE_HEIGHT, Height, DESCFLAGS_SET_0);
recPtr.Release()->InsertUnder(containertPtr);
// Bend object
Float fullWidthSize = (Width*Count) + interval*(Count - 1);
Float bendStrength = 90.0;
bendPtr->SetParameter(DEFORMOBJECT_SIZE, Vector(Height, fullWidthSize / 2, 10.0), DESCFLAGS_SET_0);
bendPtr->SetParameter(DEFORMOBJECT_MODE, DEFORMOBJECT_MODE_UNLIMITED, DESCFLAGS_SET_0);
bendPtr->SetParameter(DEFORMOBJECT_STRENGTH, bendStrength, DESCFLAGS_SET_0);
bendPtr->SetParameter(DEFORMOBJECT_ANGLE, DegToRad(-90.0), DESCFLAGS_SET_0);
bendPtr->SetAbsRot(Vector(0, 0, DegToRad(-90.0)));
bendPtr->SetAbsPos(Vector(fullWidthSize / 4, Height / 2, 0.0));
for (Int32 i = 0; i < Count; i++)
{
AutoAlloc<BaseObject> InstancePtr(Oinstance);
AutoAlloc<BaseObject> ExtrudePtr(Oextrude);
AutoAlloc<BaseObject> LightPtr(Olight);
if (!InstancePtr || !ExtrudePtr || !LightPtr)
return false;
Xpos = (Width*i) + (interval*i) + (Width / 2);
// Set names
ExtrudePtr->SetName("Extrude_" + String::IntToString(i));
InstancePtr->SetName("Instance_" + String::IntToString(i));
LightPtr->SetName("Light_" + String::IntToString(i));
// Light object
LightPtr->SetParameter(LIGHT_TYPE, 8, DESCFLAGS_SET_0);
LightPtr->SetParameter(LIGHT_AREADETAILS_SIZEX, Width*0.9, DESCFLAGS_SET_0);
LightPtr->SetParameter(LIGHT_AREADETAILS_SIZEY, Height*0.9, DESCFLAGS_SET_0);
LightPtr->SetAbsPos(Vector(Xpos, Ypos, 0));
LightPtr.Release()->InsertUnder(ExtrudePtr);
// Instance object
InstancePtr->SetParameter(INSTANCEOBJECT_LINK, recPtr, DESCFLAGS_SET_0);
InstancePtr.Release()->InsertUnder(ExtrudePtr);
// Extrude object
ExtrudePtr->SetParameter(EXTRUDEOBJECT_MOVE, Vector(0, 0, 0), DESCFLAGS_SET_0);
ExtrudePtr->SetParameter(EXTRUDEOBJECT_HIERARCHIC, true, DESCFLAGS_SET_0);
ExtrudePtr->SetAbsPos(Vector(Xpos, Ypos, 0));
ExtrudePtr.Release()->InsertUnder(parentPtr);
}
bendPtr.Release()->InsertUnder(parentPtr);
parentPtr.Release()->InsertUnder(containertPtr);
...
Screenshot of the generated scene:
Preview of the bend deformation, when I manipulate the strength value of my the Bend object. You see that the bend deformer affect only the Extrude objects and not the Light objects:
If you have any suggestion on the method that I can use to reproduce a similar deformation as an Bend Deformer using C++, but can be applied on group of Light objects. I would be most grateful.
Thank you.