/* BEGIN TEMPLATE */ void dragon(int order, double x, double y, double z, double t) { /* BEGIN SOLUTION */ double u, v; if (order == 1) { setPos(x, y); moveTo(z, t); } else { u = (x + z + t - y) / 2; v = (y + t - z + x) / 2; dragon(order - 1, x, y, u, v); dragon(order - 1, z, t, u, v); } /* END SOLUTION */ }
void dragonComp(turtle_t &turt, int x, double side){ if (x == 1) turt.forward(side); else{ dragon(turt, x-1, side); turt.turn_right(90); dragonComp(turt, x-1, side); } }
void DragonScene::init(){ if(_loaded){ return; } _loaded = true; //Position fixed objects. const glm::mat4 dragonModel = glm::scale(glm::translate(glm::mat4(1.0f), glm::vec3(-0.1,-0.05,-0.25)),glm::vec3(0.5f)); const glm::mat4 planeModel = glm::scale(glm::translate(glm::mat4(1.0f),glm::vec3(0.0f,-0.35f,-0.5f)), glm::vec3(2.0f)); const glm::mat4 suzanneModel = glm::scale(glm::translate(glm::mat4(1.0f), glm::vec3(0.2,0.0,0.0)),glm::vec3(0.25f)); // Objects creation. Object suzanne(Object::Type::Regular, "suzanne", { {"suzanne_texture_color", true }, {"suzanne_texture_normal", false}, {"suzanne_texture_rough_met_ao", false} }); Object dragon(Object::Type::Regular, "dragon", { { "dragon_texture_color", true }, { "dragon_texture_normal", false }, { "dragon_texture_rough_met_ao", false } }); Object plane(Object::Type::Parallax, "groundplane", { { "groundplane_texture_color", true }, { "groundplane_texture_normal", false }, { "groundplane_texture_rough_met_ao", false }, { "groundplane_texture_depth", false } }, {}, false); suzanne.update(suzanneModel); dragon.update(dragonModel); plane.update(planeModel); objects.push_back(suzanne); objects.push_back(dragon); objects.push_back(plane); // Background creation. backgroundReflection = Resources::manager().getCubemap("corsica_beach_cube", {GL_RGB32F, GL_LINEAR, GL_CLAMP_TO_EDGE})->id; // \todo Find a way to avoid passing the gamma flag to the object. background = Object(Object::Type::Skybox, "skybox", {}, {{"corsica_beach_cube", false }}); loadSphericalHarmonics("corsica_beach_cube_shcoeffs"); // Compute the bounding box of the shadow casters. const BoundingBox bbox = computeBoundingBox(true); // Lights creation. // Create directional light. directionalLights.emplace_back(glm::vec3(-2.0f,-1.5f,0.0f), glm::vec3(1.0f,1.0f, 0.92f), bbox); directionalLights[0].castShadow(true); // Create spotlight. spotLights.emplace_back(glm::vec3(2.0f,2.0f,2.0), glm::vec3(-1.0f,-1.0f,-1.0f), glm::vec3(0.0f,10.0f,10.0f), 0.5f, 0.6f, 5.0f, bbox); spotLights[0].castShadow(true); // Create point lights. const float lI = 4.0; // Light intensity. const std::vector<glm::vec3> colors = { glm::vec3(lI,0.0,0.0), glm::vec3(0.0,lI,0.0), glm::vec3(0.0,0.0,lI), glm::vec3(lI,lI,0.0)}; for(size_t i = 0; i < 4; ++i){ const glm::vec3 position = glm::vec3(-1.0f+2.0f*(i%2),-0.1f,-1.0f+2.0f*(i/2)); pointLights.emplace_back(position, colors[i], 1.2f, bbox); } }
void render_drawing(turtle_t &turt) { //~ koch(turt, 1.0); // testPattern(turt); turt.reset(); turt.clear(); turt.set_bgcol(0.22, 0.69, 0.87); turt.backward_move(0.3); turt.turn_right(90); turt.forward_move(0.2); turt.set_col(0.498039, 1.0, 0.0); int num = 20; dragon(turt, num, 0.03/num); }
int main(int argc, char** argv) { Win110ct win; Turtle * t = win.getTurtle(); t->penDown(); t->setPosition(512,200); t->setColour({128,128,255}); for(int i=0; i<24; ++i) { t->setPosition(512,200); dragon(t, i, 400); win.render(); SDL_Delay(2000); win.clearBack(); } win.getchar(); return 0; }
bool spec_breath_lightning( CHAR_DATA *ch ) { return dragon( ch, "lightning breath" ); }
bool spec_breath_frost( CHAR_DATA *ch ) { return dragon( ch, "frost breath" ); }
bool spec_breath_fire( CHAR_DATA *ch ) { return dragon( ch, "fire breath" ); }
bool spec_breath_acid( CHAR_DATA *ch ) { return dragon( ch, "acid breath" ); }
void NowListening::slotPrepareNowListening() { QVariantMap trackInfo; QString player; bool playerFound = false; bool isPlaying = false; MPRIS amarok(QLatin1String("amarok")); if (amarok.isValid()) { if (amarok.isPlaying()) { trackInfo = amarok.getTrackMetadata(); isPlaying = true; } playerFound = true; player = QLatin1String("Amarok"); } MPRIS audacious(QLatin1String("audacious")); if (!isPlaying && audacious.isValid()) { if (audacious.isPlaying()) { trackInfo = audacious.getTrackMetadata(); isPlaying = true; } playerFound = true; player = QLatin1String("Audacious"); } // MPRIS id of Dragon Player contain pid of it. QStringList playersList = MPRIS::getRunningPlayers(); if (!playersList.isEmpty() && playersList.indexOf(QRegExp(QLatin1String("dragonplayer(.*)"))) > -1) { int i = playersList.indexOf(QRegExp(QLatin1String("dragonplayer(.*)"))); MPRIS dragon(playersList.at(i)); if (!isPlaying && dragon.isValid()) { if (dragon.isPlaying()) { trackInfo = dragon.getTrackMetadata(); isPlaying = true; } playerFound = true; player = QLatin1String("Dragon Player"); } } //need to enable MPRIS Plugin (Qmmp +0.4) MPRIS qmmp(QLatin1String("qmmp")); if (!isPlaying && qmmp.isValid()) { if (qmmp.isPlaying()) { trackInfo = qmmp.getTrackMetadata(); isPlaying = true; } playerFound = true; player = QLatin1String("Qmmp"); } // only works if enabled D-BUS control interface in VLC (VLC 0.9.0+) MPRIS vlc(QLatin1String("vlc")); if (!isPlaying && vlc.isValid()) { if (vlc.isPlaying()) { trackInfo = vlc.getTrackMetadata(); isPlaying = true; } playerFound = true; player = QLatin1String("VLC"); } //Mpris not complete supported by Kaffeine Version 1.0-svn3 /* MPRIS kaffeine("kaffeine"); if(!isPlaying && kaffeine.isValid()){ if(kaffeine.isPlaying()){ trackInfo=kaffeine.getTrackMetadata(); isPlaying=true; } playerFound=true; player="Kaffeine"; } */ if (!isPlaying && QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.kde.juk")).value()) { QDBusInterface jukPlayer(QLatin1String("org.kde.juk"), QLatin1String("/Player"), QLatin1String("org.kde.juk.player")); if (((QDBusReply<bool>)jukPlayer.call(QLatin1String("playing"))).value()) { QDBusReply< QString> reply = jukPlayer.call(QLatin1String("trackProperty"), QLatin1String("Title")); trackInfo.insert(QLatin1String("title"), reply.value()); reply = jukPlayer.call(QLatin1String("trackProperty"), QLatin1String("Track")); trackInfo.insert(QLatin1String("track"), reply.value()); reply = jukPlayer.call(QLatin1String("trackProperty"), QLatin1String("Album")); trackInfo.insert(QLatin1String("album"), reply.value()); reply = jukPlayer.call(QLatin1String("trackProperty"), QLatin1String("Artist")); trackInfo.insert(QLatin1String("artist"), reply.value()); reply = jukPlayer.call(QLatin1String("trackProperty"), QLatin1String("Year")); trackInfo.insert(QLatin1String("year"), reply.value()); reply = jukPlayer.call(QLatin1String("trackProperty"), QLatin1String("Genre")); trackInfo.insert(QLatin1String("genre"), reply.value()); isPlaying = true; } playerFound = true; player = QLatin1String("JuK"); } if (!isPlaying && QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.gnome.Rhythmbox")).value()) { QDBusInterface rhythmboxPlayer(QLatin1String("org.gnome.Rhythmbox") , QLatin1String("/org/gnome/Rhythmbox/Player"), QLatin1String("org.gnome.Rhythmbox.Player")); if (((QDBusReply<bool>)rhythmboxPlayer.call(QLatin1String("getPlaying"))).value()) { QDBusReply<QString> uri = rhythmboxPlayer.call(QLatin1String("getPlayingUri")); QDBusInterface rhythmboxShell(QLatin1String("org.gnome.Rhythmbox") , QLatin1String("/org/gnome/Rhythmbox/Shell"), QLatin1String("org.gnome.Rhythmbox.Shell")); QDBusReply< QMap<QString, QVariant> > reply = rhythmboxShell.call(QLatin1String("getSongProperties"), uri.value()); trackInfo = reply.value(); isPlaying = true; } playerFound = true; player = QLatin1String("Rhythmbox"); } if (!isPlaying && QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.exaile.Exaile")).value()) { QDBusInterface exailePlayer(QLatin1String("org.exaile.Exaile"), QLatin1String("/org/exaile/Exaile"), QLatin1String("org.exaile.Exaile")); if (((QDBusReply<bool>) exailePlayer.call(QLatin1String("IsPlaying"))).value()) { QDBusReply<QString> reply = exailePlayer.call(QLatin1String("GetTrackAttr"), QLatin1String("tracknumber")); trackInfo.insert(QLatin1String("tracknumber"), reply.value()); reply = exailePlayer.call(QLatin1String("GetTrackAttr"), QLatin1String("title")); trackInfo.insert(QLatin1String("title"), reply.value()); reply = exailePlayer.call(QLatin1String("GetTrackAttr"), QLatin1String("album")); trackInfo.insert(QLatin1String("album"), reply.value()); reply = exailePlayer.call(QLatin1String("GetTrackAttr"), QLatin1String("artist")); trackInfo.insert(QLatin1String("artist"), reply.value()); reply = exailePlayer.call(QLatin1String("GetTrackAttr"), QLatin1String("year")); trackInfo.insert(QLatin1String("year"), reply.value()); reply = exailePlayer.call(QLatin1String("GetTrackAttr"), QLatin1String("genre")); trackInfo.insert(QLatin1String("genre"), reply.value()); isPlaying = true; } playerFound = true; player = QLatin1String("Exaile"); } if (!isPlaying && QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.bansheeproject.Banshee")).value()) { // provide for new interface in Banshee 1.0+ QDBusInterface bansheePlayer(QLatin1String("org.bansheeproject.Banshee"), QLatin1String("/org/bansheeproject/Banshee/PlayerEngine"), QLatin1String("org.bansheeproject.Banshee.PlayerEngine")); if (!((QDBusReply<QString>) bansheePlayer.call(QLatin1String("GetCurrentState"))).value().compare(QLatin1String("playing"))) { QDBusReply< QMap<QString, QVariant> > reply = bansheePlayer.call(QLatin1String("GetCurrentTrack")); trackInfo = reply.value(); trackInfo.insert(QLatin1String("title"), trackInfo[QLatin1String("name")]); isPlaying = true; } playerFound = true; player = QLatin1String("Banshee"); } //trying to find not supported players that implamented the MPRIS-Dbus interface if (!isPlaying && !MPRIS::getRunningPlayers().isEmpty()) { for (const QString &playerName: MPRIS::getRunningPlayers()) { playerFound = true; MPRIS mprisPlayer(playerName); if (mprisPlayer.isValid() && mprisPlayer.isPlaying()) { trackInfo = mprisPlayer.getTrackMetadata(); isPlaying = true; player = mprisPlayer.getPlayerIdentification().left( mprisPlayer.getPlayerIdentification().lastIndexOf(QLatin1Char(' '))); //remove the version of player break; } } } if (!isPlaying) { if (playerFound) KMessageBox::information(Choqok::UI::Global::mainWindow(), i18nc("Player is running, But it's not playing.", "Play your desired music player.")); else KMessageBox::sorry(Choqok::UI::Global::mainWindow(), i18n("No supported player found.")); return; } NowListeningSettings::self()->load(); QString text = NowListeningSettings::templateString(); text.replace(QLatin1String("%track%"), trackInfo[QLatin1String("tracknumber")].toString()); text.replace(QLatin1String("%title%"), trackInfo[QLatin1String("title")].toString()); text.replace(QLatin1String("%album%"), trackInfo[QLatin1String("album")].toString()); text.replace(QLatin1String("%artist%"), trackInfo[QLatin1String("artist")].toString()); text.replace(QLatin1String("%year%"), trackInfo[QLatin1String("year")].toString()); text.replace(QLatin1String("%genre%"), trackInfo[QLatin1String("genre")].toString()); text.replace(QLatin1String("%player%"), player); if (Choqok::UI::Global::quickPostWidget()) { Choqok::UI::Global::quickPostWidget()->setText(text); } }
void run() { dragon(getParamInt(0), getParamDouble(1), getParamDouble(2), getParamDouble(3), getParamDouble(4)); }