Using multile texture files in vtkOBJImporter

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using multile texture files in vtkOBJImporter

vinmean
Following is my function to import obj files with texture. But I need to import obj files that have multiple .png files as textures. Is there a way to use vtkOBJImporter class with mulitple texture files?

void import_vtk_tex_obj(std::string filenameOBJ, std::string filenameMTL, std::string filenameTEX, boost::shared_ptr<pcl::visualization::PCLVisualizer> view)
{
        vtkNew<vtkOBJImporter> importer;
        std::string texture_path = vtksys::SystemTools::GetFilenamePath(filenameTEX);

        importer->SetFileName(filenameOBJ.data());
        importer->SetFileNameMTL(filenameMTL.data());
        importer->SetTexturePath(texture_path.data());
        importer->SetRenderWindow(view->getRenderWindow());
        importer->Update();
        vtkSmartPointer<vtkRenderer> renderer =view->getRenderWindow()->GetRenderers()->GetFirstRenderer();
        renderer->ResetCamera();
}
Reply | Threaded
Open this post in threaded view
|

Re: Using multile texture files in vtkOBJImporter

Ken Martin
Your example should have an OBJ with multiple textures if there is no more than one texture per material.

If the issue is that you have an OBJ file where one piece (material?), uses multiple textures and has multiple sets of texture coordinates per vertex, that is not fully supported.  I believe currently the multiple sets of texture coordinates are read in but only the first texture map and coordinate are used but I may be out of date.



On Wed, Aug 16, 2017 at 3:14 AM, vinmean <[hidden email]> wrote:
Following is my function to import obj files with texture. But I need to
import obj files that have multiple .png files as textures. Is there a way
to use vtkOBJImporter class with mulitple texture files?

void import_vtk_tex_obj(std::string filenameOBJ, std::string filenameMTL,
std::string filenameTEX,
boost::shared_ptr<pcl::visualization::PCLVisualizer> view)
{
        vtkNew<vtkOBJImporter> importer;
        std::string texture_path =
vtksys::SystemTools::GetFilenamePath(filenameTEX);

        importer->SetFileName(filenameOBJ.data());
        importer->SetFileNameMTL(filenameMTL.data());
        importer->SetTexturePath(texture_path.data());
        importer->SetRenderWindow(view->getRenderWindow());
        importer->Update();
        vtkSmartPointer<vtkRenderer> renderer
=view->getRenderWindow()->GetRenderers()->GetFirstRenderer();
        renderer->ResetCamera();
}



--
View this message in context: http://vtk.1045678.n5.nabble.com/Using-multile-texture-files-in-vtkOBJImporter-tp5744430.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/vtkusers



--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065

This communication, including all attachments, contains confidential and legally privileged information, and it is intended only for the use of the addressee.  Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. If you received this communication in error please notify us immediately and destroy the original message.  Thank you.

_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Using multile texture files in vtkOBJImporter

Bill Lorensen
Ken is correct. Only one texture per object.

On Aug 16, 2017 10:08 AM, "Ken Martin" <[hidden email]> wrote:
Your example should have an OBJ with multiple textures if there is no more than one texture per material.

If the issue is that you have an OBJ file where one piece (material?), uses multiple textures and has multiple sets of texture coordinates per vertex, that is not fully supported.  I believe currently the multiple sets of texture coordinates are read in but only the first texture map and coordinate are used but I may be out of date.



On Wed, Aug 16, 2017 at 3:14 AM, vinmean <[hidden email]> wrote:
Following is my function to import obj files with texture. But I need to
import obj files that have multiple .png files as textures. Is there a way
to use vtkOBJImporter class with mulitple texture files?

void import_vtk_tex_obj(std::string filenameOBJ, std::string filenameMTL,
std::string filenameTEX,
boost::shared_ptr<pcl::visualization::PCLVisualizer> view)
{
        vtkNew<vtkOBJImporter> importer;
        std::string texture_path =
vtksys::SystemTools::GetFilenamePath(filenameTEX);

        importer->SetFileName(filenameOBJ.data());
        importer->SetFileNameMTL(filenameMTL.data());
        importer->SetTexturePath(texture_path.data());
        importer->SetRenderWindow(view->getRenderWindow());
        importer->Update();
        vtkSmartPointer<vtkRenderer> renderer
=view->getRenderWindow()->GetRenderers()->GetFirstRenderer();
        renderer->ResetCamera();
}



