![]() |
#1
|
|||
|
|||
Code Jumps under load
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 for graphInstance in graphBasket: 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 Loading File: ../resources/joNew/050305_ballBlueOpac.WRL Loading File: ../resources/joNew/050305_ballRedOpac.WRL timeElapsedWorld: 0.263915784652 timeElapsedWorld: 0.266729903628 timeElapsedWorld: 0.270578388046 Loading File: ../resources/joNew/050305_ballGreen.WRL 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
|
|||
|
|||
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
|
|||
|
|||
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: 050315_GoodMouseSelectMenues.py:976: SyntaxWarning: name 'counterGraphSelectMenue' is assigned to before global declaration 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
|
|||
|
|||
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
|
|||
|
|||
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): global beginPos0502, line0503,counterMaterialSelectMenue,info,i, counterGraphSelectMenue,infoArray0513 pos = viz.mousepos() #print 'mouse is currently at',pos if button == viz.MOUSEBUTTON_LEFT: if info.materialSelectLock==1: #print 'counterMaterialSelectMenue:',counterMaterialSelectMenue counterMaterialSelectMenue=counterMaterialSelectMenue%6 #print 'counterMaterialSelectMenue:',counterMaterialSelectMenue if (counterMaterialSelectMenue==0): radioPine.set(True) if (counterMaterialSelectMenue==1): radioPlastic.set(True) if (counterMaterialSelectMenue==2): radioGranite.set(True) if (counterMaterialSelectMenue==3): radioBronze.set(True) if (counterMaterialSelectMenue==4): radioSilver.set(True) if (counterMaterialSelectMenue==5): radioGold.set(True) counterMaterialSelectMenue=counterMaterialSelectMenue+1 if infoUIWorld.graphSelectLock==1: infoArray0513=infoUIWorldArray #print 'counterGraphSelectMenue:',counterGraphSelectMenue counterGraphSelectMenue=counterGraphSelectMenue%13 #print 'counterGraphSelectMenue:',counterGraphSelectMenue setMenueSelectionZero(infoUIWorldArray) selectUnselectMenueItem(infoUIWorldArray[counterGraphSelectMenue]) counterGraphSelectMenue=counterGraphSelectMenue+1 |
#6
|
|||
|
|||
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
|
|||
|
|||
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]] Loading File: ../resources/joNew/050305_ballGreenOpac.WRL 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) greyBallBasket.append(greyBall) print 'g',greyBallPositions del greyBallPositions[0] Loading File: ../resources/joNew/050305_ballGreenOpac.WRL 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, Loading File: ../resources/joNew/050305_ballBlue.WRL trial 1 slfvy 2.0 halooBall 1 Loading File: ../resources/joNew/050305_ballBlueOpac.WRL 0001j [[0.0, 0.98499999999999999, -0.40376310574821728]] gg [[0.0, 0.98499999999999999, -0.40376310574821728]] slfvy 2.0 gg [[0.0, 0.98499999999999999, -0.40376310574821728]] Loading File: ../resources/joNew/050305_ballGreenOpac.WRL 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
|
|||
|
|||
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 |
#9
|
|||
|
|||
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 Loading File: ../resources/joNew/050305_ballRedOpac.WRL 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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 |
|
|