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 |
HRESULT InitGeometry() { // Initialize three vertices for rendering a triangle CUSTOMVERTEX g_Vertices[] = { { -1.0f,-1.0f, 0.0f, 0xffff0000, }, { 1.0f,-1.0f, 0.0f, 0xff0000ff, }, { 0.0f, 1.0f, 0.0f, 0xffffffff, }, { 1.0f,1.0f,0.0f, 0xffff0000, }, //<----- Zweites Dreieck { 3.0f,1.0f,0.0f, 0xff0000ff, }, { 2.0f,2.0f,0.0f, 0xff0000ff, }, }; usw... |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
VOID SetupMatrices() { // For our world matrix, we will just rotate the object about the y-axis. D3DXMATRIXA16 matWorld, matWorld1, matWorld2, matWorld3; // Set up the rotation matrix to generate 1 full rotation (2*PI radians) // every 1000 ms. To avoid the loss of precision inherent in very high // floating point numbers, the system time is modulated by the rotation // period before conversion to a radian angle. UINT iTime = timeGetTime() % 1000; FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f; D3DXMatrixRotationY( &matWorld, fAngle ); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); usw.... |
Zitat von »"0x00000023"«
das dreieck render das sich nicht drehen soll,
dann die rotationsmatrix setzen und dann das andere rendern
bzw. wenn du das renderst das sich nicht drehen soll
dann setzt entsprechend wieder eine nicht rotiert transformationsmatrix.
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
VOID Render() { // Clear the backbuffer to a black color g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { // Setup the world, view, and projection matrices g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 ); //<--- zeichnet das erste Dreieck SetupMatrices(); <--- Jetzt kommt die Rotation // Render the vertex buffer contents g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 1, 2 ); <-- Zeichnet das zweite Dreieck |
Anonymous
unregistriert
Zitat
Syntax
HRESULT DrawPrimitive( D3DPRIMITIVETYPE PrimitiveType,
UINT StartVertex, <--------------!!!!
UINT PrimitiveCount <--------------!!!!!
);
Quellcode |
|
1 2 |
D3DXMatrixRotationY( &matWorld, fAngle ); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); |
Quellcode |
|
1 2 |
D3DXMatrixIdentity( &matWorld); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); |
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 |
VOID SetupMatrices() { // For our world matrix, we will just rotate the object about the y-axis. D3DXMATRIXA16 matWorld, matWorld1, matWorld2, matWorld3; D3DXMatrixIdentity( &matWorld); <-- Hier hab ich die Identitätsmatrix eingefügt g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); // Set up the rotation matrix to generate 1 full rotation (2*PI radians) // every 1000 ms. To avoid the loss of precision inherent in very high // floating point numbers, the system time is modulated by the rotation // period before conversion to a radian angle. UINT iTime = timeGetTime() % 1000; FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f; D3DXMatrixRotationY( &matWorld, fAngle ); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); VOID Render() { // Clear the backbuffer to a black color g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { // Setup the world, view, and projection matrices g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1); SetupMatrices(); // Render the vertex buffer contents g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 3, 1 ); // End the scene g_pd3dDevice->EndScene(); } |
Alter Hase
Alter Hase
Werbeanzeige