Results 1 to 27 of 27

Thread: Direct3D + mouse

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Exclamation Direct3D + mouse

    Hi,
    a thing that I need for all the 3D games I make is the mouse, but I haven't found a good tutorial to combine Mouse and Graphics.

    I'm using Direct3D7.
    I wonder how I can transform the (x,y) coordinates of the mouse into 3D space. (And I know de Y-coordinate of the destination space, not X and Y)
    (picking?)
    Do I have to proceed like this?
    transform Pmouse(x,y) 3 times:
    1. projection matrix ^-1
    2. view matrix ^-1
    3. world matrix ^-1

    Questions:
    1) True?
    2) Is there a function in VB to make the inverse matrix?
    3) Why are there 4 rows and cols in those 3 matrices (x,y,z,?)
    4) Is there a good tutorial for this problem (DX7! + VB6)

    Thanx
    DixCie

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Question Re: Direct3D + mouse

    I can find the coords of the mouse easily, but I don't know how to transform those coordinates into Direct3D's 3D world. it's more a direct3d (7) question than a mouse question... (That tutorial had no relation with direct3d)
    But thanks for the try!
    DixCie

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Like what do you mean? Using the Y coordinates as Z? It's that simple. Just use the Y coordinates as Z coordinates. You can't move the mouse in a 3-axis coordinate system (XYZ). It can only move 2-axises (XY). So yeah, you get the picture.

    You can try downloading anyone of my projects at

    www.angelfire.com/fl5/memorydll/index.html. That shows you controling the camera with the mouse as well as the numpad keys. For the Y axis in my code, just replace the Camera_Angle_X with Camera_Position_Z in the mouse event callback located in FrmMain.

    [Edit]No better yet, something like this only it needs modified a bit to work with the mouse. I don't have VB in front of me so I can't test it now:

    VB Code:
    1. 'Camera Forward
    2.  
    3.             Camera_Position_X = Camera_Position_X + Fast_Sin(Camera_Angle_Y) * Camera_Speed
    4.             Camera_Position_Z = Camera_Position_Z - Fast_Cos(Camera_Angle_Y) * Camera_Speed

  5. #5
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Direct3D + mouse

    No JACOB, he wants to go from screen space (x,y) to world space (x,y,z)

    It is done by extrapolating from screen space through the projection and camera matrix.

    I had a function which did this very easily, I was going to share it but I cannot find it anywhere.

    To determine the exact point, for example if you are clicking on a unit, you fire a ray from your screen space through to the 3d world and keep it going until it colldes with anything, that is where the user clicked...

    Sorry I can't provide any tutorials or source.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  6. #6
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Oh that's what he meant.

    Slaps himself in the face

    I already have something like that going in my DJ program to where I can scratch a 3D vinyl. Hang on I'll get the code.......

  7. #7
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Ok in a module, declare this:

    VB Code:
    1. Public Direct3D_Viewport As D3DVIEWPORT8
    2.  
    3. 'I know the data type is a vector, but it's actually returning vertices
    4.  
    5. Public Vertex_Out(4) As D3DVECTOR
    6. Public Vertices(4) As D3DVECTOR

    Next, over where you created your polygons, you do this:

    VB Code:
    1. 'Here is where you have created your polygon
    2.  
    3.     Polygon_Vertex_List(0) = Create_Unlit_Vertex(-100, 0, -100, 0, 0, 0, 0, 0)
    4.     Polygon_Vertex_List(1) = Create_Unlit_Vertex(100, 0, -100, 0, 0, 0, 1, 0)
    5.     Polygon_Vertex_List(2) = Create_Unlit_Vertex(-100, 0, 100, 0, 0, 0, 0, 1)
    6.     Polygon_Vertex_List(3) = Create_Unlit_Vertex(100, 0, -100, 0, 0, 0, 1, 0)
    7.     Polygon_Vertex_List(4) = Create_Unlit_Vertex(100, 0, 100, 0, 0, 0, 1, 1)
    8.     Polygon_Vertex_List(5) = Create_Unlit_Vertex(-100, 0, 100, 0, 0, 0, 0, 1)
    9.    
    10.     'This is the code that needs to be in there:
    11.  
    12.     [b]
    13.     Vertices(0).X = Polygon_Vertex_List(0).X: Vertices(0).Y = Polygon_Vertex_List(0).Y: Vertices(0).Z = Polygon_Vertex_List(0).Z
    14.     Vertices(1).X = Polygon_Vertex_List(1).X: Vertices(1).Y = Polygon_Vertex_List(1).Y: Vertices(1).Z = Polygon_Vertex_List(1).Z
    15.     Vertices(2).X = Polygon_Vertex_List(4).X: Vertices(2).Y = Polygon_Vertex_List(4).Y: Vertices(2).Z = Polygon_Vertex_List(4).Z
    16.     Vertices(3).X = Polygon_Vertex_List(5).X: Vertices(3).Y = Polygon_Vertex_List(5).Y: Vertices(3).Z = Polygon_Vertex_List(5).Z[/b]

    Next, in your game loop, do this:

    VB Code:
    1. Direct3D_Device.GetViewport Direct3D_Viewport
    2.  
    3. 'This converts World coordinates to screen coordinates
    4.  
    5. D3DXVec3Project Vertex_Out(0), Vertices(0), Direct3D_Viewport, Perspective_Transformation_Matrix, Camera_Transformation_Matrix, World_Transformation_Matrix
    6. D3DXVec3Project Vertex_Out(1), Vertices(1), Direct3D_Viewport, Perspective_Transformation_Matrix, Camera_Transformation_Matrix, World_Transformation_Matrix
    7. D3DXVec3Project Vertex_Out(2), Vertices(2), Direct3D_Viewport, Perspective_Transformation_Matrix, Camera_Transformation_Matrix, World_Transformation_Matrix
    8. D3DXVec3Project Vertex_Out(3), Vertices(3), Direct3D_Viewport, Perspective_Transformation_Matrix, Camera_Transformation_Matrix, World_Transformation_Matrix

    Using the Vertex_Out() variables, you test for a mouse click within that region by just using its X and Y variables. If it passes, you can have it do whatever you want.

    Is this what you meant? Or was it the other way around. If it's the other way around, then you have to use DirectX's D3DXVec3Unproject with the Vertices() being your mouse coordinates.

  8. #8
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Direct3D + mouse

    Are you sure?
    It cannot...

    Where's all the math?
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  9. #9
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Using D3DXVec3Unproject, it'll just convert screen coordinates to World coordinates. No math needed. It does it for you. Same goes with D3DXVec3Project only you get opposite results.

  10. #10
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    I believe the math part you are talking about might have something to do with testing to see if the mouse is within the 3D coordinates after the conversion is made, right?

    This is in OpenGL and in C++ but it might help. Converting it to DX and VB6 wouldn't be a problem.
    Attached Files Attached Files

  11. #11
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Found this link in gamedev.net

    http://www.mvps.org/directx/articles/rayproj.htm

  12. #12

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Thumbs up Re: Direct3D + mouse

    The mvps link seems nice!
    Thanx!
    I'll try to convert it into VB - code...

    DixCie

  13. #13
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Direct3D + mouse

    Bingo Jacob!
    That is the article I used to get it working the first time I did it, that is the math I saw missing.

    Although I still forbid myself to use any D3DX functions unless I either know what they do or absolutly cannot find an alternative.

    So the snippet I was trying to post was a D3DX free C++ version of what was in that article.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  14. #14

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Re: Direct3D + mouse

    Ok, first question:
    how can I invert a matrix with VB and Direct3D7?

    => I want to put this 2 things into VB, but how (what is d3dmath?):

    D3DMath_MatrixInvert(invMatrix,viewMatrix);
    D3DMath_VectorMatrixMultiply(p1,p1,invMatrix);
    Last edited by dixcie; Apr 26th, 2005 at 02:21 PM.

  15. #15
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Apparently I believe that D3DXVec3Unproject does the math for you. Look at the last post:

    http://www.gamedev.net/community/for...opic_id=315786

  16. #16

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Re: Direct3D + mouse

    But I don't think D3DXVec3Project is compatible with DirectX7, is it?

  17. #17
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Look in the object browser in VB and do a search. Remember, it's D3DXVec3Unproject that you are gonna need.

    Yeah I don't have VB in front of me right now. I'm at work. So I can't tell just yet.

  18. #18
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Direct3D + mouse

    It sure aint, that is why I had to get all the math myself.
    I'll see if I can help you.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  19. #19

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Re: Direct3D + mouse

    I found exactly the same tutorial for VB: http://gpwiki.org/index.php/VB:3Dmouse
    but that is for DX7: I still can't do this:
    VB Code:
    1. D3DXMatrixInverse matInverse, 0, matView

    (I tried to add DirectX8 to the project, but he gave an error on that line: 'Type d'argument ByRef incompatible' (FR) => any solutions?
    => matInverse is a D3Dmatrix, but maybe for DX7 instead of DX8???)

    (but on this site I find the VectorMatrixMultiply function )

    I still wonder how I can find matInverse...
    Last edited by dixcie; Apr 27th, 2005 at 10:23 AM.

  20. #20

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Re: Direct3D + mouse

    I did just make a Sub to resolve the problem, i think it's faster than searching on internet...

    if someone is interested:

    VB Code:
    1. Sub InverseMatrix(srcMatrix As D3DMATRIX, destMatrix As D3DMATRIX)
    2.  
    3. 'destination matrix = invMatrix
    4. Dim rc(4, 8)
    5. rc(1, 1) = srcMatrix.rc11
    6. rc(1, 2) = srcMatrix.rc12
    7. rc(1, 3) = srcMatrix.rc13
    8. rc(1, 4) = srcMatrix.rc14
    9. rc(2, 1) = srcMatrix.rc21
    10. rc(2, 2) = srcMatrix.rc22
    11. rc(2, 3) = srcMatrix.rc23
    12. rc(2, 4) = srcMatrix.rc24
    13. rc(3, 1) = srcMatrix.rc31
    14. rc(3, 2) = srcMatrix.rc32
    15. rc(3, 3) = srcMatrix.rc33
    16. rc(3, 4) = srcMatrix.rc34
    17. rc(4, 1) = srcMatrix.rc41
    18. rc(4, 2) = srcMatrix.rc42
    19. rc(4, 3) = srcMatrix.rc43
    20. rc(4, 4) = srcMatrix.rc44
    21.  
    22. For i = 1 To 4
    23. For j = 5 To 8
    24.     If j = i + 4 Then
    25.         rc(i, j) = 1
    26.     Else
    27.         rc(i, j) = 0
    28.     End If
    29. Next j
    30. Next i
    31.  
    32. '1. Spil = 1,1
    33. For i = 2 To 4
    34. For j = 2 To 8
    35.     rc(i, j) = rc(i, j) * rc(1, 1) - rc(i, 1) * rc(1, j)
    36. Next j
    37.     rc(i, 1) = 0
    38. Next i
    39.  
    40. '2. Spil = 2,2
    41. For i = 1 To 4
    42. If i = 2 Then GoTo LineABCDE1
    43. For j = 1 To 8
    44.     If j <> 2 Then rc(i, j) = rc(i, j) * rc(2, 2) - rc(i, 2) * rc(2, j)
    45. Next j
    46.     rc(i, 2) = 0
    47. LineABCDE1:
    48. Next i
    49.  
    50. '3. Spil = 3,3
    51. For i = 1 To 4
    52. If i = 3 Then GoTo LineABCDE2
    53. For j = 1 To 8
    54.     If j <> 3 Then rc(i, j) = rc(i, j) * rc(3, 3) - rc(i, 3) * rc(3, j)
    55. Next j
    56.     rc(i, 3) = 0
    57. LineABCDE2:
    58. Next i
    59.  
    60. '4. Spil = 3,3
    61. For i = 1 To 3
    62. For j = 1 To 8
    63.     If j <> 4 Then rc(i, j) = rc(i, j) * rc(4, 4) - rc(i, 4) * rc(4, j)
    64. Next j
    65.     rc(i, 4) = 0
    66. Next i
    67.  
    68. destMatrix.rc11 = rc(1, 5) / rc(1, 1)
    69. destMatrix.rc12 = rc(1, 6) / rc(1, 1)
    70. destMatrix.rc13 = rc(1, 7) / rc(1, 1)
    71. destMatrix.rc14 = rc(1, 8) / rc(1, 1)
    72. destMatrix.rc21 = rc(2, 5) / rc(2, 2)
    73. destMatrix.rc22 = rc(2, 6) / rc(2, 2)
    74. destMatrix.rc23 = rc(2, 7) / rc(2, 2)
    75. destMatrix.rc24 = rc(2, 8) / rc(2, 2)
    76. destMatrix.rc31 = rc(3, 5) / rc(3, 3)
    77. destMatrix.rc32 = rc(3, 6) / rc(3, 3)
    78. destMatrix.rc33 = rc(3, 7) / rc(3, 3)
    79. destMatrix.rc34 = rc(3, 8) / rc(3, 3)
    80. destMatrix.rc41 = rc(4, 5) / rc(4, 4)
    81. destMatrix.rc42 = rc(4, 6) / rc(4, 4)
    82. destMatrix.rc43 = rc(4, 7) / rc(4, 4)
    83. destMatrix.rc44 = rc(4, 8) / rc(4, 4)
    84.  
    85. End Sub

  21. #21
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Are you sure that'll work?

  22. #22
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Direct3D + mouse

    I was attempting to proove it, but I cannot find the darn project I had which utilized a matrix inverse....

    But, I did find something from a fairly useful matrix article, it is c++ but it is correct:
    PHP Code:
    bool CMatrix4x4::inverseMatrix(CMatrix4x4 m)
    {
       
    float tempMatrix[16] = {0};
       
    float d12d13d23d24d34d41;

        
    d12 m.matrix[2]  * m.matrix[7]  - m.matrix[3]  * m.matrix[6];
        
    d13 m.matrix[2]  * m.matrix[11] - m.matrix[3]  * m.matrix[10];
        
    d23 m.matrix[6]  * m.matrix[11] - m.matrix[7]  * m.matrix[10];
        
    d24 m.matrix[6]  * m.matrix[15] - m.matrix[7]  * m.matrix[14];
        
    d34 m.matrix[10] * m.matrix[15] - m.matrix[11] * m.matrix[14];
        
    d41 m.matrix[14] * m.matrix[3]  - m.matrix[15] * m.matrix[2];

        
    tempMatrix[0] =   m.matrix[5] * d34 m.matrix[9] * d24 m.matrix[13] * d23;
        
    tempMatrix[1] = -(m.matrix[1] * d34 m.matrix[9] * d41 m.matrix[13] * d13);
        
    tempMatrix[2] =   m.matrix[1] * d24 m.matrix[5] * d41 m.matrix[13] * d12;
        
    tempMatrix[3] = -(m.matrix[1] * d23 m.matrix[5] * d13 m.matrix[9]  * d12);

        
    // Calculate the determinant.
        
    float determinant m.matrix[0] * tempMatrix[0] + m.matrix[4] * tempMatrix[1] +
                           
    m.matrix[8] * tempMatrix[2] + m.matrix[12] * tempMatrix[3];

        
    // Clear if the determinant is equal to zero.  0 means matrix have no inverse.
        
    if(determinant == 0.0)
           {
               
    Clear();
             return 
    false;
           }

        
    float invDeterminant 1.0f determinant;
        
        
    // Compute rest of inverse.
        
    tempMatrix[0] *= invDeterminant;
        
    tempMatrix[1] *= invDeterminant;
        
    tempMatrix[2] *= invDeterminant;
        
    tempMatrix[3] *= invDeterminant;

        
    tempMatrix[4] = -(m.matrix[4] * d34 m.matrix[8] * d24 m.matrix[12] * d23) * invDeterminant;
        
    tempMatrix[5] =   m.matrix[0] * d34 m.matrix[8] * d41 m.matrix[12] * d13  invDeterminant;
        
    tempMatrix[6] = -(m.matrix[0] * d24 m.matrix[4] * d41 m.matrix[12] * d12) * invDeterminant;
        
    tempMatrix[7] =   m.matrix[0] * d23 m.matrix[4] * d13 m.matrix[8]  * d12  invDeterminant;

        
    // Pre-compute 2x2 dets for first two rows when computing cofactors 
        // of last two rows.
        
    d12 m.matrix[0]  * m.matrix[5]  - m.matrix[1]  * m.matrix[12];
        
    d13 m.matrix[0]  * m.matrix[9]  - m.matrix[1]  * m.matrix[8];
        
    d23 m.matrix[4]  * m.matrix[9]  - m.matrix[5]  * m.matrix[8];
        
    d24 m.matrix[4]  * m.matrix[13] - m.matrix[5]  * m.matrix[12];
        
    d34 m.matrix[8]  * m.matrix[13] - m.matrix[9]  * m.matrix[12];
        
    d41 m.matrix[12] * m.matrix[1]  - m.matrix[13] * m.matrix[0];

        
    tempMatrix[8]  =   m.matrix[7] * d34 m.matrix[11] * d24 m.matrix[15] * d23 invDeterminant;
        
    tempMatrix[9]  = -(m.matrix[3] * d34 m.matrix[11] * d41 m.matrix[15] * d13) * invDeterminant;
        
    tempMatrix[10] =   m.matrix[3] * d24 m.matrix[7]  * d41 m.matrix[15] * d12 invDeterminant;
        
    tempMatrix[11] = -(m.matrix[3] * d23 m.matrix[7]  * d13 m.matrix[11] * d12) * invDeterminant;
        
    tempMatrix[12] = -(m.matrix[6] * d34 m.matrix[10] * d24 m.matrix[14] * d23) * invDeterminant;
        
    tempMatrix[13] =   m.matrix[2] * d34 m.matrix[10] * d41 m.matrix[14] * d13 invDeterminant;
        
    tempMatrix[14] = -(m.matrix[2] * d24 m.matrix[6]  * d41 m.matrix[14] * d12) * invDeterminant;
        
    tempMatrix[15] =   m.matrix[2] * d23 m.matrix[6]  * d13 m.matrix[10] * d12 invDeterminant;

       
    // Save the temp matrix to our matrix.
       
    matrix[0]  = tempMatrix[0];  matrix[1]  = tempMatrix[1];
       
    matrix[2]  = tempMatrix[2];  matrix[3]  = tempMatrix[3];
        
    matrix[4]  = tempMatrix[4];  matrix[5]  = tempMatrix[5];
       
    matrix[6]  = tempMatrix[6];  matrix[7]  = tempMatrix[7];
        
    matrix[8]  = tempMatrix[8];  matrix[9]  = tempMatrix[9];
       
    matrix[10] = tempMatrix[10]; matrix[11] = tempMatrix[11];
        
    matrix[12] = tempMatrix[12]; matrix[13] = tempMatrix[13];
       
    matrix[14] = tempMatrix[14]; matrix[15] = tempMatrix[15];

       return 
    true;
    }


    bool CMatrix4x4::invertMatrix(CMatrix4x4 m)
    {
       
    // Transpose rotation
      
    matrix0] = m.matrix0];  matrix1] = m.matrix4];  matrix2] = m.matrix8];
      
    matrix4] = m.matrix1];  matrix5] = m.matrix5];  matrix6] = m.matrix9];
      
    matrix8] = m.matrix2];  matrix9] = m.matrix6];  matrix[10] = m.matrix[10];
      
      
    // Clear shearing terms
      
    matrix[3] = 0.0fmatrix[7] = 0.0fmatrix[11] = 0.0fmatrix[15] = 1.0f;

      
    // Translation is minus the dot of tranlation and rotations
      
    matrix[12] = -(m.matrix[12]*m.matrix[0]) - (m.matrix[13]*m.matrix[1]) - (m.matrix[14]*m.matrix2]);
      
    matrix[13] = -(m.matrix[12]*m.matrix[4]) - (m.matrix[13]*m.matrix[5]) - (m.matrix[14]*m.matrix6]);
      
    matrix[14] = -(m.matrix[12]*m.matrix[8]) - (m.matrix[13]*m.matrix[9]) - (m.matrix[14]*m.matrix[10]);
       return 
    true;

    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  23. #23

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Re: Direct3D + mouse

    According to my TI 83+ calc., my method works (for 4x4 matrices)... I used the Gauss-Jordan method, but personalized a bit...

  24. #24
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Hey, while we are on the subject of clicking polygons in 3D coordinates and all of that, what if you have a quad with a texture of a circle, such as a vinyl (which is what's in my DJ program) and you just wanted the the click to be within the radius of that polygon, no matter what angle it appears to be on? That way there, when you make it transparent to reveal just the vinyl, then you wouldn't see weird things like clicking within the invisible corners for when you are gonna scratch.

  25. #25
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Quote Originally Posted by dixcie
    I found exactly the same tutorial for VB: http://gpwiki.org/index.php/VB:3Dmouse
    but that is for DX7: I still can't do this:
    VB Code:
    1. D3DXMatrixInverse matInverse, 0, matView

    (I tried to add DirectX8 to the project, but he gave an error on that line: 'Type d'argument ByRef incompatible' (FR) => any solutions?
    => matInverse is a D3Dmatrix, but maybe for DX7 instead of DX8???)

    (but on this site I find the VectorMatrixMultiply function )

    I still wonder how I can find matInverse...
    Theres just one problem with that VB program. It only works with static non moving polygons, although the camera can move freely. That's why I made a thread on Getting Transformed Vertices so I can test that rather than testing the model vertices.

  26. #26

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Re: Direct3D + mouse

    (http://www.mvps.org/directx/articles/rayproj.htm)=> Is this tutorial working for camera's which source and dest vertices are not in the X,Y or Z axis?
    (e.g.: Source(0,90,-30);Dest(0,0,0))

  27. #27
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Direct3D + mouse

    Could you possibly make a VB port from it? I was having a hardtime.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width