PDA

View Full Version : viz.link Objects


new_horizon
01-17-2011, 08:16 AM
Hi All,

I am working on a virtual city scene and need to attach an emitting lighting source to a motorcycle image. I have attempted this so far by placing a tif image onto a rectangle in vizard, then creating a white filled circle of the correct diameter and then attaching a light to it - however, whenever I attempt to link all of the above together, the object moves position and will not move to the coordinates that I try to place it at in the scene.

The code looks like this - if anyone can share any knowledge it would be greatly appreciated - probably a basic error to you guys!

# Create headlight shape
viz.startlayer(viz.POLY_FILL)
viz.vertexcolor(1,1,1)
Radius = 0.1
NUM_DOTS = 10000.0
for i in range(0, NUM_DOTS):
angle= 360.0*(i/NUM_DOTS)
x = Radius*math.sin(angle)
y = Radius*math.cos(angle)
# Put a vertex at each of these, but jump back to zero in between
viz.vertex(0,0)
viz.vertex(x,y)
headlight1 = viz.endlayer()
headlight1.color(1,1,1)
headlight1.setPosition(0,0.7,0)


# Create motorcycle with solo light #
bikesize = [0.75,1.65]
motorcycle0 = viz.addTexture('MC cropped v2.tif')
vehicle0 = viz.addTexQuad(viz.WORLD,viz.MainScene,1) # 1m sq quad
vehicle0.texture(motorcycle0)
vehicle0.setScale(bikesize[0], bikesize[1],1) #Size to bike width & height
vehicles[0] = vehicle0 # Note IMPORTANT saves the address of the object for later use
Obj_sz[2]= 2*Radius

#Add emissive light to headlight
beam = viz.addLight()
# Make light positional
beam.position(0,0.7,0)
# Make this positional light a spot light by limiting its spread
beam.spread(45)
beam.intensity(1)
viz.link(beam, headlight1)
viz.link(headlight1, vehicle0)
vehicle0.setPosition(0,0.625,0)

Thanks

Mark

Jeff
01-18-2011, 11:57 AM
In your last two lines you have:
viz.link(headlight1, vehicle0)
vehicle0.setPosition(0,0.625,0)
Since vehicle0 takes the position and orientation of headlight1 you won't be able to set the position of vehicle0.