Well, I guess the sense of the camera and the marker might need to be =20=
reversed. There are only two options, and I can never remember which =20
one to try first, so I guess I picked the wrong sense.
In any case, a simple inversion of the m matrix returned by =20
arglCameraView (prior to extracting the eyepos, lookat and up vector) =20=
should be sufficient.
This handy function inverts an homogenous coordinate transform (HCT) =20
matrix m.
void invertHCTd(GLdouble m[16])
{
GLdouble tmp;
=09
// Invert the orientation by transposing.
tmp =3D m[1]; m[1] =3D m[4]; m[4] =3D tmp;
tmp =3D m[2]; m[2] =3D m[8]; m[8] =3D tmp;
tmp =3D m[6]; m[6] =3D m[9]; m[9] =3D tmp;
=09
// Invert the position by negating.
m[12] =3D -m[12]; m[13] =3D -m[13]; m[14] =3D -m[14];
}
To answer your earlier question: the reason that the 3rd column of =20
the matrix is subtracted from the eyepos to get the lookat point is =20
that column is a unit vector pointing opposite to the forward =20
direction of the camera. So by subtracting it from the eyepos, we get =20=
a point in world coordinates which lies on the camera's principle =20
axis, and is hence a "lookat" point.
These questions are really getting away from ARTK and into the =20
general realm of computer graphics, so it might pay to seek out a =20
good text in that area.
Cheers,
Phil.
On 20/06/2006, at 8:06 PM, Mr C J Hughes wrote:
> Hi Phil,
>
> Many thanks for your help,
>
> It was a problem with being included during the link phase and so I
> managed to fix this!
>
> Next problem - I am getting some very strange results with the =20
> snippit of
> code that you game me to derive the 'up vector', 'look at' and 'eye
> position' from the transformation matrix.
>
> Firstly can you explain why the lookat values have the matrix value
> subtracted from the eyepos? if I remove the 'eyepos[] -' from each =20
> lookat
> value then I can at least see the object being rendered!!
>
> And also my VTK rendering seems to be 90 degrees wrong on one axis. =20=
> - I am
> steering an OpenGL application and applying the same transformtaion =20=
> to the
> VTK application at the same time and technically as far as I can =20
> tell they
> should be identical, but it seems to be wrong in one axis.
>
> I know this isn;t much information to go on, but do you have any =20
> ideas?
>
> Many thanks for your time,
>
> Chris
>
> On Tue, 20 Jun 2006, Philip Lamb wrote:
>
>> gsub_lite.h is the correct header to include. I would check that you
>> are including it from the correct path.
>>
>> If the "not found" error is included during the link phase, make sure
>> that you have got libARgsub_lite including in your link libraries
>> (proceedure differs depending on what platform / development
>> environment you're using.)
>>
>> Regards,
>> Phil.
>>
>> On 19/06/2006, at 10:05 PM, Chris Hughes wrote:
>>
>>> Hi Philip et al.
>>>
>>> Your code looks like it should provide what I need! However I
>>> cannot find
>>> the arglCameraView() function? - even if I include the gsub_lite.h
>>> library.
>>>
>>> If I substitute in the argConvGlPara() function then it appears to
>>> work
>>> successfully however my object is a long way in the distance, which
>>> suggests
>>> that I need to use this new function so that I can scale the
>>> transformaion.
>>>
>>> As far as I can tell I am using ARToolkit version 2.71.2 so
>>> according to the
>>> API the function should exist..
>>
>
> --=20
>
> Gall y neges e-bost hon, ac unrhyw atodiadau a anfonwyd gyda hi,
> gynnwys deunydd cyfrinachol ac wedi eu bwriadu i'w defnyddio'n unig
> gan y sawl y cawsant eu cyfeirio ato (atynt). Os ydych wedi derbyn y
> neges e-bost hon trwy gamgymeriad, rhowch wybod i'r anfonwr ar
> unwaith a dil=EBwch y neges. Os na fwriadwyd anfon y neges atoch chi,
> rhaid i chi beidio =E2 defnyddio, cadw neu ddatgelu unrhyw wybodaeth a
> gynhwysir ynddi. Mae unrhyw farn neu safbwynt yn eiddo i'r sawl a'i
> hanfonodd yn unig ac nid yw o anghenraid yn cynrychioli barn
> Prifysgol Cymru, Bangor. Nid yw Prifysgol Cymru, Bangor yn gwarantu
> bod y neges e-bost hon neu unrhyw atodiadau yn rhydd rhag firysau neu
> 100% yn ddiogel. Oni bai fod hyn wedi ei ddatgan yn uniongyrchol yn
> nhestun yr e-bost, nid bwriad y neges e-bost hon yw ffurfio contract
> rhwymol - mae rhestr o lofnodwyr awdurdodedig ar gael o Swyddfa
> Cyllid Prifysgol Cymru, Bangor. www.bangor.ac.uk (Ysgol Gwybodeg)
>
> This email and any attachments may contain confidential material and
> is solely for the use of the intended recipient(s). If you have
> received this email in error, please notify the sender immediately
> and delete this email. If you are not the intended recipient(s), you
> must not use, retain or disclose any information contained in this
> email. Any views or opinions are solely those of the sender and do
> not necessarily represent those of the University of Wales, Bangor.
> The University of Wales, Bangor does not guarantee that this email or
> any attachments are free from viruses or 100% secure. Unless
> expressly stated in the body of the text of the email, this email is
> not intended to form a binding contract - a list of authorised
> signatories is available from the University of Wales, Bangor Finance
> Office. www.bangor.ac.uk (School of Informatics)
|