Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2013
4,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. void TMinimalObject::RenderShadowsFOV()
  2. {
  3.     if (fovshadows)
  4.     {
  5.         b2Vec2 pos=game->GetPlayerPosition();
  6.         pos*=C_SCALE;
  7.         b2PolygonShape* sh;
  8.         for (b2Fixture* f=rbody->GetFixtureList(); f; f=f->GetNext())
  9.         {
  10.             sh=(b2PolygonShape*)f->GetShape();
  11.  
  12.             int nrverts=sh->GetVertexCount();
  13.             b2Vec2 worldvert;
  14.             b2Vec2 offset1;
  15.             b2Vec2 offset2;
  16.             SetTexture(0);
  17.             SetBlend(BM_SOLID);
  18.             SetColor(0,0,0,1);
  19.             glBegin(GL_TRIANGLE_STRIP);
  20.             for (int i=0; i<nrverts+1; i++)
  21.             {
  22.                 int i2=i%nrverts;
  23.                 worldvert=rbody->GetWorldPoint(sh->GetVertex(i2));
  24.                 worldvert*=C_SCALE;
  25.                 offset1=worldvert;
  26.                 offset1-=pos;
  27.                 offset1.Normalize();
  28.                 offset2=offset1;
  29.                 offset2*=4;
  30.                 offset1*=1000000;
  31.                 glVertex2f(worldvert.x+offset1.x,worldvert.y+offset1.y);
  32.                 glVertex2f(worldvert.x+offset2.x,worldvert.y+offset2.y);
  33.             }
  34.             glEnd();
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement