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  ~GABC_CollectPacked() override;
73 
74  /// @{
75  /// Interface defined for GT_GEOPrimCollect
78  const GT_RefineParms *parms) const override;
81  const GEO_Primitive *const* prim_list,
82  int nsegments,
83  GT_GEOPrimCollectData *data) const override;
85  endCollecting(const GT_GEODetailListHandle &geometry,
86  GT_GEOPrimCollectData *data) const override;
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  const char *className() const override { return "GABC_PackedArchive"; }
102 
103  bool bucketPrims(const GT_PackedAlembicArchive *prev_archive,
104  const GT_RefineParms *ref_parms,
105  bool force_update) override;
106 
107  GT_PrimitiveHandle doSoftCopy() const override { return nullptr; }
108 
109  int getIndex() const { return myIndex; }
110 
111 private:
112  bool archiveMatch(const GT_PackedAlembicArchive *archive) const override;
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  ~GABC_PackedAlembic() override;
130 
131  void initVisAnim() override;
132 
133  const char *className() const override
134  { return "GABC_PackedAlembic"; }
135 
137  { return new GABC_PackedAlembic(*this); }
138 
139  GT_PrimitiveHandle getPointCloud(const GT_RefineParms *p,
140  bool &xform) const override;
141  GT_PrimitiveHandle getFullGeometry(const GT_RefineParms *p,
142  bool &xform) const override;
143  GT_PrimitiveHandle getBoxGeometry(const GT_RefineParms *p) const override;
144  GT_PrimitiveHandle getCentroidGeometry(
145  const GT_RefineParms *p) const override;
146 
147  bool canInstance() const override { return true; }
148  bool getInstanceKey(UT_Options &options) const override;
149  GT_PrimitiveHandle getInstanceGeometry(const GT_RefineParms *p,
150  bool ignore_visibility=false) const override;
151  GT_TransformHandle getInstanceTransform() const override;
152 
153  bool isVisible() override;
154 
155  bool refine(GT_Refine &refiner,
156  const GT_RefineParms *parms=NULL) const override;
157 
158  bool getCachedGeometry(
159  GT_PrimitiveHandle &ph) const override;
160 
161  void getCachedTransform(
162  GT_TransformHandle &ph) const override;
163  void getCachedVisibility(bool &visible) const override;
164 
165  bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
166  const GT_RefineParms &refine) override;
167 private:
168  int64 myColorID;
169  UT_Matrix4D myTransform;
170  mutable GABC_AlembicCache myCache;
171 };
172 
173 /// Packed instance with alembic extensions
175 {
176 public:
179  GABC_PackedInstance(const GT_PrimitiveHandle &geometry,
180  const GT_TransformArrayHandle &transforms,
181  GEO_AnimationType animation,
182  const GT_GEOOffsetList &packed_prim_offsets=GT_GEOOffsetList(),
186  ~GABC_PackedInstance() override;
187 
188  bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
189  const GT_RefineParms &refine) override;
190 
191 private:
192  mutable UT_Array<GABC_AlembicCache> myCache;
193 };
194 
195 }; // GABC_NAMESPACE
196 
197 #endif
Single Alembic shape (non-instanced)
UT_IntrusivePtr< GT_AttributeList > GT_AttributeListHandle
Definition: GT_Handles.h:24
GT_PrimitiveHandle doSoftCopy() const override
Collector for packed primitives.
Definition: GABC_PackedGT.h:68
Packed instance with alembic extensions.
Single Alembic shape (non-instanced)
#define GABC_NAMESPACE
Definition: GABC_API.h:42
Collection data container.
Instanced alembic primitive.
bool canInstance() const override
GEO_AnimationType
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
long long int64
Definition: SYS_Types.h:116
const char * className() const override
GA_API const UT_StringHolder transform
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
GT_PrimitiveHandle doSoftCopy() const override
A map of string to various well defined value types.
Definition: UT_Options.h:84
GLuint index
Definition: glcorearb.h:786
#define GABC_API
Definition: GABC_API.h:37
GT_GEOPrimCollectData * beginCollecting(const GT_GEODetailListHandle &geometry, const GT_RefineParms *parms) const override
GT_PrimitiveHandle endCollecting(const GT_GEODetailListHandle &geometry, GT_GEOPrimCollectData *data) const override
UT_SharedPtr< GT_GEODetailList > GT_GEODetailListHandle
GT_PrimitiveHandle collect(const GT_GEODetailListHandle &geo, const GEO_Primitive *const *prim_list, int nsegments, GT_GEOPrimCollectData *data) const override
const char * className() const override
Definition: format.h:895
GLenum src
Definition: glcorearb.h:1793