Message Boards Message Boards

Put a texture onto a 3d model?

GROUPS:

I am currently getting a mangled model whenever I try and add a texture. The obj file was obtained from exporting the heart model provided by wolfram. Any help would be appreciated.

ListSurfacePlot3D[Import["C:\\Users\\Ellis\\Documents\\theheartP4.obj", "VertexData"], 
 PlotStyle -> Texture[ExampleData[{"ColorTexture", "CheetahFur"}]]]

mangled model

POSTED BY: Fred Crithlow
Answer
21 days ago

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. If you do not format code, it may become corrupted and useless to other members. Please EDIT your posts and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

enter image description here

POSTED BY: Moderation Team
Answer
21 days ago

Which model of the heart was used? There is a 3D model

AnatomyData[Entity["AnatomicalStructure", "Heart"], "Graphics3D"]
POSTED BY: Alexander Trounev
Answer
21 days ago

The heart object that I used was the model from wolfram, but I still had a mangled end result.

POSTED BY: Fred Crithlow
Answer
21 days ago

You can add more options

ListSurfacePlot3D[Import["C:\\Users\\Ellis\\Documents\\theheartP4.obj", "VertexData"], 
PlotStyle -> Texture[ExampleData[{"ColorTexture", "CheetahFur"}]], MaxPlotPoints -> 35, Mesh -> None, PlotRange -> All]
POSTED BY: Alexander Trounev
Answer
21 days ago

I originally had those options used, changing the max plot points only changed how intricately the model was mangled.

ListSurfacePlot3D[
Import["C:\\Users\\Ellis\\Documents\\theheartP4.obj", "VertexData"], 
PlotStyle -> Texture[ExampleData[{"ColorTexture", "CheetahFur"}]], 
MaxPlotPoints -> 35, Mesh -> None, PlotRange -> All]

enter image description here

I have also used a few different models in case somehow the vertex data was incorrect prior to projecting a texture onto it.

POSTED BY: Fred Crithlow
Answer
21 days ago

First get the data from the Wolfram database:

heartModel = AnatomyData[Entity["AnatomicalStructure", "Heart"], "Graphics3D"];
furryTexture = Texture[ExampleData[{"ColorTexture", "CheetahFur"}]];

Then:

RegionPlot3D[
    DiscretizeGraphics@heartModel,
    PlotStyle -> furryTexture
 ]

enter image description here

POSTED BY: Hans Milton
Answer
20 days ago

Thank you! Also, do you know what was messing up my earlier attempts? How could I do this with any model that can be imported?

POSTED BY: Fred Crithlow
Answer
20 days ago

Dont know exactly what went wrong for you. But it probably has something to do with ListSurfacePlot3D/VertexData versus RegionPlot3D/DiscretizeGraphics. Compare these two examples:

shuttleModelA = ExampleData[{"Geometry3D", "SpaceShuttle"}];
RegionPlot3D@DiscretizeGraphics@shuttleModelA

enter image description here

shuttleModelB = ExampleData[{"Geometry3D", "SpaceShuttle"}, "VertexData"];
ListSurfacePlot3D[shuttleModelB, MaxPlotPoints -> 50]

enter image description here

POSTED BY: Hans Milton
Answer
20 days ago

On the other hand, the example from the textbook shows quite a good result using ListSurfacePlot3D

3DBunny

POSTED BY: Alexander Trounev
Answer
20 days ago

The texture on the bunny works, because the rendering of the basic model works with ListSurfacePlot3D, in this case. If the model rendering is not good the application of a texture will not improve the situation.

With ExampleData["Geometry3D"] it seems generally to be better to use RegionPlot3D/DiscretizeGraphics compared to the alternative ListSurfacePlot3D/VertexData.

Examples with the Klein Bottle:

RegionPlot3D@DiscretizeGraphics@ExampleData[{"Geometry3D", "KleinBottle"}]

enter image description here

ListSurfacePlot3D@ExampleData[{"Geometry3D", "KleinBottle"}, "VertexData"]

enter image description here

POSTED BY: Hans Milton
Answer
19 days ago

Group Abstract Group Abstract