Strand control basics

Discussions about SOFTIMAGEs© Interactive Creative Environment©
jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Strand control basics

Post by jamnique » 06 Jul 2011, 17:24

Hello everybody, this is my first post:)
I hope this is an appropriate place to ask some advice, although i see this forum is mainly populated with great solutions.

I was hoping i could find some more clues about the basics of manipulating strands, sadly i didn't find much on the level that i can actually understand.

What i would like to learn is how to simultaneously:
1) Keep strands' origins updated to the position of the emitter
2) Constrain strands' ends to desired locations
3) Apply turbulence / forces to the segments between, and make the strands behave like strings strung between the origin and the end.
4) Preferably use as little simulation as possible, like artists at Polynoid do, to retain the ability to animate by hand / effectors

I have found bits and pieces of other people's work that do parts of what i would like to achieve but, as i have said before, it's hard to "reverse engineer" them without knowing what to look for. I think some answers i seek are buried here, but it's a monster of an ICEtree:

http://area.autodesk.com/forum/autodesk ... p-cobwebs/

Sorry if i am asking for help with trivial things, but i have spent a lot of time trying to figure it out by myself (and google) with little success.
I am not looking for a ready-to-use solution, but i would really appreciate if someone pointed me in the right direction in terms of planning and methods to look into.

Moderator edit - I changed the "community.softimage" link, that doesn't seem to work anymore into the Area link that was probably intended - HB

grahamef
Posts: 281
Joined: 23 Jun 2009, 19:01

Re: Strand control basics

Post by grahamef » 06 Jul 2011, 18:08

Strands are basically per-particle arrays of positions. The strands get drawn from each particle to the first position in its array, then the second, etc. You can create strands manually by putting the positions you want in an array and saving it as the StrandPosition attribute.

So:

1. This will not be an issue if you are not using simulation. If you are using simulation, you can reset the particles' positions to the emit location every frame.

2. Set the last element in the StrandPosition array to the desired position.

3. Update the positions in the StrandPosition array based on any inputs you want.

4. You can e.g. jitter positions without simulation by using a turbulence field to modify point positions.

Hope that gives you a good starting point. Good luck!

jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Re: Strand control basics

Post by jamnique » 07 Jul 2011, 00:09

Thanks grahamef! I started looking into arrays, and now i can generate a strand and set / transform positions of individual points, rotate them, change the number of segments, add turbulence to the strand, grow it and such.

However, I have no idea how to apply effects only to a selected range of segments in the array (other than one by one via SetInArray), or weight the influence across the strand.

Should I:
A) Filter the turbulence somehow before setting StrandPositions (maybe by PopFromArray?)
B) Multiply the Array by another one containing weights (based on ID?)
B) Apply turbulence to the whole strand and linearly interpolate the new StrandPositions with the original ones (would still require distributing the weight of the blend)
C) Apply turbulence to the whole strand and then set selected points back using SetInArray (doesn't seem to work, maybe i should have done it on another tree, and it would still require some blending)
D) Or is there some compound that allows to spread values (like turbulence amount) across a strand (array)? Calculate Strand Ratios (+Fcurve?)

Sorry if I'm not making much sense, math isn't my strong side.
Basically i would like to know if i should try to filter StrandPosition changes before setting them (and how), or hammer them back in later in another iteration (ICEtree?)

fabricio.chamon
Posts: 94
Joined: 09 Jun 2009, 21:47

Re: Strand control basics

Post by fabricio.chamon » 07 Jul 2011, 04:17

I'd go for the fcurve approach. Easy to control and no fancy array manipulations...
not in front of soft now, but should be like:

get strandposition > get array sub indices > normalize it (by dividing or rescaling) > fcurve input

then multiply any effect you want by the fcurve output

jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Re: Strand control basics

Post by jamnique » 07 Jul 2011, 07:04

Thanks Fabricio, this actually worked the way i wanted it to ;] Still, i would like to know more about the array manipulation approach, seams more flexible for more complex things, like the spider web.

I got halfway there with arrays - I managed to filter out the first segment with Get Array Minimum and Find In Array fed into Set in Array and an if statement, but i couldn't get it to work with Get Array Maximum at the same time. No idea how to stack "If's". I doubt it should be done this way though. I'll keep digging.
You do not have the required permissions to view the files attached to this post.

User avatar
Mathaeus
Posts: 1778
Joined: 08 Jun 2009, 19:11
Location: Zagreb, Croatia

Re: Strand control basics

Post by Mathaeus » 07 Jul 2011, 09:24

jamnique wrote:Thanks Fabricio, this actually worked the way i wanted it to ;] Still, i would like to know more about the array manipulation approach, seams more flexible for more complex things, like the spider web.

