PDA

View Full Version : Problems with making multiple objects from one .wrl?


mjabon
07-09-2007, 10:05 PM
Hello. I am having problems when I use a for loop to create a bunch of objects from one wrl. I want them all to be draggable by the hd. This is what I write:

for i in range(0,num):
rnumx = random.random()
rnumz = random.random()
#print rnum
screw = viz.add(SCREW_FILE)
tex = viz.add(SCREW_TEXTURE)
screw.texture(tex)
screw.scale(scale,SCREW_LENGTH,scale)
screw.rotate(1,0,0,90)
screw.translate(0,0,0)
screw.translate(x + r*rnumx,y + rnumz,z)
allObjects.append(screw)
screws.append(screw)
screw.visible(1)
hd.add(screw)
screw.stiffness(1.0)

But I can only pick up the first one.

farshizzo
07-10-2007, 11:03 AM
Hi,

Are you getting any error messages? The code looks OK. Could you try reposting the code with the tags so that the formatting is preserved?

mjabon
07-10-2007, 12:53 PM
Well, I've attached the whole py file so maybe you can see the problem. Basically what happens is I make 4 screws, and the haptic pen picks up one and drags it - no problem. Then I pick up another one. I drag it somewhere. Then I go to pick up a 4th screw, but when I click down on it the pen magically moves the 2nd screw, even though I'm nowhere near it. It gets stuck on that one scerw, and no matter where I click it will drag that screw. It is weird.

mjabon
07-10-2007, 01:23 PM
actually, it seems to be working. I think the haptic pen is just a little picky