I used the collision of boxes that are placed in enviornment having two tables. I used the mouse cursor to grab the objects and placed in the other table. But i am facing one problem in case of collision detection between the objects. I used the proximity sensor for the objects and mouse when they are collided with each other ( minimum distance) then mouse picks/links that object. I am using the same sensor for collision also, some physics idea that are given in the documentation of vizard bt boxes are collided to each other but due to the gravity they are flying. i put the density as it is given in the documentation bt i does not works. Then idecided to move from this logic and try something else i tried to form the two proximity one for boxex collision and one between boxes and mouse but boxes are flying. I used the similar concept with crates that is define by vizard it work there bt not in the blocks. Please give some idea to resolve this problem. Here i am attaching thre function - one for hand , other for linking mouse and block and in last placing of blocks. In enviornment i already used the collide palne and collission for table also. So for collision what methodss i should go for because when i am working on same proximity sensors it will not works. All objects are placed in origin in vizard and then manually set the positions for plaing on table.`
global hand
hand = viz.addChild( 'marker.wrl' )
#hand.collidebox()
#xa,ya,za=hand.getPosition()
#hand.collideBox()
hand.enable(viz.COLLIDE_NOTIFY)
#hand.density=0.0000001
#viz.phys.setGravity([0,-1,0])
#vizact.onkeydown(' ', viz.phys.enable)
hand.setPosition( [-7.5, 1.2, -10] )
hand.setEuler(0,0,0)
hand.setScale(0.3,0.3,0.3)
ViewLink = viz.link(hand,viz.MainView)
viz.link(hand,device)
ViewLink.preEuler( [0,25 ,0] )
ViewLink.preTrans( [0,0.2,-0.5] )
def p_ball(e):
# print 'hit'
# global sound1
# sound1.play()
global bn
# grab = 1
# ball.addAction(blast
# b[z].addAction(blast)
for i in range(len(b)):
#global xh,zh
xh,yh,zh=hand.getPosition()
# zh= (zh)
# print 'abcd'
xb,yb,zb=b[i].getPosition()
zb= (abs(zb))
zh= (abs(zh))
xb= (abs(xb))
xh= (abs(xh))
#print zh,zb
if (abs(zh-zb)<.4 and abs(xh-xb)<.4):
# b[i].addAction(blast)
# b[i].visible(viz.OFF)
# b[i].visible(viz.ON)
global link
if bn==100:
link = None
link = viz.grab( hand, b[i] )
#tool.grabAndHold()
if link == True:
global Block1
Pos=Block1.getPosition(MODE=VIZ.REL_GLOBAL)
# else:
# print 'aaaaaa'
bn=i
#UpdateMovement()
#UpdateMovement()
global k
k=k+1
tbox2.message(str(k))
/i tried something here but it wont work. here i am using the proximity sensor for the collision of boxes.
xb11,yb11,zb11=b[0].getPosition() ####### proximity POSITION 1
print xb11,yb11,zb11
xb1= (abs(xb11))
zb1= (abs(zb11))
print xb1,zb1
xb22,yb22,zb22=b[1].getPosition() ` ` ####### proximity POSITION 2
print xb22,yb22,zb22
xb2= (abs(xb22))
zb2= (abs(zb22))
print xb2,zb2
xb33,yb33,zb33=b[2].getPosition() ` ` ####### proximity POSITION 3
print xb33,yb33,zb33
xb3= (abs(xb33))
zb3= (abs(zb33))
print xb3,zb3
#
# if ((zb1-zb2)<1.5 or (zb1-zb3)<1.5 or (xb1-xb2)<1.5
or (xb1-xb3)<1.5):
#
# print 'Ashish'
# global tbox22
# tbox22=viz.addTextbox()
# tbox22.setPosition(0.11,0.1,0.1)
# global touch11
# touch11='OBSTACLE-ERROR'
# tbox22.message(str(touch11))
#
# Block1.setPosition([-7.5,1.1,-2.9]) ` ####### POSITION OF THE BALLOON`
# Block2.setPosition([-7.5,1.1,-1.9]) ` ####### POSITION OF THE BALLOON`
#
# #Block0.setPosition(xb11-1,yb11,zb11-1) ` ####### POSITION OF THE BALLOON`
#
#
# elif ((zb2-zb1)<.5 or (zb2-zb3)<.5 or (xb2-xb1)<.5
or (xb2-xb3)<.5):
#
# print 'Ashish'
# global tbox22
# tbox22=viz.addTextbox()
#
# tbox22.setPosition(0.11,0.1,0.1)
# global touch11
# touch11='OBSTACLE-ERROR'
# tbox22.message(str(touch11))
#
# Block0.setPosition([-7.5,1.11,-3.7]) ` ####### POSITION OF THE BALLOON`
# Block2.setPosition([-7.5,1.1,-1.9]) ` ####### POSITION OF THE BALLOON`
#
# #Block1.setPosition(xb22-1,yb22,zb22-1) ` ####### POSITION OF THE BALLOON`
#
#
# elif ((zb3-zb1)<.5 or (zb3-zb2)<.5 or (xb3-xb1)<.5
or (xb3-xb2)<.5):`
#
# print 'Ashish'
# global tbox22
# tbox22=viz.addTextbox()
#
# tbox22.setPosition(0.11,0.03,0.1)
# global touch11
# touch11='OBSTACLE-ERROR'
# tbox22.message(str(touch11))
#
`# Block0.setPosition([-7.5,1.11,-3.7])` `
`# Block1.setPosition([-7.5,1.1,-2.9])` `
# #Block2.setPosition(xb33-1,yb33,zb33-1)
#abc()
fb()
/code for blocks i put the collision with the blocks same i put with plane /and tables while with ground plane then gravity pulls the object /downwards so i collision i used with the tables to`put the blocks on the /table
def put_balloons(manager_b,b,b_y,b2):
# import vizshape
# aa=vizshape.addCube()
# aa.setPosition(-7.5,1.1,2.4)
# kk=aa.collideBox()
# kk.density=100000
/BLOCK 1---------- TABLE 1 global Block0
Block0=viz.addChild('b2.osgb')
#crate = viz.addChild('crate.osgb',pos=[-7.38,1.2,-3.9])
#crate.visible(viz.OFF)
#crate.collideBox(density=50000000000)
#crate.alpha(0.3)
Block0.setPosition(-7.5,1.1,-3.7)
Block0.setEuler(90,0,0)
Block0.setScale(.3,.3,.3)
bs=vizproximity.addBoundingBoxSensor(Block0)
manager_b.addSensor(bs)
b.append(Block0)
#Block0.collideBox()
Block0.disable(viz.DYNAMICS)
# global link
# ss=viz.link(crate,Block0)
# ss.preTrans( [-0.17,-0.1,-.1 ])
# Block0.enable(viz.RENDERING)
/BLOCK 2---------- TABLE 1
global Block1
Block1=viz.addChild('b7.osgb')
#crate = viz.addChild('crate.osgb',pos=[-7.38,1.2,-3])
#crate.visible(viz.OFF)
#crate.collideBox(density=50000000000)
#crate.alpha(0.3)
Block1.setPosition(-7.5,1.1,-2.9)
Block1.setEuler(90,0,0)
Block1.setScale(.3,.3,.3)
bs=vizproximity.addBoundingBoxSensor(Block1)
manager_b.addSensor(bs)
b.append(Block1)
#Block1.collideBox()
Block1.disable(viz.DYNAMICS)
#Block1.enable(viz.RENDERING)
/BLOCK 3--------- TABLE
global Block2
Block2=viz.addChild('b9.osgb')
#crate = viz.addChild('crate.osgb',pos=[-7.38,1.2,-2.1])
#crate.visible(viz.OFF)
#crate.collideBox(density=50000000000)
#crate.alpha(0.3)
Block2.setPosition(-7.5,1.1,-1.9)
Block2.setEuler(90,0,0)
Block2.setScale(.3,.3,.3)
bs=vizproximity.addBoundingBoxSensor(Block2)
manager_b.addSensor(bs)
b.append(Block2)
Block2.collideBox()
#Block2.density=0.0000001
Block2.disable(viz.DYNAMICS)
#Block2.enable(viz.RENDERING)
/BLOCK 1----------TABLE2
global Block00
Block00=viz.addChild('b2.osgb')
Block00.setPosition(-7.5,1.15,4)
Block00.setEuler(90,0,0)
Block00.setScale(.3,.01,.3) #.025,.0004,.02,
b2.append(Block00)
/BLOCK 2----------TABLE2
global Block11
Block11=viz.addChild('b7.osgb')
Block11.setPosition(-7.5,1.15,5)
Block11.setEuler(90,0,0)
Block11.setScale(.3,.01,.3)
b2.append(Block11)
/BLOCK 3----------TABLE3
global Block22
Block22=viz.addChild('b9.osgb')
Block22.setPosition(-7.5,1.1,6)
Block22.setEuler(90,0,0)
Block22.setScale(.3,.01,.3)
b2.append(Block22)
#
#viz.phys.setGravity(0,-9) #Sets the Y plane gravity to -2
put_balloons(manager_b,b,b_y,b2)