Copy Link
Add to Bookmark
Report

Doom Editing Digest Vol. 01 Nr. 360

eZine's profile picture
Published in 
Doom editing
 · 6 months ago

From:      owner-doom-editing-digest 
To: doom-editing-digest@nvg.unit.no
Subject: doom-editing-digest V1 #360
Reply-To: doom-editing
Errors-To: owner-doom-editing-digest
Precedence: bulk


doom-editing-digest Thursday, 27 July 1995 Volume 01 : Number 360

Level merge/scale/translate/rotate/shear in Perl
Question :
Re: Question :
Non-Reappearing Altdeath Items
Re: Question :
Re: Question :
Re: Strange sector fall-ins...

----------------------------------------------------------------------

From: iwj10@cus.cam.ac.uk (Ian Jackson)
Date: Wed, 26 Jul 95 12:31 BST
Subject: Level merge/scale/translate/rotate/shear in Perl

I don't know whether any of the other editors can do any of the things
that this script can, but I was recently using a version of DEU that
couldn't.

This script takes a number of PWAD's and produces a PWAD (named
`tmpm.wad') with a single level which is the superposition of all the
input levels. Things, vertices, linedefs, sidedefs, sectors and
special sector tags (below 100) are renumbered.

The script doesn't handle graphics and sound resources, nodes trees,
&c, only map data. It includes empty REJECT, BLOCKMAP &c resources in
the output because otherwise DEU won't load the resulting level; sound
and graphics resources will be discarded (with a warning message).

It also doesn't do anything like merging vertices, linedefs, &c that
happen to coincide.

However, it can do arbitrary linear transformations on the horizontal
and vertical coordinate spaces, and can rotate all the Things by a
particular amount.

Any texture alignment you do is likely to be screwed up by scaling,
and will almost certainly be mangled by shear. Translation, rotation
and simple vertical shifts should be fine for this.

The level number of the output WAD is the same as that for the last
level in the last input WAD. (I haven't tested it with input WADs
with multiple levels, but it should work.)

If there is demand there are a number of other things it could be made
to do quite easily; possibilities are global `search-and-replace' on
textures and preprogrammed modifications to Things.

The scaling/translation/rotation/shear to be applied is be specified
by using the -t<abc><xyz><number> option, where <abc> is `a', `b' or
`c' for which coefficient of the transformation equations is to be
changed, <xyx> is `x', `y' or `z' for which coordinate's equation is
to be changed and <number> is the new coefficient. The equations are
x' = ax*x + bx*y + cx
y' = ay*x + by*y + cy
z' = az*z + cz
where x',y',z' are the new coordinates, x,y,z the old and ax and so on
the coefficients. bz isn't used, as the vertical Z transformation is
independent of the horizontal X,Y transformation. The default values
are ax=by=az=1.0 and all the rest zero - this is the identity
transformation.

I couldn't be bothered to write code to turn series of requests like
`rotate clockwise by 90 degrees' and `translate by (1000,-500)' into
the coefficients, so you'll just have to do that yourself. If you
can't figure out how go and attend a maths class :-).

Thing rotation is done separately: you just say -r<degrees>.
(According to the Doom specs the angles will be rounded to the nearest
90 degrees, so rotating Things by small amounts is unlikely to be
useful unless they are already at odd angles.)

You can mix settings of the translation/thing rotation options with
WAD files; each WAD will be processed using the options specified up
to that point. So, for example, you can do
$ mergewads.pl -tax0.75 -tby0.75 part1.wad -tax1 -tby1 -tcx4000 part2.wad
to merge part1 and part2 with part 1 scaled down by a quarter and
part2 translated by 4000 units in the X direction (so that it doesn't
overlap part1).

This script may not work well on DOS versions of Perl, because it
loads all the data into memory and processes it there. Use Un*x - you
know it makes sense :-).

Ian.

#!/usr/bin/perl

