示例#1
0
		private void RecreateNormals()
		{
			_options = _optionsService.GetContentPreviewOptions();

			if (_model == null)
				return;

			// Extract normals.
			foreach (ModelMesh mesh in _model.Meshes)
				foreach (ModelMeshPart meshPart in mesh.MeshParts)
					meshPart.Tag = GetNormalBuffers(mesh, meshPart, _parentControl.GraphicsDevice, _options.NormalLengthPercentage);
		}
		private void RecreateBoundingBox()
		{
			_options = _optionsService.GetContentPreviewOptions();

			if (_model == null)
				return;

			foreach (ModelMesh mesh in _model.Meshes)
			{
				BoundingBox boundingBox = new BoundingBox();
				foreach (ModelMeshPart meshPart in mesh.MeshParts)
				{
					BoundingBox? bbox = GetBoundingBox(meshPart);
					if (bbox != null)
						boundingBox = BoundingBox.CreateMerged(boundingBox, bbox.Value);
				}

				mesh.Tag = CreateBoundingBoxBuffers(boundingBox, _parentControl.GraphicsDevice);
			}
		}
示例#3
0
		private void RecreateGrid(GraphicsDevice graphicsDevice, IOptionsService optionsService)
		{
			_options = optionsService.GetContentPreviewOptions();
			_spacing = _options.GridSpacing;
			_majorLines = _options.MajorLinesEveryNthGridLine;
			_minorColor = ConvertUtility.ToXnaColor(_options.GridLineMinorColor);
			_majorColor = ConvertUtility.ToXnaColor(_options.GridLineMajorColor);
			_axisColor = ConvertUtility.ToXnaColor(_options.GridLineAxisColor);

			int size = _options.GridSize;

			_lineBuffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionColor), size * 4, BufferUsage.WriteOnly);

			VertexPositionColor[] vertices = new VertexPositionColor[size * 4];

			int end = (size - 1) / 2;
			int start = -end;

			int index = 0;

			// Lines along z.
			for (int x = start; x <= end; ++x)
			{
				Color color = GetColor(x);
				vertices[index++] = new VertexPositionColor(new Vector3(GetCoordinate(x), 0, GetCoordinate(start)), color);
				vertices[index++] = new VertexPositionColor(new Vector3(GetCoordinate(x), 0, GetCoordinate(end)), color);
			}

			// Lines along x.
			for (int z = start; z <= end; ++z)
			{
				Color color = GetColor(z);
				vertices[index++] = new VertexPositionColor(new Vector3(GetCoordinate(start), 0, GetCoordinate(z)), color);
				vertices[index++] = new VertexPositionColor(new Vector3(GetCoordinate(end), 0, GetCoordinate(z)), color);
			}

			_lineBuffer.SetData(vertices);
		}
示例#4
0
		private void SetOptions()
		{
			_options = _optionsService.GetContentPreviewOptions();
		}