2

我正在尝试在Vizard 4.0中创建一个自动生成 10,000 多个对象的世界。一旦制作了这些物体,我想飞过它们或让它们以一定的速度向我想要的任何方向移动。

我为此编写了代码,但它没有给我想要的 fps。目前,我使用此代码只能获得大约 7fps,并且我需要将其至少提高到 60fps。我试过移动它们和移动相机。但两者都给出相同的fps。我已经写了移动的部分,其中球只是在一个方向上自行移动,并且要使相机移动,您需要按住鼠标左键或鼠标右键或同时按住两者。

要运行这个程序,您首先需要从 worldviz 安装 Vizard。它带有 90 天的免费试用期。我对 Vizard 相当陌生,因此非常感谢任何帮助。谢谢

下面的代码:

enter code here

import viz
import vizact
import vizshape
import random
import vizinfo
import viztask


#Enable full screen anti-aliasing (FSAA) to smooth edges
viz.setMultiSample(4)

#Start World
viz.go(viz.FULLSCREEN)


#Increase the Field of View
viz.MainWindow.fov(60)

#Set my location 8 meters back from 0,0,0
viz.move([0,0,-8])


def Create_Shape(Number,x_pace,y_pace,z_pace,set_Time) :
    #create an array of shapes
    shapes = []
    #Generate Shapes
    for i in range(Number):
        #Generate random values for position and orientation
        x = random.randint(-100,100)
        y = random.randint(-100,100)
        z = random.randint(-100,100)

        #generate shapes

        shape = vizshape.addSphere()
        #shape.setScale(0.25,0.25,0.25)
        shape.setPosition([x,y,z])
    shapes.append(shape)

    #Move shapes
    move = vizact.move(x_pace,y_pace,z_pace,set_Time)
    #Loop through all shapes and move them
    for shape in shapes:
        shape.addAction(move)
        #return shapes
        return shapes

#Calls create shape with the number of shapes needed to be made and
#the speed and time for the shapes to move at
Create_Shape(10000,0,0,10,10000000)
4

1 回答 1

0

很久以前,当我在 Vizard 上工作时,我记得加载它们作为实例会更好地执行,内存和速度方面,不幸的是我不记得语法,但它是这样的

shape = vizshape.addSphere(x) // where x is a flag for loading as instance, cant recall it well :)
于 2013-09-29T13:53:23.557 回答