There is an ancient part of code floating around (at least 4 years old) where I answered a similar question. Yes, you need a third vertex for the roll and do some basic vector arithmetics.

Here comes the code, try to put it to good use. :-)

Code:

function addons(entity1,v1,v2,v3); //function prototype

entity* tempentity
var hand_pos[3];
var hand_pos2[3];
var hand_pos3[3];
var hand_pos4[3];
var vec1[3];
var vec2[3];

function addons(entity1,v1,v2,v3)
{
// you = me;
tempentity = ptr_for_handle(entity1); //entity to attach to me

vec_for_vertex(tempentity.x,you,v1); //vertex to place origin at

vec_for_vertex(hand_pos,you,v2); //vert to orient pan and tilt
vec_for_vertex(hand_pos2,you,v1);
vec_for_vertex(hand_pos3,you,v3); //vert to orient roll
vec_for_vertex(hand_pos4,you,v2);

vec_sub(hand_pos,tempentity.x); //sets our pan and tilt
vec_to_angle(tempentity.pan,hand_pos);
tempentity.roll = null;

//all this does the roll, courtesy of Gnometech
vec_sub(hand_pos3,hand_pos4);
vec_set (vec1, nullvector);
vec1.y = 1;
vec_rotate (vec1, tempentity.pan);
vec_set (vec2, nullvector);
vec2.z = 1;
vec_rotate (vec2, tempentity.pan); // those vectors span the plane
temp.x = vec_dot (vec1, hand_pos3);
temp.y = vec_dot (vec2, hand_pos3);
temp.z = 0; // if target is not in the span of the front vector, temp is not equal nullvector
vec_to_angle (vec1.pan, temp); // we re-use v1, as it is no longer needed
tempentity.roll = vec1.pan; // As temp.z is 0, only the pan of v1 will be set and that is our desired angle
}



Regards,
Gnometech


Download our playable Movement & Interaction Tutorial for 3DGS here:
http://www.puppenheim.org/MITutorial.zip