PDA

View Full Version : Linking Objects


new_horizon
04-20-2012, 05:32 AM
Hi All,

A while ago, I had a problem with headlights, whereby when I attached them to a car, I had a jagged light effect as the vehicle approached - because it was highlighting each road texture quad in turn.

I have decided that the way to get over this would be to simply link a small quad that is fixed to the vehicle (offset by say 20 cm) in front, that the lights could illuminate as it moved towards the viewer.

However, I am having difficulties getting the quad to link, as the euler command is not rotating it (see code) below.

If anyone knows a way that I can program it to get the road quad to lay flat, that would be great.

Thanks

Mark


road = viz.addTexture('Roadstrip3.png')
roadstrip = viz.addTexQuad(viz.WORLD,viz.MainScene,1)
roadstrip.texture(road)
roadstrip.setScale(roadscale[0],roadscale[1],1)
roadstrip.setPosition(0,1,1)
roadstrip.setEuler(90,90,0)

# vehicle 1 a Car ### TOYOTA
car1 = viz.addTexture('car2.gif')
vehicle0 = viz.addTexQuad(viz.WORLD,viz.MainScene,1)
vehicle0.texture(car1)
vehicle0.setScale(carsize[0],carsize[1],1)
vehicle0.setEuler(90,0,0)
vehicle0.setPosition(outofview)
vehicles[0] = vehicle0
viz.link(vehicle0, roadstrip, priority=1, offset = (0, -1.2, -0.1))

Frank Verberne
04-20-2012, 06:07 AM
When it comes to linking objects in vizard, you have to use the commands link.preEuler([yaw,pitch,roll]) and link.preTrans([x,y,z]) functions after creating the link instead of vehicle0.setEuler and vehicle0.setPosition before creating the link. So try this:
link = viz.link(vehicle0, roadstrip, priority=1, offset = (0, -1.2, -0.1))
link.preEuler([90,0,0])
link.preTrans(outofview)