GetLookAtMatrix() публичный Метод

public GetLookAtMatrix ( ) : Matrix
Результат Matrix
Пример #1
0
        public void RenderQuadSolidOnly(DeviceContext deviceContext, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector3 color, Camera camera)
        {
            DataBox databox = deviceContext.MapSubresource(mPositionVertexBuffer,
                                                           0,
                                                           QUAD_NUM_VERTICES *
                                                           POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                           POSITION_NUM_BYTES_PER_COMPONENT,
                                                           MapMode.WriteDiscard,
                                                           SlimDX.Direct3D11.MapFlags.None);

            databox.Data.Write(p1);
            databox.Data.Write(p4);
            databox.Data.Write(p2);
            databox.Data.Write(p3);

            deviceContext.UnmapSubresource(mPositionVertexBuffer, 0);

            deviceContext.InputAssembler.InputLayout       = mRenderSolidInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers(POSITION_SLOT,
                                                          new VertexBufferBinding(mPositionVertexBuffer,
                                                                                  POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                  POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                  0));

            mEffect.GetVariableByName("gTransform").AsMatrix().SetMatrix(camera.GetLookAtMatrix() * camera.GetProjectionMatrix());
            mEffect.GetVariableByName("gColor").AsVector().Set(color);

            mRenderSolidPass.Apply(deviceContext);
            deviceContext.Draw(QUAD_NUM_VERTICES, 0);
        }
Пример #2
0
        public void RenderPoint(DeviceContext deviceContext, Vector3 p, Vector3 color, Camera camera)
        {
            var databox = deviceContext.MapSubresource(mPositionVertexBuffer,
                                                       0,
                                                       POINT_NUM_VERTICES *
                                                       POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                       POSITION_NUM_BYTES_PER_COMPONENT,
                                                       MapMode.WriteDiscard,
                                                       SlimDX.Direct3D11.MapFlags.None);

            databox.Data.Write(p);

            deviceContext.UnmapSubresource(mPositionVertexBuffer, 0);

            deviceContext.InputAssembler.InputLayout       = mRenderWireframeInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList;
            deviceContext.InputAssembler.SetVertexBuffers(POSITION_SLOT,
                                                          new VertexBufferBinding(mPositionVertexBuffer,
                                                                                  POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                  POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                  0));

            mEffect.GetVariableByName("gColor").AsVector().Set(color);
            mEffect.GetVariableByName("gTransform").AsMatrix().SetMatrix(camera.GetLookAtMatrix() * camera.GetProjectionMatrix());
            mRenderWireframePass.Apply(deviceContext);

            deviceContext.Draw(POINT_NUM_VERTICES, 0);
        }
