ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
789
789
EMPFEHLEN
-
02.01.12 20:04 #1
- Registriert seit
- Oct 2008
- Beiträge
- 12
Hallo,
ich wollte mich mal an einem kleinen Raumschiffspiel üben und habe schon das erste Problem.
Es geht hierbei um die Kamera.
Noch habe ich kein Raumschiff sondern nur eine Kamera mit der man sich durchs all bewegen kann.
ich habe hier die Funktion mit der ich die Kamera Rendere
Code :1 2 3 4 5 6 7 8 9 10
public void SetKammere() { m_Device.Transform.World = Matrix.Identity; m_Device.Transform.View = Matrix.LookAtLH(new Vector3(WorldInformation.xWorldPos, WorldInformation.yWorldPos, -5.0f + WorldInformation.zWorldPos), new Vector3(WorldInformation.xWorldPos, WorldInformation.yWorldPos, WorldInformation.zWorldPos), new Vector3(0.0f, 1.0f, 0.0f)) * Matrix.RotationYawPitchRoll(WorldInformation.fAngleX, WorldInformation.fAngleY, 0.0f); m_Device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, GetAufloesung, 1.0f, 250.0f); // m_Device.Transform.World.RotateY(WorldInformation.fAngle); }
und hier eine mit der ich die Kamera steuere (umsehen und auf der z und x achse bewegen)
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
public void MoveForward() { float ZAchse = 1; float XAchse = 1; //neue Variablen zum rechnen mit den zwei winkeln x und y float neuXWinkelOld = Geometry.RadianToDegree(WorldInformation.fAngleX); float neuYWinkelOld = Geometry.RadianToDegree(WorldInformation.fAngleY); float neuXWinkel = neuXWinkelOld; float neuYWinkel = neuYWinkelOld; float neuYWinkelZAchseOld = neuXWinkelOld + 90; if (neuYWinkelZAchseOld > 180) neuYWinkelZAchseOld -= 360; float neuYWinkelZAchse = neuYWinkelZAchseOld; //zurechtlegen der Achsen //für ZAchse if (neuXWinkel < 0) neuXWinkel *= -1; if (neuYWinkel < 0) neuYWinkel *= -1; if (neuXWinkel > 90) neuXWinkel -= 90; if (neuYWinkel > 90) neuYWinkel -= 90; //für XAchse if (neuYWinkelZAchse < 0) neuYWinkelZAchse *= -1; if (neuYWinkelZAchse > 90) neuYWinkelZAchse -= 90; float xProzent = neuXWinkel * 100 / 90; float yProzent = neuYWinkel * 100 / 90; float yProzentXAchse = neuYWinkelZAchse * 100 / 90; ZAchse -= ZAchse / 100 * xProzent; ZAchse -= ZAchse / 100 * yProzent; XAchse -= XAchse / 100 * xProzent; XAchse -= xProzent / 100 * yProzentXAchse; if (neuXWinkelOld > 90 || neuXWinkelOld < -90) { ZAchse -= 1; } if (neuYWinkelZAchseOld > 90 || neuYWinkelZAchseOld < -90) { XAchse -= 1; } WorldInformation.zWorldPos += ZAchse; WorldInformation.xWorldPos += XAchse; }
umsehen mit der Kamera
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
if (Eingabe.MouseButtons[1] != 0) { WorldInformation.fAngleX -= Eingabe.xMouseMovement / 100; WorldInformation.fAngleY -= Eingabe.yMouseMovement / 100; if (Geometry.RadianToDegree(WorldInformation.fAngleX) > 180) WorldInformation.fAngleX = Geometry.DegreeToRadian(-180); if (Geometry.RadianToDegree(WorldInformation.fAngleX) < -180) WorldInformation.fAngleX = Geometry.DegreeToRadian(180); if (Geometry.RadianToDegree(WorldInformation.fAngleY) > 180) WorldInformation.fAngleY = Geometry.DegreeToRadian(-180); if (Geometry.RadianToDegree(WorldInformation.fAngleY) < -180) WorldInformation.fAngleY = Geometry.DegreeToRadian(180); }
Das umsehen klappe hab wegs solange ich mich nicht von der position bewegt habe.. doch nun wenn ich mich fortbewege stimmt die z rotation welche ich ja auch nicht gemacht habe weil ich der meinung bin das diese nicht benötigt wird weggelassen habe.
So nur ich steuer in die komplett falsche richtung.
kann mir jemand schritt für schritt erklären wie ich eine richtige kamera führung durchs all erstellen kann?
Wäre sehr nett
Danke schon mal leute
Geändert von Zera Kakkade (02.01.12 um 23:00 Uhr)
Ähnliche Themen
-
Directx 8 und 9
Von Anfänger92 im Forum C/C++Antworten: 0Letzter Beitrag: 13.05.07, 12:38 -
C# und DirectX
Von time-master im Forum LiteraturAntworten: 0Letzter Beitrag: 26.03.06, 00:16 -
[DirectX // Win 32] DirectX im Fenster?
Von Nizomi im Forum C/C++Antworten: 8Letzter Beitrag: 31.08.05, 23:26 -
DirectX
Von the edge im Forum C/C++Antworten: 1Letzter Beitrag: 10.04.05, 18:23 -
DirectX
Von DerAndere im Forum Microsoft WindowsAntworten: 10Letzter Beitrag: 08.11.04, 21:54





Zitieren
Login





