x3d文件语法结构
x3d文件语法结构包含文件结构、文件头、文件体和注释。
x3d文件结构由x3d文件头、x3d主程序概貌组成。其中、x3d主程序概貌又包含头文档盒场景,头文档又包含组建和说明信息,场景包含x3d中的各种三维立体节点文件。
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE X3D PUBLIC "http://www.web3d.org/specifications/x3d-3.1.dtd"
- "file:///www.web3d.org/TaskGroups/x3d/translation/x3d-3.1.dtd">
- <!--Warning: transitional DOCTYPE in source .x3d file-->
- <X3D profile="Immersive" version="3.0"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.1.xsd">
- <head>
- <meta content="X3D Դʵ=name=" name="filename"/>
- <meta content="name=zjz" name="author"/>
- <meta content="*enter name of original author here*" name="creator"/>
- <meta
- content="*enter copyright information here* Example: Copyright (c) Web3D Consortium Inc. 2006" name="rights"/>
- <meta
- content="*enter online Uniform Resource Identifier (URI) or Uniform Resource Locator (URL) address for this file here*" name="identifier"/>
- <meta
- content="X3D-Edit, http://www.web3d.org/x3d/content/README.X3D-Edit.html" name="generator"/>
- </head>
- <Scene>
- <Background skyColor="0.98 0.98 0.98"/>
- <Transform translation="0 1 0">
- <Shape>
- <Appearance>
- <Material diffuseColor="0 1 0"/>
- </Appearance>
- <Sphere radius="1"/>
- </Shape>
- </Transform>
- <Transform translation="0 -1.6 0">
- <Shape>
- <Appearance>
- <Material diffuseColor="0 0 1"/>
- </Appearance>
- <Cone bottom="true" bottomRadius="2" height="4" side="true"/>
- </Shape>
- </Transform>
- </Scene>
- </X3D>
-
x3d头文件。在每个x3d文件中,文件头都必须位于x3d文件的第一行。x3d使用xml语法格式声明,<?xml version="1.0" encoding="UTF-8"?>,声明从“<?xml”开始,到“?>”结束,version属性指明编写文档的xml版本号,encoding表示使用编码字符集。
-
x3d文档类型声明。x3d文档类型声明用来在文档中详细地说明文档信息,必须出现在文档的第一个元素前,文档类型采用DTD格式:<!DOCTYPE X3D PUBLIC "http://www.web3d.org/specifications/x3d-3.1.dtd"
"file:///www.web3d.org/TaskGroups/x3d/translation/x3d-3.1.dtd"> -
x3d文件体。x3d文件主要描述的是x3d主程序概貌(profile),主程序概貌又涵盖了组件和说明信息,以及场景中的各个节点信息。x3d根文档标签:<X3D profile="Immersive" version="3.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.1.xsd"> </x3d> -
x3d头文档<head>描述: <head>
<meta content="X3D Դʵ=name=" name="filename"/>
<meta content="name=zjz" name="author"/>
<meta content="*enter name of original author here*" name="creator"/>
<meta
content="*enter copyright information here* Example: Copyright (c) Web3D Consortium Inc. 2006" name="rights"/>
<meta
content="*enter online Uniform Resource Identifier (URI) or Uniform Resource Locator (URL) address for this file here*" name="identifier"/>
<meta
content="X3D-Edit, http://www.web3d.org/x3d/content/README.X3D-Edit.html" name="generator"/>
</head> -
x3d场景主题<Scene>描述,场景主体由一对<Scene>和</Scene>组成,中间可以插入背景节点、视角节点、导航节点、几何几点、复杂造型节点等,用这些节点来创建场景三维立体空间所需要的各种场景和造型。 <Scene>
<Background skyColor="0.98 0.98 0.98"/>
<Transform translation="0 1 0">
<Shape>
<Appearance>
<Material diffuseColor="0 1 0"/>
</Appearance>
<Sphere radius="1"/>
</Shape>
</Transform>
<Transform translation="0 -1.6 0">
<Shape>
<Appearance>
<Material diffuseColor="0 0 1"/>
</Appearance>
<Cone bottom="true" bottomRadius="2" height="4" side="true"/>
</Shape>
</Transform>
</Scene> -
x3d文件注释:<!--Warning: transitional DOCTYPE in source .x3d file-->,注释以一个符号"<!--"开头,以"-->"结束。