IndexedFaceSet在x3d文件中创建额外的面

时间:2016-04-22 09:24:53

标签: x3d x3dom

我使用x3dom创建了一个x3d文件。以下是文件的结构。将以下代码复制到文本编辑器中并将其另存为.x3d文件。对于imgage texture,你可以考虑任何jpg文件并将它放在与x3d相同的位置。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"      
"http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Interchange' version='3.0'    
xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' 
xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
<Scene>
   <NavigationInfo type='"EXAMINE" "WALK" "FLY" "ANY"'/>
   <DirectionalLight intensity="0.8" direction="0 1 0"/>
   <DirectionalLight intensity="0.9" direction="0 -1 0"/>
   <DirectionalLight intensity="0.6" direction="1 0 -1"/>
   <DirectionalLight intensity="0.6" direction="-1 0 -1"/>
   <DirectionalLight intensity="0.6" direction="-1 0 1"/>
   <DirectionalLight intensity="0.6" direction="1 0 1"/>
   <Shape>
      <Appearance>
         <Material ambientIntensity="0.2" diffuseColor="0.004 0.004 0.004" emissiveColor="0 0 0" shininess="0.2" specularColor="0 0 0" transparency="0"/>
         <ImageTexture url="Penguins.jpg"/>
      </Appearance>
   <IndexedFaceSet convex="true" coordIndex="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 -1 " ccw="true">
       <Coordinate point="132.2349 0 329.9732 123.0347 0 336.9273 109.9391 0 350.0229 102.985 0 359.223 82.26761 0 386.6317 69.30841 0 436.438 74.03987 0 470.4683 78.77134 0 504.4987 104.8261 0 548.8805 132.2349 0 569.598 191.8598 0 569.598 191.8598 0 689.9727 911.8589 0 689.9727 1032.234 0 569.598 1032.234 0 270.3483 852.2339 0 270.3483 852.2339 0 210.7232 371.8596 0 210.7232 371.8596 0 329.9732"/>
   </IndexedFaceSet>
  </Shape>
  <Viewpoint description="Center of Space" fieldOfView="0.785" position="553.1368 60 450.348"/>
 </Scene>
</X3D>

从顶视图看,3D对象看起来像这样, enter image description here

从底部视图看起来像这样, enter image description here

我检查了所有的点,但是它们的顺序正确,但不确定为什么会创建这两个额外的面。我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

你绘制一个非凸形状,因此你需要将凸面设置为false,此外如果你想从“后面”看到你的形状,你需要将solid设置为false。

这有效:

<IndexedFaceSet convex="false" solid="false" coordIndex="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 -1">

(你不需要ccw,默认情况下是真的)