For Each Loop - Houdini Vex - CG Forge

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ส.ค. 2019
  • Check out the link below for the full course:
    www.cgforge.com/course?courseid=vex_foundations_ii
    Thanks for watching!

ความคิดเห็น • 19

  • @dongxianbones
    @dongxianbones หลายเดือนก่อน

    I found this tutorial incredibly helpful! when chatgpt is not so. It explained the foreach VEX function in detail and showed me exactly how to use it. The guidance on why a local variable is used was particularly enlightening. The instructor really held my hand through the process, making it easy to follow along. Highly recommended for anyone looking to understand VEX functions thoroughly and logically.

    • @ohimarc9983
      @ohimarc9983 18 วันที่ผ่านมา

      See any idiot can use ai 😂

  • @elpamidor6601
    @elpamidor6601 4 ปีที่แล้ว +5

    That was the best vex tutorial i ever seen. İ never understand others

  • @sagarthapa3765
    @sagarthapa3765 3 ปีที่แล้ว

    Thank you!

  • @josefh8782
    @josefh8782 ปีที่แล้ว +1

    Understand the point you make for simplicity, but I've wondering whether its correct to think of wrangles themselves as a "for loop", given then are actually multithreaded operations which run the snippet as simultaneously as possible across all points, rather than iteratively like a loop. For example, lets say you have some geo with a detail attribute @d = 1. If you were to run a point wrangle over this, specifying that if @d=1, change each point colour to red, then change the attribute to @d=0. Every point will turn red. This would not happen in a for loop, as the condition would be positive for the first point, and then the detail attribute would be changed, and no more points would meet the condition.

    • @cgforge
      @cgforge  ปีที่แล้ว +1

      Hey Josef, you are correct in that wrangles are multi-threaded operations which run the snippet simultaneously across the points. In this situation, I tried teaching for-loops in vex in a way that might be a bit more intuitive though.
      When we do something in a point wrangle, we would like to do something "for each point." Even though I understand it's multi-threaded and calculated simultaneously, the intuitive logic in our head still says... "for each point" I would like to do something. So, when we introduce for loops on top of that, it will feel confusing at first because in our heads, we're already doing something "for each point." That's why I say that for-loops are kind of like a for-loop within a for-loop.
      We're already going through each point and doing something because it's a point wrangle, but on top of that, we are running a for-each operation on each individual point. This also means that the only way to really use a for-loop on each individual point in some kind of meaningful way is by storing array attribute values on each point so that the for-loop has something to iterate over when it encounters the array attribute values that are stored on one individual point.
      Hopefully that makes a bit of sense - It's true that it's not technically correct to say that, "wrangles are a for-each loop on geometry components." But, this logic is very helpful when trying to understand how to think about for-each loops within the context of vex for the first time, and that's why I taught it in that way.

  • @mansamnnnnikaido
    @mansamnnnnikaido 3 ปีที่แล้ว

    Hi, I have a question here.
    Why do we have to use @colors[0] in foreach loop to set this vector? I thought [0] means the very first element in the vector?

    • @cgforge
      @cgforge  3 ปีที่แล้ว +1

      In this case, @colors[0] refers to the first entry in the array. You're right that [0] can also mean that you're trying to access the first index of the vector, but in this case, it's going for the array because @colors is a vector array - not a vector attribute.

    • @mansamnnnnikaido
      @mansamnnnnikaido 3 ปีที่แล้ว

      @@cgforge I see! Fully understand now. Thanks for the rapid reply!

    • @cgforge
      @cgforge  3 ปีที่แล้ว

      @@mansamnnnnikaido Awesome! No problem

  • @tetsuooshima832
    @tetsuooshima832 4 ปีที่แล้ว +1

    Very interesting... Right off the bat I'm wondering why we can't just type "foreach(@colors[]) then if colors[0] == red then do something". I mean who needs the x vector lol often with coding I just need to accept the rules, that's how it is x) I guess I won't get it until I try.
    Also in the end we don't get to see any red color replaced by random colors, because it's white so there's red in it and everything gets replaced... so what's the point asking for red color at all x) Maybe it would be easier to understand with a black object with red paint ? But anyway let me first open Houdini and try all of this stuff xD

    • @tetsuooshima832
      @tetsuooshima832 4 ปีที่แล้ว +1

      ok so I just tried and in fact, whatever color the input object is (even pure blue), you get the exact same result so I don't get it at all, what all that code was for !!! Maybe I did something wrong xD
      Also to simplify the tutorial why not put in the If statement something like, another color instead, it's less code for beginners like me to grasp; like @colors[0] = {0,1,1}
      but @colors[0] = set(0,1,1) will work as well don't ask me why I get the same thing, I don't know ! x)

  • @jooncult
    @jooncult 4 ปีที่แล้ว +2

    s[]@confused = {"no more","awesome"};
    foreach(string tutorial; @confused)
    {
    if (tutorial == "awesome")
    {
    @confused[1] = ("thank you");
    }
    }

    • @ohimarc9983
      @ohimarc9983 18 วันที่ผ่านมา

      You missed some underscores the code doesn't work😂

  • @jiajima9593
    @jiajima9593 2 ปีที่แล้ว

    Confused

    • @cgforge
      @cgforge  2 ปีที่แล้ว

      I had to re-read and watch tutorials about it a few times to understand it at first. Try re-watching, practicing, and reading what others have said about For Each Loops. It may take a few times to understand it.

  • @npmmalayalamvfxtutorials1717
    @npmmalayalamvfxtutorials1717 4 ปีที่แล้ว

    I need to find a programmer friend

    • @user-uu3ul5wx1k
      @user-uu3ul5wx1k 2 ปีที่แล้ว

      no, they cant help, the fundementals are totally different, even i tried to find one, he was like how this works😂😂😂

    • @npmmalayalamvfxtutorials1717
      @npmmalayalamvfxtutorials1717 2 ปีที่แล้ว

      @@user-uu3ul5wx1k lol