We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Tutorial issue – from cgbookcase.com

Home Forums General Questions Tutorial issue – from cgbookcase.com

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #12116
    Pottsie
    Participant

    Hi!

    I’m following the tutorial as presented here. And I’m trying to understand this one specific section, which is changing the material via next/previous arrows. I do understand most of what is going on, but when I try to work through the math, it doesn’t make sense to me (and I know I’m probably doing something incorrectly).

    In the screenshot you’ll see the puzzle configuration. So here is what I’m trying to work through. To start, the “CouchMaterialChange” variable is set to 500 (which is divisible by the total number of items in the “CouchMaterials” list (which is 5). I won’t explain all the code here (it’s in the screenshot), but here is how my math is working out.

    – CouchMaterialChange(500)
    – User clicks “next”
    – This adds 1 to CouchMaterialChange, thus 501
    – 501 is divided by the number of materials in the list (5), thus 100.2
    – The remainder is then returned, 2.
    – Hence 2 points to the 2nd item in the CouchMaterials list.

    Am I thinking of this correctly, or where have I messed up the logic?

    Any help would be appreciated!

    Check out my sketch book :) | www.instagram.com/b.potts.art/

    #12123
    elk
    Customer

    Hi.

    The remainder of a division is whatever whole number (not desimal) is left over if a division does not end up with a whole number, if that makes scense.

    Mening if you divided 500/5 you get 100 with 0 as the remainder. 501 / 5 gives 100 and 1 as the remainder, and so on until you get to 505 that would give you 101 and 0 as a remainder again (101 * 5 + 0), giving you a loop of the 5 possible values for the list of materials.

    I did not test this with puzzles but i think this is what he is going for. Remainder is a useful technic in programming and is often called the modulo operator, often represented by “%” inn place of the regular “/” operator. Lists (or arrays) in programming often start with 0 as the first number(or index) not 1, so a list from 1-5 options would go from 0-4 indexes insted.

    Hope this help and anyone feel free to fill in if i missed something.

    #12125
    Pottsie
    Participant

    Ah, yes..I missed the WHOLE number part.

    This makes sense now. Thank you!

    Check out my sketch book :) | www.instagram.com/b.potts.art/

    #12126
    elk
    Customer

    No problem. Happy I could help out. :good:

    #12138

    Awesome! :) @elk Thanks for helping out. :good:

    Chief 3D Verger | LinkedIn | Twitter

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.