HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
COP2_SampleGenerator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  * Constant SampleGenerator COP
27  */
28 #ifndef __COP2_SAMPLEGENERATOR_H__
29 #define __COP2_SAMPLEGENERATOR_H__
30 
31 #include <UT/UT_Vector3.h>
32 #include <UT/UT_Vector4.h>
33 #include <COP2/COP2_Generator.h>
34 
35 namespace HDK_Sample {
36 
37 /// @brief Simple COP generator example for the HDK
38 
39 /// This HDK example demonstrates how to generate image data in COPs. It
40 /// generates random white noise.
41 ///
43 {
44 public:
45  static OP_Node *myConstructor(OP_Network*, const char *,
46  OP_Operator *);
47  /// *{
48  /// Static lists to define parameters and local variables
53  /// *}
54 
55  /// Determine frame range, image composition and other sequence info
57 
58 protected:
59  /// Evaluate parms and stash data for cooking in a COP2_ContextData object
60  virtual COP2_ContextData *newContextData(const TIL_Plane *, int,
61  float t, int xres, int yres,
62  int thread,
63  int max_threads);
64 
65  /// Create the image data for a single tile list - multithreaded call
66  virtual OP_ERROR generateTile(COP2_Context &context,
67  TIL_TileList *tilelist);
68 
69  virtual ~COP2_SampleGenerator();
70 private:
71  COP2_SampleGenerator(OP_Network *parent, const char *name,
72  OP_Operator *entry);
73 
74  /// *{
75  /// Parameter evaluation methods
76  int SEED(fpreal t)
77  { return evalInt("seed",0,t); }
78 
79  void AMP(UT_Vector4 &amp, fpreal t)
80  { amp.x() = evalFloat("ampl",0,t);
81  amp.y() = evalFloat("ampl",1,t);
82  amp.z() = evalFloat("ampl",2,t);
83  amp.w() = evalFloat("ampl",3,t); }
84  /// *}
85 };
86 
87 /// @brief Data class to hold parm values and data for COP2_SampleGenerator
88 
89 /// This class is used to hold the evaluated parms and data needed for the
90 /// cook. Because the cook method generateTiles() is threaded and called
91 /// multiple times, this class caches any data needed once and is used by many
92 /// tiles and threads, to reduce redundancy.
94 {
95 public:
96  cop2_SampleGeneratorData() : myAmp(0.0f,0.0f,0.0f), mySeed(0) { }
97 
98  virtual ~cop2_SampleGeneratorData() { ; }
99 
101  int mySeed;
102 };
103 
104 } // End HDK_Sample namespace
105 
106 #endif
T & z(void)
Definition: UT_Vector4.h:372
virtual TIL_Sequence * cookSequenceInfo(OP_ERROR &error)
*}
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
static CH_LocalVariable myVariableList[]
static OP_VariablePair myVariablePair
Simple COP generator example for the HDK.
static OP_TemplatePair myTemplatePair
GLfloat f
Definition: glcorearb.h:1925
Data class to hold parm values and data for COP2_SampleGenerator.
GLuint const GLchar * name
Definition: glcorearb.h:785
T & y(void)
Definition: UT_Vector4.h:370
virtual OP_ERROR error()
Definition: COP2_Node.h:444
double fpreal
Definition: SYS_Types.h:263
static OP_Node * myConstructor(OP_Network *, const char *, OP_Operator *)
T & x(void)
Definition: UT_Vector4.h:368
exint evalInt(int pi, int vi, fpreal t) const
T & w(void)
Definition: UT_Vector4.h:374
virtual OP_ERROR generateTile(COP2_Context &context, TIL_TileList *tilelist)
Create the image data for a single tile list - multithreaded call.
virtual COP2_ContextData * newContextData(const TIL_Plane *, int, float t, int xres, int yres, int thread, int max_threads)
Evaluate parms and stash data for cooking in a COP2_ContextData object.