Depth map surface
From H3D.org
The DepthMapSurface is an H3DSurfaceNode that uses a 2D texture to determine the depth of the surface. It is best to use an 8-bit grayscale image as the texture, where black will correspond to the maximum depth, white the minimum and other grayscale values will be interpolated between the two.
Here we will look at two example uses of the DepthMapSurface
DepthMapSurface on a Sphere
<!!-- depthMappedSphere.x3d --> <Group> <Shape> <Appearance> <Material /> <ImageTexture url="depthmap.png" DEF="IMT" repeatS="false" repeatT="false"/> ... ... ... </Appearance> <Sphere radius="0.1" /> </Shape> </Group>
The code excerpt above cretes a Sphere with an ImageTexture. On its own this code is complete and would create the graphical presentation of the sphere.
<!!-- depthMappedSphere.x3d --> ... ... <DepthMapSurface stiffness="0.3" maxDepth="0.007" staticFriction="0.4" dynamicFriction="0.2" whiteIsOut="true" > <ImageTexture containerField="depthMap" url="depthmap_gray.png" repeatS="false" repeatT="false"/> </DepthMapSurface> ... ...
When the DepthMapSurface is added it not only makes haptics possible on the Sphere, but also creates a surface for the Sphere that has depth corresponding to the color of its depth map. Like FrictionalSurface, its stiffness, staticFriction and dynamicFriction set the surface stiffness and frictional properties. The maxDepth field indicates that the maximum difference between black (RGB(0, 0, 0)) and white (RGB(1, 1, 1)) is 0.007 metres. When whiteIsOut is true, white becomes the "higher" surface while black "sinks" into the surface. If it is false then it is the other way round.
The ImageTexture node provides the image that the DepthMapSurface uses. Its containerField is set to depthMap to indicate that it belongs to the depthMap field of its parent node, the DepthMapSurface.
DepthMapSurface on an IndexedFaceSet
<!!-- depthMappedITS.x3d --> <Group> <Shape> <Appearance> <Material /> <ImageTexture url="depthmapSG.png" DEF="IMT" repeatS="false" repeatT="false"/> <DepthMapSurface stiffness="0.3" maxDepth="0.003" staticFriction="0.4" dynamicFriction="0.2" whiteIsOut="true" > <ImageTexture containerField="depthMap" url="depthmapSG_gray.png" repeatS="false" repeatT="false"/> </DepthMapSurface> </Appearance> <IndexedTriangleSet index="2 1 3 1 0 3" solid="false"> <Coordinate DEF="COORD" point="0.15 0.15 0, 0.15 -0.15 0, -0.15 -0.15 0, -0.15 0.15 0" /> <TextureCoordinate3D point="1.0 1.0 0.0, 1.0 0 0.0, 0 0 1.0, 0 1.0 1.0 "/> </IndexedTriangleSet> </Shape> </Group>
Instead of using Sphere as the geometry as before, this example uses the IndexedTriangleSet.

