POV-Ray Object Collection
Roadsigns Macro


Overview
Adding New Signs

Files in this Distribution
Redistribution
Macro Reference
Variable Reference


Overview

The Roadsigns macros were created by Chris Bartlett in March 2008 for the POV-Ray Object Collection at http://lib.povray.org/ (search for 'Roadsigns') and are licensed under the terms of the CC-LGPL. The download consists of an include file containing prism objects representing the symbols used on road signs in the UK and an include file containing a set of macros that can combine these symbols with road sign shapes.

To add a road sign to your scene file you include the "roadsigns.inc" file and call the 'Roadsigns_Panel' macro.

light_source { <-15,7.5,-15>, rgb 2}
camera {location -y look_at 0}
#include "roadsigns.inc"
Roadsigns_Panel("Warning", "WildHorses")
object {Roadsigns_Panel("Regulatory", "NoCarsOrBikes") translate 0.6*y}

Various examples are provided in the file 'roadsigns.pov'. Dimensions are specified in metres. The ScaleConvert macro from the POV-Ray Object Collection can be used to convert between different units of measure.

The following pre-defined symbols are provided. Note. Although the symbols in the table below are categorised by the 'type' of sign they normally appear on, you can use any symbol with any sign type. Just specify the sign type ("Warning", "Regulatory", "Compulsory", "Hazard" etc.) as the first parameter to the 'Roadsigns_Panel' macro and the symbol name ("HumpBridge", "Fire" etc.) as the second parameter:

"Warning" symbols (Triangular warning signs)

"Aircraft"

"AccompaniedHorses"

"BendToLeft"

"BendToRight"

"Cattle"

"Crossroads"

"CycleRoute"

"DoubleBendLeft"

"DoubleBendRight"

"DualCarriagewayEnds"

"FallingRocks"

"FrailPedestrians"

"HumpBridge"

"Humps"

"JunctionOnBend"

"LevelCrossingWithBarrier"

"LevelCrossingWithoutBarrier"

"MenAtWork"

"OpeningBridge"

"OverheadElectricCable"

"Pedestrians"

"Quayside"

"RiskOfGrounding"

"RiskOfIce"

"RoadNarrowsBothSides"

"RoadNarrowsOnLeft"

"RoadNarrowsOnRight"

"Roundabout"

"SchoolCrossing"

"Sidewinds"

"SlipperyRoad"

"SoftVerges"

"StaggeredJunction"

"SteepHillDownwards"

"SteepHillUpwards"

"TJunctionWithPriority"

"TrafficMergingFromLeft"

"TrafficQueues"

"TrafficSignals"

"TramcarCrossing"

"TunnelAhead"

"TwoWayTraffic"

"TwoWayTrafficCrossing"

"UnevenRoad"

"WildAnimals"

"WildHorses"

"ZebraCrossing"
"Regulatory" symbols (Signs giving orders)

"HeightLimit"

"MaxTruckLength"

"MaxTruckWeight"

"NoBuses"

"NoCarsOrBikes"

"NoCycling"

"NoExplosives"

"NoLeftTurn"

"NoOvertaking"

"NoRightTurn"

"NoTowedCaravans"

"NoUTurns"

"NoVehicles"

"PriorityToOncomingVehicles"

"WidthLimit"
"Compulsory" symbols (Signs giving orders)

"AheadOnly"

"BusesAndCyclesOnly"

"CyclesOnly"

"KeepLeft"

"KeepRight"

"MiniRoundabout"

"PassEitherSide"

"SegregatedPedestrian"

"TramsOnly"

"TurnLeft"

"TurnLeftAhead"

"TurnRight"

"TurnRightAhead"
Where no symbol is found the symbol 'name' is displayed. e.g.

"Regulatory","20"

"Regulatory","60"

"Compulsory","30"

"Warning","!"

"Warning","?"
"Hazard" symbols
Note. These symbols are contained in the "roadsigns_hazardsymbols.inc" include file. To use this file add the following line:
#declare Roadsigns_SymbolFile = "roadsigns_hazardsymbols.inc";
to your scene file before calling the 'Roadsigns_Panel' macro

"ScullAndCrossBones"

"Cross"

"Explosion"

"Fire"

"Oxidation"

"Corrosion"

