Inheritance: ResourceItem
Esempio n. 1
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        public ResourceItem Convert(object input, String collection)
        {
            LightObject obj = (LightObject) input;
            LightItem ret = new LightItem();

            ret.LightType = obj.Type;
            ret.Properties = new Dictionary<string, object>();

            foreach (LightPropertyObject property in obj.Properties) {
                if(property.Key == "color") {
                    String[] colors = property.Value.Split(' ');
                    float[] colorf = SystemCore.Environment.CreateFloat32Array((ulong)colors.Length);

                    for (int i = 0; i < colors.Length; i++) {
                        colorf[i] = float.Parse(colors[i]);
                    }

                    ret.Properties["color"] = colorf;
                } else if (property.Key == "intensity") {
                    ret.Properties["intensity"] = float.Parse(property.Value);
                } else if (property.Key == "falloff_angle") {
                    ret.Properties["falloff_angle"] = float.Parse(property.Value);
                }
            }

            return ret;
        }
Esempio n. 2
0
        public void BindLight(Vector3 lightPos, LightItem light, Matrix4X4 mvMatrix, Matrix4X4 pMatrix)
        {
            if (this._parent.LightPassShader == null) return;

            /*uniforms*/
            this._graphics.UniformMatrix4fv(_parent.LightPassShader.Uniforms["uMVMatrix"], false, mvMatrix.Elements);
            this._graphics.UniformMatrix4fv(_parent.LightPassShader.Uniforms["uPMatrix"], false, pMatrix.Elements);

            this._graphics.Uniform3f(_parent.LightPassShader.Uniforms["uLightPos"], lightPos.Elements[0], lightPos.Elements[1], lightPos.Elements[2]);
            this._graphics.Uniform3f(_parent.LightPassShader.Uniforms["uLightColor"], ((float[])light.Properties["color"])[0],
                ((float[])light.Properties["color"])[1], ((float[])light.Properties["color"])[2]);
            this._graphics.Uniform1i(_parent.LightPassShader.Uniforms["uLightType"], light.LightType);
            this._graphics.Uniform1f(_parent.LightPassShader.Uniforms["uLightIntensity"], (float)light.Properties["intensity"]);
        }