Ejemplo n.º 1
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     _track = new Trackball();
     _track.Attach(this);
     _track.Slaves.Add((Viewport3D)this.FindName("myViewport"));
     _track.Enabled = true;
 }
Ejemplo n.º 2
0
 private void OnLoaded(object sender, EventArgs e)
 {
     // setup trackball for moving the model around
     _trackball = new Trackball();
     _trackball.Attach(this);
     _trackball.Slaves.Add(myViewport3D);
     _trackball.Enabled = true;
 }
Ejemplo n.º 3
0
        public CubeControl()
        {
            InitializeComponent();

            _trackball = new Trackball();
            _trackball.Attach(this);
            _trackball.Slaves.Add(myViewport3D);
            _trackball.Enabled = true;

            BeginStoryboard((Storyboard)FindResource("RotateStoryboard"));
        }
Ejemplo n.º 4
0
        private void GraphScene3D(Canvas screenCanvas, String eqX, String eqY, String eqZ)
        {
            // We do this so we can get good error information.
            // The values return by these calls are ignored.
            FunctionParser.Parse(eqX);
            FunctionParser.Parse(eqY);
            FunctionParser.Parse(eqZ);


            PerspectiveCamera camera = new PerspectiveCamera();

            camera.Position          = new Point3D(0, 0, 5);
            camera.LookDirection     = new Vector3D(0, 0, -2);
            camera.UpDirection       = new Vector3D(0, 1, 0);
            camera.NearPlaneDistance = 1;
            camera.FarPlaneDistance  = 100;
            camera.FieldOfView       = 45;

            Model3DGroup group = null;


            group = new Model3DGroup();
            FunctionMesh mesh = new FunctionMesh(eqX, eqY, eqZ, UMin, UMax, VMin, VMax);

            group.Children.Add(new GeometryModel3D(mesh.CreateMesh(UGrid + 1, VGrid + 1), new DiffuseMaterial(Brushes.Blue)));
            group.Children.Add(new DirectionalLight(Colors.White, new Vector3D(-1, -1, -1)));


            Viewport3D viewport = new Viewport3D();

            //<newcode>
            ModelVisual3D sceneVisual = new ModelVisual3D();

            sceneVisual.Content = group;
            viewport.Children.Clear();
            viewport.Children.Add(sceneVisual);
            //</newcode>


            //viewport.Models = group;
            viewport.Camera       = camera;
            viewport.Width        = CanvasWidth;
            viewport.Height       = CanvasHeight;
            viewport.ClipToBounds = true;

            screenCanvas.Children.Clear();
            screenCanvas.Children.Add(viewport);
            _tb = new Trackball();
            _tb.Attach(screenCanvas);
            _tb.Enabled = true;
            _tb.Servants.Add(viewport);
            screenCanvas.IsVisibleChanged += new DependencyPropertyChangedEventHandler(screenCanvas_IsVisibleChanged);
        }
Ejemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            //// Kinectが接続されているかどうかを確認する
            //if ( KinectSensor.KinectSensors.Count == 0 ) {
            //    throw new Exception( "Kinectを接続してください" );
            //}

            //// Kinectの動作を開始する
            //StartKinect( KinectSensor.KinectSensors[0] );

            _trackball = new Trackball();
            _trackball.Attach(this);
            _trackball.Slaves.Add(myViewport3D);
            _trackball.Enabled = true;
        }
Ejemplo n.º 6
0
        private void OnLoaded(object sender, EventArgs e)
        {
            // setup trackball for moving the model around
            _trackball = new Trackball();
            _trackball.Attach(this);
            _trackball.Servants.Add(myViewport3D);
            _trackball.Enabled = true;

            // Get the mesh objects for changing the material
            ModelVisual3D mv3d     = myViewport3D.Children[0] as ModelVisual3D;
            Model3DGroup  m3dgBase = mv3d.Content as Model3DGroup;

            Model3DGroup m3dg = m3dgBase.Children[0] as Model3DGroup;

            _TopPlane    = m3dg.Children[2] as GeometryModel3D;
            _BottomPlane = m3dg.Children[3] as GeometryModel3D;

            m3dg            = m3dgBase.Children[1] as Model3DGroup;
            _FrontSpinPlane = m3dg.Children[0] as GeometryModel3D;
            _BackSpinPlane  = m3dg.Children[1] as GeometryModel3D;

            AnimateToNextPicture();
        }
Ejemplo n.º 7
0
        private void GraphScene3D(Canvas screenCanvas,String eqX, String eqY, String eqZ)
        {
            // We do this so we can get good error information.
            // The values return by these calls are ignored.
            FunctionParser.Parse(eqX);
            FunctionParser.Parse(eqY);
            FunctionParser.Parse(eqZ);

            PerspectiveCamera camera = new PerspectiveCamera();
            camera.Position = new Point3D(0, 0, 5);
            camera.LookDirection = new Vector3D(0, 0, -2);
            camera.UpDirection = new Vector3D(0, 1, 0);
            camera.NearPlaneDistance = 1;
            camera.FarPlaneDistance = 100;
            camera.FieldOfView = 45;

            Model3DGroup group = null;

            group = new Model3DGroup();
            FunctionMesh mesh = new FunctionMesh(eqX, eqY, eqZ, UMin, UMax, VMin, VMax);
            group.Children.Add(new GeometryModel3D(mesh.CreateMesh(UGrid + 1, VGrid + 1), new DiffuseMaterial(Brushes.Blue)));
            group.Children.Add(new DirectionalLight(Colors.White, new Vector3D(-1, -1, -1)));

            Viewport3D viewport = new Viewport3D();

            //<newcode>
            ModelVisual3D sceneVisual = new ModelVisual3D();
            sceneVisual.Content = group;
            viewport.Children.Clear();
            viewport.Children.Add(sceneVisual);
            //</newcode>

            //viewport.Models = group;
            viewport.Camera = camera;
            viewport.Width = CanvasWidth;
            viewport.Height = CanvasHeight;
            viewport.ClipToBounds = true;

            screenCanvas.Children.Clear();
            screenCanvas.Children.Add(viewport);
            _tb = new Trackball();
            _tb.Attach(screenCanvas);
            _tb.Enabled = true;
            _tb.Servants.Add(viewport);
            screenCanvas.IsVisibleChanged += new DependencyPropertyChangedEventHandler(screenCanvas_IsVisibleChanged);
        }
