[vtkusers] problem about user defined subclass of vtkCamera

Yanbing Hu Yanbing.Hu at virtualwind.com
Tue Oct 14 13:24:21 EDT 2008


I wonder if anybody could give me any hint? I try to make a subclass of
vtkCamera (say tmpCamera), but by using tmpCamera, no actor shows up.
but if I just replace "tmpCamera *camera = new tmpCamera;" with
"vtkCamera *camera = vtkCamera::New();" , the actor shows up. Here is
the code:
 
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkCubeSource.h"
 

class tmpCamera :public vtkCamera{};
 
int main_rotate_about_picked_point( int argc, char *argv[] )
{
 vtkCubeSource *cube = vtkCubeSource::New();
 vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
  mapper->SetInput(cube->GetOutput());
  mapper->ScalarVisibilityOff();
 
 vtkActor* actor = vtkActor::New();
  actor->SetMapper(mapper);
  actor->SetPosition(0.0,0.0,-3.0);
  actor->GetProperty()->SetColor(0.0,1.0,0.0);
 
vtkInteractorStyleTrackballCamera *style =
vtkInteractorStyleTrackballCamera::New();
 
 vtkRenderer *ren = vtkRenderer::New();
 tmpCamera* camera = new tmpCamera();
    ren->SetActiveCamera(camera);
    ren->AddActor(actor);
 
vtkRenderWindow *renwin = vtkRenderWindow::New();
  renwin->AddRenderer(ren);
  
 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renwin);
  iren->SetInteractorStyle(style);
 
 renwin->SetSize(600,600);
 renwin->Render();
 iren->Initialize();
 iren->Start();
 
 return 0;
}
 
What did I do wrong? thanks a lot
 
Yanbing

______________________________________________________________ 

Reputation Resources Results 

http://www.rwdi.com 

______________________________________________________________ 

This communication is intended for the sole use of the party to whom it 
is addressed and may contain information that is privileged and/or 
confidential. Any other distribution, copying or disclosure is strictly
prohibited. If you have received this e-mail in error, please notify us
immediately by telephone (1-519-823-1311) and delete the message without 
retaining any hard or electronic copies of same. 

RWDI scans outgoing emails for viruses, but makes no warranty as to their
absence in this email or attachments.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081014/4e24abec/attachment.htm>


More information about the vtkusers mailing list