HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tetprim/GR_PrimTetra.h
/*
* Copyright (c) 2024
* Side Effects Software Inc. All rights reserved.
*
* Redistribution and use of Houdini Development Kit samples in source and
* binary forms, with or without modification, are permitted provided that the
* following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. The name of Side Effects Software may not be used to endorse or
* promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __GR_PrimTetra__
#define __GR_PrimTetra__
namespace HDK_Sample
{
/// The primitive render hook which creates GR_PrimTetra objects.
class GR_PrimTetraHook : public GUI_PrimitiveHook
{
public:
~GR_PrimTetraHook() override;
/// This is called when a new GR_Primitive is required for a tetra.
/// gt_prim or geo_prim contains the GT or GEO primitive this object is being
/// created for, depending on whether this hook is registered to capture
/// GT or GEO primitives.
/// info and cache_name should be passed down to the GR_Primitive
/// constructor.
/// processed should return GR_PROCESSED or GR_PROCESSED_NON_EXCLUSIVE if
/// a primitive is created. Non-exclusive allows other render hooks or the
/// native Houdini primitives to be created for the same primitive, which is
/// useful for support hooks (drawing decorations, bounding boxes, etc).
const GEO_Primitive *geo_prim,
const GR_RenderInfo *info,
const char *cache_name,
) override;
};
/// Primitive object that is created by GR_PrimTetraHook whenever a
/// tetrahedron primitive is found. This object can be persistent between
/// renders, though display flag changes or navigating though SOPs can cause
/// it to be deleted and recreated later.
class GR_PrimTetra : public GR_Primitive
{
public:
const char *cache_name,
const GEO_Primitive *prim);
~GR_PrimTetra() override;
const char *className() const override { return "GR_PrimTetra"; }
/// See if the tetra primitive can be consumed by this primitive. Only
/// tetra from the same detail will ever be passed in.
int geo_type,
const GT_PrimitiveHandle &ph,
const GEO_Primitive *prim) override;
/// Called whenever the parent detail is changed, draw modes are changed,
/// selection is changed, or certain volatile display options are changed
/// (such as level of detail).
const GT_PrimitiveHandle &primh,
const GR_UpdateParms &p) override;
/// Called whenever the primitive is required to render, which may be more
/// than one time per viewport redraw (beauty, shadow passes, wireframe-over)
/// It also may be called outside of a viewport redraw to do picking of the
/// geometry.
GR_RenderMode render_mode,
GR_DrawParms dp) override;
const GR_DecorationParms &parms) override;
const GR_DisplayOption *opt,
unsigned int pick_type,
GR_PickStyle pick_style,
bool has_pick_map) override;
private:
int myID;
RE_Geometry *myGeo;
bool myInstancedFlag;
};
} // End HDK_Sample namespace.
#endif