Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 混合器导入X3D层次结构_Python_Blender_X3d - Fatal编程技术网

Python 混合器导入X3D层次结构

Python 混合器导入X3D层次结构,python,blender,x3d,Python,Blender,X3d,我正在寻找如何将对象层次结构从X3D文件导入Blender 2.63工作区的方法。我知道在\Blender\2.63\scripts\addons\io\u scene\u x3d\import\u x3d.py中有一个python导入器模块 我发现,如果我将参数PREF_FLAT更改为True,就会创建转换节点的层次结构。但仅此而已,没有显示任何内容 def load(operator, context, filepath="", global_matrix=None): load_

我正在寻找如何将对象层次结构从X3D文件导入Blender 2.63工作区的方法。我知道在\Blender\2.63\scripts\addons\io\u scene\u x3d\import\u x3d.py中有一个python导入器模块

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

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场景示例

<?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>

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

导入\u x3d.py:

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文件。 然后从命令行执行,如下所示:

./blender blank.blend -P import_x3d.py

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

您已经解决了这个问题吗?也许你可以提供一个小的演示x3d文件,如果你没有。我专注于另一个问题,所以我只是张贴pone解决这个问题。我可以将简单的输入示例发布到Row。