本文整理汇总了C#中IMesh类的典型用法代码示例。如果您正苦于以下问题:C# IMesh类的具体用法?C# IMesh怎么用?C# IMesh使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMesh类属于命名空间,在下文中一共展示了IMesh类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloudInCell
public CloudInCell(IParticleStorage<Particle> particles, IGrid2D grid, IMesh mesh, bool parallel)
{
this.particles = particles;
this.grid = grid;
this.mesh = mesh;
this.parallel = parallel;
}
示例2: Smooth
public void Smooth(IMesh mesh, int limit)
{
var smoothedMesh = (Mesh)mesh;
var mesher = new GenericMesher(config);
var predicates = config.Predicates();
// The smoother should respect the mesh segment splitting behavior.
this.options.SegmentSplitting = smoothedMesh.behavior.NoBisect;
// Take a few smoothing rounds (Lloyd's algorithm).
for (int i = 0; i < limit; i++)
{
Step(smoothedMesh, factory, predicates);
// Actually, we only want to rebuild, if the mesh is no longer
// Delaunay. Flipping edges could be the right choice instead
// of re-triangulating...
smoothedMesh = (Mesh)mesher.Triangulate(Rebuild(smoothedMesh), options);
factory.Reset();
}
smoothedMesh.CopyTo((Mesh)mesh);
}
示例3: CPlayer
public CPlayer(IGameObjectManager pObjMan, IEngineCore pEngineCore)
: base(pObjMan, pEngineCore)
{
_fVelocity = 0f;
uiShotPause = 15;
ObjType = EGameObjectType.GotPlayer;
_stPos = new TPoint2(Res.GameVpWidth / 2f, Res.GameVpHeight / 2f);
_fSize = 150f;
_fColScale = 0.6f;
dimPl = new TPoint3(_fSize, _fSize, _fSize);
IResourceManager pResMan;
IEngineSubSystem pSubSys;
pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_INPUT, out pSubSys);
pInput = (IInput)pSubSys;
pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out pSubSys);
pResMan = (IResourceManager)pSubSys;
IEngineBaseObject pBaseObj;
pResMan.GetResourceByName(Res.MeshShip, out pBaseObj);
pMesh = (IMesh)pBaseObj;
pResMan.GetResourceByName(Res.TexShip, out pBaseObj);
pTex = (ITexture)pBaseObj;
pResMan.GetResourceByName(Res.TexSpark, out pBaseObj);
pTexSpark = (ITexture)pBaseObj;
}
示例4: Collides
public bool Collides(
Ray testRay,
IEnumerable<IMesh> meshes,
out Vector3 position,
out IMesh hitMesh,
bool furthest = false)
{
var distance = furthest ? 0f : 10000f;
var closestPosition = Vector3.Zero;
IMesh closestMesh = null;
foreach (var mesh in meshes)
{
if (mesh.MeshVertexPositions == null)
{
continue;
}
for (var a = 0; a < mesh.MeshIndicies.Length; a += 3)
{
var vertexA = mesh.MeshVertexPositions[mesh.MeshIndicies[a]];
var vertexB = mesh.MeshVertexPositions[mesh.MeshIndicies[a + 1]];
var vertexC = mesh.MeshVertexPositions[mesh.MeshIndicies[a + 2]];
float tempDistance;
var point = this.m_Collision.CollidesWithTriangle(
testRay,
vertexA,
vertexB,
vertexC,
out tempDistance,
false);
if (point != null)
{
if (!furthest)
{
if (tempDistance < distance && tempDistance > 0)
{
distance = tempDistance;
closestPosition = point.Value;
closestMesh = mesh;
}
}
else
{
if (tempDistance > distance && tempDistance > 0)
{
distance = tempDistance;
closestPosition = point.Value;
closestMesh = mesh;
}
}
}
}
}
position = closestPosition;
hitMesh = closestMesh;
return closestPosition != Vector3.Zero;
}
示例5: SetTextureVertices
public unsafe bool SetTextureVertices(IMesh maxMesh, MyMesh myMesh)
{
bool countChanged = false;
if (maxMesh.NumTVerts != myMesh.NumTextureCoordinates)
{
maxMesh.SetNumTVerts(myMesh.NumTextureCoordinates, false);
countChanged = true;
}
IntPtr p3h = maxMesh.GetTVertPtr(0).NativePointer;
float* p3 = (float*)p3h.ToPointer();
int elementsPerVertex = myMesh.TextureCoordinates.Count / myMesh.NumTextureCoordinates;
switch (elementsPerVertex)
{
case 2:
for (int i = 0; i < myMesh.NumTextureCoordinates; i++)
{
p3[(i * 3) + 0] = myMesh.TextureCoordinates[(i * 2) + 0];
p3[(i * 3) + 1] = myMesh.TextureCoordinates[(i * 2) + 1];
p3[(i * 3) + 2] = 0.0f;
};
break;
case 3:
Marshal.Copy(myMesh.TextureCoordinates.ToArray(), 0, p3h, myMesh.NumTextureCoordinates * 3);
break;
default:
throw new NotImplementedException(("Unable to handle texture coordinates with " + elementsPerVertex + " elements."));
}
return countChanged;
}
示例6: Load
public void Load(IMesh mesh, string filePath)
{
using (var streamReader = new StreamReader(filePath))
{
Load(streamReader, mesh);
}
}
示例7: Combine
/// <summary>
/// Combine this mesh with another.
/// </summary>
/// <param name="anotherMesh">Another mesh.</param>
/// <seealso cref="ConstructiveSolidGeometry.Union"/>
public virtual void Combine(IMesh anotherMesh)
{
BspNode<SplittableTriangle> a = this.ToBspTree();
BspNode<SplittableTriangle> b = anotherMesh.ToBspTree();
a.Unite(b);
this.SetBsp(a);
}
示例8: Write
public void Write(IMesh mesh, string filename)
{
if (mesh.Vertices.Count > 0)
{
format.Write(mesh, filename);
}
}
示例9: Write
public void Write(IMesh mesh, string filename)
{
var writer = new TriangleWriter();
writer.WritePoly((Mesh)mesh, Path.ChangeExtension(filename, ".poly"));
writer.WriteElements((Mesh)mesh, Path.ChangeExtension(filename, ".ele"));
}
示例10: Load
public void Load(IMesh mesh, string filePath)
{
var dxfLoad = DxfDocument.Load(filePath);
var vertices = new List<IVertex>();
var faces = new List<IFace>();
var verticesIndexMap = new Dictionary<IVertex, int>();
int currentVertexIndex = 0;
foreach (var face3D in dxfLoad.Faces3d)
{
var v1 = face3D.FirstVertex;
var v2 = face3D.SecondVertex;
var v3 = face3D.ThirdVertex;
var v4 = face3D.FourthVertex;
currentVertexIndex = CreateTriangleFace(v1, v2, v3, verticesIndexMap, currentVertexIndex, vertices, faces);
currentVertexIndex = CreateTriangleFace(v3, v4, v1, verticesIndexMap, currentVertexIndex, vertices, faces);
}
foreach (var vertex in vertices)
{
mesh.AddVertex(vertex);
}
foreach (var face in faces)
{
mesh.AddFace(face);
}
}
示例11: ComputeNormals
public static VNormal[] ComputeNormals(IMesh mesh)
{
var vnorms = new VNormal[mesh.NumVerts];
var fnorms = new Vector3[mesh.NumFaces];
for (var index = 0; index < mesh.NumVerts; index++)
{
vnorms[index] = new VNormal();
}
for (var index = 0; index < mesh.NumFaces; index++)
{
var face = mesh.Faces[index];
Vector3 v0 = mesh.Verts[(int)face.V[0]].ToVector3();
Vector3 v1 = mesh.Verts[(int)face.V[1]].ToVector3();
Vector3 v2 = mesh.Verts[(int)face.V[2]].ToVector3();
fnorms[index] = Vector3.Cross((v1 - v0), (v2 - v1));
for (var j = 0; j < 3; j++)
{
vnorms[(int)face.V[j]].AddNormal(fnorms[index], face.SmGroup);
}
fnorms[index].Normalize();
}
for (var index = 0; index < mesh.NumVerts; index++)
{
vnorms[index].Normalize();
}
return vnorms;
}
示例12: DestroyMesh
public void DestroyMesh(ref IMesh _OutMesh)
{
if (m_MeshInstanceContainer.ContainsKey(_OutMesh.m_InstanceID)) {
m_MeshInstanceContainer[_OutMesh.m_InstanceID].Release();
m_MeshInstanceContainer.Remove(_OutMesh.m_InstanceID);
_OutMesh = null;
}
}
示例13: Subtract
/// <summary>
/// Subtracts another mesh from this one.
/// </summary>
/// <param name="anotherMesh">Another mesh.</param>
/// <seealso cref="ConstructiveSolidGeometry.Subtract"/>
public virtual void Subtract(IMesh anotherMesh)
{
BspNode<SplittableTriangle> a = this.ToBspTree();
BspNode<SplittableTriangle> b = anotherMesh.ToBspTree();
a.Invert();
a.Unite(b);
a.Invert();
this.SetBsp(a);
}
示例14: PICMonitor
public PICMonitor(IGrid2D grid, IMesh mesh, IParticleStorage<Particle> particles, IPICSolver solver)
{
this.grid = grid;
this.particles = particles;
this.mesh = mesh;
this.solver = solver;
GridX = grid.X;
GridY = grid.Y;
Status = PICStatus.Created;
}
示例15: vertexPositions
public static Vector3[] vertexPositions(IMesh mesh){
Vector3[] positions = new Vector3[mesh.VerticesCount];
int i = 0;
foreach(IVertex v in mesh.Vertices) {
positions [i] = v.Position;
i++;
}
return positions;
}