HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GABC_PackedGT.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) COPYRIGHTYEAR
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  */
27 
28 #ifndef __GABC_PackedGT__
29 #define __GABC_PackedGT__
30 
31 #include "GABC_API.h"
32 #include "GABC_Types.h"
33 #include "GABC_PackedImpl.h"
35 #include <GT/GT_PackedAlembic.h>
36 #include <GT/GT_PrimInstance.h>
37 
38 class GU_PrimPacked;
39 
40 namespace GABC_NAMESPACE
41 {
42 
44 {
45 public:
47  {
48  myVisibilityAnimated = false;
49  myTransformAnimated = false;
50  }
51 
52  void setVisibilityAnimated(bool anim) { myVisibilityAnimated = anim;}
53  void setTransformAnimated(bool anim) { myTransformAnimated = anim; }
54 
55  void getVisibility(const GABC_PackedImpl *impl, bool &visible);
56  void getTransform(const GABC_PackedImpl *impl,
58 
59 private:
60  UT_Map<fpreal, bool> myVisibility;
61  UT_Map<fpreal, UT_Matrix4D> myTransform;
62 
63  bool myVisibilityAnimated;
64  bool myTransformAnimated;
65 };
66 
67 /// Collector for packed primitives.
69 {
70 public:
72  virtual ~GABC_CollectPacked();
73 
74  /// @{
75  /// Interface defined for GT_GEOPrimCollect
76  virtual GT_GEOPrimCollectData *
78  const GT_RefineParms *parms) const;
79  virtual GT_PrimitiveHandle
81  const GEO_Primitive *const* prim_list,
82  int nsegments,
84  virtual GT_PrimitiveHandle
85  endCollecting(const GT_GEODetailListHandle &geometry,
87  /// @}
88 private:
89 };
90 
91 /// Collection class for a single archive's worth of Alembic primitives.
92 /// This is generally only useful for the viewport.
94 {
95 public:
96  GABC_PackedArchive(const UT_StringHolder &archive_name,
97  const GT_GEODetailListHandle &source_list,
98  const GABC_NAMESPACE::GABC_IArchivePtr &archive,
99  int index);
100 
101  virtual const char *className() const { return "GABC_PackedArchive"; }
102 
103  virtual bool bucketPrims(const GT_PackedAlembicArchive *prev_archive,
104  const GT_RefineParms *ref_parms,
105  bool force_update);
106 
107  virtual GT_PrimitiveHandle doSoftCopy() const { return nullptr; }
108 
109  int getIndex() const { return myIndex; }
110 
111 private:
112  virtual bool archiveMatch(const GT_PackedAlembicArchive *archive) const;
113 
115  int myIndex;
116 };
117 
118 /// Single Alembic shape (non-instanced)
120 {
121 public:
123  const GU_PrimPacked *prim,
124  const GT_DataArrayHandle &vp_mat,
125  const GT_DataArrayHandle &vp_remap,
126  bool build_packed_attribs = false);
127 
129  virtual ~GABC_PackedAlembic();
130 
131  virtual void initVisAnim();
132 
133  virtual const char *className() const { return "GABC_PackedAlembic"; }
135  { return new GABC_PackedAlembic(*this); }
136 
137  virtual GT_PrimitiveHandle getPointCloud(const GT_RefineParms *p,
138  bool &xform) const;
139  virtual GT_PrimitiveHandle getFullGeometry(const GT_RefineParms *p,
140  bool &xform) const;
141  virtual GT_PrimitiveHandle getBoxGeometry(const GT_RefineParms *p) const;
142  virtual GT_PrimitiveHandle getCentroidGeometry(const GT_RefineParms *p) const;
143 
144  virtual bool canInstance() const { return true; }
145  virtual bool getInstanceKey(UT_Options &options) const;
146  virtual GT_PrimitiveHandle getInstanceGeometry(const GT_RefineParms *p,
147  bool ignore_visibility=false) const;
148  virtual GT_TransformHandle getInstanceTransform() const;
149 
150  virtual bool isVisible();
151 
152  virtual bool refine(GT_Refine &refiner,
153  const GT_RefineParms *parms=NULL) const;
154 
155  virtual bool getCachedGeometry(GT_PrimitiveHandle &ph) const;
156 
157  virtual void getCachedTransform(GT_TransformHandle &ph) const;
158  virtual void getCachedVisibility(bool &visible) const;
159 
160  virtual GT_TransformHandle getLocalTransform() const;
161 
162  virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
163  const GT_RefineParms &refine);
164 private:
165  int64 myColorID;
166  UT_Matrix4D myTransform;
167  mutable GABC_AlembicCache myCache;
168 };
169 
170 /// Packed instance with alembic extensions
172 {
173 public:
176  GABC_PackedInstance(const GT_PrimitiveHandle &geometry,
178  GEO_AnimationType animation,
179  const GT_GEOOffsetList &packed_prim_offsets=GT_GEOOffsetList(),
183  virtual ~GABC_PackedInstance();
184 
185  virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
186  const GT_RefineParms &refine);
187 
188 private:
189  mutable UT_Array<GABC_AlembicCache> myCache;
190 };
191 
192 }; // GABC_NAMESPACE
193 
194 #endif
Single Alembic shape (non-instanced)
png_infop int transforms
Definition: png.h:2591
virtual GT_PrimitiveHandle endCollecting(const GT_GEODetailListHandle &geometry, GT_GEOPrimCollectData *data) const
UT_IntrusivePtr< GT_AttributeList > GT_AttributeListHandle
Definition: GT_Handles.h:24
Collector for packed primitives.
Definition: GABC_PackedGT.h:68
virtual GT_PrimitiveHandle collect(const GT_GEODetailListHandle &geo, const GEO_Primitive *const *prim_list, int nsegments, GT_GEOPrimCollectData *data) const
Packed instance with alembic extensions.
Single Alembic shape (non-instanced)
#define GABC_NAMESPACE
Definition: GABC_API.h:42
Collection data container.
Instanced alembic primitive.
long long int64
Definition: SYS_Types.h:107
virtual GT_GEOPrimCollectData * beginCollecting(const GT_GEODetailListHandle &geometry, const GT_RefineParms *parms) const
GEO_AnimationType
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
GLboolean * data
Definition: glcorearb.h:130
GA_API const UT_StringHolder transform
virtual GT_PrimitiveHandle doSoftCopy() const
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
A map of string to various well defined value types.
Definition: UT_Options.h:42
GLuint index
Definition: glcorearb.h:785
#define GABC_API
Definition: GABC_API.h:37
virtual GT_PrimitiveHandle doSoftCopy() const
virtual const char * className() const
virtual bool canInstance() const
UT_SharedPtr< GT_GEODetailList > GT_GEODetailListHandle
virtual const char * className() const
GLenum src
Definition: glcorearb.h:1792