For those of use whose experience with matrices is that of the solving systems of equations and numerical methods sorts rather than the 3D transformations sorts, I was wondering if someone with more experience in this could explain in more detail than the API docs what some of the Matrix4 and Vector3D methods do. The ones I in particular are curious about are below:
Matrix4::buildCameraLookAtMatrixLH/RH:
The API says that it builds a left handed and right handed look-at matrix,
What is a look-at matrix?
What are some uses for one?
Whats the difference with the hands?
Syntactically, how would one use it?
what is an "up vector"?
Matrix4::buildNDCToDCMatrix:
I suppose this would make more sense if I knew what normalized device coordinates vs device coordinates were.
buildProjectionMatrixOrthoRH/LH:
What is an orthogonal projection matrix?
What are some uses for one?
Syntactically, how would one use it?
buildProjectionMatrixFov and buildProjectionMatrixPerspective
What are the differences between orthoganal, FOV, and Perspective projection matrices?
getTranslation
getTransposed
interpolate
i have an idea of what this one might do, but who would use it?
where would an inverse rotate/translate vector be used?
transformvect/plane/box
translatevect/plane/box
I am just as confused on some of the vector3D methods:
getHorizontalAngle
getInterpolated
normalize
rotateXY/XZ/YZ
I am confused by the center parameter in this function
OK, I realize I have just caused someone to go through alot of work with the explanation of these methods, but I am sure it will help many people immensly. Below is a specific "issue" I am having
I am attempting to use the rotation of a node to return a vector which corresponds the the direction that the node is facing. This is done so I have a basis to use for teh targeting and animation of projectiles in my game.
Example of what I mean,
vector3d getDirection(vector3d rotation);
used like direction = getDirection(node.getRotation());
so that a node with rotation of (0, 180, 0) would return (0, -1, 0)
and a node with rotation of (0, 225, 0) would return (-.707, 0, -.707) and so on.
Thank you for all the help
Matrix4 Methods explanation and rotation vs. direction
Matrix4 Methods explanation and rotation vs. direction
PWAUVAN (Programmer With An Unnecessarily Verbose Acronym Name
Re: Matrix4 Methods explanation and rotation vs. direction
I guess a 'look at matrix' is a matrix which rotates something to look at a target. the difference between left and right handed cartasean coordinate systems can be explained like this-PWAUVAN wrote: Matrix4::buildCameraLookAtMatrixLH/RH:
The API says that it builds a left handed and right handed look-at matrix,
What is a look-at matrix?
What are some uses for one?
Whats the difference with the hands?
Syntactically, how would one use it?
what is an "up vector"?
point your thumb upwards (this is the Y axis), your index finger forwards (this is Z), now point your middle finger towards your other hand (this is X). Irrlicht uses a left-handed coordinate system, where X goes from right to left when Y is facing up.
an "up vector" is a normalized vector (a vector of length 1.0, not a rotation), which faces upwards.
no idea, i've never had to worry about this! if I ever need to convert between normalized device coordinates and device coordinates, I know where to look thoughPWAUVAN wrote: Matrix4::buildNDCToDCMatrix:
I suppose this would make more sense if I knew what normalized device coordinates vs device coordinates were.
You would use it to create an orthogonal projection matrix for your camera's view transformation. if you're using irrlicht's cameras, you don't need to worry about this. If you're making your own camera and want it to have no perspective (things dont get smaller in the distance), you can use this.PWAUVAN wrote: buildProjectionMatrixOrthoRH/LH:
What is an orthogonal projection matrix?
What are some uses for one?
Syntactically, how would one use it?
not sure, I guess its just the values you use to create the view matrix.PWAUVAN wrote: buildProjectionMatrixFov and buildProjectionMatrixPerspective
What are the differences between orthoganal, FOV, and Perspective projection matrices?
translation means movement. 4x4 matrics have translation, rotation and scale.PWAUVAN wrote: getTranslation
transposing a matrix is the act of turning it on its side- swapping the columns and rows.PWAUVAN wrote: getTransposed
anyone who wants to interpolate between two matrices, you don't have to use it just because its there!PWAUVAN wrote: interpolate
i have an idea of what this one might do, but who would use it?
usually you'd use the whole inverse matrix, to reverse a matrix multiplication.PWAUVAN wrote: where would an inverse rotate/translate vector be used?
translate (move) or transform (scale, move, rotate) a plane, box or vector.PWAUVAN wrote: transformvect/plane/box
translatevect/plane/box
gets the rotation of a vector around 0,1,0PWAUVAN wrote: getHorizontalAngle
interpolates between one vector and another. for example, interpolating 0.5 between 1,1,1 and 2,2,2 would give 1.5, 1.5, 1.5.PWAUVAN wrote: getInterpolated
makes the vector a "unit vector" which has a length of 1.0PWAUVAN wrote: normalize
center is the axis you wish to rotate around.PWAUVAN wrote: rotateXY/XZ/YZ
I am confused by the center parameter in this function
yeah i'm bored already, but i shall press on regardless...PWAUVAN wrote: OK, I realize I have just caused someone to go through alot of work with the explanation of these methods, but I am sure it will help many people immensly. Below is a specific "issue" I am having
first you must decide which way up or forwards is. try this-PWAUVAN wrote: I am attempting to use the rotation of a node to return a vector which corresponds the the direction that the node is facing. This is done so I have a basis to use for teh targeting and animation of projectiles in my game.
Example of what I mean,
vector3d getDirection(vector3d rotation);
used like direction = getDirection(node.getRotation());
so that a node with rotation of (0, 180, 0) would return (0, -1, 0)
and a node with rotation of (0, 225, 0) would return (-.707, 0, -.707) and so on.
Code: Select all
vector3df upVector(0,1,0);
node->getAbsoluteTransformation().rotateVect(upVector);
return upVector;
My solution to the issue
Thank you for the help bitplane, as well as the extremely long and informative reply. Your absolute transformation code worked well, I am able to use it to not only determine what the node is "looking at" without having to attach a camera to it, but Ive found that the directiong vector can be used to shoot a projectile by first calling normalize on the upVector after it has been rotated and then applaying a velocity scalar to it to create a velocity vector.
To get the a velocity vector using a continuation of bitplane's code
Now to fire a projectile using the velocity vector returned: (assuming no gravity)
Now call this function for every projectile during the device run loop and have each projectile get eliminated either after it collides with something or it has gone a certain distance.
I have found that another, rather hack way to get the direction vector of a node is just to create a child node of extremely tiny size about 100 units or so infront of your node. since this node is a child node it will always be in the direction of the "face" of the node. So to get the direction the node is facing just do
I suppose you could get real creative with this method, maybe use a line3d instead of another node. THis line could double for collision detection or defining the limits of "sight" for nodes controlled by AI. Also, if you are (such as I am) creating a node with multiple "guns" (think an x-wing or TIE Interceptor) where the guns projectiles ought to converge at some point, the child node or other end of the line as a point to converge the projectiles without having to define a specific in game target to converge at. Drawing the child node closer or shortening the line length can have the gunfire converge closer to the player node and vice versa. [/quote]
To get the a velocity vector using a continuation of bitplane's code
Code: Select all
vector3df upVector(0,1,0);
node->getAbsoluteTransformation().rotateVect(upVector);
upVector->Normalize();
return upVector;
Code: Select all
Vector3D VelocityVec = CreateVelocityVec(); //The function we just wrote
Matrix4 m = new Matrix4();
m->setRotationDegrees(projectilenode->getRotationDegrees());
m->TransformVect(velocityVec);
Vector3D Pos = projectilenode->getPosition();
Pos->setX(Pos->getX + VelocityVec->getX();
Pos->setX(Pos->getY + VelocityVec->getY();
Pos->setX(Pos->getZ + VelocityVec->getZ();
projectilenode-_setPosition(Pos);
I have found that another, rather hack way to get the direction vector of a node is just to create a child node of extremely tiny size about 100 units or so infront of your node. since this node is a child node it will always be in the direction of the "face" of the node. So to get the direction the node is facing just do
Code: Select all
directionVec = (Node->getAbsolutePosition() - ChildNode->getAbsolutePosition())->Normalize();
return directionVec;
PWAUVAN (Programmer With An Unnecessarily Verbose Acronym Name