Digital Art Zone

 
     
Saving Custom Data in .duf
Posted: 20 November 2012 05:43 AM   [ Ignore ]
Power Member
Avatar
RankRankRank
Total Posts:  1874
Joined  2006-02-17

I have a situation where I need to save custom data into the .duf file with the scene.  I can get an object to save, but I cannot seem to get any of the callbacks to execute to allow me to put my data into the “extra” sections.  Are there any examples on saving data that are completely foreign to DS,  but are critical for the plugin, to save in the scene’s .duf?

EDIT:  What would be more useful is a flow diagram on what is happening on .duf save/load and when/why, in the process, specific routines are called.

Also, what caveats should I watch for when (if) I can save the data, for reading it back out?

Kendall

 Signature 

Any opinions expressed in this post are those of Kendall Sears and may, or may not, be more, or less, valid than any other opinion.

The contents of this post are intended for the DAZ forum only, do not re-post any portion to any other forum without his permission.

Profile
 
 
Posted: 20 November 2012 06:43 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  15734
Joined  2003-10-09

Do these threads help:

http://www.daz3d.com/forums/viewthread/10728/
http://www.daz3d.com/forums/viewthread/11040/

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 24 November 2012 04:16 AM   [ Ignore ]   [ # 2 ]
Power Member
Avatar
RankRankRank
Total Posts:  1345
Joined  2009-10-27

Same problem for me. Some more examples, or detailed documentation would be very helpful.

 Signature 

Alessandro’s Store
Blog
LAMH FB

Profile
 
 
Posted: 26 November 2012 11:02 AM   [ Ignore ]   [ # 3 ]
Member
Rank
Total Posts:  106
Joined  2010-12-31
Kendall Sears - 20 November 2012 05:43 AM

I have a situation where I need to save custom data into the .duf file with the scene.  I can get an object to save, but I cannot seem to get any of the callbacks to execute to allow me to put my data into the “extra” sections.  Are there any examples on saving data that are completely foreign to DS,  but are critical for the plugin, to save in the scene’s .duf?

EDIT:  What would be more useful is a flow diagram on what is happening on .duf save/load and when/why, in the process, specific routines are called.

Also, what caveats should I watch for when (if) I can save the data, for reading it back out?

Kendall

lets call where you install the SDK to be SdkFolder, the following examples exists
- SdkFolder\samples\saving\customsceneelements
- SdkFolder\samples\saving\customscenedata
- SdkFolder\modifiers\DzBlackHole

customsceneelements shows the following custom elements
- custom DzNode
- custom DzModifier
- custom DzMaterial
- custom DzShape/DzGeometry combination

customscenedata shows a custom DzSceneData

DzBlackHole is a world space modifier(very esoteric, but it does show how the extra information radius is added to the Custom node.  Because the DzProperty is known to the system, it does not need custom save work.  In fact, all it needs is on read, the proper stuff to be created. Note: createNode() and applyInstancetoObject

————————————————————————————————————

I am assuming that you want a custom DzSceneData?

In any case, from a high level point of view, the write works something like this.
- gather all the scene assets in the scene that Studio can find(think IDzSceneAsset).  A custom DzNode will be found if it is added to the scene via dzScene->addNode.  If its not added to the scene, Studio does not know about it.
- assign ids and stuff to the assets.  In DSON, there are no pointers, so the issue of resolving assets becomes quite a bit of work and complexity.
- write out definitions
- write out instances
- write out animations

————————————————————————————————————

Kendall,

Do the samples not work for you?  Can you come up with a scenario that you would like a sample of?

Profile
 
 
Posted: 26 November 2012 11:15 AM   [ Ignore ]   [ # 4 ]
Power Member
Avatar
RankRankRank
Total Posts:  1874
Joined  2006-02-17
dtamm - 26 November 2012 11:02 AM
Kendall Sears - 20 November 2012 05:43 AM

I have a situation where I need to save custom data into the .duf file with the scene.  I can get an object to save, but I cannot seem to get any of the callbacks to execute to allow me to put my data into the “extra” sections.  Are there any examples on saving data that are completely foreign to DS,  but are critical for the plugin, to save in the scene’s .duf?

EDIT:  What would be more useful is a flow diagram on what is happening on .duf save/load and when/why, in the process, specific routines are called.

Also, what caveats should I watch for when (if) I can save the data, for reading it back out?

Kendall

lets call where you install the SDK to be SdkFolder, the following examples exists
- SdkFolder\samples\saving\customsceneelements
- SdkFolder\samples\saving\customscenedata
- SdkFolder\modifiers\DzBlackHole

customsceneelements shows the following custom elements
- custom DzNode
- custom DzModifier
- custom DzMaterial
- custom DzShape/DzGeometry combination

customscenedata shows a custom DzSceneData

DzBlackHole is a world space modifier(very esoteric, but it does show how the extra information radius is added to the Custom node.  Because the DzProperty is known to the system, it does not need custom save work.  In fact, all it needs is on read, the proper stuff to be created. Note: createNode() and applyInstancetoObject

————————————————————————————————————

I am assuming that you want a custom DzSceneData?

In any case, from a high level point of view, the write works something like this.
- gather all the scene assets in the scene that Studio can find(think IDzSceneAsset).  A custom DzNode will be found if it is added to the scene via dzScene->addNode.  If its not added to the scene, Studio does not know about it.
- assign ids and stuff to the assets.  In DSON, there are no pointers, so the issue of resolving assets becomes quite a bit of work and complexity.
- write out definitions
- write out instances
- write out animations

————————————————————————————————————

Kendall,

Do the samples not work for you?  Can you come up with a scenario that you would like a sample of?

The samples work fine, as far as they go.  What I want to do is more complex than what is described within the samples.  For the current project, I need to attach lots of custom definition information to nodes.  In some upcoming projects it gets more complex, dealing with encryption, CMS issues and the like.

Kendall

 Signature 

Any opinions expressed in this post are those of Kendall Sears and may, or may not, be more, or less, valid than any other opinion.

The contents of this post are intended for the DAZ forum only, do not re-post any portion to any other forum without his permission.

Profile
 
 
Posted: 26 November 2012 11:31 AM   [ Ignore ]   [ # 5 ]
Member
Rank
Total Posts:  106
Joined  2010-12-31
Kendall Sears - 26 November 2012 11:15 AM

The samples work fine, as far as they go.  What I want to do is more complex than what is described within the samples.  For the current project, I need to attach lots of custom definition information to nodes.  In some upcoming projects it gets more complex, dealing with encryption, CMS issues and the like.

Kendall

Your choices for serialization of data are something along the following:
- primitives.
- array of primitives
- structure of primitives
- structure of arrays of primitives
- arrays of structures or primitives.
- structures of structures

On the write, primitives are shown, array of array of primitives is shown.  Do you want the array of structures case shown? or a structure of structures?  Or am I misunderstanding completely.

Things get really complicated when we have a graph, where it is not obvious who is responsible to save out structureA, like the following situation.
Node1
- Pointer to structureA
Node2
- Pointer to structureA

 

 

Profile
 
 
Posted: 26 November 2012 11:56 AM   [ Ignore ]   [ # 6 ]
Power Member
Avatar
RankRankRank
Total Posts:  1874
Joined  2006-02-17
dtamm - 26 November 2012 11:31 AM
Kendall Sears - 26 November 2012 11:15 AM

The samples work fine, as far as they go.  What I want to do is more complex than what is described within the samples.  For the current project, I need to attach lots of custom definition information to nodes.  In some upcoming projects it gets more complex, dealing with encryption, CMS issues and the like.

Kendall

Your choices for serialization of data are something along the following:
- primitives.
- array of primitives
- structure of primitives
- structure of arrays of primitives
- arrays of structures or primitives.
- structures of structures

On the write, primitives are trivial, array of array of primitives is shown.  Do you want the array of structures case shown? or a structure of structures?  Or am I misunderstanding completely.

Things get really complicated when we have a graph, where it is not obvious who is responsible to save out structureA, like the following situation.
Node1
- Pointer to structureA
Node2
- Pointer to structureA

 

I’m reevaluating my options based on your response.  How about the ability to add an appendix section to the .duf containing abstract data that may contain anything?  This section would be fed raw to the plugin to do whatever is necessary.

Kendall

 Signature 

Any opinions expressed in this post are those of Kendall Sears and may, or may not, be more, or less, valid than any other opinion.

The contents of this post are intended for the DAZ forum only, do not re-post any portion to any other forum without his permission.

Profile
 
 
Posted: 26 November 2012 12:02 PM   [ Ignore ]   [ # 7 ]
Member
Rank
Total Posts:  106
Joined  2010-12-31
Kendall Sears - 26 November 2012 11:56 AM

I’m reevaluating my options based on your response.  How about the ability to add an appendix section to the .duf containing abstract data that may contain anything?  This section would be fed raw to the plugin to do whatever is necessary.

Kendall

By raw, do you mean binary?  Either way.  Raw to me means that you don’t really want or care for it to be human readable.  In that case, I would get yourself a QByteArray of your data and call toBase64() on it.  then write it out as a string.

 

Profile
 
 
Posted: 26 November 2012 12:04 PM   [ Ignore ]   [ # 8 ]
Member
Rank
Total Posts:  106
Joined  2010-12-31

If you have pointers to DzNode’s and other daz object, then would of course have to account for that and devise a way to resolve those pointers.

Profile
 
 
Posted: 26 November 2012 12:15 PM   [ Ignore ]   [ # 9 ]
Power Member
Avatar
RankRankRank
Total Posts:  1874
Joined  2006-02-17
dtamm - 26 November 2012 12:02 PM
Kendall Sears - 26 November 2012 11:56 AM

I’m reevaluating my options based on your response.  How about the ability to add an appendix section to the .duf containing abstract data that may contain anything?  This section would be fed raw to the plugin to do whatever is necessary.

Kendall

By raw, do you mean binary?  Either way.  Raw to me means that you don’t really want or care for it to be human readable.  In that case, I would get yourself a QByteArray of your data and call toBase64() on it.  then write it out as a string.

No, by ‘raw’ I meant that DS/Carrara doesn’t try to do *anything* with the section other than pass it along.  It’s possible to assign a null and then do as you suggest with a QByteArray, I just was hoping for something a bit more ‘formal.’  Something like:  “Here’s a section of the .duf that belongs only to the plugins.”  You know, somewhere where we can store custom scripting code, unforseen datatypes, etc without involving DAZ or breaking the .duf file.

“appendix” : [
  {
      “id” : “My Plugin’s Demented ID”,
      “name” : “My Plugin’s Demented Name”,
      “type” : “abstract”,
      “label” : “Nanny Nanny Boo Boo”,

      “Demented Field value name1” : “value”,
...
  }
]

Kendall

 

 Signature 

Any opinions expressed in this post are those of Kendall Sears and may, or may not, be more, or less, valid than any other opinion.

The contents of this post are intended for the DAZ forum only, do not re-post any portion to any other forum without his permission.

Profile
 
 
Posted: 26 November 2012 12:22 PM   [ Ignore ]   [ # 10 ]
Member
Rank
Total Posts:  106
Joined  2010-12-31

I am not sure what you mean by assign a null, do you mean create a custom DzNode that does not do anything besides hold data?

From my point of view, a custom scenedata is an appendix for your plugin.  Is that not what you want?

Profile
 
 
Posted: 26 November 2012 12:40 PM   [ Ignore ]   [ # 11 ]
Power Member
Avatar
RankRankRank
Total Posts:  1874
Joined  2006-02-17
dtamm - 26 November 2012 12:22 PM

I am not sure what you mean by assign a null, do you mean create a custom DzNode that does not do anything besides hold data?

From my point of view, a custom scenedata is an appendix for your plugin.  Is that not what you want?

I need to reevaluate some issues before I say too much more.  I believe that you’ve provided me with what I need to work out the current project’s issue.

Some of the things I’m looking to try to do would cause quite a firestorm if discussed in an open forum.

Kendall

 Signature 

Any opinions expressed in this post are those of Kendall Sears and may, or may not, be more, or less, valid than any other opinion.

The contents of this post are intended for the DAZ forum only, do not re-post any portion to any other forum without his permission.

Profile