0

我正在尝试使用 IndexedFaceSet 制作中间有窗口的墙模型,但我不知道如何实现。

这是我的代码:

#VRML V2.0 utf8

Shape {
    appearance Appearance {
        material Material {
            diffuseColor 1.0 1.0 1.0
        }
        texture ImageTexture {
            url "textures/stone.jpg"
        }
    }
    geometry IndexedFaceSet {
        coord Coordinate {
            point [
                -5.0 0.0 -1.0, -2.5 0.0 0.0,
                 2.5 0.0 0.0,  5.0 0.0 -1.0,
                 5.0 4.0 -1.0,  2.5 4.0 0.0,
                -2.5 4.0 0.0, -5.0 4.0 -1.0,
            ]
        }
        texCoord TextureCoordinate {
            point [
                0.0 0.0,  0.7 0.0,  0.7 0.7,  1.3 0.7,
                1.3 0.0,  2.0 0.0,  2.0 1.0,  0.0 1.0
            ]
        }
        coordIndex [ 0, 1, 2, 3, 4, 5, 6, 7 ]
        convex FALSE
        solid FALSE
    }
}

这是小屋的墙壁。我猜想,我需要在中间的另一个 IndexedFaceSet 充当墙上的一个洞,或者在我的情况下充当玻璃窗。这是一个学校项目。

谢谢

4

1 回答 1

1

构建正确的 VRML 模型

VRML 具有强大的建模能力,然而,VRML 浏览器主要不是为了计算任何对象的布尔集操作,而是解决它们的叠加并应用它们的视觉属性来创建场景视图

因此,构建您的模型必须依靠自己的几何图形进行一些简单的变换(旋转/平移),但没有任何实体建模代数

Shape_A+Shape_B作为联合操作的一个例子(又名“胶水”实体形状在一起)是不可能的)

Shape_A-Shape_B作为减法运算的一个例子(又名“钻”一个形状等于的孔Shape_BShape_A从 _A 中移除材料)也是不可能的)

是的,VRML 中有用于更智能的对象分组的对象层次结构,但这些并没有创建在墙上打洞的方法,也没有创建具有玻璃材料属性(不透明度、反射性等)的盒子。 )不会在视觉上渲染场景图以透明地显示全景图,就像通过墙上的窗户看到的一样。

如果不是不可逆转地固定在IndexedFaceSet{}一个人身上,可能会从四个部分(一个 leftSideBox、一个bottomBaseBox、一个rightSideBox 和一个upperLintelBox)组成一堵墙,作为一种组装或砌砖,所有这些盒子都仔细排列,并排,形成一堵墙,同时也“包围”了预期玻璃窗的自由空间。

原则上,这种被分解为一组普通表面三角形的四边形方法(并省略了接触平面各自部分上的相邻面)可以作为组装相同通孔的简单方法IndexedFaceSet{}。然而,为这些中的每一个编码 3D 坐标将是相当乏味的(如果不使用任何具有 VRML 输出的实体建模软件生成器)。

是的,对这些刻面进行纹理处理是另一个需要解决的复杂程度,尽管比制作一个只显示墙壁石头的玻璃窗要简单得多。

为了正确显示面,重要的是保持 2D 面法线向量指向 3D 体“外部”(角必须按逆时针顺序索引,以便右手手指跟随 ccw 方向拇指指向“向外”——从 2D 刻面的 ccw 定义的边缘开始。

看一看

#VRML V2.0 utf8

Background {   skyColor 0.9 0.9 1.0
               }
Viewpoint {    position 1.5 -1.5 1.75
               }
Transform {    translation 0, 0, 0
               children
               Shape {  appearance Appearance { material Material { diffuseColor 0.2 0.8 1.0 
                                                                    }
                                                }
                        geometry Box {          size 3 1 1
                                                }
                        }
               }
Transform {    translation 0, 0, 2
               children
               Shape {  appearance Appearance { material Material { diffuseColor 0.2 0.8 1.0 
                                                                    }
                                                }
                        geometry Box {          size 3 1 1
                                                }
                        }
               }
Transform {    translation 1,0,1
               children
               Shape {  appearance Appearance { material Material { diffuseColor 0.2 0.8 1.0 
                                                                    }
                                                }
                        geometry Box {          size 1 1 1
                                                }
                        }
               }
Transform {    translation -1,0,1
               children
               Shape {  appearance Appearance { material Material { diffuseColor 0.2 0.8 1.0 
                                                                    }
                                                }
                        geometry Box {          size 1 1 1
                                                }
                        }
               }

asHtml

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv='Content-Type' content='text/html;charset=utf-8'></meta>
    <link rel='stylesheet' type='text/css' href='http://www.x3dom.org/x3dom/release/x3dom.css'></link>
    <script type='text/javascript' src='http://www.x3dom.org/x3dom/release/x3dom.js'></script>
  </head>
  <body>
    <x3d id='someUniqueId' showStat='false' showLog='false' x='0px' y='0px' width='400px' height='400px'>
      <scene DEF='scene'>
        <background skyColor='0.9 0.9 1'></background>
        <viewpoint position='0 -2.5 1.75'></viewpoint>
        <transform>
          <shape>
            <appearance>
              <material diffuseColor='0.2 0.8 1'></material>
            </appearance>
            <box size='3 1 1'></box>
          </shape>
        </transform>
        <transform translation='0 0 2'>
          <shape>
            <appearance>
              <material diffuseColor='0.2 0.8 1'></material>
            </appearance>
            <box size='3 1 1'></box>
          </shape>
        </transform>
        <transform translation='1 0 1'>
          <shape>
            <appearance>
              <material diffuseColor='0.2 0.8 1'></material>
            </appearance>
            <box size='1 1 1'></box>
          </shape>
        </transform>
        <transform translation='-1 0 1'>
          <shape>
            <appearance>
              <material diffuseColor='0.2 0.8 1'></material>
            </appearance>
            <box size='1 1 1'></box>
          </shape>
        </transform>
      </scene>
    </x3d>
  </body>
</html>
于 2014-09-05T15:08:24.467 回答