I created a linear light from the user interface, using this series of commands:
Command: LinearLight
Light origin: 1,2,3
Light length and direction: 4,7,9
This gave me a long cylindrical light in the first quadrant.
I tried to do the same thing using code, and got pretty close, except for the diameter of the light. What do I need to add or do differently?
void makeLinearLight(CRhinoDoc * rDoc)
{
ON_Light* light = new ON_Light();
light->SetStyle(ON::LightStyle(ON::world_linear_light));
ON_3dPoint * lightPos = new ON_3dPoint(1, 2, 3);
ON_3dPoint * endLoc = new ON_3dPoint(4, 7, 9);
ON_3dVector dirVec(endLoc->x - lightPos->x, endLoc->y - lightPos->y, endLoc->z - lightPos->z);
double length = lightPos->DistanceTo(*endLoc);
light->SetLocation(*lightPos);
light->SetDirection(dirVec);
light->SetLength(dirVec);
if (light->IsValid())
{
CRhinoLightTable& light_table = rDoc->m_light_table;
light_table.AddLight(*light);
}
else
{
delete light;
}
}