本文整理汇总了C#中Surface.build方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.build方法的具体用法?C# Surface.build怎么用?C# Surface.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface.build方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: readMesh
//.........这里部分代码省略.........
//vertex face
v0 =(int) file.ReadUInt16 ();
v1 =(int) file.ReadUInt16 ();
v2 =(int) file.ReadUInt16 ();
faces.Add (new Face (v0, v1, v2));
//texture faces
v0 =(int) file.ReadUInt16();
v1 =(int) file.ReadUInt16 ();
v2 =(int) file.ReadUInt16 ();
tfaces.Add (new Face (v0, v1, v2));
}
file.BaseStream.Seek(OffsetTexCoords,SeekOrigin.Begin);
Debug.Log("Num TextureCoord"+NumTexCoords);
for (int i=0; i<NumTexCoords; i++)
{
float u=(float) file.ReadInt16()/SkinWidth;
float v=(float)1*- file.ReadInt16()/SkinWidth;
uvCoords.Add(new Vector2(u,v));
}
//**************************************************
file.BaseStream.Seek(OffsetFrames,SeekOrigin.Begin);
Debug.Log("Num Frames"+OffsetFrames);
for (int i=0; i<NumFrames; i++)
{
Vector3 Scale=Vector3.zero;
Vector3 Translate=Vector3.zero;
Scale.x = file.ReadSingle();
Scale.y = file.ReadSingle();
Scale.z = file.ReadSingle();
Translate.x = file.ReadSingle();
Translate.y = file.ReadSingle();
Translate.z = file.ReadSingle();
char[] name= file.ReadChars(16);
//Debug.LogWarning(new string(name));
for (int j=0; j<NumVertices; j++)
{
byte x = file.ReadByte();
byte y = file.ReadByte();
byte z = file.ReadByte();
byte w = file.ReadByte();
// System.BitConverter.ToSingle(buffer, 0);
float sx = Scale.x * x + Translate.x;
float sy = Scale.z * z + Translate.z;
float sz = Scale.y * y + Translate.y;
model.vertex.Add(new Vector3(sx,sy,sz));
}
}
//meshFilter.sharedMesh =Surface.createCube ("cube");
for (int f=0; f<NumFrames; f++)
{
Surface surface= new Surface("frame");
for (int i=0; i<faces.Count; i++)
{
Vector3 v1 = model.vertex[f * vertex_Count + faces[i].v0];
Vector3 v2 = model.vertex[f * vertex_Count + faces[i].v1];
Vector3 v3 = model.vertex[f * vertex_Count + faces[i].v2];
Vector2 uv1 = uvCoords[0 * uv_count + tfaces[i].v0];
Vector2 uv2 = uvCoords[0 * uv_count + tfaces[i].v1];
Vector2 uv3 = uvCoords[0 * uv_count + tfaces[i].v2];
surface.addFace(v1, v2, v3, uv1, uv2, uv3);
}
surface.build();
surface.RecalculateNormals();
surface.Optimize();
model.Frames.Add(surface.getMesh());
}
model.meshFilter.sharedMesh=model.Frames[0];
model.ready=true;
Debug.LogWarning("read ok");
}
} else {
Debug.LogError (filename + " dont exits");
}
}
示例2: createCube
//.........这里部分代码省略.........
surf.VertexNormal(5,0.0f,0.0f,1.0f);
surf.VertexNormal(6,0.0f,0.0f,1.0f);
surf.VertexNormal(7,0.0f,0.0f,1.0f);
surf.VertexNormal(8,0.0f,-1.0f,0.0f);
surf.VertexNormal(9,0.0f,1.0f,0.0f);
surf.VertexNormal(10,0.0f,1.0f,0.0f);
surf.VertexNormal(11,0.0f,-1.0f,0.0f);
surf.VertexNormal(12,0.0f,-1.0f,0.0f);
surf.VertexNormal(13,0.0f,1.0f,0.0f);
surf.VertexNormal(14,0.0f,1.0f,0.0f);
surf.VertexNormal(15,0.0f,-1.0f,0.0f);
surf.VertexNormal(16,-1.0f,0.0f,0.0f);
surf.VertexNormal(17,-1.0f,0.0f,0.0f);
surf.VertexNormal(18,1.0f,0.0f,0.0f);
surf.VertexNormal(19,1.0f,0.0f,0.0f);
surf.VertexNormal(20,-1.0f,0.0f,0.0f);
surf.VertexNormal(21,-1.0f,0.0f,0.0f);
surf.VertexNormal(22,1.0f,0.0f,0.0f);
surf.VertexNormal(23,1.0f,0.0f,0.0f);
surf.VertexTexCoords(0,0.0f,1.0f,0.0f,0);
surf.VertexTexCoords(1,0.0f,0.0f,0.0f,0);
surf.VertexTexCoords(2,1.0f,0.0f,0.0f,0);
surf.VertexTexCoords(3,1.0f,1.0f,0.0f,0);
surf.VertexTexCoords(4,1.0f,1.0f,0.0f,0);
surf.VertexTexCoords(5,1.0f,0.0f,0.0f,0);
surf.VertexTexCoords(6,0.0f,0.0f,0.0f,0);
surf.VertexTexCoords(7,0.0f,1.0f,0.0f,0);
surf.VertexTexCoords(8,0.0f,1.0f,0.0f,0);
surf.VertexTexCoords(9,0.0f,0.0f,0.0f,0);
surf.VertexTexCoords(10,1.0f,0.0f,0.0f,0);
surf.VertexTexCoords(11,1.0f,1.0f,0.0f,0);
surf.VertexTexCoords(12,0.0f,0.0f,0.0f,0);
surf.VertexTexCoords(13,0.0f,1.0f,0.0f,0);
surf.VertexTexCoords(14,1.0f,1.0f,0.0f,0);
surf.VertexTexCoords(15,1.0f,0.0f,0.0f,0);
surf.VertexTexCoords(16,0.0f,1.0f,0.0f,0);
surf.VertexTexCoords(17,0.0f,0.0f,0.0f,0);
surf.VertexTexCoords(18,1.0f,0.0f,0.0f,0);
surf.VertexTexCoords(19,1.0f,1.0f,0.0f,0);
surf.VertexTexCoords(20,1.0f,1.0f,0.0f,0);
surf.VertexTexCoords(21,1.0f,0.0f,0.0f,0);
surf.VertexTexCoords(22,0.0f,0.0f,0.0f,0);
surf.VertexTexCoords(23,0.0f,1.0f,0.0f,0);
surf.VertexTexCoords(0,0.0f,1.0f,0.0f,1);
surf.VertexTexCoords(1,0.0f,0.0f,0.0f,1);
surf.VertexTexCoords(2,1.0f,0.0f,0.0f,1);
surf.VertexTexCoords(3,1.0f,1.0f,0.0f,1);
surf.VertexTexCoords(4,1.0f,1.0f,0.0f,1);
surf.VertexTexCoords(5,1.0f,0.0f,0.0f,1);
surf.VertexTexCoords(6,0.0f,0.0f,0.0f,1);
surf.VertexTexCoords(7,0.0f,1.0f,0.0f,1);
surf.VertexTexCoords(8,0.0f,1.0f,0.0f,1);
surf.VertexTexCoords(9,0.0f,0.0f,0.0f,1);
surf.VertexTexCoords(10,1.0f,0.0f,0.0f,1);
surf.VertexTexCoords(11,1.0f,1.0f,0.0f,1);
surf.VertexTexCoords(12,0.0f,0.0f,0.0f,1);
surf.VertexTexCoords(13,0.0f,1.0f,0.0f,1);
surf.VertexTexCoords(14,1.0f,1.0f,0.0f,1);
surf.VertexTexCoords(15,1.0f,0.0f,0.0f,1);
surf.VertexTexCoords(16,0.0f,1.0f,0.0f,1);
surf.VertexTexCoords(17,0.0f,0.0f,0.0f,1);
surf.VertexTexCoords(18,1.0f,0.0f,0.0f,1);
surf.VertexTexCoords(19,1.0f,1.0f,0.0f,1);
surf.VertexTexCoords(20,1.0f,1.0f,0.0f,1);
surf.VertexTexCoords(21,1.0f,0.0f,0.0f,1);
surf.VertexTexCoords(22,0.0f,0.0f,0.0f,1);
surf.VertexTexCoords(23,0.0f,1.0f,0.0f,1);
surf.AddTriangle(0,1,2); // front
surf.AddTriangle(0,2,3);
surf.AddTriangle(6,5,4); // back
surf.AddTriangle(7,6,4);
surf.AddTriangle(6+8,5+8,1+8); // top
surf.AddTriangle(2+8,6+8,1+8);
surf.AddTriangle(0+8,4+8,7+8); // bottom
surf.AddTriangle(0+8,7+8,3+8);
surf.AddTriangle(6+16,2+16,3+16); // right
surf.AddTriangle(7+16,6+16,3+16);
surf.AddTriangle(0+16,1+16,5+16); // left
surf.AddTriangle(0 + 16, 5 + 16, 4 + 16);
surf.build ();
return surf.getMesh ();
}