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 get full texture filename?  (Read 11779 times)

Jolly Roger

  • Newbie
  • *
  • Posts: 4
    • View Profile
How to get full texture filename?
« on: June 09, 2008, 02:56:20 pm »

The example c export plugin script writes the name of the texture to file but don't include it's extension (jpg, gif, bmp).
How would I go about getting the full filename of a texture?
Thanks.

Roger
« Last Edit: June 09, 2008, 03:12:59 pm by Jolly Roger »
Logged

Claude

  • Sr. Member
  • ****
  • Posts: 285
    • View Profile
Re: How to get full texture filename?
« Reply #1 on: June 09, 2008, 09:09:45 pm »

From the script spec:
Texture Type

struct texture {
    string name;       // texture’s name
    int Marked;        // Marked flag, 1 or 0
    const int CubeMap; // 1 if a Cube Map, else 0
    int InvertImage;   // invert image flag, 1 or 0
    string GetFileName(void);
    string GetCubeMapFileName(int face);
    int SetFileName(string name);
    int SetCubeMapFileName(string name, int face);
};

He's probably using the name member.
Try the "string GetFileName(void)" one.You should get the extension
and the directory also if my memory doesn't fail me.
Logged

Steve

  • Administrator
  • Hero Member
  • *****
  • Posts: 2126
    • View Profile
Re: How to get full texture filename?
« Reply #2 on: June 10, 2008, 01:13:20 am »

That's correct.  The name field is the testure's name as used within Anim8or.  The GetFileName() function returns the file name.
Logged

Jolly Roger

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to get full texture filename?
« Reply #3 on: June 10, 2008, 04:11:36 pm »

Thanks for your help.

Roger
Logged

Jolly Roger

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to get full texture filename?
« Reply #4 on: June 11, 2008, 02:57:51 pm »

I've tried tinkering with the code but I can't seem to get it to work. Although I'm no stranger to programming I know next to nothing about c.
I'd be grateful for a snippet of code to show me how to do this.
Thanks.

Roger
Logged

Jolly Roger

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to get full texture filename?
« Reply #5 on: June 12, 2008, 07:26:53 pm »

I've finally worked it out.  :)

This seems to do the trick:

$name[1] = $tex[1].GetFileName();
$name[2] = $tex[1].name +"."+$name[1].GetExt;
$output.print("TextureFilename {\n");
$output.print("\"%s\";\n", $name[2]);
Logged