Jump to content

Noob Question


doc

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...