3

I have a textured 3d model which has an obj file , mtl file and a png image for textures . I can visualize them without textures using trimesh and vtkplotter as :

//trimesh//
m = trimesh.load("3dmodel.obj")

//vtkplotter//
m = load("3dmodel.obj")

But they display the 3d models as plain meshes . I want to see them along with textures .

Can anyone please help me View the 3d models along with textures . Any small help would be greatly helpful .

RedBall
  • 311
  • 4
  • 12

3 Answers3

2

You can try the following:

from vtkplotter import load

# https://free3d.com/3d-model/091_aya-3dsmax-2020-189298.html
mesh = load("091_W_Aya_100K.obj").texture("tex/091_W_Aya_2K_01.jpg")
mesh.lighting('glossy') # change lighting (press k interactively)

mesh.show()

enter image description here

mmusy
  • 1,292
  • 9
  • 10
  • 2
    Thank You so much for the help . That saved my day . Huge Huge thumbs up for your immediate response . That worked great . Can I get in touch with you I have few more queries . Would you wish to help me if you can . I need to know how to deform the mesh and wrap one over another using vtkplotter . Could you help me . – RedBall Jan 19 '20 at 07:43
  • i'm happy that worked for you, an even faster way to get help is to open an issue in the github repo. There's a nr of examples about deforming meshes in https://github.com/marcomusy/vtkplotter-examples to see if any fits your needs. – mmusy Jan 19 '20 at 11:22
  • 1
    Sure will check there . Thanks for your support :) – RedBall Jan 19 '20 at 14:19
2

you can act like this:

import numpy as np
import trimesh
from PIL import Image

im = Image.open("Lmobl/texture.png")
mesh = trimesh.load('Lmobl/raw_model.obj',process=False)
tex = trimesh.visual.TextureVisuals(image=im)
mesh.visual.texture = tex
mesh.show()

and here the result: enter image description here

and for without texture, you'll find answer here

Ali Ganjbakhsh
  • 541
  • 7
  • 13
1

You can just use f3d for that : https://gitlab.kitware.com/f3d/f3d/-/releases

f3d /path/to/3dmodel.obj
Mathieu Westphal
  • 2,544
  • 1
  • 19
  • 33