Exemple #1
0
World::Impl::Impl( World * container, sf::RenderTarget & target, FontManager & fonts, SoundPlayer & sounds, bool isNetworked ) :
	pContainer( container ),
	mTarget( target ),
	mWorldView( target.getDefaultView() ),
	mTextures(),
	mFonts( fonts ),
	mSounds( sounds ),
	mSceneGraph(),
	mSceneLayers(),
	mWorldBounds( 0.f, 0.f, mWorldView.getSize().x, 5000.f ),
	mSpawnPosition( mWorldView.getSize().x / 2.f, mWorldBounds.height - mWorldView.getSize().y / 2.f ),
	mScrollSpeed( -50.f ),
	mScrollSpeedCompensation( 1.f ),
	mPlayerAircrafts(),
	mEnemySpawnPoints(),
	mActiveEnemies(),
	mNetworkedWorld( isNetworked ),
	mNetworkNode( nullptr ),
	mPhysics( b2Vec2( 0.f, 9.8f ) )
{
	mSceneTexture.create( mTarget.getSize().x, mTarget.getSize().y );

	LoadTextures();
	BuildScene();
	mWorldView.setCenter( mSpawnPosition );
}
bool CDirect3D11::StartUp()
{
	if( CreateDeviceAndSwapChain() )
	{
		//Do nothing
	}
	else
	{
		return false;
	}
	if( CreateRenderTargetView() )
	{
		//Do nothing
	}
	else
	{
		return false;
	}
	if ( CreateDepthStencilBufferAndView(true) )
	{
		m_pd3dDeviceContext->OMSetRenderTargets(1, &m_pd3dRenderTargetView, m_pd3dDepthStencilView);
	}
	else
	{
		return false;
	}
	if ( BuildScene() )
	{
		return true;
	}
	{
		OnDestroy();
		return false;
	}
}
void SpaceInvadersSceneBuilder::ResetScene() {
    GameRegistry<Item>::Instance()->UnregisterAll();
    GameRegistry<Rectangle>::Instance()->UnregisterAll();
    GameRegistry<SpaceInvader>::Instance()->UnregisterAll();
    GameRegistry<SpaceInvaderShot>::Instance()->UnregisterAll();
    GameRegistry<SpaceShip>::Instance()->UnregisterAll();
    GameRegistry<SpaceShipShot>::Instance()->UnregisterAll();
    GameRegistry<SpaceShipSpecialShot>::Instance()->UnregisterAll();
    GameRegistry<IBackground>::Instance()->UnregisterAll();
    BuildScene();
}
bool D3D::Setup()
{
	m_pScene = BuildScene(Device);
	//m_pScene->Update();

	// Set up the textures
	Device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
	Device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	Device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
	Device->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE );
	Device->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	Device->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
	Device->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
	Device->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );

	// Set miscellaneous render states
	Device->SetRenderState( D3DRS_DITHERENABLE,   FALSE );
	Device->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
	Device->SetRenderState( D3DRS_ZENABLE,        TRUE );
	Device->SetRenderState( D3DRS_AMBIENT,        0x000F0F0F );

	// Set up our view matrix. A view matrix can be defined given an eye point,
	// a point to lookat, and a direction for which way is up. Here, we set the
	// eye five units back along the z-axis and up three units, look at the
	// origin, and define "up" to be in the y-direction.

	// Set the projection matrix
	D3DXMATRIX matProj;
	FLOAT fAspect = (FLOAT)Width / (FLOAT)Height;
	D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 10000.0f );
	Device->SetTransform( D3DTS_PROJECTION, &matProj );

	// Set up lighting stat`es
	D3DXVECTOR3 dir(1.0f, -0.0f, 0.25f);
	D3DXCOLOR   c = d3d::WHITE;
	D3DLIGHT9 light = d3d::InitDirectionalLight(&dir, &c);

	Device->SetLight( 0, &light );
	Device->LightEnable( 0, TRUE );
	Device->SetRenderState( D3DRS_LIGHTING, TRUE );

	return true;
}
Exemple #5
0
HRESULT InitGeometry()
{
	BuildScene();

	g_dist_tolerance = 1.0f;
	g_line_widh = 0.1f;
	g_joint_style = VG::LJOINT_MITER;
	g_stroke_style = VG::SS_LINE_GRAD_WIDTH;

	D3DXFONT_DESC lf;
	ZeroMemory(&lf, sizeof(D3DXFONT_DESCA));
	lf.Height = 18;
	lf.Width = 6;
	lf.Weight = 500;
	lf.CharSet = DEFAULT_CHARSET;
	wcscpy(lf.FaceName, L"Courier New");
	D3DXCreateFontIndirect(pD3DDevice, &lf, &g_font);

	return S_OK;
}
Exemple #6
0
   void VisualSceneOCCGeometry :: DrawScene ()
   {
      if ( occgeometry->changed )
      {
         BuildScene();
         occgeometry -> changed = 0;
      }

      glClearColor(backcolor, backcolor, backcolor, 1.0);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      SetLight();

      glPushMatrix();
      glMultMatrixf (transformationmat);

      glShadeModel (GL_SMOOTH);
      glDisable (GL_COLOR_MATERIAL);
      glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);

      glEnable (GL_BLEND);
      glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      
      //  glEnable (GL_LIGHTING);

      double shine = vispar.shininess;
      // double transp = vispar.transp;

      glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine);
      glLogicOp (GL_COPY);

      glEnable (GL_NORMALIZE);

      float mat_col[] = {  0.2f, 0.2f, 0.8f, 1.0f};
      glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);

      glPolygonOffset (1, 1);
      glEnable (GL_POLYGON_OFFSET_FILL);

      // Philippose - 30/01/2009
      // Added clipping planes to Geometry view
      SetClippingPlane();

      GLfloat matcoledge[] = {  0, 0, 1, 1};
      GLfloat matcolhiedge[] = {  1, 0, 0, 1};

      glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcoledge);
      glLineWidth (1.0f);

      if (vispar.occshowedges) glCallList (linelists.Get(1));
      if (vispar.occshowsurfaces) glCallList (trilists.Get(1));

      glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge);
      glLineWidth (5.0f);

      if (vispar.occshowedges) glCallList (linelists.Get(2));

      for (int i = 1; i <= occgeometry->vmap.Extent(); i++)
      if (occgeometry->vvispar[i-1].IsHighlighted())
      {
         glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge);
         glLineWidth (5.0f);

         glBegin (GL_LINES);

         gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(occgeometry->vmap(i)));
         double d = rad/100;
         glVertex3f (p.X()-d, p.Y(), p.Z());
         glVertex3f (p.X()+d, p.Y(), p.Z());
         glVertex3f (p.X(), p.Y()-d, p.Z());
         glVertex3f (p.X(), p.Y()+d, p.Z());
         glVertex3f (p.X(), p.Y(), p.Z()-d);
         glVertex3f (p.X(), p.Y(), p.Z()+d);
         glEnd();
      }

      glDisable (GL_POLYGON_OFFSET_FILL);

      glPopMatrix();
      //  DrawCoordinateCross ();
      //  DrawNetgenLogo ();
      glFinish();

      glDisable (GL_POLYGON_OFFSET_FILL);
   }
