首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >搅拌机导入X3D层次结构

搅拌机导入X3D层次结构
EN

Stack Overflow用户
提问于 2012-10-09 17:02:18
回答 1查看 1.1K关注 0票数 0

我正在寻找如何从X3D文件导入对象层次结构到Blender 2.63工作区的方法。我知道\Blender\2.63\scripts\addons\io_scene_x3d\import_x3d.py中有一个python导入程序模块。

我发现,如果我将参数PREF_FLAT更改为True,就会创建转换节点的层次结构。但仅此而已什么都没有展示。

代码语言:javascript
复制
def load(operator, context, filepath="", global_matrix=None):

    load_web3d(filepath,
               PREF_FLAT=False,
               PREF_CIRCLE_DIV=16,
               global_matrix=global_matrix,
               )

    return {'FINISHED'}

有人知道如何正确地显示所有节点吗?

X3D场景示例

代码语言:javascript
复制
<?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='Immersive' >
<head> 
</head>
<Scene>
<Transform DEF='dad_Arm'
 translation='0 5 0'>
 <Transform DEF='dad_IndexedFaceSet2'
  containerField='children'
  translation='0 -5 0'>
  <Shape DEF='IndexedFaceSet2'
   containerField='children'>
   <Appearance
    containerField='appearance'>
    <Material DEF='Shiny_Blue'
     containerField='material'
     ambientIntensity='0.200'
     shininess='0.100'
     diffuseColor='0 0 1'
     specularColor='0 0 1'/>
   </Appearance>
   <IndexedFaceSet DEF='GeoIndexedFaceSet2'
    containerField='geometry'
    creaseAngle='0.524'
    coordIndex='
      0 16 1 -1
      1 16 2 -1
      2 16 3 -1
      3 16 4 -1
      4 16 5 -1
      5 16 6 -1
      6 16 7 -1
      7 16 8 -1
      8 16 9 -1
      9 16 10 -1
      10 16 11 -1
      11 16 12 -1
      12 16 13 -1
      13 16 14 -1
      14 16 15 -1
      15 16 0 -1
      18 33 17 -1
      19 33 18 -1
      20 33 19 -1
      21 33 20 -1
      22 33 21 -1
      23 33 22 -1
      24 33 23 -1
      25 33 24 -1
      26 33 25 -1
      27 33 26 -1
      28 33 27 -1
      29 33 28 -1
      30 33 29 -1
      31 33 30 -1
      32 33 31 -1
      17 33 32 -1
      0 18 17 -1
      18 0 1 -1
      1 19 18 -1
      19 1 2 -1
      2 20 19 -1
      20 2 3 -1
      3 21 20 -1
      21 3 4 -1
      4 22 21 -1
      22 4 5 -1
      5 23 22 -1
      23 5 6 -1
      6 24 23 -1
      24 6 7 -1
      7 25 24 -1
      25 7 8 -1
      8 26 25 -1
      26 8 9 -1
      9 27 26 -1
      27 9 10 -1
      10 28 27 -1
      28 10 11 -1
      11 29 28 -1
      29 11 12 -1
      12 30 29 -1
      30 12 13 -1
      13 31 30 -1
      31 13 14 -1
      14 32 31 -1
      32 14 15 -1
      15 17 32 -1
      17 15 0 -1'>
    <Coordinate DEF='IndexedFaceSet2_Coord'
     containerField='coord'
     point='
      0 5.1 10
      .03827 5.09239 10
      .07071 5.07071 10
      .09239 5.03827 10
      .1 5 10
      .09239 4.96173 10
      .07071 4.92929 10
      .03827 4.90761 10
      -0 4.9 10
      -.03827 4.90761 10
      -.07071 4.92929 10
      -.09239 4.96173 10
      -.1 5 10
      -.09239 5.03827 10
      -.07071 5.07071 10
      -.03827 5.09239 10
      0 5 10
      0 5.1 0
      .03827 5.09239 0
      .07071 5.07071 0
      .09239 5.03827 0
      .1 5 0
      .09239 4.96173 0
      .07071 4.92929 0
      .03827 4.90761 0
      -0 4.9 0
      -.03827 4.90761 0
      -.07071 4.92929 0
      -.09239 4.96173 0
      -.1 5 0
      -.09239 5.03827 0
      -.07071 5.07071 0
      -.03827 5.09239 0
      0 5 0'/>
   </IndexedFaceSet>
  </Shape>
 </Transform>
