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 |
// Sphere check fSqRadius = tbVector3LengthSq(vMiddle); for(WORD h = 0; h < 6; h++) { fDistance = tbPlaneDotCoords( m_pFrustum->Planes[h], Node->vMiddle); if(fDistance * fDistance < -fSqRadius) { // Sphere is out Node->isVisible = false; return; } iVertxIn += 1; } |
Quellcode |
|
1 |
fDistance * fDistance < -fSqRadius |
Quellcode |
|
1 2 3 4 5 6 7 8 |
// Wenn es kein Blatt war, weitersplitten if(!(Node->isLeaf)) { for(WORD k = 0; k < 8; ++k) { NodeIsVisible(Node->pChildren[k]); } } |
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 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 |
void CMap::NodeIsVisible(SQuadNode *Node) { if(Node != NULL) { float fDistance; WORD iVertxOut = 0; WORD iSphereIn = 0; tbVector3 vCheckPoints[8]; tbVector3 temp; tbVector3 vCenter; float fSqRadius; // BoundingSphere Test vCenter = Node->m_vertizes[0].vPosition; temp = Node->m_vertizes[1].vPosition - Node->m_vertizes[0].vPosition; fSqRadius = temp.x * temp.x + temp.z * temp.z; for(int g = 0; g < 6; g++) { fDistance = tbPlaneDotCoords(m_pFrustumPlanes[g], vCenter); if(fDistance * fDistance > fSqRadius) { if(fDistance < 0.0f) { Node->m_isVisible = false; return; } // else iSphereIn += 1; } } // Prüft ob Sphere komplett im Frustum ist if(iSphereIn == 6) { Node->m_isVisible = true; // Wenn es kein Blatt war, weitersplitten if(!(Node->m_isLeaf)) { NodeIsVisible(Node->m_pChildren[0]); NodeIsVisible(Node->m_pChildren[1]); NodeIsVisible(Node->m_pChildren[2]); NodeIsVisible(Node->m_pChildren[3]); } return; } // BoundingBox Test WORD h = 1; do { vCheckPoints[h-1].x = Node->m_vertizes[h].vPosition.x; vCheckPoints[h-1].y = Node->m_vMax.y; vCheckPoints[h-1].z = Node->m_vertizes[h].vPosition.z; vCheckPoints[h].x = Node->m_vertizes[h].vPosition.x; vCheckPoints[h].y = Node->m_vMin.y; vCheckPoints[h].z = Node->m_vertizes[h].vPosition.z; h += 2; }while(h < 8); // calculate our distances to each of the planes for(WORD i = 0; i < 6; ++i) { for(WORD j = 0; j < 8; ++j) { // find the distance to this plane fDistance = tbPlaneDotCoords(m_pFrustumPlanes[i], vCheckPoints[j]); if(fDistance < 0) iVertxOut += 1; } // Wenn Knoten nicht sichtbar, return if(iVertxOut == 8) { Node->m_isVisible = false; return; } iVertxOut = 0; } // Node is Visible Node->m_isVisible = true; // Wenn es kein Blatt war, weitersplitten if(!(Node->m_isLeaf)) { NodeIsVisible(Node->m_pChildren[0]); NodeIsVisible(Node->m_pChildren[1]); NodeIsVisible(Node->m_pChildren[2]); NodeIsVisible(Node->m_pChildren[3]); } } } |
Werbeanzeige