private void InitialiseSceneStateViewModel()
        {
            _lightSourceType = _sceneState.LightSourceType;
            _id = _sceneState.PointID;

            switch (_sceneState.ColorMode)
            {
            case "ct":
                _mirek = _sceneState.ColorTemperature;
                break;

            case "hs":
                _hue = _sceneState.Hue;
                break;
            }

            if (_sceneState.SceneType == SceneType.Image)
            {
                _sceneState.Point = new Point {
                    X = _x, Y = _y
                };
            }

            _saturation = _sceneState.Saturation;
            _brightness = _sceneState.Brightness;
        }
Example #2
0
 public SceneState(LightSourceType lightSourceType, SceneType sceneType, string id) : this()
 {
     LightSourceType = lightSourceType;
     SceneType       = sceneType;
     PointID         = id;
     ColorMode       = ColourHelper.GetColorMode(SceneType);
 }
 /// <summary>
 /// Create a new light source
 /// </summary>
 public Light()
 {
     LightSourceType = LightSourceType.Directonal;
     LightIntensity  = 10000;
     LightColor      = new Vector4(255, 255, 255, 1);
     Position        = new Vector3(0);
     Rotation        = new Vector3(45, 45, 0);
 }
 /// <summary>
 /// Make a Deep copy of a light source
 /// </summary>
 /// <param name="light"> Light source to copy </param>
 public Light(Light light)
 {
     LightSourceType = light.LightSourceType;
     LightIntensity  = light.LightIntensity;
     LightColor      = new Vector4(light.LightColor.X, light.LightColor.Y, light.LightColor.Z, light.LightColor.W);
     Position        = new Vector3(light.Position.X, light.Position.Y, light.Position.Z);
     Rotation        = new Vector3(light.Rotation.X, light.Rotation.Y, light.Rotation.Z);
 }
        /// <summary>
        /// Create a new light source
        /// </summary>
        /// <param name="lightSourceType"> The type of light source </param>
        /// <param name="lightColor"> The color of the light source </param>
        /// <param name="lightIntensity"> The intensity of the light source in LUX @ 1m^2 </param>
        /// <param name="position"> Position of the light source </param>
        /// <param name="rotation"> Rotation of the light source </param>
        public Light(LightSourceType lightSourceType, Vector4 lightColor, float lightIntensity, Vector3 position, Vector3 rotation)
        {
            LightSourceType = lightSourceType;
            LightIntensity  = lightIntensity;
            LightColor      = lightColor;

            Position = position;
            Rotation = rotation;
        }
Example #6
0
 /// <summary>
 /// Constructs a new instance of the <see cref="Light"/> class.
 /// </summary>
 public Light()
 {
     m_lightType      = LightSourceType.Undefined;
     m_attConstant    = 0.0f;
     m_attLinear      = 1.0f;
     m_attQuadratic   = 0.0f;
     m_angleInnerCone = (float)Math.PI * 2.0f;
     m_angleOuterCone = (float)Math.PI * 2.0f;
     m_areaSize       = new Vector2D(0.0f, 0.0f);
 }
Example #7
0
        /// <summary>Use this constructor when creating a brand new light source. Accounts for the type and modifies the coords accordingly.</summary>
        /// <param name="position">Position to create at. This will be a block position and therefore defaults to the back/left corner of the block initially.</param>
        /// <param name="type">Light source type to create.</param>
        /// <param name="attachedToFace">Face being attached to within this block.</param>
        public LightSource(ref Position position, LightSourceType type, Face attachedToFace) : base(ref position, attachedToFace)
        {
            Type = type;
            switch (type)
            {
            case LightSourceType.PlaceholderTorch:
                throw new NotSupportedException("Torch not finished.");

            case LightSourceType.Lantern:
                //adjust coords to account for the shape of a lantern (quarter block)
                const float EIGHTH = Constants.BLOCK_SIZE / 8;
                switch (AttachedToFace)
                {
                case Face.Front:
                    Coords.Xf += Constants.HALF_BLOCK_SIZE;
                    Coords.Yf += Constants.HALF_BLOCK_SIZE;
                    Coords.Zf += EIGHTH * 7;
                    break;

                case Face.Right:
                    Coords.Xf += EIGHTH * 7;
                    Coords.Yf += Constants.HALF_BLOCK_SIZE;
                    Coords.Zf += Constants.HALF_BLOCK_SIZE;
                    break;

                case Face.Top:                                 //flush with roof
                    Coords.Xf += Constants.HALF_BLOCK_SIZE;
                    Coords.Yf += Constants.QUARTER_BLOCK_SIZE * 3;
                    Coords.Zf += Constants.HALF_BLOCK_SIZE;
                    break;

                case Face.Left:
                    Coords.Xf += EIGHTH;
                    Coords.Yf += Constants.HALF_BLOCK_SIZE;
                    Coords.Zf += Constants.HALF_BLOCK_SIZE;
                    break;

                case Face.Bottom:                                 //flush with floor
                    Coords.Xf += Constants.HALF_BLOCK_SIZE;
                    Coords.Zf += Constants.HALF_BLOCK_SIZE;
                    break;

                default:                                 //back
                    Coords.Xf += Constants.HALF_BLOCK_SIZE;
                    Coords.Yf += Constants.HALF_BLOCK_SIZE;
                    Coords.Zf += EIGHTH;
                    break;
                }
                break;

            default:
                throw new Exception(string.Format("Cannot create unknown light source type: {0}", type));
            }
        }
