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


C# Camera.SetDeviceViewAndProjection方法代码示例

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


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

示例1: DrawIndividualLayer

        private static void DrawIndividualLayer(Camera camera, RenderMode renderMode, Layer layer, Section section)
        {
            bool hasLayerModifiedCamera = false;

            if (layer.Visible)
            {
                Renderer.CurrentLayer = layer;

                if (section != null)
                {
                    string layerName = "No Layer";
                    if(layer != null)
                    {
                        layerName = layer.Name;
                    }
                    Section.GetAndStartContextAndTime("Layer: " + layerName);
                }
                ClearBackgroundForLayer(camera);


                #region Set View and Projection
                // Store the camera's FieldOfView in the oldFieldOfView and
                // set the camera's FieldOfView to the layer's OverridingFieldOfView
                // if necessary.
                mOldCameraLayerSettings.SetFromCamera(camera);

                Vector3 oldPosition = camera.Position;

                if (layer.LayerCameraSettings != null)
                {
                    layer.LayerCameraSettings.ApplyValuesToCamera(camera, SetCameraOptions.PerformZRotation, null);
                    hasLayerModifiedCamera = true;
                }

                camera.SetDeviceViewAndProjection(mCurrentEffect, layer.RelativeToCamera);
                #endregion


                if (renderMode == RenderMode.Default)
                {
                    if (layer.mZBufferedSprites.Count > 0)
                    {
                        DrawZBufferedSprites(camera, layer.mZBufferedSprites);
                    }

                    // Draw the camera's layer
                    DrawMixed(layer.mSprites, layer.mSortType,
                        layer.mTexts, layer.mBatches, layer.RelativeToCamera, camera, section);

                    #region Draw Shapes

                    DrawShapes(camera,
                        layer.mSpheres,
                        layer.mCubes,
                        layer.mRectangles,
                        layer.mCircles,
                        layer.mPolygons,
                        layer.mLines,
                        layer.mCapsule2Ds,
                        layer);

                    #endregion
                }

                // Set the Camera's FieldOfView back
                // Vic asks:  What if the user wants to have a wacky field of view?
                // Does that mean that this will regulate it on layers?  This is something
                // that may need to be fixed in the future, but it seems rare and will bloat
                // the visible property list considerably.  Let's leave it like this for now
                // to establish a pattern then if the time comes to change this we'll be comfortable
                // with the overriding field of view pattern so a better decision can be made.
                if (hasLayerModifiedCamera)
                {
                    mOldCameraLayerSettings.ApplyValuesToCamera(camera, SetCameraOptions.ApplyMatrix, layer.LayerCameraSettings);
                    camera.Position = oldPosition;
                }
                if (section != null)
                {
                    Section.EndContextAndTime();
                }
            }
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:82,代码来源:Renderer.Common.cs

示例2: Draw

        /// <summary>
        /// Custom drawing technique - sets graphics states and
        /// draws the custom shape
        /// </summary>
        /// <param name="camera">The currently drawing camera</param>
        #endregion
        public void Draw(Camera camera)
        {
            if (Visible)
            {
                // Set graphics states
                FlatRedBallServices.GraphicsDevice.RenderState.FillMode = FillMode.Solid;
                FlatRedBallServices.GraphicsDevice.RenderState.CullMode = CullMode.None;

                // Set the vertex declaration
                FlatRedBallServices.GraphicsDevice.VertexDeclaration = mVertexDeclaration;

                // Have the current camera set our current view/projection variables
                camera.SetDeviceViewAndProjection(mEffect, false);

                // Here we get the positioned object's transformation (position / rotation)
                mEffect.World = base.TransformationMatrix;

                if (mPositionColorVertices != null)
                {
                    mEffect.VertexColorEnabled = true;
                    mEffect.TextureEnabled = false;
                }
                else
                {
                    mEffect.VertexColorEnabled = false;
                    mEffect.TextureEnabled = true;
                    mEffect.Texture = Texture;
                }


                // Start the effect
                mEffect.Begin();
                foreach (EffectPass pass in mEffect.CurrentTechnique.Passes)
                {
                    // Start each pass

                    pass.Begin();
                    if (mPositionColorVertices != null)
                    {
                        // Draw the shape
                        FlatRedBallServices.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                            PrimitiveType.TriangleList,
                            mPositionColorVertices, 0, mPositionColorVertices.Length,
                            mIndices, 0, mIndices.Length / 3);
                    }
                    else
                    {
                        // Draw the shape
                        FlatRedBallServices.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionTexture>(
                            PrimitiveType.TriangleList,
                            mPositionTextureVertices, 0, mPositionTextureVertices.Length,
                            mIndices, 0, mIndices.Length / 3);
                    }

                    // End each pass
                    pass.End();
                }
                // End the effect
                mEffect.End();
            }
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:67,代码来源:GeometryDrawableBatch.cs


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