Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

An update to Anim8or, v1.00b, is available with a few bug fixes. Get your copy HERE. See the "ReadMe" file for details.

Author Topic: How to retrieve a texture's BlendMode ?  (Read 1603 times)

selden

  • Full Member
  • ***
  • Posts: 143
    • View Profile
    • Modelling for Celestia
How to retrieve a texture's BlendMode ?
« 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. :(



Logged
Selden

Claude

  • Full Member
  • ***
  • Posts: 248
    • View Profile
Re: How to retrieve a texture's BlendMode ?
« Reply #1 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);
Logged

Steve

  • Administrator
  • Hero Member
  • *****
  • Posts: 1532
    • View Profile
Re: How to retrieve a texture's BlendMode ?
« Reply #2 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);

Logged

Claude

  • Full Member
  • ***
  • Posts: 248
    • View Profile
Re: How to retrieve a texture's BlendMode ?
« Reply #3 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.
Logged

selden

  • Full Member
  • ***
  • Posts: 143
    • View Profile
    • Modelling for Celestia
Re: How to retrieve a texture's BlendMode ?
« Reply #4 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
Logged
Selden