Path: chuka.playstation.co.uk!news From: "Mario Wynands" Newsgroups: scee.yaroze.programming.3d_graphics,scea.yaroze.programming.3d_graphics Subject: Re: Local->Parent->World Coords calculations- HELP!!! Date: Wed, 25 Aug 1999 23:29:37 +1200 Organization: PlayStation Net Yaroze (SCEE) Lines: 255 Message-ID: <7q0k3m$6lp18@chuka.playstation.co.uk> References: <37C344C7.4D97924D@mcneish.freeserve.co.uk> NNTP-Posting-Host: p42-max3.wlg.ihug.co.nz Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0013_01BEEF51.B221C6A0" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Xref: chuka.playstation.co.uk scee.yaroze.programming.3d_graphics:1397 scea.yaroze.programming.3d_graphics:381 This is a multi-part message in MIME format. ------=_NextPart_000_0013_01BEEF51.B221C6A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Bruce, In order to find the world coordinates of a child object itself you only = need to make the call to GsGetLw similar to below MATRIX temp_matrix; GsGetLw(&child_coord2, &temp_matrix); // where child_coord2 is the child objects GsCOORDINATE2 structure world_x =3D temp_matrix.t[0]; world_y =3D temp_matrix.t[1]; world_z =3D temp_matrix.t[2]; ApplyMatrix can be used to change coordinates (or direction vectors) in = child space to coordinates in world space similar to below MATRIX temp_matrix; GsGetLw(&child_coord2, &temp_matrix); ApplyMatrixLV( &temp_matrix, &offset, &result); // where offset is a positional (or directional) vector in child space world_x =3D result.vx; world_y =3D result.vy; world_z =3D result.vz; The psuedo code is basically demonstrating that you can find the local = to world transformation matrix by multiplying the local matrix with the = matrices of all the parents in the coordinate system hierarchy. The = line return X.matrix * LocalToWorldMatrix(X.super);=20 is really the key as you will see the function calls itself to multiply = the local matrix by the local matrix of the immediate parent. Through = recursion this will create a string of matrix multiplications, stopping = when it finds a parent whose own parent is the world (or WORLD in Yaroze = speak) via the test =20 if super =3D=3D WORLD=20 return X.matrix;=20 Hope this helps, Mario SIDHE INTERACTIVE mario@sidhe.co.nz http://www.sidhe.co.nz Bruce McNeish wrote in message = news:37C344C7.4D97924D@mcneish.freeserve.co.uk... Hello All,=20 I have been working on the AI for my game and have come to a bit of a = dead-end.=20 I have a player that has several child coordinate systems attached to = it, ie their parent system is that of the player, and I am trying to get = the world coordinates of these points.=20 After browsing this group I read that I should be using GsGetLw = followed by ApplyMatrix but how????=20 It is probably a straight forward process but I am missing something = simple but what???=20 I also read the Matrix and Vector tutorial and it included the = following function psuedo code=20 LocalToWorldMatrix(X) {=20 if super =3D=3D WORLD=20 return X.matrix;=20 else=20 return X.matrix * LocalToWorldMatrix(X.super);=20 }=20 What does that mean?=20 This is the corner stone of my AI design and I would appreciate some = help as this could lead to a job.=20 Bruce=20 ------------------------------------------------=20 | CoolFusion Developments |=20 | http://www.netyaroze-europe.com/~bmcneish|=20 ------------------------------------------------=20 ------=_NextPart_000_0013_01BEEF51.B221C6A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi Bruce,
 
In order to find the world coordinates = of a child=20 object itself you only need to make the call to GsGetLw similar to=20 below
 
 
MATRIX temp_matrix;
GsGetLw(&child_coord2,=20 &temp_matrix);
// where child_coord2 is the child = objects=20 GsCOORDINATE2 structure
 
world_x =3D = temp_matrix.t[0];
world_y =3D = temp_matrix.t[1];
world_z =3D = temp_matrix.t[2];
 
 
 
ApplyMatrix can be used to change coordinates (or direction = vectors) in=20 child space to coordinates in world space similar to below
 
MATRIX temp_matrix;
GsGetLw(&child_coord2,=20 &temp_matrix);
ApplyMatrixLV( &temp_matrix, &offset, &result);
// where offset is a positional (or directional) vector in child=20 space
 
world_x =3D result.vx;
world_y =3D result.vy;
world_z =3D=20 result.vz;
 
 
The psuedo code is basically demonstrating that you can find the = local to=20 world transformation matrix by multiplying the local matrix with the = matrices of=20 all the parents in the coordinate system hierarchy.  The line
 
return X.matrix * LocalToWorldMatrix(X.super);
is really the key as you will see the function calls itself to = multiply the=20 local matrix by the local matrix of the immediate parent.  Through=20 recursion this will create a string of matrix multiplications, stopping = when it=20 finds a parent whose own parent is the world (or WORLD in Yaroze speak) = via the=20 test 
 
if super =3D=3D WORLD 
    return=20 X.matrix;
 
 
Hope this helps,
 
Mario
 
SIDHE INTERACTIVE
mario@sidhe.co.nz
http://www.sidhe.co.nz
 
Bruce McNeish <bruce@mcneish.freeserve.co.= uk>=20 wrote in message news:37C344C7.4D9= 7924D@mcneish.freeserve.co.uk...
Hello=20 All,=20

I have been working on the AI for my game and have come to a bit of = a=20 dead-end.=20

I have a player that has several child coordinate systems attached = to it,=20 ie their parent system is that of the player, and I am trying to get = the world=20 coordinates of these points.=20

After browsing this group I read that I should be using GsGetLw = followed by=20 ApplyMatrix but how????=20

It is probably a straight forward process but I am missing = something simple=20 but what???=20

I also read the Matrix and Vector tutorial and it included the = following=20 function psuedo code=20

LocalToWorldMatrix(X) {=20
        if super =3D=3D = WORLD=20 =
           = =20 return X.matrix;
        = else=20 =
           = =20 return X.matrix * LocalToWorldMatrix(X.super);
}=20

What does that mean?=20

This is the corner stone of my AI design and I would appreciate = some help=20 as this could lead to a job.=20

Bruce=20

------------------------------------------------
| CoolFusion=20 = Developments          &= nbsp;           &n= bsp;     =20 |
| http://www.netyaroze-= europe.com/~bmcneish|=20
------------------------------------------------=20

------=_NextPart_000_0013_01BEEF51.B221C6A0--