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

 			Creating Slopes in maps for Risen3D.

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

 Last revision - 7th January 2018

 Latest demo map - SlopesTest.wad

 =====================================================================================
	OVERVIEW
 =====================================================================================

 It is now possible to create floors and ceilings using a map editor which will be
 rendered as slopes in Risen3D.  These support movement and blocking in the normal
 way and can have dyn-lights/glow applied.


 Since OGL rendering is intolerant of incorrect z heights, as this could lead to
 either a plane being twisted or the need to generate several small triangular
 walls depending on the method which in any event may lead to HOMs due to mis-
 registration of z heights on shared vertexes between different sloped sectors
 the following method has been designed for use with Risen3D to avoid this problem.
 As such this is currently proprietary to Risen3D and Risen3D does not, therefore,
 support slopes in maps designed for use with other ports.

 Risen3D only supports sloped sectors that are triangles or trapeziums.  This may
 seem somewhat limiting except that any sloped surface can be constructed from
 these primitives.  Conversely it may seem that this could lead to a lot more
 effort being needed to construct slopes.  This is true if each map were to be
 started from scratch.  The idea, however, is for an author to build a library
 of basic types that can then be imported and sized in a map.  Shapes formed from
 triangles can be pulled around with no fear that the any new shape created doing
 this will fail to work.  This can be tested by pulling the crater around in the
 demo map using an editor. It can quickly be reformed into a trench for example.
 Note that the crater's rim is defined by a specified height.  The height can
 only be changed by selecting the rim's lines and manually changing the value.

 Since Risen3D needs to apply glow, dyn-lights etc. to a sloped sector the method
 chosen ensures that this will be applied effectively.  Fire the plasma gun up
 into the dome's roof, for instance, to see this working.  The demo map uses tra-
 peziums where possible for demonstration purposes so be careful if pulling a
 trapeziums vertexes around that it remains a trapezium.  Alternatively use a
 line to split it into two triangles (a new sector will be needed for one of them).


 =====================================================================================
	METHOD
 =====================================================================================

 Slopes are defined using tex definitions similar to those used for 3D lines.
 They are, however, mutually exclusive and, as such, can be used together
 in the same map.  To show this some bridges have been put in the demo map
 that cross the water in the domed ceiling room.  3D structures themselves,
 however, cannot also be sloped.

 RULE: 3D lines and slopes cannot be mixed in the same or overlapping sectors
       but can co-exist in the same map.


 NOTE: A THING type 15503 must be placed in a map to indicate it has slopetypes.
       Only one need be used and can be anywhere in the map including any dead
       space.

       Lines forming sloped sectors can be pointing in any direction but their
       vertexes must be merged.

       Textures used to define slope heights are side sensitive and must be on
       the sloped sectors lineside.

       Unless the lines forming a sloped sector require their triangular side
       walls to be drawn then no textures other than special height specifying
       textures should be placed on the line's sides.  Specifying textures that
       can't be seen when drawn will cause problems with lighting or movement.

       A sloped sector must only have one height definition for the lower slope
       and one for the upper.  Since this/these must be on the sector's lineside
       then a line itself may have up to four definitions if both sectors are
       sloped.

       No 'missing' textures are allowed.  If a line is shown to have a missing
       texture when using an editor then the missing texture must have a texture
       added.  Note that a slope definition texture counts as being a texture.
       This is usually valid as creating a slope means that no visible texture
       is needed (as the slope will have obscured it).  In the event that a
       slope is required that does not extend to the top of the other sector
       on a two-sided line then a texture can be defined by placing it on the
       other side.

       If a side wall texture is required then, if the sector heights on both
       sides of a line are the same, a midtex only will suffice.  If not then
       add a lower or upper texture as needed.  The midtex must still be present.
       See further down for details.

       If a single sector is used to create a sloped wall then its raised or
       lowered end (depending on whether it's a floor or ceiling sloped sector)
       must abut a further sector which will have to be added so that the
       raised end is not left open (i.e. does not have the same sector as the
       other two or three lines the sloped sector is contained by).

                -----------------------------------------
                |       SECTOR 1        |   SECTOR 2    |
                |  sloped raised end -> | normal sector |
                -----------------------------------------
                 

       An example is shown in the SlopesTest.wad S561. This has the raised
       end terminated by S562. The height of S562 must be at least as high
       as the raised end of S561. Where higher then an infill tex can be
       specified by setting a midtex on the sloped lineside's side. If none
       is set then S1's floor's flat (or ceiling flat for sloped ceiling
       sectors) for the infill texture will be used.

       Since all offsets are relative to the sector they are in then slopes
       can be added to lifts etc.

       SlopesTest.wad is provided to show how sloped sectors can be used.


 Two sector types are supported;

	a) A triangular sector composed of three lines.
	b) A trapezoidal sector composed of four lines.


 1) Creating slopes using triangular sectors.

    The triangle can have one vertex lifted or lowered by a defined amount or two
    vertexes lifted or lowered.  The amount defines the slope's top/bottom height
    difference relative to the sectors ceiling/floor height.

    Ceiling sector vertexes will always be lowered by the defined amount and floor
    vertexes raised by the defined amount.  As such values defined are always
    positive.

    The values are entered by using the tex definitions on the line side for the
    sector to be sloped.  These take the form;
	i ) $Axxxxxx where xxxxxx is the decimal value to lift/lower a single vertex
	ii) $Bxxxxxx where xxxxxx is the decimal value to lift/lower two vertexes.

    These definitions must always be eight characters in length.  Leading zeros
    should be used to make up the length.  E.g. to lift a single vertex by 1 then
    $A000001 would be used.

    If a vertex or vertexes are to be raised then the bottom texture name is used.
    If a vertex or vertexes are to be lowered then the top texture name is used.

    To lift a single vertex then place the name on the line opposing the vertex.
    To lift two vertexes then place the name on the line sharing the vertexes.


 2) Creating slopes using trapeziums.

    A trapezium always has two vertexes lifted/lowered.  As such only a $B name
    can be used and should be placed on the lineside sharing the vertexes.

    The line opposing that with the definition must be parallel to the defined
    line.  The other two lines can be at any angle to these lines.  This is the
    definition of a trapezium. A rectangle/square are just special cases where
    all opposing lines are parallel (i.e. all internal angles are 90 degrees).


 3) Specifying triangular walls that should be drawn.

    When raising/lowering vertexes then, where not abutting another slope, tri-
    angular walls will be created.  To indicate that a texture should be drawn on
    these then the middle texture must be defined.  This can be any texture as it
    is only used to indicate that a texture must be drawn - it is not actually
    drawn.  The texture that is required to be drawn must be defined in the bottom
    texture (for floor slopes) and/or the top texture (for ceiling slopes) as
    appropriate.

    Note that if using two different textures then the x, y offsets must be shared
    due to the limitations of the doom engine.  Thus offsetting a top texture on
    a slope's side will offset any bottom texture by the same amount.  Texture
    unpegging flags for bottom textures work in the normal way.  Top textures
    are only pegged if the backsector is a move sector.  In this specific
    instance it can be unpegged by setting the upper unpegged flag.


 4) Specifying textures against two-sided walls

    Where specifying a slope against a two's wall that is less than the wall's
    height then a $B definition prevents defining a texture for the exposed
    part of the wall.  To enable a texture to be defined then Risen3D allows
    this to be specified using the line's other side.  An example is in the
    test map for one of the moving sectors with a sloped top.


 5) Automatic height determination.

    Quite often heights can be automatically determined if an author wants a slope
    to extend to the other sector's height of a $B line.  If this is required then
    just put 0 in the $B def (i.e. $B000000).  Risen3D will then inspect the
    other sector belonging to the $B line to determine the height required.  As
    well as simplifying map design this also has the advantage that the other
    sector's height can be changed without having to edit the slopes defs.

    This is also true for a $A line but ONLY if it abuts a $B triangular sector.
    Since the single vertex could reference several sectors and Risen3D would
    need to know which sector's height should be used it can only determine
    this by looking at the common line shared by both the $A and $B sectors and
    adopting $B's height.  The common line must also have no midtexture set.
    By identifying its pair errors are avoided if several triangular sectors
    abut each other with different slope values.  This is demonstrated in the
    room with a domed ceiling where despite all the values using auto height
    settings Risen3D is able to identify the heights of the $A lines from their
    paired sectors.


 6) Slopes in sectors with faked floors

    A slope can be placed in a sector with a faked floor.  If on a slope and the
    slope is below the faked floor then, if waterdynamics is enabled, the slope will
    offer less resistance to climbing.  To enable glow a separate sector will have
    to be employed for the part of the slope higher than the fake sector's floor.
    Currently where slopes are employed in fake sectors then only the floor slope
    is supported.  This means faked ceiling slopes are not supported.  An example
    of a slope in a sector with a faked floor extending above and below the faked
    floor's height is contained in the demo wad.
    

 7) In General

    Sectors are identified by Risen3D as sloped sectors by virtue of their having
    $A / $B height definition(s).  Error checking is carried out on sectors defined
    as slopes at load time and if any map authoring errors are found loading will be
    terminated and the errors found can be seen in the file R3Ddebug.out.  This file,
    which is generated to aid map design/debugging can be found in the base Risen3D
    directory.

    If a move sloped sector has not been given enough height to accommodate the
    slope's height then the program will exit with a MAP ERROR when the sector
    is activated.  

    If you get the error message saying lines are not parallel (for trapeziums) and
    where this is difficult to fix by moving one of the vertexes in the x,y plane
    then split the trapezium into two triangles and change the tex definitions as
    appropriate.

    Not all errors are trapped and particular care must be taken to define the
    necessary textures correctly and to not have definitions where none should
    exist.

    NOTE: Raising/lowering does not create a back wall.  Thus if none exists
    there will be a HOM as no texture is drawn - ever.  A raised $B line must
    back another sector and must not be higher than that sector's floor height.
    The same consideration should be used for ceiling slopes.

 8) Note that floor glow is not applied to slopes as these are sloped floors.  As
    such there is no functionality to transfer glow from floors to floors.  It is
    not considered worthwhile to change this at the current time.


====================================================================================
 Texture infill between different height slope sectors.       Added in v220-33
====================================================================================

 Where two sloped sectors abut but are of different heights an infill texture
 can now be added using the mid texture of the line between them.

                -------------------------------------------
                |       SECTOR 1         _|   SECTOR 2    |
                |  midtex this side only  |               |
                -------------------------------------------
                 
                         
 If S1 is sloped up to S2 and is higher than the sloped height at the dividing
 line with S2 (or vice versa) then if the line separating S1 and S2 has its
 frontsector facing S2 and midtex is put on the line's frontsector then this will
 fill the gap. Note that the midtex must *always* be put on line side 0 and no
 midtex must be present for any other textures on either side 0 or side 1 else
 the code will fail.

 Examples exist in the SlopesTest.wad e.g. L1237, 1238 and L1274, 1375 amongst
 others. Note that L1240, 1371 (for example) have no midtex as the slopes abut
 at the same height. 
 

 GMJ JAN 2018

