Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Mon, 19 Nov 2007 23:42:27 -0800,    group: microsoft.public.win32.programmer.directx.sdk        back       


DirectX and Matrix confusion   
What I am trying to do is build a function that draws a wall out of blocks. 
I have a function that can do this easily as long as no rotationn takes 
place.  I pass it the bottom/left X,Y,Z, width, height.  I can then use two 
for loops to iterate through the blocks and build the wall.

Okay, now I'm trying to modify this function to be able to biuld the wall in 
any arbitrary rotation.

So I also pass it a X,Y,Z rotation in degrees.  My thinking is, okay, if I 
have one corner of the wall, I know it's width and it's height and how it's 
rotated, I should be able to build it.  And this is where I"m getting 
stumped.  I first tried to figure out some 3d math but that didn't get me 
far, so I thought about matrixes (someone suggested to me actually) so this 
is what I'm trying.

With no rotation things work out, but that's to be expected, since no 
rotation is simply multiplying by 1.0f, 1.0f, 1.0f and nothing is changed. 
But when I multiply in the rotation matrix the wall shoots over into lala 
land, although it is a wall with the correct dimentions and rotation facing.

So this is what I"im attempting:

1. Build a matrix based on the starting postion and ending position
2. Build a matrix based on the rotation (rotation x,y,z).
3. Determine the block number (0 to block height).  Then I try to transform 
by the matrix where this block is to take place and it's not working out. 
:The problem with showing code is the DirectX calls are wrapped in a 3rd 
party library and so won't be native DX.

Here is soem code if you can make sense of it (which isn't working 
correctly, the wall is in the wrong location)

void DrawWall( const VEC3& P1, float Width, float Height, const VEC3& 
Rotate )
{
    Reset_Matrix();
    Translate( P1.x + Width, P1.y + Height, P1.z );
    MATRIX TranslateMat = Get_Built_Transform();

    Reset_Matrix();
    RotateX( Rotate.x );
    RotateY( Rotate.y );
    RotateZ( Rotate.z );
    MATRIX RotateMat = Get_Built_Transform();

    // At this point, if I attempt to use thes two matrixes to draw 
somethign to see whree
   // it is in 3d space, it's in the wrong location.

    // If I do it this way:
    Transform_Matrix( RotateMat * TranslateMat );
    Draw_Model( &SmallSphere, 0, NULL, true );
    // it is not rotated at all, acts as if rotation was 0.

   // if I do it this way:
    Transform_Matrix( TranslateMat * RotateMat );
    Draw_Model( &SmallSphere, 0, NULL, true );

   // Then its off into lala land, either far to the right or far to the 
left
   // depending on the rotation I'm experimenting with 90 or -90

}

Anyone have a clue as to how I could do this?  It doesn't matter to me if I 
have to give differnet parameters to the function.  I at first thought of 
pasing one corner X,Y,Z and the opostie corner X,Y,Z but it coudl be rotated 
any direction between those points (take a piece of paper, hold it by 
opposite corners, you can keep yoru fingers in place yet rotate the paper 
around).
date: Mon, 19 Nov 2007 23:42:27 -0800   author:   Jim Langston

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us