Revision: 2214
Author: mike.popoloski
Date: Sun May 18 20:39:07 2014 UTC
Log: Checking in a stripped down version of SlimDX that builds cleanly
with the latest Windows Kits in Visual Studio 2013.
http://code.google.com/p/slimdx/source/detail?r=2214
Added:
/branches/vs2013
/branches/vs2013/License.txt
/branches/vs2013/SlimMath
/branches/vs2013/SlimMath/BoundingBox.cs
/branches/vs2013/SlimMath/BoundingSphere.cs
/branches/vs2013/SlimMath/Color3.cs
/branches/vs2013/SlimMath/Color4.cs
/branches/vs2013/SlimMath/Design
/branches/vs2013/SlimMath/Design/BaseConverter.cs
/branches/vs2013/SlimMath/Design/FieldPropertyDescriptor.cs
/branches/vs2013/SlimMath/Design/Half2Converter.cs
/branches/vs2013/SlimMath/Design/Half3Converter.cs
/branches/vs2013/SlimMath/Design/Half4Converter.cs
/branches/vs2013/SlimMath/Design/HalfConverter.cs
/branches/vs2013/SlimMath/Design/MatrixConverter.cs
/branches/vs2013/SlimMath/Design/QuaternionConverter.cs
/branches/vs2013/SlimMath/Design/Vector2Converter.cs
/branches/vs2013/SlimMath/Design/Vector3Converter.cs
/branches/vs2013/SlimMath/Design/Vector4Converter.cs
/branches/vs2013/SlimMath/Half.cs
/branches/vs2013/SlimMath/Half2.cs
/branches/vs2013/SlimMath/Half3.cs
/branches/vs2013/SlimMath/Half4.cs
/branches/vs2013/SlimMath/HalfUtilities.cs
/branches/vs2013/SlimMath/Matrix.cs
/branches/vs2013/SlimMath/Matrix3x2.cs
/branches/vs2013/SlimMath/Plane.cs
/branches/vs2013/SlimMath/Properties
/branches/vs2013/SlimMath/Properties/AssemblyInfo.cs
/branches/vs2013/SlimMath/Quaternion.cs
/branches/vs2013/SlimMath/Rational.cs
/branches/vs2013/SlimMath/SlimMath.csproj
/branches/vs2013/SlimMath/Utilities.cs
/branches/vs2013/SlimMath/Vector2.cs
/branches/vs2013/SlimMath/Vector3.cs
/branches/vs2013/SlimMath/Vector4.cs
/branches/vs2013/build
/branches/vs2013/build/CustomDictionary.xml
/branches/vs2013/build/SlimDX.FxCop
/branches/vs2013/build/SlimDX.sln
/branches/vs2013/build/SlimDX.vcxproj
/branches/vs2013/build/SlimDX.vcxproj.filters
/branches/vs2013/source
/branches/vs2013/source/AssemblyInfo.cpp
/branches/vs2013/source/CollectionShim.h
/branches/vs2013/source/ComObject.cpp
/branches/vs2013/source/ComObject.h
/branches/vs2013/source/ComObjectMacros.h
/branches/vs2013/source/CompilationException.cpp
/branches/vs2013/source/CompilationException.h
/branches/vs2013/source/Configuration.cpp
/branches/vs2013/source/Configuration.h
/branches/vs2013/source/DataBox.cpp
/branches/vs2013/source/DataBox.h
/branches/vs2013/source/DataRectangle.cpp
/branches/vs2013/source/DataRectangle.h
/branches/vs2013/source/DataStream.cpp
/branches/vs2013/source/DataStream.h
/branches/vs2013/source/Enums.h
/branches/vs2013/source/InternalHelpers.h
/branches/vs2013/source/ObjectTable.cpp
/branches/vs2013/source/ObjectTable.h
/branches/vs2013/source/Result.cpp
/branches/vs2013/source/Result.h
/branches/vs2013/source/SlimDXException.cpp
/branches/vs2013/source/SlimDXException.h
/branches/vs2013/source/Utilities.cpp
/branches/vs2013/source/Utilities.h
/branches/vs2013/source/VersionConfig.h
/branches/vs2013/source/auto_array.h
/branches/vs2013/source/d3dcompiler
/branches/vs2013/source/d3dcompiler/ConstantBufferDC.cpp
/branches/vs2013/source/d3dcompiler/ConstantBufferDC.h
/branches/vs2013/source/d3dcompiler/ConstantBufferDescriptionDC.cpp
/branches/vs2013/source/d3dcompiler/ConstantBufferDescriptionDC.h
/branches/vs2013/source/d3dcompiler/D3DCompilerException.cpp
/branches/vs2013/source/d3dcompiler/D3DCompilerException.h
/branches/vs2013/source/d3dcompiler/EnumsDC.h
/branches/vs2013/source/d3dcompiler/IncludeDC.cpp
/branches/vs2013/source/d3dcompiler/IncludeDC.h
/branches/vs2013/source/d3dcompiler/InputBindingDescriptionDC.cpp
/branches/vs2013/source/d3dcompiler/InputBindingDescriptionDC.h
/branches/vs2013/source/d3dcompiler/ShaderBytecodeDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderBytecodeDC.h
/branches/vs2013/source/d3dcompiler/ShaderDescriptionDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderDescriptionDC.h
/branches/vs2013/source/d3dcompiler/ShaderMacroDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderMacroDC.h
/branches/vs2013/source/d3dcompiler/ShaderParameterDescriptionDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderParameterDescriptionDC.h
/branches/vs2013/source/d3dcompiler/ShaderReflectionDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderReflectionDC.h
/branches/vs2013/source/d3dcompiler/ShaderReflectionTypeDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderReflectionTypeDC.h
/branches/vs2013/source/d3dcompiler/ShaderReflectionVariableDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderReflectionVariableDC.h
/branches/vs2013/source/d3dcompiler/ShaderSignatureDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderSignatureDC.h
/branches/vs2013/source/d3dcompiler/ShaderTypeDescriptionDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderTypeDescriptionDC.h
/branches/vs2013/source/d3dcompiler/ShaderVariableDescriptionDC.cpp
/branches/vs2013/source/d3dcompiler/ShaderVariableDescriptionDC.h
/branches/vs2013/source/direct3d11
/branches/vs2013/source/direct3d11/Asynchronous11.cpp
/branches/vs2013/source/direct3d11/Asynchronous11.h
/branches/vs2013/source/direct3d11/BlendState11.cpp
/branches/vs2013/source/direct3d11/BlendState11.h
/branches/vs2013/source/direct3d11/BlendStateDescription11.cpp
/branches/vs2013/source/direct3d11/BlendStateDescription11.h
/branches/vs2013/source/direct3d11/Buffer11.cpp
/branches/vs2013/source/direct3d11/Buffer11.h
/branches/vs2013/source/direct3d11/BufferDescription11.cpp
/branches/vs2013/source/direct3d11/BufferDescription11.h
/branches/vs2013/source/direct3d11/ClassInstance11.cpp
/branches/vs2013/source/direct3d11/ClassInstance11.h
/branches/vs2013/source/direct3d11/ClassInstanceDescription11.cpp
/branches/vs2013/source/direct3d11/ClassInstanceDescription11.h
/branches/vs2013/source/direct3d11/ClassLinkage11.cpp
/branches/vs2013/source/direct3d11/ClassLinkage11.h
/branches/vs2013/source/direct3d11/CommandList11.cpp
/branches/vs2013/source/direct3d11/CommandList11.h
/branches/vs2013/source/direct3d11/ComputeShader11.cpp
/branches/vs2013/source/direct3d11/ComputeShader11.h
/branches/vs2013/source/direct3d11/ComputeShaderWrapper11.cpp
/branches/vs2013/source/direct3d11/ComputeShaderWrapper11.h
/branches/vs2013/source/direct3d11/Counter11.cpp
/branches/vs2013/source/direct3d11/Counter11.h
/branches/vs2013/source/direct3d11/CounterCapabilities11.cpp
/branches/vs2013/source/direct3d11/CounterCapabilities11.h
/branches/vs2013/source/direct3d11/CounterMetadata11.cpp
/branches/vs2013/source/direct3d11/CounterMetadata11.h
/branches/vs2013/source/direct3d11/Debug11.cpp
/branches/vs2013/source/direct3d11/Debug11.h
/branches/vs2013/source/direct3d11/DebugMessage11.cpp
/branches/vs2013/source/direct3d11/DebugMessage11.h
/branches/vs2013/source/direct3d11/DebugMessageId11.h
/branches/vs2013/source/direct3d11/DepthStencilOperationDescription11.cpp
/branches/vs2013/source/direct3d11/DepthStencilOperationDescription11.h
/branches/vs2013/source/direct3d11/DepthStencilState11.cpp
/branches/vs2013/source/direct3d11/DepthStencilState11.h
/branches/vs2013/source/direct3d11/DepthStencilStateDescription11.cpp
/branches/vs2013/source/direct3d11/DepthStencilStateDescription11.h
/branches/vs2013/source/direct3d11/DepthStencilView11.cpp
/branches/vs2013/source/direct3d11/DepthStencilView11.h
/branches/vs2013/source/direct3d11/DepthStencilViewDescription11.cpp
/branches/vs2013/source/direct3d11/DepthStencilViewDescription11.h
/branches/vs2013/source/direct3d11/Device11.cpp
/branches/vs2013/source/direct3d11/Device11.h
/branches/vs2013/source/direct3d11/DeviceChild11.cpp
/branches/vs2013/source/direct3d11/DeviceChild11.h
/branches/vs2013/source/direct3d11/DeviceContext11.cpp
/branches/vs2013/source/direct3d11/DeviceContext11.h
/branches/vs2013/source/direct3d11/Direct3D11Exception.cpp
/branches/vs2013/source/direct3d11/Direct3D11Exception.h
/branches/vs2013/source/direct3d11/DomainShader11.cpp
/branches/vs2013/source/direct3d11/DomainShader11.h
/branches/vs2013/source/direct3d11/DomainShaderWrapper11.cpp
/branches/vs2013/source/direct3d11/DomainShaderWrapper11.h
/branches/vs2013/source/direct3d11/Enums11.h
/branches/vs2013/source/direct3d11/GeometryShader11.cpp
/branches/vs2013/source/direct3d11/GeometryShader11.h
/branches/vs2013/source/direct3d11/GeometryShaderWrapper11.cpp
/branches/vs2013/source/direct3d11/GeometryShaderWrapper11.h
/branches/vs2013/source/direct3d11/HullShader11.cpp
/branches/vs2013/source/direct3d11/HullShader11.h
/branches/vs2013/source/direct3d11/HullShaderWrapper11.cpp
/branches/vs2013/source/direct3d11/HullShaderWrapper11.h
/branches/vs2013/source/direct3d11/InfoQueue11.cpp
/branches/vs2013/source/direct3d11/InfoQueue11.h
/branches/vs2013/source/direct3d11/InfoQueueFilter11.cpp
/branches/vs2013/source/direct3d11/InfoQueueFilter11.h
/branches/vs2013/source/direct3d11/InfoQueueFilterDescription11.cpp
/branches/vs2013/source/direct3d11/InfoQueueFilterDescription11.h
/branches/vs2013/source/direct3d11/InputAssemblerWrapper11.cpp
/branches/vs2013/source/direct3d11/InputAssemblerWrapper11.h
/branches/vs2013/source/direct3d11/InputElement11.cpp
/branches/vs2013/source/direct3d11/InputElement11.h
/branches/vs2013/source/direct3d11/InputLayout11.cpp
/branches/vs2013/source/direct3d11/InputLayout11.h
/branches/vs2013/source/direct3d11/OutputMergerWrapper11.cpp
/branches/vs2013/source/direct3d11/OutputMergerWrapper11.h
/branches/vs2013/source/direct3d11/PerfAnnotation.cpp
/branches/vs2013/source/direct3d11/PerfAnnotation.h
/branches/vs2013/source/direct3d11/PipelineStatistics11.cpp
/branches/vs2013/source/direct3d11/PipelineStatistics11.h
/branches/vs2013/source/direct3d11/PixelShader11.cpp
/branches/vs2013/source/direct3d11/PixelShader11.h
/branches/vs2013/source/direct3d11/PixelShaderWrapper11.cpp
/branches/vs2013/source/direct3d11/PixelShaderWrapper11.h
/branches/vs2013/source/direct3d11/Predicate11.cpp
/branches/vs2013/source/direct3d11/Predicate11.h
/branches/vs2013/source/direct3d11/Query11.cpp
/branches/vs2013/source/direct3d11/Query11.h
/branches/vs2013/source/direct3d11/QueryDescription11.cpp
/branches/vs2013/source/direct3d11/QueryDescription11.h
/branches/vs2013/source/direct3d11/RasterizerState11.cpp
/branches/vs2013/source/direct3d11/RasterizerState11.h
/branches/vs2013/source/direct3d11/RasterizerStateDescription11.cpp
/branches/vs2013/source/direct3d11/RasterizerStateDescription11.h
/branches/vs2013/source/direct3d11/RasterizerWrapper11.cpp
/branches/vs2013/source/direct3d11/RasterizerWrapper11.h
/branches/vs2013/source/direct3d11/RenderTargetBlendDescription11.cpp
/branches/vs2013/source/direct3d11/RenderTargetBlendDescription11.h
/branches/vs2013/source/direct3d11/RenderTargetView11.cpp
/branches/vs2013/source/direct3d11/RenderTargetView11.h
/branches/vs2013/source/direct3d11/RenderTargetViewDescription11.cpp
/branches/vs2013/source/direct3d11/RenderTargetViewDescription11.h
/branches/vs2013/source/direct3d11/Resource11.cpp
/branches/vs2013/source/direct3d11/Resource11.h
/branches/vs2013/source/direct3d11/ResourceRegion11.cpp
/branches/vs2013/source/direct3d11/ResourceRegion11.h
/branches/vs2013/source/direct3d11/ResourceView11.cpp
/branches/vs2013/source/direct3d11/ResourceView11.h
/branches/vs2013/source/direct3d11/ResultCode11.cpp
/branches/vs2013/source/direct3d11/ResultCode11.h
/branches/vs2013/source/direct3d11/SamplerDescription11.cpp
/branches/vs2013/source/direct3d11/SamplerDescription11.h
/branches/vs2013/source/direct3d11/SamplerState11.cpp
/branches/vs2013/source/direct3d11/SamplerState11.h
/branches/vs2013/source/direct3d11/ShaderResourceView11.cpp
/branches/vs2013/source/direct3d11/ShaderResourceView11.h
/branches/vs2013/source/direct3d11/ShaderResourceViewDescription11.cpp
/branches/vs2013/source/direct3d11/ShaderResourceViewDescription11.h
/branches/vs2013/source/direct3d11/StreamOutputBufferBinding11.cpp
/branches/vs2013/source/direct3d11/StreamOutputBufferBinding11.h
/branches/vs2013/source/direct3d11/StreamOutputElement11.cpp
/branches/vs2013/source/direct3d11/StreamOutputElement11.h
/branches/vs2013/source/direct3d11/StreamOutputStatistics11.cpp
/branches/vs2013/source/direct3d11/StreamOutputStatistics11.h
/branches/vs2013/source/direct3d11/StreamOutputWrapper11.cpp
/branches/vs2013/source/direct3d11/StreamOutputWrapper11.h
/branches/vs2013/source/direct3d11/Texture1D11.cpp
/branches/vs2013/source/direct3d11/Texture1D11.h
/branches/vs2013/source/direct3d11/Texture1DDescription11.cpp
/branches/vs2013/source/direct3d11/Texture1DDescription11.h
/branches/vs2013/source/direct3d11/Texture2D11.cpp
/branches/vs2013/source/direct3d11/Texture2D11.h
/branches/vs2013/source/direct3d11/Texture2DDescription11.cpp
/branches/vs2013/source/direct3d11/Texture2DDescription11.h
/branches/vs2013/source/direct3d11/Texture3D11.cpp
/branches/vs2013/source/direct3d11/Texture3D11.h
/branches/vs2013/source/direct3d11/Texture3DDescription11.cpp
/branches/vs2013/source/direct3d11/Texture3DDescription11.h
/branches/vs2013/source/direct3d11/TextureLoader.cpp
/branches/vs2013/source/direct3d11/TextureLoader.h
/branches/vs2013/source/direct3d11/TimestampQueryData11.cpp
/branches/vs2013/source/direct3d11/TimestampQueryData11.h
/branches/vs2013/source/direct3d11/UnorderedAccessView11.cpp
/branches/vs2013/source/direct3d11/UnorderedAccessView11.h
/branches/vs2013/source/direct3d11/UnorderedAccessViewDescription11.cpp
/branches/vs2013/source/direct3d11/UnorderedAccessViewDescription11.h
/branches/vs2013/source/direct3d11/VertexBufferBinding11.cpp
/branches/vs2013/source/direct3d11/VertexBufferBinding11.h
/branches/vs2013/source/direct3d11/VertexShader11.cpp
/branches/vs2013/source/direct3d11/VertexShader11.h
/branches/vs2013/source/direct3d11/VertexShaderWrapper11.cpp
/branches/vs2013/source/direct3d11/VertexShaderWrapper11.h
/branches/vs2013/source/direct3d11/Viewport11.cpp
/branches/vs2013/source/direct3d11/Viewport11.h
/branches/vs2013/source/directwrite
/branches/vs2013/source/directwrite/BitmapRenderTargetDW.cpp
/branches/vs2013/source/directwrite/BitmapRenderTargetDW.h
/branches/vs2013/source/directwrite/ClusterMetrics.h
/branches/vs2013/source/directwrite/DirectWriteException.cpp
/branches/vs2013/source/directwrite/DirectWriteException.h
/branches/vs2013/source/directwrite/Enums.h
/branches/vs2013/source/directwrite/FactoryDW.cpp
/branches/vs2013/source/directwrite/FactoryDW.h
/branches/vs2013/source/directwrite/Font.cpp
/branches/vs2013/source/directwrite/Font.h
/branches/vs2013/source/directwrite/FontCollection.cpp
/branches/vs2013/source/directwrite/FontCollection.h
/branches/vs2013/source/directwrite/FontCollectionLoader.cpp
/branches/vs2013/source/directwrite/FontCollectionLoader.h
/branches/vs2013/source/directwrite/FontFace.cpp
/branches/vs2013/source/directwrite/FontFace.h
/branches/vs2013/source/directwrite/FontFamily.cpp
/branches/vs2013/source/directwrite/FontFamily.h
/branches/vs2013/source/directwrite/FontFeature.cpp
/branches/vs2013/source/directwrite/FontFeature.h
/branches/vs2013/source/directwrite/FontFile.cpp
/branches/vs2013/source/directwrite/FontFile.h
/branches/vs2013/source/directwrite/FontFileAnalysis.cpp
/branches/vs2013/source/directwrite/FontFileAnalysis.h
/branches/vs2013/source/directwrite/FontFileEnumerator.cpp
/branches/vs2013/source/directwrite/FontFileEnumerator.h
/branches/vs2013/source/directwrite/FontFileLoader.cpp
/branches/vs2013/source/directwrite/FontFileLoader.h
/branches/vs2013/source/directwrite/FontFileStream.cpp
/branches/vs2013/source/directwrite/FontFileStream.h
/branches/vs2013/source/directwrite/FontList.cpp
/branches/vs2013/source/directwrite/FontList.h
/branches/vs2013/source/directwrite/FontMetrics.cpp
/branches/vs2013/source/directwrite/FontMetrics.h
/branches/vs2013/source/directwrite/FontTable.cpp
/branches/vs2013/source/directwrite/FontTable.h
/branches/vs2013/source/directwrite/GdiInterop.cpp
/branches/vs2013/source/directwrite/GdiInterop.h
/branches/vs2013/source/directwrite/GlyphMetrics.cpp
/branches/vs2013/source/directwrite/GlyphMetrics.h
/branches/vs2013/source/directwrite/GlyphOffset.cpp
/branches/vs2013/source/directwrite/GlyphOffset.h
/branches/vs2013/source/directwrite/GlyphRunAnalysis.cpp
/branches/vs2013/source/directwrite/GlyphRunAnalysis.h
/branches/vs2013/source/directwrite/GlyphRunDW.cpp
/branches/vs2013/source/directwrite/GlyphRunDW.h
/branches/vs2013/source/directwrite/GlyphRunDescription.cpp
/branches/vs2013/source/directwrite/GlyphRunDescription.h
/branches/vs2013/source/directwrite/HitTestMetrics.h
/branches/vs2013/source/directwrite/IClientDrawingEffect.h
/branches/vs2013/source/directwrite/IFontCollectionLoader.cpp
/branches/vs2013/source/directwrite/IFontCollectionLoader.h
/branches/vs2013/source/directwrite/IFontFileLoader.cpp
/branches/vs2013/source/directwrite/IFontFileLoader.h
/branches/vs2013/source/directwrite/ITextRenderer.cpp
/branches/vs2013/source/directwrite/ITextRenderer.h
/branches/vs2013/source/directwrite/InlineObject.cpp
/branches/vs2013/source/directwrite/InlineObject.h
/branches/vs2013/source/directwrite/InlineObjectMetrics.h
/branches/vs2013/source/directwrite/LineMetrics.h
/branches/vs2013/source/directwrite/LocalizedStrings.cpp
/branches/vs2013/source/directwrite/LocalizedStrings.h
/branches/vs2013/source/directwrite/NumberSubstitution.cpp
/branches/vs2013/source/directwrite/NumberSubstitution.h
/branches/vs2013/source/directwrite/OverhangMetrics.h
/branches/vs2013/source/directwrite/PixelSnapping.cpp
/branches/vs2013/source/directwrite/PixelSnapping.h
/branches/vs2013/source/directwrite/RenderingParameters.cpp
/branches/vs2013/source/directwrite/RenderingParameters.h
/branches/vs2013/source/directwrite/ResultCodeDW.cpp
/branches/vs2013/source/directwrite/ResultCodeDW.h
/branches/vs2013/source/directwrite/Strikethrough.cpp
/branches/vs2013/source/directwrite/Strikethrough.h
/branches/vs2013/source/directwrite/TextAnalysisSink.cpp
/branches/vs2013/source/directwrite/TextAnalysisSink.h
/branches/vs2013/source/directwrite/TextAnalysisSource.cpp
/branches/vs2013/source/directwrite/TextAnalysisSource.h
/branches/vs2013/source/directwrite/TextAnalyzer.cpp
/branches/vs2013/source/directwrite/TextAnalyzer.h
/branches/vs2013/source/directwrite/TextFormat.cpp
/branches/vs2013/source/directwrite/TextFormat.h
/branches/vs2013/source/directwrite/TextLayout.cpp
/branches/vs2013/source/directwrite/TextLayout.h
/branches/vs2013/source/directwrite/TextMetrics.h
/branches/vs2013/source/directwrite/TextRange.cpp
/branches/vs2013/source/directwrite/TextRange.h
/branches/vs2013/source/directwrite/ToDo.txt
/branches/vs2013/source/directwrite/Trimming.h
/branches/vs2013/source/directwrite/Typography.cpp
/branches/vs2013/source/directwrite/Typography.h
/branches/vs2013/source/directwrite/Underline.cpp
/branches/vs2013/source/directwrite/Underline.h
/branches/vs2013/source/dxgi
/branches/vs2013/source/dxgi/Adapter.cpp
/branches/vs2013/source/dxgi/Adapter.h
/branches/vs2013/source/dxgi/Adapter1.cpp
/branches/vs2013/source/dxgi/Adapter1.h
/branches/vs2013/source/dxgi/AdapterDescription.cpp
/branches/vs2013/source/dxgi/AdapterDescription.h
/branches/vs2013/source/dxgi/AdapterDescription1.cpp
/branches/vs2013/source/dxgi/AdapterDescription1.h
/branches/vs2013/source/dxgi/DXGIException.cpp
/branches/vs2013/source/dxgi/DXGIException.h
/branches/vs2013/source/dxgi/DXGIExtensionMethods.cpp
/branches/vs2013/source/dxgi/DXGIExtensionMethods.h
/branches/vs2013/source/dxgi/Device1.cpp
/branches/vs2013/source/dxgi/Device1.h
/branches/vs2013/source/dxgi/DeviceChildDxgi.cpp
/branches/vs2013/source/dxgi/DeviceChildDxgi.h
/branches/vs2013/source/dxgi/DeviceDxgi.cpp
/branches/vs2013/source/dxgi/DeviceDxgi.h
/branches/vs2013/source/dxgi/Enums.h
/branches/vs2013/source/dxgi/Factory.cpp
/branches/vs2013/source/dxgi/Factory.h
/branches/vs2013/source/dxgi/Factory1.cpp
/branches/vs2013/source/dxgi/Factory1.h
/branches/vs2013/source/dxgi/FrameStatistics.cpp
/branches/vs2013/source/dxgi/FrameStatistics.h
/branches/vs2013/source/dxgi/GammaControl.cpp
/branches/vs2013/source/dxgi/GammaControl.h
/branches/vs2013/source/dxgi/GammaControlCapabilities.cpp
/branches/vs2013/source/dxgi/GammaControlCapabilities.h
/branches/vs2013/source/dxgi/KeyedMutex.cpp
/branches/vs2013/source/dxgi/KeyedMutex.h
/branches/vs2013/source/dxgi/ModeDescription.cpp
/branches/vs2013/source/dxgi/ModeDescription.h
/branches/vs2013/source/dxgi/ObjectDxgi.cpp
/branches/vs2013/source/dxgi/ObjectDxgi.h
/branches/vs2013/source/dxgi/Output.cpp
/branches/vs2013/source/dxgi/Output.h
/branches/vs2013/source/dxgi/OutputDescription.cpp
/branches/vs2013/source/dxgi/OutputDescription.h
/branches/vs2013/source/dxgi/ResourceDxgi.cpp
/branches/vs2013/source/dxgi/ResourceDxgi.h
/branches/vs2013/source/dxgi/ResultCodeDxgi.cpp
/branches/vs2013/source/dxgi/ResultCodeDxgi.h
/branches/vs2013/source/dxgi/SampleDescription.cpp
/branches/vs2013/source/dxgi/SampleDescription.h
/branches/vs2013/source/dxgi/Surface1.cpp
/branches/vs2013/source/dxgi/Surface1.h
/branches/vs2013/source/dxgi/SurfaceDescription.cpp
/branches/vs2013/source/dxgi/SurfaceDescription.h
/branches/vs2013/source/dxgi/SurfaceDxgi.cpp
/branches/vs2013/source/dxgi/SurfaceDxgi.h
/branches/vs2013/source/dxgi/SwapChainDescription.cpp
/branches/vs2013/source/dxgi/SwapChainDescription.h
/branches/vs2013/source/dxgi/SwapChainDxgi.cpp
/branches/vs2013/source/dxgi/SwapChainDxgi.h
/branches/vs2013/source/external
/branches/vs2013/source/external/DDSTextureLoader.cpp
/branches/vs2013/source/external/DDSTextureLoader.h
/branches/vs2013/source/external/dxerr.cpp
/branches/vs2013/source/external/dxerr.h
/branches/vs2013/source/rawinput
/branches/vs2013/source/rawinput/DeviceInfo.cpp
/branches/vs2013/source/rawinput/DeviceInfo.h
/branches/vs2013/source/rawinput/DeviceRI.cpp
/branches/vs2013/source/rawinput/DeviceRI.h
/branches/vs2013/source/rawinput/Enums.h
/branches/vs2013/source/rawinput/HidInfo.h
/branches/vs2013/source/rawinput/InputMessageFilter.cpp
/branches/vs2013/source/rawinput/InputMessageFilter.h
/branches/vs2013/source/rawinput/KeyboardInfo.h
/branches/vs2013/source/rawinput/KeyboardInputEventArgs.h
/branches/vs2013/source/rawinput/MouseInfo.h
/branches/vs2013/source/rawinput/MouseInputEventArgs.h
/branches/vs2013/source/rawinput/RawInputEventArgs.h
/branches/vs2013/source/stack_array.h
/branches/vs2013/source/stdafx.h
/branches/vs2013/source/windows
/branches/vs2013/source/windows/DisplayMonitor.cpp
/branches/vs2013/source/windows/DisplayMonitor.h
/branches/vs2013/source/windows/NativeWindow.cpp
/branches/vs2013/source/windows/NativeWindow.h
/branches/vs2013/source/xinput
/branches/vs2013/source/xinput/Controller.cpp
/branches/vs2013/source/xinput/Controller.h
/branches/vs2013/source/xinput/Enums.h
/branches/vs2013/source/xinput/Gamepad.cpp
/branches/vs2013/source/xinput/Gamepad.h
/branches/vs2013/source/xinput/ResultCodeXI.cpp
/branches/vs2013/source/xinput/ResultCodeXI.h
/branches/vs2013/source/xinput/State.cpp
/branches/vs2013/source/xinput/State.h
/branches/vs2013/source/xinput/Vibration.cpp
/branches/vs2013/source/xinput/Vibration.h
/branches/vs2013/source/xinput/XInputException.cpp
/branches/vs2013/source/xinput/XInputException.h
=======================================
--- /dev/null
+++ /branches/vs2013/License.txt Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,19 @@
+Copyright (c) 2007-2012 SlimDX Group
+
+Permission is hereby granted, free of charge, to any person obtaining a
copy
+of this software and associated documentation files (the "Software"), to
deal
+in the Software without restriction, including without limitation the
rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/BoundingBox.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,306 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents an axis-aligned bounding box in three dimensional space.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct BoundingBox : IEquatable<BoundingBox>, IFormattable
+ {
+ /// <summary>
+ /// The minimum point of the box.
+ /// </summary>
+ public Vector3 Minimum;
+
+ /// <summary>
+ /// The maximum point of the box.
+ /// </summary>
+ public Vector3 Maximum;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.BoundingBox"/> struct.
+ /// </summary>
+ /// <param name="minimum">The minimum vertex of the bounding
box.</param>
+ /// <param name="maximum">The maximum vertex of the bounding
box.</param>
+ public BoundingBox(Vector3 minimum, Vector3 maximum)
+ {
+ this.Minimum = minimum;
+ this.Maximum = maximum;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.BoundingBox"/> struct.
+ /// </summary>
+ /// <param name="minimumX">The minimum x-coordinate of the
bounding box.</param>
+ /// <param name="minimumY">The minimum y-coordinate of the
bounding box.</param>
+ /// <param name="minimumZ">The minimum z-coordinate of the
bounding box.</param>
+ /// <param name="maximumX">The maximum x-coordinate of the
bounding box.</param>
+ /// <param name="maximumY">The maximum y-coordinate of the
bounding box.</param>
+ /// <param name="maximumZ">The maximum z-coordinate of the
bounding box.</param>
+ public BoundingBox(float minimumX, float minimumY, float minimumZ,
float maximumX, float maximumY, float maximumZ)
+ {
+ this.Minimum = new Vector3(minimumX, minimumY, minimumZ);
+ this.Maximum = new Vector3(maximumX, maximumY, maximumZ);
+ }
+
+ /// <summary>
+ /// Retrieves the eight corners of the bounding box.
+ /// </summary>
+ /// <returns>An array of points representing the eight corners of
the bounding box.</returns>
+ public Vector3[] GetCorners()
+ {
+ Vector3[] results = new Vector3[8];
+ results[0] = new Vector3(Minimum.X, Maximum.Y, Maximum.Z);
+ results[1] = new Vector3(Maximum.X, Maximum.Y, Maximum.Z);
+ results[2] = new Vector3(Maximum.X, Minimum.Y, Maximum.Z);
+ results[3] = new Vector3(Minimum.X, Minimum.Y, Maximum.Z);
+ results[4] = new Vector3(Minimum.X, Maximum.Y, Minimum.Z);
+ results[5] = new Vector3(Maximum.X, Maximum.Y, Minimum.Z);
+ results[6] = new Vector3(Maximum.X, Minimum.Y, Minimum.Z);
+ results[7] = new Vector3(Minimum.X, Minimum.Y, Minimum.Z);
+ return results;
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingBox"/> that fully
contains the given points.
+ /// </summary>
+ /// <param name="points">The points that will be contained by the
box.</param>
+ /// <param name="result">When the method completes, contains the
newly constructed bounding box.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="points"/> is <c>null</c>.</exception>
+ public static void FromPoints(Vector3[] points, out BoundingBox
result)
+ {
+ if (points == null)
+ throw new ArgumentNullException("points");
+
+ Vector3 min = new Vector3(float.MaxValue);
+ Vector3 max = new Vector3(float.MinValue);
+
+ for (int i = 0; i < points.Length; ++i)
+ {
+ Vector3.Min(ref min, ref points[i], out min);
+ Vector3.Max(ref max, ref points[i], out max);
+ }
+
+ result = new BoundingBox(min, max);
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingBox"/> that fully
contains the given points.
+ /// </summary>
+ /// <param name="points">The points that will be contained by the
box.</param>
+ /// <returns>The newly constructed bounding box.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="points"/> is <c>null</c>.</exception>
+ public static BoundingBox FromPoints(Vector3[] points)
+ {
+ if (points == null)
+ throw new ArgumentNullException("points");
+
+ Vector3 min = new Vector3(float.MaxValue);
+ Vector3 max = new Vector3(float.MinValue);
+
+ for (int i = 0; i < points.Length; ++i)
+ {
+ Vector3.Min(ref min, ref points[i], out min);
+ Vector3.Max(ref max, ref points[i], out max);
+ }
+
+ return new BoundingBox(min, max);
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingBox"/> from a given
sphere.
+ /// </summary>
+ /// <param name="sphere">The sphere that will designate the
extents of the box.</param>
+ /// <param name="result">When the method completes, contains the
newly constructed bounding box.</param>
+ public static void FromSphere(ref BoundingSphere sphere, out
BoundingBox result)
+ {
+ result.Minimum = new Vector3(sphere.Center.X - sphere.Radius,
sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius);
+ result.Maximum = new Vector3(sphere.Center.X + sphere.Radius,
sphere.Center.Y + sphere.Radius, sphere.Center.Z + sphere.Radius);
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingBox"/> from a given
sphere.
+ /// </summary>
+ /// <param name="sphere">The sphere that will designate the
extents of the box.</param>
+ /// <returns>The newly constructed bounding box.</returns>
+ public static BoundingBox FromSphere(BoundingSphere sphere)
+ {
+ BoundingBox box;
+ box.Minimum = new Vector3(sphere.Center.X - sphere.Radius,
sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius);
+ box.Maximum = new Vector3(sphere.Center.X + sphere.Radius,
sphere.Center.Y + sphere.Radius, sphere.Center.Z + sphere.Radius);
+ return box;
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingBox"/> that is as
large as the total combined area of the two specified boxes.
+ /// </summary>
+ /// <param name="value1">The first box to merge.</param>
+ /// <param name="value2">The second box to merge.</param>
+ /// <param name="result">When the method completes, contains the
newly constructed bounding box.</param>
+ public static void Merge(ref BoundingBox value1, ref BoundingBox
value2, out BoundingBox result)
+ {
+ Vector3.Min(ref value1.Minimum, ref value2.Minimum, out
result.Minimum);
+ Vector3.Max(ref value1.Maximum, ref value2.Maximum, out
result.Maximum);
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingBox"/> that is as
large as the total combined area of the two specified boxes.
+ /// </summary>
+ /// <param name="value1">The first box to merge.</param>
+ /// <param name="value2">The second box to merge.</param>
+ /// <returns>The newly constructed bounding box.</returns>
+ public static BoundingBox Merge(BoundingBox value1, BoundingBox
value2)
+ {
+ BoundingBox box;
+ Vector3.Min(ref value1.Minimum, ref value2.Minimum, out
box.Minimum);
+ Vector3.Max(ref value1.Maximum, ref value2.Maximum, out
box.Maximum);
+ return box;
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has the same
value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(BoundingBox left, BoundingBox right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has a
different value than <paramref name="right"/>; otherwise,
<c>false</c>.</returns>
+ public static bool operator !=(BoundingBox left, BoundingBox right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "Minimum:{0}
Maximum:{1}", Minimum.ToString(), Maximum.ToString());
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format)
+ {
+ if (format == null)
+ return ToString();
+
+ return string.Format(CultureInfo.CurrentCulture, "Minimum:{0}
Maximum:{1}", Minimum.ToString(format, CultureInfo.CurrentCulture),
+ Maximum.ToString(format, CultureInfo.CurrentCulture));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(IFormatProvider formatProvider)
+ {
+ return string.Format(formatProvider, "Minimum:{0}
Maximum:{1}", Minimum.ToString(), Maximum.ToString());
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format, IFormatProvider
formatProvider)
+ {
+ if (format == null)
+ return ToString(formatProvider);
+
+ return string.Format(formatProvider, "Minimum:{0}
Maximum:{1}", Minimum.ToString(format, formatProvider),
+ Maximum.ToString(format, formatProvider));
+ }
+
+ /// <summary>
+ /// Returns a hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A hash code for this instance, suitable for use in hashing
algorithms and data structures like a hash table.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Minimum.GetHashCode() + Maximum.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see
cref="SlimMath.Vector4"/> is equal to this instance.
+ /// </summary>
+ /// <param name="value">The <see cref="SlimMath.Vector4"/> to
compare with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="SlimMath.Vector4"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(BoundingBox value)
+ {
+ return Minimum == value.Minimum && Maximum == value.Maximum;
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="System.Object"/>
is equal to this instance.
+ /// </summary>
+ /// <param name="obj">The <see cref="System.Object"/> to compare
with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="System.Object"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((BoundingBox)obj);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/BoundingSphere.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,357 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents a bounding sphere in three dimensional space.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct BoundingSphere : IEquatable<BoundingSphere>, IFormattable
+ {
+ /// <summary>
+ /// The center of the sphere in three dimensional space.
+ /// </summary>
+ public Vector3 Center;
+
+ /// <summary>
+ /// The radious of the sphere.
+ /// </summary>
+ public float Radius;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.BoundingBox"/> struct.
+ /// </summary>
+ /// <param name="center">The center of the sphere.</param>
+ /// <param name="radius">The radius of the sphere.</param>
+ public BoundingSphere(Vector3 center, float radius)
+ {
+ this.Center = center;
+ this.Radius = radius;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.BoundingBox"/> struct.
+ /// </summary>
+ /// <param name="centerX">The x-coordinate for the center of the
sphere.</param>
+ /// <param name="centerY">The y-coordinate for the center of the
sphere.</param>
+ /// <param name="centerZ">The z-coordinate for the center of the
sphere.</param>
+ /// <param name="radius">The radius of the sphere.</param>
+ public BoundingSphere(float centerX, float centerY, float centerZ,
float radius)
+ {
+ this.Center = new Vector3(centerX, centerY, centerZ);
+ this.Radius = radius;
+ }
+
+ /// <summary>
+ /// Translates and scales this instance by a <see
cref="SlimMath.Matrix"/>.
+ /// </summary>
+ /// <param name="matrix">The <see cref="SlimMath.Matrix"/> to
transform this instance by.</param>
+ /// <param name="result">When the method completes, contains the
transformed <see cref="SlimMath.BoundingSphere"/>.</param>
+ /// <remarks>
+ /// The result of this operation is undefined if the matrix
contains any transformations other than
+ /// translation, rotation, and uniform scaling.
+ /// </remarks>
+ public void Transform(ref Matrix matrix, out BoundingSphere result)
+ {
+ Vector3.TransformCoordinate(ref Center, ref matrix, out
result.Center);
+
+ float row1 = (matrix.M11 * matrix.M11) + (matrix.M12 *
matrix.M12) + (matrix.M13 * matrix.M13);
+ float row2 = (matrix.M21 * matrix.M21) + (matrix.M22 *
matrix.M22) + (matrix.M23 * matrix.M23);
+ float row3 = (matrix.M31 * matrix.M31) + (matrix.M32 *
matrix.M32) + (matrix.M33 * matrix.M33);
+ float num = Math.Max(row1, Math.Max(row2, row3));
+
+ result.Radius = Radius * (float)Math.Sqrt(num);
+
+ }
+
+ /// <summary>
+ /// Translates and scales this instance by a <see
cref="SlimMath.Matrix"/>.
+ /// </summary>
+ /// <param name="matrix">The <see cref="SlimMath.Matrix"/> to
transform this instance by.</param>
+ /// <returns>The transformed <see
cref="SlimMath.BoundingSphere"/>.</returns>
+ /// <remarks>
+ /// The result of this operation is undefined if the matrix
contains any transformations other than
+ /// translation, rotation, and uniform scaling.
+ /// </remarks>
+ public BoundingSphere Transform(Matrix matrix)
+ {
+ BoundingSphere result;
+ Transform(ref matrix, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingSphere"/> that fully
contains the given points.
+ /// </summary>
+ /// <param name="points">The points that will be contained by the
sphere.</param>
+ /// <param name="result">When the method completes, contains the
newly constructed bounding sphere.</param>
+ public static void FromPoints(Vector3[] points, out BoundingSphere
result)
+ {
+ //Find the center of all points.
+ Vector3 center = Vector3.Zero;
+ for (int i = 0; i < points.Length; ++i)
+ {
+ Vector3.Add(ref points[i], ref center, out center);
+ }
+
+ //This is the center of our sphere.
+ center /= (float)points.Length;
+
+ //Find the radius of the sphere
+ float radius = 0f;
+ for (int i = 0; i < points.Length; ++i)
+ {
+ //We are doing a relative distance comparison to find the
maximum distance
+ //from the center of our sphere.
+ float distance;
+ Vector3.DistanceSquared(ref center, ref points[i], out
distance);
+
+ if (distance > radius)
+ radius = distance;
+ }
+
+ //Find the real distance from the DistanceSquared.
+ radius = (float)Math.Sqrt(radius);
+
+ //Construct the sphere.
+ result.Center = center;
+ result.Radius = radius;
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingSphere"/> that fully
contains the given points.
+ /// </summary>
+ /// <param name="points">The points that will be contained by the
sphere.</param>
+ /// <returns>The newly constructed bounding sphere.</returns>
+ public static BoundingSphere FromPoints(Vector3[] points)
+ {
+ BoundingSphere result;
+ FromPoints(points, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingSphere"/> from a
given box.
+ /// </summary>
+ /// <param name="box">The box that will designate the extents of
the sphere.</param>
+ /// <param name="result">When the method completes, the newly
constructed bounding sphere.</param>
+ public static void FromBox(ref BoundingBox box, out BoundingSphere
result)
+ {
+ Vector3.Lerp(ref box.Minimum, ref box.Maximum, 0.5f, out
result.Center);
+
+ float x = box.Minimum.X - box.Maximum.X;
+ float y = box.Minimum.Y - box.Maximum.Y;
+ float z = box.Minimum.Z - box.Maximum.Z;
+
+ float distance = (float)(Math.Sqrt((x * x) + (y * y) + (z *
z)));
+ result.Radius = distance * 0.5f;
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingSphere"/> from a
given box.
+ /// </summary>
+ /// <param name="box">The box that will designate the extents of
the sphere.</param>
+ /// <returns>The newly constructed bounding sphere.</returns>
+ public static BoundingSphere FromBox(BoundingBox box)
+ {
+ BoundingSphere result;
+ FromBox(ref box, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingSphere"/> that is the
as large as the total combined area of the two specified spheres.
+ /// </summary>
+ /// <param name="value1">The first sphere to merge.</param>
+ /// <param name="value2">The second sphere to merge.</param>
+ /// <param name="result">When the method completes, contains the
newly constructed bounding sphere.</param>
+ public static void Merge(ref BoundingSphere value1, ref
BoundingSphere value2, out BoundingSphere result)
+ {
+ Vector3 difference = value2.Center - value1.Center;
+
+ float length = difference.Length;
+ float radius = value1.Radius;
+ float radius2 = value2.Radius;
+
+ if (radius + radius2 >= length)
+ {
+ if (radius - radius2 >= length)
+ {
+ result = value1;
+ return;
+ }
+
+ if (radius2 - radius >= length)
+ {
+ result = value2;
+ return;
+ }
+ }
+
+ Vector3 vector = difference * (1.0f / length);
+ float min = Math.Min(-radius, length - radius2);
+ float max = (Math.Max(radius, length + radius2) - min) * 0.5f;
+
+ result.Center = value1.Center + vector * (max + min);
+ result.Radius = max;
+ }
+
+ /// <summary>
+ /// Constructs a <see cref="SlimMath.BoundingSphere"/> that is the
as large as the total combined area of the two specified spheres.
+ /// </summary>
+ /// <param name="value1">The first sphere to merge.</param>
+ /// <param name="value2">The second sphere to merge.</param>
+ /// <returns>The newly constructed bounding sphere.</returns>
+ public static BoundingSphere Merge(BoundingSphere value1,
BoundingSphere value2)
+ {
+ BoundingSphere result;
+ Merge(ref value1, ref value2, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has the same
value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(BoundingSphere left, BoundingSphere
right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has a
different value than <paramref name="right"/>; otherwise,
<c>false</c>.</returns>
+ public static bool operator !=(BoundingSphere left, BoundingSphere
right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "Center:{0}
Radius:{1}", Center.ToString(), Radius.ToString());
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format)
+ {
+ if (format == null)
+ return ToString();
+
+ return string.Format(CultureInfo.CurrentCulture, "Center:{0}
Radius:{1}", Center.ToString(format, CultureInfo.CurrentCulture),
+ Radius.ToString(format, CultureInfo.CurrentCulture));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(IFormatProvider formatProvider)
+ {
+ return string.Format(formatProvider, "Center:{0} Radius:{1}",
Center.ToString(), Radius.ToString());
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format, IFormatProvider
formatProvider)
+ {
+ if (format == null)
+ return ToString(formatProvider);
+
+ return string.Format(formatProvider, "Center:{0} Radius:{1}",
Center.ToString(format, formatProvider),
+ Radius.ToString(format, formatProvider));
+ }
+
+ /// <summary>
+ /// Returns a hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A hash code for this instance, suitable for use in hashing
algorithms and data structures like a hash table.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Center.GetHashCode() + Radius.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see
cref="SlimMath.Vector4"/> is equal to this instance.
+ /// </summary>
+ /// <param name="value">The <see cref="SlimMath.Vector4"/> to
compare with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="SlimMath.Vector4"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(BoundingSphere value)
+ {
+ return Center == value.Center && Radius == value.Radius;
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="System.Object"/>
is equal to this instance.
+ /// </summary>
+ /// <param name="obj">The <see cref="System.Object"/> to compare
with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="System.Object"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((BoundingSphere)obj);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Color3.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,874 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents a color in the form of rgb.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct Color3 : IEquatable<Color3>, IFormattable
+ {
+ /// <summary>
+ /// The red component of the color.
+ /// </summary>
+ public float Red;
+
+ /// <summary>
+ /// The green component of the color.
+ /// </summary>
+ public float Green;
+
+ /// <summary>
+ /// The blue component of the color.
+ /// </summary>
+ public float Blue;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color3"/> struct.
+ /// </summary>
+ /// <param name="value">The value that will be assigned to all
components.</param>
+ public Color3(float value)
+ {
+ Red = Green = Blue = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color3"/> struct.
+ /// </summary>
+ /// <param name="red">The red component of the color.</param>
+ /// <param name="green">The green component of the color.</param>
+ /// <param name="blue">The blue component of the color.</param>
+ public Color3(float red, float green, float blue)
+ {
+ Red = red;
+ Green = green;
+ Blue = blue;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color3"/> struct.
+ /// </summary>
+ /// <param name="value">The red, green, and blue components of the
color.</param>
+ public Color3(Vector3 value)
+ {
+ Red = value.X;
+ Green = value.Y;
+ Blue = value.Z;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color3"/> struct.
+ /// </summary>
+ /// <param name="rgb">A packed integer containing all three color
components.
+ /// The alpha component is ignored.</param>
+ public Color3(int rgb)
+ {
+ Red = ((rgb >> 16) & 255) / 255.0f;
+ Green = ((rgb >> 8) & 255) / 255.0f;
+ Blue = (rgb & 255) / 255.0f;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color3"/> struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the red, green,
and blue components of the color. This must be an array with three
elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than four
elements.</exception>
+ public Color3(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 3)
+ throw new ArgumentOutOfRangeException("values", "There
must be three and only three input values for Color3.");
+
+ Red = values[0];
+ Green = values[1];
+ Blue = values[2];
+ }
+
+ /// <summary>
+ /// Gets or sets the component at the specified index.
+ /// </summary>
+ /// <value>The value of the red, green, or blue component,
depending on the index.</value>
+ /// <param name="index">The index of the component to access. Use
0 for the red component, 1 for the green component, and 2 for the blue
component.</param>
+ /// <returns>The value of the component at the specified
index.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="index"/> is out of the range [0, 2].</exception>
+ public float this[int index]
+ {
+ get
+ {
+ switch (index)
+ {
+ case 0: return Red;
+ case 1: return Green;
+ case 2: return Blue;
+ }
+
+ throw new ArgumentOutOfRangeException("index", "Indices
for Color3 run from 0 to 2, inclusive.");
+ }
+
+ set
+ {
+ switch (index)
+ {
+ case 0: Red = value; break;
+ case 1: Green = value; break;
+ case 2: Blue = value; break;
+ default: throw new
ArgumentOutOfRangeException("index", "Indices for Color3 run from 0 to 2,
inclusive.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Negates a color.
+ /// </summary>
+ public void Negate()
+ {
+ this.Red = -Red;
+ this.Green = -Green;
+ this.Blue = -Blue;
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="scalar">The amount by which to scale.</param>
+ public void Scale(float scalar)
+ {
+ this.Red *= scalar;
+ this.Green *= scalar;
+ this.Blue *= scalar;
+ }
+
+ /// <summary>
+ /// Inverts the color (takes the complement of the color).
+ /// </summary>
+ public void Invert()
+ {
+ this.Red = 1.0f - Red;
+ this.Green = 1.0f - Green;
+ this.Blue = 1.0f - Blue;
+ }
+
+ /// <summary>
+ /// Adjusts the contrast of a color.
+ /// </summary>
+ /// <param name="contrast">The amount by which to adjust the
contrast.</param>
+ public void AdjustContrast(float contrast)
+ {
+ this.Red = 0.5f + contrast * (Red - 0.5f);
+ this.Green = 0.5f + contrast * (Green - 0.5f);
+ this.Blue = 0.5f + contrast * (Blue - 0.5f);
+ }
+
+ /// <summary>
+ /// Adjusts the saturation of a color.
+ /// </summary>
+ /// <param name="saturation">The amount by which to adjust the
saturation.</param>
+ public void AdjustSaturation(float saturation)
+ {
+ float grey = Red * 0.2125f + Green * 0.7154f + Blue * 0.0721f;
+
+ this.Red = grey + saturation * (Red - grey);
+ this.Green = grey + saturation * (Green - grey);
+ this.Blue = grey + saturation * (Blue - grey);
+ }
+
+ /// <summary>
+ /// Converts the color into a packed integer.
+ /// </summary>
+ /// <returns>A packed integer containing all three color
components. The alpha channel is set to 255.</returns>
+ public int ToRgb()
+ {
+ uint a = 255;
+ uint r = ((uint)(Red * 255.0f) & 0xFF);
+ uint g = ((uint)(Green * 255.0f) & 0xFF);
+ uint b = ((uint)(Blue * 255.0f) & 0xFF);
+
+ uint value = b;
+ value |= g << 8;
+ value |= r << 16;
+ value |= a << 24;
+
+ return (int)value;
+ }
+
+ /// <summary>
+ /// Converts the color into a three component vector.
+ /// </summary>
+ /// <returns>A three component vector containing the red, green,
and blue components of the color.</returns>
+ public Vector3 ToVector3()
+ {
+ return new Vector3(Red, Green, Blue);
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the color.
+ /// </summary>
+ /// <returns>A three-element array containing the components of
the color.</returns>
+ public float[] ToArray()
+ {
+ return new float[] { Red, Green, Blue };
+ }
+
+ /// <summary>
+ /// Adds two colors.
+ /// </summary>
+ /// <param name="left">The first color to add.</param>
+ /// <param name="right">The second color to add.</param>
+ /// <param name="result">When the method completes, completes the
sum of the two colors.</param>
+ public static void Add(ref Color3 left, ref Color3 right, out
Color3 result)
+ {
+ result.Red = left.Red + right.Red;
+ result.Green = left.Green + right.Green;
+ result.Blue = left.Blue + right.Blue;
+ }
+
+ /// <summary>
+ /// Adds two colors.
+ /// </summary>
+ /// <param name="left">The first color to add.</param>
+ /// <param name="right">The second color to add.</param>
+ /// <returns>The sum of the two colors.</returns>
+ public static Color3 Add(Color3 left, Color3 right)
+ {
+ return new Color3(left.Red + right.Red, left.Green +
right.Green, left.Blue + right.Blue);
+ }
+
+ /// <summary>
+ /// Subtracts two colors.
+ /// </summary>
+ /// <param name="left">The first color to subtract.</param>
+ /// <param name="right">The second color to subtract.</param>
+ /// <param name="result">WHen the method completes, contains the
difference of the two colors.</param>
+ public static void Subtract(ref Color3 left, ref Color3 right, out
Color3 result)
+ {
+ result.Red = left.Red - right.Red;
+ result.Green = left.Green - right.Green;
+ result.Blue = left.Blue - right.Blue;
+ }
+
+ /// <summary>
+ /// Subtracts two colors.
+ /// </summary>
+ /// <param name="left">The first color to subtract.</param>
+ /// <param name="right">The second color to subtract</param>
+ /// <returns>The difference of the two colors.</returns>
+ public static Color3 Subtract(Color3 left, Color3 right)
+ {
+ return new Color3(left.Red - right.Red, left.Green -
right.Green, left.Blue - right.Blue);
+ }
+
+ /// <summary>
+ /// Modulates two colors.
+ /// </summary>
+ /// <param name="left">The first color to modulate.</param>
+ /// <param name="right">The second color to modulate.</param>
+ /// <param name="result">When the method completes, contains the
modulated color.</param>
+ public static void Modulate(ref Color3 left, ref Color3 right, out
Color3 result)
+ {
+ result.Red = left.Red * right.Red;
+ result.Green = left.Green * right.Green;
+ result.Blue = left.Blue * right.Blue;
+ }
+
+ /// <summary>
+ /// Modulates two colors.
+ /// </summary>
+ /// <param name="left">The first color to modulate.</param>
+ /// <param name="right">The second color to modulate.</param>
+ /// <returns>The modulated color.</returns>
+ public static Color3 Modulate(Color3 left, Color3 right)
+ {
+ return new Color3(left.Red * right.Red, left.Green *
right.Green, left.Blue * right.Blue);
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="value">The color to scale.</param>
+ /// <param name="Scalar">The amount by which to scale.</param>
+ /// <param name="result">When the method completes, contains the
scaled color.</param>
+ public static void Scale(ref Color3 value, float Scalar, out
Color3 result)
+ {
+ result.Red = value.Red * Scalar;
+ result.Green = value.Green * Scalar;
+ result.Blue = value.Blue * Scalar;
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="value">The color to scale.</param>
+ /// <param name="scalar">The amount by which to scale.</param>
+ /// <returns>The scaled color.</returns>
+ public static Color3 Scale(Color3 value, float scalar)
+ {
+ return new Color3(value.Red * scalar, value.Green * scalar,
value.Blue * scalar);
+ }
+
+ /// <summary>
+ /// Negates a color.
+ /// </summary>
+ /// <param name="value">The color to negate.</param>
+ /// <param name="result">When the method completes, contains the
negated color.</param>
+ public static void Negate(ref Color3 value, out Color3 result)
+ {
+ result.Red = -value.Red;
+ result.Green = -value.Green;
+ result.Blue = -value.Blue;
+ }
+
+ /// <summary>
+ /// Negates a color.
+ /// </summary>
+ /// <param name="value">The color to negate.</param>
+ /// <returns>The negated color.</returns>
+ public static Color3 Negate(Color3 value)
+ {
+ return new Color3(-value.Red, -value.Green, -value.Blue);
+ }
+
+ /// <summary>
+ /// Inverts the color (takes the complement of the color).
+ /// </summary>
+ /// <param name="value">The color to invert.</param>
+ /// <param name="result">When the method completes, contains the
inverted color.</param>
+ public static void Invert(ref Color3 value, out Color3 result)
+ {
+ result.Red = 1.0f - value.Red;
+ result.Green = 1.0f - value.Green;
+ result.Blue = 1.0f - value.Blue;
+ }
+
+ /// <summary>
+ /// Inverts the color (takes the complement of the color).
+ /// </summary>
+ /// <param name="value">The color to invert.</param>
+ /// <returns>The inverted color.</returns>
+ public static Color3 Invert(Color3 value)
+ {
+ return new Color3(-value.Red, -value.Green, -value.Blue);
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <param name="result">When the method completes, contains the
clamped value.</param>
+ public static void Clamp(ref Color3 value, ref Color3 min, ref
Color3 max, out Color3 result)
+ {
+ float red = value.Red;
+ red = (red > max.Red) ? max.Red : red;
+ red = (red < min.Red) ? min.Red : red;
+
+ float green = value.Green;
+ green = (green > max.Green) ? max.Green : green;
+ green = (green < min.Green) ? min.Green : green;
+
+ float blue = value.Blue;
+ blue = (blue > max.Blue) ? max.Blue : blue;
+ blue = (blue < min.Blue) ? min.Blue : blue;
+
+ result = new Color3(red, green, blue);
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <returns>The clamped value.</returns>
+ public static Color3 Clamp(Color3 value, Color3 min, Color3 max)
+ {
+ Color3 result;
+ Clamp(ref value, ref min, ref max, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two colors.
+ /// </summary>
+ /// <param name="start">Start color.</param>
+ /// <param name="end">End color.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
linear interpolation of the two colors.</param>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static void Lerp(ref Color3 start, ref Color3 end, float
amount, out Color3 result)
+ {
+ result.Red = start.Red + amount * (end.Red - start.Red);
+ result.Green = start.Green + amount * (end.Green -
start.Green);
+ result.Blue = start.Blue + amount * (end.Blue - start.Blue);
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two colors.
+ /// </summary>
+ /// <param name="start">Start color.</param>
+ /// <param name="end">End color.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The linear interpolation of the two colors.</returns>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static Color3 Lerp(Color3 start, Color3 end, float amount)
+ {
+ return new Color3(
+ start.Red + amount * (end.Red - start.Red),
+ start.Green + amount * (end.Green - start.Green),
+ start.Blue + amount * (end.Blue - start.Blue));
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two colors.
+ /// </summary>
+ /// <param name="start">Start color.</param>
+ /// <param name="end">End color.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
cubic interpolation of the two colors.</param>
+ public static void SmoothStep(ref Color3 start, ref Color3 end,
float amount, out Color3 result)
+ {
+ amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f :
amount);
+ amount = (amount * amount) * (3.0f - (2.0f * amount));
+
+ result.Red = start.Red + ((end.Red - start.Red) * amount);
+ result.Green = start.Green + ((end.Green - start.Green) *
amount);
+ result.Blue = start.Blue + ((end.Blue - start.Blue) * amount);
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two colors.
+ /// </summary>
+ /// <param name="start">Start color.</param>
+ /// <param name="end">End color.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The cubic interpolation of the two colors.</returns>
+ public static Color3 SmoothStep(Color3 start, Color3 end, float
amount)
+ {
+ amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f :
amount);
+ amount = (amount * amount) * (3.0f - (2.0f * amount));
+
+ return new Color3(
+ start.Red + ((end.Red - start.Red) * amount),
+ start.Green + ((end.Green - start.Green) * amount),
+ start.Blue + ((end.Blue - start.Blue) * amount));
+ }
+
+ /// <summary>
+ /// Returns a color containing the smallest components of the
specified colorss.
+ /// </summary>
+ /// <param name="left">The first source color.</param>
+ /// <param name="right">The second source color.</param>
+ /// <param name="result">When the method completes, contains an
new color composed of the largest components of the source colorss.</param>
+ public static void Max(ref Color3 left, ref Color3 right, out
Color3 result)
+ {
+ result.Red = (left.Red > right.Red) ? left.Red : right.Red;
+ result.Green = (left.Green > right.Green) ? left.Green :
right.Green;
+ result.Blue = (left.Blue > right.Blue) ? left.Blue :
right.Blue;
+ }
+
+ /// <summary>
+ /// Returns a color containing the largest components of the
specified colorss.
+ /// </summary>
+ /// <param name="left">The first source color.</param>
+ /// <param name="right">The second source color.</param>
+ /// <returns>A color containing the largest components of the
source colors.</returns>
+ public static Color3 Max(Color3 left, Color3 right)
+ {
+ Color3 result;
+ Max(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Returns a color containing the smallest components of the
specified colors.
+ /// </summary>
+ /// <param name="left">The first source color.</param>
+ /// <param name="right">The second source color.</param>
+ /// <param name="result">When the method completes, contains an
new color composed of the smallest components of the source colors.</param>
+ public static void Min(ref Color3 left, ref Color3 right, out
Color3 result)
+ {
+ result.Red = (left.Red < right.Red) ? left.Red : right.Red;
+ result.Green = (left.Green < right.Green) ? left.Green :
right.Green;
+ result.Blue = (left.Blue < right.Blue) ? left.Blue :
right.Blue;
+ }
+
+ /// <summary>
+ /// Returns a color containing the smallest components of the
specified colors.
+ /// </summary>
+ /// <param name="left">The first source color.</param>
+ /// <param name="right">The second source color.</param>
+ /// <returns>A color containing the smallest components of the
source colors.</returns>
+ public static Color3 Min(Color3 left, Color3 right)
+ {
+ Color3 result;
+ Min(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Adjusts the contrast of a color.
+ /// </summary>
+ /// <param name="value">The color whose contrast is to be
adjusted.</param>
+ /// <param name="contrast">The amount by which to adjust the
contrast.</param>
+ /// <param name="result">When the method completes, contains the
adjusted color.</param>
+ public static void AdjustContrast(ref Color3 value, float
contrast, out Color3 result)
+ {
+ result.Red = 0.5f + contrast * (value.Red - 0.5f);
+ result.Green = 0.5f + contrast * (value.Green - 0.5f);
+ result.Blue = 0.5f + contrast * (value.Blue - 0.5f);
+ }
+
+ /// <summary>
+ /// Adjusts the contrast of a color.
+ /// </summary>
+ /// <param name="value">The color whose contrast is to be
adjusted.</param>
+ /// <param name="contrast">The amount by which to adjust the
contrast.</param>
+ /// <returns>The adjusted color.</returns>
+ public static Color3 AdjustContrast(Color3 value, float contrast)
+ {
+ return new Color3(
+ 0.5f + contrast * (value.Red - 0.5f),
+ 0.5f + contrast * (value.Green - 0.5f),
+ 0.5f + contrast * (value.Blue - 0.5f));
+ }
+
+ /// <summary>
+ /// Adjusts the saturation of a color.
+ /// </summary>
+ /// <param name="value">The color whose saturation is to be
adjusted.</param>
+ /// <param name="saturation">The amount by which to adjust the
saturation.</param>
+ /// <param name="result">When the method completes, contains the
adjusted color.</param>
+ public static void AdjustSaturation(ref Color3 value, float
saturation, out Color3 result)
+ {
+ float grey = value.Red * 0.2125f + value.Green * 0.7154f +
value.Blue * 0.0721f;
+
+ result.Red = grey + saturation * (value.Red - grey);
+ result.Green = grey + saturation * (value.Green - grey);
+ result.Blue = grey + saturation * (value.Blue - grey);
+ }
+
+ /// <summary>
+ /// Adjusts the saturation of a color.
+ /// </summary>
+ /// <param name="value">The color whose saturation is to be
adjusted.</param>
+ /// <param name="saturation">The amount by which to adjust the
saturation.</param>
+ /// <returns>The adjusted color.</returns>
+ public static Color3 AdjustSaturation(Color3 value, float
saturation)
+ {
+ float grey = value.Red * 0.2125f + value.Green * 0.7154f +
value.Blue * 0.0721f;
+
+ return new Color3(
+ grey + saturation * (value.Red - grey),
+ grey + saturation * (value.Green - grey),
+ grey + saturation * (value.Blue - grey));
+ }
+
+ /// <summary>
+ /// Inverts the color (takes the complement of the color).
+ /// </summary>
+ /// <param name="value">The color to invert.</param>
+ /// <returns>The inverted color.</returns>
+ public static Color3 operator ~(Color3 value)
+ {
+ return new Color3(1.0f - value.Red, 1.0f - value.Green, 1.0f -
value.Blue);
+ }
+
+ /// <summary>
+ /// Adds two colors.
+ /// </summary>
+ /// <param name="left">The first color to add.</param>
+ /// <param name="right">The second color to add.</param>
+ /// <returns>The sum of the two colors.</returns>
+ public static Color3 operator +(Color3 left, Color3 right)
+ {
+ return new Color3(left.Red + right.Red, left.Green +
right.Green, left.Blue + right.Blue);
+ }
+
+ /// <summary>
+ /// Assert a color (return it unchanged).
+ /// </summary>
+ /// <param name="value">The color to assert (unchange).</param>
+ /// <returns>The asserted (unchanged) color.</returns>
+ public static Color3 operator +(Color3 value)
+ {
+ return value;
+ }
+
+ /// <summary>
+ /// Subtracts two colors.
+ /// </summary>
+ /// <param name="left">The first color to subtract.</param>
+ /// <param name="right">The second color to subtract.</param>
+ /// <returns>The difference of the two colors.</returns>
+ public static Color3 operator -(Color3 left, Color3 right)
+ {
+ return new Color3(left.Red - right.Red, left.Green -
right.Green, left.Blue - right.Blue);
+ }
+
+ /// <summary>
+ /// Negates a color.
+ /// </summary>
+ /// <param name="value">The color to negate.</param>
+ /// <returns>A negated color.</returns>
+ public static Color3 operator -(Color3 value)
+ {
+ return new Color3(-value.Red, -value.Green, -value.Blue);
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="scalar">The factor by which to scale the
color.</param>
+ /// <param name="value">The color to scale.</param>
+ /// <returns>The scaled color.</returns>
+ public static Color3 operator *(float scalar, Color3 value)
+ {
+ return new Color3(value.Red * scalar, value.Green * scalar,
value.Blue * scalar);
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="value">The factor by which to scale the
color.</param>
+ /// <param name="scalar">The color to scale.</param>
+ /// <returns>The scaled color.</returns>
+ public static Color3 operator *(Color3 value, float scalar)
+ {
+ return new Color3(value.Red * scalar, value.Green * scalar,
value.Blue * scalar);
+ }
+
+ /// <summary>
+ /// Modulates two colors.
+ /// </summary>
+ /// <param name="left">The first color to modulate.</param>
+ /// <param name="right">The second color to modulate.</param>
+ /// <returns>The modulated color.</returns>
+ public static Color3 operator *(Color3 left, Color3 right)
+ {
+ return new Color3(left.Red * right.Red, left.Green *
right.Green, left.Blue * right.Blue);
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has the same
value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(Color3 left, Color3 right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has a
different value than <paramref name="right"/>; otherwise,
<c>false</c>.</returns>
+ public static bool operator !=(Color3 left, Color3 right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Color3"/> to <see cref="SlimMath.Color4"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Color4(Color3 value)
+ {
+ return new Color4(1.0f, value.Red, value.Green, value.Blue);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Color3"/> to <see cref="SlimMath.Vector3"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Vector3(Color3 value)
+ {
+ return new Vector3(value.Red, value.Green, value.Blue);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Vector3"/> to <see cref="SlimMath.Color3"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Color3(Vector3 value)
+ {
+ return new Color3(value.X, value.Y, value.Z);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="System.Int32"/> to <see cref="SlimMath.Color3"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Color3(int value)
+ {
+ return new Color3(value);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "Red:{1}
Green:{2} Blue:{3}", Red, Green, Blue);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format)
+ {
+ if (format == null)
+ return ToString();
+
+ return string.Format(CultureInfo.CurrentCulture, "Red:{1}
Green:{2} Blue:{3}", Red.ToString(format, CultureInfo.CurrentCulture),
+ Green.ToString(format, CultureInfo.CurrentCulture),
Blue.ToString(format, CultureInfo.CurrentCulture));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(IFormatProvider formatProvider)
+ {
+ return string.Format(formatProvider, "Red:{1} Green:{2}
Blue:{3}", Red, Green, Blue);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format, IFormatProvider
formatProvider)
+ {
+ if (format == null)
+ return ToString(formatProvider);
+
+ return string.Format(formatProvider, "Red:{0} Green:{1}
Blue:{2}",Red.ToString(format, formatProvider),
+ Green.ToString(format, formatProvider),
Blue.ToString(format, formatProvider));
+ }
+
+ /// <summary>
+ /// Returns a hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A hash code for this instance, suitable for use in hashing
algorithms and data structures like a hash table.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Red.GetHashCode() + Green.GetHashCode() +
Blue.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="SlimMath.Color3"/>
is equal to this instance.
+ /// </summary>
+ /// <param name="other">The <see cref="SlimMath.Color3"/> to
compare with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="SlimMath.Color3"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(Color3 other)
+ {
+ return (Red == other.Red) && (Green == other.Green) && (Blue
== other.Blue);
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="System.Object"/>
is equal to this instance.
+ /// </summary>
+ /// <param name="obj">The <see cref="System.Object"/> to compare
with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="System.Object"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((Color3)obj);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Color3"/> to <see cref="System.Drawing.Color"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator System.Drawing.Color(Color3 value)
+ {
+ return System.Drawing.Color.FromArgb(
+ (byte)(255f * value.Red),
+ (byte)(255f * value.Green),
+ (byte)(255f * value.Blue));
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="System.Drawing.Color"/> to <see cref="SlimMath.Color3"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Color3(System.Drawing.Color value)
+ {
+ return new Color3()
+ {
+ Red = (float)value.R / 255f,
+ Green = (float)value.G / 255f,
+ Blue = (float)value.B / 255f
+ };
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Color4.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,1014 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// A four-component (RGBA) color value; each component is a float in
the range [0,1].
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct Color4 : IEquatable<Color4>, IFormattable
+ {
+ /// <summary>
+ /// The red component of the color.
+ /// </summary>
+ public float Red;
+
+ /// <summary>
+ /// The green component of the color.
+ /// </summary>
+ public float Green;
+
+ /// <summary>
+ /// The blue component of the color.
+ /// </summary>
+ public float Blue;
+
+ /// <summary>
+ /// The alpha component of the color.
+ /// </summary>
+ public float Alpha;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color4"/> struct.
+ /// </summary>
+ /// <param name="value">The value that will be assigned to all
components.</param>
+ public Color4(float value)
+ {
+ Alpha = Red = Green = Blue = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color4"/> struct.
+ /// </summary>
+ /// <param name="red">The red component of the color.</param>
+ /// <param name="green">The green component of the color.</param>
+ /// <param name="blue">The blue component of the color.</param>
+ public Color4(float red, float green, float blue)
+ {
+ Alpha = 1.0f;
+ Red = red;
+ Green = green;
+ Blue = blue;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color4"/> struct.
+ /// </summary>
+ /// <param name="alpha">The alpha component of the color.</param>
+ /// <param name="red">The red component of the color.</param>
+ /// <param name="green">The green component of the color.</param>
+ /// <param name="blue">The blue component of the color.</param>
+ public Color4(float alpha, float red, float green, float blue)
+ {
+ Alpha = alpha;
+ Red = red;
+ Green = green;
+ Blue = blue;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color4"/> struct.
+ /// </summary>
+ /// <param name="value">The red, green, blue, and alpha components
of the color.</param>
+ public Color4(Vector4 value)
+ {
+ Red = value.X;
+ Green = value.Y;
+ Blue = value.Z;
+ Alpha = value.W;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color4"/> struct.
+ /// </summary>
+ /// <param name="value">The red, green, and blue compoennts of the
color.</param>
+ /// <param name="alpha">The alpha component of the color.</param>
+ public Color4(Vector3 value, float alpha)
+ {
+ Red = value.X;
+ Green = value.Y;
+ Blue = value.Z;
+ Alpha = alpha;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color4"/> struct.
+ /// </summary>
+ /// <param name="argb">A packed integer containing all four color
components.</param>
+ public Color4(int argb)
+ {
+ Alpha = ((argb >> 24) & 255) / 255.0f;
+ Red = ((argb >> 16) & 255) / 255.0f;
+ Green = ((argb >> 8) & 255) / 255.0f;
+ Blue = (argb & 255) / 255.0f;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color4"/> struct.
+ /// </summary>
+ /// <param name="red">The red component of the color.</param>
+ /// <param name="green">The green component of the color.</param>
+ /// <param name="blue">The blue component of the color.</param>
+ public Color4(int red, int green, int blue)
+ {
+ Alpha = 1.0f;
+ Red = red / 255.0f;
+ Green = green / 255.0f;
+ Blue = blue / 255.0f;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color4"/> struct.
+ /// </summary>
+ /// <param name="alpha">The alpha component of the color.</param>
+ /// <param name="red">The red component of the color.</param>
+ /// <param name="green">The green component of the color.</param>
+ /// <param name="blue">The blue component of the color.</param>
+ public Color4(int alpha, int red, int green, int blue)
+ {
+ Alpha = alpha / 255.0f;
+ Red = red / 255.0f;
+ Green = green / 255.0f;
+ Blue = blue / 255.0f;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Color4"/> struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the alpha, red,
green, and blue components of the color. This must be an array with four
elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than four
elements.</exception>
+ public Color4(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 4)
+ throw new ArgumentOutOfRangeException("values", "There
must be four and only four input values for Color4.");
+
+ Alpha = values[0];
+ Red = values[1];
+ Green = values[2];
+ Blue = values[3];
+ }
+
+ /// <summary>
+ /// Gets or sets the component at the specified index.
+ /// </summary>
+ /// <value>The value of the alpha, red, green, or blue component,
depending on the index.</value>
+ /// <param name="index">The index of the component to access. Use
0 for the alpha component, 1 for the red component, 2 for the green
component, and 3 for the blue component.</param>
+ /// <returns>The value of the component at the specified
index.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="index"/> is out of the range [0, 3].</exception>
+ public float this[int index]
+ {
+ get
+ {
+ switch (index)
+ {
+ case 0: return Alpha;
+ case 1: return Red;
+ case 2: return Green;
+ case 3: return Blue;
+ }
+
+ throw new ArgumentOutOfRangeException("index", "Indices
for Color4 run from 0 to 3, inclusive.");
+ }
+
+ set
+ {
+ switch (index)
+ {
+ case 0: Alpha = value; break;
+ case 1: Red = value; break;
+ case 2: Green = value; break;
+ case 3: Blue = value; break;
+ default: throw new
ArgumentOutOfRangeException("index", "Indices for Color4 run from 0 to 3,
inclusive.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Negates a color.
+ /// </summary>
+ public void Negate()
+ {
+ this.Alpha = -Alpha;
+ this.Red = -Red;
+ this.Green = -Green;
+ this.Blue = -Blue;
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="scalar">The amount by which to scale.</param>
+ public void Scale(float scalar)
+ {
+ this.Alpha *= scalar;
+ this.Red *= scalar;
+ this.Green *= scalar;
+ this.Blue *= scalar;
+ }
+
+ /// <summary>
+ /// Inverts the color (takes the complement of the color).
+ /// </summary>
+ public void Invert()
+ {
+ this.Alpha = 1.0f - Alpha;
+ this.Red = 1.0f - Red;
+ this.Green = 1.0f - Green;
+ this.Blue = 1.0f - Blue;
+ }
+
+ /// <summary>
+ /// Adjusts the contrast of a color.
+ /// </summary>
+ /// <param name="contrast">The amount by which to adjust the
contrast.</param>
+ public void AdjustContrast(float contrast)
+ {
+ this.Red = 0.5f + contrast * (Red - 0.5f);
+ this.Green = 0.5f + contrast * (Green - 0.5f);
+ this.Blue = 0.5f + contrast * (Blue - 0.5f);
+ }
+
+ /// <summary>
+ /// Adjusts the saturation of a color.
+ /// </summary>
+ /// <param name="saturation">The amount by which to adjust the
saturation.</param>
+ public void AdjustSaturation(float saturation)
+ {
+ float grey = Red * 0.2125f + Green * 0.7154f + Blue * 0.0721f;
+
+ this.Red = grey + saturation * (Red - grey);
+ this.Green = grey + saturation * (Green - grey);
+ this.Blue = grey + saturation * (Blue - grey);
+ }
+
+ /// <summary>
+ /// Converts the color into a packed integer.
+ /// </summary>
+ /// <returns>A packed integer containing all four color
components.</returns>
+ public int ToArgb()
+ {
+ uint a = ((uint)(Alpha * 255.0f) & 0xFF);
+ uint r = ((uint)(Red * 255.0f) & 0xFF);
+ uint g = ((uint)(Green * 255.0f) & 0xFF);
+ uint b = ((uint)(Blue * 255.0f) & 0xFF);
+
+ uint value = b;
+ value |= g << 8;
+ value |= r << 16;
+ value |= a << 24;
+
+ return (int)value;
+ }
+
+ /// <summary>
+ /// Converts the color into a packed integer.
+ /// </summary>
+ /// <returns>A packed integer containing all four color
components.</returns>
+ public int ToRgba()
+ {
+ uint a = ((uint)(Alpha * 255.0f) & 0xFF);
+ uint r = ((uint)(Red * 255.0f) & 0xFF);
+ uint g = ((uint)(Green * 255.0f) & 0xFF);
+ uint b = ((uint)(Blue * 255.0f) & 0xFF);
+
+ uint value = a;
+ value |= b << 8;
+ value |= g << 16;
+ value |= r << 24;
+
+ return (int)value;
+ }
+
+ /// <summary>
+ /// Converts the color into a three component vector.
+ /// </summary>
+ /// <returns>A three component vector containing the red, green,
and blue components of the color.</returns>
+ public Vector3 ToVector3()
+ {
+ return new Vector3(Red, Green, Blue);
+ }
+
+ /// <summary>
+ /// Converts the color into a four component vector.
+ /// </summary>
+ /// <returns>A four component vector containing all four color
components.</returns>
+ public Vector4 ToVector4()
+ {
+ return new Vector4(Red, Green, Blue, Alpha);
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the color.
+ /// </summary>
+ /// <returns>A four-element array containing the components of the
color in ARGB order.</returns>
+ public float[] ToArray()
+ {
+ return new float[] { Alpha, Red, Green, Blue };
+ }
+
+ /// <summary>
+ /// Adds two colors.
+ /// </summary>
+ /// <param name="left">The first color to add.</param>
+ /// <param name="right">The second color to add.</param>
+ /// <param name="result">When the method completes, completes the
sum of the two colors.</param>
+ public static void Add(ref Color4 left, ref Color4 right, out
Color4 result)
+ {
+ result.Alpha = left.Alpha + right.Alpha;
+ result.Red = left.Red + right.Red;
+ result.Green = left.Green + right.Green;
+ result.Blue = left.Blue + right.Blue;
+ }
+
+ /// <summary>
+ /// Adds two colors.
+ /// </summary>
+ /// <param name="left">The first color to add.</param>
+ /// <param name="right">The second color to add.</param>
+ /// <returns>The sum of the two colors.</returns>
+ public static Color4 Add(Color4 left, Color4 right)
+ {
+ return new Color4(left.Alpha + right.Alpha, left.Red +
right.Red, left.Green + right.Green, left.Blue + right.Blue);
+ }
+
+ /// <summary>
+ /// Subtracts two colors.
+ /// </summary>
+ /// <param name="left">The first color to subtract.</param>
+ /// <param name="right">The second color to subtract.</param>
+ /// <param name="result">WHen the method completes, contains the
difference of the two colors.</param>
+ public static void Subtract(ref Color4 left, ref Color4 right, out
Color4 result)
+ {
+ result.Alpha = left.Alpha - right.Alpha;
+ result.Red = left.Red - right.Red;
+ result.Green = left.Green - right.Green;
+ result.Blue = left.Blue - right.Blue;
+ }
+
+ /// <summary>
+ /// Subtracts two colors.
+ /// </summary>
+ /// <param name="left">The first color to subtract.</param>
+ /// <param name="right">The second color to subtract</param>
+ /// <returns>The difference of the two colors.</returns>
+ public static Color4 Subtract(Color4 left, Color4 right)
+ {
+ return new Color4(left.Alpha - right.Alpha, left.Red -
right.Red, left.Green - right.Green, left.Blue - right.Blue);
+ }
+
+ /// <summary>
+ /// Modulates two colors.
+ /// </summary>
+ /// <param name="left">The first color to modulate.</param>
+ /// <param name="right">The second color to modulate.</param>
+ /// <param name="result">When the method completes, contains the
modulated color.</param>
+ public static void Modulate(ref Color4 left, ref Color4 right, out
Color4 result)
+ {
+ result.Alpha = left.Alpha * right.Alpha;
+ result.Red = left.Red * right.Red;
+ result.Green = left.Green * right.Green;
+ result.Blue = left.Blue * right.Blue;
+ }
+
+ /// <summary>
+ /// Modulates two colors.
+ /// </summary>
+ /// <param name="left">The first color to modulate.</param>
+ /// <param name="right">The second color to modulate.</param>
+ /// <returns>The modulated color.</returns>
+ public static Color4 Modulate(Color4 left, Color4 right)
+ {
+ return new Color4(left.Alpha * right.Alpha, left.Red *
right.Red, left.Green * right.Green, left.Blue * right.Blue);
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="value">The color to scale.</param>
+ /// <param name="scalar">The amount by which to scale.</param>
+ /// <param name="result">When the method completes, contains the
scaled color.</param>
+ public static void Scale(ref Color4 value, float scalar, out
Color4 result)
+ {
+ result.Alpha = value.Alpha * scalar;
+ result.Red = value.Red * scalar;
+ result.Green = value.Green * scalar;
+ result.Blue = value.Blue * scalar;
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="value">The color to scale.</param>
+ /// <param name="scalar">The amount by which to scale.</param>
+ /// <returns>The scaled color.</returns>
+ public static Color4 Scale(Color4 value, float scalar)
+ {
+ return new Color4(value.Alpha * scalar, value.Red * scalar,
value.Green * scalar, value.Blue * scalar);
+ }
+
+ /// <summary>
+ /// Negates a color.
+ /// </summary>
+ /// <param name="value">The color to negate.</param>
+ /// <param name="result">When the method completes, contains the
negated color.</param>
+ public static void Negate(ref Color4 value, out Color4 result)
+ {
+ result.Alpha = -value.Alpha;
+ result.Red = -value.Red;
+ result.Green = -value.Green;
+ result.Blue = -value.Blue;
+ }
+
+ /// <summary>
+ /// Negates a color.
+ /// </summary>
+ /// <param name="value">The color to negate.</param>
+ /// <returns>The negated color.</returns>
+ public static Color4 Negate(Color4 value)
+ {
+ return new Color4(-value.Alpha, -value.Red, -value.Green,
-value.Blue);
+ }
+
+ /// <summary>
+ /// Inverts the color (takes the complement of the color).
+ /// </summary>
+ /// <param name="value">The color to invert.</param>
+ /// <param name="result">When the method completes, contains the
inverted color.</param>
+ public static void Invert(ref Color4 value, out Color4 result)
+ {
+ result.Alpha = 1.0f - value.Alpha;
+ result.Red = 1.0f - value.Red;
+ result.Green = 1.0f - value.Green;
+ result.Blue = 1.0f - value.Blue;
+ }
+
+ /// <summary>
+ /// Inverts the color (takes the complement of the color).
+ /// </summary>
+ /// <param name="value">The color to invert.</param>
+ /// <returns>The inverted color.</returns>
+ public static Color4 Invert(Color4 value)
+ {
+ return new Color4(-value.Alpha, -value.Red, -value.Green,
-value.Blue);
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <param name="result">When the method completes, contains the
clamped value.</param>
+ public static void Clamp(ref Color4 value, ref Color4 min, ref
Color4 max, out Color4 result)
+ {
+ float alpha = value.Alpha;
+ alpha = (alpha > max.Alpha) ? max.Alpha : alpha;
+ alpha = (alpha < min.Alpha) ? min.Alpha : alpha;
+
+ float red = value.Red;
+ red = (red > max.Red) ? max.Red : red;
+ red = (red < min.Red) ? min.Red : red;
+
+ float green = value.Green;
+ green = (green > max.Green) ? max.Green : green;
+ green = (green < min.Green) ? min.Green : green;
+
+ float blue = value.Blue;
+ blue = (blue > max.Blue) ? max.Blue : blue;
+ blue = (blue < min.Blue) ? min.Blue : blue;
+
+ result = new Color4(alpha, red, green, blue);
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <returns>The clamped value.</returns>
+ public static Color4 Clamp(Color4 value, Color4 min, Color4 max)
+ {
+ Color4 result;
+ Clamp(ref value, ref min, ref max, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two colors.
+ /// </summary>
+ /// <param name="start">Start color.</param>
+ /// <param name="end">End color.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
linear interpolation of the two colors.</param>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static void Lerp(ref Color4 start, ref Color4 end, float
amount, out Color4 result)
+ {
+ result.Alpha = start.Alpha + amount * (end.Alpha -
start.Alpha);
+ result.Red = start.Red + amount * (end.Red - start.Red);
+ result.Green = start.Green + amount * (end.Green -
start.Green);
+ result.Blue = start.Blue + amount * (end.Blue - start.Blue);
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two colors.
+ /// </summary>
+ /// <param name="start">Start color.</param>
+ /// <param name="end">End color.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The linear interpolation of the two colors.</returns>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static Color4 Lerp(Color4 start, Color4 end, float amount)
+ {
+ return new Color4(
+ start.Alpha + amount * (end.Alpha - start.Alpha),
+ start.Red + amount * (end.Red - start.Red),
+ start.Green + amount * (end.Green - start.Green),
+ start.Blue + amount * (end.Blue - start.Blue));
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two colors.
+ /// </summary>
+ /// <param name="start">Start color.</param>
+ /// <param name="end">End color.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
cubic interpolation of the two colors.</param>
+ public static void SmoothStep(ref Color4 start, ref Color4 end,
float amount, out Color4 result)
+ {
+ amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f :
amount);
+ amount = (amount * amount) * (3.0f - (2.0f * amount));
+
+ result.Alpha = start.Alpha + ((end.Alpha - start.Alpha) *
amount);
+ result.Red = start.Red + ((end.Red - start.Red) * amount);
+ result.Green = start.Green + ((end.Green - start.Green) *
amount);
+ result.Blue = start.Blue + ((end.Blue - start.Blue) * amount);
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two colors.
+ /// </summary>
+ /// <param name="start">Start color.</param>
+ /// <param name="end">End color.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The cubic interpolation of the two colors.</returns>
+ public static Color4 SmoothStep(Color4 start, Color4 end, float
amount)
+ {
+ amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f :
amount);
+ amount = (amount * amount) * (3.0f - (2.0f * amount));
+
+ return new Color4(
+ start.Alpha + ((end.Alpha - start.Alpha) * amount),
+ start.Red + ((end.Red - start.Red) * amount),
+ start.Green + ((end.Green - start.Green) * amount),
+ start.Blue + ((end.Blue - start.Blue) * amount));
+ }
+
+ /// <summary>
+ /// Returns a color containing the smallest components of the
specified colorss.
+ /// </summary>
+ /// <param name="left">The first source color.</param>
+ /// <param name="right">The second source color.</param>
+ /// <param name="result">When the method completes, contains an
new color composed of the largest components of the source colorss.</param>
+ public static void Max(ref Color4 left, ref Color4 right, out
Color4 result)
+ {
+ result.Alpha = (left.Alpha > right.Alpha) ? left.Alpha :
right.Alpha;
+ result.Red = (left.Red > right.Red) ? left.Red : right.Red;
+ result.Green = (left.Green > right.Green) ? left.Green :
right.Green;
+ result.Blue = (left.Blue > right.Blue) ? left.Blue :
right.Blue;
+ }
+
+ /// <summary>
+ /// Returns a color containing the largest components of the
specified colorss.
+ /// </summary>
+ /// <param name="left">The first source color.</param>
+ /// <param name="right">The second source color.</param>
+ /// <returns>A color containing the largest components of the
source colors.</returns>
+ public static Color4 Max(Color4 left, Color4 right)
+ {
+ Color4 result;
+ Max(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Returns a color containing the smallest components of the
specified colors.
+ /// </summary>
+ /// <param name="left">The first source color.</param>
+ /// <param name="right">The second source color.</param>
+ /// <param name="result">When the method completes, contains an
new color composed of the smallest components of the source colors.</param>
+ public static void Min(ref Color4 left, ref Color4 right, out
Color4 result)
+ {
+ result.Alpha = (left.Alpha < right.Alpha) ? left.Alpha :
right.Alpha;
+ result.Red = (left.Red < right.Red) ? left.Red : right.Red;
+ result.Green = (left.Green < right.Green) ? left.Green :
right.Green;
+ result.Blue = (left.Blue < right.Blue) ? left.Blue :
right.Blue;
+ }
+
+ /// <summary>
+ /// Returns a color containing the smallest components of the
specified colors.
+ /// </summary>
+ /// <param name="left">The first source color.</param>
+ /// <param name="right">The second source color.</param>
+ /// <returns>A color containing the smallest components of the
source colors.</returns>
+ public static Color4 Min(Color4 left, Color4 right)
+ {
+ Color4 result;
+ Min(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Adjusts the contrast of a color.
+ /// </summary>
+ /// <param name="value">The color whose contrast is to be
adjusted.</param>
+ /// <param name="contrast">The amount by which to adjust the
contrast.</param>
+ /// <param name="result">When the method completes, contains the
adjusted color.</param>
+ public static void AdjustContrast(ref Color4 value, float
contrast, out Color4 result)
+ {
+ result.Alpha = value.Alpha;
+ result.Red = 0.5f + contrast * (value.Red - 0.5f);
+ result.Green = 0.5f + contrast * (value.Green - 0.5f);
+ result.Blue = 0.5f + contrast * (value.Blue - 0.5f);
+ }
+
+ /// <summary>
+ /// Adjusts the contrast of a color.
+ /// </summary>
+ /// <param name="value">The color whose contrast is to be
adjusted.</param>
+ /// <param name="contrast">The amount by which to adjust the
contrast.</param>
+ /// <returns>The adjusted color.</returns>
+ public static Color4 AdjustContrast(Color4 value, float contrast)
+ {
+ return new Color4(
+ value.Alpha,
+ 0.5f + contrast * (value.Red - 0.5f),
+ 0.5f + contrast * (value.Green - 0.5f),
+ 0.5f + contrast * (value.Blue - 0.5f));
+ }
+
+ /// <summary>
+ /// Adjusts the saturation of a color.
+ /// </summary>
+ /// <param name="value">The color whose saturation is to be
adjusted.</param>
+ /// <param name="saturation">The amount by which to adjust the
saturation.</param>
+ /// <param name="result">When the method completes, contains the
adjusted color.</param>
+ public static void AdjustSaturation(ref Color4 value, float
saturation, out Color4 result)
+ {
+ float grey = value.Red * 0.2125f + value.Green * 0.7154f +
value.Blue * 0.0721f;
+
+ result.Alpha = value.Alpha;
+ result.Red = grey + saturation * (value.Red - grey);
+ result.Green = grey + saturation * (value.Green - grey);
+ result.Blue = grey + saturation * (value.Blue - grey);
+ }
+
+ /// <summary>
+ /// Adjusts the saturation of a color.
+ /// </summary>
+ /// <param name="value">The color whose saturation is to be
adjusted.</param>
+ /// <param name="saturation">The amount by which to adjust the
saturation.</param>
+ /// <returns>The adjusted color.</returns>
+ public static Color4 AdjustSaturation(Color4 value, float
saturation)
+ {
+ float grey = value.Red * 0.2125f + value.Green * 0.7154f +
value.Blue * 0.0721f;
+
+ return new Color4(
+ value.Alpha,
+ grey + saturation * (value.Red - grey),
+ grey + saturation * (value.Green - grey),
+ grey + saturation * (value.Blue - grey));
+ }
+
+ /// <summary>
+ /// Inverts the color (takes the complement of the color).
+ /// </summary>
+ /// <param name="value">The color to invert.</param>
+ /// <returns>The inverted color.</returns>
+ public static Color4 operator ~(Color4 value)
+ {
+ return new Color4(1.0f - value.Alpha, 1.0f - value.Red, 1.0f -
value.Green, 1.0f - value.Blue);
+ }
+
+ /// <summary>
+ /// Adds two colors.
+ /// </summary>
+ /// <param name="left">The first color to add.</param>
+ /// <param name="right">The second color to add.</param>
+ /// <returns>The sum of the two colors.</returns>
+ public static Color4 operator +(Color4 left, Color4 right)
+ {
+ return new Color4(left.Alpha + right.Alpha, left.Red +
right.Red, left.Green + right.Green, left.Blue + right.Blue);
+ }
+
+ /// <summary>
+ /// Assert a color (return it unchanged).
+ /// </summary>
+ /// <param name="value">The color to assert (unchange).</param>
+ /// <returns>The asserted (unchanged) color.</returns>
+ public static Color4 operator +(Color4 value)
+ {
+ return value;
+ }
+
+ /// <summary>
+ /// Subtracts two colors.
+ /// </summary>
+ /// <param name="left">The first color to subtract.</param>
+ /// <param name="right">The second color to subtract.</param>
+ /// <returns>The difference of the two colors.</returns>
+ public static Color4 operator -(Color4 left, Color4 right)
+ {
+ return new Color4(left.Alpha - right.Alpha, left.Red -
right.Red, left.Green - right.Green, left.Blue - right.Blue);
+ }
+
+ /// <summary>
+ /// Negates a color.
+ /// </summary>
+ /// <param name="value">The color to negate.</param>
+ /// <returns>A negated color.</returns>
+ public static Color4 operator -(Color4 value)
+ {
+ return new Color4(-value.Alpha, -value.Red, -value.Green,
-value.Blue);
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="scalar">The factor by which to scale the
color.</param>
+ /// <param name="value">The color to scale.</param>
+ /// <returns>The scaled color.</returns>
+ public static Color4 operator *(float scalar, Color4 value)
+ {
+ return new Color4(value.Alpha * scalar, value.Red * scalar,
value.Green * scalar, value.Blue * scalar);
+ }
+
+ /// <summary>
+ /// Scales a color.
+ /// </summary>
+ /// <param name="value">The factor by which to scale the
color.</param>
+ /// <param name="scalar">The color to scale.</param>
+ /// <returns>The scaled color.</returns>
+ public static Color4 operator *(Color4 value, float scalar)
+ {
+ return new Color4(value.Alpha * scalar, value.Red * scalar,
value.Green * scalar, value.Blue * scalar);
+ }
+
+ /// <summary>
+ /// Modulates two colors.
+ /// </summary>
+ /// <param name="left">The first color to modulate.</param>
+ /// <param name="right">The second color to modulate.</param>
+ /// <returns>The modulated color.</returns>
+ public static Color4 operator *(Color4 left, Color4 right)
+ {
+ return new Color4(left.Alpha * right.Alpha, left.Red *
right.Red, left.Green * right.Green, left.Blue * right.Blue);
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has the same
value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(Color4 left, Color4 right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has a
different value than <paramref name="right"/>; otherwise,
<c>false</c>.</returns>
+ public static bool operator !=(Color4 left, Color4 right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Color4"/> to <see cref="SlimMath.Color3"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Color3(Color4 value)
+ {
+ return new Color3(value.Red, value.Green, value.Blue);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Color4"/> to <see cref="SlimMath.Vector3"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Vector3(Color4 value)
+ {
+ return new Vector3(value.Red, value.Green, value.Blue);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Color4"/> to <see cref="SlimMath.Vector4"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Vector4(Color4 value)
+ {
+ return new Vector4(value.Red, value.Green, value.Blue,
value.Alpha);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Vector3"/> to <see cref="SlimMath.Color4"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Color4(Vector3 value)
+ {
+ return new Color4(value.X, value.Y, value.Z, 1.0f);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Vector4"/> to <see cref="SlimMath.Color4"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Color4(Vector4 value)
+ {
+ return new Color4(value.X, value.Y, value.Z, value.W);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="System.Int32"/> to <see cref="SlimMath.Color4"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator Color4(int value)
+ {
+ return new Color4(value);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "Alpha:{0}
Red:{1} Green:{2} Blue:{3}", Alpha, Red, Green, Blue);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format)
+ {
+ if (format == null)
+ return ToString();
+
+ return string.Format(CultureInfo.CurrentCulture, "Alpha:{0}
Red:{1} Green:{2} Blue:{3}", Alpha.ToString(format,
CultureInfo.CurrentCulture),
+ Red.ToString(format, CultureInfo.CurrentCulture),
Green.ToString(format, CultureInfo.CurrentCulture), Blue.ToString(format,
CultureInfo.CurrentCulture));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(IFormatProvider formatProvider)
+ {
+ return string.Format(formatProvider, "Alpha:{0} Red:{1}
Green:{2} Blue:{3}", Alpha, Red, Green, Blue);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format, IFormatProvider
formatProvider)
+ {
+ if (format == null)
+ return ToString(formatProvider);
+
+ return string.Format(formatProvider, "Alpha:{0} Red:{1}
Green:{2} Blue:{3}", Alpha.ToString(format, formatProvider),
+ Red.ToString(format, formatProvider),
Green.ToString(format, formatProvider), Blue.ToString(format,
formatProvider));
+ }
+
+ /// <summary>
+ /// Returns a hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A hash code for this instance, suitable for use in hashing
algorithms and data structures like a hash table.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Alpha.GetHashCode() + Red.GetHashCode() +
Green.GetHashCode() + Blue.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="SlimMath.Color4"/>
is equal to this instance.
+ /// </summary>
+ /// <param name="other">The <see cref="SlimMath.Color4"/> to
compare with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="SlimMath.Color4"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(Color4 other)
+ {
+ return (Alpha == other.Alpha) && (Red == other.Red) && (Green
== other.Green) && (Blue == other.Blue);
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="System.Object"/>
is equal to this instance.
+ /// </summary>
+ /// <param name="obj">The <see cref="System.Object"/> to compare
with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="System.Object"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((Color4)obj);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="SlimMath.Color4"/> to <see cref="System.Drawing.Color"/>.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns>The result of the conversion.</returns>
+ public static explicit operator System.Drawing.Color(Color4 value)
+ {
+ return System.Drawing.Color.FromArgb(
+ (byte)(255f * value.Alpha),
+ (byte)(255f * value.Red),
+ (byte)(255f * value.Green),
+ (byte)(255f * value.Blue));
+ }
+
+ /// <summary>
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/BaseConverter.cs Sun May 18 20:39:07
2014 UTC
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Provides a base class for mathematical type converters.
+ /// </summary>
+ public abstract class BaseConverter : ExpandableObjectConverter
+ {
+ /// <summary>
+ /// Gets or sets the collection of exposed properties.
+ /// </summary>
+ /// <value>The collection of exposed properties.</value>
+ protected PropertyDescriptorCollection Properties
+ {
+ get;
+ set;
+ }
+
+ internal static string ConvertFromValues<T>(ITypeDescriptorContext
context, CultureInfo culture, T[] values)
+ {
+ if (culture == null)
+ culture = CultureInfo.CurrentCulture;
+
+ var converter = TypeDescriptor.GetConverter(typeof(T));
+ var results = Array.ConvertAll(values, t =>
converter.ConvertToString(context, culture, t));
+
+ return string.Join(culture.TextInfo.ListSeparator + " ",
results);
+ }
+
+ internal static T[] ConvertToValues<T>(ITypeDescriptorContext
context, CultureInfo culture, object value)
+ {
+ var str = value as string;
+ if (string.IsNullOrEmpty(str))
+ return null;
+
+ if (culture == null)
+ culture = CultureInfo.CurrentCulture;
+
+ var converter = TypeDescriptor.GetConverter(typeof(T));
+ var strings = str.Trim().Split(new[] {
culture.TextInfo.ListSeparator }, StringSplitOptions.RemoveEmptyEntries);
+
+ return Array.ConvertAll(strings, s =>
(T)converter.ConvertFromString(context, culture, s));
+ }
+
+ /// <summary>
+ /// Returns whether this converter can convert an object of the
given type to the type of this converter, using the specified context.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="sourceType">A <see cref="T:System.Type"/> that
represents the type you want to convert from.</param>
+ /// <returns>
+ /// true if this converter can perform the conversion; otherwise,
false.
+ /// </returns>
+ public override bool CanConvertFrom(ITypeDescriptorContext
context, Type sourceType)
+ {
+ return sourceType == typeof(string) ||
base.CanConvertFrom(context, sourceType);
+ }
+
+ /// <summary>
+ /// Returns whether this converter can convert the object to the
specified type, using the specified context.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="destinationType">A <see cref="T:System.Type"/>
that represents the type you want to convert to.</param>
+ /// <returns>
+ /// true if this converter can perform the conversion; otherwise,
false.
+ /// </returns>
+ public override bool CanConvertTo(ITypeDescriptorContext context,
Type destinationType)
+ {
+ return destinationType == typeof(string) || destinationType ==
typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType);
+ }
+
+ /// <summary>
+ /// Returns whether changing a value on this object requires a
call to <see
cref="M:System.ComponentModel.TypeConverter.CreateInstance(System.Collections.IDictionary)"/>
to create a new value, using the specified context.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <returns>
+ /// true if changing a property on this object requires a call to
<see
cref="M:System.ComponentModel.TypeConverter.CreateInstance(System.Collections.IDictionary)"/>
to create a new value; otherwise, false.
+ /// </returns>
+ public override bool
GetCreateInstanceSupported(ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this object supports
properties using the specified context.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <returns>
+ /// true because <see
cref="M:System.ComponentModel.TypeConverter.GetProperties(System.Object)"/>
should be called to find the properties of this object. This method never
returns false.
+ /// </returns>
+ public override bool GetPropertiesSupported(ITypeDescriptorContext
context)
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// Gets a collection of properties for the type of object
specified by the value parameter.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="value">An <see cref="T:System.Object"/> that
specifies the type of object to get the properties for.</param>
+ /// <param name="attributes">An array of type <see
cref="T:System.Attribute"/> that will be used as a filter.</param>
+ /// <returns>
+ /// A <see
cref="T:System.ComponentModel.PropertyDescriptorCollection"/> with the
properties that are exposed for the component, or null if there are no
properties.
+ /// </returns>
+ public override PropertyDescriptorCollection
GetProperties(ITypeDescriptorContext context, object value, Attribute[]
attributes)
+ {
+ return Properties;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/FieldPropertyDescriptor.cs Sun May 18
20:39:07 2014 UTC
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.ComponentModel;
+using System.Reflection;
+
+namespace SlimMath.Design
+{
+ class FieldPropertyDescriptor : PropertyDescriptor
+ {
+ readonly FieldInfo fieldInfo;
+
+ public override Type ComponentType
+ {
+ get { return fieldInfo.DeclaringType; }
+ }
+
+ public override bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public override Type PropertyType
+ {
+ get { return fieldInfo.FieldType; }
+ }
+
+ public FieldPropertyDescriptor(FieldInfo fieldInfo)
+ : base(fieldInfo.Name,
(Attribute[])fieldInfo.GetCustomAttributes(true))
+ {
+ this.fieldInfo = fieldInfo;
+ }
+
+ public override bool CanResetValue(object component)
+ {
+ return false;
+ }
+
+ public override object GetValue(object component)
+ {
+ return fieldInfo.GetValue(component);
+ }
+
+ public override void ResetValue(object component)
+ {
+ }
+
+ public override void SetValue(object component, object value)
+ {
+ fieldInfo.SetValue(component, value);
+ OnValueChanged(component, EventArgs.Empty);
+ }
+
+ public override bool ShouldSerializeValue(object component)
+ {
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return fieldInfo.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ return GetType() == obj.GetType() &&
((FieldPropertyDescriptor)obj).fieldInfo.Equals(fieldInfo);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/Half2Converter.cs Sun May 18 20:39:07
2014 UTC
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Defines a type converter for <see cref="Half2"/>.
+ /// </summary>
+ public class Half2Converter : BaseConverter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Half2Converter"/>
class.
+ /// </summary>
+ public Half2Converter()
+ {
+ var type = typeof(Half2);
+ Properties = new PropertyDescriptorCollection(new[]
+ {
+ new FieldPropertyDescriptor(type.GetField("X")),
+ new FieldPropertyDescriptor(type.GetField("Y"))
+ });
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo"/>. If null is passed, the current
culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <param name="destinationType">The <see cref="T:System.Type"/>
to convert the <paramref name="value"/> parameter to.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="destinationType"/> parameter is null.
+ /// </exception>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if (value is Half2)
+ {
+ var vector = (Half2)value;
+
+ if (destinationType == typeof(string))
+ return ConvertFromValues(context, culture,
vector.ToArray());
+
+ if (destinationType == typeof(InstanceDescriptor))
+ {
+ var constructor =
typeof(Half2).GetConstructor(Utilities.Array(typeof(float), 2));
+ if (constructor != null)
+ return new InstanceDescriptor(constructor,
vector.ToArray());
+ }
+ }
+
+ return base.ConvertTo(context, culture, value,
destinationType);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">The <see
cref="T:System.Globalization.CultureInfo"/> to use as the current
culture.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
+ {
+ var values = ConvertToValues<float>(context, culture, value);
+ return values != null ? new Half2(values) :
base.ConvertFrom(context, culture, value);
+ }
+
+ /// <summary>
+ /// Creates an instance of the type that this <see
cref="T:System.ComponentModel.TypeConverter"/> is associated with, using
the specified context, given a set of property values for the object.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="propertyValues">An <see
cref="T:System.Collections.IDictionary"/> of new property values.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> representing the given <see
cref="T:System.Collections.IDictionary"/>, or null if the object cannot be
created. This method always returns null.
+ /// </returns>
+ public override object CreateInstance(ITypeDescriptorContext
context, IDictionary propertyValues)
+ {
+ if (propertyValues == null)
+ throw new ArgumentNullException("propertyValues");
+
+ return new Half2((float)propertyValues["X"],
(float)propertyValues["Y"]);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/Half3Converter.cs Sun May 18 20:39:07
2014 UTC
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Defines a type converter for <see cref="Half3"/>.
+ /// </summary>
+ public class Half3Converter : BaseConverter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Half3Converter"/>
class.
+ /// </summary>
+ public Half3Converter()
+ {
+ var type = typeof(Half3);
+ Properties = new PropertyDescriptorCollection(new[]
+ {
+ new FieldPropertyDescriptor(type.GetField("X")),
+ new FieldPropertyDescriptor(type.GetField("Y")),
+ new FieldPropertyDescriptor(type.GetField("Z"))
+ });
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo"/>. If null is passed, the current
culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <param name="destinationType">The <see cref="T:System.Type"/>
to convert the <paramref name="value"/> parameter to.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="destinationType"/> parameter is null.
+ /// </exception>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if (value is Half3)
+ {
+ var vector = (Half3)value;
+
+ if (destinationType == typeof(string))
+ return ConvertFromValues(context, culture,
vector.ToArray());
+
+ if (destinationType == typeof(InstanceDescriptor))
+ {
+ var constructor =
typeof(Half3).GetConstructor(Utilities.Array(typeof(float), 3));
+ if (constructor != null)
+ return new InstanceDescriptor(constructor,
vector.ToArray());
+ }
+ }
+
+ return base.ConvertTo(context, culture, value,
destinationType);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">The <see
cref="T:System.Globalization.CultureInfo"/> to use as the current
culture.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
+ {
+ var values = ConvertToValues<float>(context, culture, value);
+ return values != null ? new Half3(values) :
base.ConvertFrom(context, culture, value);
+ }
+
+ /// <summary>
+ /// Creates an instance of the type that this <see
cref="T:System.ComponentModel.TypeConverter"/> is associated with, using
the specified context, given a set of property values for the object.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="propertyValues">An <see
cref="T:System.Collections.IDictionary"/> of new property values.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> representing the given <see
cref="T:System.Collections.IDictionary"/>, or null if the object cannot be
created. This method always returns null.
+ /// </returns>
+ public override object CreateInstance(ITypeDescriptorContext
context, IDictionary propertyValues)
+ {
+ if (propertyValues == null)
+ throw new ArgumentNullException("propertyValues");
+
+ return new Half3((float)propertyValues["X"],
(float)propertyValues["Y"], (float)propertyValues["Z"]);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/Half4Converter.cs Sun May 18 20:39:07
2014 UTC
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Defines a type converter for <see cref="Half4"/>.
+ /// </summary>
+ public class Half4Converter : BaseConverter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Half4Converter"/>
class.
+ /// </summary>
+ public Half4Converter()
+ {
+ var type = typeof(Half4);
+ Properties = new PropertyDescriptorCollection(new[]
+ {
+ new FieldPropertyDescriptor(type.GetField("X")),
+ new FieldPropertyDescriptor(type.GetField("Y")),
+ new FieldPropertyDescriptor(type.GetField("Z")),
+ new FieldPropertyDescriptor(type.GetField("W"))
+ });
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo"/>. If null is passed, the current
culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <param name="destinationType">The <see cref="T:System.Type"/>
to convert the <paramref name="value"/> parameter to.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="destinationType"/> parameter is null.
+ /// </exception>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if (value is Half4)
+ {
+ var vector = (Half4)value;
+
+ if (destinationType == typeof(string))
+ return ConvertFromValues(context, culture,
vector.ToArray());
+
+ if (destinationType == typeof(InstanceDescriptor))
+ {
+ var constructor =
typeof(Half4).GetConstructor(Utilities.Array(typeof(float), 4));
+ if (constructor != null)
+ return new InstanceDescriptor(constructor,
vector.ToArray());
+ }
+ }
+
+ return base.ConvertTo(context, culture, value,
destinationType);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">The <see
cref="T:System.Globalization.CultureInfo"/> to use as the current
culture.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
+ {
+ var values = ConvertToValues<float>(context, culture, value);
+ return values != null ? new Half4(values) :
base.ConvertFrom(context, culture, value);
+ }
+
+ /// <summary>
+ /// Creates an instance of the type that this <see
cref="T:System.ComponentModel.TypeConverter"/> is associated with, using
the specified context, given a set of property values for the object.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="propertyValues">An <see
cref="T:System.Collections.IDictionary"/> of new property values.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> representing the given <see
cref="T:System.Collections.IDictionary"/>, or null if the object cannot be
created. This method always returns null.
+ /// </returns>
+ public override object CreateInstance(ITypeDescriptorContext
context, IDictionary propertyValues)
+ {
+ if (propertyValues == null)
+ throw new ArgumentNullException("propertyValues");
+
+ return new Half4((float)propertyValues["X"],
(float)propertyValues["Y"], (float)propertyValues["Z"],
(float)propertyValues["W"]);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/HalfConverter.cs Sun May 18 20:39:07
2014 UTC
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2007-2014 SlimMath Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Provides a type converter to convert <see cref="T:SlimDX.Half" />
objects to and from various
+ /// other representations.
+ /// </summary>
+ public class HalfConverter : ExpandableObjectConverter
+ {
+ /// <summary>
+ /// Returns whether this converter can convert an object of the
given type to the type of this converter, using the specified context.
+ /// </summary>
+ /// <param name="context">A <see
cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a
format context.</param>
+ /// <param name="sourceType">A System::Type that represents the
type you want to convert from.</param>
+ /// <returns>
+ /// <c>true</c> if this converter can perform the conversion;
otherwise, <c>false</c>.</returns>
+ public override bool CanConvertFrom(ITypeDescriptorContext
context, Type sourceType)
+ {
+ return ((sourceType == typeof(string)) ||
base.CanConvertFrom(context, sourceType));
+ }
+
+ /// <summary>
+ /// Returns whether this converter can convert the object to the
specified type, using the specified context.
+ /// </summary>
+ /// <param name="context">A <see
cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a
format context.</param>
+ /// <param name="destinationType">A <see cref="T:System.Type" />
that represents the type you want to convert to.</param>
+ /// <returns>
+ /// <c>true</c> if this converter can perform the conversion;
otherwise, <c>false</c>.</returns>
+ public override bool CanConvertTo(ITypeDescriptorContext context,
Type destinationType)
+ {
+ if ((destinationType != typeof(string)) && (destinationType !=
typeof(InstanceDescriptor)))
+ {
+ return base.CanConvertTo(context, destinationType);
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">A <see
cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo" />. If <c>null</c> is passed, the
current culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object" /> to
convert.</param>
+ /// <returns>An <see cref="T:System.Object" /> that represents the
converted value.</returns>
+ public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
+ {
+ if (culture == null)
+ {
+ culture = CultureInfo.CurrentCulture;
+ }
+ string @string = value as string;
+ if (@string == null)
+ {
+ return base.ConvertFrom(context, culture, value);
+ }
+ @string = @string.Trim();
+ char[] separator = new char[] {
culture.TextInfo.ListSeparator[0] };
+ string[] stringArray = @string.Split(separator);
+ if (stringArray.Length != 1)
+ {
+ throw new ArgumentException("Invalid half format.");
+ }
+ float H =
(float)TypeDescriptor.GetConverter(typeof(float)).ConvertFromString(context,
culture, stringArray[0]);
+ Half type = new Half(H);
+ return type;
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">A <see
cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo" />. If <c>null</c> is passed, the
current culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object" /> to
convert.</param>
+ /// <param name="destinationType">A <see cref="T:System.Type" />
that represents the type you want to convert to.</param>
+ /// <returns>An <see cref="T:System.Object" /> that represents the
converted value.</returns>
+ public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ {
+ throw new ArgumentNullException("destinationType");
+ }
+ if (culture == null)
+ {
+ culture = CultureInfo.CurrentCulture;
+ }
+ if ((destinationType == typeof(string)) && value is Half)
+ {
+ TypeConverter converter =
TypeDescriptor.GetConverter(typeof(float));
+ return string.Join(culture.TextInfo.ListSeparator + " ",
new string[] { converter.ConvertToString(context, culture,
(float)((Half)value)) });
+ }
+ if ((destinationType == typeof(InstanceDescriptor)) && value
is Half)
+ {
+ var info = typeof(Half).GetConstructor(new Type[] {
typeof(float) });
+ if (info != null)
+ {
+ return new InstanceDescriptor(info, new object[] {
(float)((Half)value) });
+ }
+ }
+ return base.ConvertTo(context, culture, value,
destinationType);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/MatrixConverter.cs Sun May 18 20:39:07
2014 UTC
@@ -0,0 +1,160 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Defines a type converter for <see cref="Matrix"/>.
+ /// </summary>
+ public class MatrixConverter : BaseConverter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="MatrixConverter"/> class.
+ /// </summary>
+ public MatrixConverter()
+ {
+ Type type = typeof(Matrix);
+ Properties = new PropertyDescriptorCollection(new[]
+ {
+ new FieldPropertyDescriptor(type.GetField("M11")),
+ new FieldPropertyDescriptor(type.GetField("M12")),
+ new FieldPropertyDescriptor(type.GetField("M13")),
+ new FieldPropertyDescriptor(type.GetField("M14")),
+
+ new FieldPropertyDescriptor(type.GetField("M21")),
+ new FieldPropertyDescriptor(type.GetField("M22")),
+ new FieldPropertyDescriptor(type.GetField("M23")),
+ new FieldPropertyDescriptor(type.GetField("M24")),
+
+ new FieldPropertyDescriptor(type.GetField("M31")),
+ new FieldPropertyDescriptor(type.GetField("M32")),
+ new FieldPropertyDescriptor(type.GetField("M33")),
+ new FieldPropertyDescriptor(type.GetField("M34")),
+
+ new FieldPropertyDescriptor(type.GetField("M41")),
+ new FieldPropertyDescriptor(type.GetField("M42")),
+ new FieldPropertyDescriptor(type.GetField("M43")),
+ new FieldPropertyDescriptor(type.GetField("M44")),
+ });
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo"/>. If null is passed, the current
culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <param name="destinationType">The <see cref="T:System.Type"/>
to convert the <paramref name="value"/> parameter to.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="destinationType"/> parameter is null.
+ /// </exception>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if (value is Matrix)
+ {
+ var matrix = (Matrix)value;
+
+ if (destinationType == typeof(string))
+ return ConvertFromValues(context, culture,
matrix.ToArray());
+
+ if (destinationType == typeof(InstanceDescriptor))
+ {
+ var constructor =
typeof(Matrix).GetConstructor(Utilities.Array(typeof(float), 16));
+ if (constructor != null)
+ return new InstanceDescriptor(constructor,
matrix.ToArray());
+ }
+ }
+
+ return base.ConvertTo(context, culture, value,
destinationType);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">The <see
cref="T:System.Globalization.CultureInfo"/> to use as the current
culture.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
+ {
+ var values = ConvertToValues<float>(context, culture, value);
+
+ return values != null ? new Matrix(values) :
base.ConvertFrom(context, culture, value);
+ }
+
+ /// <summary>
+ /// Creates an instance of the type that this <see
cref="T:System.ComponentModel.TypeConverter"/> is associated with, using
the specified context, given a set of property values for the object.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="propertyValues">An <see
cref="T:System.Collections.IDictionary"/> of new property values.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> representing the given <see
cref="T:System.Collections.IDictionary"/>, or null if the object cannot be
created. This method always returns null.
+ /// </returns>
+ public override object CreateInstance(ITypeDescriptorContext
context, IDictionary propertyValues)
+ {
+ if (propertyValues == null)
+ throw new ArgumentNullException("propertyValues");
+
+ var matrix = new Matrix
+ {
+ M11 = (float)propertyValues["M11"],
+ M12 = (float)propertyValues["M12"],
+ M13 = (float)propertyValues["M13"],
+ M14 = (float)propertyValues["M14"],
+ M21 = (float)propertyValues["M21"],
+ M22 = (float)propertyValues["M22"],
+ M23 = (float)propertyValues["M23"],
+ M24 = (float)propertyValues["M24"],
+ M31 = (float)propertyValues["M31"],
+ M32 = (float)propertyValues["M32"],
+ M33 = (float)propertyValues["M33"],
+ M34 = (float)propertyValues["M34"],
+ M41 = (float)propertyValues["M41"],
+ M42 = (float)propertyValues["M42"],
+ M43 = (float)propertyValues["M43"],
+ M44 = (float)propertyValues["M44"]
+ };
+
+ return matrix;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/QuaternionConverter.cs Sun May 18
20:39:07 2014 UTC
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Defines a type converter for <see cref="Quaternion"/>.
+ /// </summary>
+ public class QuaternionConverter : BaseConverter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="QuaternionConverter"/> class.
+ /// </summary>
+ public QuaternionConverter()
+ {
+ var type = typeof(Quaternion);
+ Properties = new PropertyDescriptorCollection(new[]
+ {
+ new FieldPropertyDescriptor(type.GetField("X")),
+ new FieldPropertyDescriptor(type.GetField("Y")),
+ new FieldPropertyDescriptor(type.GetField("Z")),
+ new FieldPropertyDescriptor(type.GetField("W"))
+ });
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo"/>. If null is passed, the current
culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <param name="destinationType">The <see cref="T:System.Type"/>
to convert the <paramref name="value"/> parameter to.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="destinationType"/> parameter is null.
+ /// </exception>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if (value is Quaternion)
+ {
+ var quaternion = (Quaternion)value;
+
+ if (destinationType == typeof(string))
+ return ConvertFromValues(context, culture,
quaternion.ToArray());
+
+ if (destinationType == typeof(InstanceDescriptor))
+ {
+ var constructor =
typeof(Quaternion).GetConstructor(Utilities.Array(typeof(float), 4));
+ if (constructor != null)
+ return new InstanceDescriptor(constructor,
quaternion.ToArray());
+ }
+ }
+
+ return base.ConvertTo(context, culture, value,
destinationType);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">The <see
cref="T:System.Globalization.CultureInfo"/> to use as the current
culture.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
+ {
+ var values = ConvertToValues<float>(context, culture, value);
+ return values != null ? new Quaternion(values) :
base.ConvertFrom(context, culture, value);
+ }
+
+ /// <summary>
+ /// Creates an instance of the type that this <see
cref="T:System.ComponentModel.TypeConverter"/> is associated with, using
the specified context, given a set of property values for the object.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="propertyValues">An <see
cref="T:System.Collections.IDictionary"/> of new property values.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> representing the given <see
cref="T:System.Collections.IDictionary"/>, or null if the object cannot be
created. This method always returns null.
+ /// </returns>
+ public override object CreateInstance(ITypeDescriptorContext
context, IDictionary propertyValues)
+ {
+ if (propertyValues == null)
+ throw new ArgumentNullException("propertyValues");
+
+ return new Quaternion((float)propertyValues["X"],
(float)propertyValues["Y"], (float)propertyValues["Z"],
(float)propertyValues["W"]);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/Vector2Converter.cs Sun May 18
20:39:07 2014 UTC
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Defines a type converter for <see cref="Vector2"/>.
+ /// </summary>
+ public class Vector2Converter : BaseConverter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="Vector2Converter"/> class.
+ /// </summary>
+ public Vector2Converter()
+ {
+ var type = typeof(Vector2);
+ Properties = new PropertyDescriptorCollection(new[]
+ {
+ new FieldPropertyDescriptor(type.GetField("X")),
+ new FieldPropertyDescriptor(type.GetField("Y"))
+ });
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo"/>. If null is passed, the current
culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <param name="destinationType">The <see cref="T:System.Type"/>
to convert the <paramref name="value"/> parameter to.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="destinationType"/> parameter is null.
+ /// </exception>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if (value is Vector2)
+ {
+ var vector = (Vector2)value;
+
+ if (destinationType == typeof(string))
+ return ConvertFromValues(context, culture,
vector.ToArray());
+
+ if (destinationType == typeof(InstanceDescriptor))
+ {
+ var constructor =
typeof(Vector2).GetConstructor(Utilities.Array(typeof(float), 2));
+ if (constructor != null)
+ return new InstanceDescriptor(constructor,
vector.ToArray());
+ }
+ }
+
+ return base.ConvertTo(context, culture, value,
destinationType);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">The <see
cref="T:System.Globalization.CultureInfo"/> to use as the current
culture.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
+ {
+ var values = ConvertToValues<float>(context, culture, value);
+ return values != null ? new Vector2(values) :
base.ConvertFrom(context, culture, value);
+ }
+
+ /// <summary>
+ /// Creates an instance of the type that this <see
cref="T:System.ComponentModel.TypeConverter"/> is associated with, using
the specified context, given a set of property values for the object.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="propertyValues">An <see
cref="T:System.Collections.IDictionary"/> of new property values.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> representing the given <see
cref="T:System.Collections.IDictionary"/>, or null if the object cannot be
created. This method always returns null.
+ /// </returns>
+ public override object CreateInstance(ITypeDescriptorContext
context, IDictionary propertyValues)
+ {
+ if (propertyValues == null)
+ throw new ArgumentNullException("propertyValues");
+
+ return new Vector2((float)propertyValues["X"],
(float)propertyValues["Y"]);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/Vector3Converter.cs Sun May 18
20:39:07 2014 UTC
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Defines a type converter for <see cref="Vector3"/>.
+ /// </summary>
+ public class Vector3Converter : BaseConverter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="Vector3Converter"/> class.
+ /// </summary>
+ public Vector3Converter()
+ {
+ var type = typeof(Vector3);
+ Properties = new PropertyDescriptorCollection(new[]
+ {
+ new FieldPropertyDescriptor(type.GetField("X")),
+ new FieldPropertyDescriptor(type.GetField("Y")),
+ new FieldPropertyDescriptor(type.GetField("Z"))
+ });
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo"/>. If null is passed, the current
culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <param name="destinationType">The <see cref="T:System.Type"/>
to convert the <paramref name="value"/> parameter to.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="destinationType"/> parameter is null.
+ /// </exception>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if (value is Vector3)
+ {
+ var vector = (Vector3)value;
+
+ if (destinationType == typeof(string))
+ return ConvertFromValues(context, culture,
vector.ToArray());
+
+ if (destinationType == typeof(InstanceDescriptor))
+ {
+ var constructor =
typeof(Vector3).GetConstructor(Utilities.Array(typeof(float), 3));
+ if (constructor != null)
+ return new InstanceDescriptor(constructor,
vector.ToArray());
+ }
+ }
+
+ return base.ConvertTo(context, culture, value,
destinationType);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">The <see
cref="T:System.Globalization.CultureInfo"/> to use as the current
culture.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
+ {
+ var values = ConvertToValues<float>(context, culture, value);
+ return values != null ? new Vector3(values) :
base.ConvertFrom(context, culture, value);
+ }
+
+ /// <summary>
+ /// Creates an instance of the type that this <see
cref="T:System.ComponentModel.TypeConverter"/> is associated with, using
the specified context, given a set of property values for the object.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="propertyValues">An <see
cref="T:System.Collections.IDictionary"/> of new property values.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> representing the given <see
cref="T:System.Collections.IDictionary"/>, or null if the object cannot be
created. This method always returns null.
+ /// </returns>
+ public override object CreateInstance(ITypeDescriptorContext
context, IDictionary propertyValues)
+ {
+ if (propertyValues == null)
+ throw new ArgumentNullException("propertyValues");
+
+ return new Vector3((float)propertyValues["X"],
(float)propertyValues["Y"], (float)propertyValues["Z"]);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Design/Vector4Converter.cs Sun May 18
20:39:07 2014 UTC
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+using System.Globalization;
+
+namespace SlimMath.Design
+{
+ /// <summary>
+ /// Defines a type converter for <see cref="Vector4"/>.
+ /// </summary>
+ public class Vector4Converter : BaseConverter
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="Vector4Converter"/> class.
+ /// </summary>
+ public Vector4Converter()
+ {
+ var type = typeof(Vector4);
+ Properties = new PropertyDescriptorCollection(new[]
+ {
+ new FieldPropertyDescriptor(type.GetField("X")),
+ new FieldPropertyDescriptor(type.GetField("Y")),
+ new FieldPropertyDescriptor(type.GetField("Z")),
+ new FieldPropertyDescriptor(type.GetField("W"))
+ });
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">A <see
cref="T:System.Globalization.CultureInfo"/>. If null is passed, the current
culture is assumed.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <param name="destinationType">The <see cref="T:System.Type"/>
to convert the <paramref name="value"/> parameter to.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="destinationType"/> parameter is null.
+ /// </exception>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertTo(ITypeDescriptorContext context,
CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ throw new ArgumentNullException("destinationType");
+
+ if (value is Vector4)
+ {
+ var vector = (Vector4)value;
+
+ if (destinationType == typeof(string))
+ return ConvertFromValues(context, culture,
vector.ToArray());
+
+ if (destinationType == typeof(InstanceDescriptor))
+ {
+ var constructor =
typeof(Vector4).GetConstructor(Utilities.Array(typeof(float), 4));
+ if (constructor != null)
+ return new InstanceDescriptor(constructor,
vector.ToArray());
+ }
+ }
+
+ return base.ConvertTo(context, culture, value,
destinationType);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter, using
the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="culture">The <see
cref="T:System.Globalization.CultureInfo"/> to use as the current
culture.</param>
+ /// <param name="value">The <see cref="T:System.Object"/> to
convert.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> that represents the converted
value.
+ /// </returns>
+ /// <exception cref="T:System.NotSupportedException">
+ /// The conversion cannot be performed.
+ /// </exception>
+ public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
+ {
+ var values = ConvertToValues<float>(context, culture, value);
+ return values != null ? new Vector4(values) :
base.ConvertFrom(context, culture, value);
+ }
+
+ /// <summary>
+ /// Creates an instance of the type that this <see
cref="T:System.ComponentModel.TypeConverter"/> is associated with, using
the specified context, given a set of property values for the object.
+ /// </summary>
+ /// <param name="context">An <see
cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a
format context.</param>
+ /// <param name="propertyValues">An <see
cref="T:System.Collections.IDictionary"/> of new property values.</param>
+ /// <returns>
+ /// An <see cref="T:System.Object"/> representing the given <see
cref="T:System.Collections.IDictionary"/>, or null if the object cannot be
created. This method always returns null.
+ /// </returns>
+ public override object CreateInstance(ITypeDescriptorContext
context, IDictionary propertyValues)
+ {
+ if (propertyValues == null)
+ throw new ArgumentNullException("propertyValues");
+
+ return new Vector4((float)propertyValues["X"],
(float)propertyValues["Y"], (float)propertyValues["Z"],
(float)propertyValues["W"]);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Half.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,552 @@
+/*
+* Copyright (c) 2007-2014 SlimMath Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// A half precision (16 bit) floating point value.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Half : IConvertible, IComparable, IComparable<Half>,
IEquatable<Half>, IFormattable
+ {
+ private ushort value;
+
+ /// <summary>
+ /// Number of decimal digits of precision.
+ /// </summary>
+ public const int PrecisionDigits = 3;
+
+ /// <summary>
+ /// Number of bits in the mantissa.
+ /// </summary>
+ public const int MantissaBits = 11;
+
+ /// <summary>
+ /// Maximum decimal exponent.
+ /// </summary>
+ public const int MaximumDecimalExponent = 4;
+
+ /// <summary>
+ /// Maximum binary exponent.
+ /// </summary>
+ public const int MaximumBinaryExponent = 15;
+
+ /// <summary>
+ /// Minimum decimal exponent.
+ /// </summary>
+ public const int MinimumDecimalExponent = -4;
+
+ /// <summary>
+ /// Minimum binary exponent.
+ /// </summary>
+ public const int MinimumBinaryExponent = -14;
+
+ /// <summary>
+ /// Exponent radix.
+ /// </summary>
+ public const int ExponentRadix = 2;
+
+ /// <summary>
+ /// Additional rounding.
+ /// </summary>
+ public const int AdditionRounding = 1;
+
+ /// <summary>
+ /// Smallest value such that 1.0 + epsilon != 1.0
+ /// </summary>
+ public static readonly Half Epsilon = new Half(0.0004887581f);
+
+ /// <summary>
+ /// Maximum value of the number.
+ /// </summary>
+ public static readonly Half MaxValue = new Half(65504f);
+
+ /// <summary>
+ /// Minimum value of the number.
+ /// </summary>
+ public static readonly Half MinValue = new Half(6.103516E-05f);
+
+ /// <summary>
+ /// Represents not a number (NaN).
+ /// </summary>
+ public static readonly Half NaN = new Half(0.0f / 0.0f);
+
+ /// <summary>
+ /// Represents negative infinity.
+ /// </summary>
+ public static readonly Half NegativeInfinity = new Half(-1.0f /
0.0f);
+
+ /// <summary>
+ /// Represents positive infinity.
+ /// </summary>
+ public static readonly Half PositiveInfinity = new Half(1.0f /
0.0f);
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half"/> structure.
+ /// </summary>
+ /// <param name="value">The floating point value that should be
stored in 16 bit format.</param>
+ public Half(float value)
+ {
+ this.value = HalfUtilities.Pack(value);
+ }
+
+ /// <summary>
+ /// Gets the raw 16 bit value used to back this half-float.
+ /// </summary>
+ [CLSCompliant(false)]
+ public ushort RawValue
+ {
+ get { return value; }
+ }
+
+ /// <summary>
+ /// Converts an array of half precision values into full precision
values.
+ /// </summary>
+ /// <param name="values">The values to be converted.</param>
+ /// <returns>An array of converted values.</returns>
+ public static float[] ConvertToFloat(Half[] values)
+ {
+ float[] results = new float[values.Length];
+
+ for(int i = 0; i < results.Length; i++)
+ results[i] = HalfUtilities.Unpack(values[i].RawValue);
+
+ return results;
+ }
+
+ /// <summary>
+ /// Converts an array of full precision values into half precision
values.
+ /// </summary>
+ /// <param name="values">The values to be converted.</param>
+ /// <returns>An array of converted values.</returns>
+ public static Half[] ConvertToHalf(float[] values)
+ {
+ Half[] results = new Half[values.Length];
+
+ for(int i = 0; i < results.Length; i++)
+ results[i] = new Half(values[i]);
+
+ return results;
+ }
+
+ /// <summary>
+ /// Returns a value indicating whether the specified number
evaluates to negative or positive infinity.
+ /// </summary>
+ /// <param name="half">The <see cref="SlimMath.Half"/> to
check.</param>
+ /// <returns><c>true</c> if <paramref name="half"/> evaluates to
positive or negative infinity; otherwise, <c>false</c>.</returns>
+ public static bool IsInfinity(Half half)
+ {
+ return (half == PositiveInfinity) || (half ==
NegativeInfinity);
+ }
+
+ /// <summary>
+ /// Returns a value indicating whether the specified number
evaluates to NaN.
+ /// </summary>
+ /// <param name="half">The <see cref="SlimMath.Half"/> to
check.</param>
+ /// <returns><c>true</c> if <paramref name="half"/> evaluates to
NaN; otherwise, <c>false</c>.</returns>
+ public static bool IsNaN(Half half)
+ {
+ return half == NaN;
+ }
+
+ /// <summary>
+ /// Returns a value indicating whether the specified number
evaluates to negative infinity.
+ /// </summary>
+ /// <param name="half">The <see cref="SlimMath.Half"/> to
check.</param>
+ /// <returns><c>true</c> if <paramref name="half"/> evaluates to
negative infinity; otherwise, <c>false</c>.</returns>
+ public static bool IsNegativeInfinity(Half half)
+ {
+ return half == NegativeInfinity;
+ }
+
+ /// <summary>
+ /// Returns a value indicating whether the specified number
evaluates to positive infinity.
+ /// </summary>
+ /// <param name="half">The <see cref="SlimMath.Half"/> to
check.</param>
+ /// <returns><c>true</c> if <paramref name="half"/> evaluates to
positive infinity; otherwise, <c>false</c>.</returns>
+ public static bool IsPositiveInfinity(Half half)
+ {
+ return half == PositiveInfinity;
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether a specified <see
cref="SlimMath.Half"/> value is
+ /// less than another specified <see cref="SlimMath.Half"/> value.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> is less than
<paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator <(Half left, Half right)
+ {
+ return (float)left < (float)right;
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether a specified <see
cref="SlimMath.Half"/> value is
+ /// greater than another specified <see cref="SlimMath.Half"/>
value.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> is greater
than <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator >(Half left, Half right)
+ {
+ return (float)left > (float)right;
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether a specified <see
cref="SlimMath.Half"/> value is
+ /// less than or equal to another specified <see
cref="SlimMath.Half"/> value.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> is less than
or equal to <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator <=(Half left, Half right)
+ {
+ return (float)left <= (float)right;
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether a specified <see
cref="SlimMath.Half"/> value is
+ /// greater than or equal to another specified <see
cref="SlimMath.Half"/> value.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> is greater
than or equal to right; otherwise, <c>false</c>.</returns>
+ public static bool operator >=(Half left, Half right)
+ {
+ return (float)left >= (float)right;
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="left"/> has the same value as
<paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(Half left, Half right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="left"/> has a different value
than <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator !=(Half left, Half right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="T:System.Single"/> to <see cref="T:SlimMath.Half"/>.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static explicit operator Half(float value)
+ {
+ return new Half(value);
+ }
+
+ /// <summary>
+ /// Performs an implicit conversion from <see
cref="T:SlimMath.Half"/> to <see cref="T:System.Single"/>.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static implicit operator float(Half value)
+ {
+ return HalfUtilities.Unpack(value.value);
+ }
+
+ /// <summary>
+ /// Converts the value of the object to its equivalent string
representation.
+ /// </summary>
+ /// <returns>The string representation of the value of this
instance.</returns>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture,
((float)this).ToString());
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format)
+ {
+ if (format == null)
+ return ToString();
+
+ return string.Format(CultureInfo.CurrentCulture,
((float)this).ToString(format, CultureInfo.CurrentCulture));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(IFormatProvider formatProvider)
+ {
+ return string.Format(formatProvider, ((float)this).ToString());
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format, IFormatProvider
formatProvider)
+ {
+ if (format == null)
+ ToString(formatProvider);
+
+ return string.Format(formatProvider,
((float)this).ToString(format, formatProvider));
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>A 32-bit signed integer hash code.</returns>
+ public override int GetHashCode()
+ {
+ return (((value * 3) / 2) ^ value);
+ }
+
+ /// <summary>
+ /// Compares this instance to another instance of the same type.
+ /// </summary>
+ /// <param name="value">The other value to compare to this
instance.</param>
+ /// <returns>A value that specifies if this instance is greater
than, less than, or equal to <paramref name="value"/>.</returns>
+ public int CompareTo(Half value)
+ {
+ if (this < value)
+ {
+ return -1;
+ }
+
+ if (this > value)
+ {
+ return 1;
+ }
+
+ if (this != value)
+ {
+ if (!IsNaN(this))
+ {
+ return 1;
+ }
+
+ if (!IsNaN(value))
+ {
+ return -1;
+ }
+ }
+
+ return 0;
+ }
+
+ /// <summary>
+ /// Compares this instance to another instance of another type.
+ /// </summary>
+ /// <param name="value">The other value to compare to this
instance.</param>
+ /// <returns>A value that specifies if this instance is greater
than, less than, or equal to <paramref name="value"/>.</returns>
+ public int CompareTo(object value)
+ {
+ if (value == null)
+ {
+ return 1;
+ }
+
+ if (!(value is Half))
+ {
+ throw new ArgumentException("The argument value must be a
SlimMath.Half.");
+ }
+
+ Half f = (Half)value;
+ if (this < f)
+ {
+ return -1;
+ }
+
+ if (this > f)
+ {
+ return 1;
+ }
+
+ if (this != f)
+ {
+ if (!IsNaN(this))
+ {
+ return 1;
+ }
+
+ if (!IsNaN(f))
+ {
+ return -1;
+ }
+ }
+
+ return 0;
+ }
+
+ /// <summary>
+ /// Determines whether the specified object instances are
considered equal.
+ /// </summary>
+ /// <param name="value1"/>
+ /// <param name="value2"/>
+ /// <returns>
+ /// <c>true</c> if <paramref name="value1"/> is the same instance
as <paramref name="value2"/> or
+ /// if both are <c>null</c> references or if
<c>value1.Equals(value2)</c> returns <c>true</c>; otherwise,
<c>false</c>.</returns>
+ public static bool Equals(ref Half value1, ref Half value2)
+ {
+ return value1.value == value2.value;
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether the current instance is
equal to the specified object.
+ /// </summary>
+ /// <param name="other">Object to make the comparison with.</param>
+ /// <returns>
+ /// <c>true</c> if the current instance is equal to the specified
object; <c>false</c> otherwise.</returns>
+ public bool Equals(Half other)
+ {
+ return other.value == value;
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether the current instance is
equal to a specified object.
+ /// </summary>
+ /// <param name="obj">Object to make the comparison with.</param>
+ /// <returns>
+ /// <c>true</c> if the current instance is equal to the specified
object; <c>false</c> otherwise.</returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((Half)obj);
+ }
+
+ /// <summary>
+ /// Returns the <see cref="System.TypeCode"/> for value type <see
cref="SlimMath.Half"/>.
+ /// </summary>
+ /// <returns>The type code.</returns>
+ public TypeCode GetTypeCode()
+ {
+ return Type.GetTypeCode(typeof(Half));
+ }
+
+ bool IConvertible.ToBoolean(IFormatProvider provider)
+ {
+ return Convert.ToBoolean(this);
+ }
+
+ byte IConvertible.ToByte(IFormatProvider provider)
+ {
+ return Convert.ToByte(this);
+ }
+
+ char IConvertible.ToChar(IFormatProvider provider)
+ {
+ throw new InvalidCastException("Invalid cast from
SlimMath.Half to System.Char.");
+ }
+
+ DateTime IConvertible.ToDateTime(IFormatProvider provider)
+ {
+ throw new InvalidCastException("Invalid cast from
SlimMath.Half to System.DateTime.");
+ }
+
+ decimal IConvertible.ToDecimal(IFormatProvider provider)
+ {
+ return Convert.ToDecimal(this);
+ }
+
+ double IConvertible.ToDouble(IFormatProvider provider)
+ {
+ return Convert.ToDouble(this);
+ }
+
+ short IConvertible.ToInt16(IFormatProvider provider)
+ {
+ return Convert.ToInt16(this);
+ }
+
+ int IConvertible.ToInt32(IFormatProvider provider)
+ {
+ return Convert.ToInt32(this);
+ }
+
+ long IConvertible.ToInt64(IFormatProvider provider)
+ {
+ return Convert.ToInt64(this);
+ }
+
+ sbyte IConvertible.ToSByte(IFormatProvider provider)
+ {
+ return Convert.ToSByte(this);
+ }
+
+ float IConvertible.ToSingle(IFormatProvider provider)
+ {
+ return this;
+ }
+
+ object IConvertible.ToType(Type type, IFormatProvider provider)
+ {
+ return ((IConvertible)((float)this)).ToType(type, provider);
+ }
+
+ ushort IConvertible.ToUInt16(IFormatProvider provider)
+ {
+ return Convert.ToUInt16(this);
+ }
+
+ uint IConvertible.ToUInt32(IFormatProvider provider)
+ {
+ return Convert.ToUInt32(this);
+ }
+
+ ulong IConvertible.ToUInt64(IFormatProvider provider)
+ {
+ return Convert.ToUInt64(this);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Half2.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,264 @@
+/*
+* Copyright (c) 2007-2014 SlimMath Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Defines a two component vector, using half precision floating
point coordinates.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Half2 : IEquatable<Half2>, IFormattable
+ {
+ /// <summary>
+ /// Gets or sets the X component of the vector.
+ /// </summary>
+ /// <value>The X component of the vector.</value>
+ public Half X;
+
+ /// <summary>
+ /// Gets or sets the Y component of the vector.
+ /// </summary>
+ /// <value>The Y component of the vector.</value>
+ public Half Y;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half2"/> structure.
+ /// </summary>
+ /// <param name="x">The X component.</param>
+ /// <param name="y">The Y component.</param>
+ public Half2(Half x, Half y)
+ {
+ this.X = x;
+ this.Y = y;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half2"/> structure.
+ /// </summary>
+ /// <param name="value">The value to set for both the X and Y
components.</param>
+ public Half2(Half value)
+ {
+ this.X = value;
+ this.Y = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half2"/> structure.
+ /// </summary>
+ /// <param name="x">The X component.</param>
+ /// <param name="y">The Y component.</param>
+ public Half2(float x, float y)
+ {
+ this.X = (Half)x;
+ this.Y = (Half)y;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half2"/> structure.
+ /// </summary>
+ /// <param name="value">The value to set for both the X and Y
components.</param>
+ public Half2(float value)
+ {
+ this.X = this.Y = (Half)value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SlimMath.Half2"/>
struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the X and Y
components of the vector. This must be an array with two elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than two
elements.</exception>
+ public Half2(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 2)
+ throw new ArgumentOutOfRangeException("values", "There
must be two and only two input values for Half2.");
+
+ X = (Half)values[0];
+ Y = (Half)values[1];
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the vector.
+ /// </summary>
+ /// <returns>A two-element array containing the components of the
vector.</returns>
+ public Half[] ToArray()
+ {
+ return new Half[] { X, Y };
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="left"/> has the same value as
<paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(Half2 left, Half2 right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="left"/> has a different value
than <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator !=(Half2 left, Half2 right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="T:SlimMath.Vector2"/> to <see cref="T:SlimMath.Half2"/>.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static explicit operator Half2(Vector2 value)
+ {
+ return new Half2(value.X, value.Y);
+ }
+
+ /// <summary>
+ /// Performs an implicit conversion from <see
cref="T:SlimMath.Half2"/> to <see cref="T:SlimMath.Vector2"/>.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static implicit operator Vector2(Half2 value)
+ {
+ return new Vector2(value.X, value.Y);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "X:{0}
Y:{1}", X, Y);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format)
+ {
+ if (format == null)
+ return ToString();
+
+ return string.Format(CultureInfo.CurrentCulture, "X:{0}
Y:{1}", X.ToString(format, CultureInfo.CurrentCulture), Y.ToString(format,
CultureInfo.CurrentCulture));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(IFormatProvider formatProvider)
+ {
+ return string.Format(formatProvider, "X:{0} Y:{1}", X, Y);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format, IFormatProvider
formatProvider)
+ {
+ if (format == null)
+ ToString(formatProvider);
+
+ return string.Format(formatProvider, "X:{0} Y:{1}",
X.ToString(format, formatProvider), Y.ToString(format, formatProvider));
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>A 32-bit signed integer hash code.</returns>
+ public override int GetHashCode()
+ {
+ return X.GetHashCode() + Y.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether the specified object instances are
considered equal.
+ /// </summary>
+ /// <param name="value1"/>
+ /// <param name="value2"/>
+ /// <returns>
+ /// <c>true</c> if <paramref name="value1"/> is the same instance
as <paramref name="value2"/> or
+ /// if both are <c>null</c> references or if
<c>value1.Equals(value2)</c> returns <c>true</c>; otherwise,
<c>false</c>.</returns>
+ public static bool Equals(ref Half2 value1, ref Half2 value2)
+ {
+ return (value1.X == value2.X) && (value1.Y == value2.Y);
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether the current instance is
equal to the specified object.
+ /// </summary>
+ /// <param name="other">Object to make the comparison with.</param>
+ /// <returns>
+ /// <c>true</c> if the current instance is equal to the specified
object; <c>false</c> otherwise.</returns>
+ public bool Equals(Half2 other)
+ {
+ return (this.X == other.X) && (this.Y == other.Y);
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether the current instance is
equal to a specified object.
+ /// </summary>
+ /// <param name="obj">Object to make the comparison with.</param>
+ /// <returns>
+ /// <c>true</c> if the current instance is equal to the specified
object; <c>false</c> otherwise.</returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((Half2)obj);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Half3.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,278 @@
+/*
+* Copyright (c) 2007-2014 SlimMath Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Defines a three component vector, using half precision floating
point coordinates.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Half3 : IEquatable<Half3>, IFormattable
+ {
+ /// <summary>
+ /// Gets or sets the X component of the vector.
+ /// </summary>
+ /// <value>The X component of the vector.</value>
+ public Half X;
+
+ /// <summary>
+ /// Gets or sets the Y component of the vector.
+ /// </summary>
+ /// <value>The Y component of the vector.</value>
+ public Half Y;
+
+ /// <summary>
+ /// Gets or sets the Z component of the vector.
+ /// </summary>
+ /// <value>The Z component of the vector.</value>
+ public Half Z;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half3"/> structure.
+ /// </summary>
+ /// <param name="x">The X component.</param>
+ /// <param name="y">The Y component.</param>
+ /// <param name="z">The Z component.</param>
+ public Half3(Half x, Half y, Half z)
+ {
+ this.X = x;
+ this.Y = y;
+ this.Z = z;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half3"/> structure.
+ /// </summary>
+ /// <param name="value">The value to set for the X, Y, and Z
components.</param>
+ public Half3(Half value)
+ {
+ this.X = value;
+ this.Y = value;
+ this.Z = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half3"/> structure.
+ /// </summary>
+ /// <param name="x">The X component.</param>
+ /// <param name="y">The Y component.</param>
+ /// <param name="z">The Z component.</param>
+ public Half3(float x, float y, float z)
+ {
+ this.X = (Half)x;
+ this.Y = (Half)y;
+ this.Z = (Half)z;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half3"/> structure.
+ /// </summary>
+ /// <param name="value">The value to set for the X, Y, and Z
components.</param>
+ public Half3(float value)
+ {
+ this.X = this.Y = this.Z = (Half)value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SlimMath.Half3"/>
struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the X, Y, and Z
components of the vector. This must be an array with three elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than three
elements.</exception>
+ public Half3(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 3)
+ throw new ArgumentOutOfRangeException("values", "There
must be three and only three input values for Half3.");
+
+ X = (Half)values[0];
+ Y = (Half)values[1];
+ Z = (Half)values[2];
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the vector.
+ /// </summary>
+ /// <returns>A two-element array containing the components of the
vector.</returns>
+ public Half[] ToArray()
+ {
+ return new Half[] { X, Y, Z };
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="left"/> has the same value as
<paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(Half3 left, Half3 right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="left"/> has a different value
than <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator !=(Half3 left, Half3 right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="T:SlimMath.Vector3"/> to <see cref="T:SlimMath.Half3"/>.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static explicit operator Half3(Vector3 value)
+ {
+ return new Half3(value.X, value.Y, value.Z);
+ }
+
+ /// <summary>
+ /// Performs an implicit conversion from <see
cref="T:SlimMath.Half3"/> to <see cref="T:SlimMath.Vector3"/>.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static implicit operator Vector3(Half3 value)
+ {
+ return new Vector3(value.X, value.Y, value.Z);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "X:{0} Y:{1}
Z:{2} Q:{3}", X, Y, Z);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format)
+ {
+ if (format == null)
+ return ToString();
+
+ return string.Format(CultureInfo.CurrentCulture, "X:{0} Y:{1}
Z:{2}", X.ToString(format, CultureInfo.CurrentCulture),
+ Y.ToString(format, CultureInfo.CurrentCulture),
Z.ToString(format, CultureInfo.CurrentCulture));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(IFormatProvider formatProvider)
+ {
+ return string.Format(formatProvider, "X:{0} Y:{1} Z:{2}", X,
Y, Z);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format, IFormatProvider
formatProvider)
+ {
+ if (format == null)
+ return ToString(formatProvider);
+
+ return string.Format(formatProvider, "X:{0} Y:{1} Z:{2}",
X.ToString(format, formatProvider),
+ Y.ToString(format, formatProvider), Z.ToString(format,
formatProvider));
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>A 32-bit signed integer hash code.</returns>
+ public override int GetHashCode()
+ {
+ return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether the specified object instances are
considered equal.
+ /// </summary>
+ /// <param name="value1"/>
+ /// <param name="value2"/>
+ /// <returns>
+ /// <c>true</c> if <paramref name="value1"/> is the same instance
as <paramref name="value2"/> or
+ /// if both are <c>null</c> references or if
<c>value1.Equals(value2)</c> returns <c>true</c>; otherwise,
<c>false</c>.</returns>
+ public static bool Equals(ref Half3 value1, ref Half3 value2)
+ {
+ return (value1.X == value2.X) && (value1.Y == value2.Y) &&
(value1.Z == value2.Z);
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether the current instance is
equal to the specified object.
+ /// </summary>
+ /// <param name="other">Object to make the comparison with.</param>
+ /// <returns>
+ /// <c>true</c> if the current instance is equal to the specified
object; <c>false</c> otherwise.</returns>
+ public bool Equals(Half3 other)
+ {
+ return (this.X == other.X) && (this.Y == other.Y) && (this.Z
== other.Z);
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether the current instance is
equal to a specified object.
+ /// </summary>
+ /// <param name="obj">Object to make the comparison with.</param>
+ /// <returns>
+ /// <c>true</c> if the current instance is equal to the specified
object; <c>false</c> otherwise.</returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((Half3)obj);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Half4.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,290 @@
+/*
+* Copyright (c) 2007-2014 SlimMath Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Defines a four component vector, using half precision floating
point coordinates.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Half4 : IEquatable<Half4>, IFormattable
+ {
+ /// <summary>
+ /// Gets or sets the X component of the vector.
+ /// </summary>
+ /// <value>The X component of the vector.</value>
+ public Half X;
+
+ /// <summary>
+ /// Gets or sets the Y component of the vector.
+ /// </summary>
+ /// <value>The Y component of the vector.</value>
+ public Half Y;
+
+ /// <summary>
+ /// Gets or sets the Z component of the vector.
+ /// </summary>
+ /// <value>The Z component of the vector.</value>
+ public Half Z;
+
+ /// <summary>
+ /// Gets or sets the W component of the vector.
+ /// </summary>
+ /// <value>The W component of the vector.</value>
+ public Half W;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half4"/> structure.
+ /// </summary>
+ /// <param name="x">The X component.</param>
+ /// <param name="y">The Y component.</param>
+ /// <param name="z">The Z component.</param>
+ /// <param name="w">The W component.</param>
+ public Half4(Half x, Half y, Half z, Half w)
+ {
+ this.X = x;
+ this.Y = y;
+ this.Z = z;
+ this.W = w;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half4"/> structure.
+ /// </summary>
+ /// <param name="value">The value to set for the X, Y, Z, and W
components.</param>
+ public Half4(Half value)
+ {
+ this.X = value;
+ this.Y = value;
+ this.Z = value;
+ this.W = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half4"/> structure.
+ /// </summary>
+ /// <param name="x">The X component.</param>
+ /// <param name="y">The Y component.</param>
+ /// <param name="z">The Z component.</param>
+ /// <param name="w">The W component.</param>
+ public Half4(float x, float y, float z, float w)
+ {
+ this.X = (Half)x;
+ this.Y = (Half)y;
+ this.Z = (Half)z;
+ this.W = (Half)w;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="T:SlimMath.Half4"/> structure.
+ /// </summary>
+ /// <param name="value">The value to set for the X, Y, Z, and W
components.</param>
+ public Half4(float value)
+ {
+ this.X = this.Y = this.Z = this.W = (Half)value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SlimMath.Half4"/>
struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the X, Y, Z, and
W components of the vector. This must be an array with four
elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than four
elements.</exception>
+ public Half4(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 4)
+ throw new ArgumentOutOfRangeException("values", "There
must be four and only four input values for Half4.");
+
+ X = (Half)values[0];
+ Y = (Half)values[1];
+ Z = (Half)values[2];
+ W = (Half)values[3];
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the vector.
+ /// </summary>
+ /// <returns>A two-element array containing the components of the
vector.</returns>
+ public Half[] ToArray()
+ {
+ return new Half[] { X, Y, Z, W };
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="left"/> has the same value as
<paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(Half4 left, Half4 right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="left"/> has a different value
than <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator !=(Half4 left, Half4 right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see
cref="T:SlimMath.Vector4"/> to <see cref="T:SlimMath.Half4"/>.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static explicit operator Half4(Vector4 value)
+ {
+ return new Half4(value.X, value.Y, value.Z, value.W);
+ }
+
+ /// <summary>
+ /// Performs an implicit conversion from <see
cref="T:SlimMath.Half4"/> to <see cref="T:SlimMath.Vector4"/>.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static implicit operator Vector4(Half4 value)
+ {
+ return new Vector4(value.X, value.Y, value.Z, value.W);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "X:{0} Y:{1}
Z:{2} Q:{3}", X, Y, Z, W);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format)
+ {
+ if (format == null)
+ return ToString();
+
+ return string.Format(CultureInfo.CurrentCulture, "X:{0} Y:{1}
Z:{2} W:{3}", X.ToString(format, CultureInfo.CurrentCulture),
+ Y.ToString(format, CultureInfo.CurrentCulture),
Z.ToString(format, CultureInfo.CurrentCulture), W.ToString(format,
CultureInfo.CurrentCulture));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(IFormatProvider formatProvider)
+ {
+ return string.Format(formatProvider, "X:{0} Y:{1} Z:{2}
W:{3}", X, Y, Z, W);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format, IFormatProvider
formatProvider)
+ {
+ if (format == null)
+ ToString(formatProvider);
+
+ return string.Format(formatProvider, "X:{0} Y:{1} Z:{2}
W:{3}", X.ToString(format, formatProvider),
+ Y.ToString(format, formatProvider), Z.ToString(format,
formatProvider), W.ToString(format, formatProvider));
+ }
+
+ /// <summary>
+ /// Returns the hash code for this instance.
+ /// </summary>
+ /// <returns>A 32-bit signed integer hash code.</returns>
+ public override int GetHashCode()
+ {
+ return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() +
W.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether the specified object instances are
considered equal.
+ /// </summary>
+ /// <param name="value1"/>
+ /// <param name="value2"/>
+ /// <returns>
+ /// <c>true</c> if <paramref name="value1"/> is the same instance
as <paramref name="value2"/> or
+ /// if both are <c>null</c> references or if
<c>value1.Equals(value2)</c> returns <c>true</c>; otherwise,
<c>false</c>.</returns>
+ public static bool Equals(ref Half4 value1, ref Half4 value2)
+ {
+ return (value1.X == value2.X) && (value1.Y == value2.Y) &&
(value1.Z == value2.Z) && (value1.W == value2.W);
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether the current instance is
equal to the specified object.
+ /// </summary>
+ /// <param name="other">Object to make the comparison with.</param>
+ /// <returns>
+ /// <c>true</c> if the current instance is equal to the specified
object; <c>false</c> otherwise.</returns>
+ public bool Equals(Half4 other)
+ {
+ return (this.X == other.X) && (this.Y == other.Y) && (this.Z
== other.Z) && (this.W == other.W);
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether the current instance is
equal to a specified object.
+ /// </summary>
+ /// <param name="obj">Object to make the comparison with.</param>
+ /// <returns>
+ /// <c>true</c> if the current instance is equal to the specified
object; <c>false</c> otherwise.</returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((Half4)obj);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/HalfUtilities.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,181 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Helper class to perform Half/Float conversion.
+ /// </summary>
+ internal static class HalfUtilities
+ {
+ //Source:
www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf by
Jeroen van der Zijp
+ static readonly uint[] HalfToFloatMantissaTable = new uint[2048];
+ static readonly uint[] HalfToFloatExponentTable = new uint[64];
+ static readonly uint[] HalfToFloatOffsetTable = new uint[64];
+ static readonly ushort[] FloatToHalfBaseTable = new ushort[512];
+ static readonly byte[] FloatToHalfShiftTable = new byte[512];
+
+ [StructLayout(LayoutKind.Explicit)]
+ private struct FloatToUint
+ {
+ [FieldOffset(0)]
+ public uint uintValue;
+
+ [FieldOffset(0)]
+ public float floatValue;
+ }
+
+ static HalfUtilities()
+ {
+ int i;
+
+ //Mantissa table
+
+ //0 => 0
+ HalfToFloatMantissaTable[0] = 0;
+
+ //Transform subnormal to normalized
+ for (i = 1; i < 1024; i++)
+ {
+ uint m = ((uint)i) << 13;
+ uint e = 0;
+
+ while ((m & 0x00800000) == 0)
+ {
+ e -= 0x00800000;
+ m <<= 1;
+ }
+
+ m &= ~0x00800000U;
+ e += 0x38800000;
+ HalfToFloatMantissaTable[i] = m | e;
+ }
+
+ //Normal case
+ for (i = 1024; i < 2048; i++)
+ HalfToFloatMantissaTable[i] = 0x38000000 + (((uint)(i -
1024)) << 13);
+
+ //Exponent table
+
+ //0 => 0
+ HalfToFloatExponentTable[0] = 0;
+
+ for (i = 1; i < 63; i++)
+ {
+ if (i < 31)
+ {
+ //Positive Numbers
+ HalfToFloatExponentTable[i] = ((uint)i) << 23;
+ }
+ else
+ {
+ //Negative Numbers
+ HalfToFloatExponentTable[i] = 0x80000000 + (((uint)(i
- 32)) << 23);
+ }
+ }
+ HalfToFloatExponentTable[31] = 0x47800000;
+ HalfToFloatExponentTable[32] = 0x80000000;
+ HalfToFloatExponentTable[63] = 0xC7800000;
+
+ //Offset table
+ HalfToFloatOffsetTable[0] = 0;
+ for (i = 1; i < 64; i++)
+ HalfToFloatOffsetTable[i] = 1024;
+ HalfToFloatOffsetTable[32] = 0;
+
+ //Float to Half tables
+ for (i = 0; i < 256; i++)
+ {
+ int e = i - 127;
+ if (e < -24)
+ {
+ //Very small numbers map to zero
+ FloatToHalfBaseTable[i | 0x000] = 0x0000;
+ FloatToHalfBaseTable[i | 0x100] = 0x8000;
+ FloatToHalfShiftTable[i | 0x000] = 24;
+ FloatToHalfShiftTable[i | 0x100] = 24;
+ }
+ else if (e < -14)
+ {
+ //Small numbers map to denorms
+ FloatToHalfBaseTable[i | 0x000] = (ushort)((0x0400 >>
(-e - 14)));
+ FloatToHalfBaseTable[i | 0x100] = (ushort)((0x0400 >>
(-e - 14)) | 0x8000);
+ FloatToHalfShiftTable[i | 0x000] = (byte)(-e - 1);
+ FloatToHalfShiftTable[i | 0x100] = (byte)(-e - 1);
+ }
+ else if (e <= 15)
+ {
+ //Normal numbers just lose precision
+ FloatToHalfBaseTable[i | 0x000] = (ushort)(((e + 15)
<< 10));
+ FloatToHalfBaseTable[i | 0x100] = (ushort)(((e + 15)
<< 10) | 0x8000);
+ FloatToHalfShiftTable[i | 0x000] = 13;
+ FloatToHalfShiftTable[i | 0x100] = 13;
+ }
+ else if (e < 128)
+ {
+ //Large numbers map to Infinity
+ FloatToHalfBaseTable[i | 0x000] = 0x7C00;
+ FloatToHalfBaseTable[i | 0x100] = 0xFC00;
+ FloatToHalfShiftTable[i | 0x000] = 24;
+ FloatToHalfShiftTable[i | 0x100] = 24;
+ }
+ else
+ {
+ //Infinity and NaN's stay Infinity and NaN's
+ FloatToHalfBaseTable[i | 0x000] = 0x7C00;
+ FloatToHalfBaseTable[i | 0x100] = 0xFC00;
+ FloatToHalfShiftTable[i | 0x000] = 13;
+ FloatToHalfShiftTable[i | 0x100] = 13;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Unpacks the specified half.
+ /// </summary>
+ /// <param name="value">The half to unpack.</param>
+ /// <returns>The floating point representation of the
half.</returns>
+ public static float Unpack(ushort value)
+ {
+ var conv = new FloatToUint();
+ conv.uintValue =
HalfToFloatMantissaTable[HalfToFloatOffsetTable[value >> 10] +
(((uint)value) & 0x3ff)] + HalfToFloatExponentTable[value >> 10];
+ return conv.floatValue;
+ }
+
+ /// <summary>
+ /// Packs the specified float.
+ /// </summary>
+ /// <param name="value">The float to pack.</param>
+ /// <returns>The half represntation of the float.</returns>
+ public static ushort Pack(float value)
+ {
+ FloatToUint conv = new FloatToUint();
+ conv.floatValue = value;
+ return (ushort)(FloatToHalfBaseTable[(conv.uintValue >> 23) &
0x1ff] + ((conv.uintValue & 0x007fffff) >>
FloatToHalfShiftTable[(conv.uintValue >> 23) & 0x1ff]));
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Matrix.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,3088 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+using System.Globalization;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents a 4x4 mathematical matrix.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ [TypeConverter(typeof(SlimMath.Design.MatrixConverter))]
+ public struct Matrix : IEquatable<Matrix>, IFormattable
+ {
+ /// <summary>
+ /// The size of the <see cref="SlimMath.Matrix"/> type, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(Matrix));
+
+ /// <summary>
+ /// A <see cref="SlimMath.Matrix"/> with all of its components set
to zero.
+ /// </summary>
+ public static readonly Matrix Zero = new Matrix();
+
+ /// <summary>
+ /// The identity <see cref="SlimMath.Matrix"/>.
+ /// </summary>
+ public static readonly Matrix Identity = new Matrix() { M11 =
1.0f, M22 = 1.0f, M33 = 1.0f, M44 = 1.0f };
+
+ /// <summary>
+ /// Value at row 1 column 1 of the matrix.
+ /// </summary>
+ public float M11;
+
+ /// <summary>
+ /// Value at row 1 column 2 of the matrix.
+ /// </summary>
+ public float M12;
+
+ /// <summary>
+ /// Value at row 1 column 3 of the matrix.
+ /// </summary>
+ public float M13;
+
+ /// <summary>
+ /// Value at row 1 column 4 of the matrix.
+ /// </summary>
+ public float M14;
+
+ /// <summary>
+ /// Value at row 2 column 1 of the matrix.
+ /// </summary>
+ public float M21;
+
+ /// <summary>
+ /// Value at row 2 column 2 of the matrix.
+ /// </summary>
+ public float M22;
+
+ /// <summary>
+ /// Value at row 2 column 3 of the matrix.
+ /// </summary>
+ public float M23;
+
+ /// <summary>
+ /// Value at row 2 column 4 of the matrix.
+ /// </summary>
+ public float M24;
+
+ /// <summary>
+ /// Value at row 3 column 1 of the matrix.
+ /// </summary>
+ public float M31;
+
+ /// <summary>
+ /// Value at row 3 column 2 of the matrix.
+ /// </summary>
+ public float M32;
+
+ /// <summary>
+ /// Value at row 3 column 3 of the matrix.
+ /// </summary>
+ public float M33;
+
+ /// <summary>
+ /// Value at row 3 column 4 of the matrix.
+ /// </summary>
+ public float M34;
+
+ /// <summary>
+ /// Value at row 4 column 1 of the matrix.
+ /// </summary>
+ public float M41;
+
+ /// <summary>
+ /// Value at row 4 column 2 of the matrix.
+ /// </summary>
+ public float M42;
+
+ /// <summary>
+ /// Value at row 4 column 3 of the matrix.
+ /// </summary>
+ public float M43;
+
+ /// <summary>
+ /// Value at row 4 column 4 of the matrix.
+ /// </summary>
+ public float M44;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Matrix"/> struct.
+ /// </summary>
+ /// <param name="value">The value that will be assigned to all
components.</param>
+ public Matrix(float value)
+ {
+ M11 = M12 = M13 = M14 =
+ M21 = M22 = M23 = M24 =
+ M31 = M32 = M33 = M34 =
+ M41 = M42 = M43 = M44 = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Matrix"/> struct.
+ /// </summary>
+ /// <param name="M11">The value to assign at row 1 column 1 of the
matrix.</param>
+ /// <param name="M12">The value to assign at row 1 column 2 of the
matrix.</param>
+ /// <param name="M13">The value to assign at row 1 column 3 of the
matrix.</param>
+ /// <param name="M14">The value to assign at row 1 column 4 of the
matrix.</param>
+ /// <param name="M21">The value to assign at row 2 column 1 of the
matrix.</param>
+ /// <param name="M22">The value to assign at row 2 column 2 of the
matrix.</param>
+ /// <param name="M23">The value to assign at row 2 column 3 of the
matrix.</param>
+ /// <param name="M24">The value to assign at row 2 column 4 of the
matrix.</param>
+ /// <param name="M31">The value to assign at row 3 column 1 of the
matrix.</param>
+ /// <param name="M32">The value to assign at row 3 column 2 of the
matrix.</param>
+ /// <param name="M33">The value to assign at row 3 column 3 of the
matrix.</param>
+ /// <param name="M34">The value to assign at row 3 column 4 of the
matrix.</param>
+ /// <param name="M41">The value to assign at row 4 column 1 of the
matrix.</param>
+ /// <param name="M42">The value to assign at row 4 column 2 of the
matrix.</param>
+ /// <param name="M43">The value to assign at row 4 column 3 of the
matrix.</param>
+ /// <param name="M44">The value to assign at row 4 column 4 of the
matrix.</param>
+ public Matrix(float M11, float M12, float M13, float M14,
+ float M21, float M22, float M23, float M24,
+ float M31, float M32, float M33, float M34,
+ float M41, float M42, float M43, float M44)
+ {
+ this.M11 = M11; this.M12 = M12; this.M13 = M13; this.M14 = M14;
+ this.M21 = M21; this.M22 = M22; this.M23 = M23; this.M24 = M24;
+ this.M31 = M31; this.M32 = M32; this.M33 = M33; this.M34 = M34;
+ this.M41 = M41; this.M42 = M42; this.M43 = M43; this.M44 = M44;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Matrix"/> struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the components of
the matrix. This must be an array with sixteen elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than sixteen
elements.</exception>
+ public Matrix(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 16)
+ throw new ArgumentOutOfRangeException("values", "There
must be sixteen and only sixteen input values for Matrix.");
+
+ M11 = values[0];
+ M12 = values[1];
+ M13 = values[2];
+ M14 = values[3];
+
+ M21 = values[4];
+ M22 = values[5];
+ M23 = values[6];
+ M24 = values[7];
+
+ M31 = values[8];
+ M32 = values[9];
+ M33 = values[10];
+ M34 = values[11];
+
+ M41 = values[12];
+ M42 = values[13];
+ M43 = values[14];
+ M44 = values[15];
+ }
+
+ /// <summary>
+ /// Gets or sets the first row in the matrix; that is M11, M12,
M13, and M14.
+ /// </summary>
+ public Vector4 Row1
+ {
+ get { return new Vector4(M11, M12, M13, M14); }
+ set { M11 = value.X; M12 = value.Y; M13 = value.Z; M14 =
value.W; }
+ }
+
+ /// <summary>
+ /// Gets or sets the second row in the matrix; that is M21, M22,
M23, and M24.
+ /// </summary>
+ public Vector4 Row2
+ {
+ get { return new Vector4(M21, M22, M23, M24); }
+ set { M21 = value.X; M22 = value.Y; M23 = value.Z; M24 =
value.W; }
+ }
+
+ /// <summary>
+ /// Gets or sets the third row in the matrix; that is M31, M32,
M33, and M34.
+ /// </summary>
+ public Vector4 Row3
+ {
+ get { return new Vector4(M31, M32, M33, M34); }
+ set { M31 = value.X; M32 = value.Y; M33 = value.Z; M34 =
value.W; }
+ }
+
+ /// <summary>
+ /// Gets or sets the fourth row in the matrix; that is M41, M42,
M43, and M44.
+ /// </summary>
+ public Vector4 Row4
+ {
+ get { return new Vector4(M41, M42, M43, M44); }
+ set { M41 = value.X; M42 = value.Y; M43 = value.Z; M44 =
value.W; }
+ }
+
+ /// <summary>
+ /// Gets or sets the first column in the matrix; that is M11, M21,
M31, and M41.
+ /// </summary>
+ public Vector4 Column1
+ {
+ get { return new Vector4(M11, M21, M31, M41); }
+ set { M11 = value.X; M21 = value.Y; M31 = value.Z; M41 =
value.W; }
+ }
+
+ /// <summary>
+ /// Gets or sets the second column in the matrix; that is M12,
M22, M32, and M42.
+ /// </summary>
+ public Vector4 Column2
+ {
+ get { return new Vector4(M12, M22, M32, M42); }
+ set { M12 = value.X; M22 = value.Y; M32 = value.Z; M42 =
value.W; }
+ }
+
+ /// <summary>
+ /// Gets or sets the third column in the matrix; that is M13, M23,
M33, and M43.
+ /// </summary>
+ public Vector4 Column3
+ {
+ get { return new Vector4(M13, M23, M33, M43); }
+ set { M13 = value.X; M23 = value.Y; M33 = value.Z; M43 =
value.W; }
+ }
+
+ /// <summary>
+ /// Gets or sets the fourth column in the matrix; that is M14,
M24, M34, and M44.
+ /// </summary>
+ public Vector4 Column4
+ {
+ get { return new Vector4(M14, M24, M34, M44); }
+ set { M14 = value.X; M24 = value.Y; M34 = value.Z; M44 =
value.W; }
+ }
+
+ /// <summary>
+ /// Gets or sets the translation of the matrix; that is M41, M42,
and M43.
+ /// </summary>
+ public Vector3 TranslationVector
+ {
+ get { return new Vector3(M41, M42, M43); }
+ set { M41 = value.X; M42 = value.Y; M43 = value.Z; }
+ }
+
+ /// <summary>
+ /// Gets or sets the scale of the matrix; that is M11, M22, and
M33.
+ /// </summary>
+ public Vector3 ScaleVector
+ {
+ get { return new Vector3(M11, M22, M33); }
+ set { M11 = value.X; M22 = value.Y; M33 = value.Z; }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this instance is an identity
matrix.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this instance is an identity matrix; otherwise,
<c>false</c>.
+ /// </value>
+ public bool IsIdentity
+ {
+ get { return this.Equals(Identity); }
+ }
+
+ /// <summary>
+ /// Calculates the determinant of the matrix.
+ /// </summary>
+ /// <returns>The determinant of the matrix.</returns>
+ public float Determinant
+ {
+ get
+ {
+ float temp1 = (M33 * M44) - (M34 * M43);
+ float temp2 = (M32 * M44) - (M34 * M42);
+ float temp3 = (M32 * M43) - (M33 * M42);
+ float temp4 = (M31 * M44) - (M34 * M41);
+ float temp5 = (M31 * M43) - (M33 * M41);
+ float temp6 = (M31 * M42) - (M32 * M41);
+
+ return ((((M11 * (((M22 * temp1) - (M23 * temp2)) + (M24 *
temp3))) - (M12 * (((M21 * temp1) -
+ (M23 * temp4)) + (M24 * temp5)))) + (M13 * (((M21 *
temp2) - (M22 * temp4)) + (M24 * temp6)))) -
+ (M14 * (((M21 * temp3) - (M22 * temp5)) + (M23 *
temp6))));
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the component at the specified index.
+ /// </summary>
+ /// <value>The value of the matrix component, depending on the
index.</value>
+ /// <param name="index">The zero-based index of the component to
access.</param>
+ /// <returns>The value of the component at the specified
index.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="index"/> is out of the range [0, 15].</exception>
+ public float this[int index]
+ {
+ get
+ {
+ switch (index)
+ {
+ case 0: return M11;
+ case 1: return M12;
+ case 2: return M13;
+ case 3: return M14;
+ case 4: return M21;
+ case 5: return M22;
+ case 6: return M23;
+ case 7: return M24;
+ case 8: return M31;
+ case 9: return M32;
+ case 10: return M33;
+ case 11: return M34;
+ case 12: return M41;
+ case 13: return M42;
+ case 14: return M43;
+ case 15: return M44;
+ }
+
+ throw new ArgumentOutOfRangeException("index", "Indices
for Matrix run from 0 to 15, inclusive.");
+ }
+
+ set
+ {
+ switch (index)
+ {
+ case 0: M11 = value; break;
+ case 1: M12 = value; break;
+ case 2: M13 = value; break;
+ case 3: M14 = value; break;
+ case 4: M21 = value; break;
+ case 5: M22 = value; break;
+ case 6: M23 = value; break;
+ case 7: M24 = value; break;
+ case 8: M31 = value; break;
+ case 9: M32 = value; break;
+ case 10: M33 = value; break;
+ case 11: M34 = value; break;
+ case 12: M41 = value; break;
+ case 13: M42 = value; break;
+ case 14: M43 = value; break;
+ case 15: M44 = value; break;
+ default: throw new
ArgumentOutOfRangeException("index", "Indices for Matrix run from 0 to 15,
inclusive.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the component at the specified index.
+ /// </summary>
+ /// <value>The value of the matrix component, depending on the
index.</value>
+ /// <param name="row">The row of the matrix to access.</param>
+ /// <param name="column">The column of the matrix to
access.</param>
+ /// <returns>The value of the component at the specified
index.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="row"/> or <paramref name="column"/>is out of the
range [0, 3].</exception>
+ public float this[int row, int column]
+ {
+ get
+ {
+ if (row < 0 || row > 3)
+ throw new ArgumentOutOfRangeException("row", "Rows and
columns for matrices run from 0 to 3, inclusive.");
+ if (column < 0 || column > 3)
+ throw new ArgumentOutOfRangeException("column", "Rows
and columns for matrices run from 0 to 3, inclusive.");
+
+ return this[(row * 4) + column];
+ }
+
+ set
+ {
+ if (row < 0 || row > 3)
+ throw new ArgumentOutOfRangeException("row", "Rows and
columns for matrices run from 0 to 3, inclusive.");
+ if (column < 0 || column > 3)
+ throw new ArgumentOutOfRangeException("column", "Rows
and columns for matrices run from 0 to 3, inclusive.");
+
+ this[(row * 4) + column] = value;
+ }
+ }
+
+ /// <summary>
+ /// Negates a matrix.
+ /// </summary>
+ public void Negate()
+ {
+ Negate(ref this, out this);
+ }
+
+ /// <summary>
+ /// Inverts the matrix.
+ /// </summary>
+ public void Invert()
+ {
+ Invert(ref this, out this);
+ }
+
+ /// <summary>
+ /// Transposes the matrix.
+ /// </summary>
+ public void Transpose()
+ {
+ Transpose(ref this, out this);
+ }
+
+ /// <summary>
+ /// Performs the exponential operation on a matrix.
+ /// </summary>
+ /// <param name="exponent">The exponent to raise the matrix
to.</param>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="exponent"/> is negative.</exception>
+ public void Exponent(int exponent)
+ {
+ Exponent(ref this, exponent, out this);
+ }
+
+ /// <summary>
+ /// Orthogonalizes the specified matrix.
+ /// </summary>
+ /// <remarks>
+ /// <para>Orthogonalization is the process of making all rows
orthogonal to each other. This
+ /// means that any given row in the matrix will be orthogonal to
any other given row in the
+ /// matrix.</para>
+ /// <para>Because this method uses the modified Gram-Schmidt
process, the resulting matrix
+ /// tends to be numerically unstable. The numeric stability
decreases according to the rows
+ /// so that the first row is the most stable and the last row is
the least stable.</para>
+ /// <para>This operation is performed on the rows of the matrix
rather than the columns.
+ /// If you wish for this operation to be performed on the columns,
first transpose the
+ /// input and than transpose the output.</para>
+ /// </remarks>
+ public void Orthogonalize()
+ {
+ Orthogonalize(ref this, out this);
+ }
+
+ /// <summary>
+ /// Orthonormalizes the specified matrix.
+ /// </summary>
+ /// <remarks>
+ /// <para>Orthonormalization is the process of making all rows and
columns orthogonal to each
+ /// other and making all rows and columns of unit length. This
means that any given row will
+ /// be orthogonal to any other given row and any given column will
be orthogonal to any other
+ /// given column. Any given row will not be orthogonal to any
given column. Every row and every
+ /// column will be of unit length.</para>
+ /// <para>Because this method uses the modified Gram-Schmidt
process, the resulting matrix
+ /// tends to be numerically unstable. The numeric stability
decreases according to the rows
+ /// so that the first row is the most stable and the last row is
the least stable.</para>
+ /// <para>This operation is performed on the rows of the matrix
rather than the columns.
+ /// If you wish for this operation to be performed on the columns,
first transpose the
+ /// input and than transpose the output.</para>
+ /// </remarks>
+ public void Orthonormalize()
+ {
+ Orthonormalize(ref this, out this);
+ }
+
+ /// <summary>
+ /// Decomposes a matrix into an orthonormalized matrix Q and a
right traingular matrix R.
+ /// </summary>
+ /// <param name="Q">When the method completes, contains the
orthonormalized matrix of the decomposition.</param>
+ /// <param name="R">When the method completes, contains the right
triangular matrix of the decomposition.</param>
+ public void DecomposeQR(out Matrix Q, out Matrix R)
+ {
+ Matrix temp = this;
+ temp.Transpose();
+ Orthonormalize(ref temp, out Q);
+ Q.Transpose();
+
+ R = new Matrix();
+ R.M11 = Vector4.Dot(Q.Column1, Column1);
+ R.M12 = Vector4.Dot(Q.Column1, Column2);
+ R.M13 = Vector4.Dot(Q.Column1, Column3);
+ R.M14 = Vector4.Dot(Q.Column1, Column4);
+
+ R.M22 = Vector4.Dot(Q.Column2, Column2);
+ R.M23 = Vector4.Dot(Q.Column2, Column3);
+ R.M24 = Vector4.Dot(Q.Column2, Column4);
+
+ R.M33 = Vector4.Dot(Q.Column3, Column3);
+ R.M34 = Vector4.Dot(Q.Column3, Column4);
+
+ R.M44 = Vector4.Dot(Q.Column4, Column4);
+ }
+
+ /// <summary>
+ /// Decomposes a matrix into a lower triangular matrix L and an
orthonormalized matrix Q.
+ /// </summary>
+ /// <param name="L">When the method completes, contains the lower
triangular matrix of the decomposition.</param>
+ /// <param name="Q">When the method completes, contains the
orthonormalized matrix of the decomposition.</param>
+ public void DecomposeLQ(out Matrix L, out Matrix Q)
+ {
+ Orthonormalize(ref this, out Q);
+
+ L = new Matrix();
+ L.M11 = Vector4.Dot(Q.Row1, Row1);
+
+ L.M21 = Vector4.Dot(Q.Row1, Row2);
+ L.M22 = Vector4.Dot(Q.Row2, Row2);
+
+ L.M31 = Vector4.Dot(Q.Row1, Row3);
+ L.M32 = Vector4.Dot(Q.Row2, Row3);
+ L.M33 = Vector4.Dot(Q.Row3, Row3);
+
+ L.M41 = Vector4.Dot(Q.Row1, Row4);
+ L.M42 = Vector4.Dot(Q.Row2, Row4);
+ L.M43 = Vector4.Dot(Q.Row3, Row4);
+ L.M44 = Vector4.Dot(Q.Row4, Row4);
+ }
+
+ /// <summary>
+ /// Decomposes a matrix into a scale, rotation, and translation.
+ /// </summary>
+ /// <param name="scale">When the method completes, contains the
scaling component of the decomposed matrix.</param>
+ /// <param name="rotation">When the method completes, contains the
rtoation component of the decomposed matrix.</param>
+ /// <param name="translation">When the method completes, contains
the translation component of the decomposed matrix.</param>
+ /// <remarks>
+ /// This method is designed to decompose an SRT transformation
matrix only.
+ /// </remarks>
+ public bool Decompose(out Vector3 scale, out Quaternion rotation,
out Vector3 translation)
+ {
+ //Source: Unknown
+ //References:
http://www.gamedev.net/community/forums/topic.asp?topic_id=441695
+
+ //Get the translation.
+ translation.X = this.M41;
+ translation.Y = this.M42;
+ translation.Z = this.M43;
+
+ //Scaling is the length of the rows.
+ scale.X = (float)Math.Sqrt((M11 * M11) + (M12 * M12) + (M13 *
M13));
+ scale.Y = (float)Math.Sqrt((M21 * M21) + (M22 * M22) + (M23 *
M23));
+ scale.Z = (float)Math.Sqrt((M31 * M31) + (M32 * M32) + (M33 *
M33));
+
+ //If any of the scaling factors are zero, than the rotation
matrix can not exist.
+ if (Math.Abs(scale.X) < Utilities.ZeroTolerance ||
+ Math.Abs(scale.Y) < Utilities.ZeroTolerance ||
+ Math.Abs(scale.Z) < Utilities.ZeroTolerance)
+ {
+ rotation = Quaternion.Identity;
+ return false;
+ }
+
+ //The rotation is the left over matrix after dividing out the
scaling.
+ Matrix rotationmatrix = new Matrix();
+ rotationmatrix.M11 = M11 / scale.X;
+ rotationmatrix.M12 = M12 / scale.X;
+ rotationmatrix.M13 = M13 / scale.X;
+
+ rotationmatrix.M21 = M21 / scale.Y;
+ rotationmatrix.M22 = M22 / scale.Y;
+ rotationmatrix.M23 = M23 / scale.Y;
+
+ rotationmatrix.M31 = M31 / scale.Z;
+ rotationmatrix.M32 = M32 / scale.Z;
+ rotationmatrix.M33 = M33 / scale.Z;
+
+ rotationmatrix.M44 = 1f;
+
+ Quaternion.RotationMatrix(ref rotationmatrix, out rotation);
+ return true;
+ }
+
+ /// <summary>
+ /// Exchanges two rows in the matrix.
+ /// </summary>
+ /// <param name="firstRow">The first row to exchange. This is an
index of the row starting at zero.</param>
+ /// <param name="secondRow">The second row to exchange. This is an
index of the row starting at zero.</param>
+ public void ExchangeRows(int firstRow, int secondRow)
+ {
+ if (firstRow < 0)
+ throw new ArgumentOutOfRangeException("firstRow", "The
parameter firstRow must be greater than or equal to zero.");
+ if (firstRow > 3)
+ throw new ArgumentOutOfRangeException("firstRow", "The
parameter firstRow must be less than or equal to three.");
+ if (secondRow < 0)
+ throw new ArgumentOutOfRangeException("secondRow", "The
parameter secondRow must be greater than or equal to zero.");
+ if (secondRow > 3)
+ throw new ArgumentOutOfRangeException("secondRow", "The
parameter secondRow must be less than or equal to three.");
+
+ if (firstRow == secondRow)
+ return;
+
+ float temp0 = this[secondRow, 0];
+ float temp1 = this[secondRow, 1];
+ float temp2 = this[secondRow, 2];
+ float temp3 = this[secondRow, 3];
+
+ this[secondRow, 0] = this[firstRow, 0];
+ this[secondRow, 1] = this[firstRow, 1];
+ this[secondRow, 2] = this[firstRow, 2];
+ this[secondRow, 3] = this[firstRow, 3];
+
+ this[firstRow, 0] = temp0;
+ this[firstRow, 1] = temp1;
+ this[firstRow, 2] = temp2;
+ this[firstRow, 3] = temp3;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="firstColumn"></param>
+ /// <param name="secondColumn"></param>
+ public void ExchangeColumns(int firstColumn, int secondColumn)
+ {
+ if (firstColumn < 0)
+ throw new ArgumentOutOfRangeException("firstColumn", "The
parameter firstColumn must be greater than or equal to zero.");
+ if (firstColumn > 3)
+ throw new ArgumentOutOfRangeException("firstColumn", "The
parameter firstColumn must be less than or equal to three.");
+ if (secondColumn < 0)
+ throw new ArgumentOutOfRangeException("secondColumn", "The
parameter secondColumn must be greater than or equal to zero.");
+ if (secondColumn > 3)
+ throw new ArgumentOutOfRangeException("secondColumn", "The
parameter secondColumn must be less than or equal to three.");
+
+ if (firstColumn == secondColumn)
+ return;
+
+ float temp0 = this[0, secondColumn];
+ float temp1 = this[1, secondColumn];
+ float temp2 = this[2, secondColumn];
+ float temp3 = this[3, secondColumn];
+
+ this[0, secondColumn] = this[0, firstColumn];
+ this[1, secondColumn] = this[1, firstColumn];
+ this[2, secondColumn] = this[2, firstColumn];
+ this[3, secondColumn] = this[3, firstColumn];
+
+ this[0, firstColumn] = temp0;
+ this[1, firstColumn] = temp1;
+ this[2, firstColumn] = temp2;
+ this[3, firstColumn] = temp3;
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the matrix.
+ /// </summary>
+ /// <returns>A sixteen-element array containing the components of
the matrix.</returns>
+ public float[] ToArray()
+ {
+ return new[] { M11, M12, M13, M14, M21, M22, M23, M24, M31,
M32, M33, M34, M41, M42, M43, M44 };
+ }
+
+ /// <summary>
+ /// Determines the sum of two matrices.
+ /// </summary>
+ /// <param name="left">The first matrix to add.</param>
+ /// <param name="right">The second matrix to add.</param>
+ /// <param name="result">When the method completes, contains the
sum of the two matrices.</param>
+ public static void Add(ref Matrix left, ref Matrix right, out
Matrix result)
+ {
+ result.M11 = left.M11 + right.M11;
+ result.M12 = left.M12 + right.M12;
+ result.M13 = left.M13 + right.M13;
+ result.M14 = left.M14 + right.M14;
+ result.M21 = left.M21 + right.M21;
+ result.M22 = left.M22 + right.M22;
+ result.M23 = left.M23 + right.M23;
+ result.M24 = left.M24 + right.M24;
+ result.M31 = left.M31 + right.M31;
+ result.M32 = left.M32 + right.M32;
+ result.M33 = left.M33 + right.M33;
+ result.M34 = left.M34 + right.M34;
+ result.M41 = left.M41 + right.M41;
+ result.M42 = left.M42 + right.M42;
+ result.M43 = left.M43 + right.M43;
+ result.M44 = left.M44 + right.M44;
+ }
+
+ /// <summary>
+ /// Determines the sum of two matrices.
+ /// </summary>
+ /// <param name="left">The first matrix to add.</param>
+ /// <param name="right">The second matrix to add.</param>
+ /// <returns>The sum of the two matrices.</returns>
+ public static Matrix Add(Matrix left, Matrix right)
+ {
+ Matrix result;
+ Add(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Determines the difference between two matrices.
+ /// </summary>
+ /// <param name="left">The first matrix to subtract.</param>
+ /// <param name="right">The second matrix to subtract.</param>
+ /// <param name="result">When the method completes, contains the
difference between the two matrices.</param>
+ public static void Subtract(ref Matrix left, ref Matrix right, out
Matrix result)
+ {
+ result.M11 = left.M11 - right.M11;
+ result.M12 = left.M12 - right.M12;
+ result.M13 = left.M13 - right.M13;
+ result.M14 = left.M14 - right.M14;
+ result.M21 = left.M21 - right.M21;
+ result.M22 = left.M22 - right.M22;
+ result.M23 = left.M23 - right.M23;
+ result.M24 = left.M24 - right.M24;
+ result.M31 = left.M31 - right.M31;
+ result.M32 = left.M32 - right.M32;
+ result.M33 = left.M33 - right.M33;
+ result.M34 = left.M34 - right.M34;
+ result.M41 = left.M41 - right.M41;
+ result.M42 = left.M42 - right.M42;
+ result.M43 = left.M43 - right.M43;
+ result.M44 = left.M44 - right.M44;
+ }
+
+ /// <summary>
+ /// Determines the difference between two matrices.
+ /// </summary>
+ /// <param name="left">The first matrix to subtract.</param>
+ /// <param name="right">The second matrix to subtract.</param>
+ /// <returns>The difference between the two matrices.</returns>
+ public static Matrix Subtract(Matrix left, Matrix right)
+ {
+ Matrix result;
+ Subtract(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Scales a matrix by the given value.
+ /// </summary>
+ /// <param name="left">The matrix to scale.</param>
+ /// <param name="scalar">The amount by which to scale.</param>
+ /// <param name="result">When the method completes, contains the
scaled matrix.</param>
+ public static void Multiply(ref Matrix left, float scalar, out
Matrix result)
+ {
+ result.M11 = left.M11 * scalar;
+ result.M12 = left.M12 * scalar;
+ result.M13 = left.M13 * scalar;
+ result.M14 = left.M14 * scalar;
+ result.M21 = left.M21 * scalar;
+ result.M22 = left.M22 * scalar;
+ result.M23 = left.M23 * scalar;
+ result.M24 = left.M24 * scalar;
+ result.M31 = left.M31 * scalar;
+ result.M32 = left.M32 * scalar;
+ result.M33 = left.M33 * scalar;
+ result.M34 = left.M34 * scalar;
+ result.M41 = left.M41 * scalar;
+ result.M42 = left.M42 * scalar;
+ result.M43 = left.M43 * scalar;
+ result.M44 = left.M44 * scalar;
+ }
+
+ /// <summary>
+ /// Scales a matrix by the given value.
+ /// </summary>
+ /// <param name="left">The matrix to scale.</param>
+ /// <param name="scalar">The amount by which to scale.</param>
+ /// <returns>The scaled matrix.</returns>
+ public static Matrix Multiply(Matrix left, float scalar)
+ {
+ Matrix result;
+ Multiply(ref left, scalar, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Determines the product of two matrices.
+ /// </summary>
+ /// <param name="left">The first matrix to multiply.</param>
+ /// <param name="right">The second matrix to multiply.</param>
+ /// <param name="result">The product of the two matrices.</param>
+ public static void Multiply(ref Matrix left, ref Matrix right, out
Matrix result)
+ {
+ result = new Matrix();
+ result.M11 = (left.M11 * right.M11) + (left.M12 * right.M21) +
(left.M13 * right.M31) + (left.M14 * right.M41);
+ result.M12 = (left.M11 * right.M12) + (left.M12 * right.M22) +
(left.M13 * right.M32) + (left.M14 * right.M42);
+ result.M13 = (left.M11 * right.M13) + (left.M12 * right.M23) +
(left.M13 * right.M33) + (left.M14 * right.M43);
+ result.M14 = (left.M11 * right.M14) + (left.M12 * right.M24) +
(left.M13 * right.M34) + (left.M14 * right.M44);
+ result.M21 = (left.M21 * right.M11) + (left.M22 * right.M21) +
(left.M23 * right.M31) + (left.M24 * right.M41);
+ result.M22 = (left.M21 * right.M12) + (left.M22 * right.M22) +
(left.M23 * right.M32) + (left.M24 * right.M42);
+ result.M23 = (left.M21 * right.M13) + (left.M22 * right.M23) +
(left.M23 * right.M33) + (left.M24 * right.M43);
+ result.M24 = (left.M21 * right.M14) + (left.M22 * right.M24) +
(left.M23 * right.M34) + (left.M24 * right.M44);
+ result.M31 = (left.M31 * right.M11) + (left.M32 * right.M21) +
(left.M33 * right.M31) + (left.M34 * right.M41);
+ result.M32 = (left.M31 * right.M12) + (left.M32 * right.M22) +
(left.M33 * right.M32) + (left.M34 * right.M42);
+ result.M33 = (left.M31 * right.M13) + (left.M32 * right.M23) +
(left.M33 * right.M33) + (left.M34 * right.M43);
+ result.M34 = (left.M31 * right.M14) + (left.M32 * right.M24) +
(left.M33 * right.M34) + (left.M34 * right.M44);
+ result.M41 = (left.M41 * right.M11) + (left.M42 * right.M21) +
(left.M43 * right.M31) + (left.M44 * right.M41);
+ result.M42 = (left.M41 * right.M12) + (left.M42 * right.M22) +
(left.M43 * right.M32) + (left.M44 * right.M42);
+ result.M43 = (left.M41 * right.M13) + (left.M42 * right.M23) +
(left.M43 * right.M33) + (left.M44 * right.M43);
+ result.M44 = (left.M41 * right.M14) + (left.M42 * right.M24) +
(left.M43 * right.M34) + (left.M44 * right.M44);
+ }
+
+ /// <summary>
+ /// Determines the product of two matrices.
+ /// </summary>
+ /// <param name="left">The first matrix to multiply.</param>
+ /// <param name="right">The second matrix to multiply.</param>
+ /// <returns>The product of the two matrices.</returns>
+ public static Matrix Multiply(Matrix left, Matrix right)
+ {
+ Matrix result;
+ Multiply(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Scales a matrix by the given value.
+ /// </summary>
+ /// <param name="left">The matrix to scale.</param>
+ /// <param name="scalar">The amount by which to scale.</param>
+ /// <param name="result">When the method completes, contains the
scaled matrix.</param>
+ public static void Divide(ref Matrix left, float scalar, out
Matrix result)
+ {
+ float inv = 1.0f / scalar;
+
+ result.M11 = left.M11 * inv;
+ result.M12 = left.M12 * inv;
+ result.M13 = left.M13 * inv;
+ result.M14 = left.M14 * inv;
+ result.M21 = left.M21 * inv;
+ result.M22 = left.M22 * inv;
+ result.M23 = left.M23 * inv;
+ result.M24 = left.M24 * inv;
+ result.M31 = left.M31 * inv;
+ result.M32 = left.M32 * inv;
+ result.M33 = left.M33 * inv;
+ result.M34 = left.M34 * inv;
+ result.M41 = left.M41 * inv;
+ result.M42 = left.M42 * inv;
+ result.M43 = left.M43 * inv;
+ result.M44 = left.M44 * inv;
+ }
+
+ /// <summary>
+ /// Scales a matrix by the given value.
+ /// </summary>
+ /// <param name="left">The matrix to scale.</param>
+ /// <param name="scalar">The amount by which to scale.</param>
+ /// <returns>The scaled matrix.</returns>
+ public static Matrix Divide(Matrix left, float scalar)
+ {
+ Matrix result;
+ Divide(ref left, scalar, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Determines the quotient of two matrices.
+ /// </summary>
+ /// <param name="left">The first matrix to divide.</param>
+ /// <param name="right">The second matrix to divide.</param>
+ /// <param name="result">When the method completes, contains the
quotient of the two matrices.</param>
+ public static void Divide(ref Matrix left, ref Matrix right, out
Matrix result)
+ {
+ result.M11 = left.M11 / right.M11;
+ result.M12 = left.M12 / right.M12;
+ result.M13 = left.M13 / right.M13;
+ result.M14 = left.M14 / right.M14;
+ result.M21 = left.M21 / right.M21;
+ result.M22 = left.M22 / right.M22;
+ result.M23 = left.M23 / right.M23;
+ result.M24 = left.M24 / right.M24;
+ result.M31 = left.M31 / right.M31;
+ result.M32 = left.M32 / right.M32;
+ result.M33 = left.M33 / right.M33;
+ result.M34 = left.M34 / right.M34;
+ result.M41 = left.M41 / right.M41;
+ result.M42 = left.M42 / right.M42;
+ result.M43 = left.M43 / right.M43;
+ result.M44 = left.M44 / right.M44;
+ }
+
+ /// <summary>
+ /// Determines the quotient of two matrices.
+ /// </summary>
+ /// <param name="left">The first matrix to divide.</param>
+ /// <param name="right">The second matrix to divide.</param>
+ /// <returns>The quotient of the two matrices.</returns>
+ public static Matrix Divide(Matrix left, Matrix right)
+ {
+ Matrix result;
+ Divide(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs the exponential operation on a matrix.
+ /// </summary>
+ /// <param name="value">The matrix to perform the operation
on.</param>
+ /// <param name="exponent">The exponent to raise the matrix
to.</param>
+ /// <param name="result">When the method completes, contains the
exponential matrix.</param>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="exponent"/> is negative.</exception>
+ public static void Exponent(ref Matrix value, int exponent, out
Matrix result)
+ {
+ //Source:
http://rosettacode.org
+ //Refrence:
http://rosettacode.org/wiki/Matrix-exponentiation_operator
+
+ if (exponent < 0)
+ throw new ArgumentOutOfRangeException("exponent", "The
exponent can not be negative.");
+
+ if (exponent == 0)
+ {
+ result = Matrix.Identity;
+ return;
+ }
+
+ if (exponent == 1)
+ {
+ result = value;
+ return;
+ }
+
+ Matrix identity = Matrix.Identity;
+ Matrix temp = value;
+
+ while (true)
+ {
+ if ((exponent & 1) != 0)
+ identity = identity * temp;
+
+ exponent /= 2;
+
+ if (exponent > 0)
+ temp *= temp;
+ else
+ break;
+ }
+
+ result = identity;
+ }
+
+ /// <summary>
+ /// Performs the exponential operation on a matrix.
+ /// </summary>
+ /// <param name="value">The matrix to perform the operation
on.</param>
+ /// <param name="exponent">The exponent to raise the matrix
to.</param>
+ /// <returns>The exponential matrix.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="exponent"/> is negative.</exception>
+ public static Matrix Exponent(Matrix value, int exponent)
+ {
+ Matrix result;
+ Exponent(ref value, exponent, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Negates a matrix.
+ /// </summary>
+ /// <param name="value">The matrix to be negated.</param>
+ /// <param name="result">When the method completes, contains the
negated matrix.</param>
+ public static void Negate(ref Matrix value, out Matrix result)
+ {
+ result.M11 = -value.M11;
+ result.M12 = -value.M12;
+ result.M13 = -value.M13;
+ result.M14 = -value.M14;
+ result.M21 = -value.M21;
+ result.M22 = -value.M22;
+ result.M23 = -value.M23;
+ result.M24 = -value.M24;
+ result.M31 = -value.M31;
+ result.M32 = -value.M32;
+ result.M33 = -value.M33;
+ result.M34 = -value.M34;
+ result.M41 = -value.M41;
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Matrix3x2.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents a 3x2 matrix.
+ /// </summary>
+ public struct Matrix3x2
+ {
+ /// <summary>
+ /// Value at row 1 column 1 of the matrix.
+ /// </summary>
+ public float M11;
+
+ /// <summary>
+ /// Value at row 1 column 2 of the matrix.
+ /// </summary>
+ public float M12;
+
+ /// <summary>
+ /// Value at row 2 column 1 of the matrix.
+ /// </summary>
+ public float M21;
+
+ /// <summary>
+ /// Value at row 2 column 2 of the matrix.
+ /// </summary>
+ public float M22;
+
+ /// <summary>
+ /// Value at row 3 column 1 of the matrix.
+ /// </summary>
+ public float M31;
+
+ /// <summary>
+ /// Value at row 3 column 2 of the matrix.
+ /// </summary>
+ public float M32;
+
+ /// <summary>
+ /// Gets the identity matrix.
+ /// </summary>
+ public static Matrix3x2 Identity
+ {
+ get
+ {
+ var result = new Matrix3x2();
+ result.M11 = 1.0f;
+ result.M22 = 1.0f;
+
+ return result;
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Plane.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,649 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents a plane in three dimensional space.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct Plane : IEquatable<Plane>, IFormattable
+ {
+ /// <summary>
+ /// The normal vector of the plane.
+ /// </summary>
+ public Vector3 Normal;
+
+ /// <summary>
+ /// The distance of the plane along its normal from the origin.
+ /// </summary>
+ public float D;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SlimMath.Plane"/>
struct.
+ /// </summary>
+ /// <param name="value">The value that will be assigned to all
components.</param>
+ public Plane(float value)
+ {
+ Normal.X = Normal.Y = Normal.Z = D = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SlimMath.Plane"/>
struct.
+ /// </summary>
+ /// <param name="a">The X component of the normal.</param>
+ /// <param name="b">The Y component of the normal.</param>
+ /// <param name="c">The Z component of the normal.</param>
+ /// <param name="d">The distance of the plane along its normal
from the origin.</param>
+ public Plane(float a, float b, float c, float d)
+ {
+ Normal.X = a;
+ Normal.Y = b;
+ Normal.Z = c;
+ D = d;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SlimMath.Plane"/>
struct.
+ /// </summary>
+ /// <param name="value">The normal of the plane.</param>
+ /// <param name="d">The distance of the plane along its normal
from the origin</param>
+ public Plane(Vector3 value, float d)
+ {
+ Normal = value;
+ D = d;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SlimMath.Plane"/>
struct.
+ /// </summary>
+ /// <param name="point">Any point that lies along the
plane.</param>
+ /// <param name="normal">The normal of the plane.</param>
+ public Plane(Vector3 point, Vector3 normal)
+ {
+ Normal = normal;
+ D = -Vector3.Dot(normal, point);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SlimMath.Plane"/>
struct.
+ /// </summary>
+ /// <param name="point1">First point of a triangle defining the
plane.</param>
+ /// <param name="point2">Second point of a triangle defining the
plane.</param>
+ /// <param name="point3">Third point of a triangle defining the
plane.</param>
+ public Plane(Vector3 point1, Vector3 point2, Vector3 point3)
+ {
+ float x1 = point2.X - point1.X;
+ float y1 = point2.Y - point1.Y;
+ float z1 = point2.Z - point1.Z;
+ float x2 = point3.X - point1.X;
+ float y2 = point3.Y - point1.Y;
+ float z2 = point3.Z - point1.Z;
+ float yz = (y1 * z2) - (z1 * y2);
+ float xz = (z1 * x2) - (x1 * z2);
+ float xy = (x1 * y2) - (y1 * x2);
+ float invPyth = 1.0f / (float)(Math.Sqrt((yz * yz) + (xz * xz)
+ (xy * xy)));
+
+ Normal.X = yz * invPyth;
+ Normal.Y = xz * invPyth;
+ Normal.Z = xy * invPyth;
+ D = -((Normal.X * point1.X) + (Normal.Y * point1.Y) +
(Normal.Z * point1.Z));
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SlimMath.Plane"/>
struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the A, B, C, and
D components of the plane. This must be an array with four elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than four
elements.</exception>
+ public Plane(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 4)
+ throw new ArgumentOutOfRangeException("values", "There
must be four and only four input values for Plane.");
+
+ Normal.X = values[0];
+ Normal.Y = values[1];
+ Normal.Z = values[2];
+ D = values[3];
+ }
+
+ /// <summary>
+ /// Gets or sets the component at the specified index.
+ /// </summary>
+ /// <value>The value of the A, B, C, or D component, depending on
the index.</value>
+ /// <param name="index">The index of the component to access. Use
0 for the A component, 1 for the B component, 2 for the C component, and 3
for the D component.</param>
+ /// <returns>The value of the component at the specified
index.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="index"/> is out of the range [0, 3].</exception>
+ public float this[int index]
+ {
+ get
+ {
+ switch (index)
+ {
+ case 0: return Normal.X;
+ case 1: return Normal.Y;
+ case 2: return Normal.Z;
+ case 3: return D;
+ }
+
+ throw new ArgumentOutOfRangeException("index", "Indices
for Plane run from 0 to 3, inclusive.");
+ }
+
+ set
+ {
+ switch (index)
+ {
+ case 0: Normal.X = value; break;
+ case 1: Normal.Y = value; break;
+ case 2: Normal.Z = value; break;
+ case 3: D = value; break;
+ default: throw new
ArgumentOutOfRangeException("index", "Indices for Plane run from 0 to 3,
inclusive.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Changes the coefficients of the normal vector of the plane to
make it of unit length.
+ /// </summary>
+ public void Normalize()
+ {
+ float magnitude = 1.0f / (float)(Math.Sqrt((Normal.X *
Normal.X) + (Normal.Y * Normal.Y) + (Normal.Z * Normal.Z)));
+
+ Normal.X *= magnitude;
+ Normal.Y *= magnitude;
+ Normal.Z *= magnitude;
+ D *= magnitude;
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the plane.
+ /// </summary>
+ /// <returns>A four-element array containing the components of the
plane.</returns>
+ public float[] ToArray()
+ {
+ return new float[] { Normal.X, Normal.Y, Normal.Z, D };
+ }
+
+ /// <summary>
+ /// Scales each component of the plane by the given scaling factor.
+ /// </summary>
+ /// <param name="value">The plane to scale.</param>
+ /// <param name="scale">The amount by which to scale the
plane.</param>
+ /// <param name="result">When the method completes, contains the
scaled plane.</param>
+ public static void Multiply(ref Plane value, float scale, out
Plane result)
+ {
+ result.Normal.X = value.Normal.X * scale;
+ result.Normal.Y = value.Normal.Y * scale;
+ result.Normal.Z = value.Normal.Z * scale;
+ result.D = value.D * scale;
+ }
+
+ /// <summary>
+ /// Scales each component of the plane by the given scaling factor.
+ /// </summary>
+ /// <param name="value">The plane to scale.</param>
+ /// <param name="scale">The amount by which to scale the
plane.</param>
+ /// <returns>The scaled plane.</returns>
+ public static Plane Multiply(Plane value, float scale)
+ {
+ return new Plane(value.Normal.X * scale, value.Normal.Y *
scale, value.Normal.Z * scale, value.D * scale);
+ }
+
+ /// <summary>
+ /// Scales the distance component of the plane by the given
scaling factor.
+ /// </summary>
+ /// <param name="value">The plane to scale.</param>
+ /// <param name="scale">The amount by which to scale the
plane.</param>
+ /// <param name="result">When the method completes, contains the
scaled plane.</param>
+ public static void Scale(ref Plane value, float scale, out Plane
result)
+ {
+ result.Normal = value.Normal;
+ result.D = value.D * scale;
+ }
+
+ /// <summary>
+ /// Scales the distance component of the plane by the given
scaling factor.
+ /// </summary>
+ /// <param name="value">The plane to scale.</param>
+ /// <param name="scale">The amount by which to scale the
plane.</param>
+ /// <returns>The scaled plane.</returns>
+ public static Plane Scale(Plane value, float scale)
+ {
+ Plane result;
+ Scale(ref value, scale, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Calculates the dot product of the specified vector and plane.
+ /// </summary>
+ /// <param name="left">The source plane.</param>
+ /// <param name="right">The source vector.</param>
+ /// <param name="result">When the method completes, contains the
dot product of the specified plane and vector.</param>
+ public static void Dot(ref Plane left, ref Vector4 right, out
float result)
+ {
+ result = (left.Normal.X * right.X) + (left.Normal.Y * right.Y)
+ (left.Normal.Z * right.Z) + (left.D * right.W);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of the specified vector and plane.
+ /// </summary>
+ /// <param name="left">The source plane.</param>
+ /// <param name="right">The source vector.</param>
+ /// <returns>The dot product of the specified plane and
vector.</returns>
+ public static float Dot(Plane left, Vector4 right)
+ {
+ return (left.Normal.X * right.X) + (left.Normal.Y * right.Y) +
(left.Normal.Z * right.Z) + (left.D * right.W);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of a specified vector and the
normal of the plane plus the distance value of the plane.
+ /// </summary>
+ /// <param name="left">The source plane.</param>
+ /// <param name="right">The source vector.</param>
+ /// <param name="result">When the method completes, contains the
dot product of a specified vector and the normal of the Plane plus the
distance value of the plane.</param>
+ public static void DotCoordinate(ref Plane left, ref Vector3
right, out float result)
+ {
+ result = (left.Normal.X * right.X) + (left.Normal.Y * right.Y)
+ (left.Normal.Z * right.Z) + left.D;
+ }
+
+ /// <summary>
+ /// Calculates the dot product of a specified vector and the
normal of the plane plus the distance value of the plane.
+ /// </summary>
+ /// <param name="left">The source plane.</param>
+ /// <param name="right">The source vector.</param>
+ /// <returns>The dot product of a specified vector and the normal
of the Plane plus the distance value of the plane.</returns>
+ public static float DotCoordinate(Plane left, Vector3 right)
+ {
+ return (left.Normal.X * right.X) + (left.Normal.Y * right.Y) +
(left.Normal.Z * right.Z) + left.D;
+ }
+
+ /// <summary>
+ /// Calculates the dot product of the specified vector and the
normal of the plane.
+ /// </summary>
+ /// <param name="left">The source plane.</param>
+ /// <param name="right">The source vector.</param>
+ /// <param name="result">When the method completes, contains the
dot product of the specified vector and the normal of the plane.</param>
+ public static void DotNormal(ref Plane left, ref Vector3 right,
out float result)
+ {
+ result = (left.Normal.X * right.X) + (left.Normal.Y * right.Y)
+ (left.Normal.Z * right.Z);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of the specified vector and the
normal of the plane.
+ /// </summary>
+ /// <param name="left">The source plane.</param>
+ /// <param name="right">The source vector.</param>
+ /// <returns>The dot product of the specified vector and the
normal of the plane.</returns>
+ public static float DotNormal(Plane left, Vector3 right)
+ {
+ return (left.Normal.X * right.X) + (left.Normal.Y * right.Y) +
(left.Normal.Z * right.Z);
+ }
+
+ /// <summary>
+ /// Changes the coefficients of the normal vector of the plane to
make it of unit length.
+ /// </summary>
+ /// <param name="plane">The source plane.</param>
+ /// <param name="result">When the method completes, contains the
normalized plane.</param>
+ public static void Normalize(ref Plane plane, out Plane result)
+ {
+ float magnitude = 1.0f / (float)(Math.Sqrt((plane.Normal.X *
plane.Normal.X) + (plane.Normal.Y * plane.Normal.Y) + (plane.Normal.Z *
plane.Normal.Z)));
+
+ result.Normal.X = plane.Normal.X * magnitude;
+ result.Normal.Y = plane.Normal.Y * magnitude;
+ result.Normal.Z = plane.Normal.Z * magnitude;
+ result.D = plane.D * magnitude;
+ }
+
+ /// <summary>
+ /// Changes the coefficients of the normal vector of the plane to
make it of unit length.
+ /// </summary>
+ /// <param name="plane">The source plane.</param>
+ /// <returns>The normalized plane.</returns>
+ public static Plane Normalize(Plane plane)
+ {
+ float magnitude = 1.0f / (float)(Math.Sqrt((plane.Normal.X *
plane.Normal.X) + (plane.Normal.Y * plane.Normal.Y) + (plane.Normal.Z *
plane.Normal.Z)));
+ return new Plane(plane.Normal.X * magnitude, plane.Normal.Y *
magnitude, plane.Normal.Z * magnitude, plane.D * magnitude);
+ }
+
+ /// <summary>
+ /// Transforms a normalized plane by a quaternion rotation.
+ /// </summary>
+ /// <param name="plane">The normalized source plane.</param>
+ /// <param name="rotation">The quaternion rotation.</param>
+ /// <param name="result">When the method completes, contains the
transformed plane.</param>
+ public static void Transform(ref Plane plane, ref Quaternion
rotation, out Plane result)
+ {
+ float x2 = rotation.X + rotation.X;
+ float y2 = rotation.Y + rotation.Y;
+ float z2 = rotation.Z + rotation.Z;
+ float wx = rotation.W * x2;
+ float wy = rotation.W * y2;
+ float wz = rotation.W * z2;
+ float xx = rotation.X * x2;
+ float xy = rotation.X * y2;
+ float xz = rotation.X * z2;
+ float yy = rotation.Y * y2;
+ float yz = rotation.Y * z2;
+ float zz = rotation.Z * z2;
+
+ float x = plane.Normal.X;
+ float y = plane.Normal.Y;
+ float z = plane.Normal.Z;
+
+ /*
+ * Note:
+ * Factor common arithmetic out of loop.
+ */
+ result.Normal.X = ((x * ((1.0f - yy) - zz)) + (y * (xy - wz)))
+ (z * (xz + wy));
+ result.Normal.Y = ((x * (xy + wz)) + (y * ((1.0f - xx) - zz)))
+ (z * (yz - wx));
+ result.Normal.Z = ((x * (xz - wy)) + (y * (yz + wx))) + (z *
((1.0f - xx) - yy));
+ result.D = plane.D;
+ }
+
+ /// <summary>
+ /// Transforms a normalized plane by a quaternion rotation.
+ /// </summary>
+ /// <param name="plane">The normalized source plane.</param>
+ /// <param name="rotation">The quaternion rotation.</param>
+ /// <returns>The transformed plane.</returns>
+ public static Plane Transform(Plane plane, Quaternion rotation)
+ {
+ Plane result;
+ float x2 = rotation.X + rotation.X;
+ float y2 = rotation.Y + rotation.Y;
+ float z2 = rotation.Z + rotation.Z;
+ float wx = rotation.W * x2;
+ float wy = rotation.W * y2;
+ float wz = rotation.W * z2;
+ float xx = rotation.X * x2;
+ float xy = rotation.X * y2;
+ float xz = rotation.X * z2;
+ float yy = rotation.Y * y2;
+ float yz = rotation.Y * z2;
+ float zz = rotation.Z * z2;
+
+ float x = plane.Normal.X;
+ float y = plane.Normal.Y;
+ float z = plane.Normal.Z;
+
+ /*
+ * Note:
+ * Factor common arithmetic out of loop.
+ */
+ result.Normal.X = ((x * ((1.0f - yy) - zz)) + (y * (xy - wz)))
+ (z * (xz + wy));
+ result.Normal.Y = ((x * (xy + wz)) + (y * ((1.0f - xx) - zz)))
+ (z * (yz - wx));
+ result.Normal.Z = ((x * (xz - wy)) + (y * (yz + wx))) + (z *
((1.0f - xx) - yy));
+ result.D = plane.D;
+
+ return result;
+ }
+
+ /// <summary>
+ /// Transforms an array of normalized planes by a quaternion
rotation.
+ /// </summary>
+ /// <param name="planes">The array of normalized planes to
transform.</param>
+ /// <param name="rotation">The quaternion rotation.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="planes"/> is <c>null</c>.</exception>
+ public static void Transform(Plane[] planes, ref Quaternion
rotation)
+ {
+ if (planes == null)
+ throw new ArgumentNullException("planes");
+
+ float x2 = rotation.X + rotation.X;
+ float y2 = rotation.Y + rotation.Y;
+ float z2 = rotation.Z + rotation.Z;
+ float wx = rotation.W * x2;
+ float wy = rotation.W * y2;
+ float wz = rotation.W * z2;
+ float xx = rotation.X * x2;
+ float xy = rotation.X * y2;
+ float xz = rotation.X * z2;
+ float yy = rotation.Y * y2;
+ float yz = rotation.Y * z2;
+ float zz = rotation.Z * z2;
+
+ for (int i = 0; i < planes.Length; ++i)
+ {
+ float x = planes[i].Normal.X;
+ float y = planes[i].Normal.Y;
+ float z = planes[i].Normal.Z;
+
+ /*
+ * Note:
+ * Factor common arithmetic out of loop.
+ */
+ planes[i].Normal.X = ((x * ((1.0f - yy) - zz)) + (y * (xy
- wz))) + (z * (xz + wy));
+ planes[i].Normal.Y = ((x * (xy + wz)) + (y * ((1.0f - xx)
- zz))) + (z * (yz - wx));
+ planes[i].Normal.Z = ((x * (xz - wy)) + (y * (yz + wx))) +
(z * ((1.0f - xx) - yy));
+ }
+ }
+
+ /// <summary>
+ /// Transforms a normalized plane by a matrix.
+ /// </summary>
+ /// <param name="plane">The normalized source plane.</param>
+ /// <param name="transformation">The transformation matrix.</param>
+ /// <param name="result">When the method completes, contains the
transformed plane.</param>
+ public static void Transform(ref Plane plane, ref Matrix
transformation, out Plane result)
+ {
+ float x = plane.Normal.X;
+ float y = plane.Normal.Y;
+ float z = plane.Normal.Z;
+ float d = plane.D;
+
+ Matrix inverse;
+ Matrix.Invert(ref transformation, out inverse);
+
+ result.Normal.X = (((x * inverse.M11) + (y * inverse.M12)) +
(z * inverse.M13)) + (d * inverse.M14);
+ result.Normal.Y = (((x * inverse.M21) + (y * inverse.M22)) +
(z * inverse.M23)) + (d * inverse.M24);
+ result.Normal.Z = (((x * inverse.M31) + (y * inverse.M32)) +
(z * inverse.M33)) + (d * inverse.M34);
+ result.D = (((x * inverse.M41) + (y * inverse.M42)) + (z *
inverse.M43)) + (d * inverse.M44);
+ }
+
+ /// <summary>
+ /// Transforms a normalized plane by a matrix.
+ /// </summary>
+ /// <param name="plane">The normalized source plane.</param>
+ /// <param name="transformation">The transformation matrix.</param>
+ /// <returns>When the method completes, contains the transformed
plane.</returns>
+ public static Plane Transform(Plane plane, Matrix transformation)
+ {
+ Plane result;
+ float x = plane.Normal.X;
+ float y = plane.Normal.Y;
+ float z = plane.Normal.Z;
+ float d = plane.D;
+
+ transformation.Invert();
+ result.Normal.X = (((x * transformation.M11) + (y *
transformation.M12)) + (z * transformation.M13)) + (d * transformation.M14);
+ result.Normal.Y = (((x * transformation.M21) + (y *
transformation.M22)) + (z * transformation.M23)) + (d * transformation.M24);
+ result.Normal.Z = (((x * transformation.M31) + (y *
transformation.M32)) + (z * transformation.M33)) + (d * transformation.M34);
+ result.D = (((x * transformation.M41) + (y *
transformation.M42)) + (z * transformation.M43)) + (d * transformation.M44);
+
+ return result;
+ }
+
+ /// <summary>
+ /// Transforms an array of normalized planes by a matrix.
+ /// </summary>
+ /// <param name="planes">The array of normalized planes to
transform.</param>
+ /// <param name="transformation">The transformation matrix.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="planes"/> is <c>null</c>.</exception>
+ public static void Transform(Plane[] planes, ref Matrix
transformation)
+ {
+ if (planes == null)
+ throw new ArgumentNullException("planes");
+
+ Matrix inverse;
+ Matrix.Invert(ref transformation, out inverse);
+
+ for (int i = 0; i < planes.Length; ++i)
+ {
+ Transform(ref planes[i], ref transformation, out
planes[i]);
+ }
+ }
+
+ /// <summary>
+ /// Scales each component of the plane by the given value.
+ /// </summary>
+ /// <param name="scale">The amount by which to scale the
plane.</param>
+ /// <param name="plane">The plane to scale.</param>
+ /// <returns>The scaled plane.</returns>
+ public static Plane operator *(float scale, Plane plane)
+ {
+ return new Plane(plane.Normal.X * scale, plane.Normal.Y *
scale, plane.Normal.Z * scale, plane.D * scale);
+ }
+
+ /// <summary>
+ /// Scales each component of the plane by the given value.
+ /// </summary>
+ /// <param name="plane">The plane to scale.</param>
+ /// <param name="scale">The amount by which to scale the
plane.</param>
+ /// <returns>The scaled plane.</returns>
+ public static Plane operator *(Plane plane, float scale)
+ {
+ return new Plane(plane.Normal.X * scale, plane.Normal.Y *
scale, plane.Normal.Z * scale, plane.D * scale);
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has the same
value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(Plane left, Plane right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has a
different value than <paramref name="right"/>; otherwise,
<c>false</c>.</returns>
+ public static bool operator !=(Plane left, Plane right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.CurrentCulture, "A:{0} B:{1}
C:{2} D:{3}", Normal.X, Normal.Y, Normal.Z, D);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format)
+ {
+ return string.Format(CultureInfo.CurrentCulture, "A:{0} B:{1}
C:{2} D:{3}", Normal.X.ToString(format, CultureInfo.CurrentCulture),
+ Normal.Y.ToString(format, CultureInfo.CurrentCulture),
Normal.Z.ToString(format, CultureInfo.CurrentCulture), D.ToString(format,
CultureInfo.CurrentCulture));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(IFormatProvider formatProvider)
+ {
+ return string.Format(formatProvider, "A:{0} B:{1} C:{2}
D:{3}", Normal.X, Normal.Y, Normal.Z, D);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String"/> that represents this
instance.
+ /// </summary>
+ /// <param name="format">The format.</param>
+ /// <param name="formatProvider">The format provider.</param>
+ /// <returns>
+ /// A <see cref="System.String"/> that represents this instance.
+ /// </returns>
+ public string ToString(string format, IFormatProvider
formatProvider)
+ {
+ return string.Format(formatProvider, "A:{0} B:{1} C:{2}
D:{3}", Normal.X.ToString(format, formatProvider),
+ Normal.Y.ToString(format, formatProvider),
Normal.Z.ToString(format, formatProvider), D.ToString(format,
formatProvider));
+ }
+
+ /// <summary>
+ /// Returns a hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A hash code for this instance, suitable for use in hashing
algorithms and data structures like a hash table.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Normal.GetHashCode() + D.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see
cref="SlimMath.Vector4"/> is equal to this instance.
+ /// </summary>
+ /// <param name="value">The <see cref="SlimMath.Vector4"/> to
compare with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="SlimMath.Vector4"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(Plane value)
+ {
+ return Normal == value.Normal && D == value.D;
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="System.Object"/>
is equal to this instance.
+ /// </summary>
+ /// <param name="obj">The <see cref="System.Object"/> to compare
with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="System.Object"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((Plane)obj);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Properties/AssemblyInfo.cs Sun May 18
20:39:07 2014 UTC
@@ -0,0 +1,40 @@
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Resources;
+
+// General Information about an assembly is controlled through the
following
+// set of attributes. Change these attribute values to modify the
information
+// associated with an assembly.
+[assembly: AssemblyTitle("SlimMath")]
+[assembly: AssemblyDescription("Vector math library for managed
applications.")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("SlimDX Group")]
+[assembly: AssemblyProduct("SlimMath")]
+[assembly: AssemblyCopyright("Copyright © 2007-2014 SlimDX Group")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+[assembly: CLSCompliant(true)]
+
+// The following GUID is for the ID of the typelib if this project is
exposed to COM
+[assembly: Guid("5192274f-78d1-4f94-b3f8-3f65b3449d4a")]
+
+// Version information for an assembly consists of the following four
values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and
Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: NeutralResourcesLanguageAttribute("en-US")]
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Quaternion.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,1263 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+using System.Globalization;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents a four dimensional mathematical quaternion.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ [TypeConverter(typeof(SlimMath.Design.QuaternionConverter))]
+ public struct Quaternion : IEquatable<Quaternion>, IFormattable
+ {
+ /// <summary>
+ /// The size of the <see cref="SlimMath.Quaternion"/> type, in
bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(Quaternion));
+
+ /// <summary>
+ /// A <see cref="SlimMath.Quaternion"/> with all of its components
set to zero.
+ /// </summary>
+ public static readonly Quaternion Zero = new Quaternion();
+
+ /// <summary>
+ /// A <see cref="SlimMath.Quaternion"/> with all of its components
set to one.
+ /// </summary>
+ public static readonly Quaternion One = new Quaternion(1.0f, 1.0f,
1.0f, 1.0f);
+
+ /// <summary>
+ /// The identity <see cref="SlimMath.Quaternion"/> (0, 0, 0, 1).
+ /// </summary>
+ public static readonly Quaternion Identity = new Quaternion(0.0f,
0.0f, 0.0f, 1.0f);
+
+ /// <summary>
+ /// The X component of the quaternion.
+ /// </summary>
+ public float X;
+
+ /// <summary>
+ /// The Y component of the quaternion.
+ /// </summary>
+ public float Y;
+
+ /// <summary>
+ /// The Z component of the quaternion.
+ /// </summary>
+ public float Z;
+
+ /// <summary>
+ /// The W component of the quaternion.
+ /// </summary>
+ public float W;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Quaternion"/> struct.
+ /// </summary>
+ /// <param name="value">The value that will be assigned to all
components.</param>
+ public Quaternion(float value)
+ {
+ X = value;
+ Y = value;
+ Z = value;
+ W = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Quaternion"/> struct.
+ /// </summary>
+ /// <param name="value">A vector containing the values with which
to initialize the components.</param>
+ public Quaternion(Vector4 value)
+ {
+ X = value.X;
+ Y = value.Y;
+ Z = value.Z;
+ W = value.W;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Quaternion"/> struct.
+ /// </summary>
+ /// <param name="value">A vector containing the values with which
to initialize the X, Y, and Z components.</param>
+ /// <param name="w">Initial value for the W component of the
quaternion.</param>
+ public Quaternion(Vector3 value, float w)
+ {
+ X = value.X;
+ Y = value.Y;
+ Z = value.Z;
+ W = w;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Quaternion"/> struct.
+ /// </summary>
+ /// <param name="value">A vector containing the values with which
to initialize the X and Y components.</param>
+ /// <param name="z">Initial value for the Z component of the
quaternion.</param>
+ /// <param name="w">Initial value for the W component of the
quaternion.</param>
+ public Quaternion(Vector2 value, float z, float w)
+ {
+ X = value.X;
+ Y = value.Y;
+ Z = z;
+ W = w;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Quaternion"/> struct.
+ /// </summary>
+ /// <param name="x">Initial value for the X component of the
quaternion.</param>
+ /// <param name="y">Initial value for the Y component of the
quaternion.</param>
+ /// <param name="z">Initial value for the Z component of the
quaternion.</param>
+ /// <param name="w">Initial value for the W component of the
quaternion.</param>
+ public Quaternion(float x, float y, float z, float w)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ W = w;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Quaternion"/> struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the X, Y, Z, and
W components of the quaternion. This must be an array with four
elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than four
elements.</exception>
+ public Quaternion(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 4)
+ throw new ArgumentOutOfRangeException("values", "There
must be four and only four input values for Quaternion.");
+
+ X = values[0];
+ Y = values[1];
+ Z = values[2];
+ W = values[3];
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this instance is equivalent to
the identity quaternion.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this instance is an identity quaternion;
otherwise, <c>false</c>.
+ /// </value>
+ public bool IsIdentity
+ {
+ get { return this.Equals(Identity); }
+ }
+
+ /// <summary>
+ /// Gets a value indicting whether this instance is normalized.
+ /// </summary>
+ public bool IsNormalized
+ {
+ get { return Math.Abs((X * X) + (Y * Y) + (Z * Z) + (W * W) -
1f) < Utilities.ZeroTolerance; }
+ }
+
+ /// <summary>
+ /// Gets the angle of the quaternion.
+ /// </summary>
+ /// <value>The quaternion's angle.</value>
+ public float Angle
+ {
+ get
+ {
+ float length = (X * X) + (Y * Y) + (Z * Z);
+ if (length < Utilities.ZeroTolerance)
+ return 0.0f;
+
+ return (float)(2.0 * Math.Acos(W));
+ }
+ }
+
+ /// <summary>
+ /// Gets the axis components of the quaternion.
+ /// </summary>
+ /// <value>The axis components of the quaternion.</value>
+ public Vector3 Axis
+ {
+ get
+ {
+ float length = (X * X) + (Y * Y) + (Z * Z);
+ if (length < Utilities.ZeroTolerance)
+ return Vector3.UnitX;
+
+ float inv = 1.0f / length;
+ return new Vector3(X * inv, Y * inv, Z * inv);
+ }
+ }
+
+ /// <summary>
+ /// Calculates the length of the quaternion.
+ /// </summary>
+ /// <remarks>
+ /// <see cref="SlimMath.Quaternion.LengthSquared"/> may be
preferred when only the relative length is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public float Length
+ {
+ get { return (float)Math.Sqrt((X * X) + (Y * Y) + (Z * Z) + (W
* W)); }
+ }
+
+ /// <summary>
+ /// Calculates the squared length of the quaternion.
+ /// </summary>
+ /// <remarks>
+ /// This property may be preferred to <see
cref="SlimMath.Quaternion.Length"/> when only a relative length is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public float LengthSquared
+ {
+ get { return (X * X) + (Y * Y) + (Z * Z) + (W * W); }
+ }
+
+ /// <summary>
+ /// Gets or sets the component at the specified index.
+ /// </summary>
+ /// <value>The value of the X, Y, Z, or W component, depending on
the index.</value>
+ /// <param name="index">The index of the component to access. Use
0 for the X component, 1 for the Y component, 2 for the Z component, and 3
for the W component.</param>
+ /// <returns>The value of the component at the specified
index.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="index"/> is out of the range [0, 3].</exception>
+ public float this[int index]
+ {
+ get
+ {
+ switch (index)
+ {
+ case 0: return X;
+ case 1: return Y;
+ case 2: return Z;
+ case 3: return W;
+ }
+
+ throw new ArgumentOutOfRangeException("index", "Indices
for Quaternion run from 0 to 3, inclusive.");
+ }
+
+ set
+ {
+ switch (index)
+ {
+ case 0: X = value; break;
+ case 1: Y = value; break;
+ case 2: Z = value; break;
+ case 3: W = value; break;
+ default: throw new
ArgumentOutOfRangeException("index", "Indices for Quaternion run from 0 to
3, inclusive.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Conjugates the quaternion.
+ /// </summary>
+ public void Conjugate()
+ {
+ X = -X;
+ Y = -Y;
+ Z = -Z;
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given quaternion.
+ /// </summary>
+ public void Negate()
+ {
+ this.X = -X;
+ this.Y = -Y;
+ this.Z = -Z;
+ this.W = -W;
+ }
+
+ /// <summary>
+ /// Conjugates and renormalizes the quaternion.
+ /// </summary>
+ public void Invert()
+ {
+ float lengthSq = LengthSquared;
+ if (lengthSq > Utilities.ZeroTolerance)
+ {
+ lengthSq = 1.0f / lengthSq;
+
+ X = -X * lengthSq;
+ Y = -Y * lengthSq;
+ Z = -Z * lengthSq;
+ W = W * lengthSq;
+ }
+ }
+
+ /// <summary>
+ /// Converts the quaternion into a unit quaternion.
+ /// </summary>
+ public void Normalize()
+ {
+ float length = Length;
+ if (length > Utilities.ZeroTolerance)
+ {
+ float inverse = 1.0f / length;
+ X *= inverse;
+ Y *= inverse;
+ Z *= inverse;
+ W *= inverse;
+ }
+ }
+
+ /// <summary>
+ /// Exponentiates a quaternion.
+ /// </summary>
+ public void Exponential()
+ {
+ Exponential(ref this, out this);
+ }
+
+ /// <summary>
+ /// Calculates the natural logarithm of the specified quaternion.
+ /// </summary>
+ public void Logarithm()
+ {
+ Logarithm(ref this, out this);
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the quaternion.
+ /// </summary>
+ /// <returns>A four-element array containing the components of the
quaternion.</returns>
+ public float[] ToArray()
+ {
+ return new float[] { X, Y, Z, W };
+ }
+
+ /// <summary>
+ /// Adds two quaternions.
+ /// </summary>
+ /// <param name="left">The first quaternion to add.</param>
+ /// <param name="right">The second quaternion to add.</param>
+ /// <param name="result">When the method completes, contains the
sum of the two quaternions.</param>
+ public static void Add(ref Quaternion left, ref Quaternion right,
out Quaternion result)
+ {
+ result.X = left.X + right.X;
+ result.Y = left.Y + right.Y;
+ result.Z = left.Z + right.Z;
+ result.W = left.W + right.W;
+ }
+
+ /// <summary>
+ /// Adds two quaternions.
+ /// </summary>
+ /// <param name="left">The first quaternion to add.</param>
+ /// <param name="right">The second quaternion to add.</param>
+ /// <returns>The sum of the two quaternions.</returns>
+ public static Quaternion Add(Quaternion left, Quaternion right)
+ {
+ Quaternion result;
+ Add(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Subtracts two quaternions.
+ /// </summary>
+ /// <param name="left">The first quaternion to subtract.</param>
+ /// <param name="right">The second quaternion to subtract.</param>
+ /// <param name="result">When the method completes, contains the
difference of the two quaternions.</param>
+ public static void Subtract(ref Quaternion left, ref Quaternion
right, out Quaternion result)
+ {
+ result.X = left.X - right.X;
+ result.Y = left.Y - right.Y;
+ result.Z = left.Z - right.Z;
+ result.W = left.W - right.W;
+ }
+
+ /// <summary>
+ /// Subtracts two quaternions.
+ /// </summary>
+ /// <param name="left">The first quaternion to subtract.</param>
+ /// <param name="right">The second quaternion to subtract.</param>
+ /// <returns>The difference of the two quaternions.</returns>
+ public static Quaternion Subtract(Quaternion left, Quaternion
right)
+ {
+ Quaternion result;
+ Subtract(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Scales a quaternion by the given value.
+ /// </summary>
+ /// <param name="value">The quaternion to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
quaternion.</param>
+ /// <param name="result">When the method completes, contains the
scaled quaternion.</param>
+ public static void Multiply(ref Quaternion value, float scalar,
out Quaternion result)
+ {
+ result.X = value.X * scalar;
+ result.Y = value.Y * scalar;
+ result.Z = value.Z * scalar;
+ result.W = value.W * scalar;
+ }
+
+ /// <summary>
+ /// Scales a quaternion by the given value.
+ /// </summary>
+ /// <param name="value">The quaternion to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
quaternion.</param>
+ /// <returns>The scaled quaternion.</returns>
+ public static Quaternion Multiply(Quaternion value, float scalar)
+ {
+ Quaternion result;
+ Multiply(ref value, scalar, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Modulates a quaternion by another.
+ /// </summary>
+ /// <param name="left">The first quaternion to modulate.</param>
+ /// <param name="right">The second quaternion to modulate.</param>
+ /// <param name="result">When the moethod completes, contains the
modulated quaternion.</param>
+ public static void Multiply(ref Quaternion left, ref Quaternion
right, out Quaternion result)
+ {
+ float lx = left.X;
+ float ly = left.Y;
+ float lz = left.Z;
+ float lw = left.W;
+ float rx = right.X;
+ float ry = right.Y;
+ float rz = right.Z;
+ float rw = right.W;
+
+ result.X = (rx * lw + lx * rw + ry * lz) - (rz * ly);
+ result.Y = (ry * lw + ly * rw + rz * lx) - (rx * lz);
+ result.Z = (rz * lw + lz * rw + rx * ly) - (ry * lx);
+ result.W = (rw * lw) - (rx * lx + ry * ly + rz * lz);
+ }
+
+ /// <summary>
+ /// Modulates a quaternion by another.
+ /// </summary>
+ /// <param name="left">The first quaternion to modulate.</param>
+ /// <param name="right">The second quaternion to modulate.</param>
+ /// <returns>The modulated quaternion.</returns>
+ public static Quaternion Multiply(Quaternion left, Quaternion
right)
+ {
+ Quaternion result;
+ Multiply(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <param name="result">When the method completes, contains the
scaled vector.</param>
+ public static void Divide(ref Quaternion value, float scalar, out
Quaternion result)
+ {
+ result = new Quaternion(value.X / scalar, value.Y / scalar,
value.Z / scalar, value.W / scalar);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <returns>The scaled vector.</returns>
+ public static Quaternion Divide(Quaternion value, float scalar)
+ {
+ return new Quaternion(value.X / scalar, value.Y / scalar,
value.Z / scalar, value.W / scalar);
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to negate.</param>
+ /// <param name="result">When the method completes, contains a
quaternion facing in the opposite direction.</param>
+ public static void Negate(ref Quaternion value, out Quaternion
result)
+ {
+ result.X = -value.X;
+ result.Y = -value.Y;
+ result.Z = -value.Z;
+ result.W = -value.W;
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to negate.</param>
+ /// <returns>A quaternion facing in the opposite
direction.</returns>
+ public static Quaternion Negate(Quaternion value)
+ {
+ Quaternion result;
+ Negate(ref value, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Returns a <see cref="SlimMath.Quaternion"/> containing the 4D
Cartesian coordinates of a point specified in Barycentric coordinates
relative to a 2D triangle.
+ /// </summary>
+ /// <param name="value1">A <see cref="SlimMath.Quaternion"/>
containing the 4D Cartesian coordinates of vertex 1 of the triangle.</param>
+ /// <param name="value2">A <see cref="SlimMath.Quaternion"/>
containing the 4D Cartesian coordinates of vertex 2 of the triangle.</param>
+ /// <param name="value3">A <see cref="SlimMath.Quaternion"/>
containing the 4D Cartesian coordinates of vertex 3 of the triangle.</param>
+ /// <param name="amount1">Barycentric coordinate b2, which
expresses the weighting factor toward vertex 2 (specified in <paramref
name="value2"/>).</param>
+ /// <param name="amount2">Barycentric coordinate b3, which
expresses the weighting factor toward vertex 3 (specified in <paramref
name="value3"/>).</param>
+ /// <param name="result">When the method completes, contains a new
<see cref="SlimMath.Quaternion"/> containing the 4D Cartesian coordinates
of the specified point.</param>
+ public static void Barycentric(ref Quaternion value1, ref
Quaternion value2, ref Quaternion value3, float amount1, float amount2, out
Quaternion result)
+ {
+ Quaternion start, end;
+ Slerp(ref value1, ref value2, amount1 + amount2, out start);
+ Slerp(ref value1, ref value3, amount1 + amount2, out end);
+ Slerp(ref start, ref end, amount2 / (amount1 + amount2), out
result);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="SlimMath.Quaternion"/> containing the 4D
Cartesian coordinates of a point specified in Barycentric coordinates
relative to a 2D triangle.
+ /// </summary>
+ /// <param name="value1">A <see cref="SlimMath.Quaternion"/>
containing the 4D Cartesian coordinates of vertex 1 of the triangle.</param>
+ /// <param name="value2">A <see cref="SlimMath.Quaternion"/>
containing the 4D Cartesian coordinates of vertex 2 of the triangle.</param>
+ /// <param name="value3">A <see cref="SlimMath.Quaternion"/>
containing the 4D Cartesian coordinates of vertex 3 of the triangle.</param>
+ /// <param name="amount1">Barycentric coordinate b2, which
expresses the weighting factor toward vertex 2 (specified in <paramref
name="value2"/>).</param>
+ /// <param name="amount2">Barycentric coordinate b3, which
expresses the weighting factor toward vertex 3 (specified in <paramref
name="value3"/>).</param>
+ /// <returns>A new <see cref="SlimMath.Quaternion"/> containing
the 4D Cartesian coordinates of the specified point.</returns>
+ public static Quaternion Barycentric(Quaternion value1, Quaternion
value2, Quaternion value3, float amount1, float amount2)
+ {
+ Quaternion result;
+ Barycentric(ref value1, ref value2, ref value3, amount1,
amount2, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Conjugates a quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to conjugate.</param>
+ /// <param name="result">When the method completes, contains the
conjugated quaternion.</param>
+ public static void Conjugate(ref Quaternion value, out Quaternion
result)
+ {
+ result.X = -value.X;
+ result.Y = -value.Y;
+ result.Z = -value.Z;
+ result.W = value.W;
+ }
+
+ /// <summary>
+ /// Conjugates a quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to conjugate.</param>
+ /// <returns>The conjugated quaternion.</returns>
+ public static Quaternion Conjugate(Quaternion value)
+ {
+ Quaternion result;
+ Conjugate(ref value, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Calculates the dot product of two quaternions.
+ /// </summary>
+ /// <param name="left">First source quaternion.</param>
+ /// <param name="right">Second source quaternion.</param>
+ /// <param name="result">When the method completes, contains the
dot product of the two quaternions.</param>
+ public static void Dot(ref Quaternion left, ref Quaternion right,
out float result)
+ {
+ result = (left.X * right.X) + (left.Y * right.Y) + (left.Z *
right.Z) + (left.W * right.W);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of two quaternions.
+ /// </summary>
+ /// <param name="left">First source quaternion.</param>
+ /// <param name="right">Second source quaternion.</param>
+ /// <returns>The dot product of the two quaternions.</returns>
+ public static float Dot(Quaternion left, Quaternion right)
+ {
+ return (left.X * right.X) + (left.Y * right.Y) + (left.Z *
right.Z) + (left.W * right.W);
+ }
+
+ /// <summary>
+ /// Exponentiates a quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to exponentiate.</param>
+ /// <param name="result">When the method completes, contains the
exponentiated quaternion.</param>
+ public static void Exponential(ref Quaternion value, out
Quaternion result)
+ {
+ float angle = (float)Math.Sqrt((value.X * value.X) + (value.Y
* value.Y) + (value.Z * value.Z));
+ float sin = (float)Math.Sin(angle);
+
+ if (Math.Abs(sin) >= Utilities.ZeroTolerance)
+ {
+ float coeff = sin / angle;
+ result.X = coeff * value.X;
+ result.Y = coeff * value.Y;
+ result.Z = coeff * value.Z;
+ }
+ else
+ {
+ result = value;
+ }
+
+ result.W = (float)Math.Cos(angle);
+ }
+
+ /// <summary>
+ /// Exponentiates a quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to exponentiate.</param>
+ /// <returns>The exponentiated quaternion.</returns>
+ public static Quaternion Exponential(Quaternion value)
+ {
+ Quaternion result;
+ Exponential(ref value, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Conjugates and renormalizes the quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to conjugate and
renormalize.</param>
+ /// <param name="result">When the method completes, contains the
conjugated and renormalized quaternion.</param>
+ public static void Invert(ref Quaternion value, out Quaternion
result)
+ {
+ result = value;
+ result.Invert();
+ }
+
+ /// <summary>
+ /// Conjugates and renormalizes the quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to conjugate and
renormalize.</param>
+ /// <returns>The conjugated and renormalized quaternion.</returns>
+ public static Quaternion Invert(Quaternion value)
+ {
+ Quaternion result;
+ Invert(ref value, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two quaternions.
+ /// </summary>
+ /// <param name="start">Start quaternion.</param>
+ /// <param name="end">End quaternion.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
linear interpolation of the two quaternions.</param>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static void Lerp(ref Quaternion start, ref Quaternion end,
float amount, out Quaternion result)
+ {
+ float inverse = 1.0f - amount;
+
+ if (Dot(start, end) >= 0.0f)
+ {
+ result.X = (inverse * start.X) + (amount * end.X);
+ result.Y = (inverse * start.Y) + (amount * end.Y);
+ result.Z = (inverse * start.Z) + (amount * end.Z);
+ result.W = (inverse * start.W) + (amount * end.W);
+ }
+ else
+ {
+ result.X = (inverse * start.X) - (amount * end.X);
+ result.Y = (inverse * start.Y) - (amount * end.Y);
+ result.Z = (inverse * start.Z) - (amount * end.Z);
+ result.W = (inverse * start.W) - (amount * end.W);
+ }
+
+ result.Normalize();
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two quaternion.
+ /// </summary>
+ /// <param name="start">Start quaternion.</param>
+ /// <param name="end">End quaternion.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The linear interpolation of the two
quaternions.</returns>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static Quaternion Lerp(Quaternion start, Quaternion end,
float amount)
+ {
+ Quaternion result;
+ Lerp(ref start, ref end, amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Calculates the natural logarithm of the specified quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion whose logarithm will be
calculated.</param>
+ /// <param name="result">When the method completes, contains the
natural logarithm of the quaternion.</param>
+ public static void Logarithm(ref Quaternion value, out Quaternion
result)
+ {
+ if (Math.Abs(value.W) < 1.0f)
+ {
+ float angle = (float)Math.Acos(value.W);
+ float sin = (float)Math.Sin(angle);
+
+ if (Math.Abs(sin) >= Utilities.ZeroTolerance)
+ {
+ float coeff = angle / sin;
+ result.X = value.X * coeff;
+ result.Y = value.Y * coeff;
+ result.Z = value.Z * coeff;
+ }
+ else
+ {
+ result = value;
+ }
+ }
+ else
+ {
+ result = value;
+ }
+
+ result.W = 0.0f;
+ }
+
+ /// <summary>
+ /// Calculates the natural logarithm of the specified quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion whose logarithm will be
calculated.</param>
+ /// <returns>The natural logarithm of the quaternion.</returns>
+ public static Quaternion Logarithm(Quaternion value)
+ {
+ Quaternion result;
+ Logarithm(ref value, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Converts the quaternion into a unit quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to normalize.</param>
+ /// <param name="result">When the method completes, contains the
normalized quaternion.</param>
+ public static void Normalize(ref Quaternion value, out Quaternion
result)
+ {
+ Quaternion temp = value;
+ result = temp;
+ result.Normalize();
+ }
+
+ /// <summary>
+ /// Converts the quaternion into a unit quaternion.
+ /// </summary>
+ /// <param name="value">The quaternion to normalize.</param>
+ /// <returns>The normalized quaternion.</returns>
+ public static Quaternion Normalize(Quaternion value)
+ {
+ value.Normalize();
+ return value;
+ }
+
+ /// <summary>
+ /// Creates a quaternion given a rotation and an axis.
+ /// </summary>
+ /// <param name="axis">The axis of rotation.</param>
+ /// <param name="angle">The angle of rotation.</param>
+ /// <param name="result">When the method completes, contains the
newly created quaternion.</param>
+ public static void RotationAxis(ref Vector3 axis, float angle, out
Quaternion result)
+ {
+ Vector3 normalized;
+ Vector3.Normalize(ref axis, out normalized);
+
+ float half = angle * 0.5f;
+ float sin = (float)Math.Sin(half);
+ float cos = (float)Math.Cos(half);
+
+ result.X = normalized.X * sin;
+ result.Y = normalized.Y * sin;
+ result.Z = normalized.Z * sin;
+ result.W = cos;
+ }
+
+ /// <summary>
+ /// Creates a quaternion given a rotation and an axis.
+ /// </summary>
+ /// <param name="axis">The axis of rotation.</param>
+ /// <param name="angle">The angle of rotation.</param>
+ /// <returns>The newly created quaternion.</returns>
+ public static Quaternion RotationAxis(Vector3 axis, float angle)
+ {
+ Quaternion result;
+ RotationAxis(ref axis, angle, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Creates a quaternion given a rotation matrix.
+ /// </summary>
+ /// <param name="matrix">The rotation matrix.</param>
+ /// <param name="result">When the method completes, contains the
newly created quaternion.</param>
+ public static void RotationMatrix(ref Matrix matrix, out
Quaternion result)
+ {
+ float sqrt;
+ float half;
+ float scale = matrix.M11 + matrix.M22 + matrix.M33;
+
+ if (scale > 0.0f)
+ {
+ sqrt = (float)Math.Sqrt(scale + 1.0f);
+ result.W = sqrt * 0.5f;
+ sqrt = 0.5f / sqrt;
+
+ result.X = (matrix.M23 - matrix.M32) * sqrt;
+ result.Y = (matrix.M31 - matrix.M13) * sqrt;
+ result.Z = (matrix.M12 - matrix.M21) * sqrt;
+ }
+ else if ((matrix.M11 >= matrix.M22) && (matrix.M11 >=
matrix.M33))
+ {
+ sqrt = (float)Math.Sqrt(1.0f + matrix.M11 - matrix.M22 -
matrix.M33);
+ half = 0.5f / sqrt;
+
+ result.X = 0.5f * sqrt;
+ result.Y = (matrix.M12 + matrix.M21) * half;
+ result.Z = (matrix.M13 + matrix.M31) * half;
+ result.W = (matrix.M23 - matrix.M32) * half;
+ }
+ else if (matrix.M22 > matrix.M33)
+ {
+ sqrt = (float)Math.Sqrt(1.0f + matrix.M22 - matrix.M11 -
matrix.M33);
+ half = 0.5f / sqrt;
+
+ result.X = (matrix.M21 + matrix.M12) * half;
+ result.Y = 0.5f * sqrt;
+ result.Z = (matrix.M32 + matrix.M23) * half;
+ result.W = (matrix.M31 - matrix.M13) * half;
+ }
+ else
+ {
+ sqrt = (float)Math.Sqrt(1.0f + matrix.M33 - matrix.M11 -
matrix.M22);
+ half = 0.5f / sqrt;
+
+ result.X = (matrix.M31 + matrix.M13) * half;
+ result.Y = (matrix.M32 + matrix.M23) * half;
+ result.Z = 0.5f * sqrt;
+ result.W = (matrix.M12 - matrix.M21) * half;
+ }
+ }
+
+ /// <summary>
+ /// Creates a quaternion given a rotation matrix.
+ /// </summary>
+ /// <param name="matrix">The rotation matrix.</param>
+ /// <returns>The newly created quaternion.</returns>
+ public static Quaternion RotationMatrix(Matrix matrix)
+ {
+ Quaternion result;
+ RotationMatrix(ref matrix, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Creates a quaternion given a yaw, pitch, and roll value.
+ /// </summary>
+ /// <param name="yaw">The yaw of rotation.</param>
+ /// <param name="pitch">The pitch of rotation.</param>
+ /// <param name="roll">The roll of rotation.</param>
+ /// <param name="result">When the method completes, contains the
newly created quaternion.</param>
+ public static void RotationYawPitchRoll(float yaw, float pitch,
float roll, out Quaternion result)
+ {
+ float halfRoll = roll * 0.5f;
+ float halfPitch = pitch * 0.5f;
+ float halfYaw = yaw * 0.5f;
+
+ float sinRoll = (float)Math.Sin(halfRoll);
+ float cosRoll = (float)Math.Cos(halfRoll);
+ float sinPitch = (float)Math.Sin(halfPitch);
+ float cosPitch = (float)Math.Cos(halfPitch);
+ float sinYaw = (float)Math.Sin(halfYaw);
+ float cosYaw = (float)Math.Cos(halfYaw);
+
+ result.X = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch
* sinRoll);
+ result.Y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch
* sinRoll);
+ result.Z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch
* cosRoll);
+ result.W = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch
* sinRoll);
+ }
+
+ /// <summary>
+ /// Creates a quaternion given a yaw, pitch, and roll value.
+ /// </summary>
+ /// <param name="yaw">The yaw of rotation.</param>
+ /// <param name="pitch">The pitch of rotation.</param>
+ /// <param name="roll">The roll of rotation.</param>
+ /// <returns>The newly created quaternion.</returns>
+ public static Quaternion RotationYawPitchRoll(float yaw, float
pitch, float roll)
+ {
+ Quaternion result;
+ RotationYawPitchRoll(yaw, pitch, roll, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Interpolates between two quaternions, using spherical linear
interpolation.
+ /// </summary>
+ /// <param name="start">Start quaternion.</param>
+ /// <param name="end">End quaternion.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
spherical linear interpolation of the two quaternions.</param>
+ public static void Slerp(ref Quaternion start, ref Quaternion end,
float amount, out Quaternion result)
+ {
+ float opposite;
+ float inverse;
+ float dot = Dot(start, end);
+
+ if (Math.Abs(dot) > 1.0f - Utilities.ZeroTolerance)
+ {
+ inverse = 1.0f - amount;
+ opposite = amount * Math.Sign(dot);
+ }
+ else
+ {
+ float acos = (float)Math.Acos(Math.Abs(dot));
+ float invSin = (float)(1.0f / Math.Sin(acos));
+
+ inverse = (float)Math.Sin((1.0f - amount) * acos) * invSin;
+ opposite = (float)Math.Sin(amount * acos) * invSin *
Math.Sign(dot);
+ }
+
+ result.X = (inverse * start.X) + (opposite * end.X);
+ result.Y = (inverse * start.Y) + (opposite * end.Y);
+ result.Z = (inverse * start.Z) + (opposite * end.Z);
+ result.W = (inverse * start.W) + (opposite * end.W);
+ }
+
+ /// <summary>
+ /// Interpolates between two quaternions, using spherical linear
interpolation.
+ /// </summary>
+ /// <param name="start">Start quaternion.</param>
+ /// <param name="end">End quaternion.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The spherical linear interpolation of the two
quaternions.</returns>
+ public static Quaternion Slerp(Quaternion start, Quaternion end,
float amount)
+ {
+ Quaternion result;
+ Slerp(ref start, ref end, amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Interpolates between quaternions, using spherical quadrangle
interpolation.
+ /// </summary>
+ /// <param name="value1">First source quaternion.</param>
+ /// <param name="value2">Second source quaternion.</param>
+ /// <param name="value3">Thrid source quaternion.</param>
+ /// <param name="value4">Fourth source quaternion.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of interpolation.</param>
+ /// <param name="result">When the method completes, contains the
spherical quadrangle interpolation of the quaternions.</param>
+ public static void Squad(ref Quaternion value1, ref Quaternion
value2, ref Quaternion value3, ref Quaternion value4, float amount, out
Quaternion result)
+ {
+ Quaternion start, end;
+ Slerp(ref value1, ref value4, amount, out start);
+ Slerp(ref value2, ref value3, amount, out end);
+ Slerp(ref start, ref end, 2.0f * amount * (1.0f - amount), out
result);
+ }
+
+ /// <summary>
+ /// Interpolates between quaternions, using spherical quadrangle
interpolation.
+ /// </summary>
+ /// <param name="value1">First source quaternion.</param>
+ /// <param name="value2">Second source quaternion.</param>
+ /// <param name="value3">Thrid source quaternion.</param>
+ /// <param name="value4">Fourth source quaternion.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of interpolation.</param>
+ /// <returns>The spherical quadrangle interpolation of the
quaternions.</returns>
+ public static Quaternion Squad(Quaternion value1, Quaternion
value2, Quaternion value3, Quaternion value4, float amount)
+ {
+ Quaternion result;
+ Squad(ref value1, ref value2, ref value3, ref value4, amount,
out result);
+ return result;
+ }
+
+ /// <summary>
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Rational.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,115 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Defines a rational number as a numerator / denominator pair.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Rational : IEquatable<Rational>
+ {
+ /// <summary>
+ /// An empty rational value.
+ /// </summary>
+ public static readonly Rational Empty = new Rational(0, 0);
+
+ /// <summary>
+ /// Gets or sets the numerator of the rational pair.
+ /// </summary>
+ public int Numerator;
+
+ /// <summary>
+ /// Gets or sets the denominator of the rational pair.
+ /// </summary>
+ public int Denominator;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Rational"/>
structure.
+ /// </summary>
+ /// <param name="numerator">The numerator of the rational
pair.</param>
+ /// <param name="denominator">The denominator of the rational
pair.</param>
+ public Rational(int numerator, int denominator)
+ {
+ Numerator = numerator;
+ Denominator = denominator;
+ }
+
+ /// <summary>
+ /// Performs an explicit conversion from <see cref="Rational"/> to
<see cref="Single" />.
+ /// </summary>
+ /// <param name="value">The value to be converted.</param>
+ /// <returns>The converted value.</returns>
+ public static explicit operator float(Rational value)
+ {
+ return (float)value.Numerator / (float)value.Denominator;
+ }
+
+ /// <summary>
+ /// Tests for equality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has the same
value as <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool operator ==(Rational left, Rational right)
+ {
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Tests for inequality between two objects.
+ /// </summary>
+ /// <param name="left">The first value to compare.</param>
+ /// <param name="right">The second value to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> has a
different value than <paramref name="right"/>; otherwise,
<c>false</c>.</returns>
+ public static bool operator !=(Rational left, Rational right)
+ {
+ return !left.Equals(right);
+ }
+
+ /// <summary>
+ /// Returns a hash code for this instance.
+ /// </summary>
+ /// <returns>
+ /// A hash code for this instance, suitable for use in hashing
algorithms and data structures like a hash table.
+ /// </returns>
+ public override int GetHashCode()
+ {
+ return Numerator.GetHashCode() + Denominator.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see
cref="SlimMath.Rational"/> is equal to this instance.
+ /// </summary>
+ /// <param name="other">The <see cref="SlimMath.Rational"/> to
compare with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="SlimMath.Rational"/>
is equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public bool Equals(Rational other)
+ {
+ return (this.Numerator == other.Numerator) &&
(this.Denominator == other.Denominator);
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="System.Object"/>
is equal to this instance.
+ /// </summary>
+ /// <param name="obj">The <see cref="System.Object"/> to compare
with this instance.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="System.Object"/> is
equal to this instance; otherwise, <c>false</c>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (obj.GetType() != GetType())
+ return false;
+
+ return Equals((Rational)obj);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/SlimMath.csproj Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build"
xmlns="
http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)'
== '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{820FE441-822F-4519-994B-04F1DE27FF15}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <NoStandardLibraries>false</NoStandardLibraries>
+ <AssemblyName>SlimMath</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|
AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>bin\Debug\SlimMath.xml</DocumentationFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|
AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>bin\Release\SlimMath.xml</DocumentationFile>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ </PropertyGroup>
+ <PropertyGroup>
+ <RootNamespace>SlimMath</RootNamespace>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>false</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>
+ </AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Drawing" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="BoundingBox.cs" />
+ <Compile Include="BoundingSphere.cs" />
+ <Compile Include="Color3.cs" />
+ <Compile Include="Color4.cs" />
+ <Compile Include="Design\Half2Converter.cs" />
+ <Compile Include="Design\Half3Converter.cs" />
+ <Compile Include="Design\Half4Converter.cs" />
+ <Compile Include="Design\HalfConverter.cs" />
+ <Compile Include="Design\BaseConverter.cs" />
+ <Compile Include="Design\FieldPropertyDescriptor.cs" />
+ <Compile Include="Design\MatrixConverter.cs" />
+ <Compile Include="Design\QuaternionConverter.cs" />
+ <Compile Include="Design\Vector2Converter.cs" />
+ <Compile Include="Design\Vector3Converter.cs" />
+ <Compile Include="Design\Vector4Converter.cs" />
+ <Compile Include="Half.cs" />
+ <Compile Include="Half2.cs" />
+ <Compile Include="Half3.cs" />
+ <Compile Include="Half4.cs" />
+ <Compile Include="HalfUtilities.cs" />
+ <Compile Include="Matrix.cs" />
+ <Compile Include="Matrix3x2.cs" />
+ <Compile Include="Plane.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Quaternion.cs" />
+ <Compile Include="Rational.cs" />
+ <Compile Include="Utilities.cs" />
+ <Compile Include="Vector2.cs" />
+ <Compile Include="Vector3.cs" />
+ <Compile Include="Vector4.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" />
+ <ProjectExtensions>
+ <VisualStudio AllowExistingFolder="true" />
+ </ProjectExtensions>
+</Project>
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Utilities.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SlimMath
+{
+ static class Utilities
+ {
+ /// <summary>
+ /// The value for which all absolute numbers smaller than are
considered equal to zero.
+ /// </summary>
+ public const float ZeroTolerance = 1e-6f;
+
+ /// <summary>
+ /// Compares two floating point numbers based on an epsilon zero
tolerance.
+ /// </summary>
+ /// <param name="left">The first number to compare.</param>
+ /// <param name="right">The second number to compare.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> is within
epsilon of <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool EpsilonEquals(float left, float right)
+ {
+ return Math.Abs(left - right) <= ZeroTolerance;
+ }
+
+ /// <summary>
+ /// Compares two floating point numbers based on an epsilon zero
tolerance.
+ /// </summary>
+ /// <param name="left">The first number to compare.</param>
+ /// <param name="right">The second number to compare.</param>
+ /// <param name="epsilon">The epsilon value to use for zero
tolerance.</param>
+ /// <returns><c>true</c> if <paramref name="left"/> is within
epsilon of <paramref name="right"/>; otherwise, <c>false</c>.</returns>
+ public static bool EpsilonEquals(float left, float right, float
epsilon)
+ {
+ return Math.Abs(left - right) <= epsilon;
+ }
+
+ /// <summary>
+ /// Swaps two items.
+ /// </summary>
+ /// <typeparam name="T">The type of the items to swap.</typeparam>
+ /// <param name="left">The first item to swap.</param>
+ /// <param name="right">The second item to swap.</param>
+ public static void Swap<T>(ref T left, ref T right)
+ {
+ T temp = left;
+ left = right;
+ right = temp;
+ }
+
+ /// <summary>
+ /// Does something with arrays.
+ /// </summary>
+ /// <typeparam name="T">Most likely the type of elements in the
array.</typeparam>
+ /// <param name="value">Who knows what this is for.</param>
+ /// <param name="count">Probably the length of the array.</param>
+ /// <returns>An array of who knows what.</returns>
+ public static T[] Array<T>(T value, int count)
+ {
+ T[] result = new T[count];
+ for (int i = 0; i < count; i++)
+ result[i] = value;
+
+ return result;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Vector2.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,1654 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents a two dimensional mathematical vector.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ [TypeConverter(typeof(SlimMath.Design.Vector2Converter))]
+ public struct Vector2 : IEquatable<Vector2>, IFormattable
+ {
+ /// <summary>
+ /// The size of the <see cref="SlimMath.Vector2"/> type, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(Vector2));
+
+ /// <summary>
+ /// A <see cref="SlimMath.Vector2"/> with all of its components
set to zero.
+ /// </summary>
+ public static readonly Vector2 Zero = new Vector2();
+
+ /// <summary>
+ /// The X unit <see cref="SlimMath.Vector2"/> (1, 0).
+ /// </summary>
+ public static readonly Vector2 UnitX = new Vector2(1.0f, 0.0f);
+
+ /// <summary>
+ /// The Y unit <see cref="SlimMath.Vector2"/> (0, 1).
+ /// </summary>
+ public static readonly Vector2 UnitY = new Vector2(0.0f, 1.0f);
+
+ /// <summary>
+ /// A <see cref="SlimMath.Vector2"/> with all of its components
set to one.
+ /// </summary>
+ public static readonly Vector2 One = new Vector2(1.0f, 1.0f);
+
+ /// <summary>
+ /// The X component of the vector.
+ /// </summary>
+ public float X;
+
+ /// <summary>
+ /// The Y component of the vector.
+ /// </summary>
+ public float Y;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector2"/> struct.
+ /// </summary>
+ /// <param name="value">The value that will be assigned to all
components.</param>
+ public Vector2(float value)
+ {
+ X = value;
+ Y = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector2"/> struct.
+ /// </summary>
+ /// <param name="x">Initial value for the X component of the
vector.</param>
+ /// <param name="y">Initial value for the Y component of the
vector.</param>
+ public Vector2(float x, float y)
+ {
+ X = x;
+ Y = y;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector2"/> struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the X and Y
components of the vector. This must be an array with two elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than two
elements.</exception>
+ public Vector2(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 2)
+ throw new ArgumentOutOfRangeException("values", "There
must be two and only two input values for Vector2.");
+
+ X = values[0];
+ Y = values[1];
+ }
+
+ /// <summary>
+ /// Gets a value indicting whether this instance is normalized.
+ /// </summary>
+ public bool IsNormalized
+ {
+ get { return Math.Abs((X * X) + (Y * Y) - 1f) <
Utilities.ZeroTolerance; }
+ }
+
+ /// <summary>
+ /// Calculates the length of the vector.
+ /// </summary>
+ /// <remarks>
+ /// <see cref="SlimMath.Vector2.LengthSquared"/> may be preferred
when only the relative length is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public float Length
+ {
+ get { return (float)Math.Sqrt((X * X) + (Y * Y)); }
+ }
+
+ /// <summary>
+ /// Calculates the squared length of the vector.
+ /// </summary>
+ /// <remarks>
+ /// This property may be preferred to <see
cref="SlimMath.Vector2.Length"/> when only a relative length is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public float LengthSquared
+ {
+ get { return (X * X) + (Y * Y); }
+ }
+
+ /// <summary>
+ /// Gets or sets the component at the specified index.
+ /// </summary>
+ /// <value>The value of the X or Y component, depending on the
index.</value>
+ /// <param name="index">The index of the component to access. Use
0 for the X component and 1 for the Y component.</param>
+ /// <returns>The value of the component at the specified
index.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="index"/> is out of the range [0, 1].</exception>
+ public float this[int index]
+ {
+ get
+ {
+ switch (index)
+ {
+ case 0: return X;
+ case 1: return Y;
+ }
+
+ throw new ArgumentOutOfRangeException("index", "Indices
for Vector2 run from 0 to 1, inclusive.");
+ }
+
+ set
+ {
+ switch (index)
+ {
+ case 0: X = value; break;
+ case 1: Y = value; break;
+ default: throw new
ArgumentOutOfRangeException("index", "Indices for Vector2 run from 0 to 1,
inclusive.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Converts the vector into a unit vector.
+ /// </summary>
+ public void Normalize()
+ {
+ float length = Length;
+ if (length > Utilities.ZeroTolerance)
+ {
+ float inv = 1.0f / length;
+ X *= inv;
+ Y *= inv;
+ }
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given vector.
+ /// </summary>
+ public void Negate()
+ {
+ X = -X;
+ Y = -Y;
+ }
+
+ /// <summary>
+ /// Takes the absolute value of each component.
+ /// </summary>
+ public void Abs()
+ {
+ this.X = Math.Abs(X);
+ this.Y = Math.Abs(Y);
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the vector.
+ /// </summary>
+ /// <returns>A two-element array containing the components of the
vector.</returns>
+ public float[] ToArray()
+ {
+ return new float[] { X, Y };
+ }
+
+ #region Transcendentals
+ /// <summary>
+ /// Takes the square root of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root
of.</param>
+ /// <param name="result">When the method completes, contains a
vector that is the square root of the input vector.</param>
+ public static void Sqrt(ref Vector2 value, out Vector2 result)
+ {
+ result.X = (float)Math.Sqrt(value.X);
+ result.Y = (float)Math.Sqrt(value.Y);
+ }
+
+ /// <summary>
+ /// Takes the square root of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root
of.</param>
+ /// <returns>A vector that is the square root of the input
vector.</returns>
+ public static Vector2 Sqrt(Vector2 value)
+ {
+ Vector2 temp;
+ Sqrt(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the reciprocal
of.</param>
+ /// <param name="result">When the method completes, contains a
vector that is the reciprocal of the input vector.</param>
+ public static void Reciprocal(ref Vector2 value, out Vector2
result)
+ {
+ result.X = 1.0f / value.X;
+ result.Y = 1.0f / value.Y;
+ }
+
+ /// <summary>
+ /// Takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the reciprocal
of.</param>
+ /// <returns>A vector that is the reciprocal of the input
vector.</returns>
+ public static Vector2 Reciprocal(Vector2 value)
+ {
+ Vector2 temp;
+ Reciprocal(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the square root of each component in the vector and than
takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root and
recpirocal of.</param>
+ /// <param name="result">When the method completes, contains a
vector that is the square root and reciprocal of the input vector.</param>
+ public static void ReciprocalSqrt(ref Vector2 value, out Vector2
result)
+ {
+ result.X = 1.0f / (float)Math.Sqrt(value.X);
+ result.Y = 1.0f / (float)Math.Sqrt(value.Y);
+ }
+
+ /// <summary>
+ /// Takes the square root of each component in the vector and than
takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root and
recpirocal of.</param>
+ /// <returns>A vector that is the square root and reciprocal of
the input vector.</returns>
+ public static Vector2 ReciprocalSqrt(Vector2 value)
+ {
+ Vector2 temp;
+ ReciprocalSqrt(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes e raised to the component in the vector.
+ /// </summary>
+ /// <param name="value">The value to take e raised to each
component of.</param>
+ /// <param name="result">When the method completes, contains a
vector that has e raised to each of the components in the input
vector.</param>
+ public static void Exp(ref Vector2 value, out Vector2 result)
+ {
+ result.X = (float)Math.Exp(value.X);
+ result.Y = (float)Math.Exp(value.Y);
+ }
+
+ /// <summary>
+ /// Takes e raised to the component in the vector.
+ /// </summary>
+ /// <param name="value">The value to take e raised to each
component of.</param>
+ /// <returns>A vector that has e raised to each of the components
in the input vector.</returns>
+ public static Vector2 Exp(Vector2 value)
+ {
+ Vector2 temp;
+ Exp(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the sine and than the cosine of each component in the
vector.
+ /// </summary>
+ /// <param name="value">The vector to take the sine and cosine
of.</param>
+ /// <param name="sinResult">When the method completes, contains
the sine of each component in the input vector.</param>
+ /// <param name="cosResult">When the method completes, contains
the cpsome pf each component in the input vector.</param>
+ public static void SinCos(ref Vector2 value, out Vector2
sinResult, out Vector2 cosResult)
+ {
+ sinResult.X = (float)Math.Sin(value.X);
+ sinResult.Y = (float)Math.Sin(value.Y);
+
+ cosResult.X = (float)Math.Cos(value.X);
+ cosResult.Y = (float)Math.Cos(value.Y);
+ }
+
+ /// <summary>
+ /// Takes the sine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the sine of.</param>
+ /// <param name="result">When the method completes, a vector that
contains the sine of each component in the input vector.</param>
+ public static void Sin(ref Vector2 value, out Vector2 result)
+ {
+ result.X = (float)Math.Sin(value.X);
+ result.Y = (float)Math.Sin(value.Y);
+ }
+
+ /// <summary>
+ /// Takes the sine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the sine of.</param>
+ /// <returns>A vector that contains the sine of each component in
the input vector.</returns>
+ public static Vector2 Sin(Vector2 value)
+ {
+ Vector2 temp;
+ Sin(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the cosine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the cosine of.</param>
+ /// <param name="result">When the method completes, contains a
vector that contains the cosine of each component in the input
vector.</param>
+ public static void Cos(ref Vector2 value, out Vector2 result)
+ {
+ result.X = (float)Math.Cos(value.X);
+ result.Y = (float)Math.Cos(value.Y);
+ }
+
+ /// <summary>
+ /// Takes the cosine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the cosine of.</param>
+ /// <returns>A vector that contains the cosine of each component
in the input vector.</returns>
+ public static Vector2 Cos(Vector2 value)
+ {
+ Vector2 temp;
+ Cos(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the tangent of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the tangent of.</param>
+ /// <param name="result">When the method completes, contains a
vector that contains the tangent of each component in the input
vector.</param>
+ public static void Tan(ref Vector2 value, out Vector2 result)
+ {
+ result.X = (float)Math.Tan(value.X);
+ result.Y = (float)Math.Tan(value.Y);
+ }
+
+ /// <summary>
+ /// Takes the tangent of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the tangent of.</param>
+ /// <returns>A vector that contains the tangent of each component
in the input vector.</returns>
+ public static Vector2 Tan(Vector2 value)
+ {
+ Vector2 temp;
+ Tan(ref value, out temp);
+ return temp;
+ }
+ #endregion
+
+ /// <summary>
+ /// Adds two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to add.</param>
+ /// <param name="right">The second vector to add.</param>
+ /// <param name="result">When the method completes, contains the
sum of the two vectors.</param>
+ public static void Add(ref Vector2 left, ref Vector2 right, out
Vector2 result)
+ {
+ result = new Vector2(left.X + right.X, left.Y + right.Y);
+ }
+
+ /// <summary>
+ /// Adds two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to add.</param>
+ /// <param name="right">The second vector to add.</param>
+ /// <returns>The sum of the two vectors.</returns>
+ public static Vector2 Add(Vector2 left, Vector2 right)
+ {
+ return new Vector2(left.X + right.X, left.Y + right.Y);
+ }
+
+ /// <summary>
+ /// Subtracts two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to subtract.</param>
+ /// <param name="right">The second vector to subtract.</param>
+ /// <param name="result">When the method completes, contains the
difference of the two vectors.</param>
+ public static void Subtract(ref Vector2 left, ref Vector2 right,
out Vector2 result)
+ {
+ result = new Vector2(left.X - right.X, left.Y - right.Y);
+ }
+
+ /// <summary>
+ /// Subtracts two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to subtract.</param>
+ /// <param name="right">The second vector to subtract.</param>
+ /// <returns>The difference of the two vectors.</returns>
+ public static Vector2 Subtract(Vector2 left, Vector2 right)
+ {
+ return new Vector2(left.X - right.X, left.Y - right.Y);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <param name="result">When the method completes, contains the
scaled vector.</param>
+ public static void Multiply(ref Vector2 value, float scalar, out
Vector2 result)
+ {
+ result = new Vector2(value.X * scalar, value.Y * scalar);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <returns>The scaled vector.</returns>
+ public static Vector2 Multiply(Vector2 value, float scalar)
+ {
+ return new Vector2(value.X * scalar, value.Y * scalar);
+ }
+
+ /// <summary>
+ /// Modulates a vector with another by performing component-wise
multiplication.
+ /// </summary>
+ /// <param name="left">The first vector to modulate.</param>
+ /// <param name="right">The second vector to modulate.</param>
+ /// <param name="result">When the method completes, contains the
modulated vector.</param>
+ public static void Modulate(ref Vector2 left, ref Vector2 right,
out Vector2 result)
+ {
+ result = new Vector2(left.X * right.X, left.Y * right.Y);
+ }
+
+ /// <summary>
+ /// Modulates a vector with another by performing component-wise
multiplication.
+ /// </summary>
+ /// <param name="left">The first vector to modulate.</param>
+ /// <param name="right">The second vector to modulate.</param>
+ /// <returns>The modulated vector.</returns>
+ public static Vector2 Modulate(Vector2 left, Vector2 right)
+ {
+ return new Vector2(left.X * right.X, left.Y * right.Y);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <param name="result">When the method completes, contains the
scaled vector.</param>
+ public static void Divide(ref Vector2 value, float scalar, out
Vector2 result)
+ {
+ result = new Vector2(value.X / scalar, value.Y / scalar);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <returns>The scaled vector.</returns>
+ public static Vector2 Divide(Vector2 value, float scalar)
+ {
+ return new Vector2(value.X / scalar, value.Y / scalar);
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given vector.
+ /// </summary>
+ /// <param name="value">The vector to negate.</param>
+ /// <param name="result">When the method completes, contains a
vector facing in the opposite direction.</param>
+ public static void Negate(ref Vector2 value, out Vector2 result)
+ {
+ result = new Vector2(-value.X, -value.Y);
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given vector.
+ /// </summary>
+ /// <param name="value">The vector to negate.</param>
+ /// <returns>A vector facing in the opposite direction.</returns>
+ public static Vector2 Negate(Vector2 value)
+ {
+ return new Vector2(-value.X, -value.Y);
+ }
+
+ /// <summary>
+ /// Takes the absolute value of each component.
+ /// </summary>
+ /// <param name="value">The vector to take the absolute value
of.</param>
+ /// <param name="result">When the method completes, contains a
vector that has all positive components.</param>
+ public static void Abs(ref Vector2 value, out Vector2 result)
+ {
+ result = new Vector2(Math.Abs(value.X), Math.Abs(value.Y));
+ }
+
+ /// <summary>
+ /// Takes the absolute value of each component.
+ /// </summary>
+ /// <param name="value">The vector to take the absolute value
of.</param>
+ /// <returns>A vector that has all positive components.</returns>
+ public static Vector2 Abs(Vector2 value)
+ {
+ return new Vector2(Math.Abs(value.X), Math.Abs(value.Y));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="SlimMath.Vector2"/> containing the 2D
Cartesian coordinates of a point specified in Barycentric coordinates
relative to a 2D triangle.
+ /// </summary>
+ /// <param name="value1">A <see cref="SlimMath.Vector2"/>
containing the 2D Cartesian coordinates of vertex 1 of the triangle.</param>
+ /// <param name="value2">A <see cref="SlimMath.Vector2"/>
containing the 2D Cartesian coordinates of vertex 2 of the triangle.</param>
+ /// <param name="value3">A <see cref="SlimMath.Vector2"/>
containing the 2D Cartesian coordinates of vertex 3 of the triangle.</param>
+ /// <param name="amount1">Barycentric coordinate b2, which
expresses the weighting factor toward vertex 2 (specified in <paramref
name="value2"/>).</param>
+ /// <param name="amount2">Barycentric coordinate b3, which
expresses the weighting factor toward vertex 3 (specified in <paramref
name="value3"/>).</param>
+ /// <param name="result">When the method completes, contains the
2D Cartesian coordinates of the specified point.</param>
+ public static void Barycentric(ref Vector2 value1, ref Vector2
value2, ref Vector2 value3, float amount1, float amount2, out Vector2
result)
+ {
+ result = new Vector2((value1.X + (amount1 * (value2.X -
value1.X))) + (amount2 * (value3.X - value1.X)),
+ (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2
* (value3.Y - value1.Y)));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="SlimMath.Vector2"/> containing the 2D
Cartesian coordinates of a point specified in Barycentric coordinates
relative to a 2D triangle.
+ /// </summary>
+ /// <param name="value1">A <see cref="SlimMath.Vector2"/>
containing the 2D Cartesian coordinates of vertex 1 of the triangle.</param>
+ /// <param name="value2">A <see cref="SlimMath.Vector2"/>
containing the 2D Cartesian coordinates of vertex 2 of the triangle.</param>
+ /// <param name="value3">A <see cref="SlimMath.Vector2"/>
containing the 2D Cartesian coordinates of vertex 3 of the triangle.</param>
+ /// <param name="amount1">Barycentric coordinate b2, which
expresses the weighting factor toward vertex 2 (specified in <paramref
name="value2"/>).</param>
+ /// <param name="amount2">Barycentric coordinate b3, which
expresses the weighting factor toward vertex 3 (specified in <paramref
name="value3"/>).</param>
+ /// <returns>A new <see cref="SlimMath.Vector2"/> containing the
2D Cartesian coordinates of the specified point.</returns>
+ public static Vector2 Barycentric(Vector2 value1, Vector2 value2,
Vector2 value3, float amount1, float amount2)
+ {
+ Vector2 result;
+ Barycentric(ref value1, ref value2, ref value3, amount1,
amount2, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <param name="result">When the method completes, contains the
clamped value.</param>
+ public static void Clamp(ref Vector2 value, ref Vector2 min, ref
Vector2 max, out Vector2 result)
+ {
+ float x = value.X;
+ x = (x > max.X) ? max.X : x;
+ x = (x < min.X) ? min.X : x;
+
+ float y = value.Y;
+ y = (y > max.Y) ? max.Y : y;
+ y = (y < min.Y) ? min.Y : y;
+
+ result = new Vector2(x, y);
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <returns>The clamped value.</returns>
+ public static Vector2 Clamp(Vector2 value, Vector2 min, Vector2
max)
+ {
+ Vector2 result;
+ Clamp(ref value, ref min, ref max, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Calculates the distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <param name="result">When the method completes, contains the
distance between the two vectors.</param>
+ /// <remarks>
+ /// <see cref="SlimMath.Vector2.DistanceSquared(ref Vector2, ref
Vector2, out float)"/> may be preferred when only the relative distance is
needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public static void Distance(ref Vector2 value1, ref Vector2
value2, out float result)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+
+ result = (float)Math.Sqrt((x * x) + (y * y));
+ }
+
+ /// <summary>
+ /// Calculates the distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <returns>The distance between the two vectors.</returns>
+ /// <remarks>
+ /// <see cref="SlimMath.Vector2.DistanceSquared(Vector2,
Vector2)"/> may be preferred when only the relative distance is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public static float Distance(Vector2 value1, Vector2 value2)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+
+ return (float)Math.Sqrt((x * x) + (y * y));
+ }
+
+ /// <summary>
+ /// Calculates the squared distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector</param>
+ /// <param name="result">When the method completes, contains the
squared distance between the two vectors.</param>
+ /// <remarks>Distance squared is the value before taking the
square root.
+ /// Distance squared can often be used in place of distance if
relative comparisons are being made.
+ /// For example, consider three points A, B, and C. To determine
whether B or C is further from A,
+ /// compare the distance between A and B to the distance between A
and C. Calculating the two distances
+ /// involves two square roots, which are computationally
expensive. However, using distance squared
+ /// provides the same information and avoids calculating two
square roots.
+ /// </remarks>
+ public static void DistanceSquared(ref Vector2 value1, ref Vector2
value2, out float result)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+
+ result = (x * x) + (y * y);
+ }
+
+ /// <summary>
+ /// Calculates the squared distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <returns>The squared distance between the two
vectors.</returns>
+ /// <remarks>Distance squared is the value before taking the
square root.
+ /// Distance squared can often be used in place of distance if
relative comparisons are being made.
+ /// For example, consider three points A, B, and C. To determine
whether B or C is further from A,
+ /// compare the distance between A and B to the distance between A
and C. Calculating the two distances
+ /// involves two square roots, which are computationally
expensive. However, using distance squared
+ /// provides the same information and avoids calculating two
square roots.
+ /// </remarks>
+ public static float DistanceSquared(Vector2 value1, Vector2 value2)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+
+ return (x * x) + (y * y);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of two vectors.
+ /// </summary>
+ /// <param name="left">First source vector.</param>
+ /// <param name="right">Second source vector.</param>
+ /// <param name="result">When the method completes, contains the
dot product of the two vectors.</param>
+ public static void Dot(ref Vector2 left, ref Vector2 right, out
float result)
+ {
+ result = (left.X * right.X) + (left.Y * right.Y);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of two vectors.
+ /// </summary>
+ /// <param name="left">First source vector.</param>
+ /// <param name="right">Second source vector.</param>
+ /// <returns>The dot product of the two vectors.</returns>
+ public static float Dot(Vector2 left, Vector2 right)
+ {
+ return (left.X * right.X) + (left.Y * right.Y);
+ }
+
+ /// <summary>
+ /// Calculates a vector that is perpendicular to the given vector.
+ /// </summary>
+ /// <param name="value">The vector to base the perpendicular
vector on.</param>
+ /// <param name="result">When the method completes, contains the
perpendicular vector.</param>
+ /// <remarks>
+ /// This method finds the perpendicular vector using a 90 degree
counterclockwise rotation.
+ /// </remarks>
+ public static void Perp(ref Vector2 value, out Vector2 result)
+ {
+ result.X = -value.Y;
+ result.Y = value.X;
+ }
+
+ /// <summary>
+ /// Calculates a vector that is perpendicular to the given vector.
+ /// </summary>
+ /// <param name="value">The vector to base the perpendicular
vector on.</param>
+ /// <returns>The perpendicular vector.</returns>
+ /// <remarks>
+ /// This method finds the perpendicular vector using a 90 degree
counterclockwise rotation.
+ /// </remarks>
+ public static Vector2 Perp(Vector2 value)
+ {
+ Vector2 result;
+ Perp(ref value, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Calculates the perp dot product.
+ /// </summary>
+ /// <param name="left">First source vector.</param>
+ /// <param name="right">Second source vector.</param>
+ /// <param name="result">When the method completes, contains the
perp dot product of the two vectors.</param>
+ /// <remarks>
+ /// The perp dot product is defined as taking the dot product of
the perpendicular vector
+ /// of the left vector with the right vector.
+ /// </remarks>
+ public static void PerpDot(ref Vector2 left, ref Vector2 right,
out float result)
+ {
+ Vector2 temp;
+ Perp(ref left, out temp);
+
+ Dot(ref temp, ref right, out result);
+ }
+
+ /// <summary>
+ /// Calculates the perp dot product.
+ /// </summary>
+ /// <param name="left">First source vector.</param>
+ /// <param name="right">Second source vector.</param>
+ /// <returns>The perp dot product of the two vectors.</returns>
+ /// <remarks>
+ /// The perp dot product is defined as taking the dot product of
the perpendicular vector
+ /// of the left vector with the right vector.
+ /// </remarks>
+ public static float PerpDot(Vector2 left, Vector2 right)
+ {
+ float result;
+ PerpDot(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Converts the vector into a unit vector.
+ /// </summary>
+ /// <param name="value">The vector to normalize.</param>
+ /// <param name="result">When the method completes, contains the
normalized vector.</param>
+ public static void Normalize(ref Vector2 value, out Vector2 result)
+ {
+ result = value;
+ result.Normalize();
+ }
+
+ /// <summary>
+ /// Converts the vector into a unit vector.
+ /// </summary>
+ /// <param name="value">The vector to normalize.</param>
+ /// <returns>The normalized vector.</returns>
+ public static Vector2 Normalize(Vector2 value)
+ {
+ value.Normalize();
+ return value;
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
linear interpolation of the two vectors.</param>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static void Lerp(ref Vector2 start, ref Vector2 end, float
amount, out Vector2 result)
+ {
+ result.X = start.X + ((end.X - start.X) * amount);
+ result.Y = start.Y + ((end.Y - start.Y) * amount);
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The linear interpolation of the two vectors.</returns>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static Vector2 Lerp(Vector2 start, Vector2 end, float
amount)
+ {
+ Vector2 result;
+ Lerp(ref start, ref end, amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
cubic interpolation of the two vectors.</param>
+ public static void SmoothStep(ref Vector2 start, ref Vector2 end,
float amount, out Vector2 result)
+ {
+ amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f :
amount);
+ amount = (amount * amount) * (3.0f - (2.0f * amount));
+
+ result.X = start.X + ((end.X - start.X) * amount);
+ result.Y = start.Y + ((end.Y - start.Y) * amount);
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The cubic interpolation of the two vectors.</returns>
+ public static Vector2 SmoothStep(Vector2 start, Vector2 end, float
amount)
+ {
+ Vector2 result;
+ SmoothStep(ref start, ref end, amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a Hermite spline interpolation.
+ /// </summary>
+ /// <param name="value1">First source position vector.</param>
+ /// <param name="tangent1">First source tangent vector.</param>
+ /// <param name="value2">Second source position vector.</param>
+ /// <param name="tangent2">Second source tangent vector.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <param name="result">When the method completes, contains the
result of the Hermite spline interpolation.</param>
+ public static void Hermite(ref Vector2 value1, ref Vector2
tangent1, ref Vector2 value2, ref Vector2 tangent2, float amount, out
Vector2 result)
+ {
+ float squared = amount * amount;
+ float cubed = amount * squared;
+ float part1 = ((2.0f * cubed) - (3.0f * squared)) + 1.0f;
+ float part2 = (-2.0f * cubed) + (3.0f * squared);
+ float part3 = (cubed - (2.0f * squared)) + amount;
+ float part4 = cubed - squared;
+
+ result.X = (((value1.X * part1) + (value2.X * part2)) +
(tangent1.X * part3)) + (tangent2.X * part4);
+ result.Y = (((value1.Y * part1) + (value2.Y * part2)) +
(tangent1.Y * part3)) + (tangent2.Y * part4);
+ }
+
+ /// <summary>
+ /// Performs a Hermite spline interpolation.
+ /// </summary>
+ /// <param name="value1">First source position vector.</param>
+ /// <param name="tangent1">First source tangent vector.</param>
+ /// <param name="value2">Second source position vector.</param>
+ /// <param name="tangent2">Second source tangent vector.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <returns>The result of the Hermite spline
interpolation.</returns>
+ public static Vector2 Hermite(Vector2 value1, Vector2 tangent1,
Vector2 value2, Vector2 tangent2, float amount)
+ {
+ Vector2 result;
+ Hermite(ref value1, ref tangent1, ref value2, ref tangent2,
amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a Catmull-Rom interpolation using the specified
positions.
+ /// </summary>
+ /// <param name="value1">The first position in the
interpolation.</param>
+ /// <param name="value2">The second position in the
interpolation.</param>
+ /// <param name="value3">The third position in the
interpolation.</param>
+ /// <param name="value4">The fourth position in the
interpolation.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <param name="result">When the method completes, contains the
result of the Catmull-Rom interpolation.</param>
+ public static void CatmullRom(ref Vector2 value1, ref Vector2
value2, ref Vector2 value3, ref Vector2 value4, float amount, out Vector2
result)
+ {
+ float squared = amount * amount;
+ float cubed = amount * squared;
+
+ result.X = 0.5f * ((((2.0f * value2.X) + ((-value1.X +
value3.X) * amount)) +
+ (((((2.0f * value1.X) - (5.0f * value2.X)) + (4.0f *
value3.X)) - value4.X) * squared)) +
+ ((((-value1.X + (3.0f * value2.X)) - (3.0f * value3.X)) +
value4.X) * cubed));
+
+ result.Y = 0.5f * ((((2.0f * value2.Y) + ((-value1.Y +
value3.Y) * amount)) +
+ (((((2.0f * value1.Y) - (5.0f * value2.Y)) + (4.0f *
value3.Y)) - value4.Y) * squared)) +
+ ((((-value1.Y + (3.0f * value2.Y)) - (3.0f * value3.Y)) +
value4.Y) * cubed));
+ }
+
+ /// <summary>
+ /// Performs a Catmull-Rom interpolation using the specified
positions.
+ /// </summary>
+ /// <param name="value1">The first position in the
interpolation.</param>
+ /// <param name="value2">The second position in the
interpolation.</param>
+ /// <param name="value3">The third position in the
interpolation.</param>
+ /// <param name="value4">The fourth position in the
interpolation.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <returns>A vector that is the result of the Catmull-Rom
interpolation.</returns>
+ public static Vector2 CatmullRom(Vector2 value1, Vector2 value2,
Vector2 value3, Vector2 value4, float amount)
+ {
+ Vector2 result;
+ CatmullRom(ref value1, ref value2, ref value3, ref value4,
amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Returns a vector containing the largest components of the
specified vectors.
+ /// </summary>
+ /// <param name="value1">The first source vector.</param>
+ /// <param name="value2">The second source vector.</param>
+ /// <param name="result">When the method completes, contains an
new vector composed of the largest components of the source vectors.</param>
+ public static void Max(ref Vector2 value1, ref Vector2 value2, out
Vector2 result)
+ {
+ result.X = (value1.X > value2.X) ? value1.X : value2.X;
+ result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y;
+ }
+
+ /// <summary>
+ /// Returns a vector containing the largest components of the
specified vectors.
+ /// </summary>
+ /// <param name="value1">The first source vector.</param>
+ /// <param name="value2">The second source vector.</param>
+ /// <returns>A vector containing the largest components of the
source vectors.</returns>
+ public static Vector2 Max(Vector2 value1, Vector2 value2)
+ {
+ Vector2 result;
+ Max(ref value1, ref value2, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Returns a vector containing the smallest components of the
specified vectors.
+ /// </summary>
+ /// <param name="value1">The first source vector.</param>
+ /// <param name="value2">The second source vector.</param>
+ /// <param name="result">When the method completes, contains an
new vector composed of the smallest components of the source
vectors.</param>
+ public static void Min(ref Vector2 value1, ref Vector2 value2, out
Vector2 result)
+ {
+ result.X = (value1.X < value2.X) ? value1.X : value2.X;
+ result.Y = (value1.Y < value2.Y) ? value1.Y : value2.Y;
+ }
+
+ /// <summary>
+ /// Returns a vector containing the smallest components of the
specified vectors.
+ /// </summary>
+ /// <param name="value1">The first source vector.</param>
+ /// <param name="value2">The second source vector.</param>
+ /// <returns>A vector containing the smallest components of the
source vectors.</returns>
+ public static Vector2 Min(Vector2 value1, Vector2 value2)
+ {
+ Vector2 result;
+ Min(ref value1, ref value2, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Returns the reflection of a vector off a surface that has the
specified normal.
+ /// </summary>
+ /// <param name="vector">The source vector.</param>
+ /// <param name="normal">Normal of the surface.</param>
+ /// <param name="result">When the method completes, contains the
reflected vector.</param>
+ /// <remarks>Reflect only gives the direction of a reflection off
a surface, it does not determine
+ /// whether the original vector was close enough to the surface to
hit it.</remarks>
+ public static void Reflect(ref Vector2 vector, ref Vector2 normal,
out Vector2 result)
+ {
+ float dot = (vector.X * normal.X) + (vector.Y * normal.Y);
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Vector3.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,1811 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents a three dimensional mathematical vector.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ [TypeConverter(typeof(SlimMath.Design.Vector3Converter))]
+ public struct Vector3 : IEquatable<Vector3>, IFormattable
+ {
+ /// <summary>
+ /// The size of the <see cref="SlimMath.Vector3"/> type, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(Vector3));
+
+ /// <summary>
+ /// A <see cref="SlimMath.Vector3"/> with all of its components
set to zero.
+ /// </summary>
+ public static readonly Vector3 Zero = new Vector3();
+
+ /// <summary>
+ /// The X unit <see cref="SlimMath.Vector3"/> (1, 0, 0).
+ /// </summary>
+ public static readonly Vector3 UnitX = new Vector3(1.0f, 0.0f,
0.0f);
+
+ /// <summary>
+ /// The Y unit <see cref="SlimMath.Vector3"/> (0, 1, 0).
+ /// </summary>
+ public static readonly Vector3 UnitY = new Vector3(0.0f, 1.0f,
0.0f);
+
+ /// <summary>
+ /// The Z unit <see cref="SlimMath.Vector3"/> (0, 0, 1).
+ /// </summary>
+ public static readonly Vector3 UnitZ = new Vector3(0.0f, 0.0f,
1.0f);
+
+ /// <summary>
+ /// A <see cref="SlimMath.Vector3"/> with all of its components
set to one.
+ /// </summary>
+ public static readonly Vector3 One = new Vector3(1.0f, 1.0f, 1.0f);
+
+ /// <summary>
+ /// The X component of the vector.
+ /// </summary>
+ public float X;
+
+ /// <summary>
+ /// The Y component of the vector.
+ /// </summary>
+ public float Y;
+
+ /// <summary>
+ /// The Z component of the vector.
+ /// </summary>
+ public float Z;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector3"/> struct.
+ /// </summary>
+ /// <param name="value">The value that will be assigned to all
components.</param>
+ public Vector3(float value)
+ {
+ X = value;
+ Y = value;
+ Z = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector3"/> struct.
+ /// </summary>
+ /// <param name="x">Initial value for the X component of the
vector.</param>
+ /// <param name="y">Initial value for the Y component of the
vector.</param>
+ /// <param name="z">Initial value for the Z component of the
vector.</param>
+ public Vector3(float x, float y, float z)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector3"/> struct.
+ /// </summary>
+ /// <param name="value">A vector containing the values with which
to initialize the X and Y components.</param>
+ /// <param name="z">Initial value for the Z component of the
vector.</param>
+ public Vector3(Vector2 value, float z)
+ {
+ X = value.X;
+ Y = value.Y;
+ Z = z;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector3"/> struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the X, Y, and Z
components of the vector. This must be an array with three elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than three
elements.</exception>
+ public Vector3(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 3)
+ throw new ArgumentOutOfRangeException("values", "There
must be three and only three input values for Vector3.");
+
+ X = values[0];
+ Y = values[1];
+ Z = values[2];
+ }
+
+ /// <summary>
+ /// Gets a value indicting whether this instance is normalized.
+ /// </summary>
+ public bool IsNormalized
+ {
+ get { return Math.Abs((X * X) + (Y * Y) + (Z * Z) - 1f) <
Utilities.ZeroTolerance; }
+ }
+
+ /// <summary>
+ /// Calculates the length of the vector.
+ /// </summary>
+ /// <remarks>
+ /// <see cref="SlimMath.Vector3.LengthSquared"/> may be preferred
when only the relative length is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public float Length
+ {
+ get { return (float)Math.Sqrt((X * X) + (Y * Y) + (Z * Z)); }
+ }
+
+ /// <summary>
+ /// Calculates the squared length of the vector.
+ /// </summary>
+ /// <remarks>
+ /// This property may be preferred to <see
cref="SlimMath.Vector3.Length"/> when only a relative length is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public float LengthSquared
+ {
+ get { return (X * X) + (Y * Y) + (Z * Z); }
+ }
+
+ /// <summary>
+ /// Gets or sets the component at the specified index.
+ /// </summary>
+ /// <value>The value of the X, Y, or Z component, depending on the
index.</value>
+ /// <param name="index">The index of the component to access. Use
0 for the X component, 1 for the Y component, and 2 for the Z
component.</param>
+ /// <returns>The value of the component at the specified
index.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="index"/> is out of the range [0, 2].</exception>
+ public float this[int index]
+ {
+ get
+ {
+ switch (index)
+ {
+ case 0: return X;
+ case 1: return Y;
+ case 2: return Z;
+ }
+
+ throw new ArgumentOutOfRangeException("index", "Indices
for Vector3 run from 0 to 2, inclusive.");
+ }
+
+ set
+ {
+ switch (index)
+ {
+ case 0: X = value; break;
+ case 1: Y = value; break;
+ case 2: Z = value; break;
+ default: throw new
ArgumentOutOfRangeException("index", "Indices for Vector3 run from 0 to 2,
inclusive.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Converts the vector into a unit vector.
+ /// </summary>
+ public void Normalize()
+ {
+ float length = Length;
+ if (length > Utilities.ZeroTolerance)
+ {
+ float inv = 1.0f / length;
+ X *= inv;
+ Y *= inv;
+ Z *= inv;
+ }
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given vector.
+ /// </summary>
+ public void Negate()
+ {
+ X = -X;
+ Y = -Y;
+ Z = -Z;
+ }
+
+ /// <summary>
+ /// Takes the absolute value of each component.
+ /// </summary>
+ public void Abs()
+ {
+ this.X = Math.Abs(X);
+ this.Y = Math.Abs(Y);
+ this.Z = Math.Abs(Z);
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the vector.
+ /// </summary>
+ /// <returns>A three-element array containing the components of
the vector.</returns>
+ public float[] ToArray()
+ {
+ return new float[] { X, Y, Z };
+ }
+
+ #region Transcendentals
+ /// <summary>
+ /// Takes the square root of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root
of.</param>
+ /// <param name="result">When the method completes, contains a
vector that is the square root of the input vector.</param>
+ public static void Sqrt(ref Vector3 value, out Vector3 result)
+ {
+ result.X = (float)Math.Sqrt(value.X);
+ result.Y = (float)Math.Sqrt(value.Y);
+ result.Z = (float)Math.Sqrt(value.Z);
+ }
+
+ /// <summary>
+ /// Takes the square root of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root
of.</param>
+ /// <returns>A vector that is the square root of the input
vector.</returns>
+ public static Vector3 Sqrt(Vector3 value)
+ {
+ Vector3 temp;
+ Sqrt(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the reciprocal
of.</param>
+ /// <param name="result">When the method completes, contains a
vector that is the reciprocal of the input vector.</param>
+ public static void Reciprocal(ref Vector3 value, out Vector3
result)
+ {
+ result.X = 1.0f / value.X;
+ result.Y = 1.0f / value.Y;
+ result.Z = 1.0f / value.Z;
+ }
+
+ /// <summary>
+ /// Takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the reciprocal
of.</param>
+ /// <returns>A vector that is the reciprocal of the input
vector.</returns>
+ public static Vector3 Reciprocal(Vector3 value)
+ {
+ Vector3 temp;
+ Reciprocal(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the square root of each component in the vector and than
takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root and
recpirocal of.</param>
+ /// <param name="result">When the method completes, contains a
vector that is the square root and reciprocal of the input vector.</param>
+ public static void ReciprocalSqrt(ref Vector3 value, out Vector3
result)
+ {
+ result.X = 1.0f / (float)Math.Sqrt(value.X);
+ result.Y = 1.0f / (float)Math.Sqrt(value.Y);
+ result.Z = 1.0f / (float)Math.Sqrt(value.Z);
+ }
+
+ /// <summary>
+ /// Takes the square root of each component in the vector and than
takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root and
recpirocal of.</param>
+ /// <returns>A vector that is the square root and reciprocal of
the input vector.</returns>
+ public static Vector3 ReciprocalSqrt(Vector3 value)
+ {
+ Vector3 temp;
+ ReciprocalSqrt(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes e raised to the component in the vector.
+ /// </summary>
+ /// <param name="value">The value to take e raised to each
component of.</param>
+ /// <param name="result">When the method completes, contains a
vector that has e raised to each of the components in the input
vector.</param>
+ public static void Exp(ref Vector3 value, out Vector3 result)
+ {
+ result.X = (float)Math.Exp(value.X);
+ result.Y = (float)Math.Exp(value.Y);
+ result.Z = (float)Math.Exp(value.Z);
+ }
+
+ /// <summary>
+ /// Takes e raised to the component in the vector.
+ /// </summary>
+ /// <param name="value">The value to take e raised to each
component of.</param>
+ /// <returns>A vector that has e raised to each of the components
in the input vector.</returns>
+ public static Vector3 Exp(Vector3 value)
+ {
+ Vector3 temp;
+ Exp(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the sine and than the cosine of each component in the
vector.
+ /// </summary>
+ /// <param name="value">The vector to take the sine and cosine
of.</param>
+ /// <param name="sinResult">When the method completes, contains
the sine of each component in the input vector.</param>
+ /// <param name="cosResult">When the method completes, contains
the cpsome pf each component in the input vector.</param>
+ public static void SinCos(ref Vector3 value, out Vector3
sinResult, out Vector3 cosResult)
+ {
+ sinResult.X = (float)Math.Sin(value.X);
+ sinResult.Y = (float)Math.Sin(value.Y);
+ sinResult.Z = (float)Math.Sin(value.Z);
+
+ cosResult.X = (float)Math.Cos(value.X);
+ cosResult.Y = (float)Math.Cos(value.Y);
+ cosResult.Z = (float)Math.Cos(value.Z);
+ }
+
+ /// <summary>
+ /// Takes the sine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the sine of.</param>
+ /// <param name="result">When the method completes, a vector that
contains the sine of each component in the input vector.</param>
+ public static void Sin(ref Vector3 value, out Vector3 result)
+ {
+ result.X = (float)Math.Sin(value.X);
+ result.Y = (float)Math.Sin(value.Y);
+ result.Z = (float)Math.Sin(value.Z);
+ }
+
+ /// <summary>
+ /// Takes the sine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the sine of.</param>
+ /// <returns>A vector that contains the sine of each component in
the input vector.</returns>
+ public static Vector3 Sin(Vector3 value)
+ {
+ Vector3 temp;
+ Sin(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the cosine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the cosine of.</param>
+ /// <param name="result">When the method completes, contains a
vector that contains the cosine of each component in the input
vector.</param>
+ public static void Cos(ref Vector3 value, out Vector3 result)
+ {
+ result.X = (float)Math.Cos(value.X);
+ result.Y = (float)Math.Cos(value.Y);
+ result.Z = (float)Math.Cos(value.Z);
+ }
+
+ /// <summary>
+ /// Takes the cosine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the cosine of.</param>
+ /// <returns>A vector that contains the cosine of each component
in the input vector.</returns>
+ public static Vector3 Cos(Vector3 value)
+ {
+ Vector3 temp;
+ Cos(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the tangent of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the tangent of.</param>
+ /// <param name="result">When the method completes, contains a
vector that contains the tangent of each component in the input
vector.</param>
+ public static void Tan(ref Vector3 value, out Vector3 result)
+ {
+ result.X = (float)Math.Tan(value.X);
+ result.Y = (float)Math.Tan(value.Y);
+ result.Z = (float)Math.Tan(value.Z);
+ }
+
+ /// <summary>
+ /// Takes the tangent of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the tangent of.</param>
+ /// <returns>A vector that contains the tangent of each component
in the input vector.</returns>
+ public static Vector3 Tan(Vector3 value)
+ {
+ Vector3 temp;
+ Tan(ref value, out temp);
+ return temp;
+ }
+ #endregion
+
+ /// <summary>
+ /// Adds two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to add.</param>
+ /// <param name="right">The second vector to add.</param>
+ /// <param name="result">When the method completes, contains the
sum of the two vectors.</param>
+ public static void Add(ref Vector3 left, ref Vector3 right, out
Vector3 result)
+ {
+ result = new Vector3(left.X + right.X, left.Y + right.Y,
left.Z + right.Z);
+ }
+
+ /// <summary>
+ /// Adds two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to add.</param>
+ /// <param name="right">The second vector to add.</param>
+ /// <returns>The sum of the two vectors.</returns>
+ public static Vector3 Add(Vector3 left, Vector3 right)
+ {
+ return new Vector3(left.X + right.X, left.Y + right.Y, left.Z
+ right.Z);
+ }
+
+ /// <summary>
+ /// Subtracts two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to subtract.</param>
+ /// <param name="right">The second vector to subtract.</param>
+ /// <param name="result">When the method completes, contains the
difference of the two vectors.</param>
+ public static void Subtract(ref Vector3 left, ref Vector3 right,
out Vector3 result)
+ {
+ result = new Vector3(left.X - right.X, left.Y - right.Y,
left.Z - right.Z);
+ }
+
+ /// <summary>
+ /// Subtracts two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to subtract.</param>
+ /// <param name="right">The second vector to subtract.</param>
+ /// <returns>The difference of the two vectors.</returns>
+ public static Vector3 Subtract(Vector3 left, Vector3 right)
+ {
+ return new Vector3(left.X - right.X, left.Y - right.Y, left.Z
- right.Z);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <param name="result">When the method completes, contains the
scaled vector.</param>
+ public static void Multiply(ref Vector3 value, float scalar, out
Vector3 result)
+ {
+ result = new Vector3(value.X * scalar, value.Y * scalar,
value.Z * scalar);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <returns>The scaled vector.</returns>
+ public static Vector3 Multiply(Vector3 value, float scalar)
+ {
+ return new Vector3(value.X * scalar, value.Y * scalar, value.Z
* scalar);
+ }
+
+ /// <summary>
+ /// Modulates a vector with another by performing component-wise
multiplication.
+ /// </summary>
+ /// <param name="left">The first vector to modulate.</param>
+ /// <param name="right">The second vector to modulate.</param>
+ /// <param name="result">When the method completes, contains the
modulated vector.</param>
+ public static void Modulate(ref Vector3 left, ref Vector3 right,
out Vector3 result)
+ {
+ result = new Vector3(left.X * right.X, left.Y * right.Y,
left.Z * right.Z);
+ }
+
+ /// <summary>
+ /// Modulates a vector with another by performing component-wise
multiplication.
+ /// </summary>
+ /// <param name="left">The first vector to modulate.</param>
+ /// <param name="right">The second vector to modulate.</param>
+ /// <returns>The modulated vector.</returns>
+ public static Vector3 Modulate(Vector3 left, Vector3 right)
+ {
+ return new Vector3(left.X * right.X, left.Y * right.Y, left.Z
* right.Z);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <param name="result">When the method completes, contains the
scaled vector.</param>
+ public static void Divide(ref Vector3 value, float scalar, out
Vector3 result)
+ {
+ result = new Vector3(value.X / scalar, value.Y / scalar,
value.Z / scalar);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <returns>The scaled vector.</returns>
+ public static Vector3 Divide(Vector3 value, float scalar)
+ {
+ return new Vector3(value.X / scalar, value.Y / scalar, value.Z
/ scalar);
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given vector.
+ /// </summary>
+ /// <param name="value">The vector to negate.</param>
+ /// <param name="result">When the method completes, contains a
vector facing in the opposite direction.</param>
+ public static void Negate(ref Vector3 value, out Vector3 result)
+ {
+ result = new Vector3(-value.X, -value.Y, -value.Z);
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given vector.
+ /// </summary>
+ /// <param name="value">The vector to negate.</param>
+ /// <returns>A vector facing in the opposite direction.</returns>
+ public static Vector3 Negate(Vector3 value)
+ {
+ return new Vector3(-value.X, -value.Y, -value.Z);
+ }
+
+ /// <summary>
+ /// Takes the absolute value of each component.
+ /// </summary>
+ /// <param name="value">The vector to take the absolute value
of.</param>
+ /// <param name="result">When the method completes, contains a
vector that has all positive components.</param>
+ public static void Abs(ref Vector3 value, out Vector3 result)
+ {
+ result = new Vector3(Math.Abs(value.X), Math.Abs(value.Y),
Math.Abs(value.Z));
+ }
+
+ /// <summary>
+ /// Takes the absolute value of each component.
+ /// </summary>
+ /// <param name="value">The vector to take the absolute value
of.</param>
+ /// <returns>A vector that has all positive components.</returns>
+ public static Vector3 Abs(Vector3 value)
+ {
+ return new Vector3(Math.Abs(value.X), Math.Abs(value.Y),
Math.Abs(value.Z));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="SlimMath.Vector3"/> containing the 3D
Cartesian coordinates of a point specified in Barycentric coordinates
relative to a 3D triangle.
+ /// </summary>
+ /// <param name="value1">A <see cref="SlimMath.Vector3"/>
containing the 3D Cartesian coordinates of vertex 1 of the triangle.</param>
+ /// <param name="value2">A <see cref="SlimMath.Vector3"/>
containing the 3D Cartesian coordinates of vertex 2 of the triangle.</param>
+ /// <param name="value3">A <see cref="SlimMath.Vector3"/>
containing the 3D Cartesian coordinates of vertex 3 of the triangle.</param>
+ /// <param name="amount1">Barycentric coordinate b2, which
expresses the weighting factor toward vertex 2 (specified in <paramref
name="value2"/>).</param>
+ /// <param name="amount2">Barycentric coordinate b3, which
expresses the weighting factor toward vertex 3 (specified in <paramref
name="value3"/>).</param>
+ /// <param name="result">When the method completes, contains the
3D Cartesian coordinates of the specified point.</param>
+ public static void Barycentric(ref Vector3 value1, ref Vector3
value2, ref Vector3 value3, float amount1, float amount2, out Vector3
result)
+ {
+ result = new Vector3((value1.X + (amount1 * (value2.X -
value1.X))) + (amount2 * (value3.X - value1.X)),
+ (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2
* (value3.Y - value1.Y)),
+ (value1.Z + (amount1 * (value2.Z - value1.Z))) + (amount2
* (value3.Z - value1.Z)));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="SlimMath.Vector3"/> containing the 3D
Cartesian coordinates of a point specified in Barycentric coordinates
relative to a 3D triangle.
+ /// </summary>
+ /// <param name="value1">A <see cref="SlimMath.Vector3"/>
containing the 3D Cartesian coordinates of vertex 1 of the triangle.</param>
+ /// <param name="value2">A <see cref="SlimMath.Vector3"/>
containing the 3D Cartesian coordinates of vertex 2 of the triangle.</param>
+ /// <param name="value3">A <see cref="SlimMath.Vector3"/>
containing the 3D Cartesian coordinates of vertex 3 of the triangle.</param>
+ /// <param name="amount1">Barycentric coordinate b2, which
expresses the weighting factor toward vertex 2 (specified in <paramref
name="value2"/>).</param>
+ /// <param name="amount2">Barycentric coordinate b3, which
expresses the weighting factor toward vertex 3 (specified in <paramref
name="value3"/>).</param>
+ /// <returns>A new <see cref="SlimMath.Vector3"/> containing the
3D Cartesian coordinates of the specified point.</returns>
+ public static Vector3 Barycentric(Vector3 value1, Vector3 value2,
Vector3 value3, float amount1, float amount2)
+ {
+ Vector3 result;
+ Barycentric(ref value1, ref value2, ref value3, amount1,
amount2, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <param name="result">When the method completes, contains the
clamped value.</param>
+ public static void Clamp(ref Vector3 value, ref Vector3 min, ref
Vector3 max, out Vector3 result)
+ {
+ float x = value.X;
+ x = (x > max.X) ? max.X : x;
+ x = (x < min.X) ? min.X : x;
+
+ float y = value.Y;
+ y = (y > max.Y) ? max.Y : y;
+ y = (y < min.Y) ? min.Y : y;
+
+ float z = value.Z;
+ z = (z > max.Z) ? max.Z : z;
+ z = (z < min.Z) ? min.Z : z;
+
+ result = new Vector3(x, y, z);
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <returns>The clamped value.</returns>
+ public static Vector3 Clamp(Vector3 value, Vector3 min, Vector3
max)
+ {
+ Vector3 result;
+ Clamp(ref value, ref min, ref max, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Calculates the cross product of two vectors.
+ /// </summary>
+ /// <param name="left">First source vector.</param>
+ /// <param name="right">Second source vector.</param>
+ /// <param name="result">When the method completes, contains the
cross product of the two vectors.</param>
+ public static void Cross(ref Vector3 left, ref Vector3 right, out
Vector3 result)
+ {
+ result = new Vector3(
+ (left.Y * right.Z) - (left.Z * right.Y),
+ (left.Z * right.X) - (left.X * right.Z),
+ (left.X * right.Y) - (left.Y * right.X));
+ }
+
+ /// <summary>
+ /// Calculates the cross product of two vectors.
+ /// </summary>
+ /// <param name="left">First source vector.</param>
+ /// <param name="right">Second source vector.</param>
+ /// <returns>The cross product of the two vectors.</returns>
+ public static Vector3 Cross(Vector3 left, Vector3 right)
+ {
+ Vector3 result;
+ Cross(ref left, ref right, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Calculates the tripple cross product of three vectors.
+ /// </summary>
+ /// <param name="value1">First source vector.</param>
+ /// <param name="value2">Second source vector.</param>
+ /// <param name="value3">Third source vector.</param>
+ /// <param name="result">When the method completes, contains the
tripple cross product of the three vectors.</param>
+ public static void TripleProduct(ref Vector3 value1, ref Vector3
value2, ref Vector3 value3, out float result)
+ {
+ Vector3 temp;
+ Vector3.Cross(ref value2, ref value3, out temp);
+ Vector3.Dot(ref value1, ref temp, out result);
+ }
+
+ /// <summary>
+ /// Calculates the tripple cross product of three vectors.
+ /// </summary>
+ /// <param name="value1">First source vector.</param>
+ /// <param name="value2">Second source vector.</param>
+ /// <param name="value3">Third source vector.</param>
+ /// <returns>The tripple cross product of the three
vectors.</returns>
+ public static float TripleProduct(Vector3 value1, Vector3 value2,
Vector3 value3)
+ {
+ float result;
+ TripleProduct(ref value1, ref value2, ref value3, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Calculates the distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <param name="result">When the method completes, contains the
distance between the two vectors.</param>
+ /// <remarks>
+ /// <see cref="SlimMath.Vector3.DistanceSquared(ref Vector3, ref
Vector3, out float)"/> may be preferred when only the relative distance is
needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public static void Distance(ref Vector3 value1, ref Vector3
value2, out float result)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+ float z = value1.Z - value2.Z;
+
+ result = (float)Math.Sqrt((x * x) + (y * y) + (z * z));
+ }
+
+ /// <summary>
+ /// Calculates the distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <returns>The distance between the two vectors.</returns>
+ /// <remarks>
+ /// <see cref="SlimMath.Vector3.DistanceSquared(Vector3,
Vector3)"/> may be preferred when only the relative distance is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public static float Distance(Vector3 value1, Vector3 value2)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+ float z = value1.Z - value2.Z;
+
+ return (float)Math.Sqrt((x * x) + (y * y) + (z * z));
+ }
+
+ /// <summary>
+ /// Calculates the squared distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <param name="result">When the method completes, contains the
squared distance between the two vectors.</param>
+ /// <remarks>Distance squared is the value before taking the
square root.
+ /// Distance squared can often be used in place of distance if
relative comparisons are being made.
+ /// For example, consider three points A, B, and C. To determine
whether B or C is further from A,
+ /// compare the distance between A and B to the distance between A
and C. Calculating the two distances
+ /// involves two square roots, which are computationally
expensive. However, using distance squared
+ /// provides the same information and avoids calculating two
square roots.
+ /// </remarks>
+ public static void DistanceSquared(ref Vector3 value1, ref Vector3
value2, out float result)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+ float z = value1.Z - value2.Z;
+
+ result = (x * x) + (y * y) + (z * z);
+ }
+
+ /// <summary>
+ /// Calculates the squared distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <returns>The squared distance between the two
vectors.</returns>
+ /// <remarks>Distance squared is the value before taking the
square root.
+ /// Distance squared can often be used in place of distance if
relative comparisons are being made.
+ /// For example, consider three points A, B, and C. To determine
whether B or C is further from A,
+ /// compare the distance between A and B to the distance between A
and C. Calculating the two distances
+ /// involves two square roots, which are computationally
expensive. However, using distance squared
+ /// provides the same information and avoids calculating two
square roots.
+ /// </remarks>
+ public static float DistanceSquared(Vector3 value1, Vector3 value2)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+ float z = value1.Z - value2.Z;
+
+ return (x * x) + (y * y) + (z * z);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of two vectors.
+ /// </summary>
+ /// <param name="left">First source vector.</param>
+ /// <param name="right">Second source vector.</param>
+ /// <param name="result">When the method completes, contains the
dot product of the two vectors.</param>
+ public static void Dot(ref Vector3 left, ref Vector3 right, out
float result)
+ {
+ result = (left.X * right.X) + (left.Y * right.Y) + (left.Z *
right.Z);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of two vectors.
+ /// </summary>
+ /// <param name="left">First source vector.</param>
+ /// <param name="right">Second source vector.</param>
+ /// <returns>The dot product of the two vectors.</returns>
+ public static float Dot(Vector3 left, Vector3 right)
+ {
+ return (left.X * right.X) + (left.Y * right.Y) + (left.Z *
right.Z);
+ }
+
+ /// <summary>
+ /// Converts the vector into a unit vector.
+ /// </summary>
+ /// <param name="value">The vector to normalize.</param>
+ /// <param name="result">When the method completes, contains the
normalized vector.</param>
+ public static void Normalize(ref Vector3 value, out Vector3 result)
+ {
+ result = value;
+ result.Normalize();
+ }
+
+ /// <summary>
+ /// Converts the vector into a unit vector.
+ /// </summary>
+ /// <param name="value">The vector to normalize.</param>
+ /// <returns>The normalized vector.</returns>
+ public static Vector3 Normalize(Vector3 value)
+ {
+ value.Normalize();
+ return value;
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
linear interpolation of the two vectors.</param>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static void Lerp(ref Vector3 start, ref Vector3 end, float
amount, out Vector3 result)
+ {
+ result.X = start.X + ((end.X - start.X) * amount);
+ result.Y = start.Y + ((end.Y - start.Y) * amount);
+ result.Z = start.Z + ((end.Z - start.Z) * amount);
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The linear interpolation of the two vectors.</returns>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static Vector3 Lerp(Vector3 start, Vector3 end, float
amount)
+ {
+ Vector3 result;
+ Lerp(ref start, ref end, amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
cubic interpolation of the two vectors.</param>
+ public static void SmoothStep(ref Vector3 start, ref Vector3 end,
float amount, out Vector3 result)
+ {
+ amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f :
amount);
+ amount = (amount * amount) * (3.0f - (2.0f * amount));
+
+ result.X = start.X + ((end.X - start.X) * amount);
+ result.Y = start.Y + ((end.Y - start.Y) * amount);
+ result.Z = start.Z + ((end.Z - start.Z) * amount);
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The cubic interpolation of the two vectors.</returns>
+ public static Vector3 SmoothStep(Vector3 start, Vector3 end, float
amount)
+ {
+ Vector3 result;
+ SmoothStep(ref start, ref end, amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a Hermite spline interpolation.
+ /// </summary>
+ /// <param name="value1">First source position vector.</param>
+ /// <param name="tangent1">First source tangent vector.</param>
+ /// <param name="value2">Second source position vector.</param>
+ /// <param name="tangent2">Second source tangent vector.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <param name="result">When the method completes, contains the
result of the Hermite spline interpolation.</param>
+ public static void Hermite(ref Vector3 value1, ref Vector3
tangent1, ref Vector3 value2, ref Vector3 tangent2, float amount, out
Vector3 result)
+ {
+ float squared = amount * amount;
+ float cubed = amount * squared;
+ float part1 = ((2.0f * cubed) - (3.0f * squared)) + 1.0f;
+ float part2 = (-2.0f * cubed) + (3.0f * squared);
+ float part3 = (cubed - (2.0f * squared)) + amount;
+ float part4 = cubed - squared;
+
+ result.X = (((value1.X * part1) + (value2.X * part2)) +
(tangent1.X * part3)) + (tangent2.X * part4);
+ result.Y = (((value1.Y * part1) + (value2.Y * part2)) +
(tangent1.Y * part3)) + (tangent2.Y * part4);
+ result.Z = (((value1.Z * part1) + (value2.Z * part2)) +
(tangent1.Z * part3)) + (tangent2.Z * part4);
+ }
+
+ /// <summary>
+ /// Performs a Hermite spline interpolation.
+ /// </summary>
+ /// <param name="value1">First source position vector.</param>
+ /// <param name="tangent1">First source tangent vector.</param>
+ /// <param name="value2">Second source position vector.</param>
+ /// <param name="tangent2">Second source tangent vector.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <returns>The result of the Hermite spline
interpolation.</returns>
+ public static Vector3 Hermite(Vector3 value1, Vector3 tangent1,
Vector3 value2, Vector3 tangent2, float amount)
+ {
+ Vector3 result;
+ Hermite(ref value1, ref tangent1, ref value2, ref tangent2,
amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a Catmull-Rom interpolation using the specified
positions.
+ /// </summary>
+ /// <param name="value1">The first position in the
interpolation.</param>
+ /// <param name="value2">The second position in the
interpolation.</param>
+ /// <param name="value3">The third position in the
interpolation.</param>
+ /// <param name="value4">The fourth position in the
interpolation.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <param name="result">When the method completes, contains the
result of the Catmull-Rom interpolation.</param>
+ public static void CatmullRom(ref Vector3 value1, ref Vector3
value2, ref Vector3 value3, ref Vector3 value4, float amount, out Vector3
result)
+ {
+ float squared = amount * amount;
+ float cubed = amount * squared;
+
+ result.X = 0.5f * ((((2.0f * value2.X) + ((-value1.X +
value3.X) * amount)) +
+ (((((2.0f * value1.X) - (5.0f * value2.X)) + (4.0f *
value3.X)) - value4.X) * squared)) +
+ ((((-value1.X + (3.0f * value2.X)) - (3.0f * value3.X)) +
value4.X) * cubed));
+
+ result.Y = 0.5f * ((((2.0f * value2.Y) + ((-value1.Y +
value3.Y) * amount)) +
+ (((((2.0f * value1.Y) - (5.0f * value2.Y)) + (4.0f *
value3.Y)) - value4.Y) * squared)) +
+ ((((-value1.Y + (3.0f * value2.Y)) - (3.0f * value3.Y)) +
value4.Y) * cubed));
+
+ result.Z = 0.5f * ((((2.0f * value2.Z) + ((-value1.Z +
value3.Z) * amount)) +
+ (((((2.0f * value1.Z) - (5.0f * value2.Z)) + (4.0f *
value3.Z)) - value4.Z) * squared)) +
+ ((((-value1.Z + (3.0f * value2.Z)) - (3.0f * value3.Z)) +
value4.Z) * cubed));
+ }
+
+ /// <summary>
+ /// Performs a Catmull-Rom interpolation using the specified
positions.
+ /// </summary>
+ /// <param name="value1">The first position in the
interpolation.</param>
+ /// <param name="value2">The second position in the
interpolation.</param>
+ /// <param name="value3">The third position in the
interpolation.</param>
+ /// <param name="value4">The fourth position in the
interpolation.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <returns>A vector that is the result of the Catmull-Rom
interpolation.</returns>
+ public static Vector3 CatmullRom(Vector3 value1, Vector3 value2,
Vector3 value3, Vector3 value4, float amount)
+ {
+ Vector3 result;
+ CatmullRom(ref value1, ref value2, ref value3, ref value4,
amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Returns a vector containing the largest components of the
specified vectors.
+ /// </summary>
+ /// <param name="value1">The first source vector.</param>
+ /// <param name="value2">The second source vector.</param>
+ /// <param name="result">When the method completes, contains an
new vector composed of the largest components of the source vectors.</param>
+ public static void Max(ref Vector3 value1, ref Vector3 value2, out
Vector3 result)
+ {
+ result.X = (value1.X > value2.X) ? value1.X : value2.X;
+ result.Y = (value1.Y > value2.Y) ? value1.Y : value2.Y;
+ result.Z = (value1.Z > value2.Z) ? value1.Z : value2.Z;
+ }
+
+ /// <summary>
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /branches/vs2013/SlimMath/Vector4.cs Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,1539 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+
+namespace SlimMath
+{
+ /// <summary>
+ /// Represents a four dimensional mathematical vector.
+ /// </summary>
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ [TypeConverter(typeof(SlimMath.Design.Vector4Converter))]
+ public struct Vector4 : IEquatable<Vector4>, IFormattable
+ {
+ /// <summary>
+ /// The size of the <see cref="SlimMath.Vector4"/> type, in bytes.
+ /// </summary>
+ public static readonly int SizeInBytes =
Marshal.SizeOf(typeof(Vector4));
+
+ /// <summary>
+ /// A <see cref="SlimMath.Vector4"/> with all of its components
set to zero.
+ /// </summary>
+ public static readonly Vector4 Zero = new Vector4();
+
+ /// <summary>
+ /// The X unit <see cref="SlimMath.Vector4"/> (1, 0, 0, 0).
+ /// </summary>
+ public static readonly Vector4 UnitX = new Vector4(1.0f, 0.0f,
0.0f, 0.0f);
+
+ /// <summary>
+ /// The Y unit <see cref="SlimMath.Vector4"/> (0, 1, 0, 0).
+ /// </summary>
+ public static readonly Vector4 UnitY = new Vector4(0.0f, 1.0f,
0.0f, 0.0f);
+
+ /// <summary>
+ /// The Z unit <see cref="SlimMath.Vector4"/> (0, 0, 1, 0).
+ /// </summary>
+ public static readonly Vector4 UnitZ = new Vector4(0.0f, 0.0f,
1.0f, 0.0f);
+
+ /// <summary>
+ /// The W unit <see cref="SlimMath.Vector4"/> (0, 0, 0, 1).
+ /// </summary>
+ public static readonly Vector4 UnitW = new Vector4(0.0f, 0.0f,
0.0f, 1.0f);
+
+ /// <summary>
+ /// A <see cref="SlimMath.Vector4"/> with all of its components
set to one.
+ /// </summary>
+ public static readonly Vector4 One = new Vector4(1.0f, 1.0f, 1.0f,
1.0f);
+
+ /// <summary>
+ /// The X component of the vector.
+ /// </summary>
+ public float X;
+
+ /// <summary>
+ /// The Y component of the vector.
+ /// </summary>
+ public float Y;
+
+ /// <summary>
+ /// The Z component of the vector.
+ /// </summary>
+ public float Z;
+
+ /// <summary>
+ /// The W component of the vector.
+ /// </summary>
+ public float W;
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector4"/> struct.
+ /// </summary>
+ /// <param name="value">The value that will be assigned to all
components.</param>
+ public Vector4(float value)
+ {
+ X = value;
+ Y = value;
+ Z = value;
+ W = value;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector4"/> struct.
+ /// </summary>
+ /// <param name="x">Initial value for the X component of the
vector.</param>
+ /// <param name="y">Initial value for the Y component of the
vector.</param>
+ /// <param name="z">Initial value for the Z component of the
vector.</param>
+ /// <param name="w">Initial value for the W component of the
vector.</param>
+ public Vector4(float x, float y, float z, float w)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ W = w;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector4"/> struct.
+ /// </summary>
+ /// <param name="value">A vector containing the values with which
to initialize the X, Y, and Z components.</param>
+ /// <param name="w">Initial value for the W component of the
vector.</param>
+ public Vector4(Vector3 value, float w)
+ {
+ X = value.X;
+ Y = value.Y;
+ Z = value.Z;
+ W = w;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector4"/> struct.
+ /// </summary>
+ /// <param name="value">A vector containing the values with which
to initialize the X and Y components.</param>
+ /// <param name="z">Initial value for the Z component of the
vector.</param>
+ /// <param name="w">Initial value for the W component of the
vector.</param>
+ public Vector4(Vector2 value, float z, float w)
+ {
+ X = value.X;
+ Y = value.Y;
+ Z = z;
+ W = w;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see
cref="SlimMath.Vector4"/> struct.
+ /// </summary>
+ /// <param name="values">The values to assign to the X, Y, Z, and
W components of the vector. This must be an array with four
elements.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref
name="values"/> is <c>null</c>.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when
<paramref name="values"/> contains more or less than four
elements.</exception>
+ public Vector4(float[] values)
+ {
+ if (values == null)
+ throw new ArgumentNullException("values");
+ if (values.Length != 4)
+ throw new ArgumentOutOfRangeException("values", "There
must be four and only four input values for Vector4.");
+
+ X = values[0];
+ Y = values[1];
+ Z = values[2];
+ W = values[3];
+ }
+
+ /// <summary>
+ /// Gets a value indicting whether this instance is normalized.
+ /// </summary>
+ public bool IsNormalized
+ {
+ get { return Math.Abs((X * X) + (Y * Y) + (Z * Z) + (W * W) -
1f) < Utilities.ZeroTolerance; }
+ }
+
+ /// <summary>
+ /// Calculates the length of the vector.
+ /// </summary>
+ /// <remarks>
+ /// <see cref="SlimMath.Vector4.LengthSquared"/> may be preferred
when only the relative length is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public float Length
+ {
+ get { return (float)Math.Sqrt((X * X) + (Y * Y) + (Z * Z) + (W
* W)); }
+ }
+
+ /// <summary>
+ /// Calculates the squared length of the vector.
+ /// </summary>
+ /// <remarks>
+ /// This property may be preferred to <see
cref="SlimMath.Vector4.Length"/> when only a relative length is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public float LengthSquared
+ {
+ get { return (X * X) + (Y * Y) + (Z * Z) + (W * W); }
+ }
+
+ /// <summary>
+ /// Gets or sets the component at the specified index.
+ /// </summary>
+ /// <value>The value of the X, Y, Z, or W component, depending on
the index.</value>
+ /// <param name="index">The index of the component to access. Use
0 for the X component, 1 for the Y component, 2 for the Z component, and 3
for the W component.</param>
+ /// <returns>The value of the component at the specified
index.</returns>
+ /// <exception cref="System.ArgumentOutOfRangeException">Thrown
when the <paramref name="index"/> is out of the range [0, 3].</exception>
+ public float this[int index]
+ {
+ get
+ {
+ switch (index)
+ {
+ case 0: return X;
+ case 1: return Y;
+ case 2: return Z;
+ case 3: return W;
+ }
+
+ throw new ArgumentOutOfRangeException("index", "Indices
for Vector4 run from 0 to 3, inclusive.");
+ }
+
+ set
+ {
+ switch (index)
+ {
+ case 0: X = value; break;
+ case 1: Y = value; break;
+ case 2: Z = value; break;
+ case 3: W = value; break;
+ default: throw new
ArgumentOutOfRangeException("index", "Indices for Vector4 run from 0 to 3,
inclusive.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the X and Y components of the vector.
+ /// </summary>
+ public Vector2 XY
+ {
+ get { return new Vector2(X, Y); }
+ }
+
+ /// <summary>
+ /// Gets the Z and W components of the vector.
+ /// </summary>
+ public Vector2 ZW
+ {
+ get { return new Vector2(Z, W); }
+ }
+
+ /// <summary>
+ /// Converts the vector into a unit vector.
+ /// </summary>
+ public void Normalize()
+ {
+ float length = Length;
+ if (length > Utilities.ZeroTolerance)
+ {
+ float inverse = 1.0f / length;
+ X *= inverse;
+ Y *= inverse;
+ Z *= inverse;
+ W *= inverse;
+ }
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given vector.
+ /// </summary>
+ public void Negate()
+ {
+ X = -X;
+ Y = -Y;
+ Z = -Z;
+ W = -W;
+ }
+
+ /// <summary>
+ /// Takes the absolute value of each component.
+ /// </summary>
+ public void Abs()
+ {
+ this.X = Math.Abs(X);
+ this.Y = Math.Abs(Y);
+ this.Z = Math.Abs(Z);
+ this.W = Math.Abs(W);
+ }
+
+ /// <summary>
+ /// Creates an array containing the elements of the vector.
+ /// </summary>
+ /// <returns>A four-element array containing the components of the
vector.</returns>
+ public float[] ToArray()
+ {
+ return new float[] { X, Y, Z, W };
+ }
+
+ #region Transcendentals
+ /// <summary>
+ /// Takes the square root of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root
of.</param>
+ /// <param name="result">When the method completes, contains a
vector that is the square root of the input vector.</param>
+ public static void Sqrt(ref Vector4 value, out Vector4 result)
+ {
+ result.X = (float)Math.Sqrt(value.X);
+ result.Y = (float)Math.Sqrt(value.Y);
+ result.Z = (float)Math.Sqrt(value.Z);
+ result.W = (float)Math.Sqrt(value.W);
+ }
+
+ /// <summary>
+ /// Takes the square root of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root
of.</param>
+ /// <returns>A vector that is the square root of the input
vector.</returns>
+ public static Vector4 Sqrt(Vector4 value)
+ {
+ Vector4 temp;
+ Sqrt(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the reciprocal
of.</param>
+ /// <param name="result">When the method completes, contains a
vector that is the reciprocal of the input vector.</param>
+ public static void Reciprocal(ref Vector4 value, out Vector4
result)
+ {
+ result.X = 1.0f / value.X;
+ result.Y = 1.0f / value.Y;
+ result.Z = 1.0f / value.Z;
+ result.W = 1.0f / value.W;
+ }
+
+ /// <summary>
+ /// Takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the reciprocal
of.</param>
+ /// <returns>A vector that is the reciprocal of the input
vector.</returns>
+ public static Vector4 Reciprocal(Vector4 value)
+ {
+ Vector4 temp;
+ Reciprocal(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the square root of each component in the vector and than
takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root and
recpirocal of.</param>
+ /// <param name="result">When the method completes, contains a
vector that is the square root and reciprocal of the input vector.</param>
+ public static void ReciprocalSqrt(ref Vector4 value, out Vector4
result)
+ {
+ result.X = 1.0f / (float)Math.Sqrt(value.X);
+ result.Y = 1.0f / (float)Math.Sqrt(value.Y);
+ result.Z = 1.0f / (float)Math.Sqrt(value.Z);
+ result.W = 1.0f / (float)Math.Sqrt(value.W);
+ }
+
+ /// <summary>
+ /// Takes the square root of each component in the vector and than
takes the reciprocal of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the square root and
recpirocal of.</param>
+ /// <returns>A vector that is the square root and reciprocal of
the input vector.</returns>
+ public static Vector4 ReciprocalSqrt(Vector4 value)
+ {
+ Vector4 temp;
+ ReciprocalSqrt(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes e raised to the component in the vector.
+ /// </summary>
+ /// <param name="value">The value to take e raised to each
component of.</param>
+ /// <param name="result">When the method completes, contains a
vector that has e raised to each of the components in the input
vector.</param>
+ public static void Exp(ref Vector4 value, out Vector4 result)
+ {
+ result.X = (float)Math.Exp(value.X);
+ result.Y = (float)Math.Exp(value.Y);
+ result.Z = (float)Math.Exp(value.Z);
+ result.W = (float)Math.Exp(value.W);
+ }
+
+ /// <summary>
+ /// Takes e raised to the component in the vector.
+ /// </summary>
+ /// <param name="value">The value to take e raised to each
component of.</param>
+ /// <returns>A vector that has e raised to each of the components
in the input vector.</returns>
+ public static Vector4 Exp(Vector4 value)
+ {
+ Vector4 temp;
+ Exp(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the sine and than the cosine of each component in the
vector.
+ /// </summary>
+ /// <param name="value">The vector to take the sine and cosine
of.</param>
+ /// <param name="sinResult">When the method completes, contains
the sine of each component in the input vector.</param>
+ /// <param name="cosResult">When the method completes, contains
the cpsome pf each component in the input vector.</param>
+ public static void SinCos(ref Vector4 value, out Vector4
sinResult, out Vector4 cosResult)
+ {
+ sinResult.X = (float)Math.Sin(value.X);
+ sinResult.Y = (float)Math.Sin(value.Y);
+ sinResult.Z = (float)Math.Sin(value.Z);
+ sinResult.W = (float)Math.Sin(value.W);
+
+ cosResult.X = (float)Math.Cos(value.X);
+ cosResult.Y = (float)Math.Cos(value.Y);
+ cosResult.Z = (float)Math.Cos(value.Z);
+ cosResult.W = (float)Math.Cos(value.W);
+ }
+
+ /// <summary>
+ /// Takes the sine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the sine of.</param>
+ /// <param name="result">When the method completes, a vector that
contains the sine of each component in the input vector.</param>
+ public static void Sin(ref Vector4 value, out Vector4 result)
+ {
+ result.X = (float)Math.Sin(value.X);
+ result.Y = (float)Math.Sin(value.Y);
+ result.Z = (float)Math.Sin(value.Z);
+ result.W = (float)Math.Sin(value.W);
+ }
+
+ /// <summary>
+ /// Takes the sine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the sine of.</param>
+ /// <returns>A vector that contains the sine of each component in
the input vector.</returns>
+ public static Vector4 Sin(Vector4 value)
+ {
+ Vector4 temp;
+ Sin(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the cosine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the cosine of.</param>
+ /// <param name="result">When the method completes, contains a
vector that contains the cosine of each component in the input
vector.</param>
+ public static void Cos(ref Vector4 value, out Vector4 result)
+ {
+ result.X = (float)Math.Cos(value.X);
+ result.Y = (float)Math.Cos(value.Y);
+ result.Z = (float)Math.Cos(value.Z);
+ result.W = (float)Math.Cos(value.W);
+ }
+
+ /// <summary>
+ /// Takes the cosine of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the cosine of.</param>
+ /// <returns>A vector that contains the cosine of each component
in the input vector.</returns>
+ public static Vector4 Cos(Vector4 value)
+ {
+ Vector4 temp;
+ Cos(ref value, out temp);
+ return temp;
+ }
+
+ /// <summary>
+ /// Takes the tangent of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the tangent of.</param>
+ /// <param name="result">When the method completes, contains a
vector that contains the tangent of each component in the input
vector.</param>
+ public static void Tan(ref Vector4 value, out Vector4 result)
+ {
+ result.X = (float)Math.Tan(value.X);
+ result.Y = (float)Math.Tan(value.Y);
+ result.Z = (float)Math.Tan(value.Z);
+ result.W = (float)Math.Tan(value.W);
+ }
+
+ /// <summary>
+ /// Takes the tangent of each component in the vector.
+ /// </summary>
+ /// <param name="value">The vector to take the tangent of.</param>
+ /// <returns>A vector that contains the tangent of each component
in the input vector.</returns>
+ public static Vector4 Tan(Vector4 value)
+ {
+ Vector4 temp;
+ Tan(ref value, out temp);
+ return temp;
+ }
+ #endregion
+
+ /// <summary>
+ /// Adds two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to add.</param>
+ /// <param name="right">The second vector to add.</param>
+ /// <param name="result">When the method completes, contains the
sum of the two vectors.</param>
+ public static void Add(ref Vector4 left, ref Vector4 right, out
Vector4 result)
+ {
+ result = new Vector4(left.X + right.X, left.Y + right.Y,
left.Z + right.Z, left.W + right.W);
+ }
+
+ /// <summary>
+ /// Adds two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to add.</param>
+ /// <param name="right">The second vector to add.</param>
+ /// <returns>The sum of the two vectors.</returns>
+ public static Vector4 Add(Vector4 left, Vector4 right)
+ {
+ return new Vector4(left.X + right.X, left.Y + right.Y, left.Z
+ right.Z, left.W + right.W);
+ }
+
+ /// <summary>
+ /// Subtracts two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to subtract.</param>
+ /// <param name="right">The second vector to subtract.</param>
+ /// <param name="result">When the method completes, contains the
difference of the two vectors.</param>
+ public static void Subtract(ref Vector4 left, ref Vector4 right,
out Vector4 result)
+ {
+ result = new Vector4(left.X - right.X, left.Y - right.Y,
left.Z - right.Z, left.W - right.W);
+ }
+
+ /// <summary>
+ /// Subtracts two vectors.
+ /// </summary>
+ /// <param name="left">The first vector to subtract.</param>
+ /// <param name="right">The second vector to subtract.</param>
+ /// <returns>The difference of the two vectors.</returns>
+ public static Vector4 Subtract(Vector4 left, Vector4 right)
+ {
+ return new Vector4(left.X - right.X, left.Y - right.Y, left.Z
- right.Z, left.W - right.W);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <param name="result">When the method completes, contains the
scaled vector.</param>
+ public static void Multiply(ref Vector4 value, float scalar, out
Vector4 result)
+ {
+ result = new Vector4(value.X * scalar, value.Y * scalar,
value.Z * scalar, value.W * scalar);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <returns>The scaled vector.</returns>
+ public static Vector4 Multiply(Vector4 value, float scalar)
+ {
+ return new Vector4(value.X * scalar, value.Y * scalar, value.Z
* scalar, value.W * scalar);
+ }
+
+ /// <summary>
+ /// Modulates a vector with another by performing component-wise
multiplication.
+ /// </summary>
+ /// <param name="left">The first vector to modulate.</param>
+ /// <param name="right">The second vector to modulate.</param>
+ /// <param name="result">When the method completes, contains the
modulated vector.</param>
+ public static void Modulate(ref Vector4 left, ref Vector4 right,
out Vector4 result)
+ {
+ result = new Vector4(left.X * right.X, left.Y * right.Y,
left.Z * right.Z, left.W * right.W);
+ }
+
+ /// <summary>
+ /// Modulates a vector with another by performing component-wise
multiplication.
+ /// </summary>
+ /// <param name="left">The first vector to modulate.</param>
+ /// <param name="right">The second vector to modulate.</param>
+ /// <returns>The modulated vector.</returns>
+ public static Vector4 Modulate(Vector4 left, Vector4 right)
+ {
+ return new Vector4(left.X * right.X, left.Y * right.Y, left.Z
* right.Z, left.W * right.W);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <param name="result">When the method completes, contains the
scaled vector.</param>
+ public static void Divide(ref Vector4 value, float scalar, out
Vector4 result)
+ {
+ result = new Vector4(value.X / scalar, value.Y / scalar,
value.Z / scalar, value.W / scalar);
+ }
+
+ /// <summary>
+ /// Scales a vector by the given value.
+ /// </summary>
+ /// <param name="value">The vector to scale.</param>
+ /// <param name="scalar">The amount by which to scale the
vector.</param>
+ /// <returns>The scaled vector.</returns>
+ public static Vector4 Divide(Vector4 value, float scalar)
+ {
+ return new Vector4(value.X / scalar, value.Y / scalar, value.Z
/ scalar, value.W / scalar);
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given vector.
+ /// </summary>
+ /// <param name="value">The vector to negate.</param>
+ /// <param name="result">When the method completes, contains a
vector facing in the opposite direction.</param>
+ public static void Negate(ref Vector4 value, out Vector4 result)
+ {
+ result = new Vector4(-value.X, -value.Y, -value.Z, -value.W);
+ }
+
+ /// <summary>
+ /// Reverses the direction of a given vector.
+ /// </summary>
+ /// <param name="value">The vector to negate.</param>
+ /// <returns>A vector facing in the opposite direction.</returns>
+ public static Vector4 Negate(Vector4 value)
+ {
+ return new Vector4(-value.X, -value.Y, -value.Z, -value.W);
+ }
+
+ /// <summary>
+ /// Takes the absolute value of each component.
+ /// </summary>
+ /// <param name="value">The vector to take the absolute value
of.</param>
+ /// <param name="result">When the method completes, contains a
vector that has all positive components.</param>
+ public static void Abs(ref Vector4 value, out Vector4 result)
+ {
+ result = new Vector4(Math.Abs(value.X), Math.Abs(value.Y),
Math.Abs(value.Z), Math.Abs(value.W));
+ }
+
+ /// <summary>
+ /// Takes the absolute value of each component.
+ /// </summary>
+ /// <param name="value">The vector to take the absolute value
of.</param>
+ /// <returns>A vector that has all positive components.</returns>
+ public static Vector4 Abs(Vector4 value)
+ {
+ return new Vector4(Math.Abs(value.X), Math.Abs(value.Y),
Math.Abs(value.Z), Math.Abs(value.W));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="SlimMath.Vector4"/> containing the 4D
Cartesian coordinates of a point specified in Barycentric coordinates
relative to a 4D triangle.
+ /// </summary>
+ /// <param name="value1">A <see cref="SlimMath.Vector4"/>
containing the 4D Cartesian coordinates of vertex 1 of the triangle.</param>
+ /// <param name="value2">A <see cref="SlimMath.Vector4"/>
containing the 4D Cartesian coordinates of vertex 2 of the triangle.</param>
+ /// <param name="value3">A <see cref="SlimMath.Vector4"/>
containing the 4D Cartesian coordinates of vertex 3 of the triangle.</param>
+ /// <param name="amount1">Barycentric coordinate b2, which
expresses the weighting factor toward vertex 2 (specified in <paramref
name="value2"/>).</param>
+ /// <param name="amount2">Barycentric coordinate b3, which
expresses the weighting factor toward vertex 3 (specified in <paramref
name="value3"/>).</param>
+ /// <param name="result">When the method completes, contains the
4D Cartesian coordinates of the specified point.</param>
+ public static void Barycentric(ref Vector4 value1, ref Vector4
value2, ref Vector4 value3, float amount1, float amount2, out Vector4
result)
+ {
+ result = new Vector4(
+ (value1.X + (amount1 * (value2.X - value1.X))) + (amount2
* (value3.X - value1.X)),
+ (value1.Y + (amount1 * (value2.Y - value1.Y))) + (amount2
* (value3.Y - value1.Y)),
+ (value1.Z + (amount1 * (value2.Z - value1.Z))) + (amount2
* (value3.Z - value1.Z)),
+ (value1.W + (amount1 * (value2.W - value1.W))) + (amount2
* (value3.W - value1.W)));
+ }
+
+ /// <summary>
+ /// Returns a <see cref="SlimMath.Vector4"/> containing the 4D
Cartesian coordinates of a point specified in Barycentric coordinates
relative to a 4D triangle.
+ /// </summary>
+ /// <param name="value1">A <see cref="SlimMath.Vector4"/>
containing the 4D Cartesian coordinates of vertex 1 of the triangle.</param>
+ /// <param name="value2">A <see cref="SlimMath.Vector4"/>
containing the 4D Cartesian coordinates of vertex 2 of the triangle.</param>
+ /// <param name="value3">A <see cref="SlimMath.Vector4"/>
containing the 4D Cartesian coordinates of vertex 3 of the triangle.</param>
+ /// <param name="amount1">Barycentric coordinate b2, which
expresses the weighting factor toward vertex 2 (specified in <paramref
name="value2"/>).</param>
+ /// <param name="amount2">Barycentric coordinate b3, which
expresses the weighting factor toward vertex 3 (specified in <paramref
name="value3"/>).</param>
+ /// <returns>A new <see cref="SlimMath.Vector4"/> containing the
4D Cartesian coordinates of the specified point.</returns>
+ public static Vector4 Barycentric(Vector4 value1, Vector4 value2,
Vector4 value3, float amount1, float amount2)
+ {
+ Vector4 result;
+ Barycentric(ref value1, ref value2, ref value3, amount1,
amount2, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <param name="result">When the method completes, contains the
clamped value.</param>
+ public static void Clamp(ref Vector4 value, ref Vector4 min, ref
Vector4 max, out Vector4 result)
+ {
+ float x = value.X;
+ x = (x > max.X) ? max.X : x;
+ x = (x < min.X) ? min.X : x;
+
+ float y = value.Y;
+ y = (y > max.Y) ? max.Y : y;
+ y = (y < min.Y) ? min.Y : y;
+
+ float z = value.Z;
+ z = (z > max.Z) ? max.Z : z;
+ z = (z < min.Z) ? min.Z : z;
+
+ float w = value.W;
+ w = (w > max.W) ? max.W : w;
+ w = (w < min.W) ? min.W : w;
+
+ result = new Vector4(x, y, z, w);
+ }
+
+ /// <summary>
+ /// Restricts a value to be within a specified range.
+ /// </summary>
+ /// <param name="value">The value to clamp.</param>
+ /// <param name="min">The minimum value.</param>
+ /// <param name="max">The maximum value.</param>
+ /// <returns>The clamped value.</returns>
+ public static Vector4 Clamp(Vector4 value, Vector4 min, Vector4
max)
+ {
+ Vector4 result;
+ Clamp(ref value, ref min, ref max, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Calculates the distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <param name="result">When the method completes, contains the
distance between the two vectors.</param>
+ /// <remarks>
+ /// <see cref="SlimMath.Vector4.DistanceSquared(ref Vector4, ref
Vector4, out float)"/> may be preferred when only the relative distance is
needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public static void Distance(ref Vector4 value1, ref Vector4
value2, out float result)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+ float z = value1.Z - value2.Z;
+ float w = value1.W - value2.W;
+
+ result = (float)Math.Sqrt((x * x) + (y * y) + (z * z) + (w *
w));
+ }
+
+ /// <summary>
+ /// Calculates the distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <returns>The distance between the two vectors.</returns>
+ /// <remarks>
+ /// <see cref="SlimMath.Vector4.DistanceSquared(Vector4,
Vector4)"/> may be preferred when only the relative distance is needed
+ /// and speed is of the essence.
+ /// </remarks>
+ public static float Distance(Vector4 value1, Vector4 value2)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+ float z = value1.Z - value2.Z;
+ float w = value1.W - value2.W;
+
+ return (float)Math.Sqrt((x * x) + (y * y) + (z * z) + (w * w));
+ }
+
+ /// <summary>
+ /// Calculates the squared distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <param name="result">When the method completes, contains the
squared distance between the two vectors.</param>
+ /// <remarks>Distance squared is the value before taking the
square root.
+ /// Distance squared can often be used in place of distance if
relative comparisons are being made.
+ /// For example, consider three points A, B, and C. To determine
whether B or C is further from A,
+ /// compare the distance between A and B to the distance between A
and C. Calculating the two distances
+ /// involves two square roots, which are computationally
expensive. However, using distance squared
+ /// provides the same information and avoids calculating two
square roots.
+ /// </remarks>
+ public static void DistanceSquared(ref Vector4 value1, ref Vector4
value2, out float result)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+ float z = value1.Z - value2.Z;
+ float w = value1.W - value2.W;
+
+ result = (x * x) + (y * y) + (z * z) + (w * w);
+ }
+
+ /// <summary>
+ /// Calculates the squared distance between two vectors.
+ /// </summary>
+ /// <param name="value1">The first vector.</param>
+ /// <param name="value2">The second vector.</param>
+ /// <returns>The squared distance between the two
vectors.</returns>
+ /// <remarks>Distance squared is the value before taking the
square root.
+ /// Distance squared can often be used in place of distance if
relative comparisons are being made.
+ /// For example, consider three points A, B, and C. To determine
whether B or C is further from A,
+ /// compare the distance between A and B to the distance between A
and C. Calculating the two distances
+ /// involves two square roots, which are computationally
expensive. However, using distance squared
+ /// provides the same information and avoids calculating two
square roots.
+ /// </remarks>
+ public static float DistanceSquared(Vector4 value1, Vector4 value2)
+ {
+ float x = value1.X - value2.X;
+ float y = value1.Y - value2.Y;
+ float z = value1.Z - value2.Z;
+ float w = value1.W - value2.W;
+
+ return (x * x) + (y * y) + (z * z) + (w * w);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of two vectors.
+ /// </summary>
+ /// <param name="left">First source vector</param>
+ /// <param name="right">Second source vector.</param>
+ /// <param name="result">When the method completes, contains the
dot product of the two vectors.</param>
+ public static void Dot(ref Vector4 left, ref Vector4 right, out
float result)
+ {
+ result = (left.X * right.X) + (left.Y * right.Y) + (left.Z *
right.Z) + (left.W * right.W);
+ }
+
+ /// <summary>
+ /// Calculates the dot product of two vectors.
+ /// </summary>
+ /// <param name="left">First source vector.</param>
+ /// <param name="right">Second source vector.</param>
+ /// <returns>The dot product of the two vectors.</returns>
+ public static float Dot(Vector4 left, Vector4 right)
+ {
+ return (left.X * right.X) + (left.Y * right.Y) + (left.Z *
right.Z) + (left.W * right.W);
+ }
+
+ /// <summary>
+ /// Converts the vector into a unit vector.
+ /// </summary>
+ /// <param name="value">The vector to normalize.</param>
+ /// <param name="result">When the method completes, contains the
normalized vector.</param>
+ public static void Normalize(ref Vector4 value, out Vector4 result)
+ {
+ Vector4 temp = value;
+ result = temp;
+ result.Normalize();
+ }
+
+ /// <summary>
+ /// Converts the vector into a unit vector.
+ /// </summary>
+ /// <param name="value">The vector to normalize.</param>
+ /// <returns>The normalized vector.</returns>
+ public static Vector4 Normalize(Vector4 value)
+ {
+ value.Normalize();
+ return value;
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
linear interpolation of the two vectors.</param>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static void Lerp(ref Vector4 start, ref Vector4 end, float
amount, out Vector4 result)
+ {
+ result.X = start.X + ((end.X - start.X) * amount);
+ result.Y = start.Y + ((end.Y - start.Y) * amount);
+ result.Z = start.Z + ((end.Z - start.Z) * amount);
+ result.W = start.W + ((end.W - start.W) * amount);
+ }
+
+ /// <summary>
+ /// Performs a linear interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The linear interpolation of the two vectors.</returns>
+ /// <remarks>
+ /// This method performs the linear interpolation based on the
following formula.
+ /// <code>start + (end - start) * amount</code>
+ /// Passing <paramref name="amount"/> a value of 0 will cause
<paramref name="start"/> to be returned; a value of 1 will cause <paramref
name="end"/> to be returned.
+ /// </remarks>
+ public static Vector4 Lerp(Vector4 start, Vector4 end, float
amount)
+ {
+ Vector4 result;
+ Lerp(ref start, ref end, amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <param name="result">When the method completes, contains the
cubic interpolation of the two vectors.</param>
+ public static void SmoothStep(ref Vector4 start, ref Vector4 end,
float amount, out Vector4 result)
+ {
+ amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f :
amount);
+ amount = (amount * amount) * (3.0f - (2.0f * amount));
+
+ result.X = start.X + ((end.X - start.X) * amount);
+ result.Y = start.Y + ((end.Y - start.Y) * amount);
+ result.Z = start.Z + ((end.Z - start.Z) * amount);
+ result.W = start.W + ((end.W - start.W) * amount);
+ }
+
+ /// <summary>
+ /// Performs a cubic interpolation between two vectors.
+ /// </summary>
+ /// <param name="start">Start vector.</param>
+ /// <param name="end">End vector.</param>
+ /// <param name="amount">Value between 0 and 1 indicating the
weight of <paramref name="end"/>.</param>
+ /// <returns>The cubic interpolation of the two vectors.</returns>
+ public static Vector4 SmoothStep(Vector4 start, Vector4 end, float
amount)
+ {
+ Vector4 result;
+ SmoothStep(ref start, ref end, amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a Hermite spline interpolation.
+ /// </summary>
+ /// <param name="value1">First source position vector.</param>
+ /// <param name="tangent1">First source tangent vector.</param>
+ /// <param name="value2">Second source position vector.</param>
+ /// <param name="tangent2">Second source tangent vector.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <param name="result">When the method completes, contains the
result of the Hermite spline interpolation.</param>
+ public static void Hermite(ref Vector4 value1, ref Vector4
tangent1, ref Vector4 value2, ref Vector4 tangent2, float amount, out
Vector4 result)
+ {
+ float squared = amount * amount;
+ float cubed = amount * squared;
+ float part1 = ((2.0f * cubed) - (3.0f * squared)) + 1.0f;
+ float part2 = (-2.0f * cubed) + (3.0f * squared);
+ float part3 = (cubed - (2.0f * squared)) + amount;
+ float part4 = cubed - squared;
+
+ result = new Vector4(
+ (((value1.X * part1) + (value2.X * part2)) + (tangent1.X *
part3)) + (tangent2.X * part4),
+ (((value1.Y * part1) + (value2.Y * part2)) + (tangent1.Y *
part3)) + (tangent2.Y * part4),
+ (((value1.Z * part1) + (value2.Z * part2)) + (tangent1.Z *
part3)) + (tangent2.Z * part4),
+ (((value1.W * part1) + (value2.W * part2)) + (tangent1.W *
part3)) + (tangent2.W * part4));
+ }
+
+ /// <summary>
+ /// Performs a Hermite spline interpolation.
+ /// </summary>
+ /// <param name="value1">First source position vector.</param>
+ /// <param name="tangent1">First source tangent vector.</param>
+ /// <param name="value2">Second source position vector.</param>
+ /// <param name="tangent2">Second source tangent vector.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <returns>The result of the Hermite spline
interpolation.</returns>
+ public static Vector4 Hermite(Vector4 value1, Vector4 tangent1,
Vector4 value2, Vector4 tangent2, float amount)
+ {
+ Vector4 result;
+ Hermite(ref value1, ref tangent1, ref value2, ref tangent2,
amount, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// Performs a Catmull-Rom interpolation using the specified
positions.
+ /// </summary>
+ /// <param name="value1">The first position in the
interpolation.</param>
+ /// <param name="value2">The second position in the
interpolation.</param>
+ /// <param name="value3">The third position in the
interpolation.</param>
+ /// <param name="value4">The fourth position in the
interpolation.</param>
+ /// <param name="amount">Weighting factor.</param>
+ /// <param name="result">When the method completes, contains the
result of the Catmull-Rom interpolation.</param>
+ public static void CatmullRom(ref Vector4 value1, ref Vector4
value2, ref Vector4 value3, ref Vector4 value4, float amount, out Vector4
result)
+ {
+ float squared = amount * amount;
+ float cubed = amount * squared;
+
+ result.X = 0.5f * ((((2.0f * value2.X) + ((-value1.X +
value3.X) * amount)) +
+ (((((2.0f * value1.X) - (5.0f * value2.X)) + (4.0f *
value3.X)) - value4.X) * squared)) +
+ ((((-value1.X + (3.0f * value2.X)) - (3.0f * value3.X)) +
value4.X) * cubed));
+
+ result.Y = 0.5f * ((((2.0f * value2.Y) + ((-value1.Y +
value3.Y) * amount)) +
+ (((((2.0f * value1.Y) - (5.0f * value2.Y)) + (4.0f *
value3.Y)) - value4.Y) * squared)) +
+ ((((-value1.Y + (3.0f * value2.Y)) - (3.0f * value3.Y)) +
value4.Y) * cubed));
+
+ result.Z = 0.5f * ((((2.0f * value2.Z) + ((-value1.Z +
value3.Z) * amount)) +
+ (((((2.0f * value1.Z) - (5.0f * value2.Z)) + (4.0f *
value3.Z)) - value4.Z) * squared)) +
+ ((((-value1.Z + (3.0f * value2.Z)) - (3.0f * value3.Z)) +
value4.Z) * cubed));
+
+ result.W = 0.5f * ((((2.0f * value2.W) + ((-value1.W +
value3.W) * amount)) +
+ (((((2.0f * value1.W) - (5.0f * value2.W)) + (4.0f *
value3.W)) - value4.W) * squared)) +
+ ((((-value1.W + (3.0f * value2.W)) - (3.0f * value3.W)) +
value4.W) * cubed));
+ }
+
+ /// <summary>
+ /// Performs a Catmull-Rom interpolation using the specified
positions.
+ /// </summary>
+ /// <param name="value1">The first position in the
interpolation.</param>
+ /// <param name="value2">The second position in the
interpolation.</param>
+ /// <param name="value3">The third position in the
interpolation.</param>
+ /// <param name="value4">The fourth position in the
interpolation.</param>
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /branches/vs2013/build/CustomDictionary.xml Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,91 @@
+<Dictionary>
+ <Words>
+ <Recognized>
+ <Word>A</Word>
+ <Word>B</Word>
+ <Word>C</Word>
+ <Word>D</Word>
+ <Word>E</Word>
+ <Word>F</Word>
+ <Word>G</Word>
+ <Word>H</Word>
+ <Word>I</Word>
+ <Word>J</Word>
+ <Word>K</Word>
+ <Word>L</Word>
+ <Word>M</Word>
+ <Word>N</Word>
+ <Word>O</Word>
+ <Word>P</Word>
+ <Word>Q</Word>
+ <Word>R</Word>
+ <Word>S</Word>
+ <Word>T</Word>
+ <Word>U</Word>
+ <Word>V</Word>
+ <Word>W</Word>
+ <Word>X</Word>
+ <Word>Y</Word>
+ <Word>Z</Word>
+ <Word>Unacquire</Word>
+ <Word>Prerotated</Word>
+ <Word>Scanline</Word>
+ <Word>Typeless</Word>
+ <Word>Shader</Word>
+ <Word>Unmap</Word>
+ <Word>Rasterizer</Word>
+ <Word>Johab</Word>
+ <Word>Bytecode</Word>
+ <Word>Preshader</Word>
+ <Word>Multisample</Word>
+ <Word>Antialiased</Word>
+ <Word>Specular</Word>
+ <Word>Allocator</Word>
+ <Word>Maskable</Word>
+ <Word>Catmull</Word>
+ <Word>Multi</Word>
+ <Word>Multisampled</Word>
+ <Word>Quadrophonic</Word>
+ <Word>Presampled</Word>
+ <Word>Binormal</Word>
+ <Word>Orthogonalize</Word>
+ <Word>Normals</Word>
+ <Word>Gouraud</Word>
+ <Word>Antialias</Word>
+ <Word>Tween</Word>
+ <Word>Keyframed</Word>
+ <Word>Lossiness</Word>
+ <Word>Unkey</Word>
+ <Word>Mag</Word>
+ <Word>Min</Word>
+ <Word>Mip</Word>
+ <Word>Coord</Word>
+ <Word>Premodulate</Word>
+ <Word>Barycentric</Word>
+ <Word>Hermite</Word>
+ <Word>Unproject</Word>
+ <Word>Quintic</Word>
+ <Word>Blit</Word>
+ <Word>Tweening</Word>
+ <Word>Rasterization</Word>
+ <Word>Offscreen</Word>
+ <Word>Resettable</Word>
+ <Word>Polyline</Word>
+ <Word>Multiselect</Word>
+ <Word>Submix</Word>
+ <Word>Subresource</Word>
+ <Word>Unpruned</Word>
+ <Word>Flanger</Word>
+ <Word>Rolloff</Word>
+ <Word>Resampler</Word>
+ <Word>Renderer</Word>
+ <Word>Rasterized</Word>
+ <Word>Tessellator</Word>
+ <Word>Indexable</Word>
+ <Word>Denormalize</Word>
+ <Word>Lod</Word>
+ <Word>Unparseable</Word>
+ <Word>Precompute</Word>
+ </Recognized>
+ </Words>
+</Dictionary>
=======================================
--- /dev/null
+++ /branches/vs2013/build/SlimDX.FxCop Sun May 18 20:39:07 2014 UTC
File is too large to display a diff.
=======================================
--- /dev/null
+++ /branches/vs2013/build/SlimDX.sln Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,36 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}")
= "SlimDX", "SlimDX.vcxproj", "{8ECCE443-0440-40F4-A94C-F02E027282C3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "SlimMath", "..\SlimMath\SlimMath.csproj", "{820FE441-822F-4519-994B-04F1DE27FF15}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8ECCE443-0440-40F4-A94C-F02E027282C3}.Debug|x64.ActiveCfg = Debug|x64
+ {8ECCE443-0440-40F4-A94C-F02E027282C3}.Debug|x64.Build.0 = Debug|x64
+ {8ECCE443-0440-40F4-A94C-F02E027282C3}.Debug|x86.ActiveCfg = Debug|Win32
+ {8ECCE443-0440-40F4-A94C-F02E027282C3}.Debug|x86.Build.0 = Debug|Win32
+ {8ECCE443-0440-40F4-A94C-F02E027282C3}.Release|x64.ActiveCfg = Release|
x64
+ {8ECCE443-0440-40F4-A94C-F02E027282C3}.Release|x64.Build.0 = Release|x64
+ {8ECCE443-0440-40F4-A94C-F02E027282C3}.Release|x86.ActiveCfg = Release|
Win32
+ {8ECCE443-0440-40F4-A94C-F02E027282C3}.Release|x86.Build.0 = Release|
Win32
+ {820FE441-822F-4519-994B-04F1DE27FF15}.Debug|x64.ActiveCfg = Debug|Any
CPU
+ {820FE441-822F-4519-994B-04F1DE27FF15}.Debug|x64.Build.0 = Debug|Any CPU
+ {820FE441-822F-4519-994B-04F1DE27FF15}.Debug|x86.ActiveCfg = Debug|Any
CPU
+ {820FE441-822F-4519-994B-04F1DE27FF15}.Debug|x86.Build.0 = Debug|Any CPU
+ {820FE441-822F-4519-994B-04F1DE27FF15}.Release|x64.ActiveCfg = Release|
Any CPU
+ {820FE441-822F-4519-994B-04F1DE27FF15}.Release|x64.Build.0 = Release|Any
CPU
+ {820FE441-822F-4519-994B-04F1DE27FF15}.Release|x86.ActiveCfg = Release|
Any CPU
+ {820FE441-822F-4519-994B-04F1DE27FF15}.Release|x86.Build.0 = Release|Any
CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
=======================================
--- /dev/null
+++ /branches/vs2013/build/SlimDX.vcxproj Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,667 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0"
xmlns="
http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{8ECCE443-0440-40F4-A94C-F02E027282C3}</ProjectGuid>
+ <RootNamespace>SlimDX</RootNamespace>
+ <Keyword>ManagedCProj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|
Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <CLRSupport>true</CLRSupport>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <CLRSupport>true</CLRSupport>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"
Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <CLRSupport>true</CLRSupport>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"
Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <CLRSupport>true</CLRSupport>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"
Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"
Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"
Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|
Win32'">$(SolutionDir)x86\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|
Win32'">$(SolutionDir)x86\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|
Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|
x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|
x64'">$(SolutionDir)$(Platform)\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|
x64'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|
Win32'">$(SolutionDir)..\..\..\External\slimdx\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|
Win32'">$(SolutionDir)x86\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|
Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|
x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|
x64'">$(SolutionDir)$(Platform)\$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|
x64'">false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|
Win32'">
+ <LinkKeyFile>
+ </LinkKeyFile>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|
Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+
<PreprocessorDefinitions>WIN32;_DEBUG;WINVER=0x600;_WIN32_WINNT=0x600;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
+ <GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
+ <WarningLevel>Level4</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <AdditionalIncludeDirectories>
+ </AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+
<AdditionalDependencies>user32.lib;gdi32.lib;dxguid.lib;dxgi.lib;xinput9_1_0.lib;d3dcompiler.lib;d3d11.lib;dwrite.lib</AdditionalDependencies>
+ <Version>
+ </Version>
+
<AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+
<DelayLoadDLLs>d3dcompiler_47.dll;d3d11.dll;dwrite.dll;dxgi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AssemblyDebug>true</AssemblyDebug>
+ <LinkTimeCodeGeneration>
+ </LinkTimeCodeGeneration>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ <KeyFile>
+ </KeyFile>
+ <KeyContainer>
+ </KeyContainer>
+ <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|
x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>
+ </AdditionalIncludeDirectories>
+
<PreprocessorDefinitions>WIN32;_DEBUG;WINVER=0x600;_WIN32_WINNT=0x600;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
+ <GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
+ <WarningLevel>Level4</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+
<AdditionalDependencies>user32.lib;gdi32.lib;dxguid.lib;dxgi.lib;xinput9_1_0.lib;d3dcompiler.lib;d3d11.lib;dwrite.lib</AdditionalDependencies>
+ <Version>
+ </Version>
+
<AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+
<DelayLoadDLLs>d3dcompiler_47.dll;d3d11.dll;dwrite.dll;dxgi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AssemblyDebug>true</AssemblyDebug>
+ <LinkTimeCodeGeneration>
+ </LinkTimeCodeGeneration>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX64</TargetMachine>
+ <KeyFile>
+ </KeyFile>
+ <KeyContainer>
+ </KeyContainer>
+ <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|
Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+
<PreprocessorDefinitions>WIN32;NDEBUG;WINVER=0x600;_WIN32_WINNT=0x600;XMLDOCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FloatingPointModel>Precise</FloatingPointModel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
+ <GenerateXMLDocumentationFiles>true</GenerateXMLDocumentationFiles>
+ <XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
+ <WarningLevel>Level4</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <AdditionalIncludeDirectories>
+ </AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+
<AdditionalDependencies>user32.lib;gdi32.lib;dxguid.lib;dxgi.lib;xinput9_1_0.lib;d3dcompiler.lib;d3d11.lib;dwrite.lib</AdditionalDependencies>
+ <Version>
+ </Version>
+ <AdditionalLibraryDirectories>
+ </AdditionalLibraryDirectories>
+
<DelayLoadDLLs>d3dcompiler_47.dll;d3d11.dll;dwrite.dll;dxgi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX86</TargetMachine>
+ <KeyFile>
+ </KeyFile>
+ <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+ <KeyContainer>
+ </KeyContainer>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|
x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>
+ </AdditionalIncludeDirectories>
+
<PreprocessorDefinitions>WIN32;NDEBUG;WINVER=0x600;_WIN32_WINNT=0x600;XMLDOCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
+ <GenerateXMLDocumentationFiles>true</GenerateXMLDocumentationFiles>
+ <XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
+ <WarningLevel>Level4</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+
<AdditionalDependencies>user32.lib;gdi32.lib;dxguid.lib;dxgi.lib;xinput9_1_0.lib;d3dcompiler.lib;d3d11.lib;dwrite.lib</AdditionalDependencies>
+ <Version>
+ </Version>
+ <AdditionalLibraryDirectories>
+ </AdditionalLibraryDirectories>
+
<DelayLoadDLLs>d3dcompiler_47.dll;d3d11.dll;dwrite.dll;dxgi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ <TargetMachine>MachineX64</TargetMachine>
+ <KeyFile>
+ </KeyFile>
+ <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+ <IgnoreAllDefaultLibraries>
+ </IgnoreAllDefaultLibraries>
+ <KeyContainer>
+ </KeyContainer>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Reference Include="System">
+ <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </Reference>
+ <Reference Include="System.Core" />
+ <Reference Include="System.Drawing">
+ <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </Reference>
+ <Reference Include="System.Data">
+ <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </Reference>
+ <Reference Include="System.Xml">
+ <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\source\ComObject.cpp" />
+ <ClCompile Include="..\source\CompilationException.cpp" />
+ <ClCompile Include="..\source\Configuration.cpp" />
+ <ClCompile Include="..\source\direct3d11\PerfAnnotation.cpp" />
+ <ClCompile Include="..\source\direct3d11\TextureLoader.cpp" />
+ <ClCompile Include="..\source\directwrite\BitmapRenderTargetDW.cpp" />
+ <ClCompile Include="..\source\directwrite\DirectWriteException.cpp" />
+ <ClCompile Include="..\source\directwrite\FactoryDW.cpp" />
+ <ClCompile Include="..\source\directwrite\Font.cpp" />
+ <ClCompile Include="..\source\directwrite\FontCollection.cpp" />
+ <ClCompile Include="..\source\directwrite\FontCollectionLoader.cpp" />
+ <ClCompile Include="..\source\directwrite\FontFace.cpp" />
+ <ClCompile Include="..\source\directwrite\FontFamily.cpp" />
+ <ClCompile Include="..\source\directwrite\FontFeature.cpp" />
+ <ClCompile Include="..\source\directwrite\FontFile.cpp" />
+ <ClCompile Include="..\source\directwrite\FontFileAnalysis.cpp" />
+ <ClCompile Include="..\source\directwrite\FontFileEnumerator.cpp" />
+ <ClCompile Include="..\source\directwrite\FontFileLoader.cpp" />
+ <ClCompile Include="..\source\directwrite\FontFileStream.cpp" />
+ <ClCompile Include="..\source\directwrite\FontList.cpp" />
+ <ClCompile Include="..\source\directwrite\FontMetrics.cpp" />
+ <ClCompile Include="..\source\directwrite\FontTable.cpp" />
+ <ClCompile Include="..\source\directwrite\GdiInterop.cpp" />
+ <ClCompile Include="..\source\directwrite\GlyphMetrics.cpp" />
+ <ClCompile Include="..\source\directwrite\GlyphOffset.cpp" />
+ <ClCompile Include="..\source\directwrite\GlyphRunAnalysis.cpp" />
+ <ClCompile Include="..\source\directwrite\GlyphRunDescription.cpp" />
+ <ClCompile Include="..\source\directwrite\GlyphRunDW.cpp" />
+ <ClCompile Include="..\source\directwrite\IFontCollectionLoader.cpp" />
+ <ClCompile Include="..\source\directwrite\IFontFileLoader.cpp" />
+ <ClCompile Include="..\source\directwrite\InlineObject.cpp" />
+ <ClCompile Include="..\source\directwrite\ITextRenderer.cpp" />
+ <ClCompile Include="..\source\directwrite\LocalizedStrings.cpp" />
+ <ClCompile Include="..\source\directwrite\NumberSubstitution.cpp" />
+ <ClCompile Include="..\source\directwrite\PixelSnapping.cpp" />
+ <ClCompile Include="..\source\directwrite\RenderingParameters.cpp" />
+ <ClCompile Include="..\source\directwrite\ResultCodeDW.cpp" />
+ <ClCompile Include="..\source\directwrite\Strikethrough.cpp" />
+ <ClCompile Include="..\source\directwrite\TextAnalysisSink.cpp" />
+ <ClCompile Include="..\source\directwrite\TextAnalysisSource.cpp" />
+ <ClCompile Include="..\source\directwrite\TextAnalyzer.cpp" />
+ <ClCompile Include="..\source\directwrite\TextFormat.cpp" />
+ <ClCompile Include="..\source\directwrite\TextLayout.cpp" />
+ <ClCompile Include="..\source\directwrite\TextRange.cpp" />
+ <ClCompile Include="..\source\directwrite\Typography.cpp" />
+ <ClCompile Include="..\source\directwrite\Underline.cpp" />
+ <ClCompile Include="..\source\dxgi\DXGIExtensionMethods.cpp" />
+ <ClCompile Include="..\source\external\DDSTextureLoader.cpp" />
+ <ClCompile Include="..\source\external\dxerr.cpp" />
+ <ClCompile Include="..\source\ObjectTable.cpp" />
+ <ClCompile Include="..\source\Result.cpp" />
+ <ClCompile Include="..\source\SlimDXException.cpp" />
+ <ClCompile Include="..\source\Utilities.cpp" />
+ <ClCompile Include="..\source\DataBox.cpp" />
+ <ClCompile Include="..\source\DataRectangle.cpp" />
+ <ClCompile Include="..\source\DataStream.cpp" />
+ <ClCompile Include="..\source\xinput\ResultCodeXI.cpp" />
+ <ClCompile Include="..\source\xinput\XInputException.cpp" />
+ <ClCompile Include="..\source\xinput\Controller.cpp" />
+ <ClCompile Include="..\source\xinput\Gamepad.cpp" />
+ <ClCompile Include="..\source\xinput\State.cpp" />
+ <ClCompile Include="..\source\xinput\Vibration.cpp" />
+ <ClCompile Include="..\source\dxgi\DXGIException.cpp" />
+ <ClCompile Include="..\source\dxgi\ResultCodeDxgi.cpp" />
+ <ClCompile Include="..\source\dxgi\SwapChainDescription.cpp" />
+ <ClCompile Include="..\source\dxgi\SwapChainDxgi.cpp" />
+ <ClCompile Include="..\source\dxgi\Output.cpp" />
+ <ClCompile Include="..\source\dxgi\OutputDescription.cpp" />
+ <ClCompile Include="..\source\dxgi\Adapter.cpp" />
+ <ClCompile Include="..\source\dxgi\AdapterDescription.cpp" />
+ <ClCompile Include="..\source\dxgi\DeviceChildDxgi.cpp" />
+ <ClCompile Include="..\source\dxgi\DeviceDxgi.cpp" />
+ <ClCompile Include="..\source\dxgi\ResourceDxgi.cpp" />
+ <ClCompile Include="..\source\dxgi\Factory.cpp" />
+ <ClCompile Include="..\source\dxgi\GammaControl.cpp" />
+ <ClCompile Include="..\source\dxgi\GammaControlCapabilities.cpp" />
+ <ClCompile Include="..\source\dxgi\FrameStatistics.cpp" />
+ <ClCompile Include="..\source\dxgi\ModeDescription.cpp" />
+ <ClCompile Include="..\source\dxgi\SampleDescription.cpp" />
+ <ClCompile Include="..\source\dxgi\SurfaceDescription.cpp" />
+ <ClCompile Include="..\source\dxgi\SurfaceDxgi.cpp" />
+ <ClCompile Include="..\source\dxgi\ObjectDxgi.cpp" />
+ <ClCompile Include="..\source\dxgi\Adapter1.cpp" />
+ <ClCompile Include="..\source\dxgi\AdapterDescription1.cpp" />
+ <ClCompile Include="..\source\dxgi\Device1.cpp" />
+ <ClCompile Include="..\source\dxgi\Factory1.cpp" />
+ <ClCompile Include="..\source\dxgi\KeyedMutex.cpp" />
+ <ClCompile Include="..\source\dxgi\Surface1.cpp" />
+ <ClCompile Include="..\source\windows\NativeWindow.cpp" />
+ <ClCompile Include="..\source\windows\DisplayMonitor.cpp" />
+ <ClCompile Include="..\source\direct3d11\Direct3D11Exception.cpp" />
+ <ClCompile Include="..\source\direct3d11\ResultCode11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Buffer11.cpp" />
+ <ClCompile Include="..\source\direct3d11\BufferDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\VertexBufferBinding11.cpp" />
+ <ClCompile Include="..\source\direct3d11\CommandList11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Device11.cpp" />
+ <ClCompile Include="..\source\direct3d11\DeviceChild11.cpp" />
+ <ClCompile Include="..\source\direct3d11\DeviceContext11.cpp" />
+ <ClCompile Include="..\source\direct3d11\ComputeShaderWrapper11.cpp" />
+ <ClCompile Include="..\source\direct3d11\DomainShaderWrapper11.cpp" />
+ <ClCompile Include="..\source\direct3d11\GeometryShaderWrapper11.cpp"
/>
+ <ClCompile Include="..\source\direct3d11\HullShaderWrapper11.cpp" />
+ <ClCompile Include="..\source\direct3d11\InputAssemblerWrapper11.cpp"
/>
+ <ClCompile Include="..\source\direct3d11\OutputMergerWrapper11.cpp" />
+ <ClCompile Include="..\source\direct3d11\PixelShaderWrapper11.cpp" />
+ <ClCompile Include="..\source\direct3d11\RasterizerWrapper11.cpp" />
+ <ClCompile Include="..\source\direct3d11\StreamOutputWrapper11.cpp" />
+ <ClCompile Include="..\source\direct3d11\VertexShaderWrapper11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Counter11.cpp" />
+ <ClCompile Include="..\source\direct3d11\CounterCapabilities11.cpp" />
+ <ClCompile Include="..\source\direct3d11\CounterMetadata11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Debug11.cpp" />
+ <ClCompile Include="..\source\direct3d11\DebugMessage11.cpp" />
+ <ClCompile Include="..\source\direct3d11\InfoQueue11.cpp" />
+ <ClCompile Include="..\source\direct3d11\InfoQueueFilter11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\InfoQueueFilterDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Resource11.cpp" />
+ <ClCompile Include="..\source\direct3d11\ResourceRegion11.cpp" />
+ <ClCompile Include="..\source\direct3d11\ResourceView11.cpp" />
+ <ClCompile Include="..\source\direct3d11\DepthStencilView11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\DepthStencilViewDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\RenderTargetView11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\RenderTargetViewDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\ShaderResourceView11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\ShaderResourceViewDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\UnorderedAccessView11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\UnorderedAccessViewDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\ComputeShader11.cpp" />
+ <ClCompile Include="..\source\direct3d11\DomainShader11.cpp" />
+ <ClCompile Include="..\source\direct3d11\GeometryShader11.cpp" />
+ <ClCompile Include="..\source\direct3d11\HullShader11.cpp" />
+ <ClCompile Include="..\source\direct3d11\PixelShader11.cpp" />
+ <ClCompile Include="..\source\direct3d11\VertexShader11.cpp" />
+ <ClCompile Include="..\source\direct3d11\ClassInstance11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\ClassInstanceDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\ClassLinkage11.cpp" />
+ <ClCompile Include="..\source\direct3d11\BlendState11.cpp" />
+ <ClCompile Include="..\source\direct3d11\BlendStateDescription11.cpp"
/>
+ <ClCompile
Include="..\source\direct3d11\RenderTargetBlendDescription11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\DepthStencilOperationDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\DepthStencilState11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\DepthStencilStateDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\RasterizerState11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\RasterizerStateDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\SamplerDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\SamplerState11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Predicate11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Query11.cpp" />
+ <ClCompile Include="..\source\direct3d11\QueryDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\PipelineStatistics11.cpp" />
+ <ClCompile Include="..\source\direct3d11\StreamOutputStatistics11.cpp"
/>
+ <ClCompile Include="..\source\direct3d11\TimestampQueryData11.cpp" />
+ <ClCompile Include="..\source\direct3d11\InputElement11.cpp" />
+ <ClCompile Include="..\source\direct3d11\InputLayout11.cpp" />
+ <ClCompile
Include="..\source\direct3d11\StreamOutputBufferBinding11.cpp" />
+ <ClCompile Include="..\source\direct3d11\StreamOutputElement11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Texture1D11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Texture1DDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Texture2D11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Texture2DDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Texture3D11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Texture3DDescription11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Asynchronous11.cpp" />
+ <ClCompile Include="..\source\direct3d11\Viewport11.cpp" />
+ <ClCompile Include="..\source\d3dcompiler\D3DCompilerException.cpp" />
+ <ClCompile Include="..\source\d3dcompiler\IncludeDC.cpp" />
+ <ClCompile Include="..\source\d3dcompiler\ShaderMacroDC.cpp" />
+ <ClCompile Include="..\source\d3dcompiler\ShaderBytecodeDC.cpp" />
+ <ClCompile Include="..\source\d3dcompiler\ShaderSignatureDC.cpp" />
+ <ClCompile
Include="..\source\d3dcompiler\InputBindingDescriptionDC.cpp" />
+ <ClCompile Include="..\source\d3dcompiler\ShaderDescriptionDC.cpp" />
+ <ClCompile
Include="..\source\d3dcompiler\ShaderParameterDescriptionDC.cpp" />
+ <ClCompile Include="..\source\d3dcompiler\ShaderReflectionDC.cpp" />
+ <ClCompile Include="..\source\d3dcompiler\ConstantBufferDC.cpp" />
+ <ClCompile
Include="..\source\d3dcompiler\ConstantBufferDescriptionDC.cpp" />
+ <ClCompile Include="..\source\d3dcompiler\ShaderReflectionTypeDC.cpp"
/>
+ <ClCompile Include="..\source\d3dcompiler\ShaderTypeDescriptionDC.cpp"
/>
+ <ClCompile
Include="..\source\d3dcompiler\ShaderReflectionVariableDC.cpp" />
+ <ClCompile
Include="..\source\d3dcompiler\ShaderVariableDescriptionDC.cpp" />
+ <ClCompile Include="..\source\AssemblyInfo.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|
Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeaderFile Condition="'$(Configuration)|
$(Platform)'=='Debug|Win32'">stdafx.h</PrecompiledHeaderFile>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|
x64'">Create</PrecompiledHeader>
+ <PrecompiledHeaderFile Condition="'$(Configuration)|
$(Platform)'=='Debug|x64'">stdafx.h</PrecompiledHeaderFile>
+ <PrecompiledHeader Condition="'$(Configuration)|
$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeaderFile Condition="'$(Configuration)|
$(Platform)'=='Release|Win32'">stdafx.h</PrecompiledHeaderFile>
+ <PrecompiledHeader Condition="'$(Configuration)|
$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeaderFile Condition="'$(Configuration)|
$(Platform)'=='Release|x64'">stdafx.h</PrecompiledHeaderFile>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\source\auto_array.h" />
+ <ClInclude Include="..\source\CollectionShim.h" />
+ <ClInclude Include="..\source\ComObject.h" />
+ <ClInclude Include="..\source\ComObjectMacros.h" />
+ <ClInclude Include="..\source\CompilationException.h" />
+ <ClInclude Include="..\source\Configuration.h" />
+ <ClInclude Include="..\source\direct3d11\PerfAnnotation.h" />
+ <ClInclude Include="..\source\direct3d11\TextureLoader.h" />
+ <ClInclude Include="..\source\directwrite\BitmapRenderTargetDW.h" />
+ <ClInclude Include="..\source\directwrite\ClusterMetrics.h" />
+ <ClInclude Include="..\source\directwrite\DirectWriteException.h" />
+ <ClInclude Include="..\source\directwrite\Enums.h" />
+ <ClInclude Include="..\source\directwrite\FactoryDW.h" />
+ <ClInclude Include="..\source\directwrite\Font.h" />
+ <ClInclude Include="..\source\directwrite\FontCollection.h" />
+ <ClInclude Include="..\source\directwrite\FontCollectionLoader.h" />
+ <ClInclude Include="..\source\directwrite\FontFace.h" />
+ <ClInclude Include="..\source\directwrite\FontFamily.h" />
+ <ClInclude Include="..\source\directwrite\FontFeature.h" />
+ <ClInclude Include="..\source\directwrite\FontFile.h" />
+ <ClInclude Include="..\source\directwrite\FontFileAnalysis.h" />
+ <ClInclude Include="..\source\directwrite\FontFileEnumerator.h" />
+ <ClInclude Include="..\source\directwrite\FontFileLoader.h" />
+ <ClInclude Include="..\source\directwrite\FontFileStream.h" />
+ <ClInclude Include="..\source\directwrite\FontList.h" />
+ <ClInclude Include="..\source\directwrite\FontMetrics.h" />
+ <ClInclude Include="..\source\directwrite\FontTable.h" />
+ <ClInclude Include="..\source\directwrite\GdiInterop.h" />
+ <ClInclude Include="..\source\directwrite\GlyphMetrics.h" />
+ <ClInclude Include="..\source\directwrite\GlyphOffset.h" />
+ <ClInclude Include="..\source\directwrite\GlyphRunAnalysis.h" />
+ <ClInclude Include="..\source\directwrite\GlyphRunDescription.h" />
+ <ClInclude Include="..\source\directwrite\GlyphRunDW.h" />
+ <ClInclude Include="..\source\directwrite\HitTestMetrics.h" />
+ <ClInclude Include="..\source\directwrite\IClientDrawingEffect.h" />
+ <ClInclude Include="..\source\directwrite\IFontCollectionLoader.h" />
+ <ClInclude Include="..\source\directwrite\IFontFileLoader.h" />
+ <ClInclude Include="..\source\directwrite\InlineObject.h" />
+ <ClInclude Include="..\source\directwrite\InlineObjectMetrics.h" />
+ <ClInclude Include="..\source\directwrite\ITextRenderer.h" />
+ <ClInclude Include="..\source\directwrite\LineMetrics.h" />
+ <ClInclude Include="..\source\directwrite\LocalizedStrings.h" />
+ <ClInclude Include="..\source\directwrite\NumberSubstitution.h" />
+ <ClInclude Include="..\source\directwrite\OverhangMetrics.h" />
+ <ClInclude Include="..\source\directwrite\PixelSnapping.h" />
+ <ClInclude Include="..\source\directwrite\RenderingParameters.h" />
+ <ClInclude Include="..\source\directwrite\ResultCodeDW.h" />
+ <ClInclude Include="..\source\directwrite\Strikethrough.h" />
+ <ClInclude Include="..\source\directwrite\TextAnalysisSink.h" />
+ <ClInclude Include="..\source\directwrite\TextAnalysisSource.h" />
+ <ClInclude Include="..\source\directwrite\TextAnalyzer.h" />
+ <ClInclude Include="..\source\directwrite\TextFormat.h" />
+ <ClInclude Include="..\source\directwrite\TextLayout.h" />
+ <ClInclude Include="..\source\directwrite\TextMetrics.h" />
+ <ClInclude Include="..\source\directwrite\TextRange.h" />
+ <ClInclude Include="..\source\directwrite\Trimming.h" />
+ <ClInclude Include="..\source\directwrite\Typography.h" />
+ <ClInclude Include="..\source\directwrite\Underline.h" />
+ <ClInclude Include="..\source\dxgi\DXGIExtensionMethods.h" />
+ <ClInclude Include="..\source\Enums.h" />
+ <ClInclude Include="..\source\external\DDSTextureLoader.h" />
+ <ClInclude Include="..\source\external\dxerr.h" />
+ <ClInclude Include="..\source\InternalHelpers.h" />
+ <ClInclude Include="..\source\ObjectTable.h" />
+ <ClInclude Include="..\source\Result.h" />
+ <ClInclude Include="..\source\SlimDXException.h" />
+ <ClInclude Include="..\source\stack_array.h" />
+ <ClInclude Include="..\source\Utilities.h" />
+ <ClInclude Include="..\source\VersionConfig.h" />
+ <ClInclude Include="..\source\DataBox.h" />
+ <ClInclude Include="..\source\DataRectangle.h" />
+ <ClInclude Include="..\source\DataStream.h" />
+ <ClInclude Include="..\source\xinput\Enums.h" />
+ <ClInclude Include="..\source\xinput\ResultCodeXI.h" />
+ <ClInclude Include="..\source\xinput\XInputException.h" />
+ <ClInclude Include="..\source\xinput\Controller.h" />
+ <ClInclude Include="..\source\xinput\Gamepad.h" />
+ <ClInclude Include="..\source\xinput\State.h" />
+ <ClInclude Include="..\source\xinput\Vibration.h" />
+ <ClInclude Include="..\source\dxgi\DXGIException.h" />
+ <ClInclude Include="..\source\dxgi\Enums.h" />
+ <ClInclude Include="..\source\dxgi\ResultCodeDxgi.h" />
+ <ClInclude Include="..\source\dxgi\SwapChainDescription.h" />
+ <ClInclude Include="..\source\dxgi\SwapChainDxgi.h" />
+ <ClInclude Include="..\source\dxgi\Output.h" />
+ <ClInclude Include="..\source\dxgi\OutputDescription.h" />
+ <ClInclude Include="..\source\dxgi\Adapter.h" />
+ <ClInclude Include="..\source\dxgi\AdapterDescription.h" />
+ <ClInclude Include="..\source\dxgi\DeviceChildDxgi.h" />
+ <ClInclude Include="..\source\dxgi\DeviceDxgi.h" />
+ <ClInclude Include="..\source\dxgi\ResourceDxgi.h" />
+ <ClInclude Include="..\source\dxgi\Factory.h" />
+ <ClInclude Include="..\source\dxgi\GammaControl.h" />
+ <ClInclude Include="..\source\dxgi\GammaControlCapabilities.h" />
+ <ClInclude Include="..\source\dxgi\FrameStatistics.h" />
+ <ClInclude Include="..\source\dxgi\ModeDescription.h" />
+ <ClInclude Include="..\source\dxgi\SampleDescription.h" />
+ <ClInclude Include="..\source\dxgi\SurfaceDescription.h" />
+ <ClInclude Include="..\source\dxgi\SurfaceDxgi.h" />
+ <ClInclude Include="..\source\dxgi\ObjectDxgi.h" />
+ <ClInclude Include="..\source\dxgi\Adapter1.h" />
+ <ClInclude Include="..\source\dxgi\AdapterDescription1.h" />
+ <ClInclude Include="..\source\dxgi\Device1.h" />
+ <ClInclude Include="..\source\dxgi\Factory1.h" />
+ <ClInclude Include="..\source\dxgi\KeyedMutex.h" />
+ <ClInclude Include="..\source\dxgi\Surface1.h" />
+ <ClInclude Include="..\source\windows\NativeWindow.h" />
+ <ClInclude Include="..\source\windows\DisplayMonitor.h" />
+ <ClInclude Include="..\source\direct3d11\Direct3D11Exception.h" />
+ <ClInclude Include="..\source\direct3d11\Enums11.h" />
+ <ClInclude Include="..\source\direct3d11\ResultCode11.h" />
+ <ClInclude Include="..\source\direct3d11\Buffer11.h" />
+ <ClInclude Include="..\source\direct3d11\BufferDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\VertexBufferBinding11.h" />
+ <ClInclude Include="..\source\direct3d11\CommandList11.h" />
+ <ClInclude Include="..\source\direct3d11\Device11.h" />
+ <ClInclude Include="..\source\direct3d11\DeviceChild11.h" />
+ <ClInclude Include="..\source\direct3d11\DeviceContext11.h" />
+ <ClInclude Include="..\source\direct3d11\ComputeShaderWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\DomainShaderWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\GeometryShaderWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\HullShaderWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\InputAssemblerWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\OutputMergerWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\PixelShaderWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\RasterizerWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\StreamOutputWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\VertexShaderWrapper11.h" />
+ <ClInclude Include="..\source\direct3d11\Counter11.h" />
+ <ClInclude Include="..\source\direct3d11\CounterCapabilities11.h" />
+ <ClInclude Include="..\source\direct3d11\CounterMetadata11.h" />
+ <ClInclude Include="..\source\direct3d11\Debug11.h" />
+ <ClInclude Include="..\source\direct3d11\DebugMessage11.h" />
+ <ClInclude Include="..\source\direct3d11\DebugMessageId11.h" />
+ <ClInclude Include="..\source\direct3d11\InfoQueue11.h" />
+ <ClInclude Include="..\source\direct3d11\InfoQueueFilter11.h" />
+ <ClInclude
Include="..\source\direct3d11\InfoQueueFilterDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\Resource11.h" />
+ <ClInclude Include="..\source\direct3d11\ResourceRegion11.h" />
+ <ClInclude Include="..\source\direct3d11\ResourceView11.h" />
+ <ClInclude Include="..\source\direct3d11\DepthStencilView11.h" />
+ <ClInclude
Include="..\source\direct3d11\DepthStencilViewDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\RenderTargetView11.h" />
+ <ClInclude
Include="..\source\direct3d11\RenderTargetViewDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\ShaderResourceView11.h" />
+ <ClInclude
Include="..\source\direct3d11\ShaderResourceViewDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\UnorderedAccessView11.h" />
+ <ClInclude
Include="..\source\direct3d11\UnorderedAccessViewDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\ComputeShader11.h" />
+ <ClInclude Include="..\source\direct3d11\DomainShader11.h" />
+ <ClInclude Include="..\source\direct3d11\GeometryShader11.h" />
+ <ClInclude Include="..\source\direct3d11\HullShader11.h" />
+ <ClInclude Include="..\source\direct3d11\PixelShader11.h" />
+ <ClInclude Include="..\source\direct3d11\VertexShader11.h" />
+ <ClInclude Include="..\source\direct3d11\ClassInstance11.h" />
+ <ClInclude Include="..\source\direct3d11\ClassInstanceDescription11.h"
/>
+ <ClInclude Include="..\source\direct3d11\ClassLinkage11.h" />
+ <ClInclude Include="..\source\direct3d11\BlendState11.h" />
+ <ClInclude Include="..\source\direct3d11\BlendStateDescription11.h" />
+ <ClInclude
Include="..\source\direct3d11\RenderTargetBlendDescription11.h" />
+ <ClInclude
Include="..\source\direct3d11\DepthStencilOperationDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\DepthStencilState11.h" />
+ <ClInclude
Include="..\source\direct3d11\DepthStencilStateDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\RasterizerState11.h" />
+ <ClInclude
Include="..\source\direct3d11\RasterizerStateDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\SamplerDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\SamplerState11.h" />
+ <ClInclude Include="..\source\direct3d11\Predicate11.h" />
+ <ClInclude Include="..\source\direct3d11\Query11.h" />
+ <ClInclude Include="..\source\direct3d11\QueryDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\PipelineStatistics11.h" />
+ <ClInclude Include="..\source\direct3d11\StreamOutputStatistics11.h" />
+ <ClInclude Include="..\source\direct3d11\TimestampQueryData11.h" />
+ <ClInclude Include="..\source\direct3d11\InputElement11.h" />
+ <ClInclude Include="..\source\direct3d11\InputLayout11.h" />
+ <ClInclude
Include="..\source\direct3d11\StreamOutputBufferBinding11.h" />
+ <ClInclude Include="..\source\direct3d11\StreamOutputElement11.h" />
+ <ClInclude Include="..\source\direct3d11\Texture1D11.h" />
+ <ClInclude Include="..\source\direct3d11\Texture1DDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\Texture2D11.h" />
+ <ClInclude Include="..\source\direct3d11\Texture2DDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\Texture3D11.h" />
+ <ClInclude Include="..\source\direct3d11\Texture3DDescription11.h" />
+ <ClInclude Include="..\source\direct3d11\Asynchronous11.h" />
+ <ClInclude Include="..\source\direct3d11\Viewport11.h" />
+ <ClInclude Include="..\source\d3dcompiler\D3DCompilerException.h" />
+ <ClInclude Include="..\source\d3dcompiler\EnumsDC.h" />
+ <ClInclude Include="..\source\d3dcompiler\IncludeDC.h" />
+ <ClInclude Include="..\source\d3dcompiler\ShaderMacroDC.h" />
+ <ClInclude Include="..\source\d3dcompiler\ShaderBytecodeDC.h" />
+ <ClInclude Include="..\source\d3dcompiler\ShaderSignatureDC.h" />
+ <ClInclude Include="..\source\d3dcompiler\InputBindingDescriptionDC.h"
/>
+ <ClInclude Include="..\source\d3dcompiler\ShaderDescriptionDC.h" />
+ <ClInclude
Include="..\source\d3dcompiler\ShaderParameterDescriptionDC.h" />
+ <ClInclude Include="..\source\d3dcompiler\ShaderReflectionDC.h" />
+ <ClInclude Include="..\source\d3dcompiler\ConstantBufferDC.h" />
+ <ClInclude
Include="..\source\d3dcompiler\ConstantBufferDescriptionDC.h" />
+ <ClInclude Include="..\source\d3dcompiler\ShaderReflectionTypeDC.h" />
+ <ClInclude Include="..\source\d3dcompiler\ShaderTypeDescriptionDC.h" />
+ <ClInclude
Include="..\source\d3dcompiler\ShaderReflectionVariableDC.h" />
+ <ClInclude
Include="..\source\d3dcompiler\ShaderVariableDescriptionDC.h" />
+ <ClInclude Include="..\source\stdafx.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\SlimMath\SlimMath.csproj">
+ <Project>{820fe441-822f-4519-994b-04f1de27ff15}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="..\source\directwrite\ToDo.txt" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
=======================================
--- /dev/null
+++ /branches/vs2013/build/SlimDX.vcxproj.filters Sun May 18 20:39:07 2014
UTC
@@ -0,0 +1,1342 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0"
xmlns="
http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Base">
+
<UniqueIdentifier>{befd94d1-89fa-4d17-bee8-b53be3f54cb9}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Base\Data">
+
<UniqueIdentifier>{78133695-f3cf-419d-9bc0-4b000b45207e}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="XInput">
+
<UniqueIdentifier>{d7d1fd5f-4253-45f8-821a-dcc64f946ac7}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="XInput\Controller">
+
<UniqueIdentifier>{ea4d526f-aeb8-4f1a-a105-f081381baf53}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="XInput\State">
+
<UniqueIdentifier>{19e7d8c2-dec5-4bf1-b3a7-1d7a38a617f1}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI">
+
<UniqueIdentifier>{906459f4-9a52-4c7c-85f5-ed2682b59336}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Swap Chain">
+
<UniqueIdentifier>{e3adaec8-7899-4ab1-adef-164eb5f2e2a5}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Output">
+
<UniqueIdentifier>{7f5d4192-d79c-4a11-8211-fd652c41674a}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Adapter">
+
<UniqueIdentifier>{b5d1083f-e5ad-4ea4-a98f-0988f710da74}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Device">
+
<UniqueIdentifier>{c67a8f79-afc6-4735-bc51-0d242545ea37}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Resource">
+
<UniqueIdentifier>{5b970446-adf5-4af6-b96c-abfc33bb5248}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Factory">
+
<UniqueIdentifier>{0e0ec50d-f731-4cd4-a6eb-9bf6da5ad738}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Gamma">
+
<UniqueIdentifier>{59b73a63-51a2-4f91-a1ba-eff9f7cea25d}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Statistics">
+
<UniqueIdentifier>{55edb9e5-5581-4302-8456-07055e574ea3}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Display Mode">
+
<UniqueIdentifier>{a3946fed-7489-4478-9b08-c3724dd6a6ec}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Surface">
+
<UniqueIdentifier>{fa57b6e9-a589-4404-8ac0-4682fff1d96b}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\Object">
+
<UniqueIdentifier>{ae0823f7-e86e-4cbd-8826-b8cf64544536}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DXGI\1.1">
+
<UniqueIdentifier>{b25e75c4-304a-4000-83c0-327654718fa7}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Windows">
+
<UniqueIdentifier>{0a03be1d-1d74-4a8e-83ae-b1999b4ca81a}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Windows\DisplayMonitor">
+
<UniqueIdentifier>{4a34c9b6-7903-40f3-830a-9f200cdff2c0}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11">
+
<UniqueIdentifier>{8f949bf1-7442-4141-a7de-05e1bae06760}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Buffer">
+
<UniqueIdentifier>{c7b1b57b-a1d8-4af2-898b-dc2e662704d2}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Device">
+
<UniqueIdentifier>{62fbed3e-f259-4d07-9683-cb27be6287b7}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Device\Pipeline Wrappers">
+
<UniqueIdentifier>{a77afaca-915d-4d09-8b9c-0f4ca4329326}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Diagnostics">
+
<UniqueIdentifier>{e2181f01-5056-4767-a190-36843177765d}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Diagnostics\InfoQueue">
+
<UniqueIdentifier>{ebcd62b6-de81-452a-8728-90a2946444ed}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Resource">
+
<UniqueIdentifier>{b39bdfbd-bddc-489c-a89d-1a68ada28e64}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Resource Views">
+
<UniqueIdentifier>{dcfcd66d-936a-4c76-9f7b-ca54a52580dd}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Resource Views\DepthStencilView">
+
<UniqueIdentifier>{663276bd-45b1-4af5-9382-a16052b9637d}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Resource Views\RenderTargetView">
+
<UniqueIdentifier>{9ef3259d-6173-4890-ae99-e225d71b53ec}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Resource Views\ShaderResourceView">
+
<UniqueIdentifier>{d186f0c8-fc8c-4758-93e1-501636821b32}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Resource Views\UnorderedAccessView">
+
<UniqueIdentifier>{bb2acedc-6806-41d8-bf75-7e154c4f5bb3}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Shader">
+
<UniqueIdentifier>{d4e8d812-efde-43b5-8100-a263f3425463}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Shader\ClassInstance">
+
<UniqueIdentifier>{17aaa5fc-a112-45f2-9533-751fbcfb2032}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Shader\ClassLinkage">
+
<UniqueIdentifier>{6489999b-f66a-4f31-bf17-51859065a2d6}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\State">
+
<UniqueIdentifier>{a7572f62-b813-408d-ae43-2017496a04b1}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\State\BlendState">
+
<UniqueIdentifier>{694070dd-2af6-4d03-872b-19e0ebec6495}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\State\DepthStencilState">
+
<UniqueIdentifier>{68260805-9b97-4479-8b1e-d295153ab571}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\State\RasterizerState">
+
<UniqueIdentifier>{1d3c4163-59de-439e-82e7-df7e5f2666be}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\State\SamplerState">
+
<UniqueIdentifier>{357d7ac4-1ac1-4755-98fc-5c38067417da}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Statistics">
+
<UniqueIdentifier>{8fb57a31-aae6-4b58-937d-4f5d5104b520}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Statistics\Queries">
+
<UniqueIdentifier>{1fdab6a4-1035-4e6f-89c3-ff401891400d}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Stream Input">
+
<UniqueIdentifier>{7f1eb327-548d-4166-8e1b-3ac0201e03cb}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Stream Output">
+
<UniqueIdentifier>{bb9bd6c7-c493-4c4b-acd3-f788eb89acf4}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Texture">
+
<UniqueIdentifier>{cf6a4cb7-6291-4221-8b75-38db8151cf71}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Texture\1D">
+
<UniqueIdentifier>{307bbc39-9c51-4374-b3e2-3dbd99ea4602}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Texture\2D">
+
<UniqueIdentifier>{10e1b157-7e8d-4021-bf08-33fb41ac8728}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Texture\3D">
+
<UniqueIdentifier>{e7db47da-1223-4adb-8d95-4f6c61487bdb}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Threading">
+
<UniqueIdentifier>{2ef84c6b-e3ed-4d0d-82ba-d0a6cb13f7da}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Direct3D11\Viewport">
+
<UniqueIdentifier>{3e652314-afd6-4d7a-8bfc-24957d97d064}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="D3DCompiler">
+
<UniqueIdentifier>{ee4d36c7-3168-4010-8dfe-c1d56d9ecf7b}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="D3DCompiler\Include">
+
<UniqueIdentifier>{37d3a8a9-e618-41e9-b35a-ce245c3ce1a5}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="D3DCompiler\ShaderMacro">
+
<UniqueIdentifier>{91be18eb-51d6-4bc6-b964-4a0dca94992c}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="D3DCompiler\ShaderBytecode">
+
<UniqueIdentifier>{4daece2b-df52-4bc0-a022-acdf3df28564}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="D3DCompiler\ShaderSignature">
+
<UniqueIdentifier>{f339fb51-eb7f-468a-afef-1cdbbb4cb95f}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="D3DCompiler\Reflection">
+
<UniqueIdentifier>{3bb7ba52-9987-4b92-9bfe-ef41337b4045}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="D3DCompiler\Reflection\ConstantBuffer">
+
<UniqueIdentifier>{e11a1f6b-5161-4a01-a76d-606e553ec064}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="D3DCompiler\Reflection\Type">
+
<UniqueIdentifier>{9ab037dd-d275-4414-84d0-277c2d20838e}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="D3DCompiler\Reflection\Variable">
+
<UniqueIdentifier>{b76da25f-8c84-407a-a903-5407c4b15216}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="External">
+
<UniqueIdentifier>{ab0827a1-e5d4-408f-b55c-faff34d79a17}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="DirectWrite">
+
<UniqueIdentifier>{71f3f462-c308-48ea-9f04-1ef3292125ef}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\source\ComObject.cpp">
+ <Filter>Base</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\CompilationException.cpp">
+ <Filter>Base</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\Configuration.cpp">
+ <Filter>Base</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\ObjectTable.cpp">
+ <Filter>Base</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\Result.cpp">
+ <Filter>Base</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\SlimDXException.cpp">
+ <Filter>Base</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\Utilities.cpp">
+ <Filter>Base</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\DataBox.cpp">
+ <Filter>Base\Data</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\DataRectangle.cpp">
+ <Filter>Base\Data</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\DataStream.cpp">
+ <Filter>Base\Data</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\xinput\ResultCodeXI.cpp">
+ <Filter>XInput</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\xinput\XInputException.cpp">
+ <Filter>XInput</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\xinput\Controller.cpp">
+ <Filter>XInput\Controller</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\xinput\Gamepad.cpp">
+ <Filter>XInput\State</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\xinput\State.cpp">
+ <Filter>XInput\State</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\xinput\Vibration.cpp">
+ <Filter>XInput\State</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\DXGIException.cpp">
+ <Filter>DXGI</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\ResultCodeDxgi.cpp">
+ <Filter>DXGI</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\SwapChainDescription.cpp">
+ <Filter>DXGI\Swap Chain</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\SwapChainDxgi.cpp">
+ <Filter>DXGI\Swap Chain</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\Output.cpp">
+ <Filter>DXGI\Output</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\OutputDescription.cpp">
+ <Filter>DXGI\Output</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\Adapter.cpp">
+ <Filter>DXGI\Adapter</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\AdapterDescription.cpp">
+ <Filter>DXGI\Adapter</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\DeviceChildDxgi.cpp">
+ <Filter>DXGI\Device</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\DeviceDxgi.cpp">
+ <Filter>DXGI\Device</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\ResourceDxgi.cpp">
+ <Filter>DXGI\Resource</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\Factory.cpp">
+ <Filter>DXGI\Factory</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\GammaControl.cpp">
+ <Filter>DXGI\Gamma</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\GammaControlCapabilities.cpp">
+ <Filter>DXGI\Gamma</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\FrameStatistics.cpp">
+ <Filter>DXGI\Statistics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\ModeDescription.cpp">
+ <Filter>DXGI\Display Mode</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\SampleDescription.cpp">
+ <Filter>DXGI\Display Mode</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\SurfaceDescription.cpp">
+ <Filter>DXGI\Surface</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\SurfaceDxgi.cpp">
+ <Filter>DXGI\Surface</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\ObjectDxgi.cpp">
+ <Filter>DXGI\Object</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\Adapter1.cpp">
+ <Filter>DXGI\1.1</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\AdapterDescription1.cpp">
+ <Filter>DXGI\1.1</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\Device1.cpp">
+ <Filter>DXGI\1.1</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\Factory1.cpp">
+ <Filter>DXGI\1.1</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\KeyedMutex.cpp">
+ <Filter>DXGI\1.1</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\dxgi\Surface1.cpp">
+ <Filter>DXGI\1.1</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\windows\DisplayMonitor.cpp">
+ <Filter>Windows\DisplayMonitor</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Direct3D11Exception.cpp">
+ <Filter>Direct3D11</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\ResultCode11.cpp">
+ <Filter>Direct3D11</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Buffer11.cpp">
+ <Filter>Direct3D11\Buffer</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\BufferDescription11.cpp">
+ <Filter>Direct3D11\Buffer</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\VertexBufferBinding11.cpp">
+ <Filter>Direct3D11\Buffer</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\CommandList11.cpp">
+ <Filter>Direct3D11\Device</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Device11.cpp">
+ <Filter>Direct3D11\Device</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\DeviceChild11.cpp">
+ <Filter>Direct3D11\Device</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\DeviceContext11.cpp">
+ <Filter>Direct3D11\Device</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\ComputeShaderWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\DomainShaderWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\GeometryShaderWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\HullShaderWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\InputAssemblerWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\OutputMergerWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\PixelShaderWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\RasterizerWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\StreamOutputWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\VertexShaderWrapper11.cpp">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Counter11.cpp">
+ <Filter>Direct3D11\Diagnostics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\CounterCapabilities11.cpp">
+ <Filter>Direct3D11\Diagnostics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\CounterMetadata11.cpp">
+ <Filter>Direct3D11\Diagnostics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Debug11.cpp">
+ <Filter>Direct3D11\Diagnostics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\DebugMessage11.cpp">
+ <Filter>Direct3D11\Diagnostics\InfoQueue</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\InfoQueue11.cpp">
+ <Filter>Direct3D11\Diagnostics\InfoQueue</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\InfoQueueFilter11.cpp">
+ <Filter>Direct3D11\Diagnostics\InfoQueue</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\InfoQueueFilterDescription11.cpp">
+ <Filter>Direct3D11\Diagnostics\InfoQueue</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Resource11.cpp">
+ <Filter>Direct3D11\Resource</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\ResourceRegion11.cpp">
+ <Filter>Direct3D11\Resource</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\ResourceView11.cpp">
+ <Filter>Direct3D11\Resource Views</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\DepthStencilView11.cpp">
+ <Filter>Direct3D11\Resource Views\DepthStencilView</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\DepthStencilViewDescription11.cpp">
+ <Filter>Direct3D11\Resource Views\DepthStencilView</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\RenderTargetView11.cpp">
+ <Filter>Direct3D11\Resource Views\RenderTargetView</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\RenderTargetViewDescription11.cpp">
+ <Filter>Direct3D11\Resource Views\RenderTargetView</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\ShaderResourceView11.cpp">
+ <Filter>Direct3D11\Resource Views\ShaderResourceView</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\ShaderResourceViewDescription11.cpp">
+ <Filter>Direct3D11\Resource Views\ShaderResourceView</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\UnorderedAccessView11.cpp">
+ <Filter>Direct3D11\Resource Views\UnorderedAccessView</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\UnorderedAccessViewDescription11.cpp">
+ <Filter>Direct3D11\Resource Views\UnorderedAccessView</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\ComputeShader11.cpp">
+ <Filter>Direct3D11\Shader</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\DomainShader11.cpp">
+ <Filter>Direct3D11\Shader</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\GeometryShader11.cpp">
+ <Filter>Direct3D11\Shader</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\HullShader11.cpp">
+ <Filter>Direct3D11\Shader</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\PixelShader11.cpp">
+ <Filter>Direct3D11\Shader</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\VertexShader11.cpp">
+ <Filter>Direct3D11\Shader</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\ClassInstance11.cpp">
+ <Filter>Direct3D11\Shader\ClassInstance</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\ClassInstanceDescription11.cpp">
+ <Filter>Direct3D11\Shader\ClassInstance</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\ClassLinkage11.cpp">
+ <Filter>Direct3D11\Shader\ClassLinkage</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\BlendState11.cpp">
+ <Filter>Direct3D11\State\BlendState</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\BlendStateDescription11.cpp">
+ <Filter>Direct3D11\State\BlendState</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\RenderTargetBlendDescription11.cpp">
+ <Filter>Direct3D11\State\BlendState</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\DepthStencilOperationDescription11.cpp">
+ <Filter>Direct3D11\State\DepthStencilState</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\DepthStencilState11.cpp">
+ <Filter>Direct3D11\State\DepthStencilState</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\DepthStencilStateDescription11.cpp">
+ <Filter>Direct3D11\State\DepthStencilState</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\RasterizerState11.cpp">
+ <Filter>Direct3D11\State\RasterizerState</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\RasterizerStateDescription11.cpp">
+ <Filter>Direct3D11\State\RasterizerState</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\SamplerDescription11.cpp">
+ <Filter>Direct3D11\State\SamplerState</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\SamplerState11.cpp">
+ <Filter>Direct3D11\State\SamplerState</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Predicate11.cpp">
+ <Filter>Direct3D11\Statistics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Query11.cpp">
+ <Filter>Direct3D11\Statistics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\QueryDescription11.cpp">
+ <Filter>Direct3D11\Statistics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\PipelineStatistics11.cpp">
+ <Filter>Direct3D11\Statistics\Queries</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\StreamOutputStatistics11.cpp">
+ <Filter>Direct3D11\Statistics\Queries</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\TimestampQueryData11.cpp">
+ <Filter>Direct3D11\Statistics\Queries</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\InputElement11.cpp">
+ <Filter>Direct3D11\Stream Input</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\InputLayout11.cpp">
+ <Filter>Direct3D11\Stream Input</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\direct3d11\StreamOutputBufferBinding11.cpp">
+ <Filter>Direct3D11\Stream Output</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\StreamOutputElement11.cpp">
+ <Filter>Direct3D11\Stream Output</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Texture1D11.cpp">
+ <Filter>Direct3D11\Texture\1D</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Texture1DDescription11.cpp">
+ <Filter>Direct3D11\Texture\1D</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Texture2D11.cpp">
+ <Filter>Direct3D11\Texture\2D</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Texture2DDescription11.cpp">
+ <Filter>Direct3D11\Texture\2D</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Texture3D11.cpp">
+ <Filter>Direct3D11\Texture\3D</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Texture3DDescription11.cpp">
+ <Filter>Direct3D11\Texture\3D</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Asynchronous11.cpp">
+ <Filter>Direct3D11\Threading</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\Viewport11.cpp">
+ <Filter>Direct3D11\Viewport</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\D3DCompilerException.cpp">
+ <Filter>D3DCompiler</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\IncludeDC.cpp">
+ <Filter>D3DCompiler\Include</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\ShaderMacroDC.cpp">
+ <Filter>D3DCompiler\ShaderMacro</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\ShaderBytecodeDC.cpp">
+ <Filter>D3DCompiler\ShaderBytecode</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\ShaderSignatureDC.cpp">
+ <Filter>D3DCompiler\ShaderSignature</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\d3dcompiler\InputBindingDescriptionDC.cpp">
+ <Filter>D3DCompiler\Reflection</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\ShaderDescriptionDC.cpp">
+ <Filter>D3DCompiler\Reflection</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\d3dcompiler\ShaderParameterDescriptionDC.cpp">
+ <Filter>D3DCompiler\Reflection</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\ShaderReflectionDC.cpp">
+ <Filter>D3DCompiler\Reflection</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\ConstantBufferDC.cpp">
+ <Filter>D3DCompiler\Reflection\ConstantBuffer</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\d3dcompiler\ConstantBufferDescriptionDC.cpp">
+ <Filter>D3DCompiler\Reflection\ConstantBuffer</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\ShaderReflectionTypeDC.cpp">
+ <Filter>D3DCompiler\Reflection\Type</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\d3dcompiler\ShaderTypeDescriptionDC.cpp">
+ <Filter>D3DCompiler\Reflection\Type</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\d3dcompiler\ShaderReflectionVariableDC.cpp">
+ <Filter>D3DCompiler\Reflection\Variable</Filter>
+ </ClCompile>
+ <ClCompile
Include="..\source\d3dcompiler\ShaderVariableDescriptionDC.cpp">
+ <Filter>D3DCompiler\Reflection\Variable</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\AssemblyInfo.cpp" />
+ <ClCompile Include="..\source\dxgi\DXGIExtensionMethods.cpp">
+ <Filter>DXGI</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\PerfAnnotation.cpp">
+ <Filter>Direct3D11\Diagnostics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\external\DDSTextureLoader.cpp">
+ <Filter>External</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\external\dxerr.cpp">
+ <Filter>External</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\direct3d11\TextureLoader.cpp">
+ <Filter>Direct3D11\Texture</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\BitmapRenderTargetDW.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\DirectWriteException.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FactoryDW.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\Font.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontCollection.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontCollectionLoader.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontFace.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontFamily.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontFeature.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontFile.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontFileAnalysis.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontFileEnumerator.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontFileLoader.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontFileStream.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontList.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontMetrics.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\FontTable.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\GdiInterop.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\GlyphMetrics.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\GlyphOffset.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\GlyphRunAnalysis.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\GlyphRunDescription.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\GlyphRunDW.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\IFontCollectionLoader.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\IFontFileLoader.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\InlineObject.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\ITextRenderer.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\LocalizedStrings.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\NumberSubstitution.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\PixelSnapping.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\RenderingParameters.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\ResultCodeDW.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\Strikethrough.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\TextAnalysisSink.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\TextAnalysisSource.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\TextAnalyzer.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\TextFormat.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\TextLayout.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\TextRange.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\Typography.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\directwrite\Underline.cpp">
+ <Filter>DirectWrite</Filter>
+ </ClCompile>
+ <ClCompile Include="..\source\windows\NativeWindow.cpp">
+ <Filter>Windows</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\source\auto_array.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\CollectionShim.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\ComObject.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\ComObjectMacros.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\CompilationException.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\Configuration.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\Enums.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\InternalHelpers.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\ObjectTable.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\Result.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\SlimDXException.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\stack_array.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\Utilities.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\VersionConfig.h">
+ <Filter>Base</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\DataBox.h">
+ <Filter>Base\Data</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\DataRectangle.h">
+ <Filter>Base\Data</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\DataStream.h">
+ <Filter>Base\Data</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\xinput\Enums.h">
+ <Filter>XInput</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\xinput\ResultCodeXI.h">
+ <Filter>XInput</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\xinput\XInputException.h">
+ <Filter>XInput</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\xinput\Controller.h">
+ <Filter>XInput\Controller</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\xinput\Gamepad.h">
+ <Filter>XInput\State</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\xinput\State.h">
+ <Filter>XInput\State</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\xinput\Vibration.h">
+ <Filter>XInput\State</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\DXGIException.h">
+ <Filter>DXGI</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\Enums.h">
+ <Filter>DXGI</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\ResultCodeDxgi.h">
+ <Filter>DXGI</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\SwapChainDescription.h">
+ <Filter>DXGI\Swap Chain</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\SwapChainDxgi.h">
+ <Filter>DXGI\Swap Chain</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\Output.h">
+ <Filter>DXGI\Output</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\OutputDescription.h">
+ <Filter>DXGI\Output</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\Adapter.h">
+ <Filter>DXGI\Adapter</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\AdapterDescription.h">
+ <Filter>DXGI\Adapter</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\DeviceChildDxgi.h">
+ <Filter>DXGI\Device</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\DeviceDxgi.h">
+ <Filter>DXGI\Device</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\ResourceDxgi.h">
+ <Filter>DXGI\Resource</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\Factory.h">
+ <Filter>DXGI\Factory</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\GammaControl.h">
+ <Filter>DXGI\Gamma</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\GammaControlCapabilities.h">
+ <Filter>DXGI\Gamma</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\FrameStatistics.h">
+ <Filter>DXGI\Statistics</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\ModeDescription.h">
+ <Filter>DXGI\Display Mode</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\SampleDescription.h">
+ <Filter>DXGI\Display Mode</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\SurfaceDescription.h">
+ <Filter>DXGI\Surface</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\SurfaceDxgi.h">
+ <Filter>DXGI\Surface</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\ObjectDxgi.h">
+ <Filter>DXGI\Object</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\Adapter1.h">
+ <Filter>DXGI\1.1</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\AdapterDescription1.h">
+ <Filter>DXGI\1.1</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\Device1.h">
+ <Filter>DXGI\1.1</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\Factory1.h">
+ <Filter>DXGI\1.1</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\KeyedMutex.h">
+ <Filter>DXGI\1.1</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\dxgi\Surface1.h">
+ <Filter>DXGI\1.1</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\windows\DisplayMonitor.h">
+ <Filter>Windows\DisplayMonitor</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\Direct3D11Exception.h">
+ <Filter>Direct3D11</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\Enums11.h">
+ <Filter>Direct3D11</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\ResultCode11.h">
+ <Filter>Direct3D11</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\Buffer11.h">
+ <Filter>Direct3D11\Buffer</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\BufferDescription11.h">
+ <Filter>Direct3D11\Buffer</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\VertexBufferBinding11.h">
+ <Filter>Direct3D11\Buffer</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\CommandList11.h">
+ <Filter>Direct3D11\Device</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\Device11.h">
+ <Filter>Direct3D11\Device</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\DeviceChild11.h">
+ <Filter>Direct3D11\Device</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\DeviceContext11.h">
+ <Filter>Direct3D11\Device</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\ComputeShaderWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\DomainShaderWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\GeometryShaderWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\HullShaderWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\InputAssemblerWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\OutputMergerWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\PixelShaderWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\RasterizerWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\StreamOutputWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\VertexShaderWrapper11.h">
+ <Filter>Direct3D11\Device\Pipeline Wrappers</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\Counter11.h">
+ <Filter>Direct3D11\Diagnostics</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\CounterCapabilities11.h">
+ <Filter>Direct3D11\Diagnostics</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\CounterMetadata11.h">
+ <Filter>Direct3D11\Diagnostics</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\Debug11.h">
+ <Filter>Direct3D11\Diagnostics</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\DebugMessage11.h">
+ <Filter>Direct3D11\Diagnostics\InfoQueue</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\DebugMessageId11.h">
+ <Filter>Direct3D11\Diagnostics\InfoQueue</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\InfoQueue11.h">
+ <Filter>Direct3D11\Diagnostics\InfoQueue</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\InfoQueueFilter11.h">
+ <Filter>Direct3D11\Diagnostics\InfoQueue</Filter>
+ </ClInclude>
+ <ClInclude
Include="..\source\direct3d11\InfoQueueFilterDescription11.h">
+ <Filter>Direct3D11\Diagnostics\InfoQueue</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\Resource11.h">
+ <Filter>Direct3D11\Resource</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\ResourceRegion11.h">
+ <Filter>Direct3D11\Resource</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\ResourceView11.h">
+ <Filter>Direct3D11\Resource Views</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\DepthStencilView11.h">
+ <Filter>Direct3D11\Resource Views\DepthStencilView</Filter>
+ </ClInclude>
+ <ClInclude
Include="..\source\direct3d11\DepthStencilViewDescription11.h">
+ <Filter>Direct3D11\Resource Views\DepthStencilView</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\RenderTargetView11.h">
+ <Filter>Direct3D11\Resource Views\RenderTargetView</Filter>
+ </ClInclude>
+ <ClInclude
Include="..\source\direct3d11\RenderTargetViewDescription11.h">
+ <Filter>Direct3D11\Resource Views\RenderTargetView</Filter>
+ </ClInclude>
+ <ClInclude Include="..\source\direct3d11\ShaderResourceView11.h">
+ <Filter>Direct3D11\Resource Views\ShaderResourceView</Filter>
+ </ClInclude>
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /branches/vs2013/source/AssemblyInfo.cpp Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+#include "stdafx.h"
+
+using namespace System;
+using namespace System::Resources;
+using namespace System::Reflection;
+using namespace System::Runtime::CompilerServices;
+using namespace System::Runtime::InteropServices;
+using namespace System::Security::Permissions;
+
+//
+// General Information about an assembly is controlled through the
following
+// set of attributes. Change these attribute values to modify the
information
+// associated with an assembly.
+//
+[assembly:AssemblyTitleAttribute("SlimDX")];
+[assembly:AssemblyDescriptionAttribute("Provides a managed wrapper around
Microsoft DirectX.")];
+[assembly:AssemblyConfigurationAttribute("")];
+[assembly:AssemblyCompanyAttribute("SlimDX Group")];
+[assembly:AssemblyProductAttribute("SlimDX")];
+[assembly:AssemblyCopyrightAttribute("Copyright © 2007-2014 SlimDX
Group")];
+[assembly:AssemblyTrademarkAttribute("")];
+[assembly:AssemblyCultureAttribute("")];
+
+//
+// Version information for an assembly consists of the following four
values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the value or you can default the Revision and Build
Numbers
+// by using the '*' as shown below:
+
+#if _MSC_VER < 1600
+[assembly:AssemblyVersionAttribute("2.0.13.43")];
+#else
+[assembly:AssemblyVersionAttribute("4.0.13.43")];
+#endif
+
+[assembly:ComVisible(false)];
+
+[assembly:CLSCompliantAttribute(true)];
+
+[assembly:NeutralResourcesLanguageAttribute("en-US")];
=======================================
--- /dev/null
+++ /branches/vs2013/source/CollectionShim.h Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+#pragma once
+
+#include <vcclr.h>
+
+template<class T>
+class CollectionShim
+{
+private:
+ gcroot<System::Collections::Generic::List<T>^> items;
+
+public:
+ CollectionShim( System::Collections::Generic::List<T>^ collection ) :
items( collection ) { }
+ System::Collections::Generic::List<T>^ GetItems() { return items; }
+};
=======================================
--- /dev/null
+++ /branches/vs2013/source/ComObject.cpp Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,158 @@
+#include "stdafx.h"
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+#include "ComObject.h"
+#include "Configuration.h"
+
+using namespace System;
+
+namespace SlimDX
+{
+ ComObject::ComObject()
+ {
+ }
+
+ ComObject::~ComObject()
+ {
+ if( m_Owner != nullptr )
+ return;
+
+ Destruct();
+ }
+
+ bool ComObject::Disposed::get()
+ {
+ if( m_Unknown == 0 )
+ return true;
+
+ if( !ObjectTable::Contains( this ) )
+ return true;
+
+ return false;
+ }
+
+ IntPtr ComObject::ComPointer::get()
+ {
+ return IntPtr( m_Unknown );
+ }
+
+ ComObject^ ComObject::Owner::get()
+ {
+ return m_Owner;
+ }
+
+ void ComObject::Owner::set( ComObject^ value )
+ {
+ m_Owner = value;
+ }
+
+ IUnknown* ComObject::UnknownPointer::get()
+ {
+ return m_Unknown;
+ }
+
+ IUnknown* ComObject::InternalPointer::get()
+ {
+ return m_Unknown;
+ }
+
+ void ComObject::SetSource( System::Diagnostics::StackTrace^ stack )
+ {
+ m_Source = stack;
+ }
+
+ System::Diagnostics::StackTrace^ ComObject::CreationSource::get()
+ {
+ return m_Source;
+ }
+
+ void ComObject::SetCreationTime( int time )
+ {
+ m_CreationTime = time;
+ }
+
+ int ComObject::CreationTime::get()
+ {
+ return m_CreationTime;
+ }
+
+ void ComObject::Construct( IUnknown* pointer, ComObject^ owner, bool
addToTable )
+ {
+ if( pointer == 0 )
+ throw gcnew ArgumentNullException( "pointer" );
+
+ m_Unknown = pointer;
+
+ if (addToTable)
+ ObjectTable::Add( this, owner );
+ else
+ ObjectTable::RegisterParent( this, owner );
+ }
+
+ void ComObject::Construct( IUnknown* pointer )
+ {
+ Construct( pointer, nullptr );
+ }
+
+ void ComObject::Construct( IUnknown* pointer, ComObject^ owner )
+ {
+ if( pointer == 0 )
+ throw gcnew ArgumentNullException( "pointer" );
+
+ m_Unknown = pointer;
+ ObjectTable::Add( this, owner );
+ }
+
+ void ComObject::Construct( IntPtr pointer, Guid guid )
+ {
+ if( pointer == IntPtr::Zero )
+ throw gcnew ArgumentNullException( "pointer" );
+
+ void* result = 0;
+ IUnknown* unknown = static_cast<IUnknown*>( pointer.ToPointer() );
+ HRESULT hr = unknown->QueryInterface( Utilities::ConvertManagedGuid(
guid ), &result );
+ if( FAILED( hr ) )
+ throw gcnew InvalidCastException( "Failed to QueryInterface on
user-supplied pointer." );
+
+ Construct( unknown );
+ }
+
+ void ComObject::Destruct()
+ {
+ if( m_Unknown == 0 || !ObjectTable::Remove( this ) )
+ {
+ // test for CreationTime is to avoid throwing ObjectDisposedException
when
+ // a constructor for an object fails
+ if( Configuration::DetectDoubleDispose && CreationTime != 0 )
+ {
+ Type^ myType = GetType();
+ throw gcnew ObjectDisposedException( myType->FullName );
+ }
+ }
+ else
+ {
+ m_Unknown->Release();
+ m_Unknown = 0;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/source/ComObject.h Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,178 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+#pragma once
+
+#include "ObjectTable.h"
+#include "Configuration.h"
+#include "Result.h"
+#include "Utilities.h"
+#include "InternalHelpers.h"
+
+#ifdef XMLDOCS
+using System::IntPtr;
+using System::Diagnostics::StackTrace;
+#endif
+
+#include "ComObjectMacros.h"
+
+namespace SlimDX
+{
+ public interface struct IComObject : System::IDisposable
+ {
+ public:
+ property System::IntPtr ComPointer
+ {
+ virtual System::IntPtr get() = 0;
+ }
+ };
+
+ /// <summary>
+ /// The base class for all SlimDX types which represent COM interfaces.
+ /// </summary>
+ /// <unmanaged>IUnknown</unmanaged>
+ public ref class ComObject abstract : IComObject
+ {
+ private:
+ IUnknown* m_Unknown;
+ ComObject^ m_Owner;
+ System::Diagnostics::StackTrace^ m_Source;
+ int m_CreationTime;
+
+ private protected:
+ ComObject();
+
+ void Construct( IUnknown* pointer );
+ void Construct( IUnknown* pointer, ComObject^ owner );
+ void Construct( IUnknown* pointer, ComObject^ owner, bool addToTable );
+ void Construct( System::IntPtr pointer, System::Guid guid );
+ void Destruct();
+
+ template< typename M, typename N >
+ static M^ ConstructFromPointer( N* pointer, ComObject^ owner )
+ {
+ // Since this method is called internally by SlimDX to essentially
translate the results of native
+ // API calls to their managed counterparts via the object table, we
expect that a null pointer
+ // might be passed, and that's okay. This differs from
ConstructFromUserPointer.
+ if( pointer == 0 )
+ return nullptr;
+
+ System::Threading::Monitor::Enter( ObjectTable::SyncObject );
+ try
+ {
+ M^ tableEntry = safe_cast<M^>( SlimDX::ObjectTable::Find(
static_cast<System::IntPtr>( pointer ) ) );
+ if( tableEntry != nullptr )
+ {
+ pointer->Release();
+ return tableEntry;
+ }
+
+ M^ result = gcnew M( pointer, owner );
+ return result;
+ }
+ finally
+ {
+ System::Threading::Monitor::Exit( ObjectTable::SyncObject );
+ }
+ }
+
+ template< typename M >
+ static M^ ConstructFromUserPointer( System::IntPtr pointer )
+ {
+ // This method gets called as a result of the user invoking the IntPtr
overload of FromPointer
+ // to create a SlimDX object from an externally-tracked native object.
In this scenario, a
+ // null pointer is a failure, so we throw.
+ if( pointer == System::IntPtr::Zero )
+ throw gcnew System::ArgumentNullException( "pointer" );
+
+ M^ tableEntry = safe_cast<M^>( SlimDX::ObjectTable::Find(
static_cast<System::IntPtr>( pointer ) ) );
+ if( tableEntry != nullptr )
+ return tableEntry;
+
+ M^ result = gcnew M( pointer );
+ return result;
+ }
+
+ internal:
+ property IUnknown* UnknownPointer
+ {
+ IUnknown* get();
+ }
+
+ property IUnknown* InternalPointer
+ {
+ IUnknown* get();
+ }
+
+ property ComObject^ Owner
+ {
+ ComObject^ get();
+ void set( ComObject^ value );
+ }
+
+ void SetSource( System::Diagnostics::StackTrace^ stack );
+ void SetCreationTime( int time );
+
+ public:
+ /// <summary>
+ /// Gets a value that indicates whether the object has been disposed.
+ /// </summary>
+ property bool Disposed
+ {
+ bool get();
+ }
+
+ /// <summary>
+ /// Gets an <see cref="IntPtr">IntPtr</see> to the underlying native COM
interface.
+ /// </summary>
+ property System::IntPtr ComPointer
+ {
+ virtual System::IntPtr get();
+ }
+
+ /// <summary>
+ /// Gets a <see cref="StackTrace"/> to the location where the object was
created.
+ /// </summary>
+ property System::Diagnostics::StackTrace^ CreationSource
+ {
+ System::Diagnostics::StackTrace^ get();
+ }
+
+ /// <summary>
+ /// Gets the timestamp, in milliseconds, of the object'ss creation.
+ /// </summary>
+ property int CreationTime
+ {
+ int get();
+ }
+
+ /// <summary>
+ /// Extra tag data stored along with the object. This member is intended
for use by users of SlimDX
+ /// and has no internal meaning to the library.
+ /// </summary>
+ property Object^ Tag;
+
+ /// <summary>
+ /// Releases all resources used by the <see cref="SlimDX::ComObject"/>.
+ /// </summary>
+ virtual ~ComObject();
+ };
+}
=======================================
--- /dev/null
+++ /branches/vs2013/source/ComObjectMacros.h Sun May 18 20:39:07 2014 UTC
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+
+#undef COMOBJECT
+#undef COMOBJECT_BASE
+#undef COMOBJECT_CUSTOM
+
+#define COMOBJECT_BASE(nativeType) \
+ public: \
+ static property System::Guid NativeInterface { System::Guid get() {
return Utilities::ConvertNativeGuid( IID_ ## nativeType ); } } \
+ property nativeType* InternalPointer { nativeType* get() new { return
static_cast<nativeType*>( UnknownPointer ); } } \
+ private:
+
+// This macro provides the basic infrastructure for SlimDX ComObject
subclasses.
+#define COMOBJECT(nativeType, managedType) \
+ public protected: \
+ managedType( nativeType* pointer, ComObject^ owner ) { Construct(
pointer, owner ); } \
+ managedType( System::IntPtr pointer ) { Construct( pointer,
NativeInterface ); } \
+ managedType( nativeType* pointer, ComObject^ owner, bool addToTable ) {
Construct( pointer, owner, addToTable ); } \
+ internal: \
+ static managedType^ FromPointerReflectionThunk( System::IntPtr pointer )
{ return FromPointer( static_cast<nativeType*>( pointer.ToPointer() ) ); } \
+ static managedType^ FromPointerReflectionThunk( System::IntPtr pointer,
ComObject^ owner ) { return FromPointer( static_cast<nativeType*>(
pointer.ToPointer()), owner ); } \
+ static managedType^ FromPointer( nativeType* pointer ) { return
FromPointer( pointer, nullptr ); } \
+ static managedType^ FromPointer( nativeType* pointer, ComObject^ owner )
{ return ConstructFromPointer<managedType,nativeType>( pointer, owner ); } \
+ public: \
+ static managedType^ FromPointer( System::IntPtr pointer ) { return
ConstructFromUserPointer<managedType>( pointer ); } \
+ COMOBJECT_BASE(nativeType)
+
+// This macro provides the basic infrastructure for SlimDX ComObject
subclasses, but allows
+// the subclass to customize the behavior of the creation process for that
subclass. This macro
+// should be applied instead of the regular COMOBJECT() macro when such
customization is required.
+// The subclass must provide a body for the following methods:
+// * managedType( nativeType* pointer, ComObject^ owner )
+// * managedType( System::IntPtr pointer )
+// * managedType^ FromPointer( nativeType* pointer, ComObject^ owner,
ComObjectFlags flags )
+// * managedType^ FromPointer( System::IntPtr pointer )
+//
+// Partial specialization is not supported; if the subclass needs special
behavior for only
+// a subset of the above methods, it must still implement all of them,
copying the standard
+// implementation from the COMOBJECT() macro for the appropriate
non-specialized methods.
+#define COMOBJECT_CUSTOM(nativeType, managedType) \
+ public protected: \
+ managedType( nativeType* pointer, ComObject^ owner ); \
+ managedType( System::IntPtr pointer ); \
+ internal: \
+ static managedType^ FromPointerReflectionThunk( System::IntPtr pointer )
{ return FromPointer( static_cast<nativeType*>( pointer.ToPointer() ) ); } \
+ static managedType^ FromPointerReflectionThunk( System::IntPtr pointer,
ComObject^ owner ) { return FromPointer( static_cast<nativeType*>(
pointer.ToPointer()), owner ); } \
+ static managedType^ FromPointer( nativeType* pointer ) { return
FromPointer( pointer, nullptr ); } \
+ static managedType^ FromPointer( nativeType* pointer, ComObject^ owner
); \
+ public: \
+ static managedType^ FromPointer( System::IntPtr pointer ); \
+ COMOBJECT_BASE(nativeType)
=======================================
--- /dev/null
+++ /branches/vs2013/source/CompilationException.cpp Sun May 18 20:39:07
2014 UTC
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+#include "stdafx.h"
+
+#include "SlimDXException.h"
+#include "CompilationException.h"
+
+using namespace System;
+using namespace System::Runtime::Serialization;
+
+namespace SlimDX
+{
+ generic<typename T>
+ CompilationException^ CompilationException::Check(HRESULT hr, String^
errors)
+ {
+ if (!Configuration::ThrowOnShaderCompileError)
+ return nullptr;
+
+ try
+ {
+ Result::Record<T>(hr, "CompilationErrors", errors);
+ }
+ catch (SlimDXException^ e)
+ {
+ return gcnew CompilationException(errors, e);
+ }
+
+ return nullptr;
+ }
+
+ CompilationException::CompilationException( SerializationInfo^ info,
StreamingContext context )
+ : Exception( info, context )
+ {
+ }
+
+ CompilationException::CompilationException()
+ : Exception( "Shader compilation failed." )
+ {
+ }
+
+ CompilationException::CompilationException( String^ message )
+ : Exception( message )
+ {
+ }
+
+ CompilationException::CompilationException( String^ message, Exception^
innerException )
+ : Exception( message, innerException )
+ {
+ }
+}
=======================================
--- /dev/null
+++ /branches/vs2013/source/CompilationException.h Sun May 18 20:39:07 2014
UTC
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2007-2014 SlimDX Group
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
copy
+* of this software and associated documentation files (the "Software"), to
deal
+* in the Software without restriction, including without limitation the
rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*/
+#pragma once
+
+namespace SlimDX
+{
+ [System::Serializable]
+ public ref class CompilationException : public System::Exception
+ {
+ internal:
+ generic<typename T>
+ static CompilationException^ Check(HRESULT hr, System::String^ errors);
+
+ protected:
+ CompilationException( System::Runtime::Serialization::SerializationInfo^
info, System::Runtime::Serialization::StreamingContext context );
+
+ public:
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CompilationException"/>
class.
+ /// </summary>
+ CompilationException();
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CompilationException"/>
class.
+ /// </summary>
+ /// <param name="message">The message describing the exception.</param>
+ CompilationException( System::String^ message );
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CompilationException"/>
class.
+ /// </summary>
+ /// <param name="message">The message describing the exception.</param>
+ /// <param name="innerException">The exception that caused this
exception.</param>
+ CompilationException( System::String^ message, System::Exception^
innerException );
+ };
+}
=======================================
***Additional files exist in this changeset.***