Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
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 |
XCamera::XCamera() { m_EyePt.x = 0; m_EyePt.y = 0; m_EyePt.z = -1; m_LookAtPt.x = 0; m_LookAtPt.y = 0; m_LookAtPt.z = 1; m_fSpeed = 0; } XCamera::~XCamera() { } void XCamera::Move() { D3DXVECTOR3 direction; D3DXVec3Normalize(&direction, &(m_LookAtPt - m_EyePt)); // Die restliche Bewegungsengine kommt nocht if(KEY_DOWN('w')) { m_EyePt += direction * m_fSpeed; m_LookAtPt += direction * m_fSpeed; } if(KEY_DOWN('s')) { m_EyePt -= direction * m_fSpeed; m_LookAtPt -= direction * m_fSpeed; } // Theres some more code following here } void XCamera::Rotate() { // This method is filled later } void XCamera::Update(PDIRECT3DDEVICE9 pDevice) { Move(); Rotate(); D3DXMatrixLookAtLH(&m_matView, &m_EyePt, &m_LookAtPt, &m_Up); pDevice->SetTransform(D3DTS_VIEW, &m_matView); } |
Anonymous
unregistriert
Anonymous
unregistriert
Anonymous
unregistriert
Quellcode |
|
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 |
void XCamera::Move() { D3DXVECTOR3 direction; D3DXVec3Normalize(&direction, &(m_LookAtPt - m_EyePt)); // Just let the user move the cam, if the camera is moveable if(!this->m_MovingStarted || this->waypointStates.camMoveable == true) { // Die restliche Bewegungsengine kommt noch if(KEY_DOWN(KEY_MOVE_FORWARD)) { m_EyePt += direction * m_fSpeed; m_LookAtPt += direction * m_fSpeed; } if(KEY_DOWN(KEY_MOVE_BACKWARD)) { m_EyePt -= direction * m_fSpeed; m_LookAtPt -= direction * m_fSpeed; } } // Move the camera allong the waypoints if(this->m_MovingStarted) { int i = 0; // Index of the next waypoint // Get the index of the next waypoint while(this->m_Waypoints[i].touched == true) i++; D3DXVec3Normalize(&direction, &(this->m_Waypoints[i].point - this->m_EyePt)); this->m_EyePt += direction * this->m_Waypoints[i].movingSpeed; this->m_LookAtPt += direction * this->m_Waypoints[i].movingSpeed; // Check if the cam has arrived the actual waypoint D3DXVECTOR3 temp; D3DXVec3Subtract(&temp, &this->m_EyePt, &this->m_Waypoints[i].point); float dist = D3DXVec3Length(&temp); if(dist < 0.5f && dist > -0.5f) { // MessageBox(NULL, "You arrived", "Hello", MB_OK); this->m_Waypoints[i].touched = true; if(i >= this->numOfWaypoints) { this->m_MovingStarted = false; this->setWaypointState(WS_CAMMOVEABLE, true); } } } // Theres some more code following here } |
Werbeanzeige