当前位置: 首页>>代码示例>>C#>>正文


C# AABB.Include方法代码示例

本文整理汇总了C#中AABB.Include方法的典型用法代码示例。如果您正苦于以下问题:C# AABB.Include方法的具体用法?C# AABB.Include怎么用?C# AABB.Include使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AABB的用法示例。


在下文中一共展示了AABB.Include方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnSelectionMoved

		public void OnSelectionMoved()
		{
			// Select images and lay selectionAabb around selected images
			if(selection == null || selection.IsEmpty)
				selectionAabb = null;
			else
			{
				selectionAabb = new AABB();
				if(viewControl == ViewControl.TwoDimensional)
					foreach(TransformedImage selectedimage in selection)
					{
						AABB selectedimageBounds = selectedimage.GetBounds().Clone();
						selectedimageBounds.min.Z = selectedimageBounds.max.Z = (selectedimageBounds.min.Z + selectedimageBounds.max.Z) / 2.0f;
						selectionAabb.Include(selectedimageBounds);
					}
				else
					foreach(TransformedImage selectedimage in selection)
						selectionAabb.Include(selectedimage.GetBounds());
			}
		}
开发者ID:RcSepp,项目名称:global_view,代码行数:20,代码来源:ImageCloud.cs

示例2: Draw

		protected override void Draw(float dt, Matrix4 _transform)
		{
			if(overallAabb_invalid)
			{
				if(images != null)
				{
					overallAabb_invalid = false;
					overallAabb = new AABB();
					foreach(TransformedImage image in images.Values)
						overallAabb.Include(image.GetBounds());
				}
				else
					overallAabb = new AABB(Vector3.Zero, Vector3.Zero);
			}

			float maxdist = 1.0f;
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.min.X, overallAabb.min.Y, overallAabb.min.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.min.X, overallAabb.min.Y, overallAabb.max.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.min.X, overallAabb.max.Y, overallAabb.min.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.min.X, overallAabb.max.Y, overallAabb.max.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.max.X, overallAabb.min.Y, overallAabb.min.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.max.X, overallAabb.min.Y, overallAabb.max.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.max.X, overallAabb.max.Y, overallAabb.min.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.max.X, overallAabb.max.Y, overallAabb.max.Z) - freeview.viewpos).Length);
			//maxdist *= 1.1f;
			maxdist *= 2.0f;
			freeview.SetZRange(maxdist / 10000.0f, maxdist);

			// >>> Render

			GL.Enable(EnableCap.DepthTest);

			foreach(ImageTransform transform in transforms)
				transform.OnRender(dt, freeview);

			Matrix4 vieworient = freeview.viewmatrix, invvieworient;
			vieworient.M41 = vieworient.M42 = vieworient.M43 = 0.0f;
			invvieworient = vieworient;
			invvieworient.Transpose();

			if(selectionAabb != null)
			{
				//sdrAabb.Bind(selectionAabb.GetTransform() * freeview.viewprojmatrix);
				//Common.meshLineCube.Bind(sdrAabb, null);
				//Common.meshLineCube.Draw();
			}
			else if(showCoordinateSystem)
				coordsys.Draw(Vector3.Zero, freeview.viewprojmatrix, vieworient, freeview.viewpos, FOV_Y * backbuffersize.Width / backbuffersize.Height, backbuffersize);

			if(depthRenderingEnabled)
			{
				depthRenderingEnabled_fade += 1.0f * dt;
				if(depthRenderingEnabled_fade > 1.0f)
					depthRenderingEnabled_fade = 1.0f;
			}
			else
			{
				depthRenderingEnabled_fade -= 1.0f * dt;
				if(depthRenderingEnabled_fade < 0.0f)
					depthRenderingEnabled_fade = 0.0f;
			}

			if(images != null)
			{
#if USE_DEPTH_SORTING
				SortedList<TransformedImageAndMatrix> renderlist = new SortedList<TransformedImageAndMatrix>();
#endif

				foreach(TransformedImage iter in Viewer.visible)
					iter.PrepareRender();

				float invNumBackbufferPixels = 1.0f / ((float)backbuffersize.Width * (float)backbuffersize.Height);

				// >>> Perform temporal prefetching

				float _time = Global.time;
				//Global.time += 0.5f; // Prefetch 0.5 second into the future
				Global.time += 1.1f;
				//Global.time += 4.1f;
				//Global.time += 7.1f;
				// If the prefetching intervall is too short, images aren't loaded on time.
				// If the prefetching intervall is too long, too much memory is consumed.
				// Optimally the prefetching intervall should depend on the load time.
				foreach(TransformedImage iter in Viewer.visible)
					iter.PrefetchRenderPriority(freeview, invvieworient, backbuffersize);
				Global.time = _time;

				foreach(TransformedImage iter in Viewer.images)
				{
					// >>> Update image transforms

					iter.Update(dt);
				/*}

				foreach(TransformedImage iter in Viewer.visible) //EDIT: If only visible images get iterated here, render priority of invisible images will never be set to zero inside IsVisible()
				{*/
					Matrix4 transform;
					if(iter.IsVisible(freeview, invvieworient, backbuffersize, out transform))
					{
#if USE_DEPTH_SORTING
//.........这里部分代码省略.........
开发者ID:RcSepp,项目名称:global_view,代码行数:101,代码来源:ImageCloud.cs

示例3: Focus

		public void Focus(IEnumerable<TransformedImage> images, bool animate)
		{
			AABB aabb = new AABB();
			if(viewControl == ViewControl.TwoDimensional)
				foreach(TransformedImage image in images)
				{
					AABB imageBounds = image.GetBounds().Clone();
					imageBounds.min.Z = imageBounds.max.Z = (imageBounds.min.Z + imageBounds.max.Z) / 2.0f;
					aabb.Include(imageBounds);
				}
			else
				foreach(TransformedImage image in images)
					aabb.Include(image.GetBounds());
			if(aabb.max.X >= aabb.min.X)
			{
				FocusAABB(aabb, animate);
				Status("Focus images");
			}
		}
开发者ID:RcSepp,项目名称:global_view,代码行数:19,代码来源:ImageCloud.cs

示例4: ProcessInputEvents

		public void ProcessInputEvents(bool dtValid = true) // Should be called either once per frame or whenever a mouse or keyboard event is fired
		{
			if(inputEventTimer == null)
			{
				inputEventTimer = new System.Diagnostics.Stopwatch();
				inputEventTimer.Start();
				return;
			}
			float dt = (float)inputEventTimer.Elapsed.TotalSeconds;
			//if(dt < 0.01f)
			//	return; // Ignore events less than 0.01 seconds appart
			inputEventTimer.Restart();

			//Global.dt = Math.Min(0.1f, Global.dt); // Avoid high dt during lags

			if(dt < 1.0f && dtValid)
			{
				inputEventAverageDt = dt + (float)inputEventFrameCounter * inputEventAverageDt;
				inputEventAverageDt /= (float)++inputEventFrameCounter;
			}
			else
			{
				dt = inputEventAverageDt;
				++inputEventFrameCounter;
			}


			if(overallAabb_invalid)
			{
				if(images != null)
				{
					overallAabb_invalid = false;
					overallAabb = new AABB();
					foreach(TransformedImage image in images.Values)
						overallAabb.Include(image.GetBounds());
				}
				else
					overallAabb = new AABB(Vector3.Zero, Vector3.Zero);
			}

			float maxdist = 0.0f;
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.min.X, overallAabb.min.Y, overallAabb.min.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.min.X, overallAabb.min.Y, overallAabb.max.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.min.X, overallAabb.max.Y, overallAabb.min.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.min.X, overallAabb.max.Y, overallAabb.max.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.max.X, overallAabb.min.Y, overallAabb.min.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.max.X, overallAabb.min.Y, overallAabb.max.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.max.X, overallAabb.max.Y, overallAabb.min.Z) - freeview.viewpos).Length);
			maxdist = Math.Max(maxdist, (new Vector3(overallAabb.max.X, overallAabb.max.Y, overallAabb.max.Z) - freeview.viewpos).Length);
			maxdist *= 1.1f;
			camera_speed = 0.1f * maxdist;
			camera_speed = Math.Max(1.0f, camera_speed);
			//camera_speed = Math.Min(10.0f, camera_speed);

			// >>> Update free-view matrix

			if(glcontrol_focused)
			{
				bool viewChanged = false;
				float mdx, mdy, mdz;
				if(colorTableMgr != null && colorTableMgr.Visible && colorTableMgr.InsideMouseWheelArea(glcontrol.PointToClient(Control.MousePosition)))
					mdx = mdy = mdz = 0.0f;
				else
				{
					mdx = InputDevices.mdx;
					mdy = InputDevices.mdy;
					mdz = InputDevices.mdz;
				}
				if(viewControl == ViewControl.TwoDimensional)
				{
					freeview.ClearRotation();

					Vector3 freeViewTranslation = Vector3.Zero;//new Vector3(0.0f, 0.0f, camera_speed * 10.0f * mdz); //mdz / dt);
					if(mdz != 0)
						freeViewTranslation.Z = freeview.viewpos.Z * 2.0f * mdz;
					//Vector3 freeViewTranslation = new Vector3(0.0f, 0.0f, 10.0f * camera_speed * mdz); //mdz / dt);

					if(mouseDownInsideImageCloud && dragImage == null && (InputDevices.mstate.IsButtonDown(MouseButton.Middle) || InputDevices.mstate.IsButtonDown(MouseButton.Right)))
					{
						Vector2 dm = new Vector2(4.0f * (Control.MousePosition.X - oldmousepos.X) / backbuffersize.Width, 4.0f * (oldmousepos.Y - Control.MousePosition.Y) / backbuffersize.Height);
						Vector3 vnear = new Vector3(dm.X, dm.Y, 0.0f);
						Vector3 vfar = new Vector3(vnear.X, vnear.Y, 1.0f);
						Matrix4 invviewprojmatrix = freeview.viewprojmatrix.Inverted();
						vnear = Vector3.TransformPerspective(vnear, invviewprojmatrix);
						vfar = Vector3.TransformPerspective(vfar, invviewprojmatrix);
						Vector3 vdir = (vfar - vnear).Normalized();

						freeViewTranslation.X = 31.0f * vdir.X * freeview.viewpos.Z;//(float)dm.X / (float)backbuffersize.Width * freeview.viewpos.Z / (float)Z_NEAR;
						freeViewTranslation.Y = 31.0f * vdir.Y * freeview.viewpos.Z;//(float)dm.Y / (float)backbuffersize.Height * freeview.viewpos.Z / (float)Z_NEAR;
					}
					oldmousepos = Control.MousePosition;

					if(freeViewTranslation.X != 0.0f || freeViewTranslation.Y != 0.0f || freeViewTranslation.Z != 0.0f)
					{
						freeViewTranslation = Vector3.Multiply(freeViewTranslation, dt);
						if(freeview.viewpos.Z - freeViewTranslation.Z < freeview.znear * 1.1f)
							freeViewTranslation.Z = freeview.viewpos.Z - freeview.znear * 1.1f;
						freeview.Translate(freeViewTranslation);
						viewChanged = true;
					}
//.........这里部分代码省略.........
开发者ID:RcSepp,项目名称:global_view,代码行数:101,代码来源:ImageCloud.cs


注:本文中的AABB.Include方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。