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(); }
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(); }