Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.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 GLTF中的平移和缩放_Python_Gltf - Fatal编程技术网

Python GLTF中的平移和缩放

Python GLTF中的平移和缩放,python,gltf,Python,Gltf,我试图通过gltf显示多个框(具有不同的大小和位置) 我使用这个示例作为模板,简单地用新节点替换节点 当我将节点创建为 gltf["scenes"][0]["nodes"]=[] gltf["nodes"]=[] nodeId=0 for x, y, z, w, h, d in boxes: gltf["nodes"]+=[{ "mesh": 0, "translation": [x, y, z], "scale":[w, h, d]}] gltf["scenes"][

我试图通过gltf显示多个框(具有不同的大小和位置)

我使用这个示例作为模板,简单地用新节点替换节点

当我将节点创建为

 gltf["scenes"][0]["nodes"]=[]
 gltf["nodes"]=[]
 nodeId=0
 for x, y, z, w, h, d in boxes: 
    gltf["nodes"]+=[{ "mesh": 0, "translation": [x, y, z], "scale":[w, h, d]}]
    gltf["scenes"][0]["nodes"]+=[nodeId]
    nodeId+=1 
长方体(彼此相邻)碰撞(不仅在边上)。所以3d是错误的

当我在不缩放的情况下创建长方体时(从许多小长方体),它可以工作:

 gltf["scenes"][0]["nodes"]=[]
 gltf["nodes"]=[]
 nodeId=0
 for x, y, z, w, h, d in boxes: 
    for x1 in range(x, w+w):
        for y1 in range(y, y+w):
            for z1 in range(z, z+d):
                gltf["nodes"]+=[{"mesh": 0, "translation": [x1, y1, z1]}] 
                gltf["scences"][0]["nodes"]+=[nodeId]
                nodeId+=1      
但这当然是一个更大更复杂的gltf


框中的坐标是左下角(x、y和z值的最小值)

链接到的glTF示例框沿每个轴的顶点位置范围为
-0.5
0.5
。因此,要定位长方体,应将节点平移到长方体中心的位置

我还没有试着运行这段代码,但是对于表示方框角的
x,y,z
值,类似下面的内容应该将其更改为方框的中心。我所做的唯一改变是在译文中增加一半宽度、一半高度和一半深度

 gltf["scenes"][0]["nodes"]=[]
 gltf["nodes"]=[]
 nodeId=0
 for x, y, z, w, h, d in boxes: 
    gltf["nodes"]+=[{ "mesh": 0, "translation": [
       x + w/2,
       y + h/2,
       z + d/2
       ], "scale":[w, h, d]}]
    gltf["scenes"][0]["nodes"]+=[nodeId]
    nodeId+=1