Kamera Pitch Beschränkung
Übersicht

KyroMasterBetreff: Kamera Pitch Beschränkung |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Ich will in mein Spiel eine Beschränkung des Kamerawinkels einbauen, damit man sich nicht nach vorne "überdrehen" kann (wie in allen FPS)
If EntityPitch(Camera) > 70 Then RotateEntity Camera,70,EntityYaw(Camera),0 Wenn ich dies nach jedem Update des Winkels ausführe, so funktioniert es mit "70" als Schranke sehr gut.Wenn ich jedoch 89.x oder 90 verwende funktioniert es nicht mehr, bei 90 wird der Code nach dem "then" nie ausgeführt, wenn ich die Maus immer weiter nach unten ziehe fängt es an zu "wackeln". In einem der Tutorials stand drin dass man hier einen bräuchte, deswegen wurde 70 eingesetzt. Was hat das für Gründe? |
||
Vielen Dank für Eure Hilfe!!! |
morszeck |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Geht auch nicht... Da wen Pitch über 89.9° kommt, so ändern sich auch die ganzen anderen Winkel. Dies ist eben ein Grenzbereich, der zu einem in dem Sinne undefiniertes Verhalten führt.
Du muss dir vorstellen die Kamera sei dein Kopf, und so musst du die Kamera auch steuern. Also 70 ° sollten je nach dem doch ausreichend sein, sonst wird der Spieler schnell orientierungslos... |
||
WinXpProf&SP2, B3D V1.88, B+ V1.40, BMax101Beta, AMD TB1.4GHz, DDR266/768MB, GeForce3@64MB |
KyroMaster |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Gut ich habs ein bisschen verändert und jetzt funktioniert alles ![]() Wie heißt das Winkelsystem das in B3D zum Einsatz kommt denn?Es gibt doch mehrere Systeme (Eulerwinkel?) |
||
Vielen Dank für Eure Hilfe!!! |
![]() |
Jan_Ehemaliger Admin |
![]() Antworten mit Zitat ![]() |
---|---|---|
ach, vielleicht, hast du den falschen ansatz, speichere die winkel in Variablen ab, und beschränke diese.
dann rechnest du mit mouseX/Y/Zspeed() den winkel, und dann drehst du mit rotateentity |
||
between angels and insects |
![]() |
Markus2 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Gibt noch Quaternion , das ist komplizierter aber besser ,
Beispiel oder Link zu einer HP müßtest du finden auf BlitzBasic.com im Code Archiv . Auf dieser Webseite wo ich den Link jetzt nicht weiß was es gut erklärt . Code: Graphics3D 800,600,16,2 SetBuffer BackBuffer() Global cam=CreateCamera() PositionEntity cam,0,0,-100 Global cube=CreateCube() ScaleMesh cube,10,10,10 Global c1=CreateCube(cube) Global c2=CreateCube(cube) ScaleMesh c1,3,3,3 ScaleMesh c2,3,3,3 PositionEntity c1,-20,0,0 PositionEntity c2, 20,0,0 Local q.Quat = New Quat Local qr1.Quat = New Quat Local qr2.Quat = New Quat Local qr3.Quat = New Quat EulerToQuat q, 0,0,0 While Not KeyHit(1) If KeyDown(200) Then EulerToQuat qr1, 1,0,0 :MultiplyQuat(q,q,qr1) If KeyDown(208) Then EulerToQuat qr1,-1,0,0 :MultiplyQuat(q,q,qr1) If KeyDown(203) Then EulerToQuat qr2,0, 1,0 :MultiplyQuat(q,q,qr2) If KeyDown(205) Then EulerToQuat qr2,0,-1,0 :MultiplyQuat(q,q,qr2) If KeyDown(211) Then EulerToQuat qr3,0,0, 1 :MultiplyQuat(q,q,qr3) If KeyDown(209) Then EulerToQuat qr3,0,0,-1 :MultiplyQuat(q,q,qr3) QuatToEntity q,cube,0 MoveEntity cube,0,0,1 If KeyHit(57) Then PointEntity cam,cube,0 EndIf RenderWorld Delay 10 Flip Wend End ;---------------------------------------------------------------------------- Type Quat Field w#, x#, y#, z# End Type ; Change these constants if you notice slips in accuracy Const QuatToEulerAccuracy# = 0.001 ;---------------------------------------------------------------------------- Function EulerToQuat(out.Quat, pitch#,yaw#,roll#) ; convert a Rotation to a Quat ; NB roll is inverted due to change in handedness of coordinate systems Local cr# = Cos(-roll/2) Local cp# = Cos(pitch/2) Local cy# = Cos(yaw/2) Local sr# = Sin(-roll/2) Local sp# = Sin(pitch/2) Local sy# = Sin(yaw/2) ; These variables are only here to cut down on the number of multiplications Local cpcy# = cp * cy Local spsy# = sp * sy Local spcy# = sp * cy Local cpsy# = cp * sy ; Generate the output quat out\w = cr * cpcy + sr * spsy out\x = sr * cpcy - cr * spsy out\y = cr * spcy + sr * cpsy out\z = cr * cpsy - sr * spcy End Function Function QuatToEntity(src.Quat,Entity,RotGlobal=0) ; convert a Quat to a Rotation Local sint#, cost#, sinv#, cosv#, sinf#, cosf# Local cost_temp# sint = (2 * src\w * src\y) - (2 * src\x * src\z) cost_temp = 1.0 - (sint * sint) If Abs(cost_temp) > QuatToEulerAccuracy cost = Sqr(cost_temp) Else cost = 0 EndIf If Abs(cost) > QuatToEulerAccuracy sinv = ((2 * src\y * src\z) + (2 * src\w * src\x)) / cost cosv = (1 - (2 * src\x * src\x) - (2 * src\y * src\y)) / cost sinf = ((2 * src\x * src\y) + (2 * src\w * src\z)) / cost cosf = (1 - (2 * src\y * src\y) - (2 * src\z * src\z)) / cost Else sinv = (2 * src\w * src\x) - (2 * src\y * src\z) cosv = 1 - (2 * src\x * src\x) - (2 * src\z * src\z) sinf = 0 cosf = 1 EndIf ; Generate the output rotation RotateEntity Entity,ATan2(sint, cost),ATan2(sinf, cosf),-ATan2(sinv, cosv),RotGlobal ; inverted due to change in handedness of coordinate system End Function Function MultiplyQuat(result.Quat, q1.Quat, q2.Quat) ; result will be the same rotation as doing q1 then q2 (order matters!) Local a#, b#, c#, d#, e#, f#, g#, h# a = (q1\w + q1\x) * (q2\w + q2\x) b = (q1\z - q1\y) * (q2\y - q2\z) c = (q1\w - q1\x) * (q2\y + q2\z) d = (q1\y + q1\z) * (q2\w - q2\x) e = (q1\x + q1\z) * (q2\x + q2\y) f = (q1\x - q1\z) * (q2\x - q2\y) g = (q1\w + q1\y) * (q2\w - q2\z) h = (q1\w - q1\y) * (q2\w + q2\z) result\w = b + (-e - f + g + h) / 2.0 result\x = a - ( e + f + g + h) / 2.0 result\y = c + ( e - f + g - h) / 2.0 result\z = d + ( e - f - g + h) / 2.0 End Function |
||
KyroMaster |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Axo das heißt also dass in B3D Eulerwinkel zum Einsatz kommen, und es außer diesem System nur noch Quaternition gibt? | ||
Vielen Dank für Eure Hilfe!!! |
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Matrix gäbes es noch.
Aber der Bug würde auch da auftreten ... der lässt sich nur mit Quaternions umgehen. Dummerweise braucht die 3D engine dann wieder matrix -> man ist die ganze zeit am rumkonvertieren, was der grund is warum man es häufig nicht macht ... |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group