35 using namespace HDK_Sample;
84 return "RAY_DemoMountain";
90 uint seed = 0xbabecafe;
92 myP[0].
assign(-1, -1, 0, seed);
94 myP[1].
assign( 1, -1, 0, seed);
96 myP[2].
assign( 0, -1, 0, seed);
99 import(
"p0", myP[0].
pos.
data(), 3);
100 import(
"p1", myP[1].
pos.
data(), 3);
101 import(
"p2", myP[2].
pos.
data(), 3);
106 RAY_DemoMountain::computeBounds(
UT_BoundingBox &box,
bool include_displace)
111 if (include_displace)
122 computeBounds(box,
true);
141 computeBounds(box,
false);
164 disp = SYSfastRandomZero(seed)*
scale;
177 scale = 1.0 / (
fpreal)mySplits;
178 for (i = 0; i < 4; i++)
181 for (i = 0; i < 3; i++)
183 kids[i]->myP[0] = myP[i];
184 edgeSplit(kids[i]->myP[1], myP[i], myP[(i+1)%3], scale);
186 for (i = 0; i < 3; i++)
188 kids[3]->myP[i] = kids[(i+1)%3]->myP[2] = kids[i]->myP[1];
190 for (i = 0; i < 4; i++)
193 child->addProcedural(kids[i]);
208 clr.
x() = SYSfastRandom(seed);
209 clr.
y() = SYSfastRandom(seed);
210 clr.
z() = SYSfastRandom(seed);
215 for (
int i = 0; i < 3; i++)
222 child->addGeometry(geo);
~RAY_DemoMountain() override
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
RAY_ProceduralGeo createGeometry() const
Allocate geometry for this procedural.
T distance3d(const UT_Vector3T< T > &p1, const UT_Vector3T< T > &p2)
Compute the distance between two points.
int initialize(const UT_BoundingBox *) override
void fractalSplit()
Split into 4 new procedurals (each rendering a triangle)
constexpr SYS_FORCE_INLINE T & z() noexcept
Procedural primitive for mantra (RAY)
GA_Attribute * addDiffuseAttribute(GA_AttributeOwner who, GA_Storage s=GA_STORE_INVALID)
bool insert(ProcDefinition *def, bool replace_existing=true)
void getBoundingBox(UT_BoundingBox &box) override
The bounding box is the "object space" bounds of the procedural.
constexpr SYS_FORCE_INLINE const T * data() const noexcept
SYS_FORCE_INLINE void expandBounds(T relative, T absolute)
GA_API const UT_StringHolder Cd
GA_API const UT_StringHolder scale
static GU_PrimPoly * build(GA_Detail *gdp, int npts, int open=0, int appendpts=1)
RAY_ProceduralChildPtr createChild() const
void enlargeBounds(const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
void assign(fpreal x, fpreal y, fpreal z, uint s)
Parameter definition for arguments to RAY_Procedural.
const char * className() const override
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
SYS_FORCE_INLINE GA_Offset getMapOffset() const
Gets the offset of this primitive in the detail containing it.
OIIO_UTIL_API std::vector< std::string > splits(string_view str, string_view sep="", int maxsplit=-1)
void fractalRender()
Render triangle geometry.
SYS_FORCE_INLINE void initBounds()
RAY_DemoMountain(int splits=1)
RAY_ProceduralArg * arguments() const override
Provide a const reference to the arguments for the procedural.
RAY_Procedural * create() const override
Create a procedural, and pass ownership of the instance to mantra.
constexpr SYS_FORCE_INLINE T & y() noexcept
GU_Detail * get(int segment=0) const
Class to create a procedural.
void registerProcedural(RAY_ProceduralFactory *factory)
Modern interface to register procedurals.
constexpr SYS_FORCE_INLINE T & x() noexcept