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

Jolly Roger

  • Newbie
  • *
  • Posts: 4
    • View Profile
How to get full texture filename?
« on: June 09, 2008, 06: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, 07:12:59 pm by Jolly Roger »
Logged

Claude

  • Full Member
  • ***
  • Posts: 244
    • View Profile
Re: How to get full texture filename?
« Reply #1 on: June 10, 2008, 01:09:45 am »

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: 1524
    • View Profile
Re: How to get full texture filename?
« Reply #2 on: June 10, 2008, 05: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, 08: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, 06: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, 11: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