taking pictures within the simulatoin
Sorry for anouther newbie questoin but im having troubles.
I have got a simulatoin which sort of works and have a small method in the iteratoin of the controller class which if a new animal that hasnt been found before investigate it , i want to take a picture of it as well so i have this code,although it zooms into the new creature perfectly , and takes a picture , it seems to take the picture before it zooms in.ive tryed moving the take picture code further down , and tryed putting a while loop in as well to give it more time. but no matter what i try it looks right but when i see the picture its been taken before its zoomed in.
any help would be appriated.
self point-camera at (0,0,0) from (1,1,1).
self zoom-camera to 20.
self watch item Tempwolf.
push itemhash onto hashlist .
filename="$selfchecktime1$itemhash.png".
self save-snapshot to filename.

taking pictures within the simulatoin
The way pictures are taken is that breve reads back the most recent image from the framebuffer. When you perform a zoom in your code (or any other camera operation), it doesn't change the image in the framebuffer -- it changes the way the next frame is rendered. In other words, no camera operations take effect until the next frame is rendered. So to do what you want to do, you'll have to zoom the camera in one iteration and take the picture in the next.
- jon
taking pictures within the simulatoin
Is there anyway i can force the backbuffer to be updated? unfortantly i may need to take more than one picture of differnt animals.I cant see how to make my code work if it has to wait for the next iteratoin.
thanks noz
taking pictures within the simulatoin
Though it may be an inconvenience, it should be possible to do what you want by using a Controller variable to keep track of when the picture it ready to be taken. Here's some sample (pseudo)code:
+ to iterate: if takePictureNextIteration: { # take the picture self save-png-snapshot ... takePictureNextIteration = 0. } + to prepare-for-snapshot: # point the camera where we want it self point-camera at ... takePictureNextIteration = 1.Some variation on that idea should do exactly what you want.
- jon
taking pictures within the simulatoin
Thankyou for your help. if i was only dealing with one creature to take a pic of i could easerly implement it.Although in my code im being selective and cant quite get my head around howto make a list or something like that , that will control what pictures get taken. if that makes seanse. i'll show my code becouse im probably just overlooking the obvious.
foreach Tempwolf in Wolflist: { itemhash=Tempwolf get-hashh. # get tempwolfs hash foreach temphash in hashlist: # hashlist contains every encountered hash { if (itemhash==temphash):{numberofthisspecies++.} # if the creatures hash has been seen before increase interger } if (numberofthisspecies==0): # if this creatures hash has not been seen before { self point-camera at (0,0,0) from (1,1,1). # this bit is to set up the viewing angle self zoom-camera to 20. self watch item Tempwolf. push itemhash onto hashlist . # put this creatures hash in seen before hashlist filename="$selfchecktime1$itemhash.png". # name the file with the time and the hash of the creature self save-snapshot to filename. # take the pic. } numberofthisspecies=0. }any help would be appriated
taking pictures within the simulatoin
Assuming that filename is a variable declared at the class level, simply add the variable jk mentioned as another class variable:
+ variables: filename (string). takePictureNextIteration (int).Replace this in your code:
self save-snapshot to filename. # take the pic.For this:
takePictureNextIteration = 1.Then simply add jk's code to your iterate method (or create one if you don't have any):
+ to iterate: if takePictureNextIteration: { takePictureNextIteration = 0. self save-snapshot to filename. # take the pic. }taking pictures within the simulatoin
I didnt think it would work right but i tryed anyway. It works if there is only one new species found but its quite differnt when theres more than one found. Thankyou for your help im going to change my code so it should only ever find one new species on each iteratoin. Thankyou for all your help:)