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
Anonymous
unregistriert
Alter Hase
Anonymous
unregistriert
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 |
D3DXMATRIXA16 matProj; tbDirect3D::GetDevice()->GetTransform( D3DTS_PROJECTION, &matProj ); tbVector2 CursorPosition= m_pGUI->GetCursorPos(); POINT ptCursor; ptCursor.x = CursorPosition.x; ptCursor.y = CursorPosition.y; ScreenToClient( tbDirect3D::GetWindow(), &ptCursor ); // Compute the vector of the pick ray in screen space D3DXVECTOR3 v; v.x = ( ( ( 2.0f * ptCursor.x ) / m_d3dsdBackBuffer.Width ) - 1 ) / matProj._11; v.y = -( ( ( 2.0f * ptCursor.y ) / m_d3dsdBackBuffer.Height ) - 1 ) / matProj._22; v.z = 1.0f; // Get the inverse view matrix D3DXMATRIXA16 matView; tbDirect3D::GetDevice()->GetTransform( D3DTS_VIEW, &matView ); m=tbMatrixInvert( matView ); // Transform the screen space pick ray into 3D space vPickRayDir.x = v.x*m.m11 + v.y*m.m21 + v.z*m.m31; vPickRayDir.y = v.x*m.m12 + v.y*m.m22 + v.z*m.m32; vPickRayDir.z = v.x*m.m13 + v.y*m.m23 + v.z*m.m33; vPickRayOrig.x = m.m41; vPickRayOrig.y = m.m42; vPickRayOrig.z = m.m43; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
if(tbLineHitsModel(vPickRayOrig,vPickRayDir,BallModel,tbMatrixIdentity(),tbMatrixIdentity() ) ) { g_pSpiel->m_pFont2->Begin(); g_pSpiel->m_pFont2->DrawText(tbVector2(0.5f, 0.05f),"Treffer", TB_FF_ALIGN_HLEFT | TB_FF_ALIGN_VCENTER | TB_FF_RELATIVE | TB_FF_RELATIVESCALING); g_pSpiel->m_pFont2->End(); } |
Anonymous
unregistriert
Administrator
Zitat von »"Bum"«
und jetzt zeigt er mir ungefähr wenn ich in die richtung des Blockes mit der Maus zeige "Treffer" an.
Aber halt nur ungefähr. Wenn ich also 2cm drüber mit der Maus hinfahr zeigt er mir eben auch "Treffer" an, an was kann das liegen???
Werbeanzeige