"Fossies" - the Fresh Open Source Software Archive

Member "aqsis-1.8.2/prototypes/newcore/scenes/mbnoisetest.cpp" (24 Aug 2012, 3075 Bytes) of package /linux/privat/aqsis-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Aqsis
    2 // Copyright (C) 2001, Paul C. Gregory and the other authors and contributors
    3 // All rights reserved.
    4 //
    5 // Redistribution and use in source and binary forms, with or without
    6 // modification, are permitted provided that the following conditions are met:
    7 //
    8 // * Redistributions of source code must retain the above copyright notice,
    9 //   this list of conditions and the following disclaimer.
   10 // * Redistributions in binary form must reproduce the above copyright notice,
   11 //   this list of conditions and the following disclaimer in the documentation
   12 //   and/or other materials provided with the distribution.
   13 // * Neither the name of the software's owners nor the names of its
   14 //   contributors may be used to endorse or promote products derived from this
   15 //   software without specific prior written permission.
   16 //
   17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
   21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   27 // POSSIBILITY OF SUCH DAMAGE.
   28 //
   29 // (This is the New BSD license)
   30 
   31 #include "renderer.h"
   32 #include "surfaces.h"
   33 
   34 static GeometryPtr createPatch(const float P[12], const float Cs[3],
   35                                const Mat4& trans = Mat4())
   36 {
   37     PrimvarStorageBuilder builder;
   38     builder.add(Primvar::P, P, 12);
   39     builder.add(PrimvarSpec(PrimvarSpec::Constant, PrimvarSpec::Color, 1, ustring("Cs")),
   40                 Cs, 3);
   41     IclassStorage storReq(1,4,4,4,4);
   42     GeometryPtr patch(new Patch(builder.build(storReq)));
   43     patch->transform(trans);
   44     return patch;
   45 }
   46 
   47 void renderMbNoiseTestScene()
   48 {
   49     Options opts;
   50     opts.xRes = 512;
   51     opts.yRes = 512;
   52     opts.gridSize = 8;
   53     opts.clipNear = 0.1;
   54     opts.superSamp = Imath::V2i(1,1);
   55     opts.pixelFilter = makeBoxFilter(Vec2(1,1));
   56     opts.shutterMin = 0;
   57     opts.shutterMax = 1;
   58 
   59     Attributes attrs;
   60     attrs.shadingRate = 1;
   61     attrs.smoothShading = true;
   62     attrs.surfaceShader = createShader("default");
   63 
   64     Mat4 camToScreen = screenWindow(0,1, 0,1);
   65 
   66     // Output variables.
   67     VarList outVars;
   68     outVars.push_back(Stdvar::Ci);
   69 
   70     Renderer renderer(opts, camToScreen, outVars);
   71 
   72     float Cs[3] = {1,1,1};
   73     GeometryKeys keys;
   74     float P1[12] = {0,0,1,  0,1,1,  1,0,1,  1,1,1};
   75     keys.push_back(GeometryKey(0, createPatch(P1,Cs)));
   76     float P2[12] = {1,0,1,  1,1,1,  2,0,1,  2,1,1};
   77     keys.push_back(GeometryKey(1, createPatch(P2,Cs)));
   78     renderer.add(keys, attrs);
   79 
   80     renderer.render();
   81 }
   82