Floor Texture Alignment



Aligning textures can be a frustrating experience especially on floors with moving textures such as conveyor belts or water and slime canals. Although it is easy to control the direction that the player will move to when standing in the moving sector (angle of the SectorEffector sprite) , the floor textures will sometimes move in a different direction. Of course, the recommended directive in such a case is to change the Firstwall of the sector and make it relatively aligned by using the "R" key in 3D mode. Unfortunately, this alone does not always cure the problem and the designer will often have to use the "F" key, go back and forth between Build and Duke3D to make sure that everything looks the way it should. This is a painstaking process, particularly if you have a long chain of conveyers or a sinewy river constructed from a large number of sectors. This is also the case if you have rotated a bunch of sectors after adjusting their floor textures; the sprites are automatically rotated but not the textures and you have to start over. This tutorial is aimed at easing the process and aligning these textures with 100% predictability and to eliminate the "back-and-forth" hassle.


First, start off by making a simple rectangular sector, insert two vertices on the top wall and draw another sector on the inside of the first one. Place a SectorEffector sprite inside the inner sector and give it a Lotag of 24 to create a conveyer belt as shown in the picture on the right. Change the angle of the sprite with the < or > key to make it point downwards. Go to 3D mode and raise the sector floor by a few clicks and change the floor texture to tile #1156. It might not be aligned properly but leave it for now. Change the texture of the top middle wall to a different texture to make it easily identifiable.

Save your map and start the game with it. You will notice that when Duke steps on the conveyer, he is moving in the right direction but the belt may be moving in a direction either opposite or perpidicular to the desired direction. The reason for this is that the movement or any object placed on the conveyer belt depends only on the angle of the SectorEffector sprite present in that sector. The orientation and direction of the floor textures is an entirely different thing. In order to fully understand their behavior, three basic notions have to be reviewed. Firstwall , Relative Alignment and Texture Flipping .


Firstwall




Wall 34
X-coordinate : 3328 Flags (hex) : 0 nextsector : -1
Y-coordinate : -13568 Shade : 0 nextwall : -1
Point2 : 35 Pal : 0 Extra : -1
Sector : 4 (X,Y) repeat : 12, 8 Wall length : 96
Tags : 0, 0 (X,Y) pan : 15, 36 Pixel height : 76
( 0x0 ), ( 0x0 ) Tile number : 355
Overtile number : 0


Sector 4 Ceilings : Floors :
Firstwall : 34 Flags (hex) : 24 Flags (hex) : 40
Numberofwalls : 1 (X,Y) pan : 15, 36 (X,Y) pan : 0, 0
Firstsprite : 1 Shade byte : 7 Shade byte : 7
Tags : 0, 0 Z-coordinate : -7168 Z-coordinate : 12288
( 0x0 ), ( 0x0 ) Tile number : 355 Tile number : 1156
Extra : -1 Ceiling heinum : 4096 Floor heinum : -4096
Visibility : 32 Palookup number : 0 Palookup number : 0
Pixel height : 76





Relative Alignment




Texture Flipping




Floor hex flags


The Floor Hex Flags is a 16 bit register in which the first 7 bits (Bit 0 - Bit 6) are used by Build to convey information on the floor of a given sector. The remaining bits are reserved and not documented in the Build Docs. As the name implies, its value is in hexadecimal form and is displayed in the second row of the third column in the sector attributes screen. By reading the value of this flag, it is possible to determine the status of floor parameters like parallaxing, slope and smooshiness as well as relative alignment and direction of floor displacement without having to start the game.

Don't worry if you don't understand binary or hexadecimal, tables with the hexadecimal flag values and their corresponding texture orientation and displacement are provided below. Use these tables as a reference when you want to coordinate the floor textures and their direction of displacement in your maps. Of course, these flag values are valid provided that your floor is neither sloped, parallaxed or smooshed. If you want to apply these features to the same floors, I suggest that you do it last. Alternately, if you are familiar with binary and hex, you can use the binary table at the end of this tutorial to figure out the hex codes that will result from a combination of all the features you wish to implement. This might be useful in the event that you are reworking a existing map and have rotated many sectors


Table 1
Direction of floor displacement with corresponding hex flags when using Relative Alignment
Floor Hex Flag = 40 Floor Hex Flag = 64 Floor Hex Flag = 70 Floor Hex Flag = 54
Floor Hex Flag = 50 Floor Hex Flag = 74 Floor Hex Flag = 60 Floor Hex Flag = 44


Table 2
Direction of floor displacement with corresponding hex flags without Relative Alignment
Floor Hex Flag = 0 Floor Hex Flag = 24 Floor Hex Flag = 30 Floor Hex Flag = 14
Floor Hex Flag = 10 Floor Hex Flag = 34 Floor Hex Flag = 20 Floor Hex Flag = 4




Floor Hex Flags register bit assignment
BIT No. B15 - B7 B6 B5 B4 B3 B2 B1 B0
FUNCTION Reserved Relative
Alignment
Y-Flip X-Flip Smoosh
Tile
Swap
X & Y
Sloped
Floor
Parallaxing
MODE N/A 1 = ON
0 = OFF
1 = ON
0 = OFF
1 = ON
0 = OFF
1 = ON
0 = OFF
1 = ON
0 = OFF
1 = ON
0 = OFF
1 = ON
0 = OFF
BUILD
COMMAND
N/A R F E F [ , ] , / P



BINARY HEX
B6 B5 B4 B3 B2 B1 B0
1 0 0 0 0 0 0 40
1 1 0 0 1 0 0 64
1 1 1 0 0 0 0 70
1 0 1 0 1 0 0 54
1 0 1 0 0 0 0 50
1 1 1 0 1 0 0 74
1 1 0 0 0 0 0 60
1 0 0 0 1 0 0 44
BINARY HEX
B6 B5 B4 B3 B2 B1 B0
0 0 0 0 0 0 0 0
0 1 0 0 1 0 0 24
0 1 1 0 0 0 0 30
0 0 1 0 1 0 0 14
0 0 1 0 0 0 0 10
0 1 1 0 1 0 0 34
0 1 0 0 0 0 0 20
0 0 0 0 1 0 0 4
With Relative Alignment Without Relative Alignment



Page written by :


Download this page locally




Duke Nukem 3D is copyright ©1996 , All Rights reserved.

THIS PAGE IS NOT MADE BY OR SUPPORTED BY 3D REALMS

Copyright ©1997 Jean-Francois Groleau, All Rights reserved.
Go back to my Duke FAQ BUILD page
Go back to my Duke FAQ BUILD page Text-Only