doc Posted September 24, 2006 Share Posted September 24, 2006 I'm trying to add an attribute to my points and when I do the following: myLife = gdp->addPointAttrib("life", sizeof(float)*2, GB_ATTRIB_FLOAT, 0); I get the following error when I try to compile: SOP_Star.C:364: error: `myLife' undeclared (first use this function) so I changed my code to: gdp->addPointAttrib("life", sizeof(float)*2, GB_ATTRIB_FLOAT, 0); and it worked. I'm guessing that I have to declair and intialize "myLife" before I assign it a value, but what type does addPointAttrib return? Shoudln't the casting be implied? it certainly seems that way in the OP_SParticle.C example. Many thanks Luca Quote Link to comment Share on other sites More sharing options...
edward Posted September 24, 2006 Share Posted September 24, 2006 Notice how the myLife variable starts with the "my" prefix. This convention indicates that it is a private member variable and so its declaration can be found with SOP_SParticle's class definition in SOP_SParticle.h. If you look there, you can see that it's declared an int. The variable "gdp" is also a class member variable but unfortunately due to legacy reasons, it's not properly prefixed. It is declared as a GU_Detail pointer in SOP_SParticle's parent class, SOP_Node. Ok, so to find the signature for addPointAttrib, it's actually in GU_Detail's parent class, GEO_Detail. For some slight overview on this, see $HFS/toolkit/html/geometry/attribute.html. In short, the return value is an integer offset that says where the data is within the gdp's point attribute table. Having said all that, there's newer and better ways to access attributes. See GB_AttributeHandle. Unfortunately, for H9, it's been renamed to GEO_AttributeHandle. Quote Link to comment Share on other sites More sharing options...
doc Posted September 25, 2006 Author Share Posted September 25, 2006 thanks Ed 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.