public override void Update()
        {
            base.Update();

            // update the color of the ray
            GizmoUniformColorMaterial.UpdateColor(GraphicsDevice, rayMaterial, (Color) new Color4(GetLightColor(GraphicsDevice), 1f));
        }
Beispiel #2
0
 protected virtual void UpdateColors()
 {
     if (IsEnabled && RedUniformMaterial != null)
     {
         GizmoUniformColorMaterial.UpdateColor(GraphicsDevice, RedUniformMaterial, RedUniformColor);
         GizmoUniformColorMaterial.UpdateColor(GraphicsDevice, GreenUniformMaterial, GreenUniformColor);
         GizmoUniformColorMaterial.UpdateColor(GraphicsDevice, BlueUniformMaterial, BlueUniformColor);
     }
 }
Beispiel #3
0
        public override void Update()
        {
            base.Update();

            // update pointEntity aspect
            pointEntity.Transform.Scale = new Vector3(LightPoint.Radius);

            // update the spot color
            GizmoUniformColorMaterial.UpdateColor(GraphicsDevice, pointMaterial, (Color) new Color4(GetLightColor(GraphicsDevice), 1f));
        }
Beispiel #4
0
        public override void Update()
        {
            base.Update();

            // Update the frustum mesh to match the changed light settings:
            bool lightingModeChanged = (LightSpot.ProjectiveTexture == null && currentProjectiveTexture != null) || // <- if texture removed
                                       (LightSpot.ProjectiveTexture != null && currentProjectiveTexture == null);   // <- if texture added

            // Check if we need to rebuild the whole mesh:
            if (lightingModeChanged)
            {
                // Rebuild the mesh because we switched between textured and untextured mode:
                spotMesh.Build(GraphicsCommandList, LightSpot); // TODO: Does "Build()" properly release the resources?
                // Now assign the new mesh to the model component:
                UpdateModelComponentMesh();
            }

            // Check if we only need to update the vertex positions:
            bool GeometryAffectingParametersChanged = !MathUtil.NearEqual(currentAngleOuterInRadians, LightSpot.AngleOuterInRadians) ||
                                                      !MathUtil.NearEqual(currentRange, LightSpot.Range) ||
                                                      !MathUtil.NearEqual(currentAspectRatio, LightSpot.AspectRatio) ||                         // TODO: This will trigger a rebuild even if no texture is being used.
                                                      !MathUtil.NearEqual(currentProjectionPlaneDistance, LightSpot.ProjectionPlaneDistance) || // TODO: This will trigger a rebuild even if no texture is being used.
                                                      lightingModeChanged;

            if (GeometryAffectingParametersChanged) // TODO: PERFORMANCE: We're doing redundant work. If the lighting mode changes, we do a rebuild and then we also update the vertex positions (redundant).
            {
                // Save the current state:
                currentAngleOuterInRadians = LightSpot.AngleOuterInRadians; // "AngleOuterInRadians" already contains the max value between "AngleInner" and "AngleOuter".
                currentRange                   = LightSpot.Range;
                currentAspectRatio             = LightSpot.AspectRatio;
                currentProjectionPlaneDistance = LightSpot.ProjectionPlaneDistance;
                currentProjectiveTexture       = LightSpot.ProjectiveTexture;

                // Rebuild the mesh based on the new parameters:
                spotMesh.Rebuild(GraphicsCommandList, LightSpot);
            }

            // update the spot color
            GizmoUniformColorMaterial.UpdateColor(GraphicsDevice, spotMaterial, (Color) new Color4(GetLightColor(GraphicsDevice), 1f));
        }