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
C-/C++-Quelltext |
|
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
tbResult CGame::Render(float fTime) { CheckPlayerWon(); CheckPcWon(); tbMatrix mCam; tbMatrix mProjection; D3DLIGHT9 Light; tbDirect3D& D3D = tbDirect3D::Instance(); D3D->Clear(0,NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, tbColor(0.0f, 0.0f, 0.0f),1.0f ,0); D3D->BeginScene(); //Kamera positionieren m_vCamPos = tbVector3( 0.0f, 5.0f, 0.0f); //Kamera "Guck-Punkt" bestimmen m_vCamLookAt = tbVector3( 0.0f, 0.0f, 0.0f); //SkyBox zeichnen DrawSkyBox(); //Kameramatrix einsetzen mCam = tbMatrixCamera(m_vCamPos, m_vCamLookAt); D3D.SetTransform(D3DTS_VIEW, mCam); //Projektionsmatrix erstellen und einsetzen mProjection = tbMatrixProjection(TB_RAD_TO_DEG(70.0f),D3D.GetAspect(),0.1f,50.0f); D3D.SetTransform(D3DTS_PROJECTION, mProjection); tbColor Color = tbColor( 1.0f, 1.0f, 1.0f); //Licht erstellen ZeroMemory(&Light, sizeof(D3DLIGHT9)); Light.Type = /*D3DLIGHT_DIRECTIONAL*/D3DLIGHT_POINT; Light.Diffuse = Color; Light.Specular = Color; Light.Position = tbVector3( 0.0f, 0.0f, 0.0f); //Light.Direction = m_vCamLookAt - m_vCamPos; D3D->SetLight(0, &Light); D3D->LightEnable(0, TRUE); //Schwaches Ambiente D3D->SetRenderState(D3DRS_AMBIENT, tbColor( 0.0f, 0.0f, 0.8f)); //Blöcke rendern m_vBlockPos[0] = tbVector3( 0.0f, 0.0f, 0.0f); m_vBlockPos[1] = tbVector3( 1.0f, 0.0f, 0.0f); m_vBlockPos[2] = tbVector3( 0.0f, 0.0f, 0.0f); m_vBlockPos[3] = tbVector3( 2.0f, 0.0f, 1.0f); m_vBlockPos[4] = tbVector3( 1.0f, 0.0f, 1.0f); m_vBlockPos[5] = tbVector3( 0.0f, 0.0f, 1.0f); m_vBlockPos[6] = tbVector3( 2.0f, 0.0f, 2.0f); m_vBlockPos[7] = tbVector3( 1.0f, 0.0f, 2.0f); m_vBlockPos[8] = tbVector3( 0.0f, 0.0f, 2.0f); for(int q = 0; q < 9; q++) { D3D.SetTransform(D3DTS_WORLD, tbMatrixTranslation(m_vBlockPos[q])); if(m_iCursor == q) { tbVector3 Position = tbVector3( 0.0f, -0.5f, 0.0f) + m_vBlockPos[q]; D3D.SetTransform(D3DTS_WORLD, tbMatrixTranslation(Position)); } if(m_iBlockStatus[q] == 0) { m_pBlock[q]->Render(); } else if(m_iBlockStatus[q] == 1) //was machen, wenn der Block dem Spieler gehört { tbMatrix mRotation = tbMatrixRotationZ(TB_DEG_TO_RAD(-90.0f)); tbMatrix mTranslation(tbMatrixTranslation(m_vBlockPos[q]-tbVector3( -0.5f, -0.5f, 0.0f))); tbMatrix mWorld = mRotation * mTranslation; D3D.SetTransform(D3DTS_WORLD, mWorld); if(m_iCursor == q) { tbVector3 Position = tbVector3( 0.5f, -0.3f, 0.0f) + m_vBlockPos[q]; D3D.SetTransform(D3DTS_WORLD, mRotation*tbMatrixTranslation(Position)); } m_pBlock[q]->Render(); } else if(m_iBlockStatus[q] == 2) //was machen, wenn der Block dem Pc gehört { tbMatrix mRotation = tbMatrixRotationZ(TB_DEG_TO_RAD(90.0f)); tbMatrix mTranslation(tbMatrixTranslation(m_vBlockPos[q]-tbVector3( -0.55f, 0.5f, 0.0f))); tbMatrix mWorld = mRotation * mTranslation; D3D.SetTransform(D3DTS_WORLD, mWorld); if(m_iCursor == q) { tbVector3 Position = tbVector3( 0.55f, -1.0f, 0.0f) + m_vBlockPos[q]; D3D.SetTransform(D3DTS_WORLD, mRotation*tbMatrixTranslation(Position)); } m_pBlock[q]->Render(); } }//For-SChleife-Ende DrawPause(Color); DrawPlayerWon(Color); DrawPcWon(Color); DrawUndicided(Color); D3D->EndScene(); return TB_OK; } |
Zitat
Kamera Guck Punkt bestimmen
C-/C++-Quelltext |
|
1 2 3 |
// Weltmatrix erstellen, die die Sky-Box zur Kamera hin schiebt tbMatrix mWorld = tbMatrixTranslation(m_vCamPos); D3D.SetTransform(D3DTS_WORLD, mWorld); |
C-/C++-Quelltext |
|
1 2 3 |
m_vCamLookAt = tbVector3(sinf(fCameraRot) * cosf(fCameraUpDown), sinf(fCameraUpDown), cosf(fCameraRot) * cosf(fCameraUpDown)); |
Werbeanzeige