Original Post
🔒 Locked
Multiple World Matrices
Advertisement
There are three matrices involved.
For each model, its world matrix transforms it from local coordinates (typically around (0,0,0)) to world space. Say you have a model of a tree, then you can draw it 20 times using a slightly different world matrix and you''d create a small forest.
The view matrix transforms the world according to the camera position and look direction. Finally the transformation matrix transforms the 3D coordinates to 2D screen coordinates for example (0..640,0..480)
For each model, its world matrix transforms it from local coordinates (typically around (0,0,0)) to world space. Say you have a model of a tree, then you can draw it 20 times using a slightly different world matrix and you''d create a small forest.
The view matrix transforms the world according to the camera position and look direction. Finally the transformation matrix transforms the 3D coordinates to 2D screen coordinates for example (0..640,0..480)
Anyone have a sample of this (FF, not VS)?
looking at msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/enums/d3dtransformstatetype.asp, there is even the "D3DTS_WORLD" macro that is used to index between all the world matrices.
I only ever use 1 world matrix at a time (for each object), and stacks for all the articluated stuff... I never used multiple world matrices like this, although I am curious to the vertex-effects it''s capable of.
looking at msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/enums/d3dtransformstatetype.asp, there is even the "D3DTS_WORLD" macro that is used to index between all the world matrices.
I only ever use 1 world matrix at a time (for each object), and stacks for all the articluated stuff... I never used multiple world matrices like this, although I am curious to the vertex-effects it''s capable of.
Yikes. I just deleted my sample which used this. Could have come in handy here.
Basically you setup a blend factor in the vertex declaration (the struct), between 0.0, and 1.0. Then you can setup WORLDMATRIX(0) to be at a certain position/direction, and WORLDMATRIX(1) to be at another position/direction. The blend factor 0.0 and 1.0 will cause a LERP command to be used on those matrixes to get the final result between the two matrix.
Think of it this way. Lets say you have an arm rendered on the screen. Shoulder down to elbow, then out to the wrist. Near the shoulder the weights would be around 0. Down near the elbow 1. On the lower arm, elbow to wrist, elbow would have 0, and wrist would have 1. You will have to render each section independantly from each other (can't batch)
Lets say you have your arm down to your side. The WorldMatrix(0) and WorldMatrix(1) will have the same directions then you just render your arms as normal. But if you rotate the elbow 90 degrees, then the fixed function will rotate/move the vertexes automatically in hardware around the joint to make sure there are no seams in the polygons and that its getting stretched appropriately.
Its best if I make an example
In the first one, the upper arm of the arm WORLDMATRIX(0) and WORLDMATRIX(1) are pointing down. In the lower arm part, same thing both pointing down. In the second example, the upper arm the WORLDMATIRX(0) is pointing down, and WORLD_MATRIX(1) is pointing right. The lower arm the both matrix is pointing right. (unless you want the wrist to move in another direction then you can change the MATRIX(1) to point at a new direction)
[edited by - Joeyblow2 on November 19, 2003 11:28:35 AM]
Basically you setup a blend factor in the vertex declaration (the struct), between 0.0, and 1.0. Then you can setup WORLDMATRIX(0) to be at a certain position/direction, and WORLDMATRIX(1) to be at another position/direction. The blend factor 0.0 and 1.0 will cause a LERP command to be used on those matrixes to get the final result between the two matrix.
Think of it this way. Lets say you have an arm rendered on the screen. Shoulder down to elbow, then out to the wrist. Near the shoulder the weights would be around 0. Down near the elbow 1. On the lower arm, elbow to wrist, elbow would have 0, and wrist would have 1. You will have to render each section independantly from each other (can't batch)
Lets say you have your arm down to your side. The WorldMatrix(0) and WorldMatrix(1) will have the same directions then you just render your arms as normal. But if you rotate the elbow 90 degrees, then the fixed function will rotate/move the vertexes automatically in hardware around the joint to make sure there are no seams in the polygons and that its getting stretched appropriately.
Its best if I make an example
0 _____ 0 ____
| | | |
| | | |
| | | |________
| | \ | |
1 |___| \__|________|
0 | | 1 0 1
| |
| |
| |
1 |___|
In the first one, the upper arm of the arm WORLDMATRIX(0) and WORLDMATRIX(1) are pointing down. In the lower arm part, same thing both pointing down. In the second example, the upper arm the WORLDMATIRX(0) is pointing down, and WORLD_MATRIX(1) is pointing right. The lower arm the both matrix is pointing right. (unless you want the wrist to move in another direction then you can change the MATRIX(1) to point at a new direction)
[edited by - Joeyblow2 on November 19, 2003 11:28:35 AM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement