Aiming lights

Does anybody know if you can aim (point) a Spotlight in Daz Script in a similar fashion as aiming a camera? I've examined the DzSpotlight API but can't see anything.

 

Post edited by Richard Penney on

Comments

  • DzLight inherits DzCamera, so all the methods from the base camera object are available to lights (unless overridden).

  • Thanks a million, Richard. It had crossed my mind why DzLight was derived from DzCamera. Now I know!

     

  • PraxisPraxis Posts: 241

    Here's a starter kit: https://www.daz3d.com/forums/discussion/85971/a-script-to-orbit-camera-around-a-point

    Example usage:

    1. Create a Spotlight, and change its Label to Orbit-Camera
    2. Move that light way from the World Origin
    3. In the View Pane, make that light the Active Camera
    4. Create a Cube Primitive, and change its Label to Orbit-Point
    5. In the Script IDE Pane, Open the CameraOrbit.dsa script attached to the above post.
    6. In line 352 of the script, change findCameraByLabel to findLightByLabel
    7. Execute the script.
    8. Enjoy.

     

  • Richard PenneyRichard Penney Posts: 41
    edited September 2019

    Thanks a lot, Praxis. I'll begin looking at this code tomorrow. It could be a cool extension to the product I've been developing!

     

    Post edited by Richard Penney on
  • Richard gave me a good heads-up on the relationship between DzSpotLight and DzCamera. It helped me a lot. But I'm still not able to programatically set a spotlight's intensity. Any ideas?

     

  • Have you tried using one of the findProperty methods?

  • PraxisPraxis Posts: 241

    Richard gave me a good heads-up on the relationship between DzSpotLight and DzCamera. It helped me a lot. But I'm still not able to programatically set a spotlight's intensity. Any ideas?

    1) Create a Light, and select it.

    2) In the Script IDE Pane, enter and execute this:

    var oSel = Scene.getPrimarySelection();if( oSel ) {  print( Object.keys( oSel ) );}

    3) Copy & paste the output into your text editor, and search for "Intensity".  You will find getIntensityControl()

    4) Change the code to this, and execute it:

    var oSel = Scene.getPrimarySelection();if( oSel ) {  oSel.getIntensityControl().setValue( 1.5 );}

     

    The best general answer to Scripting questions like this may be:

    1. Read this post by Rob, which I regard as the most important post in the Scripting forum: https://www.daz3d.com/forums/discussion/comment/557942/#Comment_557942, and always keep in mind his words "IF you're up for a bit of self-discovery (i.e. no published documentation) and you realize that what you discover isn't officially supported. Meaning, it may change, without warning or notification."
    2. Check out this script in the Samples: http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/node_properties/start
    3. Google all posts by rbtwhiz in the Script Developer Discusion forum.

     

  • Hey guys. Thanks for the pointers. 

    Before I read your comment, Praxis, I was playing around with the object.findProperty() method, and got the following code to set a light's intensity.

    var oLight = Scene.findLightByLabel("SpotLight 1");var oProp = oLight.findProperty("Intensity");if (oProp){	var nValue = oProp.getValue(); // get current intensity value	nValue = 1.25;                 // initialize new value	oProp.setValue(nValue);        // set new value}

    Goes to show that there can be more than one way to accomplish things in Daz Scripting.

    And thanks for sharing the link to the post by Rob.

     

Sign In or Register to comment.