Aller au contenu

Photo

Perl script regquest. Two actually.


  • Veuillez vous connecter pour répondre
39 réponses à ce sujet

#26
Borden Haelven

Borden Haelven
  • Members
  • 403 messages
Sorry I couldn't help. Posted Image

Modifié par Borden Haelven, 21 juin 2011 - 09:57 .


#27
Calvinthesneak

Calvinthesneak
  • Members
  • 656 messages
I appreciate the situation Bannor is in, because I've been there myself. Hundreds or thousands of ACII mdls to edit, and it's really dull and tedious. I know it's possible to script up PERL or Python to do it, it's just not easy. I could probably do it given several weeks to research the languages since I've done almost no programming with them. Fortunately for me, most of my editing has been simpler and with Wildcards in Useful File utilities I've been able to manage even multi line edits.

Sadly what Bannor is looking for is just a bit too complex to really be done there because of variable spacing. Hopefully virusman gets him sorted.

#28
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
bump.

Where you still needing a solution for this Bannor.
I am comming close to a solution for this via HLA.

hopefully I will have time to compleate it tonight after I get home from work.

#29
Shadooow

Shadooow
  • Members
  • 4 468 messages
yeah sorry Bannor but I havent make any progress on my solution, its going to be especially complicated when you stated that the position of the "alpha" dont have to be always below bitmap which is quite problematic to script then.

It is possible to do via my method, but nwscript isnt really made for this so its very tough to script it...

Sh

#30
Bannor Bloodfist

Bannor Bloodfist
  • Members
  • 924 messages
Oh, completely forgot that this topic was still open.

Actually, having a script would still be useful, but I don't think nwscript can handle it ShaDoOow, I really appreciate you attempting it, but we found too many inconsistancies in the various mdls. IT seems that things can change easily, and are affected by access order/link order in the individual mdl file. So, if I were to open a tile, edit an object, it would change placement of the various options for the graphics bits, the alpha, luminosity, shininess etc... and put those lines in different locations. Likely, that could be changed, all at once, meaning just do a complete replacement of about 8-10 lines of text in the node, and make them all the same, but it just wasn't worth the effort for that.

Olias Stormcrow had a professional text editing apllication that allows for conditional testing, and replacement, he processed the tiles for me manually. His app, whatever it was, could not handle all of the tiles in question, but it did severely cut down on the ones that required manual intervention. This actually turned out to be a good report anyway, as it pointed out some other errors in those specific tiles which required different fixes anyway. Things that likely would have been missed.

Since I only have about 15-20 left to work on, I can handle these by hand now.

Thanks for the offers guys, it is appreciated, but no longer really necessary, although, someone might be able to use a script like that to make mass changes in other tilesets too.

IF you are still interested in attempting this, I can maybe help identify what lines are actually required for each instance, and just make it a quick search for node with bitmap, and replace everything between node and verts in the mdl. Everything after the vert can NOT be changed as it affects the uvw-mapping on the object, and is encoded somehow.

#31
henesua

henesua
  • Members
  • 3 863 messages
What text editor? And was it able to search for regular expressions (GREP)? I've got BBedit in os x but it would handy to see what is used on the windows side.

#32
Bannor Bloodfist

Bannor Bloodfist
  • Members
  • 924 messages

henesua wrote...

What text editor? And was it able to search for regular expressions (GREP)? I've got BBedit in os x but it would handy to see what is used on the windows side.


I don't know what the program actually is, but I was told that the single seat license cost is well over 10,000.  So it is not likely something that can be found on the net.

It does a lot more than grep though, it allows batching, and sub-functions like any normal prgramming language.  Olias claimed he was able to find the mdl's in the folder, search inside each one, find the nodes that had the proper bitmap assigned, then back process that entire node to find the specific Alpha line and make the necessary changes.

That is why I was originally requesting a perl script, because I know that can be done in a full programming language like perl.

#33
Calvinthesneak

Calvinthesneak
  • Members
  • 656 messages
You could probably program in GREP, though finding the correct sub strings and such might get tricky. GREP is pretty simple, much like REGEX and not really capable of handling advanced search functionality. I'm sure you could loop enough to do it, but trying to catch all the cases... would be difficult.

#34
henesua

henesua
  • Members
  • 3 863 messages
