General Category > ASL Scripts

How to retrieve a texture's BlendMode ?

(1/1)

selden:
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. :(



Claude:
Try:
int GetBlendMode(int kind, int mode);
If it's implemented, it should be similar to
int SetBlendMode(int kind, int mode);

Steve:
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);

Claude:
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.

selden:
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

Navigation

[0] Message Index

Go to full version