Gnuplot: Respect depthorder for Gnuplot 3d polygons

前端 未结 3 593
梦如初夏
梦如初夏 2021-01-18 04:31

I have a 3D model of a complete city, and would like to show an isometric view of those buildings. I use gnuplot polygons for this, since I don\'t think I can use pm3d for p

3条回答
  •  忘掉有多难
    2021-01-18 04:53

    Even though this is old question, I believe that made some progress in this sense. I used x-y-z data instead polygons.The correct z-order is achieved creating the faces in a certain sequence. I used a datafile named house.dat

    0.0000   0.0000   0.0000
    2.0000   0.0000   0.0000
    2.0000   0.0000   3.0000
    1.0001   0.0000   4.0000
    0.9999   0.0000   4.0000
    0.0000   0.0000   3.0000
    0.0000   0.0000   0.0000
    
    2.0000   0.0000   0.0000
    2.0000   2.0000   0.0000
    2.0000   2.0000   3.0000
    1.0001   2.0000   4.0000
    1.0001   0.0000   4.0000
    2.0000   0.0000   3.0000
    2.0000   0.0000   0.0000
    
    2.0000   2.0000   0.0000
    0.0000   2.0000   0.0000
    0.0000   2.0000   3.0000
    0.9999   2.0000   4.0000
    1.0001   2.0000   4.0000
    2.0000   2.0000   3.0000
    2.0000   2.0000   0.0000
    
    2.0000   0.0000   0.0000
    0.0000   0.0000   0.0000
    0.0000   0.0000   3.0000
    0.9999   0.0000   4.0000
    0.9999   2.0000   4.0000
    0.0000   2.0000   3.0000
    0.0000   2.0000   0.0000
    2.0000   0.0000   0.0000
    

    and this gnuplot script

    set terminal pngcairo font ',10'
    set output "house.png"
    set view equal xyz
    set view ,,1.5
    unset tics
    set xyplane at 0
    set pm3d depthorder lighting border lw 0.5
    set grid ls -1 lc "gray"
    set xrange [-1:5]
    set yrange [-1:3]
    set zrange [0:4]
    set cbrange [0:4]
    unset colorbox
    unset key
    unset border
    
    set object polygon from \
        graph 0, 0, 0 to \
        graph 1, 0, 0 to \
        graph 1, 1, 0 to \
        graph 0, 1, 0 to \
        graph 0, 0, 0 fc rgb "dark-plum" fs transparent solid 0.50 noborder
    
    splot \
        "house.dat" u   ($1):2:3:3 w pm3d ,\
        "house.dat" u ($1+2):2:3:3 w pm3d 
    

    to achieve this result:

    Formally It's works for any angle:

提交回复
热议问题