Oni Central Forum

A forum for the Oni community

You are not logged in.

#201 02/13/08 15:02

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: Mac programming

Edit: Argh, another post while I was posting!

@Ed: If our first goal is to track the existing TXMPs that use envmaps, I suppose we can make that aforementioned .txt file, and format it like so:

TXMPguys_armor
TXMPguys_armor_envmap
TXMPgirls_armor
TXMPgirls_armor_envmap

Where each TXMP that uses an envmap is listed, and the following line has the name of that envmap.  That's all I need to work with.  And then, after implementing this, we can allow the user to pick a custom envmap (which is much easier to code -- you probably could already code that yourself using 'choose file').

Edit: Even if most TXMPs use a particular envmap, just list its name over and over again.

Last edited by Iritscen (02/13/08 15:02)


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#202 02/13/08 19:02

EdT
Moderator
From: Los Angeles, CA
Registered: 01/13/07
Website

Re: Mac programming

Iritscen: Here is the list with the files I found that needed envmap.  Its in the format you requested.

Offline

#203 02/14/08 10:02

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: Mac programming

Very good, just what I wanted.  I will probably not be able to post the code for reading that until next week, just an FYI.


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#204 02/14/08 11:02

EdT
Moderator
From: Los Angeles, CA
Registered: 01/13/07
Website

Re: Mac programming

no problem, I was able to break the code off as a function, thanks.
BTW, is there a 3D program that you use? I'm trying to find a easy one, since now we can extract .obj files. smile

Offline

#205 02/14/08 11:02

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: Mac programming

EdT wrote:

no problem, I was able to break the code off as a function, thanks.

...?  You already have some code for reading a text file?  Was it something I did?


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#206 02/14/08 16:02

EdT
Moderator
From: Los Angeles, CA
Registered: 01/13/07
Website

Re: Mac programming

Sorry, I think I need to take more time when writing these posts smile Sometimes, I rush through them.

I wanted to thank you for helping me understand AS functions, so I was able to use your TXMP replacer code as a function in AE Tools.

Also, its no problem, that the code for reading text, won't be available until next week.

Offline

#207 02/15/08 09:02

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: Mac programming

Okay, cool.  I didn't think I was understanding you correctly.  Stay tuned!


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#208 02/19/08 10:02

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: Mac programming

Okay, attached is what I call EnvMapMatcher, but of course, you'll just be rolling this into the Tools.  I just got it working this morning, so I can't guarantee it's bug-free.  You'll recognize the return of some support functions (like strip_suffix) that you probably already added to the Tools, so the actual "new" code isn't as much as it will seem at first.

Notes:
- the code sets TXMP_name to a fixed value.  Obviously when you hook this code into what you've already got, that variable is your "input" to this whole bunch of code.

- the sample name I provided there ends in .oni, but notice that I'm using strip_suffix on that name before looking for it in envmapfiles.txt, so even though you might be providing a .tga file's name as input to this code, it won't change how the code works.  I hope.

- there's some active 'display dialog' code for debugging purposes, that will obviously need to be commented out in the final implementation.

- if you encounter a bug where the last character of the file is not being read (which will give a bad name for the envmap of the last TXMP listed in the text file), try adding a return to the file so the last line is empty.  It seems to be refusing to read the last character of the file, so if the last char. is unimportant, it should be okay.

Hope it works!  I had little time this weekend for coding, so this is hot off the press and not well-tested.


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#209 02/19/08 11:02

EdT
Moderator
From: Los Angeles, CA
Registered: 01/13/07
Website

Re: Mac programming

Thanks, will take a look and give it a try.

Offline

#210 02/19/08 22:02

EdT
Moderator
From: Los Angeles, CA
Registered: 01/13/07
Website

Re: Mac programming

Iritscen: Looks like I was able to incorporate your envMapMatcher to AE Tools.  But not 100% sure.  I made a separate xCode project with the code from EnvMapMatcher and TXMPReplacer. Still need to keep testing.

Offline

#211 02/21/08 11:02

EdT
Moderator
From: Los Angeles, CA
Registered: 01/13/07
Website

Re: Mac programming

Iritscen:  I hope you can help me with some coding.  I wanted to change the way the panel opens up to select the file or folder for TXMP replacement.  There is a way to attach the panel to the AE Tools window, it looks much cleaner.  But coding is much harder. I'll spare you the details...

What I need is a way to get the filename from the pathname such as:
/Users/edt/Desktop/TestLab/someTXMP/TXMPIteration001%2FKS_chestpack.tga

and the folder name in this case:
/Users/edt/Desktop/TestLab/someTXMP

Attached is the xCode test sample

Thanks

Last edited by EdT (02/21/08 11:02)

Offline

#212 02/21/08 12:02

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: Mac programming

I thought I wrote some code for that, but I can't find it.  Meh.

There's two options:
1. Modify this function to look for slashes instead of colons:

on get_suffix(file_name)
    set period to "."
    set last_pd to 0
    set suffix to ""
    set num_chars to (count of characters in file_name)
    
    repeat with y from 1 to num_chars
        if (character y of file_name is period) then
            set last_pd to y
        end if
    end repeat
    
    repeat with z from last_pd to num_chars
        set suffix to suffix & (character z of file_name)
    end repeat
    
    return suffix
end get_suffix

Simply replace "set period to "."" with "set slash to "/"" (assuming slash is not a keyword, which I don't think it is) and then of course change the occurrences of "period" to "slash" and "last_pd" to "last_slash".

Running this code in my head, it looks like it will return the last slash as part of the file's name, so you may need to change "repeat with z from last_pd to num_chars" to "repeat with z from (last_slash + 1) to num_chars".  If you do that, be aware that passing in a pathname that ends with a slash such as "MyHD/place/" will return a fatal error.  Otherwise the code will return the last folder or file in the string just fine.

2. Apple provides their own solution if you are not in a DIY mood, and I use it in some of my code.

set AppleScript's text item delimiters to {":"}
get last text item of "Hard Disk:CD Contents:Release Notes"

Except in this case you want the delimiter to be the forward-slash, since the path you're using is slash-delimited.  Simple, huh?

The only reason I didn't give you the simple solution first is that if you incorporated my code into yours, where I use the delimiter code on colon-separated paths, then I don't recommend changing the delimiter later on.  What could happen is that the delimiter gets set to a new value and then the code that expected the old value might be called again.  Blam.  If you do change the delimiter, it stays changed until you change it back later, so care is required when using this code.

You're supposed to be able to pass a list of delimiters, which would allow us to use both ":" and "/" at the same time, but Apple says, and I quote, "AppleScript currently uses only the first delimiter in the list." tongue


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#213 08/03/08 09:08

EdT
Moderator
From: Los Angeles, CA
Registered: 01/13/07
Website

Re: Mac programming

Iritscen:  I need your help again.  I want to add exporting the level's geometry to AE Tools, but I need some code.

I have a variable that gets the name of the file to be exported such as AKEVairport but I need some code that will change the name from AKEVairport to AGDBairport and save the change as another variable. Does that make sense?

Let's say variable1 = AKEVairport, then I would like variable2 = AGDBairport

This is all related to http://wiki.oni2.net/AE:Levels and the talk page.

Thanks!

Last edited by EdT (08/03/08 09:08)

Offline

Board footer

Powered by FluxBB