Utilizing SurroundingPoints

I've attached a simple proof-of-concept Canvas file (RestLength_POC, v2.4.0) which attempts to create & apply a 'rest length' to positions based on surrounding (neighboring) points. Similar to the 'flag' Sample file, this attempts to avoid stretching while deforming & maintain overall lengths between vertices.

In pseudocode/outline: given an arbitrary PolygonMesh (in this case a 10x5pt plane), get surrounding points, calculate & store distance to neighbors as a variable called 'rest_length', deform geo (in this case TurbulizeVec3[]), then add the difference between current distance to surrounding points & 'rest_length'.

My trouble (aside from lack of understanding) is in converting the indices returned from GetPointSurroundingPoints into usable positions. I've tried several methods here, though still scratching my head. Perhaps there is a node built for Kraken which already does this (store/use rest lengths), though I'm not sure where to look or what it might be called.

I'd appreciate any information or explanation, or even a link to the relevant docs.
Many thanks,
Edward

Answers

  • Gustavo BoehsGustavo Boehs Posts: 63 ✭✭
    edited February 17

    Hello Ed. I don't know much about meshes inside Fabric, but from my understanding what you want to do is store a mesh Attribute, instead of a big array with data from all points. This is the documentation for attributes: http://docs.fabric-engine.com/FabricEngine/2.4.0/HTML/KLExtensionsGuide/Geometry/polygonmeshstructure.html#polygonmesh-attributes.

    You might want to built a perPoint scalar array (ScalarConstantArrayAttribute) for your distances and a perPoint integer array (UInt16ConstantArrayAttribute) for your neighbors as a first step that you run only once after building the mesh. Then you can query them at any time as easily as: attributeName.get(pointIndex); and go on from there.

    I don't know how much of this can be done with factory nodes, you might need to wrap some functions around nodes if you want to do all of this in canvas. Maybe, now that we have blocks, you could use those to manipulate each individual attribute.

    I have attached an old attempt at a verlet implementation of my own, in case it might help to have some further examples. Take a look at verletInit->storePointDistances and the pDistanceConstraint nodes.

    Best,
    Gustavo

  • HelgeHelge Moderator, Fabric Employee Posts: 314 Fabric Employee

    Hey @QuirkEd,

    good to see you here. You really want to build this with blocks. You will want to define new attributes to store your custom data, like Gustavo mentioned. Also you really should be using a block to compute the values, so that your operation is per point, and a bit easier to read / build.

    Let me know if you have further questions!

    Best,

    Helge

    Research Engineer @ Fabric Software

Sign In or Register to comment.