Posts

Showing posts with the label dat

creating local variables, eval dat, store, fetch, examine

 To create a variable that exists at a level & for it's children, we use a text DAT. Inside the DAT, type: me.parent().setVar('variablename', 34) now when you right click the text DAT and select run-script, it creates a little table that contains the variable + value to access this, eg in the radius of a circle, type: me.var('variablename') the circle's radius parameter will now be 34. This variable can be accessed by any nested children by typing the me.var('variablename') code If you make a variable inside one of the children (lets say it's a Base), the parent will NOT be able to access it. If you want a variable to have a changing value, eg. driven by a slider or LFO, you need to use an evaluate dat and a table. Go into the base that contains your variables. inbetween the table & null, add your evaluate dat & connect a blank table as the 2nd input. Give the blank table the correct dimensions & then make sure to recreate the "n...

Rollover effect, panel chop, image selector, containers, dat execute, panel execute, strings, ifs, renderpick and instances

Finally got through most of the Elektronaut vids, so working through some of the Matthew Ragan tuts now. Here are two really good ones demoing two different ways of making a UI that allows you to select an image from a 3x3 grid and display it in a larger window/panel.  https://matthewragan.com/2015/03/29/thp-494-598-image-selector-container-method-touchdesigner/  https://matthewragan.com/2015/03/29/thp-494-598-image-selector-instance-method-touchdesigner/   Some key points that I think are good things to note - Containers are panel types of objects that can be finicky to arrange! However, you can utilise the PANEL CHOP within a container to great advantage - attributes such as "inside" or "rollover" can be used to dim the panel's opacity for example, or maybe a texture TOP that is somewhere. Containers are a bit limited in terms of how you can position them (with any great speed). You're more or less limited to rows and columns, unless you get a little creat...

what is the eval DAT?

 The Eval DAT creates a table that adheres to some rules that you give it. The first input is typically a "dumb" table that has no expressions, it might just be a row of table labels like "position, x y z". The second input is a table with expressions. These are evaluated along the columns. You can enter information into each table using a text editor. The columns are separated by TABS. eg you would type: index TAB x TAB y TAB z to create 4 columns To make the eval dat use data from the dumb table you would type "me.inputCell" into the appropriate "cells" of the 2nd input table. You will most likely use expressions like (me.inputRow)/op('noise1').width op('noise1').sample(x=me.inputRow,y=0)[0] to create data. The first is taking the row number of the table and dividing it by the width parameter of an external noise node to get a fraction. The second is setting the cell value by sampling the rgb value of "noise1" at x,y a...

using the CHOP EXECUTE DAT node - VALUE CHANGE

 Will make other posts as I learn how to use the other bits! use case - say you have a Count CHOP and wish to execute a set of instructions everytime the value changes, the CHOP Execute DAT node is what you want! Eg, take values from a NOISE and apply them to a TRANSFORM, everytime the Count changes value. This is a bit like sample/hold of random values. Create the CHOP EXECUTE DAT. Next type in the name of your Count node in the CHOPs box The part we're interested in is this segment of code- def onValueChange(channel, sampleIndex, val, prev):     return We can delete everything above that! Also make sure on the Chop Execute, that "Value Change" is set to ON. so after the colon, we can make some variables (this is for clarity, not necessary) def onValueChange(channel, sampleIndex, val, prev):          source=op('NOISE')     target=op('TRANSFORM')              target.par.tx=sourc...

using the replicator to preload a bunch of images

Use case - you need to preload a bunch of high-res images and then randomly load them into a movie-file-in TOP. (if you just load them straight from a Folder DAT, there might be some lag) Create your Folder DAT as usual, I like to connect a select DAT to this, to trim the irrelevant rows and columns. Make a CHOP thing that can be used to select a number, like a COUNT, call it "index" (we'll use it later) Make a Base Comp (call it something like "images") and inside this, create an IN DAT. Go back up a level and connect your Select DAT to the Base Comp. The Replicator creates a lot (depending on your folder) of nodes, so we use it to keep things tidy. Back inside "images", attach a null to the IN and label it "files" Create a Replicator comp (not attaching it to anything yet) drag over or type in "files" into the Template DAT Table field Create a MovieFileIN TOP, name it "file0" <-that's a zero In this MovieFileIn...

selecting a row from a table, using op...

 use case - you have a table in form of the FOLDER DAT, you want to pick from the rows of the table. Lets say they're a list of images. First, lets get rid of the first column, which just lists the filenames. We need the second column that displays a full path. Use a DAT Select node for this. Choose select Rows by Index, set appropriate last number & Columns also by Index (start and end will both be 1). In the MOVIEFILEIN node, you could type - op('NAME')[0,0] to access the image in the first row. However if you want to do something a bit clever and use a CHOP named "INDEX", for example as the number to select the row, you can't just type - op('NAME')[op('INDEX')[0],0]   <THIS WON'T WORK. And Touch Designer won't say why... op('NAME')[int(op('INDEX')[0]),0]  <You have to change the data type to an int!  so, by casting to an INT, the op('....') blabla works.