コード例 #1
0
ファイル: grmain.cpp プロジェクト: fre13131b/TORCAR
void
shutdownCars(void)
{
	int i;

	GfOut("-- shutdownCars\n");
	grShutdownSound(grNbCars);
	if (grNbCars) {
		grShutdownBoardCar();
		grShutdownSkidmarks();
		grShutdownSmoke();
		grShudownCarlight();
		/* Delete ssg objects */
		CarsAnchor->removeAllKids();
		ShadowAnchor->removeAllKids();
		for (i = 0; i < grNbCars; i++) {
			ssgDeRefDelete(grCarInfo[i].envSelector);
			ssgDeRefDelete(grCarInfo[i].shadowBase);
			ssgDeRefDelete(grCarInfo[i].wheelTexture);
			if (grCarInfo[i].driverSelectorinsg == false) {
				delete grCarInfo[i].driverSelector;
			}
		}

		PitsAnchor->removeAllKids();
		ThePits = 0;
		free(grCarInfo);
	}

	GfParmReleaseHandle(grHandle);

	for (i = 0; i < GR_NB_MAX_SCREEN; i++) {
		grScreens[i]->setCurrentCar(NULL);
	}
}
コード例 #2
0
ファイル: grboard.cpp プロジェクト: COHRINT/cuTORCS
void grShutdownBoardCar(void)
{
	int i;
	for (i = 0; i < grNbCars; i++) {
		ssgDeRefDelete(grCarInfo[i].instrument[0].texture);	
		ssgDeRefDelete(grCarInfo[i].instrument[1].texture);
		glDeleteLists(grCarInfo[i].instrument[0].needleList, 1);
		glDeleteLists(grCarInfo[i].instrument[1].needleList, 1);
		glDeleteLists(grCarInfo[i].instrument[0].CounterList, 1);
		glDeleteLists(grCarInfo[i].instrument[1].CounterList, 1);
	}
}
コード例 #3
0
// build the moon object
ssgBranch * cGrMoon::build( double moon_size )
{
	ssgDeRefDelete( moon_transform );
    moon_transform = new ssgTransform;
	moon_transform->ref();

    moon_cl = new ssgColourArray( 1 );
    sgVec4 color;
    sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
    moon_cl->add( color );

    moon_state = new ssgSimpleState();
    moon_state->setTexture( "data/textures/moon.rgba" );
    moon_state->setShadeModel( GL_SMOOTH );
    moon_state->enable( GL_LIGHTING );
    moon_state->enable( GL_CULL_FACE );
    moon_state->enable( GL_TEXTURE_2D );
    moon_state->enable( GL_COLOR_MATERIAL );
    moon_state->setColourMaterial( GL_DIFFUSE );
    moon_state->setMaterial( GL_AMBIENT, 0, 0, 0, 1 );
    moon_state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
    moon_state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
    moon_state->enable( GL_BLEND );
    moon_state->enable( GL_ALPHA_TEST );
    moon_state->setAlphaClamp( 0.01f );

    ssgBranch *moon = grMakeSphere( moon_state, moon_cl, moon_size, 15, 15,
				    grMoonOrbPreDraw, grMoonOrbPostDraw );

    moon_transform->addKid( moon );
	repaint( 0.0 );

    return moon_transform;
}
コード例 #4
0
ファイル: grsmoke.cpp プロジェクト: fre13131b/TORCAR
/** remove the smoke information for a car */
void grShutdownSmoke ()
{
    tgrSmoke *tmp, *tmp2;

    GfOut("-- grShutdownSmoke\n");

    if (!grSmokeMaxNumber) {
		return;
    }

    SmokeAnchor->removeAllKids();
    if (smokeManager) {
		tmp = smokeManager->smokeList;
		while( tmp!=NULL)
			{
				tmp2 = tmp->next;
				/* SmokeAnchor->removeKid(tmp->smoke); */
				free(tmp);
				tmp = tmp2;
			}
		smokeManager->smokeList = NULL;
		free(timeSmoke);
		free(timeFire);
		free(smokeManager);
		smokeManager = 0;
		smokeManager = NULL;
		timeSmoke = NULL;
		timeFire=NULL;
    }

	if (mst != NULL) {
		ssgDeRefDelete(mst);
		mst = NULL;
	}

	if (mstf0 != NULL) {
		ssgDeRefDelete(mstf0);
		mstf0 = NULL;
	}

	if (mstf1 != NULL) {
		ssgDeRefDelete(mstf1);
		mstf1 = NULL;
	}
}
コード例 #5
0
ファイル: grscene.cpp プロジェクト: chagge/gym_torcs
void grShutdownScene(void)
{
	if (TheScene) {
		delete TheScene;
		TheScene = 0;
	}

	if (BackgroundTex) {
		glDeleteTextures(1, &BackgroundTex);
		BackgroundTex = 0;
	}

	if (BackgroundList) {
		glDeleteLists(BackgroundList, 1);
		BackgroundList = 0;
	}

	if (BackgroundType > 2) {
		glDeleteTextures(1, &BackgroundTex2);
		glDeleteLists(BackgroundList2, 1);
	}

	if (grEnvState != NULL) {
		ssgDeRefDelete(grEnvState);
		grEnvState = NULL;
	}
	if (grEnvShadowState != NULL) {
		ssgDeRefDelete(grEnvShadowState);
		grEnvShadowState = NULL;
	}
	if (grEnvShadowStateOnCars != NULL) {
		ssgDeRefDelete(grEnvShadowStateOnCars);
		grEnvShadowStateOnCars = NULL;
	}
	if(grEnvSelector != NULL) {
		delete grEnvSelector;
		grEnvSelector = NULL;
	}

	options.endLoad();
}
コード例 #6
0
ファイル: grStars.cpp プロジェクト: 702nADOS/speed-dreams
ssgBranch * cGrStars::build( int num, sgdVec3 *star_data, double star_dist )
{
  sgVec4 color;

  // clean-up previous
  ssgDeRefDelete( stars_transform );

  // create new
  stars_transform = new ssgTransform;
  stars_transform->ref();

  if ( star_data == NULL )
  {
	  if (num > 0)
		  ulSetError(UL_WARNING, "null star data passed to cGrStars::build()");
	  else
		  return stars_transform;
  }

  // set up the orb state
  state = new ssgSimpleState();
  state->disable( GL_LIGHTING );
  state->disable( GL_CULL_FACE );
  state->disable( GL_TEXTURE_2D );
  state->enable( GL_COLOR_MATERIAL );
  state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
  state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
  state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
  state->enable( GL_BLEND );
  state->disable( GL_ALPHA_TEST );

  vl = new ssgVertexArray( num );
  cl = new ssgColourArray( num );
  // cl = new ssgColourArray( 1 );
  // sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
  // cl->add( color );

  // Build ssg structure
  sgVec3 p;
  for ( int i = 0; i < num; ++i ) 
  {
    // position seeded to arbitrary values
    sgSetVec3( p, 
      (float)( star_dist * cos( star_data[i][0] )
        * cos( star_data[i][1] )),
      (float)( star_dist * sin( star_data[i][0] )
        * cos( star_data[i][1] )),
      (float)( star_dist * sin( star_data[i][1] )));
    vl->add( p );

    // color (magnitude)
    sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
    cl->add( color );
  }

  ssgLeaf *stars_obj = 
    new ssgVtxTable ( GL_POINTS, vl, NULL, NULL, cl );
  stars_obj->setState( state );
  stars_obj->setCallback( SSG_CALLBACK_PREDRAW, grStarPreDraw );
  stars_obj->setCallback( SSG_CALLBACK_POSTDRAW, grStarPostDraw );

  stars_transform->addKid( stars_obj );

  return stars_transform;
}
コード例 #7
0
ファイル: grStars.cpp プロジェクト: 702nADOS/speed-dreams
cGrStars::~cGrStars( void )
{
  ssgDeRefDelete( stars_transform );
}
コード例 #8
0
cGrCelestialBody::~cGrCelestialBody( void )
{
    ssgDeRefDelete( transform );
}
コード例 #9
0
ssgBranch * cGrCelestialBody::build( ssgSimpleState *orb_state, ssgSimpleState *halo_state, double body_size )
{
    ssgVertexArray *halo_vl;
    ssgTexCoordArray *halo_tl;

    // clean-up previous
    ssgDeRefDelete( transform );

    // build the ssg scene graph sub tree for the sky and connected
    // into the provide scene graph branch
    transform = new ssgTransform;
    transform->ref();

    cl = new ssgColourArray( 1 );
    sgVec4 color;
    sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
    cl->add( color );

    ssgBranch *orb = grMakeSphere( orb_state, cl, (float)body_size, 15, 15,
                                   grCelestialBodyOrbPreDraw, grCelestialBodyOrbPostDraw );

    transform->addKid( orb );

    // force a repaint of the colors with arbitrary defaults
    repaint( 0.0 );

    if (halo_state)
    {
        // Build ssg structure
        float size = float(body_size * 10.0);
        sgVec3 v3;
        halo_vl = new ssgVertexArray;
        sgSetVec3( v3, -size, 0.0, -size );
        halo_vl->add( v3 );
        sgSetVec3( v3, size, 0.0, -size );
        halo_vl->add( v3 );
        sgSetVec3( v3, -size, 0.0,  size );
        halo_vl->add( v3 );
        sgSetVec3( v3, size, 0.0,  size );
        halo_vl->add( v3 );

        sgVec2 v2;
        halo_tl = new ssgTexCoordArray;
        sgSetVec2( v2, 0.0f, 0.0f );
        halo_tl->add( v2 );
        sgSetVec2( v2, 1.0, 0.0 );
        halo_tl->add( v2 );
        sgSetVec2( v2, 0.0, 1.0 );
        halo_tl->add( v2 );
        sgSetVec2( v2, 1.0, 1.0 );
        halo_tl->add( v2 );

        ssgLeaf *halo =
            new ssgVtxTable ( GL_TRIANGLE_STRIP, halo_vl, NULL, halo_tl, cl );
        halo->setState( halo_state );

        halo->setCallback( SSG_CALLBACK_PREDRAW, grCelestialBodyHaloPreDraw );
        halo->setCallback( SSG_CALLBACK_POSTDRAW, grCelestialBodyHaloPostDraw );

        transform->addKid( halo );
        //transform->addKid(new ssgaLensFlare);
    }

    return transform;
}
コード例 #10
0
// Destructor
cGrMoon::~cGrMoon( void )
{
	ssgDeRefDelete( moon_transform );
}
コード例 #11
0
ファイル: grSkyDome.cpp プロジェクト: rongzhou/speed-dreams
// initialize the sky object and connect it into our scene graph
ssgBranch * cGrSkyDome::build( double hscale, double vscale )
{
  sgVec4 color;
  double theta;
  int i;

  // clean-up previous
  ssgDeRefDelete( dome_transform );

  // create new
  dome_transform = new ssgTransform;
  dome_transform->ref();

  // set up the state
  dome_state = new ssgSimpleState();
  dome_state->setShadeModel( GL_SMOOTH );
  dome_state->disable( GL_LIGHTING );
  dome_state->disable( GL_CULL_FACE );
  dome_state->disable( GL_TEXTURE_2D );
  dome_state->enable( GL_COLOR_MATERIAL );
  dome_state->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
  dome_state->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
  dome_state->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
  dome_state->disable( GL_BLEND );
  dome_state->disable( GL_ALPHA_TEST );

  // initialize arrays
  center_disk_vl = new ssgVertexArray( 14 );
  center_disk_cl = new ssgColourArray( 14 );

  upper_ring_vl = new ssgVertexArray( 26 );
  upper_ring_cl = new ssgColourArray( 26 );

  middle_ring_vl = new ssgVertexArray( 26 );
  middle_ring_cl = new ssgColourArray( 26 );

  lower_ring_vl = new ssgVertexArray( 26 );
  lower_ring_cl = new ssgColourArray( 26 );

  // initially seed to all blue
  sgSetVec4( color, 0.0, 0.0, 1.0, 1.0 );

  // generate the raw vertex data
  sgVec3 center_vertex;
  sgVec3 upper_vertex[12];
  sgVec3 middle_vertex[12];
  sgVec3 lower_vertex[12];
  sgVec3 bottom_vertex[12];

  sgSetVec3( center_vertex, 0.0, 0.0, (float)(center_elev * vscale));

  for ( i = 0; i < 12; i++ ) 
  {
    theta = (i * 30.0) * SGD_DEGREES_TO_RADIANS;

    sgSetVec3( upper_vertex[i],
      (float)(cos(theta) * upper_radius * hscale),
      (float)(sin(theta) * upper_radius * hscale),
      (float)(upper_elev * vscale));

    sgSetVec3( middle_vertex[i],
      (float)(cos(theta) * middle_radius * hscale),
      (float)(sin(theta) * middle_radius * hscale),
      (float)(middle_elev * vscale));

    sgSetVec3( lower_vertex[i],
      (float)(cos(theta) * lower_radius * hscale),
      (float)(sin(theta) * lower_radius * hscale),
      (float)(lower_elev * vscale));

    sgSetVec3( bottom_vertex[i],
      (float)(cos(theta) * bottom_radius * hscale),
      (float)(sin(theta) * bottom_radius * hscale),
      (float)(bottom_elev * vscale));
  }

  // generate the center disk vertex/color arrays
  center_disk_vl->add( center_vertex );
  center_disk_cl->add( color );
  for ( i = 11; i >= 0; i-- ) 
  {
    center_disk_vl->add( upper_vertex[i] );
    center_disk_cl->add( color );
  }
  center_disk_vl->add( upper_vertex[11] );
  center_disk_cl->add( color );

  // generate the upper ring
  for ( i = 0; i < 12; i++ ) 
  {
    upper_ring_vl->add( middle_vertex[i] );
    upper_ring_cl->add( color );

    upper_ring_vl->add( upper_vertex[i] );
    upper_ring_cl->add( color );
  }
  upper_ring_vl->add( middle_vertex[0] );
  upper_ring_cl->add( color );

  upper_ring_vl->add( upper_vertex[0] );
  upper_ring_cl->add( color );

  // generate middle ring
  for ( i = 0; i < 12; i++ ) 
  {
    middle_ring_vl->add( lower_vertex[i] );
    middle_ring_cl->add( color );

    middle_ring_vl->add( middle_vertex[i] );
    middle_ring_cl->add( color );
  }
  middle_ring_vl->add( lower_vertex[0] );
  middle_ring_cl->add( color );

  middle_ring_vl->add( middle_vertex[0] );
  middle_ring_cl->add( color );

  // generate lower ring
  for ( i = 0; i < 12; i++ ) 
  {
    lower_ring_vl->add( bottom_vertex[i] );
    lower_ring_cl->add( color );

    lower_ring_vl->add( lower_vertex[i] );
    lower_ring_cl->add( color );
  }
  lower_ring_vl->add( bottom_vertex[0] );
  lower_ring_cl->add( color );

  lower_ring_vl->add( lower_vertex[0] );
  lower_ring_cl->add( color );

  // force a repaint of the sky colors with ugly defaults
  sgVec3 fog_color;
  sgSetVec3( fog_color, 1.0, 1.0, 1.0 );
  repaint( color, fog_color, 0.0, 5000.0 );

  // build the ssg scene graph sub tree for the sky and connected
  // into the provide scene graph branch
  ssgVtxTable *center_disk, *upper_ring, *middle_ring, *lower_ring;

  center_disk = new ssgVtxTable( GL_TRIANGLE_FAN, 
  center_disk_vl, NULL, NULL, center_disk_cl );

  upper_ring = new ssgVtxTable( GL_TRIANGLE_STRIP, 
  upper_ring_vl, NULL, NULL, upper_ring_cl );

  middle_ring = new ssgVtxTable( GL_TRIANGLE_STRIP, 
  middle_ring_vl, NULL, NULL, middle_ring_cl );

  lower_ring = new ssgVtxTable( GL_TRIANGLE_STRIP, 
  lower_ring_vl, NULL, NULL, lower_ring_cl );

  center_disk->setState( dome_state );
  upper_ring->setState( dome_state );
  middle_ring->setState( dome_state );
  lower_ring->setState( dome_state );

  dome_transform->addKid( center_disk );
  dome_transform->addKid( upper_ring );
  dome_transform->addKid( middle_ring );
  dome_transform->addKid( lower_ring );

  // not entirely satisfying.  We are depending here that the first
  // thing we add to a parent is the first drawn
  center_disk->setCallback( SSG_CALLBACK_PREDRAW, grSkyDomePreDraw );
  center_disk->setCallback( SSG_CALLBACK_POSTDRAW, grSkyDomePostDraw );

  upper_ring->setCallback( SSG_CALLBACK_PREDRAW, grSkyDomePreDraw );
  upper_ring->setCallback( SSG_CALLBACK_POSTDRAW, grSkyDomePostDraw );

  middle_ring->setCallback( SSG_CALLBACK_PREDRAW, grSkyDomePreDraw );
  middle_ring->setCallback( SSG_CALLBACK_POSTDRAW, grSkyDomePostDraw );

  lower_ring->setCallback( SSG_CALLBACK_PREDRAW, grSkyDomePreDraw );
  lower_ring->setCallback( SSG_CALLBACK_POSTDRAW, grSkyDomePostDraw );

  return dome_transform;
}
コード例 #12
0
ファイル: grSkyDome.cpp プロジェクト: rongzhou/speed-dreams
cGrSkyDome::~cGrSkyDome( void )
{
  ssgDeRefDelete( dome_transform );
}