You can wrap your objects with any pictures you like. Using Texture mapping will save the complexity to express the objects and its surface.

Node classes Used for Texture Mapping

The image file that you use for the texture should be .rgb format.

sample of .rgb image:

There are 7 node classes:

  • SoTexture2
  • SoTextureCoordinate2
  • SoTextureCoordinateBinding
  • SoTextureCoordinatePlane
  • SoTexture2Transform
  • SoTextureCoortinateEnvironment
  • SoTextureCoordinateDefault
  • Wrapping objects

    If you use textures, you need only the SoTexture2 node.

    SoTexture2

    SoTexture2 node has these fields:
  • filename (SoSFName)
  • image (SoSFImage)
  • wrapS (SoSFEnum) wrap texture in the horizontal
  • wrapT (SoSFEnum) wrap texture in the vertical
  • model (SoSFEnum)
  • blendColor (SoSFColor)
  • SoTexture2, especially filename field is the basis of texture mapping.

    Using the filename field: the Default Texture Mapping

    wrap a cone with sample texture
    Display: sample.iv

    Source: sample.c++

    Using image field: make the texture by pixel (not an image file). Set the filename field empty. See How to use SoSFImage wrap a cone grey (intensity) pixel
    Display: sample5.iv

    Source: sample5.c++

    wrap a cone rgb + Alpha (transparency) pixel
    Display: sample5_d.iv

    Source: sample5_d.c++

    Using wrapS and wrapT fields: the possible values are REPEAT (default) and CLAMP (repeat the last pixel).See The difference between REPEAT and CLAMP

    Using model field: the possible values are MODULATE (default), DECAL (change the model's shaded color to the texture color), and BLEND (blend the shaded color and blend a color).

    Using blendColor field: when BLEND texture model will be used, it specifies the color to blend.

    Coordinate a texture

    These nodes coordinate texture map by texture-coordinate functions

    SoTextureCoordinate2 , SoTextureCoordinateBinding

    SoTextureCoordinate2 node has a field
  • point (SoMFVec2f)
  • SoTextureCoordinateBinding node has a field
  • value (SoSFEnum)
  • SoTextureCoordinate2 node coordinates the texture on the shape made by vertex. In many cases, it causes some warps of the texture. SoTextureCoordinateBinding node defines that the current texture coordinates will be bound to the shape nodes.

    Using point and value fields: If the binding coordinate is default, value is needless.

    coordinate sample texture on the 3 vertices
    Display: sample7_dd.iv

    Source: sample7_dd.c++

    SoTextureCoordinatePlane

    SoTextureCoordinatePlane node has two fields:
  • directionS (SoSFVec3f) horizontal
  • directionT (SoSFVec3f) vertical
  • SoTextureCoordinatePlane node changes the repeat frequency (interval) wrap a cone with sample texture given double repeat frequency to y direction
    Display: sample6.iv

    Source: sample6.c++

    Transforming a Texture Map

    SoTexture2Transform node transforms the texture by 4 ways

    SoTexture2Transform

    There are 4 fields of the SoTexture2Transform node:
  • translation (SoSFVec2f)
  • rotation (SoSFFloat)
  • scaleFactor (SoSFVec2f)
  • center (SoSFVec2f)
  • SoTexture2Transform transforms the texture not how to wrap the object with the texture.

    Using translation field: translate a texture in 2 vector (float).

    wrap a cone with sample texture translated 0.5 to y direction
    Display: sample3.iv

    Source: sample3.c++

    Using rotation field: rotate a texture in radians.
    wrap a cone with sample texture rotated pi/2
    Display: sample2.iv

    Source: sample2.c++

    Using scaleFactor field: scaling the texture in 2 vector (float). wrap a cone with sample texture scaled 0.5 on y direction
    Display: sample4.iv

    Source: sample4.c++

    Using center field: change the center of the rotation in 2 vector (float).

    Advanced coordinate methods of texture mapping

    There are two nodes for the advanced texture mapping.

    SoTextureCoordinateEnvironment

    SoTextureCoordinateEnvironment node reflects the environment on the objects like a mirror. You need to create spherical reflection map (refer to "OpenGL Programming Guide").

    SoTextureCoordinateDefault

    SoTextureCoordinateDefault node cancels the last texture coordinate function and make default texture coordinates.
    s1021058@u-aizu.ac.jp