Пример #1
0
		void MotionWindow_Loaded(object sender, RoutedEventArgs e)
		{
			Transform3DGroup gp = new Transform3DGroup();
			uBase.Load(@"3DModules\upper.xaml");
			ScaleTransform3D sc = new ScaleTransform3D(12, 12, 1, 0, 0, 0);
			TranslateTransform3D tt = new TranslateTransform3D(0, 0, -15.5);
			gp.Children.Add(sc);
			gp.Children.Add(tt);
			uBase.Transform = gp;
			uPlatform.Load(@"3DModules\platform.xaml");
			upper.Load(@"3DModules\upper.xaml");
			AbsoluteVisual.AddLight(Colors.Wheat, new Vector3D(-1, -1, -1), Colors.Gray);
			vpMain.PlaceCamera(
				new Point3D(0, 0, 500),
				new Vector3D(0, 0, -1),
				new Vector3D(0, 1, 0),
				45
			);
			AbsoluteVisual.Children.Add(uBase);
			AbsoluteVisual.Children.Add(uPlatform);
			AbsoluteVisual.Children.Add(upper);
			ca = new EventCameraAgent(vpMain);
			ca.MouseLockRelPos = new Point(1, 1);
			ca.BindEventTo(this);
			ca.OnCameraStatusChange += new CameraAgent.CameraTransformHandler(ca_OnCameraStatusChange);
		}
Пример #2
0
		void Test_Loaded(object sender, RoutedEventArgs e)
		{
			//ModelVisual3D mv = vpMain.Children[0] as ModelVisual3D;
			//GeneralTransform3DTo2D gt = mv.TransformToAncestor(cvMain);
			//Point p = gt.Transform(new Point3D(1, 1, 1));
			//Canvas.SetLeft(btnTest, p.X);
			//Canvas.SetTop(btnTest, p.Y);
			this.WindowState = WindowState.Maximized;
			this.WindowStyle = WindowStyle.None;
			Width = SystemParameters.PrimaryScreenWidth;
			Height = SystemParameters.PrimaryScreenHeight;
			vpMain.Width = ActualWidth;
			vpMain.Height = ActualHeight;
			
			for (int i = 1; i <= 100; i++)
			{
				ModelVisual3D mv = new ModelVisual3D();
				mv.Content = mCube;
				mv.Transform = new TranslateTransform3D(0, 20 * i, 0);
				uMain.Children.Add(mv);
			}

			EventCameraAgent ca = new EventCameraAgent(vpMain);
			ca.MouseLockRelPos = new Point(1, 1);
			ca.BindEventTo(this);
			ca.OnMouseDown += new EventCameraAgent.DlgMouseDownEventHandler(delegate(object sdr, MouseButtonEventArgs evt)
			{
				if (evt.LeftButton == MouseButtonState.Pressed)
				{
					WindowState = WindowState.Minimized;
				}
			});
			ca.OnCameraStatusChange += CSC;
			t = new Timer(32);
			t.Elapsed += new ElapsedEventHandler(t_Elapsed);
			t.Enabled = true;
			t.Start();
			uMain.OriginPosition = new Point3D(5, 5, 5);
			uMain.Agent.Start();
			Activated += new EventHandler(Test_Activated);
		}
Пример #3
0
		void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			object oVisual = XamlReader.Load
			(new FileStream
			(@"..\..\3DModules\Fighter.xaml", FileMode.Open));
			vpMain.Camera = new PerspectiveCamera(
				new Point3D(-500, 0, 0),
				new Vector3D(0, 0, -1),
				new Vector3D(0, 1, 0),
				45
			);
			
			lvMain = new LightVisual3D();
			grpMain = new Model3DGroup();
			lvMain.Content = grpMain;
			grpMain.Children.Add(oVisual as Model3DGroup);
			lvMain.AddLight(Colors.Wheat, new Vector3D(-1, -1, -1), Colors.Gray);
			vpMain.Children.Add(lvMain);
			for (int i = 0; i <= 200; i++)
			{
				
				LightVisual3D lv = new LightVisual3D();
				Model3DGroup grp = new Model3DGroup();
				lv.Content = grp;
				grp.Children.Add(oVisual as Model3DGroup);
				lv.Transform = new TranslateTransform3D(0, 0, -100 * i);
				lvMain.Children.Add(lv);
			}
			ca = new EventCameraAgent(vpMain);
			ca.BindEventTo(this);
			ca.OnMouseDown += MainWindow_MouseDown;
			ca.OnMouseMove += MainWindow_MouseMove;
			//WinAPI.SetCursorPos(ActualWidth / 2, ActualHeight / 2);
			WinAPI.SetCursorPos(200, 200);
			MouseDown += new MouseButtonEventHandler(MainWindow_MouseDown);
			Activated += new EventHandler(MainWindow_Activated);
			
		}