00001 /* 00002 * Copyright (c) 2005 00003 * Side Effects Software Inc. All rights reserved. 00004 * 00005 * Redistribution and use of Houdini Development Kit samples in source and 00006 * binary forms, with or without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. The name of Side Effects Software may not be used to endorse or 00011 * promote products derived from this software without specific prior 00012 * written permission. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS 00015 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00017 * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00019 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00020 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00021 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00022 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00023 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 * 00025 *---------------------------------------------------------------------------- 00026 * This is a sample mantra procedural to subdivide a triangle as a fractal. 00027 */ 00028 00029 #ifndef __VRAY_DemoBox__ 00030 #define __VRAY_DemoBox__ 00031 00032 #include <UT/UT_BoundingBox.h> 00033 #include <VRAY/VRAY_Procedural.h> 00034 00035 namespace HDK_Sample { 00036 00037 class FractalPoint { 00038 public: 00039 void assign(fpreal x, fpreal y, fpreal z, uint s) 00040 { 00041 pos.assign(x, y, z); 00042 seed = seed; 00043 } 00044 UT_Vector3 pos; 00045 int seed; 00046 }; 00047 00048 class VRAY_DemoMountain : public VRAY_Procedural { 00049 public: 00050 VRAY_DemoMountain(int splits=1); 00051 virtual ~VRAY_DemoMountain(); 00052 00053 virtual const char *getClassName(); 00054 virtual int initialize(const UT_BoundingBox *); 00055 virtual void getBoundingBox(UT_BoundingBox &box); 00056 virtual void render(); 00057 00058 /// Split into 4 new procedurals (each rendering a triangle) 00059 void fractalSplit(); 00060 00061 /// Render triangle geometry 00062 void fractalRender(); 00063 00064 private: 00065 /// Compute bounding box (including displacement or not) 00066 void computeBounds(UT_BoundingBox &box, 00067 bool include_displace); 00068 FractalPoint myP[3]; 00069 int mySplits; 00070 }; 00071 00072 } // End HDK_Sample namespace 00073 00074 #endif
1.5.9