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
Anonymous
unregistriert
Quellcode |
|
1 2 |
PDIRECT3DTEXTURE9 g_pSphereTexture = NULL; // Textur der Kugel LPD3DXMESH g_pSphereModel = NULL; // Kugelmodell |
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 |
tbResult Render(float fNumSecsPassed) { tbMatrix mTranslation; tbMatrix mRotation; tbMatrix mWorld; HRESULT hRes; mTranslation = tbMatrixTranslation(tbVector3(0.0f, 0.0f, 2.0f)); mRotation = tbMatrixRotationY(TB_DEG_TO_RAD(g_fTime * 60.0f)); mWorld = mRotation * mTranslation; g_pD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*) (&mWorld)); if(FAILED(hRes = g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 63), 1.0f, 0))) { MessageBox(g_hWindow, "Fehler beim Leeren der Puffer!", "Fehler", MB_OK | MB_ICONEXCLAMATION); TB_ERROR_DIRECTX("g_pD3DDevice->Clear", hRes, TB_STOP); } g_pD3DDevice->BeginScene(); g_pD3DDevice->SetTexture(0, g_pSphereTexture); g_pSphereModel->DrawSubset(0); g_pD3DDevice->EndScene(); g_pD3DDevice->Present(NULL, NULL, NULL, NULL); return TB_OK; } |
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 58 59 |
tbResult InitScene() { HRESULT hResult; float fAspect; tbMatrix mProjection; g_pD3DDevice->SetRenderState(D3DRS_AMBIENT, tbColor(0.25f, 0.0f, 0.0f)); if(FAILED(hResult = D3DXCreateTextureFromFileEx(g_pD3DDevice, // Device "Sphere.bmp", // Dateiname D3DX_DEFAULT, // Breite D3DX_DEFAULT, // Höhe D3DX_DEFAULT, // MIP-Maps 0, // Verwendungszweck D3DFMT_UNKNOWN, // Format D3DPOOL_MANAGED, // Speicherklasse D3DX_FILTER_NONE, // Filter D3DX_DEFAULT, // MIP-Map-Filter 0, // Color-Key NULL, // Unwichtig NULL, // Unwichtig &g_pSphereTexture))) // Die Textur { // Fehler! TB_ERROR_DIRECTX("D3DXCreateTextureFromFileEx", hResult, TB_ERROR); } // Das Kugelmodell laden if(FAILED(hResult = D3DXLoadMeshFromX("Sphere.x", D3DXMESH_MANAGED, g_pD3DDevice, NULL, NULL, NULL, NULL, &g_pSphereModel))) { // Fehler! TB_ERROR_DIRECTX("D3DXLoadMeshFromX", hResult, TB_ERROR); } if(FAILED(hResult = g_pD3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE))) { TB_ERROR_DIRECTX("g_pD3DDevice->SetFVF", hResult, TB_ERROR); } g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); g_pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); g_pD3DDevice->SetRenderState(D3DRS_DITHERENABLE, TRUE); fAspect = (float) (g_Direct3DParameters.VideoMode.Width) / (float) (g_Direct3DParameters.VideoMode.Height); mProjection = tbMatrixProjection(TB_DEG_TO_RAD(90.0f), fAspect, 0.1f, 100.0f); g_pD3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*) (&mProjection)); return TB_OK; } |
Alter Hase
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
mTranslation = tbMatrixTranslation(tbVector3(0.0f, 0.0f, 2.0f)); mRotation = tbMatrixRotationY(TB_DEG_TO_RAD(g_fTime * 60.0f)); mScaling = tbMatrixScaling(tbVector3(?, ?, ?)); mWorld = mScaling * mRotation * mTranslation; g_pD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*) (&mWorld)); |
Anonymous
unregistriert
Werbeanzeige