Ejemplo n.º 8
0
        private void OnLoaded(object sender, EventArgs args)
        {
            immediate.Focus();
            viewport  = new Viewport3D();
            trackball = new Trackball();
            trackball.Servants.Add(viewport);
            trackball.Attach(screen);
            trackball.Enabled = true;

            graphNone.Header      = Settings.functionNone;
            graph.Header          = Settings.function;
            graph2D.Header        = Settings.function2D;
            graph3D.Header        = Settings.function3D;
            graphOptions.Header   = Settings.function;
            graphOptions2D.Header = Settings.function2D;
            graphOptions3D.Header = Settings.function3D;

            // Workaround for registry bug (key base must exist before getting values - else default won't work)
            Registry.SetValue(regSaveBase, "Version", "GraphCalc v.1.0", RegistryValueKind.String);

            xMin.Text = (string)Registry.GetValue(regSaveBase, Settings.xMinReg, Settings.xMinDefault);
            xMax.Text = (string)Registry.GetValue(regSaveBase, Settings.xMaxReg, Settings.xMaxDefault);
            yMin.Text = (string)Registry.GetValue(regSaveBase, Settings.yMinReg, Settings.yMinDefault);
            yMax.Text = (string)Registry.GetValue(regSaveBase, Settings.yMaxReg, Settings.yMaxDefault);

            xMinLabel.Text = Settings.xMin;
            xMaxLabel.Text = Settings.xMax;
            yMinLabel.Text = Settings.yMin;
            yMaxLabel.Text = Settings.yMax;

            xMin2D.Text  = (string)Registry.GetValue(regSaveBase, Settings.xMin2DReg, Settings.xMin2DDefault);
            xMax2D.Text  = (string)Registry.GetValue(regSaveBase, Settings.xMax2DReg, Settings.xMax2DDefault);
            yMin2D.Text  = (string)Registry.GetValue(regSaveBase, Settings.yMin2DReg, Settings.yMin2DDefault);
            yMax2D.Text  = (string)Registry.GetValue(regSaveBase, Settings.yMax2DReg, Settings.yMax2DDefault);
            tMin2D.Text  = (string)Registry.GetValue(regSaveBase, Settings.tMin2DReg, Settings.tMin2DDefault);
            tMax2D.Text  = (string)Registry.GetValue(regSaveBase, Settings.tMax2DReg, Settings.tMax2DDefault);
            tStep2D.Text = (string)Registry.GetValue(regSaveBase, Settings.tStep2DReg, Settings.tStep2DDefault);

            xMin2DLabel.Text  = Settings.xMin2D;
            xMax2DLabel.Text  = Settings.xMax2D;
            yMin2DLabel.Text  = Settings.yMin2D;
            yMax2DLabel.Text  = Settings.yMax2D;
            tMin2DLabel.Text  = Settings.tMin2D;
            tMax2DLabel.Text  = Settings.tMax2D;
            tStep2DLabel.Text = Settings.tStep2D;

            uMin.Text  = (string)Registry.GetValue(regSaveBase, Settings.uMinReg, Settings.uMinDefault);
            uMax.Text  = (string)Registry.GetValue(regSaveBase, Settings.uMaxReg, Settings.uMaxDefault);
            uGrid.Text = (string)Registry.GetValue(regSaveBase, Settings.uGridReg, Settings.uGridDefault);
            vMin.Text  = (string)Registry.GetValue(regSaveBase, Settings.vMinReg, Settings.vMinDefault);
            vMax.Text  = (string)Registry.GetValue(regSaveBase, Settings.vMaxReg, Settings.vMaxDefault);
            vGrid.Text = (string)Registry.GetValue(regSaveBase, Settings.vGridReg, Settings.vGridDefault);

            uMinLabel.Text  = Settings.uMin;
            uMaxLabel.Text  = Settings.uMax;
            uGridLabel.Text = Settings.uGrid;
            vMinLabel.Text  = Settings.vMin;
            vMaxLabel.Text  = Settings.vMax;
            vGridLabel.Text = Settings.vGrid;

            y.Text  = (string)Registry.GetValue(regSaveBase, Settings.yReg, Settings.yDefault);
            xt.Text = (string)Registry.GetValue(regSaveBase, Settings.xtReg, Settings.xtDefault);
            yt.Text = (string)Registry.GetValue(regSaveBase, Settings.ytReg, Settings.ytDefault);
            fx.Text = (string)Registry.GetValue(regSaveBase, Settings.fxReg, Settings.fxDefault);
            fy.Text = (string)Registry.GetValue(regSaveBase, Settings.fyReg, Settings.fyDefault);
            fz.Text = (string)Registry.GetValue(regSaveBase, Settings.fzReg, Settings.fzDefault);

            yLabel.Text  = Settings.y;
            xtLabel.Text = Settings.xt;
            ytLabel.Text = Settings.yt;
            fxLabel.Text = Settings.fx;
            fyLabel.Text = Settings.fy;
            fzLabel.Text = Settings.fz;
        }