如何绘制10000 +对象和移动他们,并获得60fps+在Vizard Python



我试图在Vizard 4.0中创建一个自动生成10,000+对象的世界。一旦这些物体被制造出来,我想要飞过它们,或者让它们以一定的速度向我想要的方向移动。

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

要运行此程序,您首先需要从worldviz安装wizard。它提供90天的免费试用。我是相当新的巫师,所以任何帮助将非常感激。谢谢你

下面的代码:

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)

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

shape = vizshape.addSphere(x) // where x is a flag for loading as instance, cant recall it well :)

相关内容

最新更新