WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 05-08-2013, 12:01 PM
Queenss_RA Queenss_RA is offline
Member
 
Join Date: May 2013
Posts: 4
How to make my code more efficent.

Hi everyone,

I am trying to create a world that automatically generates 10,000+ objects in it and once these objects have been made I want to fly through them or make them move at a certain speed in any direction I want. I have written code for this but It is not giving me the fps I want. Currently I only get about 7fps with this code and I need this to up to 60fps minimum. I have tried both moving them and moving the camera. But give the same fps. I am fairly new to vizard so any help would be much appreciated. Thank you

CODE BELOW:

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)
Reply With Quote
  #2  
Old 05-09-2013, 03:45 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
That's a lot of separate objects to be rendering and animating per frame. Do you actually need each object to be a fully modeled sphere, or is a point sprite acceptable. You can most likely achieve your desired frame rate by rendering all the objects as a single mesh of points, and animated the points within a vertex shader. If you are interested in going along with this method, then I can provide some sample code.
Reply With Quote
  #3  
Old 05-13-2013, 09:22 AM
Queenss_RA Queenss_RA is offline
Member
 
Join Date: May 2013
Posts: 4
Yeah that would be great! I changed it from spheres to squares thinking that would make it faster, which it did. But this only makes it faster for rotation not translation.
Reply With Quote
Reply

Tags
advice, code, efficent, optimization

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Sphinx to generate code documents nabrahamson Vizard 0 10-31-2011 07:38 AM
Suggestion: Code Browser kopper Vizard 5 05-23-2011 03:39 AM
How to make character animation sequence wchoi Vizard 3 01-22-2010 08:35 AM
Any ideas on linking chess 3ds file with source code? djones1010 Vizard 1 04-24-2009 09:56 PM


All times are GMT -7. The time now is 07:53 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC