Issues with creating HDK attributes

   1107   7   2
User Avatar
Member
40 posts
Joined: Oct. 2012
Offline
Hey all,
I am having problems creating attributes in HDK. The attribute I create shows up on the first frame(which is when i create it) and then disappears in the rest of the frames. Please check the cookmySop function. I am pretty sure I am doing something stupid.
Currently what I want is to take my geometry and create a spring force . So for the first step I am trying to setup my velocity, position and force attributes. So I copy my sourceGeometry into my gdp and try to manipulate the points there as per the examples.
Please help me out as I am completely lost as to why this is happening.
here is a snippet.

mySource = inputGeo(0,context);
duplicateSource(0,context);

//gdp->copy(mySource,GEO_COPY_ONCE);

flags().timeDep = 1;
CH_Manager *chman = OPgetDirector()->getChannelManager();
fpreal frame = chman->getSample(context.getTime());
fpreal reset = STARTFRAME();
//frame = frame/30.0;

if (frame<=reset || !mySource) {
my_lastCookTime = reset;
//initSystem();
myPos = GA_RWHandleV3(gdp->findAttribute(GA_ATTRIB_POINT, “P”));
GA_RWHandleV3 attrib = gdp->findAttribute(GA_ATTRIB_POINT,“v”);
if ( gdp->getPointMap().indexSize() > 0 || !mySource) {
myVelocity = GA_RWHandleV3(gdp->addFloatTuple(GA_ATTRIB_POINT,“v”,3));
//myVelocity = GA_RWHandleV3(gdp,GA_ATTRIB_POINT, “v”);
if(myVelocity.isValid()){
myVelocity.getAttribute()->setTypeInfo(GA_TYPE_VECTOR);
myVelocity->setTupleSize(3);
UT_Vector3 V;
for (GA_Iterator it(gdp->getPointRange()); !it.atEnd(); ++it) {
GA_Offset offset = *it;
UT_Vector3 V = UT_Vector3(0,0,0);
myVelocity.set(offset,UT_Vector3(0,0,0));
cout << “velocity2: ” << myVelocity->getTupleSize() <<endl;
}
}
}

}
else
{
frame += 0.05;//tollerance
//notifyGroupParmListeners(0,-1,mySource,NULL);
while (my_lastCookTime < frame)
{

cout << “velocity3: ” << myVelocity->getTupleSize() <<endl;
timeStep(chman->getSample(my_lastCookTime));
my_lastCookTime += 1;

}
}

Attachments:
Project4.zip (3.1 KB)

User Avatar
Member
818 posts
Joined: Sept. 2013
Offline
Since you call duplicateSource() every frame, the gdp is set to the input geo every frame, which doesn't have the velocity attribute.
Edited by - Nov. 5, 2015 18:42:07
Andrew / アンドリュー
User Avatar
Member
40 posts
Joined: Oct. 2012
Offline
WOW!! That did it!! You are a beautiful man!!! Thank you!!!
User Avatar
Member
40 posts
Joined: Oct. 2012
Offline
Hey. It works but now i have geometry created every frame it seems. So I am getting a trail of geo when translating the geometry. Is there a way to delete previous points/geo.
User Avatar
Member
40 posts
Joined: Oct. 2012
Offline
Nevermind. I had inserted a gdp-> merge which was causing issues. Silly me. I am learning everyday!! Thanks for your help.
User Avatar
Member
818 posts
Joined: Sept. 2013
Offline
If you want to evolve the geometry, the recommended way is actually to use DOP. The SOP_SParticle is actually the old way of doing things.
Andrew / アンドリュー
User Avatar
Member
40 posts
Joined: Oct. 2012
Offline
Yeah for the next assignment I will be trying to implement DOPs (For rbds I would need it). But assignment requires me to calculate my own detection and forces. Is that still convenient to do it through dops?
Note: The original assignment is for open gl but I am implementing everything as plugins.
User Avatar
Staff
4516 posts
Joined: July 2005
Offline
Use a Solver SOP. This gives you the feedback ability with no requirement to have the SOP_Node require a cached GU_Detail, but lets you still write everything as SOPs.
  • Quick Links