Пример #1
0
        /// <summary>
        /// Create the corresponding <see cref="LightsState.Light"/> for this object.
        /// </summary>
        /// <returns>
        /// It returns the <see cref="LightsState.Light"/> equivalent to this SceneObjectLight.
        /// </returns>
        public override LightsState.Light ToLight(GraphicsContext ctx, SceneGraphContext sceneCtx)
        {
            TransformStateBase transformState = (TransformStateBase)sceneCtx.GraphicsStateStack.Current[TransformStateBase.StateSetIndex];

            LightsState.LightSpot light = new LightsState.LightSpot();

            SetLightParameters(sceneCtx, light);

            IModelMatrix worldModel   = transformState.LocalModelView;
            IMatrix3x3   normalMatrix = worldModel.GetComplementMatrix(3, 3).GetInverseMatrix().Transpose();

            light.Direction          = ((Vertex3f)normalMatrix.Multiply((Vertex3f)Direction)).Normalized;
            light.Position           = (Vertex3f)worldModel.Multiply(Vertex3f.Zero);
            light.AttenuationFactors = AttenuationFactors;
            light.FallOff            = new Vertex2f((float)Math.Cos(Angle.ToRadians(FalloffAngle)), FalloffExponent);

            // Shadow mapping
            if (_ShadowMap != null && _ShadowViewMatrix != null)
            {
                // Determined later: light.ShadowMapIndex
                light.ShadowMapMvp.Set(_ShadowViewMatrix);
                light.ShadowMap2D = _ShadowMap;
            }
            else
            {
                light.ShadowMapIndex = -1;
                light.ShadowMap2D    = null;
            }

            return(light);
        }
Пример #2
0
        /// <summary>
        /// Multiply this IModelMatrix with another IModelMatrix.
        /// </summary>
        /// <param name="a">
        /// A <see cref="IModelMatrix"/> that specify the right multiplication operand.
        /// </param>
        /// <returns>
        /// A <see cref="IModelMatrix"/> resulting from the product of this matrix and the matrix <paramref name="a"/>.
        /// </returns>
        IModelMatrix IModelMatrix.Multiply(IModelMatrix a)
        {
            ModelMatrixDouble rModelMatrix = new ModelMatrixDouble();

            ModelMatrixDouble modelMatrixDouble = a as ModelMatrixDouble;

            if (modelMatrixDouble != null)
            {
                ComputeMatrixProduct(rModelMatrix, this, modelMatrixDouble);
                return(rModelMatrix);
            }

            ModelMatrix modelMatrix = a as ModelMatrix;

            if (modelMatrix != null)
            {
                ComputeMatrixProduct(rModelMatrix, this, modelMatrix);
                return(rModelMatrix);
            }

            throw new NotSupportedException(String.Format("multiplication of {0} by {1} is not supported", GetType(), a.GetType()));
        }
Пример #3
0
		/// <summary>
		/// Multiply this IModelMatrix with another IModelMatrix.
		/// </summary>
		/// <param name="a">
		/// A <see cref="IModelMatrix"/> that specifies the right multiplication operand.
		/// </param>
		/// <returns>
		/// A <see cref="IModelMatrix"/> resulting from the product of this matrix and the matrix <paramref name="a"/>.
		/// </returns>
		IModelMatrix IModelMatrix.Multiply(IModelMatrix a)
		{
			ModelMatrix rModelMatrix = new ModelMatrix();

			ModelMatrix modelMatrix = a as ModelMatrix;
			if (modelMatrix != null) {
				ComputeMatrixProduct(rModelMatrix, this, modelMatrix);
				return (rModelMatrix);
			}

			ModelMatrixDouble modelMatrixDouble = a as ModelMatrixDouble;
			if (modelMatrixDouble != null) {
				ComputeMatrixProduct(rModelMatrix, this, modelMatrixDouble);
				return (rModelMatrix);
			}

			throw new NotSupportedException(String.Format("multiplication of {0} by {1} is not supported", GetType(), a.GetType()));
		}
Пример #4
0
 /// <summary>
 /// Draw the bounding volume.
 /// </summary>
 /// <param name="ctx">
 /// The <see cref="GraphicsContext"/> used for drawing.
 /// </param>
 public void Draw(GraphicsContext ctx, IModelMatrix objectViewModel)
 {
 }