Billboard effect question

I’ve been trying to figure out how to make the billboard effects work for me in this situation.

I have a 2D egg generated by egg-texture-cards of an image of an arrow. I would like the arrow to point in a 3D direction but still maintain the broad-side of the egg to be toward the camera- not necessarily what setBillboardPointWorld() does because then I would lose the direction information on the arrow.

I’d like to be able to define a vector for the arrow to point and then have the graphic rotate about that axis so that the 2D image is facing the camera but still have the long dimension of the arrow constranted by the defined vector.

Is billboard the right thing to use for this. I also looked at the compass effect but I don’t think that’s what I want.

You need two billboard effects, one beneath the other. The first one rotates the arrow’s face towards the camera. The second one is an axial billboard, to rotate the arrow around its axis to point as nearly to the target as possible, without moving the axis.

from direct.directbase.DirectStart import *
from pandac.PandaModules import *

s = loader.loadModel('smiley.egg')
s.reparentTo(render)
i = s.posInterval(5, Point3(10, 0, 0), startPos = Point3(5, 5, 5))
i.loop()

arrow = loader.loadModel('up_arrow.egg')

a1 = render.attachNewNode('a1')
a1.setP(-90)
a1.setBillboardPointWorld()
arrow.reparentTo(a1)
arrow.setP(90)
arrow.setBillboardAxis(s, 0)

The setP() calls are necessary since a billboard always rotates the Y axis to the target. But we want the second one to rotate the arrow’s Z axis to the target, which means we have to pre-rotate the arrow.

David