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


C# Mesh.SetBuffer2f方法代码示例

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


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

示例1: OnUpdate

		public void OnUpdate()
		{
			if (mesh)
			{
				mesh.Dispose();
			}

			Rect rect = rectTransform.rect;
			positionVboData[0] = new Vector3f((float)rect.min.X, (float)rect.min.Y, 0);
			positionVboData[1] = new Vector3f((float)rect.min.X, (float)rect.max.Y, 0);
			positionVboData[2] = new Vector3f((float)rect.max.X, (float)rect.max.Y, 0);
			positionVboData[3] = new Vector3f((float)rect.max.X, (float)rect.min.Y, 0);
			
			mesh = new Mesh();

			mesh.AddBuffer<VertexBufferObject3f>("vertex");
			mesh.SetBuffer3f("vertex", positionVboData);

			mesh.AddBuffer<VertexBufferObject3f>("normal");
			mesh.SetBuffer3f("normal", normalVboData);

			mesh.AddBuffer<VertexBufferObject2f>("uv0");
			mesh.SetBuffer2f("uv0", uvVboData);

			mesh.SetIndices(indicesVboData, 0, Graphics.PrimitiveType.Triangles);

			MeshRenderer meshRenderer = sceneObject.GetModule<MeshRenderer>();
			if (meshRenderer)
			{
				meshRenderer.mesh = mesh;
			}
		}
开发者ID:KurtLoeffler,项目名称:EnvyEngine,代码行数:32,代码来源:Image.cs

示例2: OnUpdate

		public void OnUpdate()
		{
			//base.OnInitialize();

			string text = "Test text! "+Engine.current.deltaTime;
			Font font = new Font("Verdana", 12, FontStyle.Regular, GraphicsUnit.Point);
			Bitmap measureBitmap = new Bitmap(2, 2);
			Bitmap bitmap = null;

			System.Drawing.Graphics measureGraphics = System.Drawing.Graphics.FromImage(measureBitmap);
			measureGraphics.PageUnit = GraphicsUnit.Pixel;
			measureGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
			measureGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

			SizeF size = measureGraphics.MeasureString(text, font);
			measureGraphics.Dispose();
			measureBitmap.Dispose();

			bitmap = new Bitmap((int)size.Width, (int)size.Height);

			System.Drawing.Graphics drawGraphics = System.Drawing.Graphics.FromImage(bitmap);
			drawGraphics.PageUnit = GraphicsUnit.Pixel;
			drawGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
			drawGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
			drawGraphics.Clear(System.Drawing.Color.FromArgb(255, 0, 0, 0));
			drawGraphics.DrawString(text, font, new SolidBrush(System.Drawing.Color.White), 0, 0);
			drawGraphics.Dispose();

			if (texture)
			{
				texture.Dispose();
			}

			texture = new Texture2D(bitmap, false, Texture2D.MemoryResidence.GPU);

			bitmap.Dispose();

			if (mesh)
			{
				mesh.Dispose();
			}

			positionVboData[0] = new Vector3f(0, 0, 0);
			positionVboData[1] = new Vector3f(0, texture.height, 0);
			positionVboData[2] = new Vector3f(texture.width, texture.height, 0);
			positionVboData[3] = new Vector3f(texture.width, 0, 0);
			
			mesh = new Mesh();

			mesh.AddBuffer<VertexBufferObject3f>("vertex");
			mesh.SetBuffer3f("vertex", positionVboData);

			mesh.AddBuffer<VertexBufferObject3f>("normal");
			mesh.SetBuffer3f("normal", normalVboData);

			mesh.AddBuffer<VertexBufferObject2f>("uv0");
			mesh.SetBuffer2f("uv0", uvVboData);

			mesh.SetIndices(indicesVboData, 0, Graphics.PrimitiveType.Triangles);

			MeshRenderer meshRenderer = sceneObject.GetModule<MeshRenderer>();
			if (meshRenderer)
			{
				MaterialProperties properties = new MaterialProperties();
				MaterialPropertyTexture2D texProperty = properties.AddProperty<MaterialPropertyTexture2D>("colorTexture");
				texProperty.value = texture;
				meshRenderer.mesh = mesh;
				meshRenderer.overrideProperties = properties;
			}

		}