"Biohazard"
Oddments
A number of UK roadsigns are relatively unique and have been added as special variants. You can of course still use these special types of roadsigns with any of the other symbols and you can use these symbols with other types of sign.
Roadsigns_Panel("Octagonal", "STOP")
#declare Roadsigns_SymbolBackground = <0,164,078>/255;
Roadsigns_Panel("Compulsory", "GO")
Usually used as a temporary, manually operated roadsign at roadworks.
#declare Roadsigns_SymbolBackground = <0,117,189>/255;
Roadsigns_Panel("Regulatory", "NoWaiting")
#declare Roadsigns_SymbolBackground = <0,117,189>/255;
Roadsigns_Panel("Regulatory", "Clearway")
Roadsigns_Panel("Plain_White_Circle", "NationalSpeedLimit")
#declare Roadsigns_SymbolBackground = 0.8*<222, 52, 57>/255; Roadsigns_Panel("Compulsory", "NoEntry")
#declare Roadsigns_SymbolBackground = <1,227/255,0>;
Roadsigns_Panel("Regulatory", "SchoolCrossingPatrol")
#declare Roadsigns_SymbolText = "30";
Roadsigns_Panel("Compulsory", "EndMinimumSpeed")
Roadsigns_Panel("InvertedWarning", "")
Used for advanced warning of a 'STOP' or 'Give Way' sign
Roadsigns_Panel("InvertedWarning", "GiveWay")
#declare Roadsigns_FaceWidth = 0.36;
object {Roadsigns_Panel("RoundedRectangle", "AheadOnly")}
By using the "Ahead Only" symbol on a rounded rectangular sign you can generate a "One Way Traffic" sign.
object {Roadsigns_Panel("RoundedRectangle", "Parking")}
The plain parking sign is one of the few rectangular signs that can be generated without setting variables because it can use the default square settings.
#declare Roadsigns_FaceWidth = 0.43;
#declare Roadsigns_SymbolText = "1 mile";
object {Roadsigns_Panel("RoundedRectangle", "Parking")}
You can add your own text to the parking sign, but you'll probably need to adjust 'Roadsigns_FaceWidth' accordingly. If 'Roadsigns_SymbolText' is defined the macro scales the 'P' to make space below it for the text.
#declare Roadsigns_SymbolBackground = 0.8*<222, 52, 57>/255;
#declare Roadsigns_FaceWidth = 0.8;
#declare Roadsigns_TextArray = array [3]{"REDUCE","SPEED","NOW"};
object {Roadsigns_Panel("RoundedRectangle", "TextArray")}
The "TextArray" symbol uses text from the 'Roadsigns_TextArray' array to display multiple lines of text on whatever style of sign you choose.
#declare Roadsigns_FaceHeight = 0.30;
#declare Roadsigns_TextArray = array [2]{"GIVE WAY","50 yds"};
object {Roadsigns_Panel("SupplementaryInformation", "TextArray")}
The "SupplementaryInformation" sign accompanies other signs. This example would typically be displayed below a blank "InvertedWarning" sign to indicate the distance to a Give Way line ahead.
#declare Roadsigns_FaceHeight = 0.30;
#declare Roadsigns_FaceWidth = 0.68;
#declare Roadsigns_TextArray = array [2]{"No footway","for 400 yds"};
object {Roadsigns_Panel("SupplementaryInformation", "TextArray")}

Return to Table of Contents


Adding New Signs

The easiest way to add a new sign design is to add a prism object to the 'roadsigns_uksymbols.inc' file then update the 'Roadsigns_UKSymbolTexture' macro in the file 'roadsigns.inc', adding a clause to handle your new symbol. For example, to add a symbol called 'Hedgehog' you should call your prism object 'Roadsigns_Hedgehog' and add the following lines to the 'Roadsigns_UKSymbolTexture' macro:

#case (strcmp(SymbolName,"Hedgehog"))
  #local Roadsigns_SymbolOffset = <-0.1 ,-0.55,0>; // Hedgehog
  #local Roadsigns_ThisSymbolTexture = texture {
    Roadsigns_PrismToTexture(Roadsigns_Hedgehog,<1,1,1,1>,Roadsigns_SymbolColor)
  }
#break
A 'case' clause is added into the 'select' statement within the 'Roadsigns_UKSymbolTexture' macro. This macro consists almost entirely of different case statements for each of the different symbols. This example implements a 'case' clause to handle the symbol named "Hedgehog".

The piece of code that adds the symbol to the sign initialy centres it within the sign. If the symbol is asymmetrical it may then need to be moved left or right (e.g. -0.1 in 'x'). It may also need moving up or down to get it looking right for the shape of the sign you wish to use it with (e.g. -0.55 in 'y'). The unit of measure used for the offset is the width of the border around the edge of the sign, i.e. 1 unit = 1 border width.

The parameters to the 'Roadsigns_PrismToTexture' macro are explained below. The variable 'Roadsigns_SymbolColor' defaults to the standard symbol color for the sign being used (e.g. black for "Warning" signs, white for "Compulsory" signs.). The background color is usually completely transparent.