</Transform>
<Transform DEF='dad_Base'
 rotation='0 -1 0 1.571'>
 <Transform DEF='dad_IndexedFaceSet3'
  containerField='children'
  rotation='0 1 0 1.571'>
  <Shape DEF='IndexedFaceSet3'
   containerField='children'>
   <Appearance
    containerField='appearance'>
    <Material DEF='Shiny_Green'
     containerField='material'
     ambientIntensity='0.200'
     shininess='0.100'
     diffuseColor='0 1 0'
     specularColor='0 1 0'/>
   </Appearance>
   <IndexedFaceSet DEF='GeoIndexedFaceSet3'
    containerField='geometry'
    creaseAngle='0.524'
    coordIndex='
      1 16 0 -1
      2 16 1 -1
      3 16 2 -1
      4 16 3 -1
      5 16 4 -1
      6 16 5 -1
      7 16 6 -1
      8 16 7 -1
      9 16 8 -1
      10 16 9 -1
      11 16 10 -1
      12 16 11 -1
      13 16 12 -1
      14 16 13 -1
      15 16 14 -1
      0 16 15 -1
      1 0 17 -1
      2 1 17 -1
      3 2 17 -1
      4 3 17 -1
      5 4 17 -1
      6 5 17 -1
      7 6 17 -1
      8 7 17 -1
      9 8 17 -1
      10 9 17 -1
      11 10 17 -1
      12 11 17 -1
      13 12 17 -1
      14 13 17 -1
      15 14 17 -1
      0 15 17 -1'>
    <Coordinate DEF='IndexedFaceSet3_Coord'
     containerField='coord'
     point='
      5 0 0
      4.6194 0 1.91342
      3.53553 0 3.53553
      1.91342 0 4.6194
      0 0 5
      -1.91342 0 4.6194
      -3.53553 0 3.53553
      -4.6194 0 1.91342
      -5 0 -0
      -4.6194 0 -1.91342
      -3.53553 0 -3.53553
      -1.91342 0 -4.6194
      0 0 -5
      1.91342 0 -4.6194
      3.53553 0 -3.53553
      4.6194 0 -1.91342
      0 0 0
      0 5 0'/>
       </IndexedFaceSet>
      </Shape>
     </Transform>
    </Transform>
    </Scene>
    </X3D>
EN

回答 1

Stack Overflow用户

发布于 2013-07-10 11:24:42

最近我遇到了一个类似的问题,这就是我正在使用的python脚本:

import_x3d.py:

代码语言:javascript
复制
import sys
import os

sys.path.append(r'/path_to_blender/bin/2.63/scripts/addons/io_scene_x3d/')

import bpy
from bpy_extras.io_utils import axis_conversion
import import_x3d

global_matrix = axis_conversion('-Y','Z','-Z','Y').to_4x4()

import_x3d.load_web3d('/path_to_x3dfile/scene.x3d',
           PREF_FLAT=True,
           PREF_CIRCLE_DIV=16,
           global_matrix = global_matrix
    )

bpy.context.scene.camera = bpy.data.objects['Viewpoint']

您将需要创建一个空搅拌机场景,在其中您将导入x3d文件。之后,只需从命令行执行,如下所示:

代码语言:javascript
复制
./blender blank.blend -P import_x3d.py

我不确定这是否真的是你所需要的,但我希望它能有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12804889

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档