![]() |
|
#1
|
|||
|
|||
|
getting position relative to an object
i'm running an experiment using vizard, and the experiment consists of having a balance board apparatus with a block placed at the boards center. the board starts to tilt at the start of a trial, and as it does so the block starts to slide accordingly. participants are tasked with keeping the board stable and the block within a target region that is located 1/4 of the board's length on the left side.
the board's color is black, as is the block's. the target region is denoted by a white block that has been added as a child to the board. what i would like to do is have the block's color change to white whenever it is within the target region. problem is, i don't know how to obtain the block's position relative to the board, rather than the world without setting the block as a child of the board. any suggestions? |
|
#2
|
|||
|
|||
|
Why don't you want the block to be a child of the board?
If you are using world coordinates you could get the distance between the block position and the target position using the vizmat.Distance command. If it's within a certain then change it's color. |
|
#3
|
|||
|
|||
|
works, thanks =-)
as for why i didn't want the block to be a child of the board, whenever i had it set up that way, the ball wouldn't slide the way i wanted it to. again, not sure why... |
|
#4
|
|||
|
|||
|
ok, new issue...
the block slides off more often than i expected during my trial runs, so i'm thinking of including "bookends" on the ends of each side of the board. Code:
global bar
bar = viz.add('box.wrl')
bar.setScale([BARLENGTH, CUBESIZE,CUBESIZE])
bar.setPosition(CENTERPOS)
bar.color(viz.BLACK)
barCollideShape = bar.collideBox()
barCollideShape.setDensity(DENSITY)
barCollideShape.setFriction(FRICTION)
end1=bar.add('box.wrl')
end1.setPosition((CENTERPOS[0]-.55, CENTERPOS[1]-4, CENTERPOS[2]-5))
end1.color(viz.WHITE)
end1.setScale([.05,3,1])
end1Collide = end1.collideBox()
end1.disable(viz.DYNAMICS)
end1Collide.setDensity(DENSITY)
|
|
#5
|
|||
|
|||
|
If you increase the scale value for the X dimension does it make a difference?
Code:
end1.setScale([.05,3,1]) |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| retrieve Object names | Geoffrey | Vizard | 11 | 12-11-2009 05:26 AM |
| Get a user's current position from an object? | cgibb | Vizard | 2 | 06-03-2009 06:47 PM |
| Randomising position of an object | ptjt255 | Vizard | 11 | 10-23-2008 03:27 AM |
| Can you link the position of a tracker to the orientation of an object? | michaelrepucci | Vizard | 1 | 09-19-2008 11:23 AM |
| Getting object position in screen coordinates | v-Salik | Vizard | 1 | 10-19-2007 04:41 PM |