Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I've managed to import a Wavefront (.obj) file and store it in a variable like so:

model = Import[
    "/path_to_object/my.obj", 
    "Graphics3D", 
    Lighting -> {
        {"Ambient", RGBColor[{0.212, 0.168, 0.2}]},
        {"Directional", RGBColor[{0.8, 0., 0.}], ImageScaled[{2, 0, 2}]},
        {"Directional", RGBColor[{0., 0.8, 0.}], ImageScaled[{2, 2, 2}]},
        {"Directional", RGBColor[{0., 0., 0.8}], ImageScaled[{0, 2, 2}]}
    }
]

The output shows no black edges that you would normally see with Graphics3D objects, sort of like a "wireframe overlay". I've tried to call the Graphics3D function on model in this way:

Graphics3D[{AbsoluteThickness[2], AbsoluteDashing[{5, 5}], model}]

But I get the error:

Graphics is not a Graphics3D primitive or directive.

I've also tried adding more arguments to the Import function but I get the error:

Import::argt: Import called with 3 arguments; 1 or 2 arguments are expected.

Any ideas on how this can be accomplished? I saw that there is the command Mesh->All, but because I'm not that well versed with Mathematica yet, I don't know exactly how to apply a Mesh command to an imported Graphics3D object.

share|improve this question
    
Did you want something like DeleteCases[Import["ExampleData/wrench.obj.gz"], _EdgeForm, Infinity]? –  J. M. May 16 '13 at 14:21
    
@j-m That was fast. How can I mark your comment as the answer? =) –  sPLUS May 16 '13 at 14:26
    
Another hack for the way my .obj file is imported is: model /. EdgeForm[] -> EdgeForm[{Thick}] –  SEngstrom May 16 '13 at 14:30
    
Thanks for the helpful answers so far. –  sPLUS May 16 '13 at 16:38
add comment

2 Answers

up vote 6 down vote accepted

At OP's behest:

The easiest approach to see the mesh lines is to remove the EdgeForm[] instruction that causes them not to appear. For instance,

DeleteCases[Import["ExampleData/wrench.obj.gz"], _EdgeForm, ∞]

wrench with a mesh

As SEngstrom suggests, you can also use a replacement rule. If, for instance, you want a thick gray mesh, here's what you can do:

Import["ExampleData/wrench.obj.gz"] /. EdgeForm[] -> EdgeForm[Directive[Thick, Gray]]

wrench with a gray mesh

Finally, if you want a true wire frame (no polygons):

Import["ExampleData/wrench.obj.gz"] /. EdgeForm[] -> FaceForm[None]

wireframe wrench

share|improve this answer
add comment

What about this:

Import["ExampleData/wrench.obj.gz", "PolygonObjects"] // Graphics3D

enter image description here

You can use the FaceForm[None] trick as shown by @J.M. here just as well if you only want the wireframe looks.

share|improve this answer
    
I already showed this somewhere, but cannot find it right now... –  Yves Klett May 16 '13 at 15:18
    
Cool! I forgot you can specify properties in Import[]... –  J. M. May 16 '13 at 15:18
    
@J.M. `s rather well covered in the docs, too :-) –  Yves Klett May 16 '13 at 15:19
    
Hah, yes. I've gotten too used to Import["file.ext", filetype, opts] that I haven't been using the new features that much. –  J. M. May 16 '13 at 15:21
    
All right, it was just a comment on this one: mathematica.stackexchange.com/q/23543/131 –  Yves Klett May 16 '13 at 15:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.