[vtkusers] Re: Update on mising 2d and 3d actors

Anja Ende anja.ende at googlemail.com
Thu Oct 12 06:08:16 EDT 2006


The layering works fine as long as I do not add a 3D actor on the top layer
or keep it invisible...

By the way, the 3D actor is 49 X 50 PNG image and I am using the following
code to set up the camera:

m_renderer2->ResetCamera();
vtkCamera * cam = m_renderer2->GetActiveCamera();
cam->ParallelProjectionOn();

// the origin, spacing and extent are from a reslice object
double xc = outputOrigin[0] + 0.5*(outputExtent[0] +
outputExtent[1])*outputSpacing[0];
double yc = outputOrigin[1] + 0.5*(outputExtent[2] +
outputExtent[3])*outputSpacing[1];
double xd = (outputExtent[1] - outputExtent[0] + 1)*outputSpacing[0];
double yd = (outputExtent[3] - outputExtent[2] + 1)*outputSpacing[1];
double d = cam->GetDistance();

cam->SetParallelScale(0.5*yd);
cam->SetFocalPoint(xc,yc,0.0);
cam->SetPosition(xc,yc,+d);


On 12/10/06, Anja Ende <anja.ende at googlemail.com> wrote:
>
> Hi everyone,
>
> Ok, I have almost tried everything unsuccessfully...exxcept for what would
> make this thing work! I have had no success in mixing 2d and 3d actors.
>
> So, my latest brilliant idea was to use multiple renderers and layer them
> on the render window.
>
> So, only the top one would have the 3d actors and the bottom one would be
> my 2d actor.... I thought this would work for sure!
>
> Well, my code is like this:
>
> this->m_actor2D->SetMapper(this->m_imageMapper);
> this->m_renderer->AddViewProp(this->m_actor2D);
> // first renderer
> this->m_renderer->SetLayer(0);
>
> vtkPNGReader * cursorImage = vtkPNGReader::New();
> cursorImage->SetFileName("/home/anja/crosshair.png");
> cursorImage->Update();
>
> vtkImageChangeInformation * imageChange =
> vtkImageChangeInformation::New();
> imageChange->SetInput(cursorImage->GetOutput());
>
> vtkImageActor * actor = vtkImageActor::New();
> actor->SetInput(imageChange->GetOutput());
> imageChange->CenterImageOn();
> // second renderer
> this->m_renderer2->AddViewProp(actor);
> this->m_renderer2->SetLayer(1);
>
> // 2 layers
> this->m_renderWindow->SetNumberOfLayers(2);
> // Add the layers to my render window.
> this->m_renderWindow->AddRenderer(this->m_renderer);
> this->m_renderWindow->AddRenderer(this->m_renderer2);
>
> Well, no matter what layer I put the 2d actor in... all I can see is the
> 3d actor..always! I would die to see my 2d actor right now!!
>
> Please help me here. I am totally out of ideas now!
>
> Cheers,
>
> Anja




-- 
Cheers,

Anja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061012/3f0a1d3b/attachment.htm>


More information about the vtkusers mailing list