Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Matching up particles with vertices in 7.X
#2
Hi!

Cloth blueprints now have two extra properties: a topology (of type ObiMesh) and a skinmap (of type ObiSkinMap).

The topology holds information about the simplified cloth mesh: clusters and triangles. Clusters are groups of vertices of the original mesh that have been merged together into what will eventually become a single particle: there's a 1-1 correspondence between clusters and particles in the blueprint, and they're stored in the same order. So given a particle index, you can read the corresponding cluster on the topology and retrieve the indices of the original vertices that got absorbed into that cluster.

Code:
var cluster = clothBlueprint.topology.clusters[actorParticleIndex];
foreach (var vertexIndex in cluster.vertexIndices)
{
// do something with the vertex: mesh.vertices[vertexIndex]
}

The skinmap stores deformation influences: for each vertex in the mesh, which particles influence its deformation during simulation, and the amount of influence for each one. The amount of particles influencing each vertex is variable. This is similar to how bones influence vertices for skeletal animation (essentially linear blend skinning, if you're familiar with the term). Given a mesh vertex, you can get the particles that influence its position:

Code:
var map = clothBlueprint.defaultSkinmap.particlesOnVertices;
int offset = map.influenceOffsets[vertexIndex]; // index of the first influence for this vertex.
int count = map.influenceOffsets[vertexIndex+1] - offset; // amount of influences for this vertex.
for (int i = 0; i < count; ++i)
{
   int actorParticleIndex = map.influences[offset + i].index;
}

Note that the topology and the skinmap aren't mirror images of each other: even though a vertex may not be part of a cluster, it may be influenced by that cluster/particle at runtime.

Let me know if I can be of further help,

kind regards
Reply


Messages In This Thread
RE: Matching up particles with vertices in 7.X - by josemendez - 29-11-2024, 09:22 AM