45 #define SPRITE_LIMIT 1000
46 #define META_CORRECT 0.5
47 #define DEFAULT_ATTRIB_PATTERN ""
48 #define DEFAULT_SIZE 0.05F
51 namespace HDK_Sample {
64 using namespace HDK_Sample;
128 if (
name.multiMatch(pattern))
176 myParms = sprite->myParms;
188 for (
exint i = 0; i < sprite->myPointList.
entries(); ++i)
190 GA_Index idx = sprite->myPointList(i);
209 getRoughSpriteBox(tbox, tvbox, *gdp, ptoff, sprite_scale,
272 if (
import(
"object", str))
273 name = str.
isstring() ? (
const char *)str : 0;
280 name = queryObjectName(handle);
282 gdp = myParms->
myGdp = parent_geo.
get();
291 if (!
import(
"object:velocityscale", &myParms->
myTimeScale, 1))
295 import(
"object:velocityblur", &vblur, 1);
325 import(
"velocity", str);
330 RAYwarning(
"%s object (%s) couldn't find the '%s' attribute",
344 getRoughSpriteBox(tbox, tvbox, *gdp, ptoff, sprite_scale,
367 import(
"attribute", str);
429 convertPath(
const char *src_path,
const char *
path,
UT_String &full_path)
431 if (path && strlen(path) > 0 && path[0] !=
'/')
433 full_path = src_path;
506 uMax = txt.
x()+txt.
z();
507 vMax = txt.
y()+txt.
z();
526 ::transformPoint(*gdp, ptoff, -
size.x(), -
size.y(), xform);
533 ::transformPoint(*gdp, ptoff,
size.x(), -
size.y(), xform);
540 ::transformPoint(*gdp, ptoff,
size.x(),
size.y(), xform);
547 ::transformPoint(*gdp, ptoff, -
size.x(),
size.y(), xform);
558 convertPath(srcpath, path, full_path);
564 applyMapToPrimitive(parms.
myAttribMap, dest_attribs,
585 for (
int j = 0;
j < 4;
j++)
598 if (divs < 1) divs = 1;
599 else if (divs > 4) divs = 4;
612 fpreal xinc, yinc, zinc, factor;
628 xinc = myBox.
sizeX();
629 yinc = myBox.
sizeY();
630 zinc = myBox.
sizeZ();
633 dfactor = (xinc+yinc+zinc)/max;
634 factor = SYSpow((
fpreal)myPointList.
entries() / sprite_limit,
643 nx = ::computeDivs(xinc, max);
644 ny = ::computeDivs(yinc, max);
645 nz = ::computeDivs(zinc, max);
647 if (nx == 1 && ny == 1 && nz == 1)
651 if (xinc > zinc) nx = 2;
656 if (yinc > zinc) ny = 2;
665 for (iz = 0, zv = myBox.
vals[2][0]; iz < nz; iz++, zv += zinc)
667 for (iy = 0, yv = myBox.
vals[1][0]; iy < ny; iy++, yv += yinc)
669 for (ix = 0, xv = myBox.
vals[0][0]; ix < nx; ix++, xv += xinc)
679 child->addProcedural(kid);
696 if (makeSpritePoly(geo.
get(), getPointGdp(), myPointList, *myParms,
699 if (myParms->myVelH.isValid())
702 velocityMove(geo.
get(), vpos, getPointGdp(), myPointList,
703 myParms->myVelH, getTime());
706 obj->addGeometry(geo);
GA_Attribute * appendSegmentAttribute(fpreal shutter, const char *name="P")
void registerProcedural(RAY_ProceduralFactory *factory)
Modern interface to register procedurals.
RAY_ROProceduralGeo queryGeometry(RAY_ObjectHandle handle) const
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
Definition of a geometry attribute.
GA_ROHandleV3 mySpriteTexH
virtual bool copy(GA_Attribute &d, GA_Offset di, const GA_Attribute &s, GA_Offset si) const =0
Copy attribute values for a single element.
SYS_FORCE_INLINE const GA_AttributeDict & pointAttribs() const
GLdouble GLdouble GLint GLint const GLdouble * points
RAY_ProceduralGeo createGeometry() const
Allocate geometry for this procedural.
bool collapseAbsolutePath(bool file_path=false)
void scale(T sx, T sy, T sz)
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
RAY_ObjectHandle queryObject(const char *name) const
void clear()
Clear the handle.
SYS_FORCE_INLINE bool atEnd() const
int initialize(const UT_BoundingBox *box) override
UT_Vector3T< float > UT_Vector3
GLsizei const GLchar *const * path
GA_ROHandleT< UT_Vector2F > GA_ROHandleV2
Reference counted geometry handle for procedurals.
constexpr SYS_FORCE_INLINE T & z() noexcept
SYS_FORCE_INLINE bool isValid() const
Procedural primitive for mantra (RAY)
SYS_FORCE_INLINE const HOLDER & get(GA_Offset off, int comp=0) const
Get the string at the given offset.
void setCapacity(exint new_capacity)
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
bool insert(ProcDefinition *def, bool replace_existing=true)
GA_API const UT_StringHolder P
Standard user attribute level.
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
~RAY_DemoSprite() override
void translate(const UT_Vector3T< T > &delta)
Adds the given translate to each component of the bounding box.
SYS_FORCE_INLINE iterator begin(GA_AttributeScope scope=GA_SCOPE_INVALID) const
GA_ROHandleT< UT_Vector3F > GA_ROHandleV3
SYS_FORCE_INLINE const UT_StringHolder & getName() const
GA_RWHandleT< UT_Vector3F > GA_RWHandleV3
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
SYS_FORCE_INLINE void expandBounds(T relative, T absolute)
constexpr SYS_FORCE_INLINE T & x() noexcept
const char * buffer() const
GA_API const UT_StringHolder scale
SYS_FORCE_INLINE void add(GA_Offset off, const T &val) const
const GA_Attribute * findStringTuple(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name, int min_size=1, int max_size=-1) const
const GA_IndexMap & getPointMap() const
SYS_FORCE_INLINE GA_Attribute * addPrimAttrib(const GA_Attribute *src)
GA_RWHandleTHolder< UT_StringHolder, GA_StringIndexType, GA_ATIString > GA_RWHandleS
GA_Attribute * addTextureAttribute(GA_AttributeOwner who, GA_Storage s=GA_STORE_INVALID)
GA_Offset appendPrimitiveBlock(const GA_PrimitiveTypeId &type, GA_Size nprimitives)
Append a contiguous block of primitives by GA_PrimitiveTypeId.
SYS_FORCE_INLINE GA_Offset appendPointBlock(GA_Size npoints)
Append new points, returning the first offset of the contiguous block.
GA_Size appendVertex(GA_Offset ptoff) override
GA_ROHandleT< fpreal32 > GA_ROHandleF
GA_ROHandleS mySpriteShopH
SYS_FORCE_INLINE T get(GA_Offset off, int comp=0) const
int initChild(RAY_DemoSprite *sprite, const UT_BoundingBox &box)
void identity()
Set the matrix to identity.
virtual void close(int rounded=1, int preserve_shape=0)
UT_Matrix3 myViewRotation
GLuint const GLchar * name
#define GA_FOR_ALL_PTOFF(gdp, ptoff)
T sizeMax() const
Return the size of the largest dimension.
SYS_FORCE_INLINE bool isInvalid() const
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
RAY_ProceduralChildPtr createChild() const
void enlargeBounds(const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
void prerotate(UT_Vector3T< S > &axis, T theta, int norm=1)
IMATH_HOSTDEVICE constexpr int divs(int x, int y) IMATH_NOEXCEPT
#define GEO_STD_ATTRIB_MATERIAL
SYS_FORCE_INLINE bool isValid() const
Parameter definition for arguments to RAY_Procedural.
exint entries() const
Alias of size(). size() is preferred.
const char * className() const override
const GA_Attribute * findFloatTuple(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name, int min_size=1, int max_size=-1) const
SYS_FORCE_INLINE const GA_Primitive * get(GA_Offset off) const
SYS_FORCE_INLINE void setPos3(GA_Offset ptoff, const UT_Vector3 &pos)
Set P from a UT_Vector3.
fpreal getLevelOfDetail(const UT_BoundingBox &box) const
void translate(T dx, T dy, T dz=0)
SYS_FORCE_INLINE bool isValid() const
Check whether the bounding box contains at least one point.
SYS_FORCE_INLINE void set(GA_Offset off, const T &val) const
SYS_FORCE_INLINE void set(GA_Offset off, const HOLDER &str) const
Store the str at the given offset.
SYS_FORCE_INLINE GA_Offset getMapOffset() const
Gets the offset of this primitive in the detail containing it.
void extractScales(UT_Vector3D &scales, UT_Vector3D *shears=0)
SYS_FORCE_INLINE GA_Offset offsetFromIndex(GA_Index ordered_index) const
SYS_FORCE_INLINE GA_Size getNumPrimitives() const
Return the number of primitives.
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
SYS_FORCE_INLINE void initBounds()
GA_ROHandleV2 mySpriteScaleH
const GA_PrimitiveList & getPrimitiveList() const
GA_ROHandleF mySpriteRotH
const char * queryRootName() const
Get the name of the object which owns this procedural.
UT_Matrix4D queryTransform(RAY_Handle handle, int sample) const
RAY_ProceduralArg * arguments() const override
Provide a const reference to the arguments for the procedural.
int isInside(const UT_Vector3T< T > &pt) const
Container class for all geometry.
Attribute Interface class to copy attribute data.
const GU_Detail * get(int segment=0) const
void leftMult(const UT_Matrix4T< T > &m)
RAY_Procedural * create() const override
Create a procedural, and pass ownership of the instance to mantra.
GA_ROHandleTHolder< UT_StringHolder, GA_StringIndexType, GA_ATIString > GA_ROHandleS
ray_SpriteAttribMap * myAttribMap
constexpr SYS_FORCE_INLINE T & y() noexcept
GU_Detail * get(int segment=0) const
virtual const GA_AIFCopyData * getAIFCopyData() const
Return the attribute's copy interface or NULL.
SYS_FORCE_INLINE GA_Offset pointOffset(GA_Index index) const
Given a point's index (in append order), return its data offset.
ray_SpriteAttribMap * myNext
void getBoundingBox(UT_BoundingBox &box) override
The bounding box is the "object space" bounds of the procedural.
Class to create a procedural.
const GA_Attribute * mySourceAttrib
constexpr SYS_FORCE_INLINE T & y() noexcept
void clipBounds(const UT_BoundingBoxT< T > &box)
Find the intersections of two bounding boxes.
SYS_FORCE_INLINE bool isstring() const
SYS_API fpreal32 SYSceil(fpreal32 val)
constexpr SYS_FORCE_INLINE T & x() noexcept
GA_Attribute * addStringTuple(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringHolder &name, int tuple_size, const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())