Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. ListSurfacePlot3D[Import["inputImage.obj", "VertexData"],
  2. PlotStyle -> Texture[texture], Mesh -> None, MaxPlotPoints -> 80,
  3. TextureCoordinateFunction -> ({#1, -#2, #3} &)]
  4.  
  5. Graphics3D[
  6. {EdgeForm[],
  7. Texture[texture],
  8. GraphicsComplex[mesh,
  9. Polygon[polygon, VertexTextureCoordinates -> mesh]]}]
  10.  
  11. Import["inputImage.ply", "UserExtensions"][[2]]
  12. Import["inputImage.ply", "UserExtensions"][[3]]
  13.  
  14. "texture_u" -> {..}
  15. "texture_v" -> {..}
  16.  
  17. texturecoord = {Import["inputImage.ply", "UserExtensions"][[2]][[2]],
  18. Import["inputImage.ply", "UserExtensions"][[3]][[2]]} // Transpose
  19.  
  20. Graphics3D[
  21. {EdgeForm[],
  22. Texture[texture],
  23. GraphicsComplex[mesh,
  24. Polygon[polygon, VertexTextureCoordinates -> mesh]]}]
  25.  
  26. ListSurfacePlot3D[
  27. Import["inputImage.obj", "VertexData"],
  28. PlotStyle -> Texture[texture], Mesh -> None, MaxPlotPoints -> 80,
  29. TextureCoordinateFunction -> (If[#3 > 0.3, {0.7 #1 + 0.15, -#2 - 0.06}, {0.5, 0.9}] &),
  30. Lighting -> "Neutral"]
  31.  
  32. importOBJ[objfile_String, texturefile_String,
  33. opts : OptionsPattern[]] :=
  34. Module[{image, raw, verts, tverts, pgons, vertcoords},
  35. image = Import[texturefile];
  36. raw = Import[objfile, "Table"];
  37. If[
  38. Head /@ {image, raw} =!= {Image, List},
  39. Missing["NotAvailable"],
  40. verts = Rest /@ Cases[raw, {"v", __}];
  41. tverts = Rest /@ Cases[raw, {"vt", __}];
  42. {pgons, vertcoords} =
  43. Cases[raw, {"f",
  44. b__} :> (ToExpression@StringSplit[#, "/"] & /@ {b})] //
  45. Transpose[#, {2, 3, 1}] &;
  46. Graphics3D[
  47. GraphicsComplex[verts,
  48. {EdgeForm[], Texture[image],
  49. Polygon[#1,
  50. VertexTextureCoordinates -> tverts[[#2]]] & @@@
  51. Thread[{pgons, vertcoords}]}],
  52. opts]
  53. ]
  54. ];
  55.  
  56. objfile="https://git.io/viJXD";
  57. texturefile="http://i.stack.imgur.com/LmTQl.jpg";
  58.  
  59. importOBJ[objfile, texturefile, Boxed -> False, Lighting -> "Neutral"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement