【问题标题】:VRML Indexed FaceSetVRML 索引人脸集
【发布时间】:2011-02-27 09:04:02
【问题描述】:

您好,我正在尝试在 VRML 上使用 Indexed FaceSet 制作实体。问题是没有出现 2 张面孔,我真的不知道为什么。

代码是:

Shape {
                    geometry IndexedFaceSet {
                        coord Coordinate {
                            point [0 0 0,     #0
                                0.3 0 0,      #1
                                0 1.2 0,      #2
                                0.3 1.2 0,    #3
                                0 0 -1,       #4
                                0.3 0 -1,     #5
                                0 1.2 -1,     #6
                                0.3 1.2 -1,   #7
                                0.6 1.2 -0.3, #8
                                0.6 1.2 -0.7] #9
                            }   
                            coordIndex [6 7 9 8 3 2 -1,
                                0 1 5 4 -1,
                                1 5 9 8 -1,
                                0 1 3 2 -1,
                                4 5 7 6 -1,
                                0 4 6 2 -1,
                                3 1 8 -1,
                                7 5 9 -1
                            ]

                        }

                    appearance Appearance { material Material { diffuseColor 0 0 0.8 }}
                }

没有出现的 2 个面是最后一个面。有什么想法吗?

【问题讨论】:

    标签: vrml


    【解决方案1】:

    首先,必须以逆时针顺序定义每一面才能可见,因为 IndexedFaceSet 对象是单面的,除非您使用 solid FALSE,这就是为什么您的模型中的某些面看起来像是缺失的原因,但是它们实际上是从另一侧可见的。


    解决方案 1:实心 FALSE

    从两侧都可以看到面,因此无论是顺时针还是逆时针定义它们都没有关系。这很简单,但它会使查看器在内部渲染的多边形数量增加一倍。

    #VRML V2.0 utf8
    
    Shape {
        appearance Appearance {
            material Material {
                diffuseColor 0 0 0.8
            }
        }
        geometry IndexedFaceSet {
            solid FALSE
            coord Coordinate {
                point [0 0 0, 0.3 0 0, 0 1.2 0, 0.3 1.2 0, 0 0 -1 0.3 0 -1, 0 1.2 -1, 0.3 1.2 -1, 0.6 1.2 -0.3, 0.6 1.2 -0.7]
            }
            coordIndex [
                6 7 9 8 3 2 -1,
                0 1 5 4 -1,
                1 5 9 8 -1,
                0 1 3 2 -1,
                4 5 7 6 -1,
                0 4 6 2 -1,
                3 1 8 -1,
                7 5 9 -1
            ]
        }
    }
    

    解决方案 2:翻转有缺陷的面孔

    反转应该翻转的特定面的顶点顺序。

    #VRML V2.0 utf8
    
    Shape {
        appearance Appearance {
            material Material {
                diffuseColor 0 0 0.8
            }
        }
        geometry IndexedFaceSet {
            coord Coordinate {
                point [0 0 0, 0.3 0 0, 0 1.2 0, 0.3 1.2 0, 0 0 -1 0.3 0 -1, 0 1.2 -1, 0.3 1.2 -1, 0.6 1.2 -0.3, 0.6 1.2 -0.7]
            }
            coordIndex [
                2 3 8 9 7 6 -1, # flipped
                4 5 1 0 -1,     # flipped
                1 5 9 8 -1,
                0 1 3 2 -1,
                6 7 5 4 -1,     # flipped
                2 6 4 0 -1,     # flipped
                3 1 8 -1,
                9 5 7 -1        # flipped
            ]
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-08-15
      • 2020-09-21
      • 2019-12-31
      • 2014-06-04
      • 2016-05-23
      • 2020-07-29
      • 2011-12-14
      • 1970-01-01
      • 2016-12-16
      相关资源
      最近更新 更多