autocaulk tool


(isbowhten) #1

i wanna write a program that auto-caulks…
for this i first need to “read” the numbers into variables…

the row of the lines in .map file does not matter! (i tested it)
THIS first 2 lines are not detected correctly.
in first line:
the variables get the numbers -32 -32 48 32 -32 48 32 -32 (all correct so far) and 0 (that means it did not get any value)
( -32 -32 48 ) ( 32 -32 48 ) ( 32 -32 40 ) radiant/notex 0 0 0 0.500000 0.500000 0 0 0
( -32 32 48 ) ( -32 -32 48 ) ( -32 -32 40 ) radiant/notex 0 0 0 0.500000 0.500000 0 0 0

this lines are detected correctly!!
it does not matter how many lines it reads…
i added alot of “correct read” ones and it read those many lines correctly but not the 2 above !
( 32 32 48 ) ( -32 32 48 ) ( -32 32 40 ) radiant/notex 0 0 0 0.500000 0.500000 0 0 0
( 32 -32 48 ) ( 32 32 48 ) ( 32 32 40 ) radiant/notex 0 0 0 0.500000 0.500000 0 0 0
( 32 -32 32 ) ( -32 -32 32 ) ( -32 32 32 ) radiant/notex 0 0 0 0.500000 0.500000 0 0 0
( -32 32 -32 ) ( -32 -32 -32 ) ( 32 -32 -32 ) radiant/notex 0 0 0 0.500000 0.500000 0 0 0
(those have been detecte correct)

my question:
do you see any difference between the “correct” and the “incorreect” lines?

each normal brush (6 sides) has exactly 2 lines in which my program cant read out the last number…
so there has to be any difference hasnt it?

i also changed the row of the lines, then e.g. not the 1st two lines but the last two lines were not detected.

so definetly the difference is in the lines of the .map file !


(IndyJones) #2

i can’t understand what do you mean by autocaulk tool.


(isbowhten) #3

that is not important.
automatic caulk?
it caulks all surfaces that cant be seen.

EDIT:
i now edited in a texteditor a “incorrect” line that it is the same than a “correct” line…
result: no mistake… => only 1 mistake left … i could also edit the last mistake …
then i would not get any error by my program BUUT then ofc the brush is messed xD
anyway, this should be another prove that the difference , why my program cant read the last number in 2 of 6 lines (form the same usual brush), is IN the lines of the .map file itself


(IndyJones) #4

the alogirthm for unseen surfaces would be so * complicated, and not even worth its work, because human would to it more accurate.


(ailmanki) #5

dunno how your program does work, but could it be that the failing lines have different new lines chars?
At least I would check for the ending of the line…

edit: also if you can’t solve it, gtk radiant is opensource afaik… so the code loading the map file and saving it is available…


(isbowhten) #6

@indy
nah the human CANT make it better than the computer if just say the computer how to.
and it should be much faster and easier,.
it is not soo complex… on my mind the algorithm already exists…
just ahve to make my PC understand it…
@ailmanki
i will check that out thx


(IndyJones) #7

well, i don’t think you are going to make a working tool, but good luck anyway. :slight_smile:
when i was working on italy, i had every brush with caulk texture.

… and isn’t vis blocking in newer q3map2 unseen surfaces already? i believe pazur had a example on his site about caulking.


(shagileo) #8

A caulk maker… now that’s new :slight_smile:

Well personally I don’t think people will be needing that, since caulking isn’t that big of a challenge , but hey… you want to make mapping life a bit easier for all of us, so good luck with it :wink:


(Pegazus) #9

Good luck Isbowhten

@Indy
This program will come in good use if you know how to use it properly ! Humans make mistakes, errors and in this case we sometimes use texture on unseen faces and when you are releasing a big map that you have placed a lot of effort in you will make those mistakes alot and this will come in good hand to save a couple hours work if you know what i mean…


(isbowhten) #10

i still dont know why 2 lines cant be read correctly…
summary:
the row and the amount of lines leads to the same errors at exactly the same lines…
so there should be any difference between, shouldnt it?

i am trying some things out atm but suggestions are welcome


(IndyJones) #11

well, first of all you should say what’s your programming language (c++, turbo pascal?).


(isbowhten) #12