# Option arguments may be intermixed with PWADs.
#
# The resulting output file has one level, which is the merge of all
# the levels in the input PWADs. It is not suitable for play - you
# must rebuild the engine precalculation data (BSP tree, blockmap and
# reject map).
#
# Options:
# -t[abc][xyz]<number> sets [abc][xyz] to <number>:
# for horizontal translation/rotation/shearing
# x'= ax*x + bx*y + cx
# y'= ax*y + by*y + cy
# for vertical alteration
# z'= az*z + cz;
# (defaults are ax=by=az=1.0, others=0.0, ie no change)
# -r<angle>
# for rotation of Things - in degrees, positive anticlockwise

# Copyright 1995 Ian Jackson.

# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# It is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with GNU Emacs; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

undef $/;

$vertexoff= 0;
$linedefoff= 0;
$triggeroff= 0;
$sidedefoff= 0;
$sectoroff= 0;

$outfn= 'tmpm.wad';

$maxtrigused= -1;
$maxtrigchange= 100;

$tp{'a','x'}= 1.0;
$tp{'b','y'}= 1.0;
$tp{'a','z'}= 1.0;

while (@ARGV) {
$_= shift(@ARGV);
if (m/^-t([abc])([xyz])(\S+)$/) {
$tp{$1,$2}= $3+0.0;
} elsif (m/^-r(-?\d+)$/) {
$rotate= $1;
} elsif (m/^-/) {
die;
} else {
&readwad($_);
}
}

$xyscale1= sqrt($tp{'a','x'}*$tp{'a','x'} + $tp{'a','y'}*$tp{'a','y'});
$xyscale2= sqrt($tp{'b','x'}*$tp{'b','x'} + $tp{'b','y'}*$tp{'b','y'});

$sdiff= $xyscale1 / $xyscale2;
if ($sdiff < 0.99 || $sdiff > 1.01) { print "WARNING: shear !\n"; }

length($levelname) || die;

$dataoffset= 12;
$totallumps= 0;

&makelump($levelname,'');
&makelump('THINGS',$things);
&makelump('LINEDEFS',$linedefs);
&makelump('SIDEDEFS',$sidedefs);
&makelump('VERTEXES',$vertices);
for $f ('SEGS','SSECTORS','NODES') { &makelump($f,$englump{$f}); }
&makelump('SECTORS',$sectors);
for $f ('REJECT','BLOCKMAP') { &makelump($f,$englump{$f}); }

$output= 'PWAD'.pack('VV',$totallumps,$dataoffset).$data.$directory;

open(O,">$outfn") || die;
print(O $output) || die;
close(O) || die;

print "Wrote $outfn ($totallumps lumps).\n";

sub makelump {
printf "Output lump %s, length %lx, offset %lx.\n",$_[0],length($_[1]),$dataoffset;
$directory .= pack('VVa8',$dataoffset,length($_[1]),$_[0]);
$data .= $_[1];
$dataoffset += length($_[1]);
$totallumps++;
}

