WorldViz User Forum Code Jumps under load
 Register FAQ Search Today's Posts Mark Forums Read

#1
03-16-2005, 09:33 AM
 Johannes Member Join Date: Jan 2005 Posts: 143

Sorry for this funny topic :

There seem to be code-jumps occurring when a lot of processing has to be done:

More specific:

Code:
```				timeElapsedWorld=(time.clock()-worldTime)/slowDown + gliderObj.timeElapsedWorldBeforeBreak
glider.translate(glider.actualPos.get())
ballCannon.translate(0,gliderObj.get(viz.POSITION)[1]+0.065*math.cos(bogenConv(slope))+0.03*math.cos(bogenConv(slope+ballAngle)),gliderObj.get(viz.POSITION)[2]+0.065*math.sin(bogenConv(slope))+0.03*math.sin(bogenConv(slope+ballAngle)))
catcher.translate(gliderObj.actualPos[0],gliderObj.actualPos[1]+0.065*math.cos(bogenConv(slope))+0.06*math.cos(bogenConv(slope+ballAngle)),gliderObj.actualPos[2]+0.065*math.sin(bogenConv(slope))+0.06*math.sin(bogenConv(slope+ballAngle)))
catcherWall.translate(gliderObj.actualPos[0],gliderObj.actualPos[1]+0.065*math.cos(bogenConv(slope))+0.07*math.cos(bogenConv(slope+ballAngle)),gliderObj.actualPos[2]+0.065*math.sin(bogenConv(slope))+0.07*math.sin(bogenConv(slope+ballAngle)))
glider.actualVelocityOld=glider.actualVelocity

#1=position 2=velocity in z direction 3=acceleration 11=position on airtrack (total) 12=position in y direction 21=velocity total 22 velocity in y direction 31=acceleration total 32=acceleration in y direction

if (graphInstance.graphWhat==1):
print "timeElapsedWorld:",timeElapsedWorld
```

I get the following printouts (only if the program is under stress - a lot of balls flying etc.)

timeElapsedWorld: 1.53241976489
timeElapsedWorld: 0.25782304277
timeElapsedWorld: 0.259737781056
timeElapsedWorld: 0.261517913083
timeElapsedWorld: 0.263915784652
timeElapsedWorld: 0.266729903628
timeElapsedWorld: 0.270578388046
timeElapsedWorld: 0.27311529934
timeElapsedWorld: 1.65854041329

Any ideas?
When I turn slowDown to 1 there does not seem to be a problem. Is it possible that the division is skipped?

Johannes
#2
03-16-2005, 11:35 AM
 farshizzo WorldViz Team Member Join Date: Mar 2003 Posts: 2,849
The division is not being skipped. The slowdown might occur from loading the wrl files. Does it occur when you are not loading files?
#3
03-16-2005, 03:11 PM
 Johannes Member Join Date: Jan 2005 Posts: 143
sorry,I found my mistake:

the global variable timeElapsedWorld was changed in anothter director function while this one was executed.

Thank you,
Johannes

P.S. not important but would be nice to know:
def mouseclick(button):

But I did declare counterGraphSelectMenue=-1 in line 40 (at the beginning)

I know the warning does not matter but I still want to understand.
#4
03-16-2005, 03:20 PM
 farshizzo WorldViz Team Member Join Date: Mar 2003 Posts: 2,849
Can you post the code of your mouseclick function? What is probably happening is that you are using the counterGraphSelectMenue variable before you declare it global.
#5
03-16-2005, 03:26 PM
 Johannes Member Join Date: Jan 2005 Posts: 143
don't think so, but here is the code (purpose is to get access to the menue while being in VR):

Code:
```def mouseclick(button):
pos = viz.mousepos()
#print 'mouse is currently at',pos
if button == viz.MOUSEBUTTON_LEFT:
if info.materialSelectLock==1:

if infoUIWorld.graphSelectLock==1:
infoArray0513=infoUIWorldArray

the mouseclick function goes on but as it is declared global in the first line of mouseclick it normally should be fine. Guess I will have to live with the "warning"
#6
03-17-2005, 08:37 AM
 Johannes Member Join Date: Jan 2005 Posts: 143
The problem was that I declared it global two times in the same def

Strange that I got this kind of error-message though.

Have a great day,
Johannes
#7
03-22-2005, 06:33 PM
 Johannes Member Join Date: Jan 2005 Posts: 143
Strange Print out

Working since hours on the following strange behavior:

I append the position of a ball to an array (in a director function).

Then I draw the ball in a timer function. It usually works fine but sometimes it just does not draw the ball (load the file) even though it should!

The following code should produce the print out pattern

g [[0.0, 0.98499999999999999, -0.7870197730163716]]
g [[0.0, 0.98499999999999999, -0.7870197730163716]]

but it does not:

Code:
```if len(greyBallPositions) >0:
print 'g',greyBallPositions
for greyBallP in greyBallPositions:
greyBall=BallSubClass('hallo1')
greyBall.getTrial(0)
greyBall.initializeValues()
greyBall.translate(greyBallP)
print 'g',greyBallPositions
del greyBallPositions[0]```

g [[0.0, 0.98499999999999999, -0.7870197730163716]]
slfvy 2.0
g [[0.0, 0.98499999999999999, -0.7870197730163716]]

Why?

In the above case it is still working, in a case where the loading is printed even earlier it is not.

e,g,

trial 1
slfvy 2.0
halooBall 1
0001j [[0.0, 0.98499999999999999, -0.40376310574821728]]
gg [[0.0, 0.98499999999999999, -0.40376310574821728]]
slfvy 2.0
gg [[0.0, 0.98499999999999999, -0.40376310574821728]]
g [[0.0, 1.1785294171243699, -0.28742693506383571]]
slfvy 2.0
g [[0.0, 1.1785294171243699, -0.28742693506383571]]

At 0001j the position for the ball ist just loaded in the array greyBallPositions.

The greyBalls are subjobjects of the class Ball, maybe I made something wrong there?

It is getting late, so I might not be that clear...
Johannes
#8
03-23-2005, 10:45 AM
 farshizzo WorldViz Team Member Join Date: Mar 2003 Posts: 2,849
Sometimes python print statements are buffered. To flush them you can do the following:
Code:
```import sys
.
.
.
print 'output'
sys.stdout.flush() #Flush print buffer```
Try flushing after each call to print, this should fix your problem.
#9
03-23-2005, 11:09 AM
 Johannes Member Join Date: Jan 2005 Posts: 143
Thank you, that fixes my confusion about the printouts!

The problem thought still persists and should not exist following the printout, I will explain it:

The position of the redOpaque gets transferred to an array (inside a director function):
000j2 [[-0.20000000000000001, 0.84999999999999998, -0.59523463611544603]]

in a timer-function I printout the array:
ggg [[-0.20000000000000001, 0.84999999999999998, -0.59523463611544603]]

So the position is in it.

When the BallSubClass is called a new object get's created. Which is working as I see

It is also accessing the superClass to initialize Values (Speed =2):
slfvy 2.0

The position is still in the array before it get's deleted.
ggg [[-0.20000000000000001, 0.84999999999999998, -0.59523463611544603]]

I wonder why I see the loading file but don't see the ball in my scene? This error is happening seldom, usually it works but sometimes it does not work. I was not able to find a pattern yet.

Johannes
#10
03-28-2005, 10:36 AM
 Johannes Member Join Date: Jan 2005 Posts: 143
Could not solve the above problem yet, as it seemes the object get's loaded but does not get drawn... But I guess I have to figure that out by myself...

Other question:

1. How can I use a certain plane as a floor but the plane should be used endless?

2. Just bought some shutter glasses (e-d). Do you have experience, which mode would you set viz.go() to, e.g.
viz.go(viz.STEREO) or CRYSTAL
or ... I guess I just have to try... just if you have a short hint, that does not cost you too much time!

Johannes
#11
03-28-2005, 12:31 PM
 farshizzo WorldViz Team Member Join Date: Mar 2003 Posts: 2,849
1) Have you tried applying a large scale to your ground plane? This should be sufficient in most cases. You can also take a look at the following thread which describes a method of creating a truly infinite ground plane, http://www.worldviz.com/forum/showth...3?threadid=197

2) If you have an nVidia Quadro graphics card then you can use Quad Buffer stereo by initializing vizard with the viz.QUAD_BUFFER flag. Otherwise you can download nVidia's stereo drivers, which will automatically render your scene for shutter glasses.

3) I can't tell why the object is not being rendered. Make sure that the visiblity flag of the object is not set to 0 or that the alpha is not set to 0. Also, make sure that the object is not being occluded by another object.
#12
03-29-2005, 12:27 PM
 Johannes Member Join Date: Jan 2005 Posts: 143
Dear Farshid,

Thank you!

Quad Buffer works, but there is a dark shadow at the lower end of the screen, which moves as I move. I will also try on a better monitor, with higher frequency...

Johannes

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements Vizard Precision Position Tracker (PPT) Plug-in development

All times are GMT -7. The time now is 03:36 AM.