local to world confusion.
When having objects int the world, how do i convert the local coordinates to world coordinates? Im not sure to apply physics to them and check for collisions. I just haven't been able to figure it out. Thanks in advance.
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="88" height="70" id="H2lvl" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="http://www.ironhive.com/CFCs/H2lvl.swf?gamertag=jBaddog" /> <param name="quality" value="high" /> <param name="wmode" value="transparent"> <embed src="http://www.ironhive.com/CFCs/H2lvl.swf?gamertag=jBaddog" quality="high" bgcolor="#ffffff" width="88" height="70" name="H2lvl" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>
Without much explaination. I use this (often):
// Put vector into world space
Vector3d v =
model._VectorPosition +
model._OrthogonalView*node.z +
model._OrthogonalStrafe*node.x +
model._OrthogonalUpView*node.y;
[Edited by - tgraupmann on December 23, 2004 2:10:03 AM]
// Put vector into world space
Vector3d v =
model._VectorPosition +
model._OrthogonalView*node.z +
model._OrthogonalStrafe*node.x +
model._OrthogonalUpView*node.y;
[Edited by - tgraupmann on December 23, 2004 2:10:03 AM]
*News tagenigma.com is my new domain.
what tgraupmann is effectivly doing is multiplying the local coordinate by the current camera matrix. That code he just put is the mathematical simplification of the process.
Note the camera matrix is not the same as the modelview matrix.
When you set the camera, the camera matrix and modelview matrix are inverse.
Matrices are one of the mathematical building blocks of 3D graphics.. If not the most important. (yes, actually, it is the most important).
So understanding them is a very very good thing.
matrix/vector/quaternion FAQ
look at the code in my sig too. [smile] It has matrices all over.
-> in that code, the equivalent to what tgraupmann wrote would be:
Matrix camera;
...
Vector3 world = local * camera + camera;
Ie, rotate by the camera, then add the translation of the camera.
To go back would be:
Vector3 local = (world-camera) / camera;
for example...
k.
Hope that helps.
Note the camera matrix is not the same as the modelview matrix.
When you set the camera, the camera matrix and modelview matrix are inverse.
Matrices are one of the mathematical building blocks of 3D graphics.. If not the most important. (yes, actually, it is the most important).
So understanding them is a very very good thing.
matrix/vector/quaternion FAQ
look at the code in my sig too. [smile] It has matrices all over.
-> in that code, the equivalent to what tgraupmann wrote would be:
Matrix camera;
...
Vector3 world = local * camera + camera;
Ie, rotate by the camera, then add the translation of the camera.
To go back would be:
Vector3 local = (world-camera) / camera;
for example...
k.
Hope that helps.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement