-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9b1290
commit 02daccd
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Grasshopper.Kernel; | ||
using Rhino.Geometry; | ||
using System; | ||
|
||
namespace GH_Timeline | ||
{ | ||
public class SetCameraComponent : GH_Component | ||
{ | ||
public override Guid ComponentGuid => new Guid("EEE94A1F-A762-425C-B564-5F5282580951"); | ||
protected override System.Drawing.Bitmap Icon => Properties.Resources.icon_setcamera_24; | ||
|
||
public SetCameraComponent() | ||
: base("Set Camera", "Set Camera", "Sets the camera location and target", "Display", "Timeline") | ||
{ | ||
} | ||
|
||
protected override void RegisterInputParams(GH_InputParamManager pManager) | ||
{ | ||
pManager.AddPointParameter("Camera Location", "L", "The location of the camera", GH_ParamAccess.item); | ||
pManager.AddPointParameter("Camera Target", "T", "The target of the camera", GH_ParamAccess.item); | ||
pManager[pManager.AddTextParameter("Viewport", "V", "The name of the viewport. If none, the active viewport will be used", GH_ParamAccess.item)].Optional = true; | ||
} | ||
|
||
protected override void RegisterOutputParams(GH_OutputParamManager pManager) | ||
{ | ||
} | ||
|
||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
Rhino.Display.RhinoViewport viewport = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport; | ||
string viewportName = viewport.Name; | ||
|
||
|
||
if (DA.GetData(2, ref viewportName)) | ||
{ | ||
Rhino.Display.RhinoView rhView = Rhino.RhinoDoc.ActiveDoc.Views.Find(viewportName, false); | ||
if (rhView == null) | ||
{ | ||
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Unable to find viewport {viewportName}"); | ||
return; | ||
} | ||
|
||
viewport = rhView.ActiveViewport; | ||
} | ||
|
||
Point3d camPos = default; | ||
Point3d camTar = default; | ||
|
||
DA.GetData(0, ref camPos); | ||
DA.GetData(1, ref camTar); | ||
|
||
viewport.SetCameraLocations(camTar, camPos); | ||
} | ||
} | ||
} |