Adding objects to doc in VideoPost



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 31/05/2004 at 15:45, xxxxxxxx wrote:

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

    ---------
    Hi,
     
    It is possible to add an object into a document, just before its rendered, then remove it after the scene is rendered?
     
    My Initial thought is this

        
        
        
        
        LONG PostPlugin::Execute(PluginVideoPost *node, VideoPostStruct *vps)  
        {
        
        
        
        
         
        
        
        
        
          
         BaseDocument *doc = GetActiveDocument();  
         
        
        
        
        
         
        
        
        
        
         if(vps->vp == VP_RENDER && vps->open)  
         {  
            
          //g_cube is a global variable  
          g_cube = BaseObject::Alloc(Ocube);  
          doc->InsertObject(g_cube,NULL,NULL);  
          doc->SetChanged();
        
        
        
        
         
        
        
        
        
         }
        
        
        
        
         
        
        
        
        
         if(vps->vp == VP_RENDER && !vps->open )  
         {  
            
          //BaseObject::Free(g_cube);  
         }
        
        
        
        
         
        
        
        
        
         return RAY_OK;  
        }
        
        
        
    

    But a cube doesn't show in the rendering. Its after the render, a cube is inserted into the document (of course uncommenting the free line stops this)
     
    Is this not possible?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 31/05/2004 at 16:38, xxxxxxxx wrote:

    First of all, it's not allowed to modify the scene in any Execute(), Draw() or GetVirtualObjects() function, since these can be called from threads.
    Furthermore, you should almost never use GetActiveDocument() to get the document, since that will just get the document currently seen by the user. In this case you would want to access the cloned document for rendering (VideoPostStruct::doc).
    I'll ask the developers if there's a thread safe way to insert objects during rendering.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/06/2004 at 00:29, xxxxxxxx wrote:

    From what I heard from other programmers it´s always illegal to add objects during rendertime, no matter what.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/06/2004 at 14:49, xxxxxxxx wrote:

    Quote: Originally posted by 3D Designer on 01  June 2004
    >
    > * * *
    >
    > From what I heard from other programmers it´s always illegal to add objects during rendertime, no matter what.
    >
    > * * *

    If thats the case, how would Paul Everett make his Solid Spline Pro? I'm guessing he just adds a sweep just before render (which I have done)
     
    Although I got it working, and will only be using the plugin for personal use (it won't ever be released). I'm wondering what problems could be caused as what I have done is classed as 'illegal'



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/06/2004 at 16:30, xxxxxxxx wrote:

    Don´t know how paul is doing it. And if he is doing it this way, then this would be considered illegal.
    David O´Reilly can probably give you a long list. I am not sure if I am allowed to quote him.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/06/2004 at 23:22, xxxxxxxx wrote:

    Lets take a simple example that shows the problem visually. Take any plugin (and there are a number) that adds something at render time (or your own), if it adds an object that shows in a manager then it is easier to see the problem.
    In the editor hit render (with something that takes long enough to do this), then bring another application to the front, then back to CINEMA, or just move a window over CINEMA to force CINEMA to do some dialog refreshing. NOTE the objects appear in the corresponding manager! this is dangerous and you risk crashing CINEMA.
    Any plugin that adds anything at render time is risky, I'm not saying it will always crash, you may never notice the 'bad' effects it could have. The results could be unpredictable, you could just cause some data to become corrupt, internal pointers to change, who knows. It is called "illegal" because it is not designed to be done, you can do it, but just be aware that any form of "illegal" hack (that is what it is) can result in unpredictable results, that is why it is "illegal".
    Just because plugin (A) does something, does not make it a good idea (or safe). There are many plugins around that do many bad things (when I have run the DEBUG version of CINEMA with some plugins it is impossible to do anything because of all the ASSERTs that trigger because of illegal/bad activity) the results are always unpredictable crashing for some users, this is never a good thing.
    If this is for personal use then you at least know to be watchful if you get a crash. You could also warn any users it (could) crash (but might be unlikely in many cases). Just be aware of the potential, the crashing may not happen directly when using the plugin, but could occur after it at any time when any 'damage' done is hit.
    Sometimes completely 'legal' programming can be tricky, especially when working within somebody else's framework, if you use 'hacks' always try and establish what the results might be in worst cases and be aware of the potential issues it might cause any users. Lost work is never fun :(
    HTH.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/06/2004 at 09:09, xxxxxxxx wrote:

    Quote: Originally posted by 3D Designer on 01 June 2004
    >
    > * * *
    >
    > Don´t know how paul is doing it. And if he is doing it this way, then this would be considered illegal.
    >
    > David O´Reilly can probably give you a long list. I am not sure if I am allowed to quote him.
    >
    >
    >
    >
    > * * *

    I think Paul is doing this internally: he just puts a SweepNURBS and a Circle to the scene (both are hidden - think of the Atom-Object-example in the C++ SDK. There you can define the edges of your polygon object as cylinders and the vertices as spheres, when you make the object editable there is a NULL-object containing all the spheres and cylinders, these were previously only in the memory and not visible in the tree)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/06/2004 at 09:19, xxxxxxxx wrote:

    hehe, yes I know. The question was IF he is adding objects during rendertime. The way the Atom object is doing it is absolutely alright and legal as the objects are created virtually in the cache.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/06/2004 at 04:48, xxxxxxxx wrote:

    It's unsafe to insert objects during the rendering.
    The reason is that if you render in the editor, the original (uncloned) scene is rendered. If you now insert an object while the object manager refreshes you'll run into a crash.
    For external renders it's safe to do it in the VP, if you do it before VP_RENDER (VP_RENDER is way too late).
    The safest way is to create a generator object that creates geometry...


Log in to reply