Water::Water(Loader loader) { float positions[] = { -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f, -1.0f, 1.0f, 0.0f, 1.0f }; int indices[] = { 0, 1, 3, 3, 1, 2 }; // create a ground-plane that is 2x2 meters and scale it so it becomes 100x100 meters. waterplane = loader.createModel(positions, 12, indices, 6); Mat4 scaleMatrix; scaleMatrix.loadScale(150, 1, 150); waterplane.setModelMatrix(scaleMatrix); dudvTexture = loader.loadBMPtexture("water_dudv.bmp"); normalTexture = loader.loadBMPtexture("water_nomal.bmp"); shader.createShader("waterVertexShader.glsl", "waterFragmentShader.glsl"); reflectionFrameBuffer = FrameBufferUtilities::createBuffer(); reflectionTexture = FrameBufferUtilities::createTextureAttachment(REFLECTION_WIDTH, REFLECTION_HEIGHT); reflectionDepthBuffer = FrameBufferUtilities::createDepthBufferAttachment(REFLECTION_WIDTH, REFLECTION_HEIGHT); FrameBufferUtilities::unbindCurrentBuffer(); refractionFrameBuffer = FrameBufferUtilities::createBuffer(); refractionTexture = FrameBufferUtilities::createTextureAttachment(REFRACTION_WIDTH, REFRACTION_HEIGHT); refractionDepthTexture = FrameBufferUtilities::createDepthTextureAttachment(REFRACTION_WIDTH, REFRACTION_HEIGHT); FrameBufferUtilities::unbindCurrentBuffer(); double waterheight = 0; reflection_clip_plane = Vec4{ 0, 1, 0, -waterheight + 0.05 }; refraction_clip_plane = Vec4{ 0, -1, 0, -waterheight }; }
//Initialize the player. Player::Player() { Loader loader; this->tex = loader.loadTexture("assets/pics/player.png"); this->setTexture(tex); this->setTextureRect(sf::IntRect(0, 0, 170, 222)); this->setOrigin(this->getLocalBounds().width / 2, this->getLocalBounds().height / 2); this->setScale(sf::Vector2f(0.3, 0.3)); this->shieldTex = loader.loadTexture("assets/pics/shield.png"); this->shieldTex.setSmooth(true); this->shield.setTexture(shieldTex); this->shield.setScale(sf::Vector2f(1.5, 1.5)); this->spawnPoint = sf::Vector2f(400, 500); this->setPosition(sf::Vector2f(spawnPoint)); this->health = 100; this->damage = 10; this->ammoDescription = "Red Rays of Happiness"; this->shieldCharge = 200; this->isShielded = false; this->setRotation(0); this->acceleration = .2f; this->maxVelocity = 5.f; this->velocity = sf::Vector2f(0, 0); this->alive = true; this->isDying = false; this->pointMultiplier = 1; this->rateOfFire = 0.2; this->frameCount = 0; }
/** * Loads Config * Starts the C64 Components and Threads */ void startComponents(char* memPtr,struct _6510_cpu* cpuPtr) { std::cout << "loading components..."<<std::endl; memoryManager = new Service::MemoryManager((MemoryCell)memPtr); Loader loader = Loader(memoryManager); std::cout << "load configfile..."<< std::endl; loader.loadConfig(); std::cout << "starting Sid thread..."<<std::endl; Sid::Sid* sid = new Sid::Sid(memoryManager); std::cout << "starting cia thread..."<<std::endl; cia = new Cia::Cia(cpuPtr,memoryManager); VIC* vic = new VIC(cpuPtr); std::cout << "create memoryMap" <<std::endl; memMap = new MemoryMap(memoryManager,cpuPtr); memMap->draw(0x0,1.1); sidThread =thread([sid]{sid->run();}); C64Clock = new Service::Clock(memoryManager); Screen* screen = new Screen(vic,cia,memoryManager,memMap); screenThread = thread([screen]{screen->power();}); C64Clock->addComponent(screen); C64Clock->addComponent(cia); }
void process_lines(vector<string> & lines) { const int nlines = lines.size(); // number of lines const int n = nlines - 1; // number of input data if (nlines < 2) { cout << "number of lines is wrong" << endl; exit(EXIT_FAILURE); } Loader loader; // frontend Docker docker; // backend for (int i = 0; i < n; ++i) { string input = lines[i + 1]; //cout << input << endl; loader.load(input); loader.check(); #if 1 vector<string> tokens = loader.get_tokens(); for (unsigned int i = 0; i < tokens.size() - 1; ++i) cout << tokens[i] << ","; cout << tokens[tokens.size() - 1]; #endif cout << endl; loader.build_complex(docker.complex); docker.run(); } }
//obj = new object void ExceptionThrower::throwException(const char * exceptionClassName, const char * message) { //This method should be implemented , for now it will be empty.. Loader * loadclass = Loader::getInstance(); ClassData* exceptionClassData = loadclass->getClassData(exceptionClassName); exceptionObject = new Object(exceptionClassData); }
QMap<QString, QString> Sonnet::Speller::availableDictionaries() const { Loader *l = Loader::openLoader(); const QStringList lst = l->languages(); QMap<QString, QString> langs; foreach(QString tag, lst) { // krazy:exclude=foreach (no const& because tag is modified below) tag = tag.mid(0, tag.indexOf(QLatin1Char('-'))); int underscorePos = tag.indexOf(QLatin1Char('_')); QString cIsoName, lIsoName; if (underscorePos != -1 && underscorePos <= 3) { cIsoName = tag.mid(underscorePos + 1, 2); lIsoName = tag.left(underscorePos); } else { lIsoName = tag; } QLocale loc(tag); QString description; if (!cIsoName.isEmpty()) description= QString::fromLatin1("%1 (%2)") .arg(KGlobal::locale()->languageCodeToName(lIsoName)) .arg(KGlobal::locale()->countryCodeToName(cIsoName)); else description= KGlobal::locale()->languageCodeToName(lIsoName); //qDebug()<<"Dict is "<<tag<<" ( "<<loc.name()<<")"<<", descr = "<<description; langs.insert(description, tag); }
void main() { Loader loader; Mesh *mesh = new Mesh; loader.populatePos(mesh, 0); while (true){} }
//Constructor takes in the texture path and an id for the Power-Up. Powerups::Powerups(string path, string id) { Loader loader; this->setRadius(20); this->tex = loader.loadTexture(path); this->tex.setSmooth(true); this->setTexture(&tex); this->id = id; }
bool WindowsOperatingSystem::IsSupported(Loader const& rLdr, Architecture const& rArch) const { // At this time, only Windows on x86 is supported if ((rLdr.GetName() == "PE" || rLdr.GetName() == "PE+") && rArch.GetName() == "Intel x86") return true; return false; }
Loader* Loader::create() { Loader* screen = new Loader(); screen->autorelease(); screen->retain(); return screen; }
int run(int argc, char**argv){ Loader loader; int ord,nproc; try{ loader= Loader(argv[1],argv[2],argv[3],nproc); }catch(int e){ cout<<"Error cargando el fichero de argumento"; switch(e){ case -1: cout<<" 1"<<endl;break; case -2: cout<<" 2"<<endl;break; case -3: cout<<" 3"<<endl;break; } return -1; } ord = (int)sqrt(nproc);//dimension matrix //Create query for get processors' proxies // try{ Ice::ObjectPrx proxy = communicator()->stringToProxy("IceGrid/Query"); Ice::ObjectPrx col = communicator()->stringToProxy("Collector"); CollectorPrx collector = CollectorPrx::checkedCast(col); // }catch(){ // } Cannon::Matrix A (loader.getA()); Cannon::Matrix B (loader.getB()); Cannon::Matrix R= Modify::multiply(A,B); cout << "RESULT MATRIZ"<<endl; ofstream out("normalresult.m"); for(int i=0;i<R.ncols;i++){ for(int j=0;j<R.ncols;j++){ out << R.data[j+ i*R.ncols] << " "; cout<<R.data[j+ i*R.ncols]<< " "; } out << endl; cout << endl; } out.close(); vector < Cannon::Matrix> vA = Modify::split(A,ord); std::vector< Cannon::Matrix> vB = Modify::split(B,ord); vA = Modify::displace_horizontal(vA,ord); vB = Modify::displace_vertical(vB,ord); Dispatch dispatcher(nproc, proxy,collector);//create dispatcher for proccesors dispatcher.distr(vA,vB,0); return 0; }
void MrmlView::stopDownloads() { Loader *loader = Loader::self(); QPtrListIterator<MrmlViewItem> it( m_items ); for( ; it.current(); ++it ) { MrmlViewItem *item = it.current(); if ( !item->hasRemotePixmap() ) loader->removeDownload( item->url() ); } }
Loader* RootParser15::beginCommon( ) { mFileLoader->deleteFilePartLoader(); Loader* loader = new Loader(mFileLoader); Loader15* loader15 = new Loader15(loader); loader->setParserImpl( loader15 ); mFileLoader->setPartLoader(loader); mFileLoader->setParser(loader15); return loader; }
ScriptPromise FetchManager::fetch(ScriptState* scriptState, const FetchRequestData* request) { RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); OwnPtr<Loader> ownLoader(adoptPtr(new Loader(m_executionContext, this, resolver.release(), request))); Loader* loader = m_loaders.add(ownLoader.release()).storedValue->get(); loader->start(); return promise; }
Loader* RootParser15::beginCommonCTorWithId( const char * id ) { mFileLoader->deleteFilePartLoader(); Loader* loader = new Loader(mFileLoader, id); Loader15* loader15 = new Loader15(loader); loader->setParserImpl( loader15 ); mFileLoader->setPartLoader(loader); mFileLoader->setParser(loader15); mFileLoader->addToSidTree( id, 0); return loader; }
Loader* RootParser14::beginCommonWithId( const char * id) { mFileLoader->deleteFilePartLoader(); Loader* loader = new Loader(mFileLoader); Loader14* loader14 = new Loader14(loader); loader->setParserImpl( loader14 ); mFileLoader->setPartLoader(loader); mFileLoader->setParser(loader14); mFileLoader->addToSidTree( id, 0); return loader; }
Library *XmlReader::parse(const std::string &data) { TiXmlDocument doc; doc.Parse(data.c_str()); Loader l; XmlVisitor loader(&l); doc.Accept(&loader); return l.getLibrary(); }
Loader* Loader::create() { Loader* screen = new Loader(); screen->autorelease(); #if CC_PRELOAD_LEVEL > CC_PRELOAD_NOTHING screen->retain(); #endif return screen; }
Library *XmlReader::loadFile(const std::string &filename) { TiXmlDocument doc; doc.LoadFile(filename); Loader l; XmlVisitor loader(&l); doc.Accept(&loader); return l.getLibrary(); }
ScriptPromise FetchManager::fetch(ScriptState* scriptState, FetchRequestData* request) { RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); request->setContext(WebURLRequest::RequestContextFetch); OwnPtrWillBeRawPtr<Loader> ownLoader = Loader::create(m_executionContext, this, resolver.release(), request); Loader* loader = m_loaders.add(ownLoader.release()).storedValue->get(); loader->start(); return promise; }
Container* Loader::load(const char* file) { Loader loader; base::XML xml = base::XML::load(file); Container* base = new Container(); base->setRoot( new Root(base) ); int c = loader.addControls(xml.getRoot(), base); if(c) return base; else { delete base; return 0; } }
int main() { { Loader<Plugin> l; std::shared_ptr<Plugin> h = l.load("./testplugin.o"); std::cout << h->next() << std::endl; std::shared_ptr<Plugin> i = l.load("./testplugin.o"); std::cout << i->next() << std::endl; } // unload the triangle library }
bool SSAG::Connect(bool bootload) { if ((this->handle = libusb_open_device_with_vid_pid(ctx, SSAG_VENDOR_ID, SSAG_PRODUCT_ID)) == NULL) { if (bootload) { Loader *loader = new Loader(); if (loader->Connect()) { if (!loader->LoadFirmware()) { DBG("Failed to upload firmware to the device"); return false; } loader->Disconnect(); for (int i = 0; i < RENUMERATE_TIMEOUT; i++) { if (this->Connect(false)) return true; sleep(1); } DBG("Device did not renumerate. Timed out."); return false; } else { DBG("Failed to connect loader"); return false; } } else { return false; } } int rc; if (libusb_kernel_driver_active(this->handle, 0) == 1) { rc = libusb_detach_kernel_driver(this->handle, 0); if (rc < 0) { DBG("Can't detach kernel driver (%d)", rc); } } rc = libusb_set_configuration(this->handle, 1); if (rc < 0) { DBG("Can't set configuration (%d)", rc); } rc = libusb_claim_interface(this->handle, 0); if (rc < 0) { DBG("Can't claim interface (%d)", rc); } this->SetBufferMode(); this->SetGain(1); this->InitSequence(); return true; }
void Window::OnResourceLoaded() { DataStreamPtr stream = mSource->GetDataStream(); if (stream != NULL) { Loader loader; mLayout = loader.Load(stream, NULL); d_assert(mLayout != NULL); OnLoaded(); } }
int main(int argc, char ** argv){ Loader<QString> L; //string k = string("Pictures/feyenord.jpg"); QString k = QString(argv[1]); cout << k << endl; try{ QImage pic = L.getObject(k); QString tmp = QString("Pictures/feyenord.jpg"); int size = L.getSize(k); cout << "The size of the image is " << size << endl; //pic.display(); }catch( ImageNotFoundException &e){ cout << e.getMessage() << endl;} }
void CaptchaFormsPlugin::eventActivated(const QString& from) { int index = findChalleng("sender", from); if(index == -1) return; QHash<QString, QString> dataFields = challenges_.at(index); QString id = dataFields.value("id"); QPointer<CaptchaDialog> cd = new CaptchaDialog(id); cd->setBody(dataFields.value("body")); cd->setQuestion(dataFields.value("label")); connect(cd, SIGNAL(ok(QString, QString)), this, SLOT(submitChallenge(QString, QString))); connect(cd, SIGNAL(cancel(QString)), this, SLOT(cancelChallenge(QString))); dialogs_[id] = cd; if(dataFields.contains("data")) { QByteArray ba; ba.append(dataFields.value("data")); QPixmap pix = QPixmap::fromImage(QImage::fromData(QByteArray::fromBase64(ba))); cd->setPixmap(pix); } else { Loader *ld = new Loader(id, this); if(useProxy) { int acc = dataFields.value("account").toInt(); QString host_ = accInfo->proxyHost(acc); if(!host_.isEmpty()) { ld->setProxy(host_, accInfo->proxyPort(acc), accInfo->proxyUser(acc), accInfo->proxyPassword(acc)); } } else { Proxy p = appInfo->getProxyFor(name()); ld->setProxy(p.host, p.port, p.user, p.pass); } QString url = dataFields.value("uri"); if(url.isEmpty()) { QString str = dataFields.value("body"); QRegExp re(".*(http://[^\"]+).*"); if(re.indexIn(str) != -1) url = re.cap(1) + "/image"; } ld->start(url); connect(ld, SIGNAL(data(QString,QByteArray)), SLOT(loaderData(QString, QByteArray))); connect(ld, SIGNAL(error(QString)), SLOT(loaderError(QString))); } cd->show(); }
//Constructor. Only takes in the spawn position and initializes the Marauder. Marauder::Marauder(sf::Vector2f spawn) { Loader loader; this->tex = loader.loadTexture("assets/pics/marauder.png"); this->setTexture(tex); this->setTextureRect(sf::IntRect(0, 0, 162, 234)); this->setOrigin(this->getLocalBounds().width / 2, this->getLocalBounds().height / 2); this->setScale(sf::Vector2f(0.7, 0.7)); this->setPosition(spawn); this->setRotation(0); this->damage = 20; this->score = 40; this->health = 120; this->velocity = sf::Vector2f(1.5, 1.5); this->frameCount = 0; }
int Level::loadFrom(const Loader& loader) { cameras.clear(); meshes.clear(); materials.clear(); lights.clear(); for (auto e : mesh_objects) { delete e; } mesh_objects.clear(); for (auto e : game_objects) { delete e; } game_objects.clear(); if (physics_world != nullptr) delete physics_world; physics_world = new b2World(b2Vec2(0.0f, -9.81f)); physics_world->SetContinuousPhysics(true); physics_world->SetContactListener(new DungeonContactListener()); return loader.processScene(*this); }
void TerrainChunk::loadLODlevel(Loader loader, int level) { const int numberOfVertices[] = { NUMBER_OF_VERTICES , NUMBER_OF_VERTICES / 2 + 1, NUMBER_OF_VERTICES / 4 + 1 }; int indices[(NUMBER_OF_VERTICES - 1) * (NUMBER_OF_VERTICES - 1) * 6]; float positions[NUMBER_OF_VERTICES * NUMBER_OF_VERTICES * 3]; float textureCoords[NUMBER_OF_VERTICES * NUMBER_OF_VERTICES * 2]; float normals[NUMBER_OF_VERTICES * NUMBER_OF_VERTICES * 3]; int indicesIndex = 0, positionIndex = 0, textureCoordIndex = 0, normalIndex = 0; for (int x = 0; x < numberOfVertices[level]; x++) { for (int z = 0; z < numberOfVertices[level]; z++) { float localVertexPosX = (float)(x * SIZE) / (float)(numberOfVertices[level] - 1); float localVertexPosZ = (float)(z * SIZE) / (float)(numberOfVertices[level] - 1); double height = TerrainHeightGenerator::getHeight(pos.x + localVertexPosX, pos.z + localVertexPosZ); if (x == 0 || z == 0 || x == numberOfVertices[level] - 1 || z == numberOfVertices[level] - 1) { if (level == 1) height -= 0.15; else if (level == 2) height -= 0.30; } positions[positionIndex++] = pos.x + localVertexPosX; positions[positionIndex++] = (float)height; positions[positionIndex++] = pos.z + localVertexPosZ; float texCoordU = (float)(x) / (float)(numberOfVertices[level] - 1); float texCoordV = (float)(z) / (float)(numberOfVertices[level] - 1); textureCoords[textureCoordIndex++] = texCoordU; textureCoords[textureCoordIndex++] = texCoordV; Vec3 normal = TerrainHeightGenerator::getNormal(pos.x + localVertexPosX, pos.z + localVertexPosZ); normals[normalIndex++] = normal.x; normals[normalIndex++] = normal.y; normals[normalIndex++] = normal.z; } } for (int x = 0; x < numberOfVertices[level] - 1; x++) { for (int z = 0; z < numberOfVertices[level] - 1; z++) { int topLeft = (z * numberOfVertices[level]) + x; int topRight = topLeft + 1; int bottomLeft = ((z + 1) * numberOfVertices[level]) + x; int bottomRight = bottomLeft + 1; indices[indicesIndex++] = topLeft; indices[indicesIndex++] = bottomLeft; indices[indicesIndex++] = topRight; indices[indicesIndex++] = topRight; indices[indicesIndex++] = bottomLeft; indices[indicesIndex++] = bottomRight; } } models[level] = loader.createModel(positions, positionIndex, textureCoords, textureCoordIndex, normals, normalIndex, indices, indicesIndex); }
/** * Load the world from a file. * @param ldr Input stream to read from. */ void VoxelWorld::Load(Loader &ldr) { uint32 version = ldr.OpenBlock("WRLD"); uint16 xsize = 64; uint16 ysize = 64; if (version == 1) { xsize = ldr.GetWord(); ysize = ldr.GetWord(); } else if (version != 0) { ldr.SetFailMessage("Unknown world version."); } if (xsize >= WORLD_X_SIZE || ysize >= WORLD_Y_SIZE) { xsize = std::min<uint16>(xsize, WORLD_X_SIZE); ysize = std::min<uint16>(ysize, WORLD_Y_SIZE); ldr.SetFailMessage("Incorrect world size"); } ldr.CloseBlock(); this->SetWorldSize(xsize, ysize); if (!ldr.IsFail() && version != 0) { for (uint16 x = 0; x < xsize; x++) { for (uint16 y = 0; y < ysize; y++) { VoxelStack *vs = this->GetModifyStack(x, y); vs->Load(ldr); } } } if (version == 0 || ldr.IsFail()) this->MakeFlatWorld(8); }