예제 #1
0
        /// <summary>
        /// Loads the input data from disk.
        /// </summary>
        public override void Initialize()
        {
            InputData = RenderContext.Content.LoadWithAttributeParser <ZippedMriData>(_dataPath);

            Camera = new FirstPersonCamera(RenderContext.GraphicsDevice, new Vector3(-100, 100, -100));
            Camera.AddHorizontalRotation(MathHelper.ToRadians(90 + 45));

            var builder = new LineMeshDescriptionBuilder();
            var bbox    = new BoundingBox(Vector3.Zero, new Vector3(InputData.XLength, InputData.YLength, InputData.ZLength));

            builder.AddBox(bbox, Color.Black);
            _mesh = RenderContext.MeshCreator.CreateMesh(builder);

            _pen            = new VertexColorPen(CullMode.None);
            _cameraAttached = false;
            ToggleCameraAttach();
        }
        /// <summary>
        /// Creates a new instance of the visualizer which will display a cube in the current working array.
        /// </summary>
        /// <param name="renderContext"></param>
        /// <param name="inputData"></param>
        /// <param name="backgroundWorker"></param>
        /// <param name="camera"></param>
        public ActiveCubeVisualizer(IRenderContext renderContext, IInputData inputData, VisualizerBackgroundWorker backgroundWorker, ICamera camera)
        {
            _renderContext    = renderContext;
            _inputData        = inputData;
            _backgroundWorker = backgroundWorker;
            _camera           = camera;
            _pen = new SolidColorPen(Color.Red, CullMode.None);
            // we want to draw the outside surfaces of the currently worked on cube and its outline
            // currently this requires 2 meshes: one with the surfaces as triangles (for coloring) and one with only the outline as lines
            // if we used e.g. only the first mesh, the pen would also draw lines across the surfaces which we don't want
            // again: inefficient, but we don't care because it doesn't have to be efficient
            var cube = new TextureMeshDescriptionBuilder();
            var box  = new BoundingBox(Vector3.Zero, Vector3.One);

            cube.AddRoom(box, Vector2.One);
            _visualizerMesh = renderContext.MeshCreator.CreateMesh(cube);
            var cube2 = new LineMeshDescriptionBuilder();

            cube2.AddBox(box, Color.Black);
            _visualizerLineMesh = renderContext.MeshCreator.CreateMesh(cube2);

            _cubesPerTick = 1;
        }