本文整理汇总了C#中MeshBuilder类的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder类的具体用法?C# MeshBuilder怎么用?C# MeshBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MeshBuilder类属于命名空间,在下文中一共展示了MeshBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildRectangleMesh
public static void BuildRectangleMesh(MeshBuilder meshBuilder,
float width,
float height,
float wStart,
float hStart,
float amount) {
float fullW;
float fullH;
if ( width >= height ) {
fullH = height*amount;
fullW = width-(height-fullH);
}
else {
fullW = width*amount;
fullH = height-(width-fullW);
}
meshBuilder.Resize(4, 6);
meshBuilder.ResetIndices();
meshBuilder.AddVertex(new Vector3(fullW, fullH, 0));
meshBuilder.AddVertex(new Vector3(fullW, fullH*hStart, 0));
meshBuilder.AddVertex(new Vector3(fullW*wStart, fullH*hStart, 0));
meshBuilder.AddVertex(new Vector3(fullW*wStart, fullH, 0));
meshBuilder.AddTriangle(0, 1, 2);
meshBuilder.AddTriangle(0, 2, 3);
meshBuilder.AddRemainingUvs(Vector2.zero);
}
开发者ID:honi90,项目名称:LeapMotionVRInterface,代码行数:31,代码来源:MeshNative.cs
示例2: BuildArcMesh
public static void BuildArcMesh(MeshBuilder meshBuilder,
float innerRadius,
float outerRadius,
float startAngle,
float endAngle,
int steps) {
float angleFull = endAngle - startAngle;
float angleInc = angleFull / steps;
float angle = startAngle;
meshBuilder.Resize((steps+1)*2, steps*6);
meshBuilder.ResetIndices ();
for (int i = 0; i <= steps; ++i) {
float uv = i/(float)steps;
meshBuilder.AddVertex(GetArcPoint(innerRadius, angle));
meshBuilder.AddVertex(GetArcPoint(outerRadius, angle));
meshBuilder.AddUv(new Vector2(uv, 0));
meshBuilder.AddUv(new Vector2(uv, 1));
if ( i > 0 ) {
int vi = meshBuilder.VertexIndex;
meshBuilder.AddTriangle(vi-3, vi-4, vi-2);
meshBuilder.AddTriangle(vi-1, vi-3, vi-2);
}
angle += angleInc;
}
}
开发者ID:honi90,项目名称:LeapMotionVRInterface,代码行数:31,代码来源:MeshNative.cs
示例3: Generate
public void Generate(int chunkX, int chunkY, Map parent) {
MeshFilter filter = this.gameObject.GetComponent<MeshFilter> ();
if (filter == null) {
filter = this.gameObject.AddComponent<MeshFilter> ();
}
MeshRenderer rend = this.gameObject.GetComponent<MeshRenderer> ();
if (rend == null) {
rend = this.gameObject.AddComponent<MeshRenderer> ();
}
rend.material = parent.mapMaterial;
MeshBuilder meshBuilder = new MeshBuilder();
int startX = chunkX * 32;
int startY = chunkY * 32;
for (int i = startX; i < startX + 32; i++) {
float xPos = TILE_SIZE * (i - startX);
for (int j = startY; j < startY + 32; j++) {
float yPos = TILE_SIZE * (j - startY);
BuildTile(meshBuilder, new Vector3(xPos, 0, yPos), parent.getTile(i, j));
}
}
this.GetComponent<MeshFilter> ().sharedMesh = meshBuilder.CreateMesh ();
this.transform.position = new Vector3(chunkX * Map.ChunkSize * TILE_SIZE, 0, chunkY * Map.ChunkSize * TILE_SIZE);
}
开发者ID:Wolfie13,项目名称:RTSAI,代码行数:28,代码来源:MapChunk.cs
示例4: GenerateCurveTriangles
MeshBuilder GenerateCurveTriangles(MeshBuilder meshBuilder, bool doubleTriangles = false)
{
int baseIndex = 0;
int sizeX = 2;
int sizeY = meshBuilder.Vertices.Count / 3 - 1;
int vi = baseIndex;
for (int y = 0; y < sizeY; y++, vi++) {
for (int x = 0; x < sizeX; x++, vi++) {
meshBuilder.AddTriangle (vi, vi + sizeX + 1, vi + 1);
meshBuilder.AddTriangle (vi + 1, vi + sizeX + 1, vi + sizeX + 2);
if (y == sizeY - 1) {
meshBuilder.AddTriangle (vi + sizeX + 1, baseIndex + x, vi + sizeX + 2);
meshBuilder.AddTriangle (baseIndex + x + 1, vi + sizeX + 2, baseIndex + x);
}
if (doubleTriangles) {
meshBuilder.AddTriangle (vi + 1, vi + sizeX + 1, vi);
meshBuilder.AddTriangle (vi + sizeX + 2, vi + sizeX + 1, vi + 1);
if (y == sizeY - 1) {
meshBuilder.AddTriangle (vi + sizeX + 2, baseIndex + x, vi + sizeX + 1);
meshBuilder.AddTriangle (baseIndex + x, vi + sizeX + 2, baseIndex + x + 1);
}
}
}
}
return meshBuilder;
}
开发者ID:adrianogil,项目名称:ProceduralRace,代码行数:31,代码来源:TrackGeneration.cs
示例5: GenerateCubeMesh
void GenerateCubeMesh()
{
MeshBuilder meshBuilder = new MeshBuilder ();
Vector3 upDir = Vector3.up * meshHeight;
Vector3 rightDir = Vector3.right * meshWidth;
Vector3 forwardDir = Vector3.forward * meshLength;
Vector3 nearCorner = - 0.5f * (upDir + rightDir + forwardDir);
Vector3 farCorner = nearCorner + upDir + rightDir + forwardDir;
BuildQuad (meshBuilder, nearCorner, forwardDir, rightDir, sizeX, sizeZ);
BuildQuad (meshBuilder, nearCorner, rightDir, upDir, sizeX, sizeZ);
BuildQuad (meshBuilder, nearCorner, upDir, forwardDir, sizeX, sizeZ);
BuildQuad (meshBuilder, farCorner, -rightDir, -forwardDir, sizeX, sizeZ);
BuildQuad (meshBuilder, farCorner, -upDir, -rightDir, sizeX, sizeZ);
BuildQuad (meshBuilder, farCorner, -forwardDir, -upDir, sizeX, sizeZ);
GetComponent<MeshFilter> ().mesh = meshBuilder.CreateMesh ();
//Invoke ("Spherify", 3f);
PrepareForVerticesAnimation ();
}
开发者ID:adrianogil,项目名称:MeshGeneration,代码行数:25,代码来源:MeshPlayground.cs
示例6: MapMesh
public MapMesh(MapCompiled map)
{
texture = new Texture("Images/wall.png");
material = new ObjMaterial("Models/wall.mtl").Lookup("wall");
colorGroups = new List<WallColorGroup>();
var colorMap = new Dictionary<Color, MeshBuilder<VertexTNP3>>();
foreach (var wall in map.Walls) {
MeshBuilder<VertexTNP3> builder;
if (!colorMap.TryGetValue(wall.Color, out builder)) {
builder = new MeshBuilder<VertexTNP3>();
colorMap.Add(wall.Color, builder);
}
for (int i = 0; i < wall.Verts1.Length-1; i++) makeQuads(wall, builder, i, i+1);
if (wall.Shape == ShapeData.Closed) makeQuads(wall, builder, wall.Verts1.Length-1, 0);
}
foreach (var pair in colorMap) {
WallColorGroup g;
g.Color = pair.Key;
g.Mesh = pair.Value.ToMesh().Compile();
colorGroups.Add(g);
}
}
开发者ID:det,项目名称:Rimbalzo,代码行数:25,代码来源:MapMesh.cs
示例7: BuildQuad
void BuildQuad(MeshBuilder meshBuilder, Vector3 offset, Vector3 widthDirection, Vector3 lengthDirection)
{
Vector3 normal = Vector3.Cross(lengthDirection, widthDirection).normalized;
//Set up the vertices and triangles:
meshBuilder.Vertices.Add(offset);
meshBuilder.Uvs.Add(new Vector2(0.0f, 0.0f));
meshBuilder.Normals.Add(normal);
meshBuilder.Vertices.Add(offset + lengthDirection);
meshBuilder.Uvs.Add(new Vector2(0.0f, 1.0f));
meshBuilder.Normals.Add(normal);
meshBuilder.Vertices.Add(offset + lengthDirection + widthDirection);
meshBuilder.Uvs.Add(new Vector2(1.0f, 1.0f));
meshBuilder.Normals.Add(normal);
meshBuilder.Vertices.Add(offset + widthDirection);
meshBuilder.Uvs.Add(new Vector2(1.0f, 0.0f));
meshBuilder.Normals.Add(normal);
int startPoint = meshBuilder.Vertices.Count - 4;
if(first){
meshBuilder.AddTriangle(startPoint, startPoint + 1, startPoint + 2);
meshBuilder.AddTriangle(startPoint, startPoint + 2, startPoint + 3);
//first = false;
}
}
开发者ID:jakupklein,项目名称:martinGame,代码行数:28,代码来源:QuadTest.cs
示例8: BuildQuad
void BuildQuad(MeshBuilder meshBuilder, Vector3 offset, Vector3 widthDir, Vector3 lengthDir, int sizeX, int sizeY)
{
Vector3 normal = Vector3.Cross (lengthDir, widthDir).normalized;
float vx, vy;
// Define vertices e triangulos
for (int y = 0; y <= sizeY; y++) {
for (int x = 0; x <= sizeX; x++) {
vx = ((float) x / sizeX);
vy = ((float) y / sizeY);
meshBuilder.Vertices.Add (offset + vx * lengthDir + vy * widthDir);
meshBuilder.UVs.Add (new Vector2(vx, vy));
meshBuilder.Normals.Add (normal);
}
}
int baseIndex = meshBuilder.Vertices.Count - (sizeX+1) * (sizeY+1);
for (int vi = baseIndex, y = 0; y < sizeY; y++, vi++) {
for (int x = 0; x < sizeX; x++, vi++) {
meshBuilder.AddTriangle (vi, vi+1, vi+sizeX+2);
meshBuilder.AddTriangle (vi, vi+sizeX+2, vi+sizeX+1);
}
}
}
开发者ID:adrianogil,项目名称:MeshGeneration,代码行数:27,代码来源:MeshPlayground.cs
示例9: BuildQuad
//BuildQuad with vectors
public static Mesh BuildQuad(MeshBuilder meshBuilder, Vector3 offset, Vector3 widthDir, Vector3 lengthDir)
{
Vector3 normal = Vector3.Cross(lengthDir, widthDir).normalized;
meshBuilder.Vertices.Add(offset);
meshBuilder.UVs.Add(new Vector2(0.0f, 0.0f));
meshBuilder.Normals.Add(normal);
meshBuilder.Vertices.Add(offset + lengthDir);
meshBuilder.UVs.Add(new Vector2(0.0f, 1.0f));
meshBuilder.Normals.Add(normal);
meshBuilder.Vertices.Add(offset + lengthDir + widthDir);
meshBuilder.UVs.Add(new Vector2(1.0f, 1.0f));
meshBuilder.Normals.Add(normal);
meshBuilder.Vertices.Add(offset + widthDir);
meshBuilder.UVs.Add(new Vector2(1.0f, 0.0f));
meshBuilder.Normals.Add(normal);
int baseIndex = meshBuilder.Vertices.Count - 4;
meshBuilder.AddTriangle(baseIndex, baseIndex + 1, baseIndex + 2);
meshBuilder.AddTriangle(baseIndex, baseIndex + 2, baseIndex + 3);
Mesh _CreatedMesh = meshBuilder.CreateMesh();
_CreatedMesh.RecalculateNormals();
return _CreatedMesh;
}
开发者ID:Boerlam001,项目名称:DungeonGrind,代码行数:30,代码来源:ProceduralGen.cs
示例10: AddToMeshBuilder
// Use this for initialization
public override MeshBuilder AddToMeshBuilder(MeshBuilder meshBuilder = null)
{
if (meshBuilder == null)
{
meshBuilder = new MeshBuilder();
}
float heightPerVertice = tunnelHeight / (heightVerticesNumber-1);
circleOrigin = tunnelOrigin;
circleOrigin.y += tunnelHeight / 2f;
for(int h = 0; h < heightVerticesNumber; h++)
{
if (h == heightVerticesNumber -1)
{
addVertices = false;
}
meshBuilder = base.AddToMeshBuilder(meshBuilder);
circleOrigin.y -= heightPerVertice;
}
return meshBuilder;
}
开发者ID:adrianogil,项目名称:MeshGeneration,代码行数:27,代码来源:TunnelGeneration.cs
示例11: BuildMesh
//Build the mesh:
public override Mesh BuildMesh()
{
//Create a new mesh builder:
MeshBuilder meshBuilder = new MeshBuilder();
////one-segment cylinder (build two rings, one at the bottom and one at the top):
//BuildRing(meshBuilder, m_RadialSegmentCount, Vector3.zero, m_Radius, 0.0f, false);
//BuildRing(meshBuilder, m_RadialSegmentCount, Vector3.up * m_Height, m_Radius, 1.0f, true);
//multi-segment cylinder:
float heightInc = m_Height / m_HeightSegmentCount;
for (int i = 0; i <= m_HeightSegmentCount; i++)
{
//centre position of this ring:
Vector3 centrePos = Vector3.up * heightInc * i;
//V coordinate is based on height:
float v = (float)i / m_HeightSegmentCount;
BuildRing(meshBuilder, m_RadialSegmentCount, centrePos, m_Radius, v, i > 0);
}
////caps:
//BuildCap(meshBuilder, Vector3.zero, true);
//BuildCap(meshBuilder, Vector3.up * m_Height, false);
return meshBuilder.CreateMesh();
}
开发者ID:Ideae,项目名称:SpatialExperiments,代码行数:30,代码来源:ProcCylinder.cs
示例12: BuildMesh
//public virtual Mesh BuildMesh() {
// return new Mesh();
//}
public Mesh BuildMesh(GizmoMeshShape shape, GizmoType type) { // SIMPLE CUBE!
MeshBuilder meshBuilder = new MeshBuilder();
if(shape == GizmoMeshShape.Cube) {
meshBuilder = EditorGizmoMeshShapes.GetCubeMesh(meshBuilder);
//BuildQuad(meshBuilder, new Vector3(-0.5f, -0.5f, -0.5f), Vector3.right, Vector3.up); // FRONT
//BuildQuad(meshBuilder, new Vector3(-0.5f, -0.5f, 0.5f), Vector3.back, Vector3.up); // LEFT
//BuildQuad(meshBuilder, new Vector3(-0.5f, 0.5f, 0.5f), Vector3.back, Vector3.right); // TOP
//BuildQuad(meshBuilder, new Vector3(0.5f, -0.5f, 0.5f), Vector3.left, Vector3.up); // BACK
//BuildQuad(meshBuilder, new Vector3(0.5f, -0.5f, -0.5f), Vector3.forward, Vector3.up); // RIGHT
//BuildQuad(meshBuilder, new Vector3(-0.5f, -0.5f, 0.5f), Vector3.right, Vector3.back); // BOTTOM
if(type != GizmoType.none) {
collider = this.gameObject.AddComponent<BoxCollider>();
collider.isTrigger = true;
}
if (gizmoMaterial == null) {
gizmoMaterial = new Material(Shader.Find("Custom/CritterEditorGizmo"));
//gizmoMaterial.renderQueue = 4000;
}
GetComponent<MeshRenderer>().material = gizmoMaterial;
}
else if(shape == GizmoMeshShape.Arrow) {
EditorGizmoMeshShapes.GetArrowMesh(meshBuilder);
if (type != GizmoType.none) {
MeshCollider meshCollider = this.gameObject.AddComponent<MeshCollider>();
meshCollider.sharedMesh = meshBuilder.CreateMesh();
collider = meshCollider;
//collider.isTrigger = true;
}
if (gizmoMaterial == null) {
gizmoMaterial = new Material(Shader.Find("Custom/CritterEditorGizmo"));
//gizmoMaterial.renderQueue = 4000;
}
GetComponent<MeshRenderer>().material = gizmoMaterial;
}
else if (shape == GizmoMeshShape.OmniArrow) {
EditorGizmoMeshShapes.GetOmniArrowMesh(meshBuilder);
if (type != GizmoType.none) {
MeshCollider meshCollider = this.gameObject.AddComponent<MeshCollider>();
meshCollider.sharedMesh = meshBuilder.CreateMesh();
collider = meshCollider;
}
if (gizmoMaterial == null) {
gizmoMaterial = new Material(Shader.Find("Custom/CritterEditorGizmo"));
//gizmoMaterial.renderQueue = 4000;
}
GetComponent<MeshRenderer>().material = gizmoMaterial;
}
else {
Debug.Log("No Gizmo Shape!!!");
}
return meshBuilder.CreateMesh();
}
开发者ID:eaclou,项目名称:Master_CreatureTrainer01,代码行数:63,代码来源:EditorGizmoObject.cs
示例13: Shear
private static void Shear(MeshBuilder builder, OpenBveApi.Math.Vector3 direction, OpenBveApi.Math.Vector3 shift, double ratio)
{
for (int i = 0; i < builder.Vertices.Length; i++) {
double factor = ratio * OpenBveApi.Math.Vector3.Dot(builder.Vertices[i].SpatialCoordinates, direction);
builder.Vertices[i].SpatialCoordinates += shift * factor;
if (!builder.Vertices[i].Normal.IsNullVector()) {
factor = ratio * OpenBveApi.Math.Vector3.Dot(builder.Vertices[i].Normal, shift);
builder.Vertices[i].Normal -= direction * factor;
if (!builder.Vertices[i].Normal.IsNullVector()) {
builder.Vertices[i].Normal.Normalize();
}
}
}
for (int i = 0; i < builder.FaceCount; i++) {
for (int j = 0; j < builder.Faces[i].Vertices.Length; j++) {
if (!builder.Faces[i].Vertices[j].Normal.IsNullVector()) {
double factor = ratio * OpenBveApi.Math.Vector3.Dot(builder.Faces[i].Vertices[j].Normal, shift);
builder.Faces[i].Vertices[j].Normal -= direction * factor;
if (!builder.Faces[i].Vertices[j].Normal.IsNullVector()) {
builder.Faces[i].Vertices[j].Normal.Normalize();
}
}
}
}
}
开发者ID:sladen,项目名称:openbve2,代码行数:25,代码来源:Parser.Functions.cs
示例14: BuildMesh
//Build the mesh:
public override Mesh BuildMesh()
{
//Create a new mesh builder:
MeshBuilder meshBuilder = new MeshBuilder();
//height segments need to be half m_RadialSegmentCount for the sphere to be even horizontally and vertically:
int heightSegmentCount = m_RadialSegmentCount / 2;
//the angle increment per height segment:
float angleInc = Mathf.PI / heightSegmentCount;
for (int i = 0; i <= heightSegmentCount; i++)
{
Vector3 centrePos = Vector3.zero;
//calculate a height offset and radius based on a vertical circle calculation:
centrePos.y = -Mathf.Cos(angleInc * i) * m_Radius;
float radius = Mathf.Sin(angleInc * i) * m_Radius;
float v = (float)i / heightSegmentCount;
//build the ring:
BuildRingForSphere(meshBuilder, m_RadialSegmentCount, centrePos, radius, v, i > 0);
}
return meshBuilder.CreateMesh();
}
开发者ID:Ideae,项目名称:SpatialExperiments,代码行数:28,代码来源:ProcSphere.cs
示例15: GenerateMesh
void GenerateMesh()
{
float start_time = Time.time;
NoiseGenerator gen = new NoiseGenerator();
noise = gen.generateNoise(width,width,100);
MeshBuilder builder = new MeshBuilder();
Vector3 offset = new Vector3(0, 0, 0);
for(int x = 0;x< width;x++){
for(int z=0;z< width;z++){
offset.z+= spacing;
offset.y = noise[x * width + z] * Random.Range(-3,3);
bool tri = x > 0 && z > 0;
BuildQuadForGrid(builder,offset,new Vector2((1f/width)*x,(1f/width)*z),tri,width);
}
offset.x+= spacing;
offset.z = 0;
}
if (terrainMesh != null)
{
Mesh mesh = builder.CreateMesh();
mesh.RecalculateNormals();
terrainMesh.sharedMesh = mesh;
}
float diff = Time.time - start_time;
Debug.Log("ProceduralTerrain was generated in " + diff + " seconds.");
}
开发者ID:TechLogic,项目名称:herosofspace,代码行数:32,代码来源:AsteroidMeshGeneration.cs
示例16: MainViewModel
/// <summary>
/// Initializes a new instance of the <see cref="MainViewModel"/> class.
/// </summary>
public MainViewModel()
{
// Create a model group
var modelGroup = new Model3DGroup();
// Create a mesh builder and add a box to it
var meshBuilder = new MeshBuilder(false, false);
meshBuilder.AddBox(new Point3D(0, 0, 1), 1, 2, 0.5);
meshBuilder.AddBox(new Rect3D(0, 0, 1.2, 0.5, 1, 0.4));
// Create a mesh from the builder (and freeze it)
var mesh = meshBuilder.ToMesh(true);
// Create some materials
var greenMaterial = MaterialHelper.CreateMaterial(Colors.Green);
var redMaterial = MaterialHelper.CreateMaterial(Colors.Red);
var blueMaterial = MaterialHelper.CreateMaterial(Colors.Blue);
var insideMaterial = MaterialHelper.CreateMaterial(Colors.Yellow);
// Add 3 models to the group (using the same mesh, that's why we had to freeze it)
modelGroup.Children.Add(new GeometryModel3D { Geometry = mesh, Material = greenMaterial, BackMaterial = insideMaterial });
modelGroup.Children.Add(new GeometryModel3D { Geometry = mesh, Transform = new TranslateTransform3D(-2, 0, 0), Material = redMaterial, BackMaterial = insideMaterial });
modelGroup.Children.Add(new GeometryModel3D { Geometry = mesh, Transform = new TranslateTransform3D(2, 0, 0), Material = blueMaterial, BackMaterial = insideMaterial });
// Set the property, which will be bound to the Content property of the ModelVisual3D (see MainWindow.xaml)
this.Model = modelGroup;
}
开发者ID:chantsunman,项目名称:helix-toolkit,代码行数:30,代码来源:MainViewModel.cs
示例17: BuildQuad
/// <summary>
/// Builds a single quad based on a position offset and width and length vectors.
/// </summary>
/// <param name="meshBuilder">The mesh builder currently being added to.</param>
/// <param name="offset">A position offset for the quad.</param>
/// <param name="widthDir">The width vector of the quad.</param>
/// <param name="lengthDir">The length vector of the quad.</param>
public static void BuildQuad(MeshBuilder meshBuilder, Vector3 offset, Vector3 widthDir, Vector3 lengthDir) {
Vector3 normal = Vector3.Cross(lengthDir, widthDir).normalized;
meshBuilder.Vertices.Add(offset);
meshBuilder.UVs.Add(new Vector2(0.0f, 0.0f));
meshBuilder.Normals.Add(normal);
meshBuilder.Vertices.Add(offset + lengthDir);
meshBuilder.UVs.Add(new Vector2(0.0f, 1.0f));
meshBuilder.Normals.Add(normal);
meshBuilder.Vertices.Add(offset + lengthDir + widthDir);
meshBuilder.UVs.Add(new Vector2(1.0f, 1.0f));
meshBuilder.Normals.Add(normal);
meshBuilder.Vertices.Add(offset + widthDir);
meshBuilder.UVs.Add(new Vector2(1.0f, 0.0f));
meshBuilder.Normals.Add(normal);
//we don't know how many verts the meshBuilder is up to, but we only care about the four we just added:
int baseIndex = meshBuilder.Vertices.Count - 4;
meshBuilder.AddTriangle(baseIndex, baseIndex + 1, baseIndex + 2);
meshBuilder.AddTriangle(baseIndex, baseIndex + 2, baseIndex + 3);
}
开发者ID:eaclou,项目名称:Master_CreatureTrainer01,代码行数:32,代码来源:MeshBuilderPrimitiveShapes.cs
示例18: BuildMesh
//Build the mesh:
public override Mesh BuildMesh()
{
//Create a new mesh builder:
MeshBuilder meshBuilder = new MeshBuilder();
//calculate directional vectors for all 3 dimensions of the cube:
Vector3 upDir = Vector3.up * m_Height;
Vector3 rightDir = Vector3.right * m_Width;
Vector3 forwardDir = Vector3.forward * m_Length;
//calculate the positions of two corners opposite each other on the cube:
//positions that will place the pivot at the corner of the cube:
Vector3 nearCorner = Vector3.zero;
Vector3 farCorner = upDir + rightDir + forwardDir;
////positions that will place the pivot at the centre of the cube:
//Vector3 farCorner = (upDir + rightDir + forwardDir) / 2;
//Vector3 nearCorner = -farCorner;
//build the 3 quads that originate from nearCorner:
BuildQuad(meshBuilder, nearCorner, forwardDir, rightDir);
BuildQuad(meshBuilder, nearCorner, rightDir, upDir);
BuildQuad(meshBuilder, nearCorner, upDir, forwardDir);
//build the 3 quads that originate from farCorner:
BuildQuad(meshBuilder, farCorner, -rightDir, -forwardDir);
BuildQuad(meshBuilder, farCorner, -upDir, -rightDir);
BuildQuad(meshBuilder, farCorner, -forwardDir, -upDir);
//initialise the Unity mesh and return it:
return meshBuilder.CreateMesh();
}
开发者ID:Ideae,项目名称:SpatialExperiments,代码行数:34,代码来源:ProcCube.cs
示例19: BuildMesh
public override Mesh BuildMesh() { // SIMPLE PLANE!
MeshBuilder meshBuilder = new MeshBuilder();
BuildQuad (meshBuilder, new Vector3(-0.5f, 0.0f, 0.5f), Vector3.back, Vector3.right); // TOP
return meshBuilder.CreateMesh ();
}
开发者ID:eaclou,项目名称:Master_CreatureTrainer01,代码行数:7,代码来源:GamePieceCommonPlane.cs
示例20: BuildSimplifiedConvexMesh
public Mesh BuildSimplifiedConvexMesh()
{
var builder = new MeshBuilder();
for (int i = 0; i < 64; i++)
{
int index = Random.Range(0, mesh.triangles.Length / 3) * 3;
Vector3[] triangle = new Vector3[]
{
mesh.vertices[mesh.triangles[index + 0]],
mesh.vertices[mesh.triangles[index + 1]],
mesh.vertices[mesh.triangles[index + 2]]
};
Vector3[] norms = new Vector3[]
{
Vector3.up,
Vector3.up,
Vector3.up
};
Vector2[] uvs = new Vector2[]
{
mesh.uv[mesh.triangles[index + 0]],
mesh.uv[mesh.triangles[index + 1]],
mesh.uv[mesh.triangles[index + 2]]
};
builder.AddTriangleToMesh(triangle, norms, uvs);
}
return builder.Build();
}
开发者ID:gamezter,项目名称:BananaSplit,代码行数:34,代码来源:SimpleConvex.cs
注:本文中的MeshBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论