if you read my posts again… you will see that the mistake can’t be in my program, because the mistake does not refer to the row or amount of lines.

yes it is turbo pascal, but i can change the row of the lines and add lines or delete lines in the .map file and ALWAYS the same 2 lines are incorrectly read at the last of the 9 numbers. ( a lines has 9 numbers referring to the brush’s form)
the last number of exactly 2 lines of 6 (1 usual 6sided brush) have the value 0…
the weird thing is… that it is always 0 even if i change the mistaken number in .map or set all variables at the start to another value as 0. ! so it cant be possible that the “4” of “40” gets cut of… cause i chagned in .map to 43 and still there was 0 as value of the variable.
and it cant be the start-value of a variable (-> 0) because i set it to -1 and still the variable had value 0 !
so my program seems to read out of the string " ( numbers ) ( ) ( ) common/whatever 0 0 0 0" the number 0, which really is impossible , becaus it is not there ?

i can say it again! the row of the lines and the amount of lines does not change anything !
the mistakes are still at the same 2 lines… so there should be a difference between the lines in .map file
… ailmanki suggested another char for a " " but it isnt … ord(’ ‘) and ord(’ ') <- copied out of map file at different positions give me the same ASCII value (->32 iirc)


(ailmanki) #13

well if you like you can send me your code…
I am kinda familiar with turbo pascal…
But to say, I did not meant that space I meant the hidden char for a new line.
I thought that there could be maybe twice a new line on the end of the line.

I know of troubles with processing text… I wrote twice code to read in mapscripts… and its pita.

Also there might be numerous troubles with text… cause of encoding…


(isbowhten) #14

well… i am still convinced that the program hasnt a mistake…
there should only miss something, because the errors are always at the same lines even if i change the row…
i dont want you to prgram it for me :wink: i wanna do it myself …
maybe you can try that out xD
what i did (with a very orderless piece of code) is :

  • read the lines until the line does not start ’ (’
  • delete the ( and )
  • delete the unneeded spaces… there are sometimes 3 spaces instead of one
    … here ->x ) ( x … after ( and ) have been deleted there are 3 ’ ’ left.
  • then i read from the string the chars until the ’ ', then cut it in two parts
  • turn the part of the string into a number
  • from the original string i cut off the first part, because the first part already has been made into a number
  • i let repeat those steps until the end of the .map file
    -------> no errors except of the last number of 2 lines in each brush

well… xD ofc i can send you my code… but it will bite you…
you would wish not to have offered it ^^

i will write it here


program autocaulk;
uses crt,dos;
var t:Text;l,i,i1,i2,j,f:integer;b:boolean;v:array[1..2,1..3,1..3] of integer;
    st,p:string;

begin clrscr;i2:=0;textcolor(white);
writeln('Path to mapfile?');
repeat readln(p);  assign(t,p);if doserror<>0 then writeln('error,restart and type again!'); until doserror=0;

{/////////////////////}
reset(t);
while not eof(t) do begin readln(t,p);inc(i2);end;
                   (*START*)(*find first string*)
                   reset(t);

     for i1:=1 to i2 do BEGIN  (* BŽGIIIIIIIN*)       j:=0; i:=0;i1:=0;i2:=0;b:=false;
            l:=0;
repeat inc(l);readln(t,p); until (p[1]='(')or(eof(t)=true);
if eof(t) then break;

                     readln;
  i:=0;
 while i<length(p) do begin inc(i);
  if ((ord(p[i])>57)or(ord(p[i])<48))and((p[i]<>' ')and(p[i]<>'-')) then delete(p,i,1);
  if (ord(p[i])>65) then delete(p,i,length(p)-i+1);
 end;

 (* tweak nicht l”schen!*)i:=0;   delete(p,1,1);
repeat inc(i); if p[i]=' ' then
 begin
 if p[i+1]=' ' then delete(p,i,2);
 end;
 until i>length(p);

i:=0;
repeat inc(i);
 if p[i]=' ' then begin
 inc(j);st:=p;delete(st,i,length(st));f:=0;

 val(st,v[1,3-(j)div(3),(j)mod(3)],f);(*writeln('f ',f); 3- um reihenfolge umzukerzhen*)

 delete(p,1,i);i:=0;
 end;
until i>length(p);

   (* probe *)
   for i:=1 to 9 do writeln(v[1,3-(i)div(3),(i)mod(3)]);
(*   break;*)
{COMPARE;}
     END; (*ŽŽŽAND*)
     readln;
end.


(ailmanki) #15

are you programming in dos ? :S
with turbo pascal? lol I thought you use a bit morn modern version of Pascal …
maybe visit http://www.lazarus.freepascal.org/
then you have also some modern* tools to debug it… well I will try you code this evening… but I guess I will have first to port it to freepascal.


(isbowhten) #16

i am usin tp 7.0 … i am coding on windows… and tp already has debugging “tools”
it has “marks” where it stops executing it …
gives me adresse of program-errors,
highlights the last line it worked out if i abort program manually.

says me syntaxerrors etc…
but that is not the point here ^^ it only does not read the last number of 2 lines… no executing error

thx for testing it…
if you cant find the failure then i will start from scratch again, if you find it then pls do only point me in the right direction


(ailmanki) #17

Well the code works, I tested it with saberpeak.map …
I had to comment out one line i1:=0; , your code is pretty complicated to read, the variable names are not very meaningfull, and I have not much time :stuck_out_tongue:
Anyway in my test it failed when the last number to read, has not 4 chars…
so if the last number is 4000 it works and if it is 300 it works not, and 50000 it fails also…

program autocaulk;
uses crt,dos;
var t:Text;l,i,i1,i2,j,f:integer;b:boolean;v:array[1..2,1..3,1..3] of integer;
    st,p:string;

begin
clrscr;
i2:=0;
textcolor(white);
writeln('Path to mapfile?');

repeat readln(p);
       assign(t,p);
       if doserror<>0 then writeln('error,restart and type again!');
until doserror=0;

{/////////////////////}
reset(t);
while not eof(t) do
begin
     readln(t,p);
     inc(i2);
end;
                   (*START*)(*find first string*)
reset(t);

for i1:=1 to i2 do BEGIN  (* BŽGIIIIIIIN*)
    j:=0;
    i:=0;
    //i1:=0; <- This I had to comment out.. else the compiler says no go.. anyway.. strange code :D
    i2:=0;
    b:=false;
    l:=0;
    repeat inc(l);
           readln(t,p);
    until (p[1]='(')or(eof(t)=true);
    if eof(t) then break;
    readln;
    
    i:=0;
    while i<length(p) do begin
          inc(i);
          if ((ord(p[i])>57)or(ord(p[i])<48))and((p[i]<>' ')and(p[i]<>'-')) then delete(p,i,1);
          if (ord(p[i])>65) then delete(p,i,length(p)-i+1);
    end;
    (* tweak nicht l”schen!*)
    i:=0;
    delete(p,1,1);
    repeat inc(i);
           if p[i]=' ' then begin
              if p[i+1]=' ' then delete(p,i,2);
           end;
    until i>length(p);

    i:=0;
    repeat inc(i);
           if p[i]=' ' then begin
              inc(j);
              st:=p;
              delete(st,i,length(st));
              f:=0;
              val(st,v[1,3-(j)div(3),(j)mod(3)],f);(*writeln('f ',f); 3- um reihenfolge umzukerzhen*)

              delete(p,1,i);
              i:=0;
           end;
    until i>length(p);

   (* probe *)
   for i:=1 to 9 do writeln(v[1,3-(i)div(3),(i)mod(3)]);
(*   break;*)
{COMPARE;}
     END; (*ŽŽŽAND*)
     readln;
end.

edit: ah read your post to late, and I wouldn’t know how to point you in any direction :stuck_out_tongue:


(IRATA) #18

Just a small tip if you think your tool works properly:

Check the character encoding and hidden chars (CR/LF … whatever) of created files.
Get notepad++ http://notepad-plus.sourceforge.net/de/site.htm and analyse your lines This editor is able to show all chars and the encoding of a file.


(isbowhten) #19

i1:=0; does not need to be commented out.
hm… if it is not 4 chars long it does not work??? but how do the other number with length of 2 or 3 chars (eg. 32 -32) work then in the other lines?


(isbowhten) #20

can tp handle strings faster than numbers?
with strings it would be much easier i think.
i will start from scratch again with another algorithm