eko Posted August 26, 2014 Share Posted August 26, 2014 (edited) Hi, I got a question about doing simulation in sop.(Because I don't have a master license).Accoding to the thread http://forums.odforce.net/topic/4310-hdk-sop-sim-cook-problem/?hl=timedep.I rewrite the code. OP_ERROR SOP_TEST::cookMySop(OP_Context &context) { long frame; int initframe; UT_Interrupt *boss; myGroup=0; fpreal now = context.getTime(); frame = context.getFrame(); GA_Offset ptoff; fpreal mx = MaxDis(now); if (lockInputs(context) >= UT_ERROR_ABORT) return error(); OP_Node::flags().timeDep = 1; ///////// initframe = 1; if (error() < UT_ERROR_ABORT) { if(frame == initframe) { boss = UTgetInterrupt(); boss->opStart("Initializing"); gdp->clearAndDestroy(); duplicateSource(0, context); boss->opEnd(); } else { boss = UTgetInterrupt(); boss->opStart("Setting new grid positions"); GA_FOR_ALL_GROUP_PTOFF(gdp, myGroup, ptoff) { if (boss->opInterrupt()) break; UT_Vector3 pos=gdp->getPos3(ptoff); pos[1]+=mx; gdp->setPos3(ptoff,pos); } boss->opEnd(); } } unlockInputs(); myCurrPoint = -1; return error(); } This all works fine when I play though the frames sequentially. If I jump forward in the time bar 20 frames, right now it only cooks the 20th frame and doesn't automatically cook all the frames in between(like the particle sop does)(like the particle sop does). It seemed like it only do a cook when the frame changes. What I got to do is to cook all the frame between the 20 frames.I got some ideas from HDK documents cook_time = myLastCookTime; for ( ; cook_time <= now ; cook_time += frame_inc) { context.setTime(cook_time); ......... } But I dont know how to get the "myLastCooktime". Does Anyone got a Idea? And another strange thing is when I change the Parameter((MaxDis), it will also do the cook which I dont want. Thanks Edited August 26, 2014 by eko Quote Link to comment Share on other sites More sharing options...
sibarrick Posted August 26, 2014 Share Posted August 26, 2014 I've never actually tried this so I don't know if fundamentally what you are doing is the right way to do it. But purely from what you have already posted, wouldn't you just say myLastCookTime starts at 1 or some user defined sim start point, and then once your cook loop has run just set it equal to "now" ready for the next jump in time. You'll probably need to reset it to 1 again if myLastCookTime > now. Quote Link to comment Share on other sites More sharing options...
eko Posted August 27, 2014 Author Share Posted August 27, 2014 Thanks for your reply. if myLastCookTime > now. I will do nothing. I need to keep the lastest cook result. It's just like the spring sop node. If I jump forward to 120f. It will automatically cook all the frames in between 120f and then When I jump back to 50f. It will keep the result same with 120f Quote Link to comment Share on other sites More sharing options...
eko Posted August 29, 2014 Author Share Posted August 29, 2014 Hi,there I find the way! myLastCookTime=CHgetEvalTime(); It works fine to me. Another question, does anyone knows how to get the points connected to the given point in hdk13? Thanks! 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.