Trouble drawing a polyhedron

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

Trouble drawing a polyhedron

TacoSupreme
I am experimenting with drawing polyhedrons and encountered this problem.

When I preview everything works, but when I render it the polyhedron doesn't
draw properly.   If I draw only the polyhedron it works, but if I also draw
another cube or something else it fails when rendering.

Here is a bit of code:

union(){
    polyhedron(
        points=[[0,0,0], [0,8,0], [4,0,0], [4,8,0], [4,0,4], [4,8,4]],
        faces=[[0,1,3,2],[0,1,5,4],[5,4,2,3],[0,4,2],[1,5,3]]
    );
    translate([4,0,0]) cube([2,8,4],false);
}

What is going on here?  I'm not sure what I did wrong.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Trouble drawing a polyhedron

MichaelAtOz
Administrator
Have a look at it with View/Thrown-together, see the purple triangles.
See  here
<https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/FAQ#Why_is_my_model_showing_up_with_F5_but_not_F6?>
.



-----
Admin - email* me if you need anything, or if I've done something stupid...

* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”   Fight it! http://www.ourfairdeal.org/   time is running out!
--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Admin - email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Trouble drawing a polyhedron

fred_dot_u
In reply to this post by TacoSupreme
I'm not a whiz when it comes to OpenSCAD, but I like challenges. I read the wiki page and have quoted a portion that applies here.

I also created a crib sheet to help me understand the point and faces of the model described.

The CW aspect was missed on three faces. Once corrected, all is good.

union(){
    polyhedron(
        points=[[0,0,0], [0,8,0], [4,0,0], [4,8,0], [4,0,4], [4,8,4]],
        //faces=[[0,1,3,2],[0,1,5,4],[5,4,2,3],[0,4,2],[1,5,3]]
        faces=[[0,2,3,1],[0,1,5,4],[5,3,2,4],[0,4,2],[1,3,5]]
    );
   translate([4,0,0]) cube([2,8,4],false);
}

/*
points

0 - 0 0 0 = origin
1 - 0 8 0 = top left flat
2 - 4 0 0 = lower right flat
3 - 4 8 0 = upper right flat   
4 - 4 0 4 = top point front
5 - 4 8 4 = top point rear

faces
bottom rectangle
0132 = origin, top left flat, upper right flat, lower right flat

left angled rectangle
0154 = origin, top left flat, top point rear, top point front

vertical right rectangle
5423 = top point rear, top point front, lower right flat, upper right flat

front triangle
042 = origin, top point front, lower right flat

rear triangle
153 = top left flat, top point rear, upper right flat

When viewed from the outside, the points describing each face must be in the same order . OpenSCAD prefers CW, and provides a mechanism for detecting CCW. When the thrown together view (F12) is used with F5, CCW faces are shown in pink. Reorder the points for incorrect faces. Rotate the object to view all faces. The pink view can be turned off with F10.

*/


On Wednesday, January 23, 2019, 5:05:52 PM EST, TacoSupreme <[hidden email]> wrote:


I am experimenting with drawing polyhedrons and encountered this problem.

When I preview everything works, but when I render it the polyhedron doesn't
draw properly.  If I draw only the polyhedron it works, but if I also draw
another cube or something else it fails when rendering.

Here is a bit of code:

union(){
    polyhedron(
        points=[[0,0,0], [0,8,0], [4,0,0], [4,8,0], [4,0,4], [4,8,4]],
        faces=[[0,1,3,2],[0,1,5,4],[5,4,2,3],[0,4,2],[1,5,3]]
    );
    translate([4,0,0]) cube([2,8,4],false);
}

What is going on here?  I'm not sure what I did wrong.



--

_______________________________________________
OpenSCAD mailing list

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Trouble drawing a polyhedron

TacoSupreme
In reply to this post by MichaelAtOz
Thanks for the help when I reordered some of the points it works perfectly
now.

faces=[[2,3,1,0],[3,2,4,5],[0,1,5,4],[0,4,2],[3,5,1]]



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Trouble drawing a polyhedron

ats3788
In reply to this post by MichaelAtOz
Hello check this out was working for me
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org