Having done that (so long as you get the scaling of the prism in the include file and the offset defined in this macro right) you should be able to add a Hedgehog warning sign to your scene file:

#include "roadsigns.inc"
Roadsigns_Panel("Warning", "Hedgehog")

Alternatively, if you want to keep your own symbols separate or if you wish to build a file containing a distinct set of symbols that can be incorporated back into this collection, you can create a separate file and specify the file name using the 'Roadsigns_SymbolFile' variable before calling the 'Roadsigns_Panel' macro.

#declare Roadsigns_SymbolFile = "roadsigns_hedgehogsymbols.inc";
Roadsigns_Panel("Warning", "Hedgehog")

Note. If you get the file name wrong, or if the file is not located within the POV-Ray include path, the default file will be used. If the symbol is not found the symbol name will be displayed as text on the panel, so if your symbol name appeara on the sign instead of the graphical symbol you should check the file name and path.

Tips

Within the 'Roadsigns_UKSymbolTexture' macro in the 'roadsigns.inc' file you'll find some examples of building up more complex objects, for example objects using multiple symbols and text and using multiple coloured objects, such as in the "TrafficSignals" symbol.

You'll notice that the symbol name (e.g. 'Hedgehog') is different from the name of the object used to create the symbol (e.g. 'Roadsigns_Hedgehog'). In fact you can have multiple symbol names that use the same object definition. For example, you may wish to change the offset to align your hedgehog for a different style of sign or you may want to change the colour of the symbol for display on a different coloured background. Also you can use multiple symbol objects to build a single road sign. For example, the "NoExplosives" symbol uses two separate prism objects, one for the car and one for the explosion erupting out of the roof.

To change the colour of the symbol displayed (default <0,0,0>=Black) simply adjust the second parameter on the 'Roadsigns_PrismToTexture' macro call.

Return to Table of Contents


Files

You should have received the following files with this distribution. The latest versions are available from http://lib.povray.org.

Main Files

roadsigns.inc The main include file for the Roadsigns object containing the 'Roadsigns_Panel' macro.
roadsigns.pov A sample scene file illustrating the use of the Roadsigns macro to generate the signs shown in the image at the top of this page.
roadsigns.html This document.
roadsigns_documentimages.pov A scene file that generated most of the images used in this document. Images can be generated one at a time or by using the animation settings that are documented in comments at the top of that scene file.
roadsigns_uksymbols.inc The default symbol file containing prism objects to represent a selection of UK road sign symbols.
roadsigns_hazardsymbols.inc A symbol file containing prism objects to represent a selection of hazard sign symbols. To use symbols from this file, set the 'Roadsigns_SymbolFile' variable to "roadsigns_hazardsymbols.inc" before calling the 'Roadsigns_Panel' macro.

Return to Table of Contents


Redistribution

The Roadsigns macros are licensed under the terms of the CC-LGPL which permits (and encourages) reuse and redistribution. You can therefore incorporate these macros along with scene files that use them into a set of files that you distribute to others.

Most of the files included with the Roadsigns macros are sample images and documentation files. If you don't wish to distribute all of these files you only need to include a copy of the file 'roadsigns.inc' and an include file containing the symbols you want to use e.g. the 'roadsigns_uksymbols.inc' file or a cut-down version of it.

If you plan to submit your object to the POV-Ray Object Collection at http://lib.povray.org/ you will need to rename the files to conform to the naming standards (All files from your submission will need the same unique prefix). Remember to update the renamed 'roadsigns.inc' file to point to the renamed symbols file.

Return to Table of Contents


Macro Reference

The macros contained in the 'roadsigns.inc' file are listed below. It is unlikely that you will need to use most of these macros, but they are described for completeness.

