构建正确的 VRML 模型
VRML 具有强大的建模能力,然而,VRML 浏览器主要不是为了计算任何对象的布尔集操作,而是解决它们的叠加并应用它们的视觉属性来创建场景视图
因此,构建您的模型必须依靠自己的几何图形进行一些简单的变换(旋转/平移),但没有任何实体建模代数
(Shape_A
+Shape_B
作为联合操作的一个例子(又名“胶水”实体形状在一起)是不可能的)
(Shape_A
-Shape_B
作为减法运算的一个例子(又名“钻”一个形状等于的孔Shape_B
(Shape_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>