Results 1 to 12 of 12

Thread: C) A puzzling question {cursed, resolved}

  1. #1

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    C) A puzzling question {cursed, resolved}

    In DG8, is it possible to use the matrix with transformed vertices (like for doing 2D). If not, how would one go about rotation?
    Last edited by Sastraxi; Aug 31st, 2002 at 10:58 AM.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  2. #2
    Lively Member
    Join Date
    Jul 2002
    Posts
    118
    Sorry I only use DX8 for 3D mainly, then rotation is easy. My only 2d experience of it is very simply drawing 2d shapes on the screen. Also 2d text using RECTs.

    I guess this wont help but if any of the above sounds of any use just say and Ill get back 2 u.

  3. #3

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Well, I figured that the way that DirectX works - with vertices - I could do my own rotation, by simply using sine and cosine and rorating the vertices from the centrepoint, while keeping the same textture coordinates.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Lively Member
    Join Date
    Jul 2002
    Posts
    118
    thats the way id do it 2 if i needed 2

  5. #5

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Though I hope you would use texture coordinates and not the textture ones I described above
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    2D vertices will be drawn directly to the screen, with NO transformations applied by D3D. If you want rotation, you have to do it yourself =).

    Sorry for not replying to this sooner... I didnt see it =(.

    Z.

  7. #7

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    That's ok. But now I have my own little problem... I can't seem to make it rotate! It's an odd RECT, that's higher than wide... I don't want anybody to write anything, but some theory would help! I've got my own type of RECT that has a centre point and positive/negative X and Y values giving the locations of the sides. It's just a bit confusing
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  8. #8

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Okay, I got it!! Look at this rather messy code:
    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2. Static Angle As Double
    3. Dim TL As D3DVECTOR
    4. Dim TR As D3DVECTOR
    5. Dim BL As D3DVECTOR
    6. Dim BR As D3DVECTOR
    7.  
    8.     Select Case KeyCode
    9.         Case vbKeyLeft
    10.             Angle = Angle + 4.5
    11.         Case vbKeyRight
    12.             Angle = Angle - 4.5
    13.         Case Else
    14.             Exit Sub
    15.     End Select
    16.  
    17.     TL.z = 0
    18.     TL.x = -0.2
    19.     TL.y = -1
    20.    
    21.     TR.z = 0
    22.     TR.x = 0.2
    23.     TR.y = -1
    24.    
    25.     BL.z = 0
    26.     BL.x = -0.2
    27.     BL.y = 1
    28.  
    29.     BR.z = 0
    30.     BR.x = 0.2
    31.     BR.y = 1
    32.  
    33.     RotateVectOverZ TL, Angle * (3.1415926 / 180)
    34.     RotateVectOverZ TR, Angle * (3.1415926 / 180)
    35.     RotateVectOverZ BL, Angle * (3.1415926 / 180)
    36.     RotateVectOverZ BR, Angle * (3.1415926 / 180)
    37.  
    38.     Line1.x1 = 100 + TL.x * 50
    39.     Line1.y1 = 100 + TL.y * 50
    40.     Line1.x2 = 100 + TR.x * 50
    41.     Line1.y2 = 100 + TR.y * 50
    42.    
    43.     Line2.x1 = 100 + TR.x * 50
    44.     Line2.y1 = 100 + TR.y * 50
    45.     Line2.x2 = 100 + BR.x * 50
    46.     Line2.y2 = 100 + BR.y * 50
    47.    
    48.     Line3.x1 = 100 + BL.x * 50
    49.     Line3.y1 = 100 + BL.y * 50
    50.     Line3.x2 = 100 + TL.x * 50
    51.     Line3.y2 = 100 + TL.y * 50
    52.    
    53.     Line4.x1 = 100 + BR.x * 50
    54.     Line4.y1 = 100 + BR.y * 50
    55.     Line4.x2 = 100 + BL.x * 50
    56.     Line4.y2 = 100 + BL.y * 50
    57.    
    58. End Sub
    59. Public Sub RotateVectOverZ(Vect As D3DVECTOR, Rads As Single)
    60.     Dim TVect As D3DVECTOR
    61.    
    62.     TVect = Vect
    63.    
    64.     Vect.x = TVect.x * Cos(Rads) + TVect.y * Sin(Rads)
    65.     Vect.y = TVect.y * Cos(Rads) - TVect.x * Sin(Rads)
    66.     Vect.z = TVect.z
    67. End Sub
    You have to give it a bounding box or it will not rotate properly (it will stretch and skew). I figured this out with a tutorial on vector rotation from Lucky's site! (that's where the RotateVectOverZ function is from).
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Geez, at least use the Line function to draw your box =). It would look much cleaner =).

    Good work. DOnt you have VBGP? It has 2D matrix operations in there, which you would also use for this purpose.

    Z.

  10. #10

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Yeah I do, but they're just magazines on the proverbial coffee table, mostly. I don't find them useful, and I'd rather spend time looking on the net

    And about the horrible code, that was just to see if it would work... The real implementation is in DirectX8
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  11. #11
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Doing some fun nifty stuff, eh? =).

    Z.

  12. #12

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Yes, I'm actually testing some stuff out I know I'll have to do some 2D programming this year and want to have my own DLL with which to do it
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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