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


C# Camera.getTransformation方法代码示例

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


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

示例1: RenderMiniMap

        private Texture2D RenderMiniMap(Camera.Camera2D miniCam, GraphicsDevice graphicsDevice)
        {
            SpriteBatch localSpriteBatch = Screen.Renderer.SpriteBatch;
            RenderTarget2D mini = new RenderTarget2D(graphicsDevice, (int)ActualWidth, (int)ActualHeight);
            graphicsDevice.SetRenderTarget(mini);
            localSpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, miniCam.getTransformation() * miniCam.getScale());
            Texture2D starTexture;
            localSpriteBatch.Draw(_black, new Rectangle(0, 0, miniCam.CamWorldWidth, miniCam.CamWorldHeight), Color.White);

            foreach (Model.GalaxyDecoration decor in _gameManager.Galaxy.Decorations)
            {
                Util.TextureAtlas atlas = _content.getGalaxyDecorationAtlasFromTextureName(decor.TextureName);
                if (atlas != null)
                {
                    localSpriteBatch.Draw(atlas.AtlasTexture, new Rectangle((int)decor.Position.X, (int)decor.Position.Y, decor.Width, decor.Height), atlas.AtlasCoords[decor.TextureName], Color.White);
                }
            }

            Dictionary<Util.TextureAtlas, List<Model.Star>> sortedStars = new Dictionary<Util.TextureAtlas, List<Model.Star>>();
            foreach (Model.GalaxySector sec in _gameManager.Galaxy.Sectors)
            {
                foreach (Model.Star star in sec.Stars)
                {
                    Util.TextureAtlas atlas = _content.getStarAtlasFromTextureName(star.StarTexture);
                    if (atlas != null)
                    {
                        if (!sortedStars.ContainsKey(atlas))
                        {
                            sortedStars.Add(atlas, new List<Model.Star>());
                        }
                        sortedStars[atlas].Add(star);
                    }
                }
            }
            foreach (Util.TextureAtlas textureAtlas in sortedStars.Keys)
            {
                foreach (Model.Star star in sortedStars[textureAtlas])
                {
                    localSpriteBatch.Draw(textureAtlas.AtlasTexture, star.BoundingBox, textureAtlas.AtlasCoords[star.StarTexture], Color.White);
                }
            }

            localSpriteBatch.End();
            graphicsDevice.SetRenderTarget(null);
            return mini;
        }
开发者ID:FirestarJes,项目名称:MasterOfOrion,代码行数:46,代码来源:MinimapControl.cs

示例2: Draw

        public static void Draw(SpriteBatch sb, Camera cam, Color c)
        {
            // light
            light.BeginDrawingShadowCasters();

            sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp,
                   DepthStencilState.Default, RasterizerState.CullNone, null, cam.getTransformation());
            World.Map.DrawShadowWalls(sb, light.LightPosition);
            //World.Map.DrawSides(sb);
            sb.End();

            light.EndDrawingShadowCasters();
            shadowmapResolver.ResolveShadows(light.RenderTarget, light.RenderTarget,
                light.LightPosition);

            graphics.SetRenderTarget(screenShadows);
            graphics.Clear(c);
            sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp,
                DepthStencilState.Default, RasterizerState.CullNone, null, cam.getTransformation());
            sb.Draw(light.RenderTarget, light.LightPosition - light.LightAreaSize * 0.5f, Color.White);
            sb.End();

            graphics.SetRenderTarget(null);

            graphics.Clear(Color.Black);

            sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap,
                DepthStencilState.Default, RasterizerState.CullNone, null, cam.getTransformation());
            World.DrawGroundTiles(sb, light.LightPosition);
            sb.End();

            BlendState blendState = new BlendState();
            blendState.ColorSourceBlend = Blend.DestinationColor;
            blendState.ColorDestinationBlend = Blend.SourceColor;

            sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp,
               DepthStencilState.Default, RasterizerState.CullNone, null, cam.getTransformation());
            World.DrawWallTiles(sb, light.LightPosition, 2);
            World.Map.DrawSides(sb, light.LightPosition);
            sb.End();

            sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp,
               DepthStencilState.Default, RasterizerState.CullNone, null, cam.getTransformation());
            World.DrawSceneBehindPlayer(sb);
            World.DrawPlayers(sb);
            sb.End();

            Texture2D shadows = World.Map.GetNewShadowMap(screenShadows, light.LightPosition);

            sb.Begin(SpriteSortMode.Immediate, blendState, SamplerState.PointClamp,
                    DepthStencilState.Default, RasterizerState.CullNone, null);
            sb.Draw(shadows, new Vector2(0, 0), Color.White);
            sb.End();

            sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp,
            DepthStencilState.Default, RasterizerState.CullNone, null, cam.getTransformation());
            World.DrawWallTiles(sb, light.LightPosition, 1);
            World.DrawWallTiles(sb, light.LightPosition, 2);
            World.DrawSceneInFrontOfPlayer(sb);
            sb.End();

            sb.Begin();
            if (World.inMenu)
            {
                World.menuManager.Draw(sb);
            }
            sb.End();
        }
开发者ID:DuncanKeller,项目名称:dunGeon,代码行数:68,代码来源:Shadowmap.cs


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