Example #8
0
            void Parse(Stream s)
            {
                BinaryReader r = new BinaryReader(s);

                lightSource = (LightSourceType)r.ReadUInt32();
                transform   = new Vertex(requestedApiVersion, handler, s);
                color       = new RGB(requestedApiVersion, handler, s);
                intensity   = r.ReadSingle();
                for (int i = 0; i < lightSourceDataArray.Length; i++)
                {
                    lightSourceDataArray[i] = r.ReadSingle();
                }
            }
Example #9
0
 /// <summary>
 /// Reads the unmanaged data from the native value.
 /// </summary>
 /// <param name="nativeValue">Input native value</param>
 void IMarshalable <Light, AiLight> .FromNative(ref AiLight nativeValue)
 {
     m_name           = nativeValue.Name.GetString();
     m_lightType      = nativeValue.Type;
     m_angleInnerCone = nativeValue.AngleInnerCone;
     m_angleOuterCone = nativeValue.AngleOuterCone;
     m_attConstant    = nativeValue.AttenuationConstant;
     m_attLinear      = nativeValue.AttenuationLinear;
     m_attQuadratic   = nativeValue.AttenuationQuadratic;
     m_position       = nativeValue.Position;
     m_direction      = nativeValue.Direction;
     m_diffuse        = nativeValue.ColorDiffuse;
     m_specular       = nativeValue.ColorSpecular;
     m_ambient        = nativeValue.ColorAmbient;
 }
Example #10
0
 /// <summary>
 /// Constructs a new Light.
 /// </summary>
 /// <param name="light">Unmanaged AiLight struct</param>
 internal Light(ref AiLight light)
 {
     m_name           = light.Name.GetString();
     m_lightType      = light.Type;
     m_angleInnerCone = light.AngleInnerCone;
     m_angleOuterCone = light.AngleOuterCone;
     m_attConstant    = light.AttenuationConstant;
     m_attLinear      = light.AttenuationLinear;
     m_attQuadratic   = light.AttenuationQuadratic;
     m_position       = light.Position;
     m_direction      = light.Direction;
     m_diffuse        = light.ColorDiffuse;
     m_specular       = light.ColorSpecular;
     m_ambient        = light.ColorAmbient;
 }
Example #11
0
        /// <summary>
        /// Create a new light source
        /// </summary>
        /// <param name="lightSourceType"> The type of light source </param>
        /// <param name="lightColor"> The color of the light source </param>
        /// <param name="lightIntensity"> The intensity of the light source in LUX @ 1m^2 </param>
        public Light(LightSourceType lightSourceType, Vector4 lightColor, float lightIntensity)
        {
            LightSourceType = lightSourceType;
            LightColor      = lightColor;
            LightIntensity  = lightIntensity;

            if (lightSourceType == LightSourceType.Directonal)
            {
                Position = new Vector3(0);
                Rotation = new Vector3(45, 45, 0);
            }

            else if (lightSourceType == LightSourceType.Point)
            {
                Position = new Vector3(0);
                Rotation = new Vector3(0);
            }
        }
