0

The position of a box is updated by sending the position data in a list currentTargetPos. But when I run the following code in some loop, VPython displays a trail of all the positions box was given. There is this situation with the display. I want to display the most recent placement of box. How do I update the scene ?

from visual import *
bluebox=box(pos=vector(currentTargetPos[0], currentTargetPos[1], currentTargetPos[2]), size=  (1,1,1),color=color.cyan)
while 1:
    rate(100)
    break 

Edit: I do not have velocity data for the box. So I can not update the position using velocity. So this is basically not an animation in strict sense since while loop always breaks. But, I want to make it look like animation.

1
  • Have issues with the answer? Please accept, if it helps Commented Aug 2, 2016 at 20:39

1 Answer 1

0

If you're running the above code every time you update the position, then you're creating a new box each time, which would show multiple copies of it, at each used position.

Your loop, as shown doesn't really do anything. If you want to step through a list of values, you could do that inside the loop (I'm assuming that currentTargetPos is a list of components, x,y,z,,x,y,z,x,y,z,etc.):

counter = 0
while 1:
    rate(100)
    bluebox.pos = vector(currentTargetPos[z]+currentTargetPos[z+1]+currentTargetPos[z+2])
    counter = counter + 3
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.