|
-
Apr 16th, 2001, 09:57 AM
#1
Thread Starter
PowerPoster
Ok, I don't know how to explain the problem, look at the project I attached. The rotation matrix seems to scew up when turning around X or Y while Z rotation works fine... Please help!
-
Apr 16th, 2001, 11:08 AM
#2
Good Ol' Platypus
It works fine for me fox...
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Apr 16th, 2001, 11:37 AM
#3
I havent look at the project, but are you multiplying
matricies, and, if so, are you doing it in the right order?
That can screw things up pretty bad. Just as an example, say you have a wheel, but its lying on its side. you want it to rotate, so you want to rotate 90 along the Z,so it stands up, and then rotate around X so it spins. But, if you first apply the X Rotation, the wheel will be angled up slightly, and when you apply the Z, the wheel will appear to wobble. That MIGHT be your problem, Hope it helps.
Z.
-
Apr 16th, 2001, 11:38 AM
#4
Thread Starter
PowerPoster
Nope..
Press UP+RIGHT some time, you'll notice the stars becoming flat... they're not flat, the positions are randomized in a cube (when moving far away you see the cube...)
Code:
Controls:
Q / E = Rotate Z
Left / Right = Rotate Y
Up / Down = Rotate X
+ / - = Move Z
D / A = Move X
W / S = Move Z (you can replace this, should be Y)
-
Apr 16th, 2001, 11:41 AM
#5
Thread Starter
PowerPoster
Hm, as I can remember I took all rotation matrices, multiplied them and got the final rotation matrix... looks like this;
Code:
'The stars are fixed, I just move the camera object
Sub Draw(iUniverse As tUniverse, iColor As Long)
On Error Resume Next
Dim A As Long
Dim x2 As Single
Dim y2 As Single
Dim z2 As Single
Dim TempX As Long
Dim TempY As Long
With Camera
For A = 0 To iUniverse.StarCount
'Calculate coordinates
x2 = (iUniverse.Star(A).x * Cos(.rY) * Cos(.rZ) + .y * Sin(.rZ) + iUniverse.Star(A).z * -Sin(.rY))
y2 = (iUniverse.Star(A).x * -Sin(.rZ) + iUniverse.Star(A).y * Cos(.rX) * Cos(.rZ) + iUniverse.Star(A).z * Sin(.rX))
z2 = (iUniverse.Star(A).x * Sin(.rY) + iUniverse.Star(A).y * -Sin(.rX) + iUniverse.Star(A).z * Cos(.rX) * Cos(.rY))
If z2 > 0 Then
TempX = (.w / 2) + .FOV * (x2 / z2)
TempY = (.h / 2) + .FOV * (y2 / z2)
'Draw star
SetPixelV .FrontDC, TempX, TempY, iColor
End If
Next
End With
End Sub
-
Apr 17th, 2001, 09:33 AM
#6
Thread Starter
PowerPoster
I dont have a camera matrix, the camera is a simple type that has x, y, z and rx, ry, rz for the angle.
(project attached; see 1st post)
-
Apr 17th, 2001, 09:39 AM
#7
transcendental analytic
well thats not enough to allow the camera to rotate freely, why not use a matrix instead?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 17th, 2001, 09:43 AM
#8
Thread Starter
PowerPoster
Well when I started the project I used matrices, but I saw that it makes no sense so instead I used just variables.
However, that's not the problem I think, the only thing I need to know is what's wrong with my rotation forumla?
-
Apr 17th, 2001, 09:55 AM
#9
transcendental analytic
I have no idea how you come up with it in the first place and what rx ry and rz stand for
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 17th, 2001, 10:01 AM
#10
Thread Starter
PowerPoster
the x- y- and z-angle of the camera of course
-
Apr 17th, 2001, 03:15 PM
#11
transcendental analytic
hmm, this took me ages, i got miscalculations twice and ended up with weird rotations. I hope you're happy with the results now I also extracted the trigonometry parts outside the loop to speed up the process
Code:
Sub Draw(iUniverse As tUniverse, iColor As Long)
On Error Resume Next
Dim A As Long
Dim x2 As Single
Dim y2 As Single
Dim z2 As Single
Dim TempX As Long
Dim TempY As Long
Dim t0!, t1!, t2!, t3!, t4!, t5!, t6!, t7!, t8!, t9!, t10!
With Camera
t0 = Sin(.rX)
t1 = Cos(.rX)
t2 = Sin(.rY)
t3 = Cos(.rY)
t4 = Sin(.rZ)
t5 = Cos(.rZ)
For A = 0 To iUniverse.StarCount
'Calculate coordinates
t6 = iUniverse.Star(A).y * t5
t7 = iUniverse.Star(A).x * t4
t8 = t5 * iUniverse.Star(A).x
t9 = t4 * iUniverse.Star(A).y
t10 = t3 * iUniverse.Star(A).z
x2 = .x - (t3 * (t8 - t9) + t2 * iUniverse.Star(A).z)
y2 = .y - (t0 * (t2 * t8 - t2 * t9 - t10) + t1 * (t7 + t6))
z2 = .z - (t1 * (-t2 * t8 + t2 * t9 + t10) + t0 * (t7 + t6))
If z2 > 0 Then
TempX = (.w / 2) + .FOV * (x2 / z2)
TempY = (.h / 2) + .FOV * (y2 / z2)
'Draw star
SetPixelV .FrontDC, TempX, TempY, iColor
End If
Next
End With
End Sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|