Example #12
0
        /// <summary>
        /// Create a new light source
        /// </summary>
        /// <param name="lightSourceType"> The type of light source </param>
        /// <param name="lightIntensity"> The intensity of the light source in LUX @ 1m^2 </param>
        /// <param name="position"> Position of the light source </param>
        /// <param name="rotation"> Rotation of the light source </param>
        public Light(LightSourceType lightSourceType, float lightIntensity, Vector3 position, Vector3 rotation)
        {
            LightSourceType = lightSourceType;
            LightIntensity  = lightIntensity;

            Position = position;
            Rotation = rotation;

            if (lightSourceType == LightSourceType.Directonal)
            {
                LightColor = new Vector4(255, 255, 255, 1);
            }

            else if (lightSourceType == LightSourceType.Point)
            {
                LightColor = new Vector4(255, 255, 255, 1);
            }
        }
Example #13
0
        /// <summary>
        /// Create a new light source
        /// </summary>
        /// <param name="lightSourceType"> The type of light source </param>
        /// <param name="lightColor"> The color of the light source </param>
        /// <param name="position"> Position of the light source </param>
        /// <param name="rotation"> Rotation of the light source </param>
        public Light(LightSourceType lightSourceType, Vector4 lightColor, Vector3 position, Vector3 rotation)
        {
            LightSourceType = lightSourceType;
            LightColor      = lightColor;

            Position = position;
            Rotation = rotation;

            if (lightSourceType == LightSourceType.Directonal)
            {
                LightIntensity = 17500;
            }

            else if (lightSourceType == LightSourceType.Point)
            {
                LightIntensity = 1000;
            }
        }
Example #14
0
        /// <summary>
        /// Create a new light source
        /// </summary>
        /// <param name="lightSourceType"> The type of light source </param>
        public Light(LightSourceType lightSourceType)
        {
            LightSourceType = lightSourceType;

            if (lightSourceType == LightSourceType.Directonal)
            {
                LightIntensity = 17500;
                LightColor     = new Vector4(255, 255, 255, 1);
                Position       = new Vector3(0);
                Rotation       = new Vector3(45, 45, 0);
            }

            else if (lightSourceType == LightSourceType.Point)
            {
                LightIntensity = 750;
                LightColor     = new Vector4(255, 255, 255, 1);
                Position       = new Vector3(0);
                Rotation       = new Vector3(0);
            }
        }
Example #15
0
 /// <summary>Check if key pressed is bound to an action button.</summary>
 public static bool IsActionKey(char keyBind, out Block.BlockType? blockType, out LightSourceType? lightSourceType)
 {
     foreach (var actionButton in _actionButtons.Where(actionButton => actionButton.KeyBind == keyBind))
     {
         if (actionButton.LightSourceType.HasValue)
         {
             lightSourceType = actionButton.LightSourceType.Value;
             blockType = null;
         }
         else
         {
             blockType = actionButton.BlockType;
             lightSourceType = null;
         }
         return true;
     }
     blockType = null;
     lightSourceType = null;
     return false;
 }
Example #16
0
 public LightSource(int apiVersion, EventHandler handler, LightSourceType sectionType
                    , float X, float Y, float Z
                    , float R, float G, float B, float intensity
                    , float[] lightSourceData
                    )
     : base(apiVersion, handler)
 {
     this.lightSource = sectionType;
     this.transform   = new Vertex(requestedApiVersion, handler, X, Y, Z);
     this.color       = new RGB(requestedApiVersion, handler, R, G, B);
     this.intensity   = intensity;
     if (checking)
     {
         if (lightSourceData.Length != 24)
         {
             throw new ArgumentException("Array length must be 24");
         }
     }
     this.lightSourceDataArray = (float[])lightSourceData.Clone();
     PointToLightSourceData();
 }
Example #17
0
 public LightSource(LightSourceType type, float intensity)
 {
     Type      = type;
     Intensity = intensity;
 }
Example #18
0
 /// <summary>
 /// Constructs a new instance of the <see cref="Light"/> class.
 /// </summary>
 public Light()
 {
     m_lightType = LightSourceType.Undefined;
 }
 public static T SetLightSourceType <T>(this T entity, LightSourceType value)
     where T : LightSourceForm
 {
     entity.SetField("lightSourceType", value);
     return(entity);
 }