Пример #3
0
        public void RenderQuadGreyScaleTexture3DOnly(DeviceContext deviceContext, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector3 t1, Vector3 t2, Vector3 t3, Vector3 t4, ShaderResourceView texture, Camera camera)
        {
            DataBox databox;

            databox = deviceContext.MapSubresource(mPositionVertexBuffer,
                                                   0,
                                                   QUAD_NUM_VERTICES *
                                                   POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                   POSITION_NUM_BYTES_PER_COMPONENT,
                                                   MapMode.WriteDiscard,
                                                   SlimDX.Direct3D11.MapFlags.None);

            databox.Data.Write(p1);
            databox.Data.Write(p4);
            databox.Data.Write(p2);
            databox.Data.Write(p3);

            deviceContext.UnmapSubresource(mPositionVertexBuffer, 0);

            databox = deviceContext.MapSubresource(mTexCoordVertexBuffer,
                                                   0,
                                                   QUAD_NUM_VERTICES *
                                                   TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                   TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                   MapMode.WriteDiscard,
                                                   SlimDX.Direct3D11.MapFlags.None);

            databox.Data.Write(t1);
            databox.Data.Write(t4);
            databox.Data.Write(t2);
            databox.Data.Write(t3);

            deviceContext.UnmapSubresource(mTexCoordVertexBuffer, 0);

            deviceContext.InputAssembler.InputLayout       = mRenderGreyScaleTexture3DInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers(POSITION_SLOT,
                                                          new VertexBufferBinding(mPositionVertexBuffer,
                                                                                  POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                  POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                  0));
            deviceContext.InputAssembler.SetVertexBuffers(TEXCOORD_SLOT,
                                                          new VertexBufferBinding(mTexCoordVertexBuffer,
                                                                                  TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                                                  TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                                                  0));


            mEffect.GetVariableByName("gTexture3D").AsResource().SetResource(texture);
            mEffect.GetVariableByName("gTransform").AsMatrix().SetMatrix(camera.GetLookAtMatrix() * camera.GetProjectionMatrix());

            mRenderGreyScaleTexture3DPass.Apply(deviceContext);
            deviceContext.Draw(QUAD_NUM_VERTICES, 0);
        }
        private void RenderTileCacheEntry( DeviceContext deviceContext, Camera camera, int datasetExtentDataSpaceX, int datasetExtentDataSpaceY, TileCacheEntry tileCacheEntry, Viewport viewport )
        {
            //Check if this tile is over the edge of the image
            var tileMinExtentX = tileCacheEntry.CenterDataSpace.X - ( tileCacheEntry.ExtentDataSpace.X / 2f );
            var tileMinExtentY = tileCacheEntry.CenterDataSpace.Y - ( tileCacheEntry.ExtentDataSpace.Y / 2f );
            var tileMaxExtentX = tileCacheEntry.CenterDataSpace.X + ( tileCacheEntry.ExtentDataSpace.X / 2f );
            var tileMaxExtentY = tileCacheEntry.CenterDataSpace.Y + ( tileCacheEntry.ExtentDataSpace.Y / 2f );
            var tileProportionClipX = 1f;
            var tileProportionClipY = 1f;

            if ( datasetExtentDataSpaceX > 0 && tileMaxExtentX > datasetExtentDataSpaceX )
            {
                tileProportionClipX = 1 - ( ( tileMaxExtentX - datasetExtentDataSpaceX ) / ( tileMaxExtentX - tileMinExtentX ) );
                tileMaxExtentX = datasetExtentDataSpaceX;
            }
            if ( datasetExtentDataSpaceY > 0 && tileMaxExtentY > datasetExtentDataSpaceY )
            {
                tileProportionClipY = 1 - ( ( tileMaxExtentY - datasetExtentDataSpaceY ) / ( tileMaxExtentY - tileMinExtentY ) );
                tileMaxExtentY = datasetExtentDataSpaceY;
            }

            var p1 = new Vector3( tileMinExtentX, tileMinExtentY, 0.5f );
            var p2 = new Vector3( tileMinExtentX, tileMaxExtentY, 0.5f );
            var p3 = new Vector3( tileMaxExtentX, tileMaxExtentY, 0.5f );
            var p4 = new Vector3( tileMaxExtentX, tileMinExtentY, 0.5f );

            var t1 = new Vector3( 0f, 0f, 0f );
            var t2 = new Vector3( 0f, tileProportionClipY, 0f );
            var t3 = new Vector3( tileProportionClipX, tileProportionClipY, 0f );
            var t4 = new Vector3( tileProportionClipX, 0f, 0f );

            DataBox databox;

            databox = deviceContext.MapSubresource( mPositionVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( p1 );
            databox.Data.Write( p4 );
            databox.Data.Write( p2 );
            databox.Data.Write( p3 );

            deviceContext.UnmapSubresource( mPositionVertexBuffer, 0 );

            databox = deviceContext.MapSubresource( mTexCoordVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                    TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( t1 );
            databox.Data.Write( t4 );
            databox.Data.Write( t2 );
            databox.Data.Write( t3 );

            deviceContext.UnmapSubresource( mTexCoordVertexBuffer, 0 );

            deviceContext.InputAssembler.InputLayout = mInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers( POSITION_SLOT,
                                                           new VertexBufferBinding( mPositionVertexBuffer,
                                                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );
            deviceContext.InputAssembler.SetVertexBuffers( TEXCOORD_SLOT,
                                                           new VertexBufferBinding( mTexCoordVertexBuffer,
                                                                                    TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                                                    TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );

            mEffect.GetVariableByName( "gSourceTexture3D" ).AsResource().SetResource( tileCacheEntry.D3D11CudaTextures.Get( "SourceMap" ) );
            if ( mTileManager.SegmentationLoaded )
            {
                //if ( tileCacheEntry.D3D11CudaTextures.Internal.ContainsKey( "IdMap" ) )
                //{
                //    mEffect.GetVariableByName( "gIdTexture3D" ).AsResource().SetResource( tileCacheEntry.D3D11CudaTextures.Get( "IdMap" ) );
                //}
                //else
                //{
                //    System.Console.WriteLine("Warning: expected IdMap not found.");
                //}
                mEffect.GetVariableByName( "gIdTexture3D" ).AsResource().SetResource( tileCacheEntry.D3D11CudaTextures.Get( "IdMap" ) );
                mEffect.GetVariableByName( "gIdColorMapBuffer" ).AsResource().SetResource( mTileManager.Internal.GetIdColorMap() );
                mEffect.GetVariableByName( "gLabelIdMapBuffer" ).AsResource().SetResource( mTileManager.Internal.GetLabelIdMap() );
                mEffect.GetVariableByName( "gIdConfidenceMapBuffer" ).AsResource().SetResource( mTileManager.Internal.GetIdConfidenceMap() );

                if ( tileCacheEntry.D3D11CudaTextures.Internal.ContainsKey( "OverlayMap" ) )
                {
                    mEffect.GetVariableByName( "gOverlayTexture3D" ).AsResource().SetResource( tileCacheEntry.D3D11CudaTextures.Get( "OverlayMap" ) );
                }
            }
            mEffect.GetVariableByName( "gTransform" ).AsMatrix().SetMatrix( camera.GetLookAtMatrix() * camera.GetProjectionMatrix() );
            mEffect.GetVariableByName( "gSegmentationRatio" ).AsScalar().Set( mTileManager.SegmentationVisibilityRatio );
            mEffect.GetVariableByName( "gBoundaryLinesVisible" ).AsScalar().Set( mTileManager.ShowBoundaryLines );
            mEffect.GetVariableByName( "gBrushVisible" ).AsScalar().Set( mTileManager.SelectedSegmentId != 0 );
            mEffect.GetVariableByName( "gSelectedSegmentId" ).AsScalar().Set( mTileManager.SelectedSegmentId );
            mEffect.GetVariableByName( "gMouseOverSegmentId" ).AsScalar().Set( mTileManager.MouseOverSegmentId );

            mEffect.GetVariableByName( "gMouseOverX" ).AsScalar().Set( ( mTileManager.MouseOverX - tileMinExtentX ) / tileCacheEntry.ExtentDataSpace.X );
            mEffect.GetVariableByName( "gMouseOverY" ).AsScalar().Set( ( mTileManager.MouseOverY - tileMinExtentY ) / tileCacheEntry.ExtentDataSpace.Y );
            mEffect.GetVariableByName( "gMouseHighlightSize" ).AsScalar().Set( mTileManager.BrushSize );

            mPass.Apply( deviceContext );
            deviceContext.Draw( QUAD_NUM_VERTICES, 0 );

            //mDebugRenderer.RenderQuadWireframeOnly( deviceContext, p1, p2, p3, p4, new Vector3( 1, 0, 0 ), camera );
        }
Пример #5
0
        public void RenderSphereWireframeOnly( DeviceContext deviceContext, Vector3 p, float radius, Vector3 color, Camera camera )
        {
            var databox = deviceContext.MapSubresource( mPositionVertexBuffer,
                                                        0,
                                                        NUM_VERTICES *
                                                        POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                        POSITION_NUM_BYTES_PER_COMPONENT,
                                                        MapMode.WriteDiscard,
                                                        SlimDX.Direct3D11.MapFlags.None );

            var currentPoint = new Vector3();
            var furtherSouthPoint = new Vector3();
            var numVertices = 0;

            // northSouthTheta traces from north pole to south pole
            float northSouthTheta = (float)Math.PI / 2;

            for ( int i = 0; i <= NUM_LATITUDE_LINES; i++ )
            {
                float currentLatitudeRadius = (float)Math.Cos( northSouthTheta ) * radius;
                float nextLatitudeRadius = (float)Math.Cos( northSouthTheta + LATITUDE_STEP ) * radius;

                // eastWestTheta traces around each latitude line
                float eastWestTheta = 0;

                for ( int j = 0; j <= NUM_LONGITUDE_LINES; j++ )
                {
                    currentPoint.X = p.X + ( (float)Math.Cos( eastWestTheta ) * currentLatitudeRadius );
                    currentPoint.Y = p.Y + ( (float)Math.Sin( northSouthTheta ) * radius );
                    currentPoint.Z = p.Z + ( (float)Math.Sin( eastWestTheta ) * currentLatitudeRadius );

                    databox.Data.Write( currentPoint );
                    numVertices++;

                    furtherSouthPoint.X = p.X + ( (float)Math.Cos( eastWestTheta ) * nextLatitudeRadius );
                    furtherSouthPoint.Y = p.Y + ( (float)Math.Sin( northSouthTheta + LATITUDE_STEP ) * radius );
                    furtherSouthPoint.Z = p.Z + ( (float)Math.Sin( eastWestTheta ) * nextLatitudeRadius );

                    databox.Data.Write( furtherSouthPoint );
                    numVertices++;

                    eastWestTheta += LONGITUDE_STEP;
                }

                northSouthTheta += LATITUDE_STEP;
            }

            deviceContext.UnmapSubresource( mPositionVertexBuffer, 0 );

            deviceContext.InputAssembler.InputLayout = mRenderWireframeInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers( POSITION_SLOT,
                                                           new VertexBufferBinding( mPositionVertexBuffer,
                                                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );

            mEffect.GetVariableByName( "gTransform" ).AsMatrix().SetMatrix( camera.GetLookAtMatrix() * camera.GetProjectionMatrix() );
            mEffect.GetVariableByName( "gColor" ).AsVector().Set( color );

            mRenderWireframePass.Apply( deviceContext );
            deviceContext.Draw( numVertices, 0 );
        }
Пример #6
0
        public void RenderQuadTexture3DOnly( DeviceContext deviceContext, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector3 t1, Vector3 t2, Vector3 t3, Vector3 t4, ShaderResourceView texture, Camera camera )
        {
            DataBox databox;

            databox = deviceContext.MapSubresource( mPositionVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( p1 );
            databox.Data.Write( p4 );
            databox.Data.Write( p2 );
            databox.Data.Write( p3 );

            deviceContext.UnmapSubresource( mPositionVertexBuffer, 0 );

            databox = deviceContext.MapSubresource( mTexCoordVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                    TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( t1 );
            databox.Data.Write( t4 );
            databox.Data.Write( t2 );
            databox.Data.Write( t3 );

            deviceContext.UnmapSubresource( mTexCoordVertexBuffer, 0 );

            deviceContext.InputAssembler.InputLayout = mRenderTexture3DInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers( POSITION_SLOT,
                                                           new VertexBufferBinding( mPositionVertexBuffer,
                                                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );
            deviceContext.InputAssembler.SetVertexBuffers( TEXCOORD_SLOT,
                                                           new VertexBufferBinding( mTexCoordVertexBuffer,
                                                                                    TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                                                    TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );

            mEffect.GetVariableByName( "gTexture3D" ).AsResource().SetResource( texture );
            mEffect.GetVariableByName( "gTransform" ).AsMatrix().SetMatrix( camera.GetLookAtMatrix() * camera.GetProjectionMatrix() );

            mRenderTexture3DPass.Apply( deviceContext );
            deviceContext.Draw( QUAD_NUM_VERTICES, 0 );
        }
Пример #7
0
        public void RenderQuadSolidOnly( DeviceContext deviceContext, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector3 color, Camera camera )
        {
            DataBox databox = deviceContext.MapSubresource( mPositionVertexBuffer,
                                                    0,
                                                    QUAD_NUM_VERTICES *
                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                    MapMode.WriteDiscard,
                                                    SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( p1 );
            databox.Data.Write( p4 );
            databox.Data.Write( p2 );
            databox.Data.Write( p3 );

            deviceContext.UnmapSubresource( mPositionVertexBuffer, 0 );

            deviceContext.InputAssembler.InputLayout = mRenderSolidInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers( POSITION_SLOT,
                                                           new VertexBufferBinding( mPositionVertexBuffer,
                                                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );

            mEffect.GetVariableByName( "gTransform" ).AsMatrix().SetMatrix( camera.GetLookAtMatrix() * camera.GetProjectionMatrix() );
            mEffect.GetVariableByName( "gColor" ).AsVector().Set( color );

            mRenderSolidPass.Apply( deviceContext );
            deviceContext.Draw( QUAD_NUM_VERTICES, 0 );
        }
Пример #8
0
        public void RenderPoint( DeviceContext deviceContext, Vector3 p, Vector3 color, Camera camera )
        {
            var databox = deviceContext.MapSubresource( mPositionVertexBuffer,
                                                        0,
                                                        POINT_NUM_VERTICES *
                                                        POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                        POSITION_NUM_BYTES_PER_COMPONENT,
                                                        MapMode.WriteDiscard,
                                                        SlimDX.Direct3D11.MapFlags.None );

            databox.Data.Write( p );

            deviceContext.UnmapSubresource( mPositionVertexBuffer, 0 );

            deviceContext.InputAssembler.InputLayout = mRenderWireframeInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList;
            deviceContext.InputAssembler.SetVertexBuffers( POSITION_SLOT,
                                                           new VertexBufferBinding( mPositionVertexBuffer,
                                                                                    POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                    POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                    0 ) );

            mEffect.GetVariableByName( "gColor" ).AsVector().Set( color );
            mEffect.GetVariableByName( "gTransform" ).AsMatrix().SetMatrix( camera.GetLookAtMatrix() * camera.GetProjectionMatrix() );
            mRenderWireframePass.Apply( deviceContext );

            deviceContext.Draw( POINT_NUM_VERTICES, 0 );
        }
        private void RenderTileCacheEntry(DeviceContext deviceContext, Camera camera, int datasetExtentDataSpaceX, int datasetExtentDataSpaceY, TileCacheEntry tileCacheEntry)
        {
            //Check if this tile is over the edge of the image
            var tileMinExtentX      = tileCacheEntry.CenterDataSpace.X - (tileCacheEntry.ExtentDataSpace.X / 2f);
            var tileMinExtentY      = tileCacheEntry.CenterDataSpace.Y - (tileCacheEntry.ExtentDataSpace.Y / 2f);
            var tileMaxExtentX      = tileCacheEntry.CenterDataSpace.X + (tileCacheEntry.ExtentDataSpace.X / 2f);
            var tileMaxExtentY      = tileCacheEntry.CenterDataSpace.Y + (tileCacheEntry.ExtentDataSpace.Y / 2f);
            var tileProportionClipX = 1f;
            var tileProportionClipY = 1f;

            if (datasetExtentDataSpaceX > 0 && tileMaxExtentX > datasetExtentDataSpaceX)
            {
                tileProportionClipX = 1 - ((tileMaxExtentX - datasetExtentDataSpaceX) / (tileMaxExtentX - tileMinExtentX));
                tileMaxExtentX      = datasetExtentDataSpaceX;
            }
            if (datasetExtentDataSpaceY > 0 && tileMaxExtentY > datasetExtentDataSpaceY)
            {
                tileProportionClipY = 1 - ((tileMaxExtentY - datasetExtentDataSpaceY) / (tileMaxExtentY - tileMinExtentY));
                tileMaxExtentY      = datasetExtentDataSpaceY;
            }

            var p1 = new Vector3(tileMinExtentX, tileMinExtentY, 0.5f);
            var p2 = new Vector3(tileMinExtentX, tileMaxExtentY, 0.5f);
            var p3 = new Vector3(tileMaxExtentX, tileMaxExtentY, 0.5f);
            var p4 = new Vector3(tileMaxExtentX, tileMinExtentY, 0.5f);

            var t1 = new Vector3(0f, 0f, 0f);
            var t2 = new Vector3(0f, tileProportionClipY, 0f);
            var t3 = new Vector3(tileProportionClipX, tileProportionClipY, 0f);
            var t4 = new Vector3(tileProportionClipX, 0f, 0f);

            DataBox databox;

            databox = deviceContext.MapSubresource(mPositionVertexBuffer,
                                                   0,
                                                   QUAD_NUM_VERTICES *
                                                   POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                   POSITION_NUM_BYTES_PER_COMPONENT,
                                                   MapMode.WriteDiscard,
                                                   SlimDX.Direct3D11.MapFlags.None);

            databox.Data.Write(p1);
            databox.Data.Write(p4);
            databox.Data.Write(p2);
            databox.Data.Write(p3);

            deviceContext.UnmapSubresource(mPositionVertexBuffer, 0);

            databox = deviceContext.MapSubresource(mTexCoordVertexBuffer,
                                                   0,
                                                   QUAD_NUM_VERTICES *
                                                   TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                   TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                   MapMode.WriteDiscard,
                                                   SlimDX.Direct3D11.MapFlags.None);

            databox.Data.Write(t1);
            databox.Data.Write(t4);
            databox.Data.Write(t2);
            databox.Data.Write(t3);

            deviceContext.UnmapSubresource(mTexCoordVertexBuffer, 0);

            deviceContext.InputAssembler.InputLayout       = mInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers(POSITION_SLOT,
                                                          new VertexBufferBinding(mPositionVertexBuffer,
                                                                                  POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                  POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                  0));
            deviceContext.InputAssembler.SetVertexBuffers(TEXCOORD_SLOT,
                                                          new VertexBufferBinding(mTexCoordVertexBuffer,
                                                                                  TEXCOORD_NUM_COMPONENTS_PER_VERTEX *
                                                                                  TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                                                                  0));

            mEffect.GetVariableByName("gSourceTexture3D").AsResource().SetResource(tileCacheEntry.D3D11CudaTextures.Get("SourceMap"));
            if (mTileManager.SegmentationLoaded)
            {
                //if ( tileCacheEntry.D3D11CudaTextures.Internal.ContainsKey( "IdMap" ) )
                //{
                //    mEffect.GetVariableByName( "gIdTexture3D" ).AsResource().SetResource( tileCacheEntry.D3D11CudaTextures.Get( "IdMap" ) );
                //}
                //else
                //{
                //    System.Console.WriteLine("Warning: expected IdMap not found.");
                //}
                mEffect.GetVariableByName("gIdTexture3D").AsResource().SetResource(tileCacheEntry.D3D11CudaTextures.Get("IdMap"));
                mEffect.GetVariableByName("gIdColorMapBuffer").AsResource().SetResource(mTileManager.Internal.GetIdColorMap());
                mEffect.GetVariableByName("gLabelIdMapBuffer").AsResource().SetResource(mTileManager.Internal.GetLabelIdMap());
                mEffect.GetVariableByName("gIdConfidenceMapBuffer").AsResource().SetResource(mTileManager.Internal.GetIdConfidenceMap());
            }
            mEffect.GetVariableByName("gTransform").AsMatrix().SetMatrix(camera.GetLookAtMatrix() * camera.GetProjectionMatrix());
            mEffect.GetVariableByName("gSegmentationRatio").AsScalar().Set(mTileManager.SegmentationVisibilityRatio);
            mEffect.GetVariableByName("gBoundaryLinesVisible").AsScalar().Set(mTileManager.ShowBoundaryLines);
            mEffect.GetVariableByName("gSelectedSegmentId").AsScalar().Set(mTileManager.SelectedSegmentId);
            mEffect.GetVariableByName("gMouseOverSegmentId").AsScalar().Set(mTileManager.MouseOverSegmentId);

            mPass.Apply(deviceContext);
            deviceContext.Draw(QUAD_NUM_VERTICES, 0);

            //mDebugRenderer.RenderQuadWireframeOnly( deviceContext, p1, p2, p3, p4, new Vector3( 1, 0, 0 ), camera );
        }
Пример #10
0
        public void RenderSphereSolidOnly(DeviceContext deviceContext, Vector3 p, float radius, Vector3 color, Camera camera)
        {
            var databox = deviceContext.MapSubresource(mPositionVertexBuffer,
                                                       0,
                                                       NUM_VERTICES *
                                                       POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                       POSITION_NUM_BYTES_PER_COMPONENT,
                                                       MapMode.WriteDiscard,
                                                       SlimDX.Direct3D11.MapFlags.None);

            var currentPoint      = new Vector3();
            var furtherSouthPoint = new Vector3();
            var numVertices       = 0;

            // northSouthTheta traces from north pole to south pole
            float northSouthTheta = (float)Math.PI / 2;

            for (int i = 0; i <= NUM_LATITUDE_LINES; i++)
            {
                float currentLatitudeRadius = (float)Math.Cos(northSouthTheta) * radius;
                float nextLatitudeRadius    = (float)Math.Cos(northSouthTheta + LATITUDE_STEP) * radius;

                // eastWestTheta traces around each latitude line
                float eastWestTheta = 0;

                for (int j = 0; j <= NUM_LONGITUDE_LINES; j++)
                {
                    currentPoint.X = p.X + ((float)Math.Cos(eastWestTheta) * currentLatitudeRadius);
                    currentPoint.Y = p.Y + ((float)Math.Sin(northSouthTheta) * radius);
                    currentPoint.Z = p.Z + ((float)Math.Sin(eastWestTheta) * currentLatitudeRadius);

                    databox.Data.Write(currentPoint);
                    numVertices++;

                    furtherSouthPoint.X = p.X + ((float)Math.Cos(eastWestTheta) * nextLatitudeRadius);
                    furtherSouthPoint.Y = p.Y + ((float)Math.Sin(northSouthTheta + LATITUDE_STEP) * radius);
                    furtherSouthPoint.Z = p.Z + ((float)Math.Sin(eastWestTheta) * nextLatitudeRadius);

                    databox.Data.Write(furtherSouthPoint);
                    numVertices++;

                    eastWestTheta += LONGITUDE_STEP;
                }

                northSouthTheta += LATITUDE_STEP;
            }

            deviceContext.UnmapSubresource(mPositionVertexBuffer, 0);

            deviceContext.InputAssembler.InputLayout       = mRenderSolidInputLayout;
            deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
            deviceContext.InputAssembler.SetVertexBuffers(POSITION_SLOT,
                                                          new VertexBufferBinding(mPositionVertexBuffer,
                                                                                  POSITION_NUM_COMPONENTS_PER_VERTEX *
                                                                                  POSITION_NUM_BYTES_PER_COMPONENT,
                                                                                  0));

            mEffect.GetVariableByName("gTransform").AsMatrix().SetMatrix(camera.GetLookAtMatrix() * camera.GetProjectionMatrix());
            mEffect.GetVariableByName("gColor").AsVector().Set(color);

            mRenderSolidPass.Apply(deviceContext);
            deviceContext.Draw(numVertices, 0);
        }