duck typing in vex

   1793   1   0
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
hi all

i am trying to get duck typing behavior in vex where I can scale a space seperated user selection of point attrs regardless of type
this wrangle code is working but it relies on predefined variables and would need extending for matrices and arrays ect
anybody have a nicer solution?
cheers in advance


string attrs[] = split( chs("attrs") );
string pattrs[] = detailintrinsic(geoself(), "pointattributes");
string a;
string pa;
int type = 0;
int typesize;
int tmpi = 0;
float tmpf = 0.0;
vector tmpv = {0,0,0};
foreach(a; attrs)
{
    foreach(pa; pattrs)
    {
        if( pa == a )
            {
                
                type = pointattribtype( geoself(), a );
                typesize = pointattribsize( geoself(), a );
                
                if (type == 0)
                    {
                        tmpi = point( geoself(), a, @ptnum  );
                        setpointattrib( geoself(), a, @ptnum, tmpi * ch("scale"), "set");
                    }
                if (type == 1)
                    {
                        if (typesize == 3)
                        {
                            tmpv = point( geoself(), a, @ptnum  );
                            setpointattrib( geoself(), a, @ptnum, tmpv * ch("scale"), "set");
                        }
                        else 
                        {
                            tmpf = point( geoself(), a, @ptnum  );
                            setpointattrib( geoself(), a, @ptnum, tmpf * ch("scale"), "set");
                        }
                    }
            }
    }
    
    
    
}
Edited by megasets - Jan. 4, 2017 09:07:35
Sam Swift-Glasman
Art Director
Five AI
User Avatar
Member
2536 posts
Joined: June 2008
Offline
Am I reading this right? You are storing attributes for points as a string array detail attribute? Why don't you just put the attributes on points to begin with? It will make processing them a lot simpler.
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
  • Quick Links