algorithmic modeling for Rhino
hi all,
i have a question.... is it possible to rotate a light in a scene with a certain angle? i need it for an animation...
i can get the light object like this
A = doc.Lights;
does anyone know how to rotate this object with an angle a ?
best benjamin
Tags:
Option 1:
Rhino.DocObjects.LightObject light = doc.Lights[0];
light.LightGeometry.Rotate(ANGLE, Vector3d.ZAxis, Point3d.Origin);
light.CommitChanges();
Option 2:
private void RunScript(Transform xForm, object y, ref object A)
{
Rhino.DocObjects.LightObject light = doc.Lights[0];
light.LightGeometry.Transform(xForm);
light.CommitChanges();
}
Allowing you to pass into xForm the transform output of a rotation component. (or any other transform for that matter.)
Note that both of these will apply the same rotation over and over and over again, so it behaves unlike a typical grasshopper rotation in that adjustments are cumulative rather than re-applied from scratch each time. For finer control over the light's rotation, you might want to specify its position rather than apply a transformation. This would look something like this:
Option 3:
private void RunScript(Point3d Pt, Vector3d Dir, ref object A)
{
Rhino.DocObjects.LightObject light = doc.Lights[0];
light.LightGeometry.Location = Pt;
light.LightGeometry.Direction = Dir;
light.CommitChanges();
}
Dir is only necessary if you're operating on a directional light.
Also all of the above assume that there is exactly 1 light in the document - if you're dealing with more you'll have to be cleverer about how you access the light in question.
hi andrew,
thanks for the great help! that works !
best
benjamin
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by