Passing Linked List to Renderer
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/08/2004 at 04:13, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.206
Platform:
Language(s) : C++ ;---------
Hello.My ObjectData plugin has a linked list. I need to pass this linked list to the external renderer.
My problem is that because the external renderer clones the document thus creating a new instance of my Objectata plugin. The linked list is also created as new, so its empty by the time the renderer access it.My code:
struct Node { LONG ID; Node *NextNode; }; class CCrashTest:public ObjectData { private: LONG m_OldFrame; LONG m_Counter; Node *m_NodeHead; void AddNode(Node n); public: //virtual Bool Init(GeListNode *node); virtual BaseObject* GetVirtualObjects(PluginObject *op, HierarchyHelp *hh); static NodeData *Alloc() { return gNew CCrashTest; } }; BaseObject *CCrashTest::GetVirtualObjects(PluginObject *op, HierarchyHelp *hh) { GePrint(LongToString(m_Counter)); BaseTime bt = hh->GetDocument()->GetTime(); LONG CurrentFrame = bt.GetFrame(hh->GetDocument()->GetFps()); if(CurrentFrame != m_OldFrame) { Node n; n.ID=m_Counter; AddNode(n); } m_OldFrame = CurrentFrame; return NULL; } void CCrashTest::AddNode(Node n) { Node *l_n = new Node; (*l_n) = n; l_n->NextNode=m_NodeHead; m_NodeHead = l_n; m_Counter++; }
When the frame changes, a new item is added to the linked list. the m_Counter variable keeps track on how many items are in the linked list. If I scrub to frame 30, the number 30 is printed in the console. While i'm at frame 30 and I click render to picture viewer, the number 0 is printed to the console because the linked list was reset.
I can fix this my making the linked list global, but this is not good as multiple instances of the plugin would fight over the global variables.
As anyone got an suggestions on how I can solve this?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/08/2004 at 05:51, xxxxxxxx wrote:
It has also come to my attention that I need to store this linked list into a basecontainer so other plugins can access this linked list.
I really can't see how I can store a linked list into a basecontainer, and the more I think about it the more i'm thinking on using a normal dynamic array instead of a linked list.
Then I could store the array into a basecontainer. That would means the array would be saved with the file, the external renderer could access the array through the container, and external plugins could access the array too.I'm not sure what to do now
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/09/2004 at 02:04, xxxxxxxx wrote:
To preserve member variables in plugin nodes you need to implement NodeData::Read()/Write()/CopyTo(). Then C4D will call these functions to let you copy the linked list before rendering.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/09/2004 at 02:21, xxxxxxxx wrote:
Thank you, thank you and thank you so much Mikael. I really hadn't the faintest idea on what to do. Time to read up on those three methods