Example #20
0
 private static void AddButtonToPickerGrid(ref int col, ref int y, string name, int texture, Block.BlockType blockType = 0, LightSourceType? lightSourceType = null)
 {
     if (name.StartsWith("Placeholder")) return;
     Debug.Assert(!(blockType != 0 && lightSourceType.HasValue), "Cannot have block and light source types at the same time.");
     if (col % GRID_BUTTONS_PER_ROW == 0)
     {
         col = 1;
         y += BUTTON_SIZE;
     }
     var button = new Button(ButtonType.GridPicker, Settings.Game.Width / 2 - (GRID_BUTTONS_PER_ROW / 2 * BUTTON_SIZE) + (col * BUTTON_SIZE), y, texture)
         {
             BlockType = blockType,
             LightSourceType = lightSourceType
         };
     _blockPickerGridButtons.Add(button);
     col++;
 }
Example #21
0
 public Light()
 {
     this.Type = LightSourceType.Undefined;
     this.AttenuationConstant = 0f;
     this.AttenuationLinear = 1f;
     this.AttenuationQuadratic = 0f;
     this.AngleInnerCone = MathUtil.TwoPi;
     this.AngleOuterCone = MathUtil.TwoPi;
 }
Example #22
0
 /// <summary>Use this constructor to create already existing Light Sources, such as would come from the server. Use the constructor that accepts Position to create a brand new Light Source.</summary>
 public LightSource(ref Coords coords, LightSourceType type, Face attachedToFace, int id) : base(ref coords, attachedToFace, id)
 {
     Type          = type;
     LightStrength = GetLightSourceStrength();
     WorldData.Chunks[Coords].LightSources.TryAdd(Id, this);
 }
Example #23
0
        //izbor komponente tackastog osvetljenja
        public void ChangeLight(OpenGL gl)
        {
            SelectedLightSourceType = (LightSourceType)(((int)m_selectedLightSourceType + 1) % Enum.GetNames(typeof(LightSourceType)).Length);
            switch (m_selectedLightSourceType)
            {
            case LightSourceType.Zuto:

                //Osvetljenje
                float[] light3pos      = new float[] { 150f, 150f, -45f, 1f };
                float[] light3ambient  = new float[] { 0.576471f, 0.858824f, 0.439216f, 1.0f };
                float[] light3diffuse  = new float[] { 0.576471f, 0.858824f, 0.439216f, 1.0f };
                float[] light3specular = new float[] { 1.0f, 1.0f, 1.0f, 1.0f };

                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, light3pos);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, light3ambient);
                //gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, light3diffuse);
                //gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPECULAR, light3specular);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPOT_CUTOFF, 180f);     //tackasti svetlosni izvor
                gl.Enable(OpenGL.GL_LIGHT0);
                break;

            case LightSourceType.Crveno:

                float[] light0pos      = new float[] { 150f, 150f, -45f, 1f };
                float[] light0ambient  = new float[] { 1.0f, 0f, 0f, 1.0f };
                float[] light0diffuse  = new float[] { 1.0f, 0f, 0f, 1.0f };
                float[] light0specular = new float[] { 1.0f, 0f, 0f, 1.0f };

                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPOT_CUTOFF, 180.0f);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, light0pos);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, light0ambient);
                //gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, light0diffuse);
                // gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPECULAR, light0specular);
                gl.Enable(OpenGL.GL_LIGHT0);
                break;

            case LightSourceType.Zeleno:

                float[] light1pos      = new float[] { 150f, 150f, -45f, 1f };
                float[] light1ambient  = new float[] { 0f, 1f, 0f, 1.0f };
                float[] light1diffuse  = new float[] { 0f, 1f, 0f, 1.0f };
                float[] light1specular = new float[] { 0f, 1f, 0f, 1.0f };

                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPOT_CUTOFF, 180.0f);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, light1pos);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, light1ambient);
                //gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, light1diffuse);
                //gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPECULAR, light1specular);
                gl.Enable(OpenGL.GL_LIGHT0);
                break;

            case LightSourceType.Plavo:


                float[] light2pos      = new float[] { 150f, 150f, -45f, 1f };
                float[] light2ambient  = new float[] { 0f, 0f, 1f, 1.0f };
                float[] light2diffuse  = new float[] { 0f, 0f, 1f, 1.0f };
                float[] light2specular = new float[] { 0f, 0f, 1f, 1.0f };

                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPOT_CUTOFF, 180.0f);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, light2pos);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, light2ambient);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, light2diffuse);
                gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_SPECULAR, light2specular);
                gl.Enable(OpenGL.GL_LIGHT0);
                break;
            }
        }