Store a mesh/poly object..



  • On 30/09/2014 at 03:58, xxxxxxxx wrote:

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

    ---------
    What im trying to do at the moment is have my plugin store a polygon object ( just the mesh really ) so that it can be recalled from within the plugin later.  Is there an easy way to do this that im missing?

    What i have at the moment is basically this:

    -User clicks a button.
    -Plugin iterates through all the points and polygons of the chosen polygon object and stores the vector  and index values in base containers.
    -Plugin then writes the holding base container to a hyperfile in the plugin directory.
    -Object is now stored inside the hyperfile and can be recalled via the plugin at any time.

    Next what happens is:

    -User clicks another button.
    -Plugin reads the holding base container from the hyperfile.
    -Plugin iterates through the vectors and indexes stored and applies them to a new PolygonObject ( basically rebuilds the mesh from the data ).
    -Plugin inserts this new object into the scene.

    This works for the most part although i am working through a couple of issues ( vertex orders i think although i have been careful to recreate all polygons exactly as they were in the original )..

    But what i am wondering is, is there an easier way, to just store a PolygonObject to a hyperfile or even inside the plugins BaseContainer?  The idea is it has to be retrievable so when the plugin is distributed or used in a different C4D session/document/whatever the objects are available.  Is parsing the mesh / rebuilding it in this way the only way to achieve this?  Or am i missing an easier way to store an object?



  • On 30/09/2014 at 05:03, xxxxxxxx wrote:

    I found the following post ( thanks Yannick and Nicklas ) :

    https://plugincafe.maxon.net/topic/6878/7704_write-object-to-hyperfile&KW=ReadContainer&PID=31867#31867

    Which suggests putting the objects inside a dummy doc, saving to a memory file and then writing the memory to a hyperfile..  Its also mentioned that the bytesequence wouldnt be platform independent.  Not the end of the world i suppose but could be an annoyance.

    Sounds like the only way other than manually parsing/rebuilding the polygonal object..



  • On 07/10/2014 at 03:50, xxxxxxxx wrote:

    Are you through with this then?
    I'd like to close this issue then.
    I think, this also might be a nice topic for the C$D programming blog (http://c4dprogramming.wordpress.com/). It's noted down.



  • On 24/10/2014 at 05:06, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    I found the following post ( thanks Yannick and Nicklas ) :
    https://plugincafe.maxon.net/topic/6878/7704_write-object-to-hyperfile
    Which suggests putting the objects inside a dummy doc, saving to a memory file and then writing the memory to a hyperfile..  Its also mentioned that the bytesequence wouldnt be platform independent.  Not the end of the world i suppose but could be an annoyance.
    Sounds like the only way other than manually parsing/rebuilding the polygonal object..

    Why don't you simply store the BaseDocument that contains your object to a file, using the SaveDocument() function?

    Alternatively, you could try if C4DAtom::WriteObject(hf) does the job for you.



  • On 25/10/2014 at 11:05, xxxxxxxx wrote:

    Hi jack,

    I didn`t want to expose anything in my plugin to users so saving doc was not an option.  I ended up using the save memory to hyperfile option.  Not sure if i tried C4DAtom::WriteObject(hf) at the time i might give that a look..

    Ideally it would be useful if there was a way to store objects internally ( ie to the plugin basecontainer or similar ) but don`t think there is a way to do that.


Log in to reply