00001 /* 00002 * Copyright (c) 2012 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 * Constant SampleGenerator COP 00027 */ 00028 #ifndef __COP2_SAMPLEGENERATOR_H__ 00029 #define __COP2_SAMPLEGENERATOR_H__ 00030 00031 #include <UT/UT_Vector3.h> 00032 #include <UT/UT_Vector4.h> 00033 #include <COP2/COP2_Generator.h> 00034 00035 namespace HDK_Sample { 00036 00037 /// @brief Simple COP generator example for the HDK 00038 00039 /// This HDK example demonstrates how to generate image data in COPs. It 00040 /// generates random white noise. 00041 /// 00042 class COP2_SampleGenerator : public COP2_Generator 00043 { 00044 public: 00045 static OP_Node *myConstructor(OP_Network*, const char *, 00046 OP_Operator *); 00047 /// *{ 00048 /// Static lists to define parameters and local variables 00049 static OP_TemplatePair myTemplatePair; 00050 static OP_VariablePair myVariablePair; 00051 static PRM_Template myTemplateList[]; 00052 static CH_LocalVariable myVariableList[]; 00053 /// *} 00054 00055 /// Determine frame range, image composition and other sequence info 00056 virtual TIL_Sequence *cookSequenceInfo(OP_ERROR &error); 00057 00058 protected: 00059 /// Evaluate parms and stash data for cooking in a COP2_ContextData object 00060 virtual COP2_ContextData *newContextData(const TIL_Plane *, int, 00061 float t, int xres, int yres, 00062 int thread, 00063 int max_threads); 00064 00065 /// Create the image data for a single tile list - multithreaded call 00066 virtual OP_ERROR generateTile(COP2_Context &context, 00067 TIL_TileList *tilelist); 00068 00069 virtual ~COP2_SampleGenerator(); 00070 private: 00071 COP2_SampleGenerator(OP_Network *parent, const char *name, 00072 OP_Operator *entry); 00073 00074 /// *{ 00075 /// Parameter evaluation methods 00076 int SEED(float t) 00077 { return evalInt("seed",0,t); } 00078 00079 void AMP(UT_Vector4 &, float t) 00080 { amp.x() = evalFloat("ampl",0,t); 00081 amp.y() = evalFloat("ampl",1,t); 00082 amp.z() = evalFloat("ampl",2,t); 00083 amp.w() = evalFloat("ampl",3,t); } 00084 /// *} 00085 }; 00086 00087 /// @brief Data class to hold parm values and data for COP2_SampleGenerator 00088 00089 /// This class is used to hold the evaluated parms and data needed for the 00090 /// cook. Because the cook method generateTiles() is threaded and called 00091 /// multiple times, this class caches any data needed once and is used by many 00092 /// tiles and threads, to reduce redundancy. 00093 class cop2_SampleGeneratorData : public COP2_ContextData 00094 { 00095 public: 00096 cop2_SampleGeneratorData() : myAmp(0.0f,0.0f,0.0f), mySeed(0) { } 00097 00098 virtual ~cop2_SampleGeneratorData() { ; } 00099 00100 UT_Vector4 myAmp; 00101 int mySeed; 00102 }; 00103 00104 } // End HDK_Sample namespace 00105 00106 #endif
1.5.9