x3dom的基本节点和用法(一)

x3dom的基本节点和用法(一)

绘图
    <Box></Box>//正方体
    <sphere><sphere>//球体
    //...基本图形请看官网

官网

使用节点IndexedLineSet连点画一个3棱锥.

     <IndexedFaceSet coordIndex="0 1 2-1 0 1 3 -1 0 2 3 -1 1 2 3 ">
       <Coordinate point="0 0 1  1 0 0   0 0 0   0 1 0"/>
     </IndexedFaceSet>

Coordinate为顶点的坐标,坐标(x,y,z)。按point的顺序,每三个为一个顶点,索引值从0开始,依次递增。

coorIndex为按索引值连线画面,以-1为分割。

外观与简单贴图
    <Shape>
     <Appearance>
         <Material diffuseColor="0 1 0"/>
         <ImageTexture url="xxx.png"/>
     </Appearance>
     <IndexedFaceSet coordIndex="0 1 2 3" solid="false">
         <Coordinate point="0 0 0 0 0 1 1 0 1 1 0 0  "/>
        <TextureCoordinate  point="0 0 ,1 0, 1 1, 0 1"/>
     </IndexedFaceSet>
    </Shape>

Material为当前shape的材质,diffuseColor可设置颜色。
ImageTexture为当前模型的贴图

TextureCoordinate为模型的贴图查找对应点,应当注意point的坐标为纹理贴图的坐标,索引值映射Coordinate point的索引值。每张图片都是矩形,选取像素点自行计算该点在纹理图的坐标。
这里写图片描述

Transform节点

对Transform的子节点进行移动translation和旋转rotation
- translation为(x,y,z)
- rotation为(x, y ,z, theta),x y z 为要围绕其旋转的轴的向量,theta为旋转的角度。
- center(x,y,z)为围绕的中心点。

    <Transform  rotation=" 1 0 0 3.1416" translation='1 0 0' center="0 0 0">
        <Shape>
        </Shape>
    </Transform>

详细例子

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值