This is a multi-part message in MIME format.
------_=_NextPart_001_01C67836.EC2DF335
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
Hello,
=20
Could somebody explain to me what the scale factor is for in:
arglCameraView(trans, matrix, VIEW_SCALEFACTOR)
=20
I'm trying to implement gaze selection in an AR application. I am
treating the marker as a plane in 3D space (there'll be just one with a
number of objects on it), and then firing a ray into the scene to
determine where on the surface of the marker the ray hits.
=20
To make things easier I was hoping to take the inverted matrix of the
marker transform, and apply this to a ray, so that I can work with the
plane being un-transformed. I should get an X-Y transform that when
applied after the marker transform keeps an object at the centre of the
screen (the centre of the gaze). =20
=20
Its kind of working but not quite. If I apply a scaling factor to the
transform it works better, that's why I ask about the scale factor, but
it might be a red herring. =20
=20
Any help or suggested alternatives would be welcome.
=20
Thanks
=20
Matthew
=20
=20
-- For those interested the code is included below:
Method taken from http://answers.google.com/answers/threadview?id=3D18979=
=20
double origin[] =3D {0,0,20}; //
Initial camera location
double newOrigin[] =3D {0,0,0};
double target[] =3D {0,0,0}; // The
point the camera is looking at i.e. centre of plane
double newTarget[] =3D {0,0,0};
double orientVect[3]; //
Vector between camera location and target point
double targetDist;
double planeEq[] =3D {0,0,-100,0}; // Equation of a plane
flat, centred at origin (pre-calc)
double t; //
Used in line-plane intersect equation
double intersect[3]; //
Intersection point
=20
// Apply transformation matrix to points. invTrans is inverted marker
transform matrix
newOrigin[0] =3D (origin[0] * invTrans[0][0]) + (origin[1] *
invTrans[0][1]) + (origin[2] * invTrans[0][2]) + invTrans[0][3];
newOrigin[1] =3D (origin[0] * invTrans[1][0]) + (origin[1] *
invTrans[1][1]) + (origin[2] * invTrans[1][2]) + invTrans[1][3];
newOrigin[2] =3D (origin[0] * invTrans[2][0]) + (origin[1] *
invTrans[2][1]) + (origin[2] * invTrans[2][2]) + invTrans[2][3];
=20
newTarget[0] =3D (target[0] * invTrans[0][0]) + (target[1] *
invTrans[0][1]) + (target[2] * invTrans[0][2]) + invTrans[0][3];
newTarget[1] =3D (target[0] * invTrans[1][0]) + (target[1] *
invTrans[1][1]) + (target[2] * invTrans[1][2]) + invTrans[1][3];
newTarget[2] =3D (target[0] * invTrans[2][0]) + (target[1] *
invTrans[2][1]) + (target[2] * invTrans[2][2]) + invTrans[2][3];
=20
=20
// Get the orientation vector
orientVect[0] =3D newOrigin[0] - newTarget[0];
orientVect[1] =3D newOrigin[1] - newTarget[1];
orientVect[2] =3D newOrigin[2] - newTarget[2];
=20
=20
// Check distance. Should remain constant, and does
targetDist =3D (orientVect[0]*orientVect[0]) +
(orientVect[1]*orientVect[1]) + (orientVect[2]*orientVect[2]);
=20
=20
// Calculate t, in 3 stages
t =3D (planeEq[0]*newOrigin[0]) + (planeEq[1]*newOrigin[1]) +
(planeEq[2]*newOrigin[2]) + planeEq[3];
t =3D t/((planeEq[0]*newTarget[0]) + (planeEq[1]*newTarget[1]) +
(planeEq[2]*newTarget[2]));
t =3D 0 - t;
=20
=20
// Calculate intersect, Z remains zero which is a good sign
intersect[0] =3D newOrigin[0] + (newTarget[0]*t);
intersect[1] =3D newOrigin[1] + (newTarget[1]*t);
intersect[2] =3D newOrigin[2] + (newTarget[2]*t);
=20
=20
--
This message is intended for the addressee(s) only and should not be read=
, copied or disclosed to anyone else outwith the University without the p=
ermission of the sender.
It is your responsibility to ensure that this message and any attachments=
=20are scanned for viruses or other defects. Napier University does not a=
ccept liability for any loss
or damage which may result from this email or any attachment, or for erro=
rs or omissions arising after it was sent. Email is not a secure medium. =
Email entering the=20
University's system is subject to routine monitoring and filtering by the=
=20University.=20
------_=_NextPart_001_01C67836.EC2DF335
Content-Type: text/html;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:=
schemas-microsoft-com:office:word" xmlns=3D"http://www.w3.org/TR/REC-html=
40">
<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<style>
<!--
=20/* Style Definitions */
=20p.MsoNormal, li.MsoNormal, div.MsoNormal
=09{margin:0cm;
=09margin-bottom:.0001pt;
=09font-size:12.0pt;
=09font-family:"Times New Roman";}
a:link, span.MsoHyperlink
=09{color:blue;
=09text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
=09{color:purple;
=09text-decoration:underline;}
span.EmailStyle17
=09{mso-style-type:personal-compose;
=09font-family:Arial;
=09color:windowtext;}
@p ... Section1
=09{size:595.3pt 841.9pt;
=09margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
=09{page:Section1;}
-->
</style>
</head>
<body lang=3DEN-GB link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>Hello,<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>Could somebody explain to me what the scale factor is =
for in:
arglCameraView(trans, matrix, VIEW_SCALEFACTOR)<o:p></o:p></span></font><=
/p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>I’m trying to implement gaze selection in an AR
application. I am treating the marker as a plane in 3D space (there=
’ll
be just one with a number of objects on it), and then firing a ray into t=
he
scene to determine where on the surface of the marker the ray hits.<o:p><=
/o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>To make things easier I was hoping to take the inverte=
d
matrix of the marker transform, and apply this to a ray, so that I can wo=
rk
with the plane being un-transformed. I should get an X-Y transform =
that
when applied after the marker transform keeps an object at the centre of =
the
screen (the centre of the gaze). <o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>Its kind of working but not quite. If I apply a
scaling factor to the transform it works better, that’s why I ask a=
bout
the scale factor, but it might be a red herring. <o:p></o:p></span>=
</font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>Any help or suggested alternatives would be welcome.<o=
:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>Thanks<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>Matthew<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>-- For those interested the code is included below:<o:=
p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>Method taken from <a
href=3D"http://answers.google.com/answers/threadview?id=3D18979">http://a=
nswers.google.com/answers/threadview?id=3D18979</a><o:p></o:p></span></fo=
nt></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>double  =
; origin[]
=3D {0,0,20}; =
//
Initial camera location<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>double =
newOrigin[]
=3D {0,0,0};<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>double =
target[]
=3D {0,0,0}; &=
nbsp; &n=
bsp; //
The point the camera is looking at i.e. centre of plane<o:p></o:p></span>=
</font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>double =
newTarget[]
=3D {0,0,0};<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>double =
orientVect[3]; &nbs=
p;  =
; =
=20//
Vector between camera location and target point<o:p></o:p></span></font><=
/p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>double =
targetDist;<o:p></o:p></span></font>=
</p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>double =
planeEq[]
=3D {0,0,-100,0}; // Equation of a plane flat, centred at origin (pre-cal=
c)<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>double =
t; &nbs=
p;  =
; =
&=
nbsp; //
Used in line-plane intersect equation<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>double =
intersect[3];  =
; =
&=
nbsp; //
Intersection point<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>// Apply transformation matrix to points. invTra=
ns is
inverted marker transform matrix<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>n</span></font><font size=3D2 face=3DArial><span lang=3D=
FR
style=3D'font-size:10.0pt;font-family:Arial'>ewOrigin[0] =3D (origin[0] *=
invTrans[0][0]) + (origin[1] * invTrans[0][1]) + (origin[2] * invTrans[0]=
[2]) +
invTrans[0][3];<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DFR style=3D=
'font-size:10.0pt;
font-family:Arial'>newOrigin[1] =3D (origin[0] * invTrans[1][0]) + (origi=
n[1] *
invTrans[1][1]) + (origin[2] * invTrans[1][2]) + invTrans[1][3];<o:p></o:=
p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>newOrigin[2] =3D (origin[0] * invTrans[2][0]) + (origi=
n[1] *
invTrans[2][1]) + (origin[2] * invTrans[2][2]) + invTrans[2][3];<o:p></o:=
p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>newTarget[0] =3D (target[0] * invTrans[0][0]) + (targe=
t[1] *
invTrans[0][1]) + (target[2] * invTrans[0][2]) + invTrans[0][3];<o:p></o:=
p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>newTarget[1] =3D (target[0] * invTrans[1][0]) + (targe=
t[1] *
invTrans[1][1]) + (target[2] * invTrans[1][2]) + invTrans[1][3];<o:p></o:=
p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>newTarget[2] =3D (target[0] * invTrans[2][0]) + (targe=
t[1] *
invTrans[2][1]) + (target[2] * invTrans[2][2]) + invTrans[2][3];<o:p></o:=
p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>// Get the orientation vector<o:p></o:p></span></font>=
</p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>orientVect[0] =3D newOrigin[0] - newTarget[0];<o:p></o=
:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>orientVect[1] =3D newOrigin[1] - newTarget[1];<o:p></o=
:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>orientVect[2] =3D newOrigin[2] - newTarget[2];<o:p></o=
:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>// Check distance. Should remain constant, and d=
oes<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>targetDist =3D (orientVect[0]*orientVect[0]) +
(orientVect[1]*orientVect[1]) + (orientVect[2]*orientVect[2]);<o:p></o:p>=
</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>// Calculate t, in 3 stages<o:p></o:p></span></font></=
p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>t =3D (planeEq[0]*newOrigin[0]) + (planeEq[1]*newOrigi=
n[1]) +
(planeEq[2]*newOrigin[2]) + planeEq[3];<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>t =3D t/((planeEq[0]*newTarget[0]) + (planeEq[1]*newTa=
rget[1])
+ (planeEq[2]*newTarget[2]));<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DFR style=3D=
'font-size:10.0pt;
font-family:Arial'>t =3D 0 - t;<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DFR style=3D=
'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DFR style=3D=
'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>// Calculate intersect, Z remains zero which is a good=
=20sign<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>intersect[0] =3D newOrigin[0] + (newTarget[0]*t);<o:p>=
</o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>intersect[1] =3D newOrigin[1] + (newTarget[1]*t);<o:p>=
</o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>intersect[2] =3D newOrigin[2] + (newTarget[2]*t);<o:p>=
</o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size=
:10.0pt;
font-family:Arial'>--<o:p></o:p></span></font></p>
</div>
<FONT face=3DArial>This message is intended for the addressee(s) only and=
=20
should not be read, copied or disclosed to anyone else outwith the Univer=
sity=20
without the permission of the sender.<BR>It is your responsibility to ens=
ure=20
that this message and any attachments are scanned for viruses or other de=
fects.=20
Napier University does not accept liability for any loss<BR>or damage whi=
ch may=20
result from this email or any attachment, or for errors or omissions aris=
ing=20
after it was sent. Email is not a secure medium. Email entering the=20
<BR>University's system is subject to routine monitoring and filtering by=
=20the=20
University.</FONT>=20
</body>
</html>
------_=_NextPart_001_01C67836.EC2DF335--
|