I got halfway there with arrays - I managed to filter out the first segment with Get Array Minimum and Find In Array fed into Set in Array and an if statement, but i couldn't get it to work with Get Array Maximum at the same time. No idea how to stack "If's". I doubt it should be done this way though. I'll keep digging.
Hi there,

The 'array maximum' and 'array minimum' is value, not ID. In case of 3d vectors, if you draw a line from minimum to maximum, it's a some kind of diagonal line in world space. I'm not sure is this exactly what you want. If you want IDs, probably you want 'select in array' using zero and 'get array size' - 1, for first and last ID.

For complex 'If's', there are 'logic' nodes, 'and', 'or', so on. So, one way to isolate the effect of turbulence would be: get strand position> get array sub-indices, if ID is not zero, *and", ID is not array size -1 > add turbulence to strands.

Anyway, I would go in way suggested by Fabricio, even more for complex stuff. A small problem is, that array 're-constructions' , as you did in pictures, in most cases, needs to go to any other strand-related array: strand size, strand velocity, strand color, strand up vector, whatever you have of these.
On another side, 're-mapping' can go just where you want it to appear, and that's all. btw, what I suggested, it's also 're-mapping', not 're-construction'.

Cheers

jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Re: Strand control basics

Post by jamnique » 07 Jul 2011, 18:47

Thanks Mathaeus :) I'm really happy i came here to ask, now i can at least begin to understand some compounds i have been using and learn from them.
Next thing i would like to crack is setting pins on strand segments that can be turned on and off based on constrained strand length or choice, and add some kind of string dynamics.

Two quick questions come to mind now:
1) can i use a gradient instead of an f-curve? Seems more intuitive from the user''s perspective.
2) For scenes that need dynamic approach (string-like behavior) would i be better of using syflex/ lagoa or verlet? I need quite a few "tentacles"

Here's another baby step i have made with your help (and polynoid compounds, which i can finally understand).
The bigger the length between origin and end, the more stretched out the strand is.
You do not have the required permissions to view the files attached to this post.

User avatar
Mathaeus
Posts: 1778
Joined: 08 Jun 2009, 19:11
Location: Zagreb, Croatia

Re: Strand control basics

Post by Mathaeus » 07 Jul 2011, 19:36

jamnique wrote: Two quick questions come to mind now:
1) can i use a gradient instead of an f-curve? Seems more intuitive from the user''s perspective.
2) For scenes that need dynamic approach (string-like behavior) would i be better of using syflex/ lagoa or verlet? I need quite a few "tentacles"
1: believe me or not, I've tried the same in my first compounds. It worked, but It was slower than function curve, I guessing because of conversions, 'strand ratio' to color, color back to scalar..... In picture, there is 'smooth step' interpolation, so frequently used in CG - it's not for everything, but it's fast, and you can put everything into sliders.
2. you're owner. Verlet has some nice wavy look, it's easy to control with ICE, also it is a good source for improving the ICE knowledge.

Image

jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Re: Strand control basics

Post by jamnique » 07 Jul 2011, 21:16

Thanks, i'll look into it tonight. Finally some progress! Thanks guys ;]

jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Re: Strand control basics

Post by jamnique » 08 Jul 2011, 18:43

I am thinking about building some kind of spider-legs behavior for my tentacles. The tasks i see ahead:
1) Raycast from the "spider"'s body to get initial legs' positions, filter out points by a radius to delete the ones beneath the body and set initial legs' length (or emit particles with a certain direction only)
2) Store point positions in a custom variable (originalPointPositions), constrain length of the legs
3) Raycast again every Nth frame to find new positions if the body has moved, OR Raycast every frame and make the point positions update every Nth frame
4) Linear Interpolate between original point (and / or strand ?) positions saved N frames ago and new ones to create a transition path for the legs' ends, modified by an Fcurve in y to make the legs go up instead of sliding on the surface

If you don't mind, please let me know what you think.

User avatar
Mathaeus
Posts: 1778
Joined: 08 Jun 2009, 19:11
Location: Zagreb, Croatia

Re: Strand control basics

Post by Mathaeus » 08 Jul 2011, 20:51

jamnique wrote:I am thinking about building some kind of spider-legs behavior for my tentacles. The tasks i see ahead:
1) Raycast from the "spider"'s body to get initial legs' positions, filter out points by a radius to delete the ones beneath the body and set initial legs' length (or emit particles with a certain direction only)
2) Store point positions in a custom variable (originalPointPositions), constrain length of the legs
3) Raycast again every Nth frame to find new positions if the body has moved, OR Raycast every frame and make the point positions update every Nth frame
4) Linear Interpolate between original point (and / or strand ?) positions saved N frames ago and new ones to create a transition path for the legs' ends, modified by an Fcurve in y to make the legs go up instead of sliding on the surface

