Exemplo n.º 1
0
void App::onGraphics3D(RenderDevice* rd, Array<shared_ptr<Surface> >& surface3D) {
  rd->clear();
  rd->setShadeMode(RenderDevice::SHADE_SMOOTH);


  // Set a rotation matrix to apply when drawing the earth and earthquakes
  rd->pushState();
  rd->setObjectToWorldMatrix(CoordinateFrame(rotation, Vector3(0,0,0)));

  earth->draw(rd);

  // Draw earthquakes
  int start = eqd.getIndexByDate(Date(currentTime - PLAYBACK_WINDOW));
  int end = eqd.getIndexByDate(Date(currentTime)); 
 
  double magnitudePower;                

  for (int x=start; x<end; x++) {
    Earthquake e = eqd.getByIndex(x);
    magnitudePower = pow(2.0, e.getMagnitude()) / 10000;
    Draw::sphere(Sphere(earth->getPosition((e.getLatitude() * -1) + 90, e.getLongitude() + 180), magnitudePower), 
                  rd, makeColor((currentTime - e.getDate().asSeconds()) / PLAYBACK_WINDOW), Color4::clear()); 
    
  }

  rd->popState();

  // Call to make the GApp show the output of debugDraw
  drawDebugShapes();
}
Exemplo n.º 2
0
float Level::getEarthquakeMagnitudeAtPosition( const Vector &origin )
{
	int i;
	float totalMagnitude;
	Earthquake *earthquake;

	totalMagnitude = 0.0f;

	// Add up all of the earthquakes magnitudes to get the total

	for( i = 1 ; i <= _earthquakes.NumObjects() ; i++ )
	{
		// This should be a safe cast since only Earthquakes are allowed to be added to this list

		earthquake = _earthquakes.ObjectAt( i );

		if ( earthquake )
		{
			// Add this earthquake to the total

			totalMagnitude += earthquake->getMagnitudeAtPosition( origin );
		}
	}
	
	// Return the total magnitude of all the earthquakes

	return totalMagnitude;
}
Exemplo n.º 3
0
void App::onGraphics3D(RenderDevice* rd, Array<shared_ptr<Surface> >& surface3D) {
  rd->clear();
  rd->setShadeMode(RenderDevice::SHADE_SMOOTH);


  // Set a rotation matrix to apply when drawing the earth and earthquakes
  rd->pushState();
  rd->setObjectToWorldMatrix(CoordinateFrame(rotate));
  earth->draw(rd);

  // Draw earthquakes
  int start = eqd.getIndexByDate(Date(currentTime - PLAYBACK_WINDOW));
  int end = eqd.getIndexByDate(Date(currentTime));
  for (int x=start; x<end; x++) {
    Earthquake e = eqd.getByIndex(x);
	double radius = ((e.getMagnitude() / 10.0 - .5) / (1.0 - .5) / 6);
	Color3 color = 	color = Color3((e.getMagnitude() / 10.0 - .6) / (.8 - .6), 1 - (e.getMagnitude() / 10.0 - .6) / (.8 - .6), 0);
	if (e.getMagnitude() < 6.0 && e.getMagnitude() > 5.0) {
		color = Color3(0, 1, 0);
	}
	else if (e.getMagnitude() < 10.0 && e.getMagnitude() > 8.0) {
		color = Color3(1, 0, 0);
	}
	Sphere ball(earth->getPosition(e.getLatitude(), e.getLongitude()), radius);
	Draw::sphere(ball, rd, color, Color4::clear());
  }

  rd->popState();

  // Call to make the GApp show the output of debugDraw
  drawDebugShapes();
}
void ClientServerCommandManager::EventEarthquake( Event *ev )
{
	float duration = ev->GetFloat( 1 );
	float magnitude = ev->GetFloat( 2 );
	qboolean no_rampup = ev->GetBoolean( 3 );
	qboolean no_rampdown = ev->GetBoolean( 4 );
	Vector org;
	float radius;

	if( ev->NumArgs() > 4 )
	{
		org = ev->GetVector( 5 );

		if( ev->NumArgs() > 5 ) {
			radius = ev->GetFloat( 6 );
		}
	}

	Earthquake * earthquake = new Earthquake;

	earthquake->SetDuration( duration );
	earthquake->SetMagnitude( magnitude );
	earthquake->SetNoRampup( no_rampup );
	earthquake->SetNoRampdown( no_rampdown );

	if( ev->NumArgs() > 4 )
	{
		earthquake->SetLocation( org );

		if( ev->NumArgs() > 5 ) {
			earthquake->SetRadius( radius );
		}
	}

	earthquake->Enable();
}