开发者ID:KurtLoeffler,项目名称:EnvyEngine,代码行数:71,代码来源:StaticText.cs

示例3: ToMesh

        public Mesh ToMesh(IEnumerable<int> faceList, List<int> triangleToFaceMap)
		{
			List<Vector3f> vertices = new List<Vector3f>();
			List<Vector3f> normals = new List<Vector3f>();
			List<Vector2f> uvs = new List<Vector2f>();
			List<uint> triangles = new List<uint>();
			List<uint> edges = new List<uint>();
			
            if (faceList == null)
			{
				faceList = Enumerable.Range(0, geometry.Faces.Count).Select(i => i);
            }

			foreach (var faceIndex in faceList)
			{
                PlanktonFace face = geometry.Faces[faceIndex];
				if (face.IsUnused)
				{
					continue;
				}

				int startVertexIndex = vertices.Count;
				int[] halfedgeIndices = geometry.Faces.GetHalfedges(faceIndex);
				
                for (int h = 0; h < halfedgeIndices.Length; h++)
				{
					int halfEdgeIndex = halfedgeIndices[h];
					int vertexIndex = geometry.Halfedges[halfEdgeIndex].StartVertex;
					PlanktonVertex vertex = geometry.Vertices[vertexIndex];
					PlanktonVertex end = geometry.Vertices[vertexIndex];

					//if (vertex.IsUnused)
					//{
					//	continue;
					//}
					
					Vector3f normal = (Vector3f)GetHalfedgeNormal(halfEdgeIndex);

					Vector3f position = vertex.ToXYZ().ToVector3f();
					vertices.Add(position);
					normals.Add(normal);
					uvs.Add(new Vector2f(position.X, position.Y));

					int pairIndex = geometry.Halfedges.GetPairHalfedge(halfEdgeIndex);

					bool makeEdge = halfEdgeIndex%2 == 0 || geometry.Halfedges[halfEdgeIndex].AdjacentFace == -1 || geometry.Halfedges[pairIndex].AdjacentFace == -1;

					if (makeEdge)
					{
						edges.Add((uint)(vertices.Count-1));
						int nextIndex = vertices.Count;
						if (h == halfedgeIndices.Length-1)
						{
							nextIndex = startVertexIndex;
                        }
                        edges.Add((uint)nextIndex);
					}
				}

				for (int h = 0; h < halfedgeIndices.Length; h++)
				{
					if (h < 3)
					{
						if (triangleToFaceMap != null)
						{
							if (h == 2)
							{
								triangleToFaceMap.Add(faceIndex);
							}
						}
						
						triangles.Add((uint)(startVertexIndex+h));
					}
					else
					{
						if (triangleToFaceMap != null)
						{
							triangleToFaceMap.Add(faceIndex);
						}

						triangles.Add((uint)startVertexIndex);
						triangles.Add((uint)(startVertexIndex+(h-1)));
						triangles.Add((uint)(startVertexIndex+h));
					}
				}
			}

			Mesh mesh = new Mesh();

			mesh.AddBuffer<VertexBufferObject3f>("vertex");
			mesh.SetBuffer3f("vertex", vertices.ToArray());

			mesh.AddBuffer<VertexBufferObject3f>("normal");
			mesh.SetBuffer3f("normal", normals.ToArray());

			mesh.AddBuffer<VertexBufferObject2f>("uv0");
			mesh.SetBuffer2f("uv0", uvs.ToArray());

			mesh.SetIndices(triangles.ToArray(), 0, Graphics.PrimitiveType.Triangles);
			mesh.SetIndices(edges.ToArray(), 1, Graphics.PrimitiveType.Lines);
//.........这里部分代码省略.........
开发者ID:KurtLoeffler,项目名称:EnvyEngine,代码行数:101,代码来源:PolyMesh.cs


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