Anim8or Community

General Category => ASL Scripts => Topic started by: Jolly Roger on June 09, 2008, 06:56:20 pm

Title: How to get full texture filename?
Post by: Jolly Roger 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
Title: Re: How to get full texture filename?
Post by: Claude 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.
Title: Re: How to get full texture filename?
Post by: Steve 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.
Title: Re: How to get full texture filename?
Post by: Jolly Roger on June 10, 2008, 08:11:36 pm
Thanks for your help.

Roger
Title: Re: How to get full texture filename?
Post by: Jolly Roger 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
Title: Re: How to get full texture filename?
Post by: Jolly Roger 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]);