Exemple #7
0
  void VisualSceneGeometry :: DrawScene ()
  {  
    if (changeval != geometry->GetChangeVal())
      BuildScene();
    changeval = geometry->GetChangeVal();

    glClearColor(backcolor, backcolor, backcolor, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
    SetLight();


    glPushMatrix();
    glMultMatrixd (transformationmat);

    SetClippingPlane ();

    glShadeModel (GL_SMOOTH);
    glDisable (GL_COLOR_MATERIAL);
    glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);

    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    /*
      float mat_spec_col[] = { 1, 1, 1, 1 };
      glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, mat_spec_col);
    */

    double shine = vispar.shininess;
    double transp = vispar.transp;
    glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine);
    glLogicOp (GL_COPY);
  
    glEnable (GL_NORMALIZE);

    for (int i = 0; i < geometry->GetNTopLevelObjects(); i++)
      {
	const TopLevelObject * tlo = geometry -> GetTopLevelObject (i);
	if (tlo->GetVisible() && !tlo->GetTransparent())
	  {
	    float mat_col[] = { float(tlo->GetRed()), float(tlo->GetGreen()), 
				float(tlo->GetBlue()), 1 };
	    glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
	  
	    glCallList (trilists[i]);
	  }
      }

    glPolygonOffset (1, 1);
    glEnable (GL_POLYGON_OFFSET_FILL);

    glLogicOp (GL_NOOP);
    for (int i = 0; i < geometry->GetNTopLevelObjects(); i++)
      {
	const TopLevelObject * tlo = geometry -> GetTopLevelObject (i);
	if (tlo->GetVisible() && tlo->GetTransparent())
	  {
	    float mat_col[] = { float(tlo->GetRed()), float(tlo->GetGreen()), 
				float(tlo->GetBlue()), float(transp) };

	    glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
	  
	    glCallList (trilists[i]);
	  }
      }

    glDisable (GL_POLYGON_OFFSET_FILL);

    glPopMatrix();
    glDisable(GL_CLIP_PLANE0);
 


    DrawCoordinateCross ();
    DrawNetgenLogo ();  

    glFinish();  
  }
