JoshJ Posted February 11, 2015 Share Posted February 11, 2015 Hi, So I'm making my first steps into the HDK, having very minimal, casual c++ experience over the years. I successfully compiled some of the examples, and I'm experimenting with changing the demoVolumeSphere into a custom VRAY volume procedural. It's going well, except I can't figure out how to get any 3d noise working. I'm currently adjusting the vray_VolumeSphere::evaluate function. Here's my current code: included at the top is: #include <UT/UT_PNoise.h> --------------------------------------------- voidvray_VolumeSphere::evaluate(const UT_Vector3 &pos, const UT_Filter &, float, float, int idx, float *data) const { data[0] = -pos[1]+1 + UT_PNoise::noise1D(pos[0]); } --------------------------------------------- Correctly results in a 1d noise along the x axis. However, as soon as I attempt to use any of the 3d noise, I can't get the types, pointers, and references to cooperate. for example, when I use UT_PNoise::noise3D , I've tried every combination of * , &, etc I can think of for the inputs, but I always get an error message like: error: no matching function for call to ‘UT_PNoise::noise3D(UT_Vector3&, const UT_Vector3&, int)’ UT_PNoise::noise3D(dest,pos,1); I know I haven't mastered a lot of the c++ pointer concepts, but I'd like to learn by example and figuring it out, and I'll eventually get it. I looked through most of the HDK documentation though, and didn't find any example which could apply to this case. If someone could write out a simple example for UT_PNoise::noise3D with const UT_Vector3 &pos as an input, resulting in a 1d value, that would be awesome. Quote Link to comment Share on other sites More sharing options...
edward Posted February 11, 2015 Share Posted February 11, 2015 float x[3] = { pos(0), pos(1), pos(2) }; data[0] = UT_PNoise::noise3D(x); 1 Quote Link to comment Share on other sites More sharing options...
JoshJ Posted February 11, 2015 Author Share Posted February 11, 2015 Awesome, Thanks edward, it worked. Now I'm experimenting with UT_Noise::turbulence , which doesn't have the float x[3] input. Instead it has , for example: fpreal turbulence( const UT_Vector3 &pos, unsigned fractalDepth, fpreal rough = 0.5, fpreal atten = 1.0) const; I'm not sure what to put for the "const" entry after the end parenthesis. I've attempted to call it like this: const a = 0; fpreal x = UT_Noise::turbulence(pos,5) a; data[0] = -pos[1]+0.5 + x; which of course did not work, and I've tried a few variations and google searches about "error: cannot call member function ... const’ without object" So, what does it mean when "const" is after the function parenthesis, and how do I call this type of function correctly? also, for the void style of the function: void turbulence( const UT_Vector3 &pos, unsigned fractalDepth, UT_Vector3 &noise, fpreal rough = 0.5, fpreal atten = 1.0) const; Would I just create a UT_Vector3 variable beforehand, and enter it in like: UT_Vector3 dest;UT_Noise::turbulence(pos,5,dest); Then dest contains my noise as a UT_Vector3 object? Quote Link to comment Share on other sites More sharing options...
ranxerox Posted February 11, 2015 Share Posted February 11, 2015 the "const" after the member function name is just indicating that the function call won't affect the object it's a member of. You can safely ignore it in your case (ie. you don't have to pass anything in place of the 'const' keyword). -G Awesome, Thanks edward, it worked. Now I'm experimenting with UT_Noise::turbulence , which doesn't have the float x[3] input. Instead it has , for example: fpreal turbulence( const UT_Vector3 &pos, unsigned fractalDepth, fpreal rough = 0.5, fpreal atten = 1.0) const; I'm not sure what to put for the "const" entry after the end parenthesis. I've attempted to call it like this: const a = 0; fpreal x = UT_Noise::turbulence(pos,5) a; data[0] = -pos[1]+0.5 + x; which of course did not work, and I've tried a few variations and google searches about "error: cannot call member function ... const’ without object" So, what does it mean when "const" is after the function parenthesis, and how do I call this type of function correctly? also, for the void style of the function: void turbulence( const UT_Vector3 &pos, unsigned fractalDepth, UT_Vector3 &noise, fpreal rough = 0.5, fpreal atten = 1.0) const; Would I just create a UT_Vector3 variable beforehand, and enter it in like: UT_Vector3 dest;UT_Noise::turbulence(pos,5,dest); Then dest contains my noise as a UT_Vector3 object? Quote Link to comment Share on other sites More sharing options...
JoshJ Posted February 11, 2015 Author Share Posted February 11, 2015 thanks ranxerox, that helps. I figured out that UT_Noise needs to be instanced as an object like this: UT_Noise anoise; data[0] = -pos[1]+0.5 + anoise.turbulence(pos,5,0.5,0.5); Now it works. Quote Link to comment Share on other sites More sharing options...
JoshJ Posted February 11, 2015 Author Share Posted February 11, 2015 (edited) How do I use the enum values for the noise? UT_Vector3 x = {pos(0),0,pos(2)}; UT_Noise anoise; // set the noise type here to alligator using an enum, like: // anoise.setType(UT_Noise::UT_NoiseType(ALLIGATOR)); // which gives the error: ‘ALLIGATOR’ was not declared in this scope data[0] = -pos[1]+0.5+ anoise.turbulence(x,3,0.5,0.5)*0.1; Edit: Ok, I solved it, anoise.setType(UT_Noise::UT_NoiseType::ALLIGATOR); Edited February 11, 2015 by JoshJ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.