sub readwad {
$fn= $_[0];
open(W,$fn) || die; $w=<W>; close(W);
$c= substr($w,0,4); $c eq 'PWAD' || die ">$c<";
$wlen= length($w);
$nlumps= &i($w,4,4,'V');
$diroff= &i($w,8,4,'V');
printf "%s: %d directory entries.\n",$fn,$nlumps;
for ($i=0; $i<$nlumps; $i++) {
$destart= $diroff+$i*16;
$thisoff= &i($w,$destart,4,'V');
$thissize= &i($w,$destart+4,4,'V');
$thisname= &i($w,$destart+8,8,'A8');
$thislump= substr($w,$thisoff,$thissize);
# printf "%s: %-8s offset=%lx length=%lx\n", $fn,$thisname,$thisoff,$thissize;
length($thislump) == $thissize || die "$thissize, ".length($thislump);
if ($thisname =~ m/^E\dM\d$/ || $thisname =~ m/^MAP\d\d$/) {
print "$fn: Merging data from level $thisname.\n";
$levelname= $thisname;
$vertexoff += $vertexcnt; $vertexcnt= 0;
$linedefoff += $linedefcnt; $linedefcnt= 0;
$sidedefoff += $sidedefcnt; $sidedefcnt= 0;
$sectoroff += $sectorcnt; $sectorcnt= 0;
$thingoff += $thingcnt; $thingcnt= 0;
$triggeroff = $maxtrigused+1;
} elsif ($thisname eq 'THINGS') {
($thissize % 10) && die $thissize;
for ($j=0; $j<$thissize; $j+=10) {
$x= &i($thislump,0,2,'v');
$y= &i($thislump,2,2,'v');
$things.= &transco($x,$y,'x');
$things.= &transco($x,$y,'y');
$things.= pack('v', (&i($thislump,4,2,'v') + $rotate) % 360);
$things.= substr($thislump,6,4);
$thingcnt++;
#¶noia(10,$things);
$thislump= substr($thislump,10);
}
print "$fn: Copied THINGS ($thingcnt).\n";
} elsif ($thisname eq 'LINEDEFS') {
($thissize % 14) && die $thissize;
for ($j=0; $j<$thissize; $j+=14) {
$linedefs.= pack('v',$vertexoff+&i($thislump,0,2,'v'));
$linedefs.= pack('v',$vertexoff+&i($thislump,2,2,'v'));
$linedefs.= substr($thislump,4,4);
# print "$linedefcnt\n";
$linedefs.= &transtrigger(&i($thislump,8,2,'v'));
$linedefs.= &trans(&i($thislump,10,2,'v'),$sidedefoff);
$linedefs.= &trans(&i($thislump,12,2,'v'),$sidedefoff);
#¶noia(14,$linedefs);
$linedefcnt++;
$thislump= substr($thislump,14);
}
print "$fn: Copied LINEDEFS ($linedefcnt).\n";
} elsif ($thisname eq 'SIDEDEFS') {
($thissize % 30) && die $thissize;
for ($j=0; $j<$thissize; $j+=30) {
$sidedefs.= pack('v',$xyscale*&i($thislump,0,2,'v'));
$sidedefs.= pack('v',$tp{'a','z'}*&i($thislump,2,2,'v'));
$sidedefs.= substr($thislump,4,24);
$sidedefs.= &trans(&i($thislump,28,2,'v'),$sectoroff);
#¶noia(30,$sidedefs);
$sidedefcnt++;
$thislump= substr($thislump,30);
}
print "$fn: Copied SIDEDEFS ($sidedefcnt).\n";
} elsif ($thisname eq 'VERTEXES') {
($thissize % 4) && die $thissize;
for ($j=0; $j<$thissize; $j+=4) {
$x= &i($thislump,0,2,'v');
$y= &i($thislump,2,2,'v');
$vertices.= &transco($x,$y,'x');
$vertices.= &transco($x,$y,'y');
#¶noia(4,$vertices);
$vertexcnt++;
$thislump= substr($thislump,4);
}
print "$fn: Copied VERTicES ($vertexcnt).\n";
} elsif ($thisname eq 'SECTORS') {
#$orglump= $thislump;
($thissize % 26) && die $thissize;
for ($j=0; $j<$thissize; $j+=26) {
$sectors.= &transco(&i($thislump,0,2,'v'),0,'z');
$sectors.= &transco(&i($thislump,2,2,'v'),0,'z');
$sectors.= substr($thislump,4,20);
$sectors.= &transtrigger(&i($thislump,24,2,'v'));
#¶noia(26,$sectors);
$sectorcnt++;
$thislump= substr($thislump,26);
}
#$sectors eq $orglump || die;
# print "$fn: Copied SECTORS ($sectorcnt).\n";
} elsif ($thisname =~ m/^(SEGS|SSECTORS|NODES|REJECT|BLOCKMAP)$/) {
print "$fn: Discarding engine data ($thisname).\n";
# $englump{$thisname}= $thislump;
} else {
print "$fn: WARNING: Ignoring unknown lump $thisname, $thissize bytes.\n";
}
}
}

sub transco {
# in-times-a in-times-b usecoord
$_[0] -= 65536 if $_[0] >= 32768;
$_[1] -= 65536 if $_[1] >= 32768;
$newco= $_[0]*$tp{'a',$_[2]} + $_[1]*$tp{'b',$_[2]} + $tp{'c',$_[2]};
# printf "%s: trans (%f,%f) =$_[2]=> %f\n", $fn, $_[0],$_[1], $newco;
pack('v',$newco);
}

