|
-
Aug 29th, 2002, 11:40 PM
#1
Thread Starter
Good Ol' Platypus
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)
-
Aug 30th, 2002, 01:03 AM
#2
Lively Member
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.
-
Aug 30th, 2002, 09:47 AM
#3
Thread Starter
Good Ol' Platypus
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)
-
Aug 30th, 2002, 02:27 PM
#4
Lively Member
thats the way id do it 2 if i needed 2
-
Aug 30th, 2002, 02:43 PM
#5
Thread Starter
Good Ol' Platypus
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)
-
Aug 30th, 2002, 05:21 PM
#6
Frenzied Member
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.
-
Aug 30th, 2002, 07:59 PM
#7
Thread Starter
Good Ol' Platypus
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)
-
Aug 31st, 2002, 10:56 AM
#8
Thread Starter
Good Ol' Platypus
Okay, I got it!! Look at this rather messy code:
VB Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Static Angle As Double
Dim TL As D3DVECTOR
Dim TR As D3DVECTOR
Dim BL As D3DVECTOR
Dim BR As D3DVECTOR
Select Case KeyCode
Case vbKeyLeft
Angle = Angle + 4.5
Case vbKeyRight
Angle = Angle - 4.5
Case Else
Exit Sub
End Select
TL.z = 0
TL.x = -0.2
TL.y = -1
TR.z = 0
TR.x = 0.2
TR.y = -1
BL.z = 0
BL.x = -0.2
BL.y = 1
BR.z = 0
BR.x = 0.2
BR.y = 1
RotateVectOverZ TL, Angle * (3.1415926 / 180)
RotateVectOverZ TR, Angle * (3.1415926 / 180)
RotateVectOverZ BL, Angle * (3.1415926 / 180)
RotateVectOverZ BR, Angle * (3.1415926 / 180)
Line1.x1 = 100 + TL.x * 50
Line1.y1 = 100 + TL.y * 50
Line1.x2 = 100 + TR.x * 50
Line1.y2 = 100 + TR.y * 50
Line2.x1 = 100 + TR.x * 50
Line2.y1 = 100 + TR.y * 50
Line2.x2 = 100 + BR.x * 50
Line2.y2 = 100 + BR.y * 50
Line3.x1 = 100 + BL.x * 50
Line3.y1 = 100 + BL.y * 50
Line3.x2 = 100 + TL.x * 50
Line3.y2 = 100 + TL.y * 50
Line4.x1 = 100 + BR.x * 50
Line4.y1 = 100 + BR.y * 50
Line4.x2 = 100 + BL.x * 50
Line4.y2 = 100 + BL.y * 50
End Sub
Public Sub RotateVectOverZ(Vect As D3DVECTOR, Rads As Single)
Dim TVect As D3DVECTOR
TVect = Vect
Vect.x = TVect.x * Cos(Rads) + TVect.y * Sin(Rads)
Vect.y = TVect.y * Cos(Rads) - TVect.x * Sin(Rads)
Vect.z = TVect.z
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)
-
Aug 31st, 2002, 11:36 AM
#9
Frenzied Member
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.
-
Aug 31st, 2002, 12:40 PM
#10
Thread Starter
Good Ol' Platypus
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)
-
Aug 31st, 2002, 12:48 PM
#11
Frenzied Member
Doing some fun nifty stuff, eh? =).
Z.
-
Aug 31st, 2002, 11:15 PM
#12
Thread Starter
Good Ol' Platypus
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|