time change check?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/11/2012 at 21:07, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 13
Platform: Windows ;
Language(s) : C++ ;---------
I'm still new and asking a very simple question ...I want to check the time change (via play...drag...any change in the document time) ...
what i tried and gives me crashes :BaseTime time = doc->GetTime();
GvCalcTime* H;
BaseTime G = H->previous;
if (time.TimeDif(G) != 0)
{
GePrint("A");
} -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2012 at 05:00, xxxxxxxx wrote:
You never allocated GvCalcTime* H. The memory location it points to is invalid.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2012 at 06:40, xxxxxxxx wrote:
so what should i do? didn't find any call to store previous time
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2012 at 09:52, xxxxxxxx wrote:
I don't know what the GvCalcTime class is for, but it is definitely not what you want. As the SDK states, the class cannot be instantiated. What about just storing the previous time somewhere?
BaseTime current_time = doc->GetTime(); if (current_time == this->previous_time) { GePrint("A"); this->previous_time = current_time; }
This code-snippet implies that you have given your plugin-class an attribute BaseTime previous_time. Also, using BaseTime:: operator ==() operator is equal to checking if BaseTime::TimeDif() returns zero.
Best,
Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2012 at 13:13, xxxxxxxx wrote:
well i did that ...but the problem is it acts one time when i execute the plugin ...i need it to check always (not once)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2012 at 23:42, xxxxxxxx wrote:
What kind of plugin is it?
CommandData, ObjectData, TagData, SceneHookData, oder something else? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2012 at 01:29, xxxxxxxx wrote:
Originally posted by xxxxxxxx
well i did that ...but the problem is it acts one time when i execute the plugin ...i need it to check always (not once)
'Always' is too vague. Do you mean once per frame, every x milliseconds or what? As Jack implied in his post, it makes a real difference, depending on the plugin type. If it's a CommandData, you could use the SetTimer() and Timer() functions in GeDialog. If it's not, it'll depend on the type of plugin (e.g for an ObjectData plugin, you could check the time in Execute(), for example).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2012 at 02:45, xxxxxxxx wrote:
well the plugin (task) is to do a physics simulation (my custom physics calculations)
i want to do one step of calculations if only (frame change) so for example it doesn't change object state while time is paused(only when user drags the slider or change time it will calculate 1 step of simulation)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2012 at 06:25, xxxxxxxx wrote:
Right, so it's code that needs to be called on a frame change. Let's say you have an ObjectData plugin, you could test the frame number in the Execute() function, which will always be called at least once per frame. The easiet way to do this is to have a class-level variable which holds the number of the most recent frame before a frame change occurred. The code might look something like this:
EXECUTIONRESULT MyPlugin::Execute(BaseObject *op, BaseDocument *doc, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags) { LONG frame, startFrame, fps; fps = doc->GetFps(); startFrame = doc->GetMinTime().GetFrame(fps); // find start frame frame = doc->GetTime().GetFrame(fps); // get current frame if(frame == startFrame) { oldFrame = startFrame; // <----- oldFrame is a class-level LONG // now do whatever else might be needed in the first frame of the animation // do stuff here... } // if the user has changed the frame in some way if(frame != oldFrame) { // update whatever is needed following the frame change // do stuff here... // note that this won't be done in the first frame because there, frame == oldFrame // now reset oldFrame so these actions aren't done again in this frame oldFrame = frame; } return EXECUTIONRESULT_OK; }
The code is therefore only carried out when the frame changes. At the start frame of the animation, you might need to do other stuff, like initialising data structures or something, so that frame is treated separately.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2012 at 09:18, xxxxxxxx wrote:
wow, thanks a lot for this help spedler , what i was missing that execute() which checks each frame
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2012 at 15:30, xxxxxxxx wrote:
tested it now ..worked like a charm
thank you again for the help