[vtkusers] 2d actors, vtkImageActor and multiple rendering layers
Anja Ende
anja.ende at googlemail.com
Sun Oct 15 08:56:03 EDT 2006
Hi John,
Thanks for the answer.
I tried this approack also but on my machine I never see the 2d actor with
this one... No idea what is going on. I think I will use Qt to draw all the
overlay props which is a shame as I could have used the picking
functionality in VTK.
Thanks,
Anja
On 14/10/06, John Platt <jcplatt at dsl.pipex.com> wrote:
>
> Hi Anja,
>
>
>
> I ran your code using VTK 5 compiled by VS6 on XP. The 3d actor is always
> on top.
>
>
>
> I also removed the 2 renderers, replacing by
>
>
>
> vtkRenderer* ren = vtkRenderer::New();
>
> ren->AddActor(actor3d);
>
> ren->AddActor2D(actor2d);
>
> vtkRenderWindow* renWin = vtkRenderWindow::New();
>
> renWin->AddRenderer(ren);
>
>
>
> which puts the 2D actor on top.
>
>
>
> HTH
>
>
>
> John.
>
>
>
>
>
> -----Original Message-----
> *From:* vtkusers-bounces+jcplatt=dsl.pipex.com at vtk.org [mailto:
> vtkusers-bounces+jcplatt=dsl.pipex.com at vtk.org] *On Behalf Of *Anja Ende
> *Sent:* 14 October 2006 11:55
> *To:* VTK
> *Subject:* [vtkusers] 2d actors, vtkImageActor and multiple rendering
> layers
>
>
>
> Hi again,
>
> As per my previous problem of mixing 2d and 3d actors in the same scene, I
> thought it might be a graphics card problem. So, I managed to get another
> windows machine (I was using Linux before) but I still see the same
> problem.... the 2d actor only gets displayed when I do a pick operation on
> the 3d actor.... This is completely bizarre and after several days I have
> come with no explanation for that. I have stepped through the renderer code
> multiple times during debug, but see nothing that could offer some kind of
> explanation.
>
> I really wish someone here would take a look at this very trivial code and
> see if they could point something out. I tried to convert everything in my
> code to 3d actors but that presents another set of complications,
> unfortunately.
>
> I am attaching the code again. I really request someone to please help me.
> It will not take too much of your time. The code is really small and
> functional.
>
> #include "vtkImageData.h"
> #include " vtkImageActor.h"
> #include "vtkActor2D.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkImageMapper.h "
> #include "vtkPNGReader.h"
> #include "vtkImageChangeInformation.h"
>
> int main ()
> {
> // Read the image
> vtkPNGReader * cursorImage = vtkPNGReader::New();
> // Please replace with your own path
> cursorImage->SetFileName("C:\\crosshair.png");
> cursorImage->Update();
> // Shift center to image data oigin
> vtkImageChangeInformation * imageChange =
> vtkImageChangeInformation::New();
> imageChange->SetInput(cursorImage->GetOutput());
> imageChange->CenterImageOn();
>
> // create actor2d
> vtkImageMapper * mapper = vtkImageMapper::New();
> mapper->SetInput(imageChange->GetOutput());
> mapper->SetColorWindow(256.0);
> mapper->SetColorLevel(128.0);
> vtkActor2D * actor2d = vtkActor2D::New();
> actor2d->SetMapper(mapper);
> actor2d->SetPosition(120.0, 100.0);
>
> // create actor 3d
> vtkImageActor * actor3d = vtkImageActor::New();
> actor3d->SetInput(imageChange->GetOutput());
>
> // following lines creates our 2 layers of renderers
> vtkRenderer *ren1 = vtkRenderer::New(); // 2d actor
> ren1->AddViewProp(actor2d);
> ren1->SetLayer(0); // bottom layer
>
> vtkRenderer *ren2 = vtkRenderer::New();
> ren2->AddViewProp(actor3d); // 3d actor
> ren2->SetLayer(1); // top layer
>
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->SetNumberOfLayers(2); // we have 2 layers of renderers in our
> window
> renWin->AddRenderer(ren1);
> renWin->AddRenderer(ren2);
>
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); //
> an interactor
> iren->SetRenderWindow(renWin);
> renWin->Render();
> iren->Start();
>
> // We will not bother with deletions...program is ending anyways...
> return 0;
> }
>
> The crosshair.png image can be downloaded from here...
>
> http://pligame.sourceforge.net/images/crosshair.png
>
>
> Cheers,
>
> Anja
>
--
Cheers,
Anja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061015/68655c5b/attachment.htm>
More information about the vtkusers
mailing list