sub paranoia {
($xx=substr($thislump,0,$_[0])) eq
($yy=substr($_[1],$j)) ||
die unpack("h*",$xx)." --\n".unpack("h*",$yy)." $_[0]";
}

sub transtrigger {
# value => string
$thistrigger= $_[0];
if ($thistrigger != 0) {
if ($thistrigger < $maxtrigchange) {
# printf "changed trigger %d by %d\n", $thistrigger, $triggeroff;
$thistrigger += $triggeroff;
}
if ($thistrigger < $maxtrigchange &&
$thistrigger > $maxtrigused) { $maxtrigused = $thistrigger; }
}
pack('v',$thistrigger);
}

sub trans {
# value, offset => string
if (($_[0] & 0xffff) != 0xffff) { $_[0] += $_[1]; }
pack('v',$_[0]);
}

sub i {
# string, offset, length, unpack => value
return unpack($_[3],substr($_[0],$_[1],$_[2]));
}

------------------------------

From: "quester@topnet.nl" <quester@topnet.nl>
Date: Wed, 26 Jul 1995 16:23:25 +0200 (MET DST)
Subject: Question :

haya,
First I haven't got any mail from this list since 3 days orso.
Second : In my wad I am trying to build a Dome, but when I use to many
circles doom crashes. here is what I do :

/-----------\ My problem lies with the amount of circles close,
|/---------\| to eachother. What can I do about this.
||/-------\||
||| ||| <--- Circles with ascending Heights.
||\-------/||
|\---------/|
\-----------/
Thanx Quester.

/----------------------------------------------------------------\
| quester@topnet.nl | UUD - Member |
| Amon Endt | Irc #UUD |
| The Hague, Holland | WWW Home Page : http://bart.nl/~shadow |
\----------------------------------------------------------------/



------------------------------

From: S.Benner@lancaster.ac.uk (Steve Benner)
Date: Wed, 26 Jul 95 16:38:59 +0100
Subject: Re: Question :

At 4:23 pm 26/7/95, quester@topnet.nl wrote:
>haya,
>First I haven't got any mail from this list since 3 days orso.

Report faults such as this to owner-doom-editing@nvg.unit.no, not to the
list: there is nothing anyone on the list can do except send lots of "well
I got loads"
type messages which the original sender may never receive....

>Second : In my wad I am trying to build a Dome, but when I use to many
>circles doom crashes. here is what I do :
>
>/-----------\ My problem lies with the amount of circles close,
>|/---------\| to eachother. What can I do about this.
>||/-------\||
>||| ||| <--- Circles with ascending Heights.
>||\-------/||
>|\---------/|
>\-----------/


Your problem is probably caused by your "circles" being made up of too many
segments: this will quickly lead to a visplane overflow. Either reduce the
number of nested circles, or make your circles less circular!

- -Steve



------------------------------

From: sheaslip@ix.netcom.com (Stephen Heaslip)
Date: Wed, 26 Jul 1995 08:45:55 -0700
Subject: Non-Reappearing Altdeath Items

