当前位置: 首页>>代码示例>>C#>>正文


C# TextureCube.GetData方法代码示例

本文整理汇总了C#中TextureCube.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# TextureCube.GetData方法的具体用法?C# TextureCube.GetData怎么用?C# TextureCube.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextureCube的用法示例。


在下文中一共展示了TextureCube.GetData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SkySphere

        public SkySphere(ContentManager content, GraphicsDevice graphcisDevice, TextureCube Texture, float scale)
        {
            //model = new Object(content.Load<Model>("skysphere_mesh"), Vector3.Zero, Vector3.Zero, new Vector3(100000),GraphicsDevice);
            /*model = new Object(new Vector3(1000), "Models\\SkySphereMesh");
            model.Scale = 0.5f;*/
            model = new Object(new Vector3(0, 0, 0), "Models\\SphereHighPoly");// "Models\\SkySphereMesh");//Model Model, Vector3 Position, Vector3 Rotation,Vector3 Scale,
            //model.Scale = 1000;
            //model.Scale = 10000;
            model.Scale = scale;

            TextureCube = Texture;
            Color[] c = new Color[TextureCube.Size * TextureCube.Size];
            TextureCube.GetData<Color>(CubeMapFace.PositiveZ, c);

            effect = content.Load<Effect>("SkySphereEffect");
            effect.Parameters["CubeMap"].SetValue(Texture);
            //effect = content.Load<Effect>("SkySphere");
            //effect.Parameters["SkyboxTexture"].SetValue(Texture);

            model.SetModelEffect(effect, false);
            this.graphics = graphcisDevice;
        }
开发者ID:pentiumx,项目名称:HLSLTest,代码行数:22,代码来源:SkySphere.cs

示例2: ShouldSetAndGetData

        public void ShouldSetAndGetData(int size)
        {
            Game.DrawWith += (sender, e) =>
            {
                var dataSize = size * size;
                var textureCube = new TextureCube(Game.GraphicsDevice, size, false, SurfaceFormat.Color);

                for (var i = 0; i < 6; i++)
                {
                    var savedData = new Color[dataSize];
                    for (var index = 0; index < dataSize; index++)
                        savedData[index] = new Color(index + i, index + i, index + i);
                    textureCube.SetData((CubeMapFace) i, savedData);

                    var readData = new Color[dataSize];
                    textureCube.GetData((CubeMapFace) i, readData);

                    Assert.AreEqual(savedData, readData);
                }
            };
            Game.Run();
        }
开发者ID:KennethYap,项目名称:MonoGame,代码行数:22,代码来源:TextureCubeTest.cs

示例3: GetTexture2D

        private static Texture2D GetTexture2D(GraphicsDevice graphicsDevice, TextureCube textureCube, CubeMapFace cubeMapFace)
        {
            // Unfortunately, we cannot treat the TextureCube as Texture2D[] in XNA.
              // We could try to copy all faces into a 3x2 Texture2D, but this is problematic:
              //  - Extracting DXT compressed faces is difficult.
              //  - Additional texel border required for correct texture filtering at edges.
              //  + The skybox could be rendered with a single draw call.
              //
              // --> Manually convert TextureCube to Texture2D[6] and store array in Tag.

              var faces = textureCube.Tag as Texture2D[];
              if (faces == null || faces.Length != 6)
              {
            if (textureCube.Tag != null)
              throw new GraphicsException("The SkyboxRenderer (Reach profile) needs to store information in Tag property of the skybox texture, but the Tag property is already in use.");

            faces = new Texture2D[6];
            var size = textureCube.Size;

            int numberOfBytes;
            switch (textureCube.Format)
            {
              case SurfaceFormat.Color:
            numberOfBytes = size * size * 4;
            break;
              case SurfaceFormat.Dxt1:
            numberOfBytes = size * size / 2;
            break;
              default:
            throw new GraphicsException("The SkyboxRenderer (Reach profile) only supports the following surface formats: Color, Dxt1.");
            }

            var face = new byte[numberOfBytes];
            for (int i = 0; i < 6; i++)
            {
              var texture2D = new Texture2D(graphicsDevice, size, size, false, textureCube.Format);
              textureCube.GetData((CubeMapFace)i, face);
              texture2D.SetData(face);
              faces[i] = texture2D;
            }

            textureCube.Tag = faces;
            textureCube.Disposing += OnTextureCubeDisposing;
              }

              return faces[(int)cubeMapFace];
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:47,代码来源:SkyboxRenderer.cs

示例4: GenerateSphericalHarmonicFromCubeMap

        } // Lerp

        #endregion

        #region Generate Spherical Harmonic from CubeMap

        /// <summary>
        /// Generate a spherical harmonic from the faces of a cubemap, treating each pixel as a light source and averaging the result.
        /// </summary>
        public static SphericalHarmonicL2 GenerateSphericalHarmonicFromCubeMap(TextureCube cubeMap)
        {
            SphericalHarmonicL2 sh = new SphericalHarmonicL2();

            // Extract the 6 faces of the cubemap.
            for (int face = 0; face < 6; face++)
            {
                CubeMapFace faceId = (CubeMapFace)face;

                // Get the transformation for this face,
                Matrix cubeFaceMatrix;
                switch (faceId)
                {
                    case CubeMapFace.PositiveX:
                        cubeFaceMatrix = Matrix.CreateLookAt(Vector3.Zero, new Vector3(1, 0, 0), new Vector3(0, 1, 0));
                        break;
                    case CubeMapFace.NegativeX:
                        cubeFaceMatrix = Matrix.CreateLookAt(Vector3.Zero, new Vector3(-1, 0, 0), new Vector3(0, 1, 0));
                        break;
                    case CubeMapFace.PositiveY:
                        cubeFaceMatrix = Matrix.CreateLookAt(Vector3.Zero, new Vector3(0, 1, 0), new Vector3(0, 0, 1));
                        break;
                    case CubeMapFace.NegativeY:
                        cubeFaceMatrix = Matrix.CreateLookAt(Vector3.Zero, new Vector3(0, -1, 0), new Vector3(0, 0, -1));
                        break;
                    case CubeMapFace.PositiveZ:
                        cubeFaceMatrix = Matrix.CreateLookAt(Vector3.Zero, new Vector3(0, 0, -1), new Vector3(0, 1, 0));
                        break;
                    case CubeMapFace.NegativeZ:
                        cubeFaceMatrix = Matrix.CreateLookAt(Vector3.Zero, new Vector3(0, 0, 1), new Vector3(0, 1, 0));
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
                Color[] colorArray = new Color[cubeMap.Size * cubeMap.Size];
                cubeMap.GetData(faceId, colorArray);

                // Extract the spherical harmonic for this face and accumulate it.
                sh += ExtractSphericalHarmonicForCubeFace(cubeFaceMatrix, colorArray, cubeMap.Size);
            }

            //average out over the sphere
            return sh.GetWeightedAverageLightInputFromSphere();
        } // GenerateSphericalHarmonicFromCubeMap
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:53,代码来源:SphericalHarmonicL2.cs


注:本文中的TextureCube.GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。