--
View this message in context: http://vtk.1045678.n5.nabble.com/Using-multile-texture-files-in-vtkOBJImporter-tp5744430.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/vtkusers



--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065

This communication, including all attachments, contains confidential and legally privileged information, and it is intended only for the use of the addressee.  Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. If you received this communication in error please notify us immediately and destroy the original message.  Thank you.

_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/vtkusers


_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Using multile texture files in vtkOBJImporter

vinmean
Thanks for the reply. What I had with me was a single mesh.obj, a single MTL file mesh.mtl and multiple texture files mesh_material0000_map_kd.png, mesh_material0001_map_kd.png, mesh_material0002_map_kd.png.

After setting the obj and mtl file names, I set only the first material  mesh_material0000_map_kd.png using the importer->setTexturePath(). I was able to get the complete 3D object with the textures applied.

I had asked this question because the  setTexturePath took only one texture file path. Even though my problem seems to be resolved, I am curious to understand if my scenario is different from "Only one texture per object". It would be great if you can point me to tutorials/materials which talk about how textures are applied because I didn't understand the statement "you have an OBJ file where one piece (material?), uses multiple textures and has multiple sets of texture coordinates per vertex"
Reply | Threaded
Open this post in threaded view
|

Re: Using multile texture files in vtkOBJImporter

Bill Lorensen
SetTexturePath is a directory that contains textures...

See this example:
https://lorensen.github.io/VTKExamples/site/Cxx/IO/OBJImporter/

that uses this data:
https://github.com/lorensen/VTKExamples/tree/master/src/Testing/Data/doorman

Bill


On Wed, Aug 16, 2017 at 9:18 PM, vinmean <[hidden email]> wrote:

> Thanks for the reply. What I had with me was a single mesh.obj, a single MTL
> file mesh.mtl and multiple texture files mesh_material0000_map_kd.png,
> mesh_material0001_map_kd.png, mesh_material0002_map_kd.png.
>
> After setting the obj and mtl file names, I set only the first material
> mesh_material0000_map_kd.png using the importer->setTexturePath(). I was
> able to get the complete 3D object with the textures applied.
>
> I had asked this question because the  setTexturePath took only one texture
> file path. Even though my problem seems to be resolved, I am curious to
> understand if my scenario is different from "/Only one texture per object/".
> It would be great if you can point me to tutorials/materials which talk
> about how textures are applied because I didn't understand the statement
> /"you have an OBJ file where one piece (material?), uses multiple textures
> and has multiple sets of texture coordinates per vertex"/
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Using-multile-texture-files-in-vtkOBJImporter-tp5744430p5744463.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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:
> http://public.kitware.com/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com
_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Using multile texture files in vtkOBJImporter

Ken Martin
In reply to this post by vinmean
It is possible to have multiple texture maps applied to a single surface where the texture maps are blended together using a blending function. That is the part we do not support. Hope that helps!

On Wed, Aug 16, 2017 at 9:18 PM, vinmean <[hidden email]> wrote:
Thanks for the reply. What I had with me was a single mesh.obj, a single MTL
file mesh.mtl and multiple texture files mesh_material0000_map_kd.png,
mesh_material0001_map_kd.png, mesh_material0002_map_kd.png.

After setting the obj and mtl file names, I set only the first material
mesh_material0000_map_kd.png using the importer->setTexturePath(). I was
able to get the complete 3D object with the textures applied.

I had asked this question because the  setTexturePath took only one texture
file path. Even though my problem seems to be resolved, I am curious to
understand if my scenario is different from "/Only one texture per object/".
It would be great if you can point me to tutorials/materials which talk
about how textures are applied because I didn't understand the statement
/"you have an OBJ file where one piece (material?), uses multiple textures
and has multiple sets of texture coordinates per vertex"/



--
View this message in context: http://vtk.1045678.n5.nabble.com/Using-multile-texture-files-in-vtkOBJImporter-tp5744430p5744463.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/vtkusers



--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065

This communication, including all attachments, contains confidential and legally privileged information, and it is intended only for the use of the addressee.  Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. If you received this communication in error please notify us immediately and destroy the original message.  Thank you.

_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/vtkusers