Jump to content

How to do feedback loops in VEX to create a "Stacking" effect. Also free book generator/placer HDA.


Latimerias

Recommended Posts

I cannot seem to wrap my head around how to do this so I am asking here. Im looking for a way to "stack" values with VEX. If i simplify it I want to create a point and assign it a random value, then move it that value in the x direction. After that I want to create a second point, give it a new random value and move it that distance + the distance of the first point. The purpose is to create a point generator with random scale values that i can use with LOPs inside of an instancer to place books next to eachother at random scales. I made this in sops and it worked well on a smaller scale but I ended up doing a few thousand books and overloaded my ram. Currently what i have is this.

int iter = chi("Iterations");
float minwidth = chf("Min_Width");
float maxwidth = chf("Max_Width");


for(int i = 0; i < iter; i++){
    
    float currentwidth = fit01(rand(i), minwidth, maxwidth);
    float prevwidth = fit01(rand(i-1), minwidth, maxwidth);

    vector pos = set(prevwidth+currentwidth/2, 0, 0);
    int pt = addpoint(0, pos);

}

My thought process was to create a random value based on the iteration, this random number would be the book width scale value, which is just fitted so i dont get small values. Then to get the previous books width i would subtract the iteration by 1 which successfully returns the same value. Then i create a point and move it by the previous book width + the current book width/2 because i want the point to be centered. However this doesn't work at all because it can only access a single value back. 

Also i uploaded the sop book generator below if anyone was interested, its pretty flawed the more that i look at it i should have split it into separate HDAs and also you need to have your coordinates set to Z-up. Heres a demo of it through if anyones interested. 

 

jw_book_generator.1.0.hdanc

Edited by Latimerias
Link to comment
Share on other sites

This is what I did in the sops method i attached, is there a way to do this in VEX? I realize i would be better using a while loop probably, because i want to stop once the total distance is greater than the length of the shelf.

Edited by Latimerias
Link to comment
Share on other sites

7 hours ago, Latimerias said:

If i simplify it I want to create a point and assign it a random value, then move it that value in the x direction. After that I want to create a second point, give it a new random value and move it that distance + the distance of the first point.

Hi, 

You can do this inside a SOP solver like Animatrix mentioned, through a for loop or if statements like what I provided in the example. Essentially you're targeting the last point created then adding a new point based on the last point's position + a new random X value. Also you can control the max distance to make sure the solver doesn't create points beyond a certain distance.  

 

generating_points.hiplc

image.thumb.png.f8432be2f839978776f88422ac32f9b2.png

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...