sibarrick Posted July 13, 2005 Share Posted July 13, 2005 (edited) As far as I know, a null pointer is simply the value 0 (zero). So I'm thinking he means something like this: prefarr(gdp,0); 19463[/snapback] I'll try it when I get home, if it is that why the blue blazes doesn't it initialise to 0 if you don't specify it. Would've saved me hours of reading. Oh well I learnt some stuff anyway. Yup, 0 does it. grrrrrr.... all so simply once you know how. Well definitely one to watch out for in the future. Edited July 13, 2005 by sibarrick Quote Link to comment Share on other sites More sharing options...
George Posted July 14, 2005 Share Posted July 14, 2005 Yeah, GB_PointRefArray's constructor doesn't have a default parameter for the GB_Group (but GEO_PointRefArray has one for the mask -- so you could do: GEO_PointRefArray ptrefarr(gdp); and that should work also). Default parameters are useful when used properly, but they are a hit and miss with programmers, some people like them, others hate them. didn't try giving it a null pointer cos I thought that was *bad* Dereferencing a NULL pointer is bad, but you can still query it to see if it is NULL before you dereference it. That way they can be useful as optional parameters. So you can write a method that takes a particular parameter if the user wants to supply it, but can work more generally if the user doesn't care and just passes NULL. Your methods have to be careful and check for NULL. If you don't want an optional parameter and want pass-by-reference semantics in C++, it's probably best to use references (or const references). Take care, George. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted July 14, 2005 Share Posted July 14, 2005 (edited) Yeah, GB_PointRefArray's constructor doesn't have a default parameter for the GB_Group (but GEO_PointRefArray has one for the mask -- so you could do:GEO_PointRefArray Edited July 14, 2005 by sibarrick Quote Link to comment Share on other sites More sharing options...
George Posted July 15, 2005 Share Posted July 15, 2005 No your right, the first thing I tried was GB_Group not GEO_PointRefArray, i never thought of trying GEO_PointRefArray that way cos GB_Group had already failed, doh!So near yet so far. 19491[/snapback] Great! So you got it to work the way you like? George. Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 20, 2005 Share Posted July 20, 2005 I hope it won't sound too abstract. Imagine we have created several duplicates of our geometry before editing it in a cook method. Will it be posiible to, for example, create a vector between the points of these two different copies of the geometry? No, I don't actually need this - I am just curious. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted July 20, 2005 Share Posted July 20, 2005 I don't see why not. In fact I think there is a function built in to do just that #define FOR_PAIRS_OF_POINTS(gdp1, ppt1, gdp2, ppt2) Given you can get a point from both gdp's you can build the vector between them. Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 20, 2005 Share Posted July 20, 2005 Thanks, Sibarrick, btw, how's your Fast Occlusion stuff doing so far? Quote Link to comment Share on other sites More sharing options...
sibarrick Posted July 20, 2005 Share Posted July 20, 2005 I stopped after doing the vex implimentation, I'm not going to persue it any further at the moment as I've uncovered some other things I'd like to look at. Hopefully hoknamahn will share when he's finished Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 21, 2005 Share Posted July 21, 2005 Ok, folks I need to put a face's normal into a "central point" that I've created and placed it in the center of a face (who could've guessed! ) I mean my "central point" doesn't have a normal (I suppose) - at least I don't see it in Houdini. Or it is 0, 0, 0. I a not sure. So I need to create its normal and make it the same as face's normal. How can I do it? Thanks. Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 21, 2005 Share Posted July 21, 2005 Ok, I did that. It was relatively easy - just find out a couple of methods and it's ok: (if somebody, like me, might be interested - here's the code) gdp->normal(); int nml_index = gdp->findPointAttrib("N", sizeof(UT_Vector3), GB_ATTRIB_VECTOR); ... face_normal = prim->computeNormal(); chNml = (UT_Vector3 *)ppt->getAttribData(nml_index); *chNml = face_normal; ============================================= Another question: Is there some way to find out the distance between a point and the nearest edge? (With a condition that the point doesn't lie on an edge) Thanks. Quote Link to comment Share on other sites More sharing options...
davedjohnson Posted July 21, 2005 Share Posted July 21, 2005 Or if it is on an edge, the distance would be 0. Dave Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted July 21, 2005 Share Posted July 21, 2005 Is there some way to find out the distance between a point and the nearest edge? (With a condition that the point doesn't lie on an edge) I'd first look at the vector classes for vector-like operations like that. A quick scan of UT_Vector3 reveals: A free-floating (i.e: non-member) function which returns the square distance between a point (pos) and a line segment (pt1,pt2): inline fpreal segmentPointDist2( const UT_Vector3 &pos, const UT_Vector3 &pt1, const UT_Vector3 &pt2 ); And one member function which returns the signed distance between itself and a segment: fpreal UT_Vector3::distance(const UT_Vector3 &p1, const UT_Vector3 &v1) const; So I'm guessing you could use whichever's more convenient. The closest segment would be a matter of running the above for all edges and keeping the one whose distance has the smallest magnitude (watch out for "signed" distances in the case of the member function). (oh, btw, a "point", in the geometry-detail sense, contains a UT_Vector4, which can be reinterpreted as UT_Vector3, then the above applies... though it would be nicer if they made those functions available in hte UT_Vector4 class too...) Hope that helps, Cheers! Quote Link to comment Share on other sites More sharing options...
sibarrick Posted July 21, 2005 Share Posted July 21, 2005 Hey Madjestic wha'ya working on? Is it for private or public use? Like Mario says HDK is exploding!!! by Houdini standards anyway. Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 21, 2005 Share Posted July 21, 2005 thanks, fellas. You are helping alot. Sibarrik, Whatever I make will be community accessible as soon as it is usable enough. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted July 21, 2005 Share Posted July 21, 2005 Intriguing Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 21, 2005 Share Posted July 21, 2005 Hello again, the code is simple and it must work, I suppose, but it doesn''t for some reason:(it is supposed to add "central points" to emit_gdp and rewrite gdp) GU_Detail *emit_gdp = new GU_Detail(); if (lockInputs(context) >= UT_ERROR_ABORT) return error(); now = context.myTime; duplicateSource(0, context); FOR_ALL_PRIMITIVES(gdp, prim) { pos = prim->baryCenter(); ppt = emit_gdp->appendPoint(); ppt->getPos() = pos; } gdp->clearAndDestroy(); gdp = emit_gdp; // or gdp->merge(*emit_gdp); - it doesn't work either unlockInputs(); return error(); } what could be wron woth that? The current result is 0 geoetry - 0 points, 0 primitives, etc. Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 21, 2005 Share Posted July 21, 2005 And yes I am sure that the points are created in emit_gdp - coz if I don't clearAndDestroy my gdp and just merge'em - I see the 2 geos merged all right. gdp->merge(*emit_gdp); But actually what I need is to get rid of the initial gdp and substitute it with the new emit_gdp. Thanks. Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 22, 2005 Share Posted July 22, 2005 Sorry, folks, mysteriously it started to work fine, when I decided to recompile it another time.. wtf?.. Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 22, 2005 Share Posted July 22, 2005 Is there an easy way to Clamp a value in HDK, the same as Clamp VOP or Clamp VEX function works? (to clamp my_var, say, between 0 and 1) Or should I use just maths?, soething like: if (tmp<0)tmp=0; if (tmp>1)tmp=1; ================ and the same question about max( a , b ); function. Is there such in HDK? Thanks Quote Link to comment Share on other sites More sharing options...
MADjestic Posted July 22, 2005 Share Posted July 22, 2005 It's strange - but the vector.length(); seems to return a noralized vector no matter it was NOT normalized. rP = ppt->getPos(); eP = emit_ppt->getPos(); rvec = eP - rP; rvec.length(); //returns a result of 1; nrvec = rvec.normalize(); nrvec.length(); //returns a result > 1; that's weird, isn't it? Is it a normal behaiviour or I did something wrong? 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.