Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Ian Ross has just released a book on Anim8or. It's perect for a beginner and a good reference for experienced users. It contains detailed chapters on every aspect, with many examples. Get your own copy here: "Anim8or Tutorial Book"

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

selden

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • Modelling for Celestia
How to retrieve a texture's BlendMode ?
« on: October 28, 2015, 07: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

  • Sr. Member
  • ****
  • Posts: 285
    • View Profile
Re: How to retrieve a texture's BlendMode ?
« Reply #1 on: October 28, 2015, 07: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: 2126
    • View Profile
Re: How to retrieve a texture's BlendMode ?
« Reply #2 on: October 28, 2015, 08:06:29 pm »

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

  • Sr. Member
  • ****
  • Posts: 285
    • View Profile
Re: How to retrieve a texture's BlendMode ?
« Reply #3 on: October 28, 2015, 08:35:36 pm »

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: 222
    • View Profile
    • Modelling for Celestia
Re: How to retrieve a texture's BlendMode ?
« Reply #4 on: October 28, 2015, 11:42:43 pm »

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