Example #1
0
        public GIString1AllWhite(string name)
            : base(name)
        {
            _lightArray = new LightArray(32, 1);

            HostName = HardwareConstants.LEDWIZ1;
            initSequence();
        }
Example #2
0
        public Color[] DoSomething(Light[] lights, Color ambient, bool[,] obstacles, Rectangle renderArea, Rectangle influenceArea, int downscale)
        {
            scale      = 1f / downscale;
            lightArray = new LightArray(renderArea.Width * renderArea.Height, ambient);
            Light[]   smallerLights        = new Light[lights.Length];
            Rectangle smallerRenderArea    = new Rectangle((int)(renderArea.X * scale), (int)(renderArea.Y * scale), (int)(renderArea.Width * scale), (int)(renderArea.Height * scale));
            Rectangle smallerInfluenceArea = new Rectangle((int)(influenceArea.X * scale), (int)(influenceArea.Y * scale), (int)(influenceArea.Width * scale), (int)(influenceArea.Height * scale));

            for (int i = 0; i < smallerLights.Length; i++)
            {
                smallerLights[i] = new Light(lights[i].Position * scale, (short)(lights[i].Radius * scale), lights[i].Brightness, lights[i].Color);
                DebugRenderer.AddDebugObjectWorldSingleCall(new DebugLight(lights[i], Color.AliceBlue));
            }
            Index2[][] pointsToCheck = new Index2[lights.Length][];
            for (int i = 0; i < smallerLights.Length; i++)
            {
                pointsToCheck[i] = Circle.CalculateEdge(smallerLights[i].Position, smallerLights[i].Radius);
                foreach (var currentPoint in pointsToCheck[i])
                {
                    if (smallerRenderArea.Contains(currentPoint) || smallerRenderArea.Contains(smallerLights[i].Position))
                    {
                        foreach (var raycast in new LightRaycast(smallerLights[i], smallerLights[i].Position, currentPoint))
                        {
                            if (!smallerInfluenceArea.Contains(raycast))                             //TODO: Use binarysearch
                            {
                                continue;
                            }
                            int x = raycast.X - smallerRenderArea.X;
                            int y = raycast.Y - smallerRenderArea.Y;
                            if (obstacles[x, y])
                            {
                                break;
                            }
                            if (!smallerRenderArea.Contains(raycast))
                            {
                                continue;
                            }
                            for (int xOff = 0; xOff < downscale; xOff++)
                            {
                                for (int yOff = 0; yOff < downscale; yOff++)
                                {
                                    lightArray.Set((downscale * y + yOff) * renderArea.Width + (downscale * x + xOff), smallerLights[i].Color);
                                }
                            }
                        }
                    }
                }
            }

            return(lightArray.ToColorArray());
        }
 /// <summary>
 /// Selects the lights and opens the Light Properties page
 /// </summary>
 public override bool OnEditLight(RhinoDoc doc, ref LightArray light_array)
 {
     for (int i = 0; i < light_array.Count(); i++)
     {
         Rhino.Geometry.Light light = light_array.ElementAt(i);
         int index = doc.Lights.Find(light.Id, true);
         if (index > -1)
         {
             Rhino.DocObjects.LightObject light_obj = doc.Lights[index];
             light_obj.Select(true);
             RhinoApp.RunScript("_-PropertiesPage _Light", true);
         }
         return(true);
     }
     return(false);
 }
        /// <summary>
        /// Return all the lights in the lightmanager
        /// </summary>
        public override void GetLights(RhinoDoc doc, ref LightArray light_array)
        {
            // Append all lights in doc
            for (int i = 0; i < doc.Lights.Count; i++)
            {
                Rhino.DocObjects.LightObject light = doc.Lights[i];
                if (!light.IsDeleted)
                {
                    light_array.Append(light.LightGeometry);
                }
            }

            // Append also the custom light
            foreach (Rhino.Geometry.Light custom_light in m_light_array)
            {
                light_array.Append(custom_light);
            }
        }
 public override void UnGroup(RhinoDoc doc, ref LightArray light_array)
 {
 }