[vtkusers] Infinite sea plane - what's the best way?
Todd Martin
nztoddler at yahoo.com
Mon Apr 9 23:31:10 EDT 2018
Did you get the plan rendering without a texture first?
Todd Martin, Ph.D.
Freelance Engineer/Software Architect.
On Tuesday, April 10, 2018, 2:05:15 PM GMT+12, Jesse Kinross-Smith <Jesse.Kinross-Smith at bentley.com> wrote:
<!--#yiv0201785587 _filtered #yiv0201785587 {font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered #yiv0201785587 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv0201785587 {font-family:Consolas;panose-1:2 11 6 9 2 2 4 3 2 4;}#yiv0201785587 #yiv0201785587 p.yiv0201785587MsoNormal, #yiv0201785587 li.yiv0201785587MsoNormal, #yiv0201785587 div.yiv0201785587MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:11.0pt;font-family:"Calibri", sans-serif;}#yiv0201785587 a:link, #yiv0201785587 span.yiv0201785587MsoHyperlink {color:#0563C1;text-decoration:underline;}#yiv0201785587 a:visited, #yiv0201785587 span.yiv0201785587MsoHyperlinkFollowed {color:#954F72;text-decoration:underline;}#yiv0201785587 p.yiv0201785587msonormal0, #yiv0201785587 li.yiv0201785587msonormal0, #yiv0201785587 div.yiv0201785587msonormal0 {margin-right:0cm;margin-left:0cm;font-size:11.0pt;font-family:"Calibri", sans-serif;}#yiv0201785587 span.yiv0201785587EmailStyle18 {font-family:"Calibri", sans-serif;color:windowtext;}#yiv0201785587 .yiv0201785587MsoChpDefault {font-size:10.0pt;font-family:"Calibri", sans-serif;} _filtered #yiv0201785587 {margin:72.0pt 72.0pt 72.0pt 72.0pt;}#yiv0201785587 div.yiv0201785587WordSection1 {}-->
So I need to create an infinite textured plane to represent the sea.
vtkPlaneSource seems like the right object, but I can’t seem to get any of the examples to display anything.
A colleague tried a while back also but said he could only get it to work with OpenGL not OpenGL2.
Anyone able to offer any ideas?
I’ve got a rectilinear grid working, but it’s not ideal, really need an infinite textured plane.
Using VTK 8.1.0, C++
voidCModelView::vtkRenderImageToPlane(constCString&inputFilename,floatx,floaty,floatz)
{
USES_CONVERSION;
std::string filename = W2A(inputFilename);
// Read the image which will be the texture,
Image_Type imageType = GetImageType(inputFilename);
vtkAlgorithmOutput* ImageOutput =NULL;
vtkSmartPointer<vtkPNGReader> pNGReader = NULL;
vtkSmartPointer<vtkJPEGReader> jPEGReader = NULL;
vtkSmartPointer<vtkBMPReader> bMPReader = NULL;
switch (imageType)
{
caseImage_Type::PNG:
{
pNGReader=vtkSmartPointer<vtkPNGReader>::New();
pNGReader->SetFileName(filename.c_str());
pNGReader->Update();
ImageOutput = pNGReader->GetOutputPort();
}
break;
caseImage_Type::JPG:
{
jPEGReader=vtkSmartPointer<vtkJPEGReader>::New();
jPEGReader->SetFileName(filename.c_str());
jPEGReader->Update();
ImageOutput = jPEGReader->GetOutputPort();
}
break;
caseImage_Type::BMP:
{
bMPReader=vtkSmartPointer<vtkBMPReader>::New();
bMPReader->SetFileName(filename.c_str());
bMPReader->Update();
ImageOutput = bMPReader->GetOutputPort();
}
break;
}
if (ImageOutput ==NULL || (pNGReader==NULL && jPEGReader==NULL && bMPReader==NULL))
return;
// Create a plane
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New();
plane->SetNormal(0.0, 0.0, 1.0);
plane->SetCenter(0, 0, 0);
//plane->SetResolution(100, 100);
//plane->SetPoint1(100000, -100000, 0);
//plane->SetPoint2(-100000, 100000, 0);
// Apply the texture
vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();
texture->SetInputConnection(ImageOutput);
texture->InterpolateOn();
texture->RepeatOn();
vtkSmartPointer<vtkTextureMapToPlane> texturePlane = vtkSmartPointer<vtkTextureMapToPlane>::New();
texturePlane->SetInputConnection(plane->GetOutputPort());
vtkSmartPointer<vtkPolyDataMapper> planeMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
planeMapper->SetInputConnection(texturePlane->GetOutputPort());
vtkSmartPointer<vtkActor> texturedPlane = vtkSmartPointer<vtkActor>::New();
texturedPlane->SetMapper(planeMapper);
texturedPlane->SetTexture(texture);
texturedPlane->GetProperty()->SetOpacity(0.7);
texturedPlane->SetPickable(FALSE);
// Visualize the textured plane
m_vtkRenderer->AddActor(texturedPlane);
}
--
Jesse Kinross-Smith
Senior Software Engineer - BSW
Bentley Systems, Fremantle
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180410/5e441379/attachment.html>
More information about the vtkusers
mailing list