Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search

Motion Blur

Author
Message
  Topic Search Topic Search
JohnaH View Drop Down
Member
Member
Avatar

Joined: 2014 Sep 02
Online Status: Offline
Posts: 23
Direct Link To This Post Topic: Motion Blur
    Posted: 2017 Dec 21 at 1:14pm

User Information:

Cinema 4D Version:   R14 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------


Hello,

I am working on a tag plugin that will change the position of a baseobject that it is placed on. When I just play through the timeline the tag successfully changes the position based on a vector that I store inside the tag's basecontainer. Every time that the Execute function runs the stored vector is increased by a set amount.
My problem comes in when I try to render out the scene with a Sub-Frame Motion Blur. It doesn't seem like the basecontainer is updated each time a sub-frame is run during the render process. In the render the baseobject doesn't have the motion blur because the baseobject's position is only updated a few times during the render.

This is a trimmed down version of the code.
EXECUTIONRESULT GorillaCamClass::Execute(BaseTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags)
{
if(!doc || !op)
return EXECUTIONRESULT_OK ;

BaseContainer data = tag->GetData();

Vector distanceVector = data.GetVector(idSavedVector);
distanceVector = distanceVector + Vector(20);
op->SetAbsPos(distanceVector);
data.SetVector(idSavedVector, distanceVector);
tag->SetData(data);
return EXECUTIONRESULT_OK;
}

When I bake the baseobject's position the render properly displays the Motion Blur.

Is there something that I am missing that would properly update the tag's basecontainer, any help would be greatly appreciated.


Johan H.


Edited by JohnaH - 2017 Dec 21 at 2:01pm
Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1143
Direct Link To This Post Posted: 2017 Dec 22 at 5:40am
Hi Johan,

How do you define idSavedVector in the code? Is it declared as a member variable?
Maybe the implementation of CopyTo() is missing. The function should ensure every class member is copied to the destination object plugin.
This issue has been already discussed here.

Also, inside TagData::Execute() we usually retrieve the object's data container with GetDataInstance() so that a parameter can be directly changed.



MAXON
Developer Support
Back to Top
JohnaH View Drop Down
Member
Member
Avatar

Joined: 2014 Sep 02
Online Status: Offline
Posts: 23
Direct Link To This Post Posted: 2017 Dec 22 at 9:20am
Hello Yannick,

I was under the impression that you needed to use CopyTo() if you weren't storing all of the necessary information inside the plugin's Basecontainer, which I am doing. My problem is that the Basecontainer doesn't seem to be storing my updated values during the rendering process. I define idSavedVector  as an enum value with a set id.

Thanks for the reply.

Johan H.


Edited by JohnaH - 2017 Dec 22 at 9:23am
Back to Top
JohnaH View Drop Down
Member
Member
Avatar

Joined: 2014 Sep 02
Online Status: Offline
Posts: 23
Direct Link To This Post Posted: 2018 Jan 11 at 8:49am
Hello,

I looked at the NodeData::CopyTo() Manual and it says that CopyTo() is only needed if internal data is not stored in the element's BaseContainer. In that forum post you linked they mention class-level variables needing to be copied by implementing CopyTo(). I have no class-level variables, all of my data is stored inside the element's BaseContainer,.

Johan H.
Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1143
Direct Link To This Post Posted: 2018 Jan 12 at 3:51am
Hi Johan,

Yes the issue isn't related to the implementation of NodeData::CopyTo().

In the code you posted, the distance vector is always incremented for each call of Execute() so you're relying on the scene execution mechanism.
Execute() may be called several times for the same frame, the current frame mayb not be the next of the previous executed one etc.

It's better to use the current time given from the passed BaseDocument* doc (with BaseDocument.GetTime()).



MAXON
Developer Support
Back to Top
JohnaH View Drop Down
Member
Member
Avatar

Joined: 2014 Sep 02
Online Status: Offline
Posts: 23
Direct Link To This Post Posted: 2018 Jan 31 at 9:42am
Hello Yannick,

I understand that I want to use BaseDocument.GetTime() to get the current time. My question still is that when I run a render with Sub-Frame Motion Blur the Basecontainer containing the vector is not updated each time Execute() is run. If Execute() is being called five times between frames than I would expect that the vector values would have increased five times. Instead the vector is only increased once.

Thanks for the reply.

Johan H.

Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1143
Direct Link To This Post Posted: 2018 Feb 02 at 11:08am
Hi,

As I already explained you shouldn't rely directly on the execution and render of a scene. This can be quite complex and the order of operations isn't guaranteed.

If you're really interested on calculating a value based on sub-frame motion blur, then you should use the time value given by doc->GetTime().Get().



MAXON
Developer Support
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.109 seconds.