Note:
This section describes concepts that you will need to understand for using texture data with Spatial and Graph. However, the texture metadata is not yet fully implemented in Oracle Spatial and Graph, and a viewer is not yet supported. This section will be updated when texture support is released.
A texture is an image that represents one or more parts of a feature. Textures are commonly used with visualizer applications (viewers) that display objects stored as spatial geometries. For example, a viewer might display an office building (three-dimensional solid) using textures, to allow a more realistic visualization than using just colors. Textures can be used with two-dimensional and three-dimensional geometries.
In the simplest case, a rectangular geometry can be draped with a texture bitmap. However, often only a subregion of a texture bitmap is used, as in the following example cases:
If the texture bitmap contains multiple sides of the same building, as well as the roof and roof gables. In this case, each bitmap portion is draped over one of the geometry faces.
If the texture bitmap represents a single panel or window on the building surface, and a geometric face represents a wall with 15 such panels or windows (five on each of three floors). In this case, the single texture bitmap is tiled 15 times over the face.
If the face is non-rectangular sub-faces, such as roof gables. In this case, only a portion (possible triangular) of the texture bitmap is used.
Figure 1-10 shows a large rectangular surface that, when viewed, appears to consist of three textures, each of which is repeated multiple times in various places on the surface.
As shown in Figure 1-10:
The entire image is a large surface that consists of 12 smaller rectangular faces (surface geometries), each of which can be represented by one of three images (labeled A, B, and C).
Three texture bitmaps (labeled A, B, and C) can be used to visualize all of the faces. In this case, bitmap A is used 3 times, bitmap B is used 6 times, and bitmap C is used 3 times.
Figure 1-11 shows a texture bitmap mapped to a triangular face.
As shown in Figure 1-11:
The face (surface geometry) is a triangle. (For example, a side or roof of a building may contain several occurrences of this face.)
The texture bitmap (image) is a rectangle, shown in the box in the middle.
A portion of the texture bitmap represents an image of the face. This portion is shown by a dashed line in the box on the right.
In your application, you will need to specify coordinates within the texture bitmap to map the appropriate portion to the face geometry.
To minimize the storage requirements for image data representing surfaces, you should store images for only the distinct textures that will be needed. The data type for storing a texture is SDO_ORDINATE_ARRAY, which is used in the SDO_GEOMETRY type definition (explained in SDO_GEOMETRY Object Type).
For example, assume that the large surface in Figure 1-10 has the following definition:
SDO_GEOMETRY( 2003, -- two-dimensional polygon NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), -- one polygon (exterior polygon ring) SDO_ORDINATE_ARRAY(1,1. 1,13, 13,13, 1,13, 1,1) )
Assume that you have a MY_TEXTURE_COORDINATES table with the following definition:
CREATE TABLE my_texture_coordinates ( texture_coord_id NUMBER PRIMARY KEY, texture_name VARCHAR2(32), texture_coordinates SDO_ORDINATE_ARRAY);
Example 1-1 inserts three texture coordinate definitions into this table. For each texture, its coordinates reflect one of the appropriate smaller rectangles shown in Figure 1-10; however, you can choose any one of the appropriate rectangles for each texture. In Example 1-1, the SDO_ORDINATE_ARRAY definitions for each texture reflect a polygon near the top of Figure 1-10.
Example 1-1 Inserting Texture Coordinate Definitions
INSERT INTO my_texture_coordinates VALUES( 1, 'Texture_A', SDO_ORDINATE_ARRAY(1,9, 1,5, 5,12, 1,12, 1,9) ); INSERT INTO my_texture_coordinates VALUES( 2, 'Texture_B', SDO_ORDINATE_ARRAY(5,9, 9,9, 9,12, 5,12, 5,9) ); INSERT INTO my_texture_coordinates VALUES( 3, 'Texture_C', SDO_ORDINATE_ARRAY(1,12, 13,12, 13,13, 1,13, 1,12) );
Texture bitmaps (stored as BLOBs or as URLs in VARCHAR2 format) and texture coordinate arrays (stored using type SDO_ORDINATE_ARRAY) can be stored in the same table as the SDO_GEOMETRY column or in separate tables; however, especially for the texture bitmaps, it is usually better to use separate tables. Texture bitmaps are likely to be able to be shared among features (such as different office buildings), but texture coordinate definitions are less likely to be sharable among features. (For example, many office buildings may share the same general type of glass exterior, but few of the buildings have the same number of windows and floors. In designing your textures and applications, you must consider how many buildings use the same texture subregion or drape the texture in the same size of repetitive matrix.)
An exception is a texture coordinate array that drapes an entire texture bitmap over a rectangular geometric face. In this case, the texture coordinate array can be specified as (0,0, 1,0, 1,1, 0,1, 1,1), defined by vertices "lower left", "lower right", "upper right", "upper left", and closing with "lower left". Many data sets use this texture coordinate array extensively, because they have primarily rectangular faces and they store one facade for each texture bitmap.
If you used separate tables, you could link them to the surface geometries using foreign keys, as in Example 1-2.
Example 1-2 Creating Tables for Texture Coordinates, Textures, and Surfaces
-- One row for each texture coordinates definition. CREATE TABLE my_texture_coordinates ( texture_coord_id NUMBER PRIMARY KEY, texture_coordinates SDO_ORDINATE_ARRAY); -- One row for each texture. CREATE TABLE my_textures( texture_id NUMBER PRIMARY KEY, texture BLOB); -- One row for each surface (each individual "piece" of a -- potentially larger surface). CREATE TABLE my_surfaces( surface_id NUMBER PRIMARY KEY, surface_geometry SDO_GEOMETRY, texture_id NUMBER, texture_coord_id NUMBER, CONSTRAINT texture_id_fk FOREIGN KEY (texture_id) REFERENCES my_textures(texture_id), CONSTRAINT texture_coord_id_fk FOREIGN KEY (texture_coord_id) REFERENCES my_texture_coordinates(texture_coord_id));