Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. void ScatterSky::_initVBIB()
  2. {
  3. SphereMesh sphere(SphereMesh::Icosahedron);
  4.  
  5. SphereMesh::TriangleMesh *sphereMesh = sphere.getMesh( 10 );
  6.  
  7. // Vertex Buffer...
  8.  
  9. mPrimCount = sphereMesh->numPoly;
  10. mVertCount = mPrimCount * 3;
  11.  
  12. mVB.set( GFX, mVertCount, GFXBufferTypeStatic );
  13. ScatterSkyVertex *pVert = mVB.lock();
  14. if(!pVert) return;
  15.  
  16.  
  17. for (S32 i=0; i<numPoly; i++)
  18. {
  19. for ( S32 j=0; j < 3; ++j )
  20. {
  21. pVert->point = sphereMesh->poly[i].pnt[j];
  22. pVert->point.normalize();
  23. pVert->point *= 200000.0f;
  24. pVert++
  25. }
  26. }
  27.  
  28.  
  29. mVB.unlock();
  30.  
  31. // Primitive Buffer...
  32. mPrimBuffer.set( GFX, mPrimCount * 3, mPrimCount, GFXBufferTypeStatic );
  33.  
  34. U16 *pIdx = NULL;
  35. mPrimBuffer.lock(&pIdx);
  36. U32 curIdx = 0;
  37.  
  38. for (S32 i=0; i<numPoly; i++)
  39. {
  40. U32 offset = i*3;
  41.  
  42. pIdx[curIdx] = offset;
  43. curIdx++;
  44. pIdx[curIdx] = offset + 1;
  45. curIdx++;
  46. pIdx[curIdx] = offset + 2;
  47. curIdx++;
  48. }
  49.  
  50. mPrimBuffer.unlock();
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement