 =====================================================================================

 			Creating 3D structures in maps for Risen3D.

 =====================================================================================

 Last revision - March 2018

 Changes have been made to definitions over previous release.

 Please see demo wad to clarify descriptions.  If in doubt then study the demo wad.

 Current test map - R3Ddemo184_06.wad.

 NOTE - this map also contains examples of fake sector teleporting.
	For an explanation see the FakeSectorsTeleport.txt in R3D_Docs

 =====================================================================================
 INTRODUCTION
 =====================================================================================

 Doom - and its progeny up to and including Hexen - are 2D games.
 When a map is viewed from overhead it can be seen that there is no concept of
 passing over or beneath another structure. The 3D 'feel' is conferred by enabling
 floors to be set at different heights, by blocking player movement when the step up
 height exceeds a certain value and through the use of rising and falling floors to
 allow the player to move between different heights.

 The 2D games concept pertained until the release by id software of Quake which used
 a new 3D engine.  During this period an updated version of DOOM was independently
 developed when id Software released the code for DOOM. Known as MBF (Marine's Best
 Friend) it introduced techniques that allowed map authors to simulate 3D structures.
 Notably silent teleporting, so that a player was unaware of being moved between
 different areas of the same map, and additional variations on creating 'invisible'
 floors that can be raised or lowered.  This allows for more convincing pseudo 3D
 environments to be created, although still a 2D game.

 The original DOOM engine itself had scope for extending the perception of 3D
 structures as evidenced by some of the maps (e.g. 13, 22) that are contained in
 Requiem.wad, which is a stock DOOM2 wad that can be run with DOOM95.

 Risen3D now supports a new method of creating true 3D structures described herein.
 This is not an attempt to turn DOOM into a 3D engine but rather to allow the
 addition of selected true 3D functionality to enable the authoring of constructs
 such as bridges more easily and more effectively.


 =====================================================================================
 GENERAL
 =====================================================================================

 Structures built with a new line type, described herein, allow maps rendered by
 Risen3D to have 'proper' 3D structures that do not require hidden platforms with
 trigger lines, support lines or any of the other embedded trickery normally re-
 quired with DOOM/BOOM/MBF maps, or concepts like 'bridge' Things required by Hexen.

 Creating true 3D structures has been made as simple as possible.  All the necessary
 information to build 3D structures, using a Doom editor, is confined to editing
 linedefs.  No further special conditions such as control Things are necessary.

 These line types are totally backward compatible meaning that Risen3D will run
 DOOM/MBF maps unaffected.  It also means that they can be put into existing DOOM/
 MBF maps to enhance or replace existing structures.

 The current test map demonstrates some of the possibilities.  Note that this
 requires the commercial doom2.wad to run.

 If authoring maps then use an editor to see how things have been done.  This demo
 wad may be updated from time to time to demonstrate other functionality supported
 by Risen3D.


 =====================================================================================
 DEMO WAD
 =====================================================================================

 The Risen3D R3Ddemo184_06.wad which can be found in Risen3D\R3DGames\R3DTEST\gwads
 after installing R3D demonstrates many aspects of what can be done using 3D lines.

 This wad has been designed to show the use of simple 3D structures (at the start)
 progressing to more complex structures.  Cacodemons and other enemies have been
 included to show how both floating and non-floating actors (shootable Things)
 interact with 3D structures, both fixed and moving.

 In particular the map contains two particularly complex structures - the dome and
 the lift. These should be seen as demonstrating the extent of the concept but are
 more complex than may be thought on first viewing these structures with an editor
 as they use lines stacked on lines.

 Of more use are structures like bridges which are simple to create and can be
 easily inserted in a map.  The bridge at the start, for example, can be walked over
 or swum under even if imps are crossing simultaneously above. This is clearly
 impossible to implement with standard Doom lines. In addition no hidden structures
 are required or trigger lines.

 The fact that it is in a faked sector also needs no special consideration.  The
 fake sector definition can be deleted without affecting the bridge.  You would now
 be walking rather than swimming under it.  These types of bridges often crop up in
 DOOM TC's and MBF maps and are normally both tediously complex to author and,
 of course, are 2D.  As such if the player is walking over such a bridge nothing
 can pass under it such as other actors (monsters or missiles).  Since, however,
 bridges constructed using 3D lines are 3D then it is possible for actors to be
 passing both over and under such constructs simultaneously.

 Another useful addition are ladder lines. A single line can be used to climb to
 whatever height is required. Normally to fake a ladder several sectors are needed
 for each step up and these have to be designed not to render. All this complexity
 can now be replaced with a single line. Ladder lines can also be jumped up onto
 using forward with a timed jump. This means they can be walked under - again im-
 possible until now in a doom map. This allows the player to escape whilst enemies
 can only pass beneath.

 Other features of 3D lines are also demonstrated such as auto texture scaling, the
 prevention of enemies walking off them (with none of the attendant strolling into
 space that plagues Doom), stacking, infill, true 3D fence lines, switches that can
 only be activated if the player can contact them (allowing them to be stacked),
 walkover trigger lines that are height sensitive and so on.

 For those going round R3Ddemo184_06.wad with -nomonsters then no exit will
 be found this is because killing the cyberdemon causes an exit. See also the
 SETTING FLATS section. 


 =====================================================================================
 3DLINE THING
 =====================================================================================

 A single THING type number 15501 must be present in the map else the 3D definitions
 will be ignored.
 

 =====================================================================================
 CREATING 3D LINES
 =====================================================================================

 3D lines are defined by having two definitions incorporated.  One uses the top
 texture entry for side 1 (Entry 1) the other the top texture entry for side 2
 (Entry 2).  The entries have been hijacked for this purpose - so they no longer
 define a texture but instead are used to define the properties of a 3D line.
 Textures will be defined using the mid and bottom texture entries subject to
 the rules described further on.

 The definition on side 1 must consist of 7 characters and the definition on
 side 2 of 8 characters.  Definitions must always be prefixed with the $ char
 which counts as one character.

 Other special entries define additional functionality but all lines must have
 two basic definitions added. These are defined as follows;

 Entry 1;

 Entry 1 takes the form $Xxxxxx where X is a letter in the range A to F used to
 identify the definition type and xxxxx is a decimal number.

 The letters define the following line types;
 A - Standard 3D line.
 B - Is used if the frontside of the line should limit enemy onground movement.
 C - Defines the line as a boundary for floor/ceiling flats;
	i)  a ceiling flat at the height of the bottom of the lower texture.
	ii) a floor flat at the bottom textures top height.
 D - Used for scaling
 E - Used for ladder lines
 F - currently unused

 The decimal number xxxxx is used to define the height of the 3D line from the
 floor height of the lines backsector (in map units).  This is always a positive
 number - structures must be designed to take this into account.

 Entry 2;

 Entry 2 takes the form $xxxCyyy where C is the letter A, B, C, D, or E and xxx
 is a decimal number and yyy is a decimal number.

 xxx is a 3 digit decimal number representing the height of the bottom texture
 to be rendered.

 yyy is a 3 digit decimal number representing the height of the mid texture
 to be rendered.

 xxx and yyy are used for texture scaling or for support depths.  If no scaling
 is required then they are set to 0.  A support depth value only has to be set 
 where the line has no textures as normally the texture depth (or scaled depth)
 is used.  Lines with no textures act purely as support lines, they are not
 rendered.

 The letters define the following rendering behaviour;
 A - Map   : bottom tex to depth of xxx - map   : mid tex to depth of yyy.
 B - Scale : bottom tex to depth of xxx - map   : mid tex to depth of yyy.
 C - Map   : bottom tex to depth of xxx - scale : mid tex to depth of yyy.
 D - Scale : bottom tex to depth of xxx - scale : mid tex to depth of yyy.
 E - Ladder line (See creating ladders further on).
 F is currently unused

 Where textures are mapped then the standard unpegged flags apply.
 Where textures are scaled the texture will be made to fit the depth specified.

 BLOCKING: Lines normally block everything between the bottom and top of a texture
           except where masked textures are used on both sides of a line. These
           types allow bullets to pass.

           If you want a line which only has masked bottom textures to also block
           bullets then give the line a midtex height of 1. This height will be
           cleared at load time as it is used purely to indicate that the line
           should block bullets. All other textureless midheight values will be
           treated normally. (v220-31 on).

           In the case of B lines where a midtex height with no texture is set
           (where movement other than the player's is blocked) then it will
           remain blocked at the height set. Hence using 1 above as this value
           has no merit for blocking movement.

           If a line has both bottom and mid alpha textures then it will always
           allow bullets to pass. A line with just a masked midtex both sides,
           however, will always block bullets.

 NOTE;  Any errors will cause the line to be treated as a standard line.

	All xxx numbers should always positive. In the case of an offset then a 3D
        structure will always be higher than any 3D lines backsector floor height.
        If this is not the case then a map design error has been made.


 =====================================================================================
 SCALING TEXTURES
 =====================================================================================

 As determined above it is possible to scale textures to fit a line.  Any scaling is
 calculated using the front texture.  If a back texture is used that does not have
 the same height as the front texture but the line type has been set to scale the
 front texture then the same scaling values will be applied to the back texture.
 If not aware then this could cause confusion for the map author in wondering why
 a back texture is not fitting as expected.

 Textures are only ever scaled down.  Values which would have meant scaling up
 result, instead, in textures being vertically tiled.


 =====================================================================================
 BASIC EXAMPLES.
 =====================================================================================

 EXAMPLE 1.

 To set up a fence in sector 1 (let's say) then create a line in sector 1 with
 sector 1 in its front and backsector.  Place the texture MIDBARS1 in the
 bottom texture of side 1 and the bottom texture of side 2.  Since this is a
 standard 3D line type and since we want it on the ground then put;

 $A00000	in the top texture of side 1.

 This means create a standard line with an offset of zero from (in this case)
 sector 1's floor height.

 The simplest default for the top texture in side two is $000A000.  In this case
 let us make the fence low enough to be jumpable (assuming jumping has been set
 in the Risen3D game options) but high enough to block.

 To do this we will make the fence 36 high.  Also let us scale the whole texture
 to fit as this will look better.  Since we are scaling a bottom texture we
 will need to set the type to B or D.  Since no mid text is being used we will
 use B but D would also work. The first number (xxx) sets the bottom texture's
 height.  So, for this example, put;

 $036B000 in the top texture definition of side 2.

 You can make the line for the fence as long or as short as you like.  Run the
 map and you should now have a fence that you can jump over.

 Note: when xxx and/or yyy are set to zero then it is ignored and the standard
 texture height (xxx for the bottom tex yyy for the mid tex) will apply.

 The number of characters in the defining entries must always be as indicated.
 7 for entry 1 and 8 for entry 2.  They must have '$' as the first character.

 So why is this a 3D line?  Currently you can only jump over it, but only be-
 cause it's on the ground.  If we now give it an offset greater then the
 player's height we should be able to walk under it.  Change the toptex
 value to $A00064.  This will set the line 64 above the ground.  Now when
 the map is run you will be able to walk under it. OK - so why is this a
 3D line?  When in the map fire a rocket at the line.  You'll be able to
 fire rockets above and below but they will explode if aimed at the line.
 This means the line's open at both the top and the bottom although the
 line itself is a blocking line.  This cannot be done in DOOM.  Elevated
 lines have to be non-blocking if you want to pass under them so a rocket
 would also pass through the texture.  When used to form a bridge then,
 in Doom, hidden platforms are needed to give the illusion of support as
 same sector sided mid-tex lines where crossing and stacked in order to give
 the illusion that one bridge is crossing above another (see Requiem map13
 for example) cannot also be used to confer player height information.

 EXAMPLE 2.

 Let us now create a step using four lines.  Select, say, the texture STEP1 and
 place this in the bottom texture both sides of each line.  The four lines can
 form a rectangle.  Make the distance from the front to the back of the step 32
 or less so that we will stay on it (i.e. not fall between the lines).

 The four lines should all have their front sectors facing out.  This is a
 fundamental rule for 3D structures.  There are plenty of examples of step
 lines in the demo wad.  For this structure the STEP1 texture is sixteen high
 so entry 2 can be the default $000A000 as 16 is the step height we want.  Use
 $A00000 for entry 1 so the step is on the ground.

 To form the next step then just copy the lines and change entry 1 to, say,
 $A00016.  This will set the second step 16 units above the floor height.


 =====================================================================================
 KEEPING ENEMIES ON THE STEPS.
 =====================================================================================

 In DOOM enemies have a habit of wandering off a ledge to the full extent of their
 diameter before changing direction back onto the ledge.  This gives the impression
 of their being suspended in space.  Whereas this might just about be acceptable
 in DOOM, when they are on 3D structures it looks ridiculous.  To solve this
 problem you can set a line type entry 1 to B which will tell Risen3D to only allow
 an enemy to wander to the point where it's diameter touches the line before moving
 away from or along it).  Examples of the use of this type are in the demo wad e.g.
 the two beams spanning the length of the walkway using steps with flats or the
 lines forming the the sides of the steps over the tank.


 =====================================================================================
 SETTING FLATS
 =====================================================================================

 Two methods are employed for setting flats.

 For either case case tag the sector to a second sector.  In the second sector set
 the flat types required.  Note that the floor flat will be used for the top of
 the step and the ceiling flat for the underside of the step.

 If you wanted to use the tag for another purpose (sector heights for example)
 then tag the second sector to a third sector.  Use the third sector for the
 purpose intended.  The second sector must always be the one used to set the
 flats.

 NOTE:	the floor and ceiling heights for the flats sector (the tagged sector)
	have no use as the heights are taken from the line definitions and
	relate to the sector the linedef is in.  As such these values are used
	instead for setting light levels in certain cases.

 In both cases the underside of the step is taken as the height of the structure and
 is used to render the ceiling flat.  (Remember - the ceiling flat is the lower of
 the two flats and is always under the floor flat).

 In the first (default) case the floor flat will be from the top of the structure
 i.e. bottom tex height + mid tex height.

 In the second case the floor flat is rendered at the height of the bottom tex
 i.e. the offset (in the side 1 hitex def).

 This allows spanning flats between 3D lines keeping the mid tex visible.  (An
 example is in the demo wad and is used to construct the dome).

 To create flats use linetype C.  I.e. $Cxxxxx in entry 1.

 When setting flats above flats then each stacked structure using a tagged sector
 for the flats must have its own sector and own tagged sector even when the flats
 are the same.  Where there is no overlap then a tagged sector can be shared.

 In general lines bounding a flat must create a closed space.  The backsector
 is the sector that must be tagged to another sector (usually created outside
 the visible map) that defines the flats.

 Flats also support Things so no support lines are necessary for movement on a
 flat.  A support line is only necessary to set the starting height of a Thing.

 LIGHTING FLATS (Status under review)

 The tagged sector's floor and ceiling heights are used to set the lighting
 levels for each flat.  The floor height value will set the floor flat's
 lighting level and the ceiling height the ceiling flat.  The values should
 be between 0 (darkest) and 255 (lightest).

 Note that the sector light level in the tagged sector is currently unused.

 If the lines used to bound the sector tagged to the sector for the flats have
 zero depth, thus causing the floor and ceiling flats to have the same height,
 and the lighting levels (floor and ceiling height values) are set to 0 then
 the flats will not be rendered.  This allows the creation of transparent
 supporting planes.

 SCALING FLATS

 Method 1

 A flat can be scaled by using the light level of the sector owning the line
 with the special 270. The acceptable range is 1 to 8. This means the scale
 will be from 1 to 1/8. If the light level is outside this range then a def-
 ault of 1 is imposed. The line with the special must be single sided.

 Method 2  (v220-33 on)

 If the line with the special 270 is two sided then the x and y offsets on
 both the line's sides are used for both scaling and offset purposes. Note
 that the flat textures have to be in the sector referenced by line side 1.
 It is somewhat wasteful to make the second side a different sector although
 this won't affect any outcomes. All that will be used are the  x and y off-
 sets and the rest of a different sector's properties are unused. These may
 be pressed into service at some later date.

 a) scaling

 In the latest R3Ddemo184_06.wad (in the R3DTEST folder which will have
 been updated when installing v220-33) an example is shown for the floor/
 ceiling flats used in S103 which is tagged to L4392. In this case the texture
 is scaled in the y axis to fit exactly 3 times across the width of the sector
 and is scaled slightly differently in the x-axis to get the best fit.
 
 We start by looking at the sector's height which, in the case of S103, is 64.
 Next we take the texture's height which is 72. Thus to fit exactly we need to
 scale the texture by 64/72. Since, in this case, we need to reduce it further
 so as to fit exactly three times then the value needed will be 64/72 x 1/3
 = 0.2963 to four decimal places. In order to be able to pass a decimal value
 then the rule is to multiply any value needed by 10,000. In this case it
 gives the value needed as 2963. Thus the y value is set to this. The x-value
 has been slightly altered to get the bars in the texture to align to each end. 

 b) offset

 The next objective is to offset it to fit to the map. This is done by using
 side 1's offsets. In this case we can see from the map grid that the texture
 needs to be shifted up by 14 map units in order to align to the 64 grid. As
 such the y offset is set to -14.

 The x offset has been set to 1 to get best alignment. This and the scaling
 value being reduced to 2920 has to be done pretty much by trial and error.

 A second example using MIDSLDR has also been added with S152.


 NOTE: Risen3D will happily accept a texture as a flat but DeeP is reluctant
 in allowing this to be done. Once entered it will happily show it even if not
 in the patches list. For example if XWE is used to create texture and patch
 entries and the texture is added as a patch then DeeP is happy. Following
 getting DeeP to accept it the textures and patches lists can then, using XWE,
 be deleted without it now affecting DeeP.


 =====================================================================================
 CREATING 3D STRUCTURES WITH THEIR OWN FLATS
 =====================================================================================

 The two platforms accessed by the lift have different flats textures.  To ensure
 compliant subsectors are created the vertexes for the lines in each platform must
 correspond exactly in the x,y plane.  It is still possible it will work where there
 is no precise alignment but you may get small triangular areas where no flat is
 rendered caused by the creation, by the nodes builder, of surrogate subsectors with
 linedefs from which the 3D owner cannot be ascertained.


 To get the required flats then tag the sector to a sector outside the map and
 set the line special of one of the lines in the second sector to 270. The second
 sector's flats will then be used with the 3D floor sector.

 In general then all 3D stacked sectors should have the same floor, ceiling flats
 and light level as the sector they are in else rendering problems can occur.

 Flats can now also be more accurately scaled (v220-33 on) see scaling in the
 section above.


 =====================================================================================
 SETTING DIFFERENT LIGHT LEVELS ABOVE AND BELOW A SINGLE FLAT PAIR
 =====================================================================================

 In the test wad sector 98 has a (dimmer) lower light level.  This is achieved
 using a special line type having a midtex definition that sets the light level
 for the upper and lower textures on the line.  All of these must be on line
 side 1.

 The midtex takes the form $AxxxAyyy where xxx is the light value required for
 the lower tex and yyy for the upper in the range 0 to 255.

 In the demo wad these lines are 4505 to 4509 inclusive.  The vertexes have not
 been merged which allows them to be dragged away revealing the flat def lines
 on which they have been exactly superimposed.  This is only for demonstration
 purpose as they work equally the same if the vertexes are merged.  The flat
 def lines point in the opposite direction as these lines must have the flats
 defined on side 2.  The essential point is that a flat line def and a lit
 line def must be exactly superimposed and point in opposite directions.

 This means the sector on side 1 of the lit line will be the same as that on
 side 2 of the flat line and vice versa.

 Although sounding complex in practice it is easy to achieve (with a suitable
 editor) as having created the flat defs sector then the lines with the upper
 lower lit textures can just be copied, flipped, defined and then superimposed.

 The upper and lower textures can be different (as in the demo).  Their heights
 are calculated relative to the high and low flat floors and for this reason
 they will only work with a flats sector having one pair of flats.

 On loading, these line types are tested to ensure their subsector has a single
 flat pair.  If this test fails then the program will terminate with any such
 lines being printed to R3Ddebug.out as an aid in correcting the problem.

 Note that the floor light will be taken from the actual sectors light level
 and the flat floor lighting from the reference sector that defines the flat
 textures to use.  The light levels are set in the heights remember.


 =====================================================================================
 GENERAL DEFINITION
 =====================================================================================

	  _______ Middle tex height = Top of low text + height of mid tex
	|
	|
	|
	|
	| Mid texture = side (1 or 2) middle tex (or none)
	|
	|
	|
	| _______ Top of low tex = height of lower tex
	.
	.  Lower texture = side (1 or 2) lower tex (or none)
	.
	. _______ Lower tex bottom = backsector floor height + height in entry 1


 1)	The mid tex always adjoins the bottom tex.

 2)	Textures can be defined as having heights even when not present.
	This allows for the omission of textures that will never be seen where
	occluded by flats but where the heights are needed to calculate the flats
	position.  It also allows invisible blocking lines to be created.

	NOTE: if creating a textureless blocking line to impede a THING but
              you want to allow missiles to pass then set the line's
              SECRET flag to ON.

 3)	Using lines with heights defined but no textures are useful for
	creating blocking lines (to guide a player onto a ladder for example)
	or for providing support lines to position a THING's starting height.
	NOTE: lines have two purposes - one is to calculate the players height
	and must be spaced apart by no more than 32 units (unless you want the
	player to fall through but not a larger actor like the Cyberdemon).
	Where flats are applied then the flat acts as a support meaning lines
	can be more widely spaced.
	The second is to provide the necessary information for rendering.

 4)	If scaling is being used then the heights will be the scaled heights. 


 =====================================================================================
 USING A 3D LINE TO CREATE A LADDER
 =====================================================================================

 To make a ladder, use a line with it's MIDtexture set both sides to the texture
 required for the ladder.  The same texture must be set both sides.  Note that
 where a masked texture is used, which will invariably be the case for a ladder,
 then Risen3D will automatically tile the texture vertically.  Do not set the
 lower unpegged flag as this will cause rendering problems.  Set the other values
 as required but ensuring that entry 2's letter is E.  The ladder will only be
 active on the frontside.  No height collision detection is carried out on
 adjacent lines and it is left to the map author to ensure that ladders do not
 allow players to pass through adjacent structures on their way up and down.

 Note that the same sector must be used both sides.  Examples of ladders are
 contained in the demo wad.  To position the texture the X and Y offsets can
 be used in the normal way.

 Since E is used in entry 2 no scaling is possible.  This would not normally be
 required for ladder textures hence using this as the definition.  Bottom
 textures can be set but they will not form part of the ladder.  The main
 reason for using the midtexture is to allow ladders to be placed on 3D structures
 where the height of the offset, defined using the lower tex value, is used to
 calculate the correct positioning of shared flats. (See the higher ladder on
 the cliff formation near the start point in the demo wad).

 Another use is where you want the ladder to start off the ground.  Doing this
 makes it possible to have a ladder that can be walked under but also able to be
 jumped on to (if not too high) still allowing it to be climbed.  An example is
 the lower cliff ladder in the demo wad.  Normally the bottom texture will
 block movement when it has height even where no texture is defined.  The
 single exception is for ladders allowing them to be offset (using the bottom
 texture height).  Doing this still allows Things to pass beneath them (if they
 are not too high).

 In general ladders can be jumped on to or jumped off of.  Since getting on a
 ladder to climb down it is near impossible then, where this is required, the
 best method is to use a platform from where the player can jump onto the ladder.
 An example is included in the demo wad.  For this example textureless lines have
 been added at each side of the ladder to act as blocking lines to prevent the
 player from getting on the side of the ladder (else would pass up through the
 step lines forming the platforms).  These lines also act to guide the player
 onto the middle part of the ladder.

 Movement on ladders is determined by direction (forward back) and mouse look,
 if used.  The rules are as follows;

 ACTION			DIRECTION

 Forward		Climb
 Forward looking up	Climb
 Forward looking down	Descend

 Backward		Descend
 Backward looking up	Descend
 Backward looking down	Climb

 Jump facing ladder	Stay on ladder or jump onto ladder 
 Jump facing away	Jump off ladder if forward key is pressed

 Backward at base	Move backwards away from ladder if facing ladder
 Forward at base	Move forwards away from ladder if facing away.

 NOTE:	The jump action is not magnified when on a ladder.  The amount of forward
	motion is limited.  This prevents unrealistic mega jumps when jumping off
	a ladder when at some height above the ground.  This would be caused by
	the need to have forward momentum (as pressing the forward key) but
	this is suppressed when the player is on the ladder.


 =====================================================================================
 CREATING 3D ELEVATORS
 =====================================================================================

 In the demo map there is a tower with a central lift.  This is a 'true' 3D lift as
 you can walk under it.  To get 3D lines to move they must be linked with a standard
 elevator structure.

 The lift uses line specials 230 and 234. Those supported are 227 to 234 (but not
 235 to 238).  The rule for actor movements are a) Any actor (including the player)
 will be crushed if caught between the ceiling and the top of the lift platform on
 a rising lift or the floor and the bottom of the lift platform on a falling lift.

 In the demo map the actual lift sector is placed outside the map.  Linked directly
 to this are lines in the main 3D lift sector.  The main lift sector, therefore,
 will contain these non 3D lines which are outside the map. Lines in the main lift
 sector can be used to connect other sectors on their back sector - but all lines
 in the main lift sector must have the sector number in their lines' frontsector.
 All these lines must be 3D line types.

 If more than 5 linked sectors are used Risen3D will exit with an edit error.
 If any of the main lift sectors lines do not have the front sector in the line's
 frontsector Risen3D will exit with an edit error.

 Note that the test map has not had vertexes merged - this is to make it possible
 to deconstruct the lift for both examination and editing purposes.  Once
 vertexes have been merged then editing becomes impossible.

 Things on lifts cannot drop off them when the height from lift to floor is >
 24 mapunits irrespective of whether the lift is moving or not. This behaviour
 differs from static 3D lines where a $B type is used to block walking off. In
 the R3Ddemo184_06 map the Baron (T176) can drop off onto the lift - it is only
 stepping off that is inhibited.

 NOTE: Unfortunately the vertexes in R3Ddemo184_06.wad were accidentally merged
       making it difficult to see how the lift was constructed. For this reason
       with v31 a new wad was added, LIFTS_DEMO.wad, which shows other lift
       ideas this time with the vertexes unmerged. 

 The editor used to construct the test map was DeePsea from SBsoftware.  This has
 got some additional support for editing 3D line types in Risen3D.


 =====================================================================================
 SWITCHES ACTIVATING LIFTS
 =====================================================================================

 In DOOM/BOOM where vertically aligned switches are required then one, single, tall
 texture is rendered to ensure that the switch texture changes when activated.  To
 get round this limitation, where using a 3D line type for a switch, if vertically
 stacked and where the line's vertices are identical (x, y) then all the stacked
 switch textures will be changed when activating a switch.  An example is in the
 demo wad for the switches used for the lift on the ground and on each of the
 two platforms.


 =====================================================================================
 USING 3D LINES FOR THING SUPPORT
 =====================================================================================

 Step lines must be no further apart than a Things radius if required to stay on them.
 Use 32 as a maximum separation if all Things are to stay on them.  You could create
 steps where a Cyberdemon would stay on them but other Things will fall through for
 example.

 To position Things on structures then ensure its crosshairs are on the required
 line.  An example is included in the demo wad where a rocket box is positioned at a
 higher level than a rocket launcher.  The granularity for checking is 0.5 map unit
 so precise placement is essential. There are several examples in the main demo wad.

 An example is also included for Things on angled lines (the armour bonuses in
 the dome).  Here extreme care must be used to ensure Things exactly intersect
 the line.  In this case the lines are angled at 45 degrees which ensures they
 pass through grid intersections.  Using single lines can be employed but be
 wary of creating maps where too many spurious subsectors are formed by the
 nodes builder as this can cause flats problems.  Often a problem where a flat
 is missing or is at the wrong height can be cured just by moving the vertex
 at one end of a line by a small amount.

 In general if a Thing could be at one of several heights where positioned within
 stacked sectors (e.g. the floors connected by the lift) or stacked lines (e.g.
 steps over steps) then it must be on a line that is ether existing or provided
 so that the required height can be deduced.

 -------- TELEPORT z HEIGHT

 It is possible to confer a z-offset to a THING being teleported to an
 MT_TELEPORTMAN THING.  To do this put the MT_TELEPORTMAN THING on a 2's
 line with the same sector each side (which must be the same sector as
 the MT_TELEPORTMAN THING is in).  Clear all textures then in the top
 texture of side 1 put $Axxxxx where xxxxx is the height you wish the
 teleported thing to be spawned above the sector's floor height. xxxxx
 is a decimal number and must always be 5 long so to spawn 32 above the
 floor height use $A00064.

 Place $000A000 in side 2's top texture.

 NOTE: the MT_TELEPORTMAN THING's x and y must be exactly on the line
       else the line will have no effect.


 =====================================================================================
 TRANSLUCENCY
 =====================================================================================

 The normal type 260 to set the translucency of a mid tex applies as before.  In
 addition a new type 277 has been provided allowing the bottom tex to be made
 translucent.  To make both a bottom and mid tex translucent use 278.


 =====================================================================================
 NEGATIVE TAGGED EFFECTS
 =====================================================================================

 Two effects have currently been implemented that are defined by having a negative
 line tag and with a value passed in the line special.

 If Thing type 15501 is not present then the line tags and specials will be treated
 as normal to allow for compatibility with other maps.  If it is present then
 the line tags and specials will be searched for prior to any other decoding,
 they will then be processed and finally reset to zero so as not to affect the
 normal engine functionality.

# Currently two effects are supported defined using negative line tags;
#
#	============================
#	TAG -1 = ROTATING STRUCTURES
#	============================
#
# Support removed in v220-13 in favour of using model rotation


	==============================
	TAG -2 = SCROLLING TRANSLUCENT
	==============================

 Lines tagged -2 will be rendered translucent and will have the line special set
 after loading to 255.  Prior to this the value in line special is used to determine
 the height of the line so this is what should be set when editing the map.

 The texture x and y offsets work the same as with special 255 (scroll speed).

 (See the waterfalls in the demo wad).

 =====================================================================================
 MERGING VERTICES
 =====================================================================================

 Vertices can be merged where all the lines sharing the vertex have the same sectors
 on their front and back.  If this is not the case then rendering can fail.  The
 best course of action is to disable ALL auto vertex merging when editing 3D
 structures. Where certain vertices can be merged or linedefs should be split then
 do this manually.

 Merging multiple vertexes can help speed up map rendering slightly but where more
 than two are merged can make the map uneditable.

 =====================================================================================
 EDITING/RENDERING ISSUES
 =====================================================================================

 In the demo wad there are two identical staircase structures rising to three levels
 where one has been caged. The lines are all in the same sector so are piled on
 top of each other.  The easiest way to edit such structures is to select lines
 and then drag them away.  The second staircase has been put in its own sector to
 make editing easier.

 If small triangular flats errors start to appear then forcing the creation of
 subsectors by adding nodes can effect a cure.

 =====================================================================================
 SPECIAL EXCEPTION (v220-10)
 =====================================================================================

 Textureless 3D lines can be used as hidden blocking or support lines. In the case
 of such a line being in a moving floor sector then these lines are ignored if
 the Thing is a pipebomb or a grenade. An example can be found in DoomDragon
 sectors 705 and 708 where a rising chaingun is deployed. If firing a pipebomb
 into these sectors before they are triggered then they will fall to the floor
 of the sector uninhibited by the 3D lines. The 3D lines are there to support
 any other type of Thing being able to walk over the sector without falling
 to its floor.

 =====================================================================================
 EDITING TRICKS
 =====================================================================================

 The single most troublesome area is in successfully building nodes.

 You may occasionally find problems with missing flats.  In order to help the nodes
 builder successfully create the necessary subsectors then adding a line (see ex-
 ample in area with lift where there's a chain gun) or creating an additional node
 on a line usually fixes the problem.  This has to be experimented with as there are
 no hard and fast rules.  Despite the complexity of some of the structures in the
 test wad there are only three cases where a line or a node had had to be added.

 NOTE: Nodes are built automatically by Risen3D in a manner that leaves the original
       wad untouched. The only point to bear in mind is that when running in edit
       mode no pruning is done to ensure that line or sector numbers are unchanged
       from the original wad whereas running normally means pruning is carried out.
       This can mean that there is a difference between running in one mode when
       compared to the other.

 =====================================================================================
 COMPATIBILITY
 =====================================================================================

 The method used allows for backward compatibility with DOOM/MBF and BOOM maps.
 
 3D line types are counted at load time and the number found, if not 0, is printed
 out to the console.

 =====================================================================================
 IMPORTANT
 =====================================================================================

 If wishing to be able to drag lines off lines make sure your editor has
 auto merge vertexes disabled.

 Setting vertices is critically important.  Any non aligned stacked vertices
 will not only cause rendering problems but can also lead to an invalid node
 build which, if run, may cause Risen3D to crash.

 Don't forget to put a THING type 15501 in the map!

 When developing maps do not use a savegame even if the nodes are unchanged.
 The way textures are saved could mean changes will not be seen between an
 older savegame and any texture changes made in the map.


 NOTE:	The demo map was designed using DeePSea from www.sbsoftware.com.
	All 3D structures have been authored by myself (so I take all blame for
	map errors!).


GMJ March 2018
