maansrune Posted February 26, 2016 Share Posted February 26, 2016 Hey guys, first time posting here. Hope you can help me, I'm a VEX noob, but I want to learn. I'm have created planes from point scattered across a character. I now want these planes to neatly wrap to original mesh. For that I use the below VEX in a VEX point wrangle node. And it works.. but... int prim; vector primuv; // Find distance to nearest point of geometry from input 2 vector dist = xyzdist(@OpInput2, @P, prim, primuv, 1000000000000); vector adata = primuv(@OpInput2, "P", prim, primuv); vector diff = (@P - adata)*fit01(@leaf_splat_paint,3,1); // Subtract distance from original position vector product = diff * ch("splatMult"); // Add multiplier to SPLAT effect vector sum = product + adata; // Add the new point position to the product @P = sum; // Make sum new position My problem is that whenever the characters legs cross close to one another, the planes of one leg try to align with the opposite leg, creating a jittering stretching effect that is not desirable. This is also true if the arms comes close to the face or the torso. My question is, what do I need to add to the VEX code to search for closest point along surface and not within volume of space? Any help is appreciated. This forum has been a god sent in the past for me, you guys have helped me out of more trouble than I care to admit Cheers Quote Link to comment Share on other sites More sharing options...
jmpr Posted February 26, 2016 Share Posted February 26, 2016 Hi I would timefreeze a frame or if you have a bindpose (T-Pose), use that as your OpInput2, and then plug the animated character into OpInput3 to get the current P so something like this int prim; vector primuv; // Find distance to nearest point of geometry from input 2 vector dist = xyzdist(@OpInput2, @P, prim, primuv, 1000000000000); //You look up prim number and uv on static pose vector adata = primuv(@OpInput3, "P", prim, primuv); // You fetch the P from the animated character vector diff = (@P - adata)*fit01(@leaf_splat_paint,3,1); // Subtract distance from original position vector product = diff * ch("splatMult"); // Add multiplier to SPLAT effect vector sum = product + adata; // Add the new point position to the product @P = sum; // Make sum new position Good luck Quote Link to comment Share on other sites More sharing options...
maansrune Posted February 27, 2016 Author Share Posted February 27, 2016 (edited) Hey Jens. Thank you for your quick reply. The solution you proposed seemed solid, but it's not working. This is the process of creating the planes (can't share images or the file sadly, so I'll have to describe as best as I can): Point are scattered on static mesh PRIMUV attribute is interpolated onto scattered points from static mesh Points get animation applied, interpolated onto them from animated mesh via PRIMUV and a FLOW attribute Planes are created from points. The planes inherent the animation, but stick out at angles matching the FLOW attribute To flatten down the planes, the Point Wrangle node from above is used. Animated planes (Opinput1) are matched to closest surface on animated mesh (Opinput2), which they closely match already. This approach however, generates the artefacts where planes are attracted to any surface that is nearest. Hand comes close to face and planes on face stretch toward hand instead of face. So when I used the script above, I assume the XYZDIST function gets confused because the distance between animated model and the static model is too great (Static model is placed a 0,0,0, animated model is somewhere else in world space), and the planes are distributed somewhere between the two models. Is there no way to force the XYZDIST to only look along a given connected surface and not a spherical field? Or some other function that will do something similar? Hope this made any sense at all. Otherwise I guess I'll have to live with the artefacts for now. Edited February 27, 2016 by maansrune Quote Link to comment Share on other sites More sharing options...
anim Posted February 27, 2016 Share Posted February 27, 2016 as mentioned above, make the planes sample the geometry at rest frame, get primuv and primid, and then during animation get P from that location at animated mesh, you will be guaranteed that it will not snap to different location Quote Link to comment Share on other sites More sharing options...
anim Posted February 27, 2016 Share Posted February 27, 2016 found some time to make an example ts_stable_stick_locations.hip 1 Quote Link to comment Share on other sites More sharing options...
maansrune Posted March 8, 2016 Author Share Posted March 8, 2016 Thanks for your help guys Just what I was looking for Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.