'App.getRenderOptions' [undefined] is not a function...?

ReDaveReDave Posts: 815
edited December 1969 in Daz Script Developer Discussion

I'm trying something along the lines of Yacomo's render script here: http://forumarchive.daz3d.com/viewtopic.php?p=1628030#1628030
but I get an error about:

WARNING: Script Error: Line 5
WARNING: TypeError: Result of expression 'App.getRenderOptions' [undefined] is not a function.

This used to work in both DS2 and 3. Any idea on what do I need to do?

Comments

  • ReDaveReDave Posts: 815
    edited December 1969

    I was able to export a Render Preset in "deprecated" format that does what I want. Doesn't look all that different to me, but this one works.

  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    First get the Render Manager from the App, then get the Render Options from the Render Manager.

    var oRenderMgr = App.getRenderMgr();
    var oRenderOpts = oRenderMgr.getRenderOptions();

    -Rob

  • ReDaveReDave Posts: 815
    edited June 2012

    Hmm, testing some more and comparing with Yacomo's script, the variable declarations are on a different line in his script, which is apparently what throws the error. Not sure if it is intended behaviour.

    I'm also trying to use setCropWindow which in DS3 was in DzRenderHandler, but I can't see any working example apart from what you guys did in the Ambient Occlusion scripted render script, which however hides part of its declarations. If I use your property enumeration script on DzScriptedRenderer I get a very long list which from my perusal doesn't seem to include setCropWindow. :-S I know I must get the Handler (not enumerated either with your script), but the example in the DS3 documentation doesn't work in DS4. I must say I'm feeling like one of those proverbial monkeys on a typewriter at this point... :-( Hmm and can the DzScriptedRenderer class be used in regular scripts that do not get run from the Scripted Renderer drop-down?
    Here is one of the attempts I did, based on the DS3 getHandler script:

    
    // Get the active viewport and camera
    var oActiveView = MainWindow.getViewportMgr().getActiveViewport();
    var oCamera = oActiveView.get3DViewport().getCamera();
    
    // Get the render options
    var oRenderOptions = App.getRenderMgr().getRenderOptions();
    var RSize = new Size(600,600);
    var oRect=Rect( 0.1,0.5,0.2,0.3 );
    var RName="Render.jpg";
    var On=1;
    
    // Create a handler
    var oHandler = DzRenderHandler.getHandler(RSize,0,RName );
    
    // If we have a valid handler
    if( oHandler ){
        // Set the background color
        DzScriptedRenderer.setUseCropWindow(On);
        DzScriptedRenderer.setCropWindow( oRect );
    
    
        // Get the renderer
        var oRenderer = oRenderOptions.getActiveRenderer();
    
         Render, using our handler and options
        oRenderer.render( oHandler, oCamera, oRenderOptions );
    }
    


    Edit, BTW for anybody else who may be lurking, Rob's property enumeration script can be found here

    Post edited by ReDave on
  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    Apologies, ReDave, there are quite a few issues with your script... but I don't have time right now to explain it all.

    A night or two ago I wrote an example that would work and I was going to post it for you to compare/study, but in so doing found a couple bugs with the class factories (code that allows C++ objects to be created by script and converted) for the requisite render handlers. The bugs have since been fixed, but I wanted to look into using a different approach to work around them... so you wouldn't have to wait until the build with the fix becomes available in order for the script to be useful.

    Yes, you can use the scripted render in "regular" scripts that to not populate the combobox... that is how it was done prior the combobox being added (for convenience).

    -Rob

  • ReDaveReDave Posts: 815
    edited December 1969

    OK, thanks for everything you're doing! And no worries I can wait a few days. ^_^

  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    I added some rendering samples to the Documentation Center last night. I still have some tweaks to make, but there is enough there to begin dissecting.

    -Rob

  • ReDaveReDave Posts: 815
    edited December 1969

    Awesome, thanks Rob! After a quick perusal it looks like setCropWindow can only be used in viewport renders?

  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    No, the setCropWindow() method is inherited from DzRenderHandler...

    Dz3DViewRenderHandler and DzViewRenderHandler both inherit from DzImageRenderHandler and DzImageRenderHandler inherits from DzRenderHandler.

    Do you understand how inheritance works? A very basic explination boils down to... an object can access all of the methods/signals/properties of its own, along with all of the methods/signals/properties of the object it inherits (aka "superclass"), along with all of the methods/signals/properties of the object that object inherits... and so on up the chain. On the C++ side of things, there are some very specific details that have to be considered, but I usually don't go into all that when I'm describing something to someone who is scripting rather than someone who is exposing their API to script.

    So, anyway, in the context of Dz3DViewRenderHandler... a Dz3DViewRenderHandler object can access all of it own methods/signals/properties, along with all of the methods/signals/properties on DzImageRenderHandler and all of the methods/signals/properties on DzRenderHandler.

    -Rob

  • ReDaveReDave Posts: 815
    edited December 1969

    Yes I do understand the idea of inheritance, I believe you explained it already a couple of times on the old forums, at least since I am a member. I see now the script was intended as two examples. ;) I hope I'll have time to piece it this week!

Sign In or Register to comment.