Textures
With texture mapping a 2D image is mapped on the 3D surface of a model. A 2D image in JPG or PNG format is loaded into the system and linked to a node that contains a mesh of an object. Texture mapping is often applied to visualize materials like concrete, brick, or wood. Texture mapping can also be used to create signs, signals, and illustrations. In this example, we show how you can use texture mapping to dynamically change overhead road signs.
Solids
First, the images of the traffic signs speed_60.png
and speed_clear.png
are uploaded into the system. The texture is loaded by including a texture
block from the materials section and the name of the texture is entered. The texture block has two parameters that define how often the texture is repeated in both directions. This is commonly applied for repetitive textures, such as tiles or wood. The texture is applied to a flat block with a height and width of 2
. Next, the texture is cleared and another block with black color is positioned just behind.
A truss is created by combining a pattern of three cylinders and 6 joints in a triangular shape. This shape is then repeated a number of times in Z-direction. The length of the truss is defined by a parameter length
.
The overhead portal with three signs and a road is created. The repeat block contains a comma-separated array of variable names that are used to set the name of the object in the GLTF file. The name of the object is be composed of the name of the variable and the name of the part, for example, a_Sign
.
Topics
We create a topic to link the geometry of the rack to the GLTF file, and a subtopic for each unit in the rack that has a link to the name of the node in the GLTF file.
road.portal.geometry = Portal.gltf
road.portal.sign_01.node = a_Sign
road.portal.sign_01.texture = speed_60.png
road.portal.sign_02.node = b_Sign
road.portal.sign_02.texture = speed_60.png
road.portal.sign_03.node = c_Sign
road.portal.sign_03.texture = speed_60.png
Model
A model is created by including the main topic road.portal
, which loads all the subtopics for the signs as well. To change the sign, you can click on one of the signs in the 3D model, and then change the texture to speed_clear.png
.
Explanation
When the GLTF of the portal is rendered, the database of topics is searched for a subtopic .node
with a value equal to the name of the node. If found, the database is searched for a subtopic .texture
. If found, the texture image is loaded from the database and applied to the material of the mesh in the node.