HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
COP2_SampleGenerator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024
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
61  float t, int xres, int yres,
62  int thread,
63  int max_threads) override;
64 
65  /// Create the image data for a single tile list - multithreaded call
67  TIL_TileList *tilelist) override;
68 
69  ~COP2_SampleGenerator() override;
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  ~cop2_SampleGeneratorData() override { ; }
99 
101  int mySeed;
102 };
103 
104 } // End HDK_Sample namespace
105 
106 #endif
TIL_Sequence * cookSequenceInfo(OP_ERROR &error) override
*}
OP_ERROR error() override
Definition: COP2_Node.h:445
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector4.h:493
COP2_ContextData * newContextData(const TIL_Plane *, int, float t, int xres, int yres, int thread, int max_threads) override
Evaluate parms and stash data for cooking in a COP2_ContextData object.
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.
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector4.h:491
static OP_TemplatePair myTemplatePair
GLfloat f
Definition: glcorearb.h:1926
Data class to hold parm values and data for COP2_SampleGenerator.
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector4.h:495
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble t
Definition: glad.h:2397
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
static OP_Node * myConstructor(OP_Network *, const char *, OP_Operator *)
fpreal64 fpreal
Definition: SYS_Types.h:277
constexpr SYS_FORCE_INLINE T & w() noexcept
Definition: UT_Vector4.h:497
exint evalInt(int pi, int vi, fpreal t) const
OP_ERROR generateTile(COP2_Context &context, TIL_TileList *tilelist) override
Create the image data for a single tile list - multithreaded call.