Beispiel #1
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        void PushLightComponent(LightComponent component)
        {
            LightItem light = (LightItem) this._library.GetResource(component.LightHandle);

            if(light == null) {
                if(this._lightQueue[LightComponent.TypePoint] == null)
                    this._lightQueue[LightComponent.TypePoint] = new List<Node>();

                this._lightQueue[LightComponent.TypePoint].Add(component.Parent);
            } else {
                if (this._lightQueue[light.LightType] == null)
                    this._lightQueue[light.LightType] = new List<Node>();

                this._lightQueue[light.LightType].Add(component.Parent);
            }
        }
Beispiel #2
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        private void RenderLight(ShaderGroup lightShader, LightComponent component, MeshItem lightVolume)
        {
            LightItem light = (LightItem) this._library.GetResource(component.LightHandle);

            if(light == null)
                return;

            float intensity = (float) light.Properties["intensity"];

            /*update sphere scale matrix*/
            this._scaleMatrix.Elements[0] = intensity * 2;
            this._scaleMatrix.Elements[5] = intensity * 2;
            this._scaleMatrix.Elements[10] = intensity * 2;
            this._scaleMatrix.Elements[15] = 1.0f;

            this._vMatrix.MultiplyM2(component.Parent.World, this._mvMatrix);
            this._mvMatrix.MultiplyM2(this._scaleMatrix, this._mvMatrix);

            Vector3 pos = this._mvMatrix.TransformV(new Vector3(new float[] {0.0f, 0.0f, 0.0f}));

            /*check view occlusion*/
            this.UpdateCullInfo(this._mvMatrix);

            /*test for view occlusion*/
            if (this._occluder != null && !this._occluder.Test(this._cullInfo, null, lightVolume))
                return;

            /*bind shader, mesh and buffers*/
            lightShader.ShaderBinder.BindLight(pos, light, this._mvMatrix, this._pMatrix);
            this._context.DrawElements(WebGLE.Triangles, this._lightSphereVolume.Indexes.Length, WebGLE.UnsignedShortT, 0);
        }
Beispiel #3
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        void PopLightComponent(LightComponent component)
        {
            LightItem light = (LightItem)this._library.GetResource(component.LightHandle);

            if (light == null) {
                if (this._lightQueue[LightComponent.TypePoint] == null)
                    return;

                this._lightQueue[LightComponent.TypePoint].Remove(component.Parent);
            } else {
                if (this._lightQueue[light.LightType] == null)
                    return;

                this._lightQueue[light.LightType].Remove(component.Parent);
            }
        }