Anim8or Community

General Category => Ongoing Anim8or Development => Topic started by: Steve on March 05, 2014, 10:48:43 pm

Title: ASL Attribute Functions
Post by: Steve on March 05, 2014, 10:48:43 pm
ASL now has functions add new attributes and to change their types and values.  Previously you could only read existing attributes' values.  In addition attribute functions now work for materials.

Object attribute functions:
    attrubute object.NewAttribute(string name);

Material attribute functions:
    int material.GetNumAttributes(void);
    attribute material.GetAttribute(int index);
    attribute material.LookupAttribute(string name);
    attribute material.NewAttribute(string name);

Functions to set attribute values:
    int attribute.SetKind(AttributeTypes);
    int attribute.SetBoolValue(int);
    int attribute.SetIntValue(int);
    int attribute.SetFloatValue(float);
    int attribute.SetPoint3Value(point3);
    int attribute.SetQuaternionValue(quaternion);
    int attribute.SetStringValue(string);

Note: these functions automatically change the type of an attribute to match the type of the SetTypeValue call, so be careful when using them. I thought that this would make it easier to add new attributes but if you thing that they should check that the type matches, or convert the value, let me know.

They return 1 if they succeed which should always happen, for now. This will change if we decide that they should check the types in one form or another.

Title: ASL Functions to make glass
Post by: Steve on March 05, 2014, 11:15:27 pm
Here is an example that builds a glass material using attributes:

material $MakeGlass(void)
    object $object;
    attribute $attribute;
    material $glass;

    $object = project.curObject;
    $glass = $object.NewMaterial("glass");
    $glass.diffuse = (0.96, 1.0, 0.98);
    $glass.Ks = 0.7;
    $glass.alpha = 0.1;
    $glass.roughness = 200;
    $attribute = $glass.NewAttribute("class");
    $attribute = $glass.NewAttribute("IOR");

    return $glass;

Title: Re: ASL Attribute Functions
Post by: Raxx on March 06, 2014, 03:12:40 pm
I tested some of this out, seems to work well enough :) I think the SetTypeValue approach is good enough.
Title: Re: ASL Attribute Functions
Post by: Raxx on January 10, 2015, 04:13:35 am
So, I'm working on something for the scene editor. Is attribute lookup and assignment for the scene editor not implemented yet?