コード例 #1
0
ファイル: BrushFactory.cs プロジェクト: matthewRitter/GolfIt
        /// <summary>Converts a <see cref="RealtimeCSG.Legacy.Surface"/>/<see cref="RealtimeCSG.Legacy.TexGen"/>/<see cref="RealtimeCSG.Legacy.TexGenFlags"/> combination into a <see cref="RealtimeCSG.Foundation.SurfaceDescription"/>.</summary>
        /// <param name="surface">A legacy <see cref="RealtimeCSG.Legacy.Surface"/> that describes how the texture space is orientated relative to the brush.</param>
        /// <param name="texGen">A legacy <see cref="RealtimeCSG.Legacy.TexGen"/> that describes how the texture coordinates are calculated in the <see cref="RealtimeCSG.Foundation.SurfaceDescription"/>.</param>
        /// <param name="texGenFlags">A legacy <see cref="RealtimeCSG.Legacy.TexGenFlags"/> enum that describes if the <see cref="RealtimeCSG.Foundation.SurfaceDescription"/> texture generation will be in world-space or brush-space.</param>
        /// <returns>A new <see cref="RealtimeCSG.Foundation.SurfaceDescription"/></returns>
        public static SurfaceDescription CreateSurfaceDescription(Surface surface, TexGen texGen, TexGenFlags texGenFlags)
        {
            var localToTextureSpace = SurfaceUtility.GetLocalToTextureSpaceMatrix(texGen, surface);

            SurfaceDescription description;

            description.smoothingGroup = texGen.SmoothingGroup;
            description.surfaceFlags   = ((texGenFlags & TexGenFlags.WorldSpaceTexture) == 0) ? SurfaceFlags.None : SurfaceFlags.TextureIsInWorldSpace;

            description.UV0.U = localToTextureSpace.GetRow(0);
            description.UV0.V = localToTextureSpace.GetRow(1);

            return(description);
        }