Roadsigns_Panel macro
The Roadsigns_Panel macro may well be the only macro you ever need to call. It defines a panel whose shape is determined based on the first parameter and adds the symbol named in the second parameter (or text if it doesn't find a symbol of that name).
Style indicates the type of panel to generate ("Warning" or "Regulatory")
Symbol provides the name of the symbol to use on the panel, or some text/digits to display on it.
Roadsigns_PrismToTexture macro
This utility macro takes an object that is passed to it and returns a pigment
It also centres the object at the origin and turns it through -90 degrees around the x axis.
It requires 3 parameters:
SymbolObject a POV-Ray object suitable for use as a pigment (one with a well defined inside and outside)
ExteriorColour a colour value for everything outside the object
InteriorColour a colour value for everything inside the object
Roadsigns_UKSymbolTexture macro
This macro tries to find the specified symbol in the uk symbols file and returns a texture using the symbol as an object pattern. If it's not in the list it simply returns it as a piece of text converted to a texture. This macro requires one parameter:
It also centres the object at the origin and turns it through -90 degrees around the x axis.

SymbolName The name of the symbol to display. Otherwise text to display e.g. "50"

Roadsigns_DefaultSettings macro
This macro assigns default values to any key control variables that are not yet set.
Roadsigns_Undef macro
This macro resets key control variables so that they can revert to default values.

Return to Table of Contents


Variable Reference

VariableDescription
Roadsigns_SymbolFile The file containing the definition of the symbols to be used to make the sign. This defaults to "roadsigns_uksymbols.inc" but can be set to "roadsigns_hazardsymbols.inc" for the Hazards symbols shown above or to a file of your own making.
Roadsigns_Thickness The thickness of the material used to make the sign.
Roadsigns_Diameter The diameter of a circular sign (e.g. a "Regulatory" sign).
Roadsigns_FaceHeight The height of a non-circular sign (e.g. a "Warning" sign).
Roadsigns_FaceWidth The width of a rectangular sign, such as the "RoundedRectangle" and "SupplementaryInformation" signs. The width of most other shapes is determined automatically to maintain the correct proportions of the sign.
Roadsigns_CornerRadius The corner radius of a rectangular sign, such as the "RoundedRectangle" and "SupplementaryInformation" signs or a triangular sign such as the "Warning" sign. This is normally defined automatically, but you can set it in your scene file.
Roadsigns_SymbolText Certain road signs contain text within the symbols. Where this text is configurable you can set this variable to the required text. For example, the maximum lorry length for the "MaxTruckLength" symbol can be set using:
#declare Roadsigns_SymbolText = "Max 12m";
before calling the 'Roadsigns_Panel' macro.

This variable can be used with the "SteepHillDownwards" symbol and the "SteepHillDownwards" symbol to specify the gradient you wish to be displayed. It can be used with the "EndMinimumSpeed" to specify the speed and optionally with the "Parking" sign to indicate the distance to the parking area.

Roadsigns_TextArray This array is intended to be used with the "TextArray" symbol which retrieves the elements of text and builds a symbol that consists of those lines of text, centrally justified and scaled to fit within the height of the sign. This is most frequently used with rectangular signs, such as the "RoundedRectangle" and "SupplementaryInformation" signs. For example:
#declare Roadsigns_TextArray = array [2]{"GIVE WAY","50 yds"};
object {Roadsigns_Panel("SupplementaryInformation", "TextArray")}
can be used to generate a panel to go beneath an empty inverted red bordered triangle to give advanced warning of the distance to a Give Way line.
Roadsigns_SymbolColor The color of the main part of the symbol is usually determined by the type of sign, so "Compulsory" signs use white symbols and "Regulatory" signs use black symbols. If you need to override this setting you can specify the color of your choice using this variable before calling the 'Roadsigns_Panel' macro.
Roadsigns_Normal You can add a surface normal definition to the texture used for the front surface of the sign by setting this value.
Roadsigns_Finish You can add a surface finish definition to the texture used for the front surface of the sign by setting this value.
Roadsigns_DirtTexture You can add a layer of texture on top of the other textures that are used to make up the road sign. Although this can be used for a variety of purposes, the main intention is to enable a layer of dirt to be added to obscure the surface. This is a full texture definition and can include a pigment, a normal and a finish. Note. The pigment has to be partially transparent or it will totally obscure the surface of the road sign. The default setting is completely transparent.
Roadsigns_SignalRed A colour vector defining the colour 'Signal Red' as used on UK road signs. You can change this setting in your scene file to substitute an alternative colour.
Roadsigns_MiddleBlue A colour vector defining the colour 'Middle Blue' as used on UK road signs. You can change this setting in your scene file to substitute an alternative colour.
Roadsigns_Green A colour vector defining the colour 'Green' as used on UK road signs (Mainly the 'GO' sign). You can change this setting in your scene file to substitute an alternative colour.
Roadsigns_Orange A colour vector defining the orange colour used for the hazard signs. You can change this setting in your scene file to substitute an alternative colour.
Roadsigns_White A colour vector defining the white parts of a sign. You can change this setting in your scene file to substitute an alternative colour.
Roadsigns_GreyBack A colour vector defining the grey parts of a sign. You can change this setting in your scene file to substitute an alternative colour.
Roadsigns_BorderWidth The width of the border around the edge of the "Warning" and "Regulatory" signs. This width is normally defined automatically, but you can set it in your scene file, although a number of dimensions are calculated based upon this value, such as the amount by which symbols are offset from their geometrical centre to 'centre' them on the road sign.
Roadsigns_Delta When constructing the road sign object, certain dimensions need to be adjusted by a small amount to avoid coincident surfaces. This variable controls that amount and is usually set to 0.0000001. This should not normally need to be changed.

Return to Table of Contents