Twice while play-testing my latest map over the modoom with two different
buddies, one on a Mac, the other a PC, we found that some of the items
weren't respawning. Different items failed to reappear each time, once some
armor bonuses, the second time the double barreled shotgun. There are no
funky tricks about the level design, and I do not believe that I've stessed
any upper limit on items (I've made/seen levels with far more items--besides
they were there at the start of the game, the just didn't respawn).

In a related note, these games seemed a little "hitchy," and I was bounced
from one with a consistancy error (yes, we were using the exact same wad).
If this is just a telecom problem related to a bad connection, etc., I
apologize for wasting everyone's time.

But... I've never heard of, or experienced this before, and am concerned
it's design related.

Thanks

sheaslip@ix.netcom.com

This Sig is Netscape enhanced!
(Blink, blink, blink...)


------------------------------

From: "quester@topnet.nl" <quester@topnet.nl>
Date: Wed, 26 Jul 1995 17:49:50 +0200 (MET DST)
Subject: Re: Question :

/----------------------------------------------------------------\
| quester@topnet.nl | UUD - Member |
| Amon Endt | Irc #UUD |
| The Hague, Holland | WWW Home Page : http://bart.nl/~shadow |
\----------------------------------------------------------------/

On Wed, 26 Jul 1995, Steve Benner wrote:

> At 4:23 pm 26/7/95, quester@topnet.nl wrote:
> >haya,
> >First I haven't got any mail from this list since 3 days orso.
>
> Report faults such as this to owner-doom-editing@nvg.unit.no, not to the
> list: there is nothing anyone on the list can do except send lots of "well
> I got loads"
type messages which the original sender may never receive....
>
> >Second : In my wad I am trying to build a Dome, but when I use to many
> >circles doom crashes. here is what I do :
> >
> >/-----------\ My problem lies with the amount of circles close,
> >|/---------\| to eachother. What can I do about this.
> >||/-------\||
> >||| ||| <--- Circles with ascending Heights.
> >||\-------/||
> >|\---------/|
> >\-----------/
>
>
> Your problem is probably caused by your "circles" being made up of too many
> segments: this will quickly lead to a visplane overflow. Either reduce the
> number of nested circles, or make your circles less circular!
Well that could solve the question, but my was gets screwed up, after I
save it NOT after I use the Nodebuilder, al the sectors are screwed etc.
That was why I found this strange.

>
> -Steve
>
>
>

------------------------------

From: S.Benner@lancaster.ac.uk (Steve Benner)
Date: Wed, 26 Jul 95 17:47:08 +0100
Subject: Re: Question :

At 5:49 pm 26/7/95, quester@topnet.nl wrote:
>
>On Wed, 26 Jul 1995, Steve Benner wrote:
>
>>
>> Your problem is probably caused by your "circles" being made up of too many
>> segments: this will quickly lead to a visplane overflow. Either reduce the
>> number of nested circles, or make your circles less circular!
>Well that could solve the question, but my was gets screwed up, after I
>save it NOT after I use the Nodebuilder, al the sectors are screwed etc.
>That was why I found this strange.
>

If your editor is screwing up, I'd suggest you changed editors. Try
another: see if the problem goes away. If it does and you prefer your "old"
editor, mail the author and report the bug....

- -Steve



------------------------------

From: Denis.Moeller@kiel.netsurf.de (Denis)
Date: Wed, 26 Jul 95 16:52 GMT
Subject: Re: Strange sector fall-ins...

Hi!

>>Node-Builders (including id's), moving, deleting & re-creating the
>>whole area -> Nothing changed, argh! Then I moved a few THINGS in
>>that sector and in all connected to it. All is fine now. Hey, I'm
>>building levels for a f*** long time now and the level doesn't
>>contain any specials or strange things - it's just a level.
>I have run across that problem before, The only thing that I found to
>possible create it was a sector about 16 grid away that was equal to the
>height that I fell. I moved the adjacent sector over about 16 more and it
>fixed the problem, but I have seen this problem before, without any
>sectors?! I think its some kind of BSP fluke.
My thought. But now that thing appears again; there is a floor that
should move up due to a switch. Now I can't fix this fall-in-problem.
Everytime it's fixed (by splitting some sectors or moving some things)
the shitty floor WON'T move up. I can't believe it. If the floor is
working the fall-in is back. Argh!

Does anyone got any ideas?

>>[] Just play our Doom (2) Add-Ons: Sudtic, Teutic, Obtic. Thanks. []
>Ontic was great! Where can I get Sudtic and Teutic?
ftp.cdrom.com, in the Doom-level dir.

cya
Denis
[] Denis Moeller, author of NWT v1.3 and TiC's WAD Reviews. []
[] Just play our Doom (2) Add-Ons: Sudtic, Teutic, Obtic. Thanks. []


------------------------------

End of doom-editing-digest V1 #360
**********************************

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT