[vtk-developers] Camera Animation

John Biddiscombe biddisco at cscs.ch
Fri May 13 04:35:32 EDT 2005


I notice some Camera Animation code going into cvs, I have put two files 
here
ftp://ftp.cscs.ch/out/biddisco/vtk/
This is a reasonably simply camera animation class that I've been using 
to create some nice flythoughs of data. It works by wrapping a 
SplineWidget and allowing you to drag it around on screen, then you can 
follow the trajectory. The loop can be closed or open and it has some 
utility code thrown in. control of UpVector etc etc. (NB. twop widgets 
are included, one for the camera path, the other for the focal point, 
which can track following another spline, but I've found this to be 
difficult to coordinate nicely and I need to work on it some more, so 
just ignore that bit).

I don't know if it's any use to anyone, but if it gives anyone any ideas 
or saves some effort, then please use any of it. It'd be lovely in 
Paraview.<hint hint, cough cough>

JB

stuff from header for reference

  // Description:
  // Toggle visibility of the splines that define the camera path and focus path
  virtual void SetVisible(int v);

  // Specify an initial guess for location of Camera path
  virtual void PlacePath(vtkDataSet *data);

  // Specify an initial guess for location of Camera focus
  virtual void PlaceFocus(vtkDataSet *data);

  virtual void SetInteractor(vtkRenderWindowInteractor *);
  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);

  // Description:
  // Set/Get the number of Camera Path handles
  void SetNumberOfPathHandles(int i);
  vtkGetMacro(NumberOfPathHandles, int);

  // Description:
  // Set/Get the number of Divisions between Camera Path handles
  void SetNumberOfPathDivisions(int i);
  vtkGetMacro(NumberOfPathDivisions,int);

  // Description:
  // Set/Get the number of Camera Focus handles
  void SetNumberOfFocusHandles(int i);
  vtkGetMacro(NumberOfFocusHandles,int);

  // Description:
  // Set/Get the number of Camera Path handles
  void SetNumberOfFocusDivisions(int i);
  vtkGetMacro(NumberOfFocusDivisions,int);

  // Description:
  // Control whether the spline is open or closed. 
  // A closed spline forms a continuous loop: 
  void SetPathSplineClosed(int i);
  vtkGetMacro(PathSplineClosed,int);

  // Description:
  // Control whether the spline is open or closed. 
  // A closed spline forms a continuous loop: 
  void SetFocusSplineClosed(int i);
  vtkGetMacro(FocusSplineClosed,int);

  //BTX - manage the Focus mode
  enum FocusModes
  {
    FocusPath=0,
    LookAhead,
    FixedPoint
  };
  //ETX
  //BTX - manage the Up mode
  enum UpModes
  {
    RelativeVector=0,
    RelativeVectorInverted,
    FixedVector
  };
  //ETX

  // Description:
  // Set how the Camera Focus position is controlled
  // FocusPath : The path specified by the FocusPath polydata/spline is used to 
  // control how the focal point changes. 
  // LookAhead : The Focal Position of the camera follws the direction of the 
  // ahead vector as defined by the camera path polydata/spline
  // FixedPoint : The Focal point is fixed at a user defined position
  void SetFocusModeToFocusPath()   { this->SetFocusMode(FocusPath); }
  void SetFocusModeToLookAhead()   { this->SetFocusMode(LookAhead); }
  void SetFocusModeToFixedPoint()  { this->SetFocusMode(FixedPoint); }
  vtkSetMacro(FocusMode,int);
  vtkGetMacro(FocusMode,int);
  vtkSetVector3Macro(FocalPosition, double);
  vtkGetVector3Macro(FocalPosition, double);

  void SetUpModeToRelativeVector()         { this->SetUpMode(RelativeVector); }
  void SetUpModeToRelativeVectorInverted() { this->SetUpMode(RelativeVectorInverted); }
  void SetUpModeToFixedVector()            { this->SetUpMode(FixedVector); }
  vtkSetMacro(UpMode,int);
  vtkGetMacro(UpMode,int);
  vtkSetVector3Macro(UpVector, double);
  vtkGetVector3Macro(UpVector, double);

  // Description:
  // Set/Get this when loading/saving state from file
  // otherwise ignore it
  vtkSetMacro(StreamInitialized,int);
  vtkGetMacro(StreamInitialized,int);
  vtkBooleanMacro(StreamInitialized,int);

  // Description:
  // A utility variable to enable or disable the animation. 
  // This is provided to allow apps using the camera to switch on/off the state without having
  // additional variables - it keeps everything in one place.
  vtkSetMacro(AnimationEnabled,int);
  vtkGetMacro(AnimationEnabled,int);
  vtkBooleanMacro(AnimationEnabled,int);
  
//BTX
  void SaveToStream(vtkstd::ostream &str);
  void LoadFromStream(vtkstd::istream &str);

  static void LoadCameraSettings(vtkCameraAnimation *&camera, vtkRenderWindowInteractor *interactor, 
      vtkDataSet *path, vtkDataSet *focus, const char *title, const char *appname);
//ETX





-- 
John Biddiscombe,                            email:biddisco @ cscs.ch
http://www.cscs.ch/about/BJohn.php
CSCS, Swiss National Supercomputing Centre  | Tel:  +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland      | Fax:  +41 (91) 610.82.82





More information about the vtk-developers mailing list