TEAPOT.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 1.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
00022 -- */
00023 
00024 // file teapot.c    included in nurbs.c
00025 
00026 static float teapot_vertices[]={
00027  1,   1.40000, 0.00000, 2.40000,  53, 2.00000, 0.00000, 1.35000, 105,-1.50000, 0.00000, 0.15000,
00028  2,   1.40000,-0.78400, 2.40000,  54, 2.00000,-1.12000, 1.35000, 106,-2.00000, 1.12000, 0.45000,
00029  3,   0.78400,-1.40000, 2.40000,  55, 1.12000,-2.00000, 1.35000, 107,-1.12000, 2.00000, 0.45000,
00030  4,   0.00000,-1.40000, 2.40000,  56, 0.00000,-2.00000, 1.35000, 108, 0.00000, 2.00000, 0.45000,
00031  5,   1.33750, 0.00000, 2.53125,  57, 2.00000, 0.00000, 0.90000, 109,-1.50000, 0.84000, 0.22500,
00032  6,   1.33750,-0.74900, 2.53125,  58, 2.00000,-1.12000, 0.90000, 110,-0.84000, 1.50000, 0.22500,
00033  7,   0.74900,-1.33750, 2.53125,  59, 1.12000,-2.00000, 0.90000, 111, 0.00000, 1.50000, 0.22500,
00034  8,   0.00000,-1.33750, 2.53125,  60, 0.00000,-2.00000, 0.90000, 112,-1.50000, 0.84000, 0.15000,
00035  9,   1.43750, 0.00000, 2.53125,  61,-0.98000,-1.75000, 1.87500, 113,-0.84000, 1.50000, 0.15000,
00036  10,  1.43750,-0.80500, 2.53125,  62,-1.75000,-0.98000, 1.87500, 114, 0.00000, 1.50000, 0.15000,
00037  11,  0.80500,-1.43750, 2.53125,  63,-1.75000, 0.00000, 1.87500, 115, 1.12000, 2.00000, 0.45000,
00038  12,  0.00000,-1.43750, 2.53125,  64,-1.12000,-2.00000, 1.35000, 116, 2.00000, 1.12000, 0.45000,
00039  13,  1.50000, 0.00000, 2.40000,  65,-2.00000,-1.12000, 1.35000, 117, 0.84000, 1.50000, 0.22500,
00040  14,  1.50000,-0.84000, 2.40000,  66,-2.00000, 0.00000, 1.35000, 118, 1.50000, 0.84000, 0.22500,
00041  15,  0.84000,-1.50000, 2.40000,  67,-1.12000,-2.00000, 0.90000, 119, 0.84000, 1.50000, 0.15000,
00042  16,  0.00000,-1.50000, 2.40000,  68,-2.00000,-1.12000, 0.90000, 120, 1.50000, 0.84000, 0.15000,
00043  17, -0.78400,-1.40000, 2.40000,  69,-2.00000, 0.00000, 0.90000, 121,-1.60000, 0.00000, 2.02500,
00044  18, -1.40000,-0.78400, 2.40000,  70,-1.75000, 0.98000, 1.87500, 122,-1.60000,-0.30000, 2.02500,
00045  19, -1.40000, 0.00000, 2.40000,  71,-0.98000, 1.75000, 1.87500, 123,-1.50000,-0.30000, 2.25000,
00046  20, -0.74900,-1.33750, 2.53125,  72, 0.00000, 1.75000, 1.87500, 124,-1.50000, 0.00000, 2.25000,
00047  21, -1.33750,-0.74900, 2.53125,  73,-2.00000, 1.12000, 1.35000, 125,-2.30000, 0.00000, 2.02500,
00048  22, -1.33750, 0.00000, 2.53125,  74,-1.12000, 2.00000, 1.35000, 126,-2.30000,-0.30000, 2.02500,
00049  23, -0.80500,-1.43750, 2.53125,  75, 0.00000, 2.00000, 1.35000, 127,-2.50000,-0.30000, 2.25000,
00050  24, -1.43750,-0.80500, 2.53125,  76,-2.00000, 1.12000, 0.90000, 128,-2.50000, 0.00000, 2.25000,
00051  25, -1.43750, 0.00000, 2.53125,  77,-1.12000, 2.00000, 0.90000, 129,-2.70000, 0.00000, 2.02500,
00052  26, -0.84000,-1.50000, 2.40000,  78, 0.00000, 2.00000, 0.90000, 130,-2.70000,-0.30000, 2.02500,
00053  27, -1.50000,-0.84000, 2.40000,  79, 0.98000, 1.75000, 1.87500, 131,-3.00000,-0.30000, 2.25000,
00054  28, -1.50000, 0.00000, 2.40000,  80, 1.75000, 0.98000, 1.87500, 132,-3.00000, 0.00000, 2.25000,
00055  29, -1.40000, 0.78400, 2.40000,  81, 1.12000, 2.00000, 1.35000, 133,-2.70000, 0.00000, 1.80000,
00056  30, -0.78400, 1.40000, 2.40000,  82, 2.00000, 1.12000, 1.35000, 134,-2.70000,-0.30000, 1.80000,
00057  31,  0.00000, 1.40000, 2.40000,  83, 1.12000, 2.00000, 0.90000, 135,-3.00000,-0.30000, 1.80000,
00058  32, -1.33750, 0.74900, 2.53125,  84, 2.00000, 1.12000, 0.90000, 136,-3.00000, 0.00000, 1.80000,
00059  33, -0.74900, 1.33750, 2.53125,  85, 2.00000, 0.00000, 0.45000, 137,-1.50000, 0.30000, 2.25000,
00060  34,  0.00000, 1.33750, 2.53125,  86, 2.00000,-1.12000, 0.45000, 138,-1.60000, 0.30000, 2.02500,
00061  35, -1.43750, 0.80500, 2.53125,  87, 1.12000,-2.00000, 0.45000, 139,-2.50000, 0.30000, 2.25000,
00062  36, -0.80500, 1.43750, 2.53125,  88, 0.00000,-2.00000, 0.45000, 140,-2.30000, 0.30000, 2.02500,
00063  37,  0.00000, 1.43750, 2.53125,  89, 1.50000, 0.00000, 0.22500, 141,-3.00000, 0.30000, 2.25000,
00064  38, -1.50000, 0.84000, 2.40000,  90, 1.50000,-0.84000, 0.22500, 142,-2.70000, 0.30000, 2.02500,
00065  39, -0.84000, 1.50000, 2.40000,  91, 0.84000,-1.50000, 0.22500, 143,-3.00000, 0.30000, 1.80000,
00066  40,  0.00000, 1.50000, 2.40000,  92, 0.00000,-1.50000, 0.22500, 144,-2.70000, 0.30000, 1.80000,
00067  41,  0.78400, 1.40000, 2.40000,  93, 1.50000, 0.00000, 0.15000, 145,-2.70000, 0.00000, 1.57500,
00068  42,  1.40000, 0.78400, 2.40000,  94, 1.50000,-0.84000, 0.15000, 146,-2.70000,-0.30000, 1.57500,
00069  43,  0.74900, 1.33750, 2.53125,  95, 0.84000,-1.50000, 0.15000, 147,-3.00000,-0.30000, 1.35000,
00070  44,  1.33750, 0.74900, 2.53125,  96, 0.00000,-1.50000, 0.15000, 148,-3.00000, 0.00000, 1.35000,
00071  45,  0.80500, 1.43750, 2.53125,  97,-1.12000,-2.00000, 0.45000, 149,-2.50000, 0.00000, 1.12500,
00072  46,  1.43750, 0.80500, 2.53125,  98,-2.00000,-1.12000, 0.45000, 150,-2.50000,-0.30000, 1.12500,
00073  47,  0.84000, 1.50000, 2.40000,  99,-2.00000, 0.00000, 0.45000, 151,-2.65000,-0.30000, 0.93750,
00074  48,  1.50000, 0.84000, 2.40000, 100,-0.84000,-1.50000, 0.22500, 152,-2.65000, 0.00000, 0.93750,
00075  49,  1.75000, 0.00000, 1.87500, 101,-1.50000,-0.84000, 0.22500, 153,-2.00000,-0.30000, 0.90000,
00076  50,  1.75000,-0.98000, 1.87500, 102,-1.50000, 0.00000, 0.22500, 154,-1.90000,-0.30000, 0.60000,
00077  51,  0.98000,-1.75000, 1.87500, 103,-0.84000,-1.50000, 0.15000, 155,-1.90000, 0.00000, 0.60000,
00078  52,  0.00000,-1.75000, 1.87500, 104,-1.50000,-0.84000, 0.15000, 156,-3.00000, 0.30000, 1.35000,
00079 
00080  157,-2.70000, 0.30000, 1.57500, 207, 0.80000, 0.00000, 3.15000, 257, 0.00000, 0.40000, 2.55000,
00081  158,-2.65000, 0.30000, 0.93750, 208, 0.80000,-0.45000, 3.15000, 258,-1.30000, 0.72800, 2.55000,
00082  159,-2.50000, 0.30000, 1.12500, 209, 0.45000,-0.80000, 3.15000, 259,-0.72800, 1.30000, 2.55000,
00083  160,-1.90000, 0.30000, 0.60000, 210, 0.00000,-0.80000, 3.15000, 260, 0.00000, 1.30000, 2.55000,
00084  161,-2.00000, 0.30000, 0.90000, 211, 0.00000, 0.00000, 2.85000, 261,-1.30000, 0.72800, 2.40000,
00085  162, 1.70000, 0.00000, 1.42500, 212, 0.20000, 0.00000, 2.70000, 262,-0.72800, 1.30000, 2.40000,
00086  163, 1.70000,-0.66000, 1.42500, 213, 0.20000,-0.11200, 2.70000, 263, 0.00000, 1.30000, 2.40000,
00087  164, 1.70000,-0.66000, 0.60000, 214, 0.11200,-0.20000, 2.70000, 264, 0.22400, 0.40000, 2.55000,
00088  165, 1.70000, 0.00000, 0.60000, 215, 0.00000,-0.20000, 2.70000, 265, 0.40000, 0.22400, 2.55000,
00089  166, 2.60000, 0.00000, 1.42500, 216,-0.00200, 0.00000, 3.15000, 266, 0.72800, 1.30000, 2.55000,
00090  167, 2.60000,-0.66000, 1.42500, 217,-0.45000,-0.80000, 3.15000, 267, 1.30000, 0.72800, 2.55000,
00091  168, 3.10000,-0.66000, 0.82500, 218,-0.80000,-0.45000, 3.15000, 268, 0.72800, 1.30000, 2.40000,
00092  169, 3.10000, 0.00000, 0.82500, 219,-0.80000, 0.00000, 3.15000, 269, 1.30000, 0.72800, 2.40000,
00093  170, 2.30000, 0.00000, 2.10000, 220,-0.11200,-0.20000, 2.70000, 270, 0.00000, 0.00000, 0.00000,
00094  171, 2.30000,-0.25000, 2.10000, 221,-0.20000,-0.11200, 2.70000, 271, 1.50000, 0.00000, 0.15000,
00095  172, 2.40000,-0.25000, 2.02500, 222,-0.20000, 0.00000, 2.70000, 272, 1.50000, 0.84000, 0.15000,
00096  173, 2.40000, 0.00000, 2.02500, 223, 0.00000, 0.00200, 3.15000, 273, 0.84000, 1.50000, 0.15000,
00097  174, 2.70000, 0.00000, 2.40000, 224,-0.80000, 0.45000, 3.15000, 274, 0.00000, 1.50000, 0.15000,
00098  175, 2.70000,-0.25000, 2.40000, 225,-0.45000, 0.80000, 3.15000, 275, 1.50000, 0.00000, 0.07500,
00099  176, 3.30000,-0.25000, 2.40000, 226, 0.00000, 0.80000, 3.15000, 276, 1.50000, 0.84000, 0.07500,
00100  177, 3.30000, 0.00000, 2.40000, 227,-0.20000, 0.11200, 2.70000, 277, 0.84000, 1.50000, 0.07500,
00101  178, 1.70000, 0.66000, 0.60000, 228,-0.11200, 0.20000, 2.70000, 278, 0.00000, 1.50000, 0.07500,
00102  179, 1.70000, 0.66000, 1.42500, 229, 0.00000, 0.20000, 2.70000, 279, 1.42500, 0.00000, 0.00000,
00103  180, 3.10000, 0.66000, 0.82500, 230, 0.45000, 0.80000, 3.15000, 280, 1.42500, 0.79800, 0.00000,
00104  181, 2.60000, 0.66000, 1.42500, 231, 0.80000, 0.45000, 3.15000, 281, 0.79800, 1.42500, 0.00000,
00105  182, 2.40000, 0.25000, 2.02500, 232, 0.11200, 0.20000, 2.70000, 282, 0.00000, 1.42500, 0.00000,
00106  183, 2.30000, 0.25000, 2.10000, 233, 0.20000, 0.11200, 2.70000, 283,-0.84000, 1.50000, 0.15000,
00107  184, 3.30000, 0.25000, 2.40000, 234, 0.40000, 0.00000, 2.55000, 284,-1.50000, 0.84000, 0.15000,
00108  185, 2.70000, 0.25000, 2.40000, 235, 0.40000,-0.22400, 2.55000, 285,-1.50000, 0.00000, 0.15000,
00109  186, 2.80000, 0.00000, 2.47500, 236, 0.22400,-0.40000, 2.55000, 286,-0.84000, 1.50000, 0.07500,
00110  187, 2.80000,-0.25000, 2.47500, 237, 0.00000,-0.40000, 2.55000, 287,-1.50000, 0.84000, 0.07500,
00111  188, 3.52500,-0.25000, 2.49375, 238, 1.30000, 0.00000, 2.55000, 288,-1.50000, 0.00000, 0.07500,
00112  189, 3.52500, 0.00000, 2.49375, 239, 1.30000,-0.72800, 2.55000, 289,-0.79800, 1.42500, 0.00000,
00113  190, 2.90000, 0.00000, 2.47500, 240, 0.72800,-1.30000, 2.55000, 290,-1.42500, 0.79800, 0.00000,
00114  191, 2.90000,-0.15000, 2.47500, 241, 0.00000,-1.30000, 2.55000, 291,-1.42500, 0.00000, 0.00000,
00115  192, 3.45000,-0.15000, 2.51250, 242, 1.30000, 0.00000, 2.40000, 292,-1.50000,-0.84000, 0.15000,
00116  193, 3.45000, 0.00000, 2.51250, 243, 1.30000,-0.72800, 2.40000, 293,-0.84000,-1.50000, 0.15000,
00117  194, 2.80000, 0.00000, 2.40000, 244, 0.72800,-1.30000, 2.40000, 294, 0.00000,-1.50000, 0.15000,
00118  195, 2.80000,-0.15000, 2.40000, 245, 0.00000,-1.30000, 2.40000, 295,-1.50000,-0.84000, 0.07500,
00119  196, 3.20000,-0.15000, 2.40000, 246,-0.22400,-0.40000, 2.55000, 296,-0.84000,-1.50000, 0.07500,
00120  197, 3.20000, 0.00000, 2.40000, 247,-0.40000,-0.22400, 2.55000, 297, 0.00000,-1.50000, 0.07500,
00121  198, 3.52500, 0.25000, 2.49375, 248,-0.40000, 0.00000, 2.55000, 298,-1.42500,-0.79800, 0.00000,
00122  199, 2.80000, 0.25000, 2.47500, 249,-0.72800,-1.30000, 2.55000, 299,-0.79800,-1.42500, 0.00000,
00123  200, 3.45000, 0.15000, 2.51250, 250,-1.30000,-0.72800, 2.55000, 300, 0.00000,-1.42500, 0.00000,
00124  201, 2.90000, 0.15000, 2.47500, 251,-1.30000, 0.00000, 2.55000, 301, 0.84000,-1.50000, 0.15000,
00125  202, 3.20000, 0.15000, 2.40000, 252,-0.72800,-1.30000, 2.40000, 302, 1.50000,-0.84000, 0.15000,
00126  203, 2.80000, 0.15000, 2.40000, 253,-1.30000,-0.72800, 2.40000, 303, 0.84000,-1.50000, 0.07500,
00127  204, 0.00000, 0.00000, 3.15000, 254,-1.30000, 0.00000, 2.40000, 304, 1.50000,-0.84000, 0.07500,
00128  205, 0.00000,-0.00200, 3.15000, 255,-0.40000, 0.22400, 2.55000, 305, 0.79800,-1.42500, 0.00000,
00129  206, 0.00200, 0.00000, 3.15000, 256,-0.22400, 0.40000, 2.55000, 306, 1.42500,-0.79800, 0.00000};
00130 
00131 static long teapot_patchs[]=
00132     {  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
00133        4, 17, 18, 19,  8, 20, 21, 22, 12, 23, 24, 25, 16, 26, 27, 28,
00134       19, 29, 30, 31, 22, 32, 33, 34, 25, 35, 36, 37, 28, 38, 39, 40,
00135       31, 41, 42,  1, 34, 43, 44,  5, 37, 45, 46,  9, 40, 47, 48, 13,
00136       13, 14, 15, 16, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
00137       16, 26, 27, 28, 52, 61, 62, 63, 56, 64, 65, 66, 60, 67, 68, 69,
00138       28, 38, 39, 40, 63, 70, 71, 72, 66, 73, 74, 75, 69, 76, 77, 78,
00139       40, 47, 48, 13, 72, 79, 80, 49, 75, 81, 82, 53, 78, 83, 84, 57,
00140       57, 58, 59, 60, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
00141       60, 67, 68, 69, 88, 97, 98, 99, 92,100,101,102, 96,103,104,105,
00142       69, 76, 77, 78, 99,106,107,108,102,109,110,111,105,112,113,114,
00143       78, 83, 84, 57,108,115,116, 85,111,117,118, 89,114,119,120, 93,
00144      121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,
00145      124,137,138,121,128,139,140,125,132,141,142,129,136,143,144,133,
00146      133,134,135,136,145,146,147,148,149,150,151,152, 69,153,154,155,
00147      136,143,144,133,148,156,157,145,152,158,159,149,155,160,161, 69,
00148      162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,
00149      165,178,179,162,169,180,181,166,173,182,183,170,177,184,185,174,
00150      174,175,176,177,186,187,188,189,190,191,192,193,194,195,196,197,
00151      177,184,185,174,189,198,199,186,193,200,201,190,197,202,203,194,
00152      204,204,204,204,207,208,209,210,211,211,211,211,212,213,214,215,
00153      204,204,204,204,210,217,218,219,211,211,211,211,215,220,221,222,
00154      204,204,204,204,219,224,225,226,211,211,211,211,222,227,228,229,
00155      204,204,204,204,226,230,231,207,211,211,211,211,229,232,233,212,
00156      212,213,214,215,234,235,236,237,238,239,240,241,242,243,244,245,
00157      215,220,221,222,237,246,247,248,241,249,250,251,245,252,253,254,
00158      222,227,228,229,248,255,256,257,251,258,259,260,254,261,262,263,
00159      229,232,233,212,257,264,265,234,260,266,267,238,263,268,269,242,
00160      270,270,270,270,279,280,281,282,275,276,277,278, 93,120,119,114,
00161      270,270,270,270,282,289,290,291,278,286,287,288,114,113,112,105,
00162      270,270,270,270,291,298,299,300,288,295,296,297,105,104,103, 96,
00163      270,270,270,270,300,305,306,279,297,303,304,275, 96, 95, 94, 93};
00164 
00165 void NurbsTeapot(void){
00166  long knots[] = { 0, 0, 0, 0, 1, 1, 1, 1};
00167  double weight=1.0,scale=5.0;
00168  float v,vertices[306][3];
00169  int n,i,j,k,id;
00170  for(i=0,k=0;i<306;i++){
00171    id=((long)teapot_vertices[k])-1;
00172    k++;
00173    for(j=0;j<3;j++){
00174      v=teapot_vertices[k];
00175      vertices[id][j]=v;
00176      k++;
00177    }
00178  }
00179  for(n=0,k=0;n<32;n++){ // patch
00180    CreateNurbs();
00181    MainNp->numU = 4;
00182    MainNp->numV = 4;
00183    MainNp->orderU = 4;
00184    MainNp->orderV = 4;
00185    MainNp->properties.GranularityMin=1;
00186    MainNp->properties.GranularityMax=8;
00187    AllocNurbs(MainNp,NULL,NULL);
00188    for (i = 0; i < MainNp->numU + MainNp->orderU; i++){
00189      MainNp->kvU[i] = MainNp->kvV[i] = (double)knots[i];
00190    }
00191    for(i=0;i<4;i++)
00192    for(j=0;j<4;j++){
00193      id=teapot_patchs[k]-1;
00194 if(id < 0 || id >= 306)MessageBox(NULL,"Bad vertex",NULL,MB_OK);
00195      MainNp->points[i][j].x = NpointerX + (vertices[id][0] * (double)MINUNIT)
00196                 * scale * weight;
00197      MainNp->points[i][j].y = NpointerY + (vertices[id][1] * (double)MINUNIT)
00198                 * scale * weight;
00199      MainNp->points[i][j].z = NpointerZ + (vertices[id][2] * (double)MINUNIT)
00200                 * scale * weight;
00201      MainNp->points[i][j].w = weight;
00202      MainNp->points[i][j].selected = FALSE;
00203      k++;
00204    }
00205  }
00206  return;
00207 }

Generated on Sun Apr 27 14:20:12 2014 for OpenFX by  doxygen 1.5.6