If you don't mind, please let me know what you think.
well I've only played with bipeds :), and this one is based on point cloud, each particle is a body part, ice tree is animated (not simulated), just an function curve and modulo trickery for walking cycle on the virtual path. Raycast is used only to avoid interpenetration. I never published it because is still messy,..
... but it's generally based on purely simulated 'procedural crabs' from mt ice tutorials by Helge Mathee. This is a bit old (but still usable, I think) collection of ICE examples, including 2-bone IK chains, I think there is even an spider there.

btw when you are with ray-casting, you aren't bounded with 'from' - you can raycast from anywhere in 3d space, you can also raycast a whole array in different directions. But it is important to 'fit' the result into some context. Let's say, use self .pointposition plus some 3d vector for raycast origin, or just 'linear interpolate' with zero weight of self .pointposition (this forces per-point context).
I also wouldn't go with deleting if this isn't necessary, just to keep everything 'cleaner' for 'distribution of result' stage (which result to which point and so on) - but all that is just my very personal preference.

Whatever, If there isn't any newer stuff, take look at mentioned mt ice tutorials, I think it's a kind of golden mine for what you talking.

cheers

jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Re: Strand control basics

Post by jamnique » 08 Jul 2011, 23:00

Woah, lot's of great examples. And there actually is a spider ;] I'll try to understand how it all works and come back ;) Thanks!

jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Re: Strand control basics

Post by jamnique » 09 Jul 2011, 05:41

Ok, I understand how the spider works :) I have another question: if i wanted to generate strands from another strand (like hair on spider's legs), can i somehow access points on the surface of the generated mental ray primitive, or choose location based on UVs of the strand rather than strand positions?
Or is that unnecessary, and it would be better to build a new linearly interpolated array of points between each two leg segments (for hair origins)?

EDIT: I decided to go with the last approach, since i know how ;] Still, I'm curious if the former two are possible, and what advantages/disadvantages would UVs have compared to this approach.

User avatar
Mathaeus
Posts: 1778
Joined: 08 Jun 2009, 19:11
Location: Zagreb, Croatia

Re: Strand control basics

Post by Mathaeus » 09 Jul 2011, 09:23

jamnique wrote:Ok, I understand how the spider works :) I have another question: if i wanted to generate strands from another strand (like hair on spider's legs), can i somehow access points on the surface of the generated mental ray primitive, or choose location based on UVs of the strand rather than strand positions?
Or is that unnecessary, and it would be better to build a new linearly interpolated array of points between each two leg segments (for hair origins)?
- access points on the surface of the generated mental ray primitive : don't believe it's possible (at least not in feasible way). In Softimage, renderer is 'last'.

- choose location based on UVs of the strand rather than strand positions : you can save a 'strand location', but imho this has a sense only if you're generating the strands from location, using 'UV to location node' or something like that. Anyway, you can 'interpolate array on array', there are a few ready-for-use nodes for this, like 'get position on strand' in Melena addon (still, Mr. Mathee is author). Btw node can interpolate on any array, not just strand position.
Of course you can get this in 'parallel' way, as you already said.

From my own experience, both 'interpolate array on array' and 'parallel' are enough fast, especially with small arrays of two-three members. Whatever fits better into your concept.

jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Re: Strand control basics

Post by jamnique » 11 Jul 2011, 02:01

Thank you for tips Mathaeus. I haven't had the chance to play with my tentacles yet, but soon i will make some time to work on them again and i will post results.

jamnique
Posts: 14
Joined: 05 Jul 2011, 07:36
Skype: darthjamnique

Re: Strand control basics

Post by jamnique » 17 Jul 2011, 01:32

Ok, i had some time to dissect more compounds, read, watch tutorials and play. I can do and understand quite a bit compared to what i could before (which was close to nothing). Thanks to u you guys ;]

One thing that keeps bugging me though, and i am wondering if there are clever ways around it, is object context conflicts.

Let's say i have a null, a grid and a point cloud with an ICE tree on it. I get the null's global position and the grid's point positions. I subtract one from another to create vectors. So far so good. Now, i am trying to use these vectors to drive parameters of the point cloud (namely blend them with a raycast direction vector, but let's say set data on a self.TMP) and... no joy. It says that the self.TMP will accept only data of types such and such OF POINTCLOUD.POINTCLOUD.

I understand that this is a fundamental concept in ICE, but i don't really know how to deal with this. ID to location doesn't seem to do the trick.