Render in project camera grasshopper

Suppose im doing an animation with Render In Project. Is there a way to interactively preview the camera? I can use the Look-through function on the camera component but I would need to do this at every frame, I want to interactively iterate all views before pressing render animation. Is it possible? … It works if I use the render component only, but not with render in the project.

Hi

The V-Ray camera is not connected to any view in Rhino, hence you cannot update the viewport from the Timeline component.
The only way, currently, is to use script, that executes on each frame that updates the active Rhino view. The code behind “Look thru Camera” function is merely 4 lines long (for perspective camera), and with some adaptation it can be used as-is in the script like this:


you only need the position, target, fov and tilt parameters for a perspective camera (it is a bit more complicated for parallel camera)
and the code is:

  private void RunScript(object position, object target, object fov, object tilt, ref object A)
  {
    var doc = Rhino.RhinoDoc.ActiveDoc;
    var vp = doc.Views.ActiveView.ActiveViewport;
    double fovr = Rhino.RhinoMath.ToRadians((double) fov);
    double tiltr = Rhino.RhinoMath.ToRadians((double) tilt);

    vp.ChangeToPerspectiveProjection(true, vp.FrustumAspect * 12.0 / Math.Tan(fovr * 0.5));
    vp.CameraUp = Vector3d.ZAxis;
    vp.SetCameraLocations((Point3d) target, (Point3d) position);
    vp.Rotate(tiltr, -(Vector3d) vp.CameraDirection, (Point3d) vp.CameraLocation);

    doc.Views.ActiveView.Redraw();
  }

I’m sending the example files
RiPrCamAnim.3dm (188.7 KB)
RiPrCamAnim.gh (22.5 KB)

1 Like

thank you! Nikolay very much appreciated the help.

Hi,

Just wanted to inform you that we decided to expose the camera API so that it can be called with a script.
Now the very same procedure boils down to the following:

there are 4 methods in total, going back and forth to a given or the active Rhino viewport
image

The API will be available in V-Ray for Rhino 6.20.03

thank great news, Nikolay where do i find the best documentation for vrayforgrasshopper api? or see the exposed methods.

you said “The Best”, like there are multiple documentations…
well, there is none. Typically for .net assemblies the documentation is contained within, you just need to read the assembly metadata. There are multiple ways to do so, including the Script Editor itself:

I personally use the ObjectBrowser that is build in the Visual Studio

1 Like