Beispiel #1
0
		public CubeRenderer(GraphicsDeviceControl parentControl, CameraController cameraController)
		{
			parentControl.MouseDown += (sender, e) =>
			{
				if (IsWithinCameraCube(parentControl, e.Location))
				{
					cameraController.MouseDown(ToXnaPoint(e.Location));
					_isCubeActive = true;
					parentControl.Invalidate();
				}
			};
			parentControl.MouseMove += (sender, e) =>
			{
				bool isCubeActive = _isCubeActive;
				_isCubeActive = IsWithinCameraCube(parentControl, e.Location) || cameraController.IsMouseButtonDown;
				if (cameraController.MouseMove(ToXnaPoint(e.Location)) || isCubeActive != _isCubeActive)
					parentControl.Invalidate();
			};
			parentControl.MouseUp += (sender, e) =>
			{
				if (!IsWithinCameraCube(parentControl, e.Location))
				{
					_isCubeActive = false;
					parentControl.Invalidate();
				}
				cameraController.MouseUp(ToXnaPoint(e.Location));
			};

			_size = 100; // TODO: Make this a configurable setting.
		}
Beispiel #2
0
		public ModelRenderer(GraphicsDeviceControl parentControl)
		{
			_parentControl = parentControl;
			_ballController = new CameraController();

			parentControl.MouseWheelWpf += (sender, e) =>
			{
				_cameraPosition += _viewDirection * e.Delta * _modelRadius * 0.001f;
				parentControl.Invalidate();
			};

			_widgets = new ModelRendererWidget[4];
			_widgets[0] = new GridRenderer(parentControl);
			_widgets[1] = new CubeRenderer(parentControl, _ballController);

			_normalsRenderer = new NormalsRenderer(parentControl, this);
			_widgets[2] = _normalsRenderer;

			_bboxRenderer = new BoundingBoxRenderer(parentControl, this);
			_widgets[3] = _bboxRenderer;
		}