BBedit and textmate can do all of that. And they each cost less than $100. OSX only unfortunately. I just wanted a windows tool so that I didn't have to hop between OS's when working on MDLs for NWN. I am really weak in windows command line and so don't know how to script it to use regular expressions.

[edit] Stupid question - but do any windows flavors have *nix style text editor apps ported to their command line? vi emacs or the like?

Modifié par henesua, 29 juin 2011 - 09:29 .


#35
Bannor Bloodfist

Bannor Bloodfist
  • Members
  • 924 messages
GNU Emacs for windows

#36
eeriegeek

eeriegeek
  • Members
  • 47 messages
henesua, google the cygwin project, it's a port of the gnu tools to windows and gives you a bash shell window with access to many of the most useful tools (including vi, emacs, and perl!)

#37
eeriegeek

eeriegeek
  • Members
  • 47 messages
also, bannor, it sounds like it might be a generally useful tool, if you would like to pm me a couple of before and after mdl files i can take a shot at writing a perl script.

#38
henesua

henesua
  • Members
  • 3 863 messages
Thanks eeriegeek, that sounds exactly like what i need to avoid learning the command line for windows.

#39
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

Bannor Bloodfist wrote...

 Actually, having a script would still be useful, but I don't think nwscript can handle it ShaDoOow, I really appreciate you attempting it, but we found too many inconsistancies in the various mdls. IT seems that things can change easily, and are affected by access order/link order in the individual mdl file. So, if I were to open a tile, edit an object, it would change placement of the various options for the graphics bits, the alpha, luminosity, shininess etc... and put those lines in different locations....

  IF you are still interested in attempting this, I can maybe help identify what lines are actually required for each instance, and just make it a quick search for node with bitmap, and replace everything between node and verts in the mdl. Everything after the vert can NOT be changed as it affects the uvw-mapping on the object, and is encoded somehow.



The system I am still working on writing has no problem with the placements of the KeyWords, As long as the Key Word is the first text on the line.    It basicly searches for the KeyWord in this case 'bitmap',    then checks to see if the text after it is the correct value.  If the value is correct it then searches forward for the end of the node.  Then back for the begining of the node.   It then searches for the second Key and Value,  once the second key if found  it checks the value. if it does not match it replaces it. 

The current problem that I have ran into is that not all nodes, that have a 'bitmap' key,, have an 'alpha' key.  This raises the question.  IF the bitmap is found with no alpha in the same node what should be done?  Should a Alpha key be added?  Would this hurt something that I do not know about?  

I do not think it would.  I guess the question would be where to add it.  In some of the bioware tile sets I have noticed that the alpha key is after the verts with the bitmap key being before them.   A verry broad assumption I have is that I could add the key anwhere into the node as long as it is after the bitmap key.   Does that sound like a safe assumption to you?

#40
Bannor Bloodfist

Bannor Bloodfist
  • Members
  • 924 messages
So far, I have never found the alpha AFTER the bitmap, but that doesn't mean it can't be there. In every mdl I have specifically looked for it, the alpha was somewhere before the Bitmap, and always before the verts etc... But you may be right in the assumption that specific location doesn't matter, as long as you don't place it inside some of the sub sections, IE, don't place alpha line in between the many different lines for verts, faces, etc...

The alpha line is not a required field, and only shows up on those tiles that have had some sort of adjustment made to the texture, either re-uvw mapping it, or changing one of the other various settings. By default, alpha is "assumed" to be 1.0 by the engine so if the line doesn't exist in the mdl, it just takes the assumed 1.0 state.

There are other lines similar to Alpha that likely could use the same sort of treatment, but I have not investigated them at this stage of things yet.
Code:
scale 1
  render 1
  shadow 0
  beaming 0
  inheritcolor 0
  rotatetexture 1
  alpha 0.8
  transparencyhint 1
  selfillumcolor 0 0 0
  ambient 1 1 1
  diffuse 1 1 1
  specular 0 0 0
  shininess 26
  center 0 0 0
  bitmap tctl0_water01
endcode

I believe several of those are usefull, diffuse settings, shininess, ambient, selfillumcolor, abd inheritcolor all affect the way the texture is rendered. But I also believe that they tend to be defaulted to whatever Bioware originally used. Meaning they may not be required to get a texture to paint.

Modifié par Bannor Bloodfist, 04 juillet 2011 - 07:32 .