コード例 #1
0
ファイル: UrhoApp.cs プロジェクト: xamarin/urho-samples
		unsafe Model CreateModelFromVertexData(SurfaceDto surface)
		{
			var model = new Model();
			var vertexBuffer = new VertexBuffer(Context, false);
			var indexBuffer = new IndexBuffer(Context, false);
			var geometry = new Geometry();

			vertexBuffer.Shadowed = true;
			vertexBuffer.SetSize((uint)surface.VertexData.Length, ElementMask.Position | ElementMask.Normal | ElementMask.Color, false);

			fixed (SpatialVertexDto* p = &surface.VertexData[0])
				vertexBuffer.SetData(p);

			var indexData = surface.IndexData;
			indexBuffer.Shadowed = true;
			indexBuffer.SetSize((uint)indexData.Length, false, false);
			indexBuffer.SetData(indexData);

			geometry.SetVertexBuffer(0, vertexBuffer);
			geometry.IndexBuffer = indexBuffer;
			geometry.SetDrawRange(PrimitiveType.TriangleList, 0, (uint)indexData.Length, 0, (uint)surface.VertexData.Length, true);

			model.NumGeometries = 1;
			model.SetGeometry(0, 0, geometry);
			model.BoundingBox = new BoundingBox(new Vector3(-1.26f, -1.26f, -1.26f), new Vector3(1.26f, 1.26f, 1.26f));

			return model;
		}
コード例 #2
0
 /// <summary>
 /// Set the index buffer.
 /// </summary>
 private void SetIndexBuffer(IndexBuffer buffer)
 {
     Runtime.ValidateRefCounted(this);
     Geometry_SetIndexBuffer(handle, (object)buffer == null ? IntPtr.Zero : buffer.Handle);
 }