// // time: Wed Apr 24 07:57:11 1996 // // version: 3.0.0 (format), 3.1.0 (DX) // // // Begin MDF // MODULE TextureMap // CATEGORY Macros // DESCRIPTION Sets up a surface and an image for texture mapping // INPUT surface; field or group; (none); surface onto which to put texture map // INPUT surface_orientation; integer; 0; orientation of the surface field (see Reorient manual page) // INPUT texture; field or group; (none); image to use as texture map // INPUT texture_orientation; integer; 0; orientation of the texture map (see Reorient manual page) // INPUT texture_map_size; value list or field; [7 7]; size of texture map to use, must be power of 2 (2**7=128) // OUTPUT texturemap; object; texture map // End MDF // // comment: // comment: This macro takes a rectangular surface and an image and arranges it so that the image is texture mapped onto the surface at rendering time. The detail in the final picture is obtained from the image which is input to this macro, not from the number of quads in the input surface. To see a texture mapped image you must be using the hardware rendering option in the Image macro, and you must be running on a system which supports texture mapping (currently systems which use OpenGL for rendering - the dec alpha and ibm6000s with OpenGL support. See the -hwrender option of the dx command by running "dx -morehelp" for more information on ibm6000 options.) // comment: // comment: The first input to this macro is the rectangular surface to be shown. The second input is the orientation of this surface. It is a number between 0 and 7; see the Reorient module for an explanation of how to specify a specific orientation (or just try some numbers out). For good performance there should be as few quads in the surface as possible - use Reduce before putting the surface into this macro to reduce the number of quads. The surface can be a single quad constructed with the Construct module; this will have the best possible performance. // comment: // comment: The third input is the image to be mapped onto the surface. The fourth input is the orientation of this image relative to the surface. Again, see the Reorient module for an explanation of how to specify orientations. // comment: // comment: The last input controls the size of the texture map. The input must be a number between 6 and 12 (default 7) which specifies what power of 2 the size will be. 2**6 is 64, 2**7 is 128, etc. Since hardware requires that the texture map be a power of 2 in resolution, this macro resamples the image into a 32x32, 64x64 etc image. The original image can be any size. The smaller the size of the texture map the faster the rendering, with some loss of precision relative to the original image. There is usually a limit in the hardware card for the maximum size of a texture map; if the size exceeds that limit the rendering will either fail or will become drastically slower as main memory may be used instead of memory local to the hardware rendering card. // comment: // comment: If the surface is to be deformed, the texture must first be mapped to the flat surface and then the RubberSheet module can be used to deform the underlying surface. If the resulting image looks bright with no relief discernable use the Shade module to enable shading. If the image then looks dark, it may be because the hardware card is interpreting the front of the image as the back. Use the following sequence of 3 modules to invert the shading: Mark(object, "normals") -> Compute(object, expression="-a") -> Unmark(object). Use this sequence after the Shade module and before the Image module. // comment: (C) COPYRIGHT International Business Machines Corp. 1996. // comment: All Rights Reserved. // comment: Licensed Materials - Property of IBM // comment: // comment: Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the software without specific prior written permission. // comment: // comment: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOFTWARE, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IBM DOES NOT WARRANT AGAINST THE INFRINGMENT OF PATENTS, COPYRIGHT OR ANY OTHER INTELLECTUAL PROPERTY RIGHTS OF OTHERS. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, IS WITH YOU. // comment: // workspace: width = 1042, height = 815 // layout: snap = 0, width = 50, height = 50, align = NN // macro TextureMap( surface ,surface_orientation = 0 ,texture ,texture_orientation = 0 ,texture_map_size = [7 7] ) -> ( texturemap ) { // // node Input[7]: x = 941, y = 6, inputs = 0, label = Input // parameter: position = 5, name = 'texture_map_size', value = '[7 7]', descriptive = 0, description = 'size of texture map to use, must be power of 2 (2**7=128)', required = 0, visible = 1 // TextureMap_Input_7_out_1 = texture_map_size; // // node Compute[51]: x = 970, y = 83, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "($0 < 6 || $0 > 12 ) ? 1 : 0" // expression: value = (exponent < 6 || exponent > 12 ) ? 1 : 0 // name[2]: value = exponent // TextureMap_Compute_51_out_1 = Compute( "($0 < 6 || $0 > 12 ) ? 1 : 0", TextureMap_Input_7_out_1 ) [instance: 51, cache: 1]; // // node Compute[55]: x = 907, y = 196, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "!$0" // expression: value = !a // name[2]: value = a // TextureMap_Compute_55_out_1 = Compute( "!$0", TextureMap_Compute_51_out_1 ) [instance: 55, cache: 1]; // // node Input[8]: x = 32, y = 20, inputs = 0, label = Input // parameter: position = 1, name = 'surface', value = ' ', descriptive = 0, description = 'surface onto which to put texture map ', required = 1, visible = 1 // TextureMap_Input_8_out_1 = surface; // // node Input[9]: x = 102, y = 18, inputs = 0, label = Input // parameter: position = 2, name = 'surface_orientation', value = '0', descriptive = 0, description = 'orientation of the surface field (see Reorient manual page)', required = 0, visible = 1 // TextureMap_Input_9_out_1 = surface_orientation; // // node Reorient[4]: x = 49, y = 117, inputs = 2, label = Reorient // TextureMap_Reorient_4_out_1 = Reorient( TextureMap_Input_8_out_1, TextureMap_Input_9_out_1 ) [instance: 4, cache: 1]; // // node Mark[6]: x = 82, y = 201, inputs = 2, label = Mark // input[2]: defaulting = 0, visible = 1, type = 32, value = "positions" // TextureMap_Mark_6_out_1 = Mark( TextureMap_Reorient_4_out_1, "positions" ) [instance: 6, cache: 1]; // // node Compute[60]: x = 37, y = 320, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "$0.x" // expression: value = a.x // name[2]: value = a // TextureMap_Compute_60_out_1 = Compute( "$0.x", TextureMap_Mark_6_out_1 ) [instance: 60, cache: 1]; // // node Statistics[2]: x = 17, y = 399, inputs = 1, label = Statistics // TextureMap_Statistics_2_out_1, TextureMap_Statistics_2_out_2, TextureMap_Statistics_2_out_3, TextureMap_Statistics_2_out_4, TextureMap_Statistics_2_out_5 = Statistics( TextureMap_Compute_60_out_1 ) [instance: 2, cache: 1]; // // node Compute[61]: x = 173, y = 317, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "$0.y" // expression: value = a.y // name[2]: value = a // TextureMap_Compute_61_out_1 = Compute( "$0.y", TextureMap_Mark_6_out_1 ) [instance: 61, cache: 1]; // // node Statistics[1]: x = 154, y = 400, inputs = 1, label = Statistics // TextureMap_Statistics_1_out_1, TextureMap_Statistics_1_out_2, TextureMap_Statistics_1_out_3, TextureMap_Statistics_1_out_4, TextureMap_Statistics_1_out_5 = Statistics( TextureMap_Compute_61_out_1 ) [instance: 1, cache: 1]; // // node Compute[59]: x = 41, y = 526, inputs = 6, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "[ ($0.x - $1) / ($2 - $1), ($0.y - $3) / ($4 - $3)]" // expression: value = [ (vector.x - xmin) / (xmax - xmin), (vector.y - ymin) / (ymax - ymin)] // name[2]: value = vector // name[3]: value = xmin // name[4]: value = xmax // name[5]: value = ymin // name[6]: value = ymax // TextureMap_Compute_59_out_1 = Compute( "[ ($0.x - $1) / ($2 - $1), ($0.y - $3) / ($4 - $3)]", TextureMap_Mark_6_out_1, TextureMap_Statistics_2_out_4, TextureMap_Statistics_2_out_5, TextureMap_Statistics_1_out_4, TextureMap_Statistics_1_out_5 ) [instance: 59, cache: 1]; // // node Replace[3]: x = 327, y = 752, inputs = 4, label = Replace // input[4]: defaulting = 0, visible = 1, type = 32, value = "uv" // TextureMap_Replace_3_out_1 = Replace( TextureMap_Compute_59_out_1, TextureMap_Reorient_4_out_1, NULL, "uv" ) [instance: 3, cache: 1]; // // node Input[6]: x = 438, y = 15, inputs = 0, label = Input // parameter: position = 3, name = 'texture', value = ' ', descriptive = 0, description = 'image to use as texture map', required = 1, visible = 1 // TextureMap_Input_6_out_1 = texture; // // node Reorient[6]: x = 463, y = 102, inputs = 2, label = Reorient // TextureMap_Reorient_6_out_1 = Reorient( TextureMap_Input_6_out_1, NULL ) [instance: 6, cache: 1]; // // node Inquire[10]: x = 446, y = 185, inputs = 3, label = Inquire // input[2]: defaulting = 0, visible = 1, type = 32, value = "grid counts" // input[3]: defaulting = 0, visible = 1, type = 32, value = "positions" // TextureMap_Inquire_10_out_1 = Inquire( TextureMap_Reorient_6_out_1, "grid counts", "positions" ) [instance: 10, cache: 1]; // // node Compute[56]: x = 420, y = 274, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "[0, int($0.x) - 1]" // expression: value = [0, int(a.x) - 1] // name[2]: value = a // TextureMap_Compute_56_out_1 = Compute( "[0, int($0.x) - 1]", TextureMap_Inquire_10_out_1 ) [instance: 56, cache: 1]; // // node Compute[57]: x = 888, y = 87, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "2**$0" // expression: value = 2**a // name[2]: value = a // TextureMap_Compute_57_out_1 = Compute( "2**$0", TextureMap_Input_7_out_1 ) [instance: 57, cache: 1]; // // node Compute[52]: x = 504, y = 275, inputs = 3, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "[($0.y-1) / (float($1)-1) , -($0.x-1) / (float($1)-1) ]" // expression: value = [(a.y-1) / (float(b)-1) , -(a.x-1) / (float(b)-1) ] // name[2]: value = a // name[3]: value = b // TextureMap_Compute_52_out_1 = Compute( "[($0.y-1) / (float($1)-1) , -($0.x-1) / (float($1)-1) ]", TextureMap_Inquire_10_out_1, TextureMap_Compute_57_out_1 ) [instance: 52, cache: 1]; // // node Compute[53]: x = 593, y = 270, inputs = 2, label = Compute // input[1]: defaulting = 0, visible = 0, type = 32, value = "int([$0, $0])" // expression: value = int([a, a]) // name[2]: value = a // TextureMap_Compute_53_out_1 = Compute( "int([$0, $0])", TextureMap_Compute_57_out_1 ) [instance: 53, cache: 1]; // // node Construct[3]: x = 487, y = 361, inputs = 4, label = Construct // TextureMap_Construct_3_out_1 = Construct( TextureMap_Compute_56_out_1, TextureMap_Compute_52_out_1, TextureMap_Compute_53_out_1, NULL ) [instance: 3, cache: 1]; // // node Mark[1]: x = 697, y = 255, inputs = 2, label = Mark // input[2]: defaulting = 0, visible = 1, type = 32, value = "colors" // TextureMap_Mark_1_out_1 = Mark( TextureMap_Reorient_6_out_1, "colors" ) [instance: 1, cache: 1]; // // node Map[1]: x = 630, y = 445, inputs = 4, label = Map // input[3]: visible = 1 // input[4]: defaulting = 0, visible = 1, type = 32, value = "colors" // TextureMap_Map_1_out_1 = Map( TextureMap_Construct_3_out_1, TextureMap_Mark_1_out_1, NULL, "colors" ) [instance: 1, cache: 1]; // // node Input[10]: x = 739, y = 7, inputs = 0, label = Input // parameter: position = 4, name = 'texture_orientation', value = '0', descriptive = 0, description = 'orientation of the texture map (see Reorient manual page)', required = 0, visible = 1 // TextureMap_Input_10_out_1 = texture_orientation; // // node Reorient[7]: x = 711, y = 534, inputs = 2, label = Reorient // TextureMap_Reorient_7_out_1 = Reorient( TextureMap_Map_1_out_1, TextureMap_Input_10_out_1 ) [instance: 7, cache: 1]; // // node Options[2]: x = 593, y = 605, inputs = 3, label = Options // input[2]: defaulting = 0, visible = 1, type = 32, value = "texture" // TextureMap_Options_2_out_1 = Options( TextureMap_Replace_3_out_1, "texture", TextureMap_Reorient_7_out_1 ) [instance: 2, cache: 1]; // // node Inquire[11]: x = 525, y = 731, inputs = 3, label = Inquire // input[2]: defaulting = 0, visible = 1, type = 32, value = "has component + 1" // input[3]: defaulting = 0, visible = 1, type = 32, value = "colors" // TextureMap_Inquire_11_out_1 = Inquire( TextureMap_Options_2_out_1, "has component + 1", "colors" ) [instance: 11, cache: 1]; // // node Color[2]: x = 609, y = 707, inputs = 5, label = Color // input[2]: defaulting = 0, visible = 1, type = 32, value = "white" // TextureMap_Color_2_out_1 = Color( TextureMap_Options_2_out_1, "white", NULL, NULL, NULL ) [instance: 2, cache: 1]; // // node Switch[46]: x = 701, y = 752, inputs = 3, label = Switch // TextureMap_Switch_46_out_1 = Switch( TextureMap_Inquire_11_out_1, TextureMap_Color_2_out_1, TextureMap_Options_2_out_1 ) [instance: 46, cache: 1]; // // node Switch[45]: x = 918, y = 733, inputs = 2, label = Switch // TextureMap_Switch_45_out_1 = Switch( TextureMap_Compute_55_out_1, TextureMap_Switch_46_out_1 ) [instance: 45, cache: 1]; // // node Output[10]: x = 843, y = 752, inputs = 1, label = Output // parameter: position = 1, name = 'texturemap', value = ' ', descriptive = 0, description = 'texture map', required = 0, visible = 1 // texturemap = TextureMap_Switch_45_out_1; // // node Route[14]: x = 993, y = 182, inputs = 2, outputs = 2, label = Route // input[2]: defaulting = 0, visible = 1, type = 67108863, value = 1 // TextureMap_Route_14_out_1, TextureMap_Route_14_out_2 = Route( TextureMap_Compute_51_out_1, 1 ) [instance: 14, cache: 1]; // // node Message[1]: x = 968, y = 264, inputs = 3, label = Message // input[1]: defaulting = 0, visible = 1, type = 32, value = "Size input should be between 6 and 12" // input[2]: defaulting = 0, visible = 1, type = 32, value = "error" // Message( "Size input should be between 6 and 12", "error", TextureMap_Route_14_out_1 ) [instance: 1, cache: 1]; // network: end of macro body } TextureMap_Input_7_out_1 = NULL; TextureMap_Compute_51_out_1 = NULL; TextureMap_Compute_55_out_1 = NULL; TextureMap_Input_8_out_1 = NULL; TextureMap_Input_9_out_1 = NULL; TextureMap_Reorient_4_out_1 = NULL; TextureMap_Mark_6_out_1 = NULL; TextureMap_Compute_60_out_1 = NULL; TextureMap_Statistics_2_out_4 = NULL; TextureMap_Statistics_2_out_5 = NULL; TextureMap_Compute_61_out_1 = NULL; TextureMap_Statistics_1_out_4 = NULL; TextureMap_Statistics_1_out_5 = NULL; TextureMap_Compute_59_out_1 = NULL; TextureMap_Replace_3_out_1 = NULL; TextureMap_Input_6_out_1 = NULL; TextureMap_Reorient_6_out_1 = NULL; TextureMap_Inquire_10_out_1 = NULL; TextureMap_Compute_56_out_1 = NULL; TextureMap_Compute_57_out_1 = NULL; TextureMap_Compute_52_out_1 = NULL; TextureMap_Compute_53_out_1 = NULL; TextureMap_Construct_3_out_1 = NULL; TextureMap_Mark_1_out_1 = NULL; TextureMap_Map_1_out_1 = NULL; TextureMap_Input_10_out_1 = NULL; TextureMap_Reorient_7_out_1 = NULL; TextureMap_Options_2_out_1 = NULL; TextureMap_Inquire_11_out_1 = NULL; TextureMap_Color_2_out_1 = NULL; TextureMap_Switch_46_out_1 = NULL; TextureMap_Switch_45_out_1 = NULL; TextureMap_Route_14_out_1 = NULL;