Exemple #8
0
  void VisualSceneSpecPoints :: DrawScene ()
  {
    if (!mesh) 
      {
	VisualScene::DrawScene();
	return;
      }

    if (changeval != specpoints.Size())
      BuildScene();
    changeval = specpoints.Size();



    glClearColor(backcolor, backcolor, backcolor, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glEnable (GL_COLOR_MATERIAL);
    glColor3f (1.0f, 1.0f, 1.0f);
    glLineWidth (1.0f);

    glPushMatrix();
    glMultMatrixd (transformationmat);

    //  glEnable (GL_COLOR);
    //  glDisable (GL_COLOR_MATERIAL);
    if (vispar.drawedtangents)
      {
	glColor3d (1, 0, 0);
	glBegin (GL_LINES);
	for (int i = 1; i <= specpoints.Size(); i++)
	  {
	    const Point3d p1 = specpoints.Get(i).p;
	    const Point3d p2 = specpoints.Get(i).p + len * specpoints.Get(i).v;
	    glVertex3d (p1.X(), p1.Y(), p1.Z());
	    glVertex3d (p2.X(), p2.Y(), p2.Z());
	  }
	glEnd();
      }

    if (vispar.drawededges)
      {
	glColor3d (1, 0, 0);
	glBegin (GL_LINES);
	for (int i = 1; i <= mesh->GetNSeg(); i++)
	  {
	    const Segment & seg = mesh -> LineSegment (i);
	    glVertex3dv ( (*mesh)[seg[0]] );
            glVertex3dv ( (*mesh)[seg[1]] );
	    // glVertex3dv ( &(*mesh)[seg[0]].X() );
	    // glVertex3dv ( &(*mesh)[seg[1]].X() );
	  }
	glEnd();
      }

    glColor3d (1, 0, 0);
    glBegin (GL_LINES);
    int edges[12][2] = 
      { { 0, 1 },
	{ 2, 3 },
	{ 4, 5 },
	{ 6, 7 },
	{ 0, 2 },
	{ 1, 3 },
	{ 4, 6 },
	{ 5, 7 },
	{ 0, 4 },
	{ 1, 5 },
	{ 2, 6 },
	{ 3, 7 } };
    for (int i = 0; i < boxes.Size(); i++)
      {
	for (int j = 0; j < 12; j++)
	  {
	    glVertex3dv ( boxes[i].GetPointNr(edges[j][0]) );
	    glVertex3dv ( boxes[i].GetPointNr(edges[j][1]) );
	  }
	/*
	glVertex3dv ( boxes[i].PMin() );
	glVertex3dv ( boxes[i].PMax() );
	*/
      }
    glEnd();



    if (vispar.drawededgenrs)
      {
	glEnable (GL_COLOR_MATERIAL);
	GLfloat textcol[3] = { GLfloat(1 - backcolor),
			       GLfloat(1 - backcolor), 
			       GLfloat(1 - backcolor) };
	glColor3fv (textcol);
	glNormal3d (0, 0, 1);
	glPushAttrib (GL_LIST_BIT);
	// glListBase (fontbase);

	char buf[20];
	for (int i = 1; i <= mesh->GetNSeg(); i++)
	  {
	    const Segment & seg = mesh -> LineSegment (i);
	    const Point3d p1 = mesh -> Point (seg[0]);
	    const Point3d p2 = mesh -> Point (seg[1]);

	    const Point3d p = Center (p1, p2);
	    glRasterPos3d (p.X(), p.Y(), p.Z());
	  
	    sprintf (buf, "%d", seg.edgenr);
	    // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
	    MyOpenGLText (buf);
	  }
      
	glPopAttrib ();
	glDisable (GL_COLOR_MATERIAL);
      }


    if (vispar.drawedpoints)
      {

	glColor3d (0, 0, 1);
	/*
	  glPointSize( 3.0 );

	float range[2];
	glGetFloatv(GL_POINT_SIZE_RANGE, &range[0]);
	cout << "max ptsize = " << range[0] << "-" << range[1] << endl;
      

	glBegin( GL_POINTS );
	for (int i = 1; i <= mesh -> GetNP(); i++)
	  {
	    const Point3d & p = mesh -> Point(i);
	    if (i % 2)
	      glVertex3f( p.X(), p.Y(), p.Z());
	  }
	glEnd();
	*/

	static GLubyte knoedel[] = 
	  {
	    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
	  };
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

	glDisable (GL_COLOR_MATERIAL);
	glDisable (GL_LIGHTING);
	glDisable (GL_CLIP_PLANE0);
      
	for (int i = 1; i <= mesh -> GetNP(); i++)
	  {
	    const Point3d & p = mesh -> Point(i);
	    glRasterPos3d (p.X(), p.Y(), p.Z());
	    glBitmap (7, 7, 3, 3, 0, 0, &knoedel[0]);
	  }
      }

    if (vispar.drawedpointnrs)
      {
	glEnable (GL_COLOR_MATERIAL);
	GLfloat textcol[3] = { GLfloat(1 - backcolor),
			       GLfloat(1 - backcolor),
			       GLfloat(1 - backcolor) };
	glColor3fv (textcol);
	glNormal3d (0, 0, 1);
	glPushAttrib (GL_LIST_BIT);
	// glListBase (fontbase);
      
	char buf[20];
	for (int i = 1; i <= mesh->GetNP(); i++)
	  {
	    const Point3d & p = mesh->Point(i);
	    glRasterPos3d (p.X(), p.Y(), p.Z());
	  
	    sprintf (buf, "%d", i);
	    // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
	    MyOpenGLText (buf);
	  }
      
	glPopAttrib ();
	glDisable (GL_COLOR_MATERIAL);
      }


    
    
    

    glPopMatrix();

    if (vispar.drawcoordinatecross)
      DrawCoordinateCross ();
    DrawNetgenLogo ();

    glFinish();  
  }