private int Reset( VIEWPLANE p_ViewPlane )
        {
            m_Scale = 1.0f;
            m_WorldScale = 1.0f;
            m_XDelta = 0.0f;
            m_YDelta = 0.0f;
            m_ZDelta = 0.0f;

            m_ViewPlane = p_ViewPlane;

            m_CameraPosition = Vector3.Zero;
            m_LookPoint = Vector3.Zero;

            m_ClearColour = new Color( 8, 8, 8 );

            switch( m_ViewPlane )
            {
                case VIEWPLANE.VIEWPLANE_XY:
                {
                    this.Name = "Orthographic View [Front]";
                    m_CameraPosition.Z = -1000.0f;
                    break;
                }
                case VIEWPLANE.VIEWPLANE_XZ:
                {
                    this.Name = "Orthographic View [Top]";
                    m_CameraPosition.Y = 1000.0f;
                    break;
                }
                case VIEWPLANE.VIEWPLANE_YZ:
                {
                    this.Name = "Orthographic View [Side]";
                    m_CameraPosition.X = 1000.0f;
                    break;
                }
            }

            m_MiddleButtonDown = false;

            if( m_Grid != null )
            {
                m_Grid.ViewPlane = m_ViewPlane;
            }

            return 0;
        }
 public OrthographicViewControl( VIEWPLANE p_ViewPlane )
     : base()
 {
     this.Reset( p_ViewPlane );
 }
Example #3
0
        public int Create( VIEWPLANE p_Type, int p_Width, int p_Height,
            float p_Stride, float p_Offset, Color p_NormalColour,
            int p_HeavyDivision, Color p_HeavyColour)
        {
            m_Effect.Alpha = 1.0f;
            m_Effect.LightingEnabled = false;
            m_Effect.VertexColorEnabled = true;

            Vector3 [ ] Vertices = new Vector3[ ( ( p_Width + p_Height ) * 2 ) + 4 ];
            float HalfColumns = p_Width / 2;
            float HalfRows = p_Height / 2;
            float RowStart = -HalfRows * p_Stride;
            float ColumnStart = -HalfColumns * p_Stride;
            float RowIndex = RowStart;
            float ColumnIndex = ColumnStart;
            int Row = 0;
            int Column = 0;
            m_ViewPlane = p_Type;

            m_ViewPlane = VIEWPLANE.VIEWPLANE_XZ;

            for( Row = 0; Row < p_Height * 2; ++Row )
            {
                Vertices[ Row ] = new Vector3( ColumnStart, 0.0f, RowIndex );
                    ++Row;
                Vertices[ Row ] = new Vector3( -ColumnStart, 0.0f, RowIndex );

                RowIndex += p_Stride;
            }

            // Add the last edge to the row
            Vertices[ Row ] = new Vector3( ColumnStart, 0.0f, RowIndex );
            ++Row;
            Vertices[ Row ] = new Vector3( -ColumnStart, 0.0f, RowIndex );
            ++Row;

            for( Column = 0; Column < p_Width * 2; ++Column )
            {
                Vertices[ Row + Column ] = new Vector3( ColumnIndex,
                    0.0f, RowStart );
                ++Column;
                Vertices[ Row + Column ] = new Vector3( ColumnIndex,
                    0.0f, -RowStart );

                ColumnIndex += p_Stride;
            }

            // Add the last edge to the column
            Vertices[ Row + Column ] = new Vector3( ColumnIndex,
                0.0f, RowStart );
            ++Column;
            Vertices[ Row + Column ] = new Vector3( ColumnIndex,
                0.0f, -RowStart );

            m_Vertices = new VertexPositionColor[ ( ( p_Width + p_Height ) * 2 ) + 4];

            int LineCount = 0;

            for( int i = 0; i < ( p_Height * 2 ) + 2; ++i )
            {
                m_Vertices[ i ].Position = Vertices[ i ];
                if( ( i % ( p_HeavyDivision * 2 ) ) == 0 )
                {
                    m_Vertices[ i ].Color = p_HeavyColour;
                    m_Vertices[ i + 1 ].Color = p_HeavyColour;
                    ++i;
                    ++LineCount;
                    m_Vertices[ i ].Position = Vertices[ i ];
                }
                else
                {
                    m_Vertices[ i ].Color = p_NormalColour;
                }
                ++LineCount;
            }

            for( int i = 0; i < ( p_Width * 2 ) + 2; ++i )
            {
                m_Vertices[ i + LineCount ].Position = Vertices[ i + LineCount ];
                if( ( i % ( p_HeavyDivision *2 ) ) == 0 )
                {
                    m_Vertices[ i + LineCount ].Color = p_HeavyColour;
                    m_Vertices[ i + LineCount + 1 ].Color = p_HeavyColour;
                    ++i;
                    m_Vertices[ i + LineCount ].Position = Vertices[ i + LineCount ];
                }
                else
                {
                    m_Vertices[ i + LineCount ].Color = p_NormalColour;
                }
            }

            m_VertexBuffer = new VertexBuffer( m_GraphicsDevice,
                typeof( VertexPositionColor ), ( ( p_Width + p_Height ) * 2 ) + 4,
                BufferUsage.None );

            m_VertexBuffer.SetData< VertexPositionColor >( m_Vertices );

            m_ViewPlane = p_Type;
            m_TotalWidth = p_Width * p_Stride;
            m_TotalHeight = p_Height * p_Stride;

            return 0;
        }