Anim8or Community

General Category => ASL Scripts => Topic started by: selden on October 28, 2015, 11:05:33 pm

Title: How to retrieve a texture's BlendMode ?
Post by: selden on October 28, 2015, 11:05:33 pm
How can I retrieve the BlendMode associated with a Texture in the export script that I'm working on?
(I'm trying to improve the functionality of my CMOD export script.)

The documentation at http://anim8or.com/scripts/spec/index.html shows "int GetBlendMode(int mode);" to be an element of  "struct material" except that can't be right. That would allow only one BlendMode per material, while there actually can be many BlendModes in a material, one associated with each of a Material's Textures. Unfortunately, my attempts to retrieve it as if it were an element of a texture structure don't work. :(



Title: Re: How to retrieve a texture's BlendMode ?
Post by: Claude on October 28, 2015, 11:50:52 pm
Try:
int GetBlendMode(int kind, int mode);
If it's implemented, it should be similar to
int SetBlendMode(int kind, int mode);
Title: Re: How to retrieve a texture's BlendMode ?
Post by: Steve on October 29, 2015, 12:06:29 am
There is a typo in the spec.  The real description should be:

int material.GetBlendMode(int kind);

where kind is one of:

enum {
    TEXTURE_AMBIENT,
    TEXTURE_DIFFUSE,
    TEXTURE_SPECULAR,
    TEXTURE_EMISSIVE,
    TEXTURE_TRANSPARENCY,
    TEXTURE_BUMPMAP,
    TEXTURE_ENVIRONMENT,
};

and the return value:

enum BlendMode {
    BLEND_MODE_DECAL = 0,
    BLEND_MODE_DARKEN = 1,
    BLEND_MODE_LIGHTEN = 2,
};

An example:

mode = lMaterial.GetBlendMode(TEXTURE_DIFFUSE);

Title: Re: How to retrieve a texture's BlendMode ?
Post by: Claude on October 29, 2015, 12:35:36 am
I didn't think about this long enough to see that
int mode was not required,but I was wondering
what int SetBlendMode() and int SetAlphaMode()
would return.
Title: Re: How to retrieve a texture's BlendMode ?
Post by: selden on October 29, 2015, 03:42:43 am
Steve,

Thanks, a lot! That did exactly what I wanted. I was able implement "decal" and "darken". Unfortunately, Celestia does not provide a way to add colors, only multiply, so I was unable to implement "lighten".

The revised CMOD exporter is now available at http://www.classe.cornell.edu/~seb/celestia/modelling.html#4.1