void ModelPool::drawModel(std::string filename) { int ID; ID = getModelByName(filename); files[ID]->draw(); }
void SparDiskPanel::updateIntro() { auto typeId = _selectSparBox->getSpar(); _introSpar = typeId; if(typeId <= 0) { setSelectSparBox(nullptr); return; } auto spar = _sparDisk->getSpar(typeId); if(spar == nullptr) return; auto owner = dynamic_cast<Player*>(_sparDisk->getOwner()); if(owner == nullptr) return; auto sparPatchNum = owner->getItemBag()->getPropSizeByType(2002005); _patchNumLab->setString(a2u("ËéƬ:")+cocos2d::Value(sparPatchNum).asString()+a2u(" Éý¼¶ÏûºÄ:")+cocos2d::Value(spar->getCostPatchNum()).asString()); std::string nickName; std::string introduce; nickName = spar->getNickName(); introduce = spar->getModelByName("introduce").asString(); stringReplace(introduce, "%rate", cocos2d::Value(int(spar->getRate() * 100)).asString()+"%"); stringReplace(introduce, "%drate", cocos2d::Value(int(spar->getDrate() * 100)).asString()+"%"); _nickNameLab->setString(nickName); _introLab->setString(introduce); if(spar->getRate() >= spar->getMaxRate() || spar->getDrate() >= spar->getMaxDrate()) { _completeLab->setVisible(true); _refineBtn->setVisible(false); } else { _completeLab->setVisible(false); _refineBtn->setVisible(true); } }
GLWidget::GLWidget(QWidget *parent) : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) { // set default look at lookAt[0]=0; lookAt[1]=0; lookAt[2]=10; // set initial light position lightPos = { 0,0,0,1 }; // load the model and move it down 100 units modelLocation[0] = 0; modelLocation[1] = -100; modelLocation[2] = 0; qtPurple = QColor::fromCmykF(0.39, 0.39, 0.0, 0.0); // no models loaded yet so set it to a invalid id modelDisplayList = -1; numMaterial = 0; // create new timer to handle animation t = new QTimer(); // connect the timers timeout signal to the timer expired slot connect(t, SIGNAL(timeout()), this, SLOT(timerExpired())); // start the timer with a 30ms timout (30ms ~ 30Hz) t->start(30); // steal all keyboard inputs this->grabKeyboard(); theta = 180; phi = 0; // update the GL context updateGL(); // go load the terain loadNewModel(GL_TEXTURE0, "./models/terrain1.obj"); this->terrainModel = getModelByName("terrain1.obj"); // activate all the textures glActiveTexture(GL_TEXTURE1); loadTexture("./models/Grass.jpg"); glActiveTexture(GL_TEXTURE2); loadTexture("./models/WoodChips.jpg"); glActiveTexture(GL_TEXTURE3); loadTexture("./models/SkyBox.jpg"); // build the skybox this->skyBoxModel.setDisplayID( buildSkyBox(490)); // activate the skybox texture glActiveTexture(GL_TEXTURE0); // load all shaders program.removeAllShaders(); program.addShaderFromSourceFile(QGLShader::Vertex, "./shaders/perpixelphong.vert"); program.addShaderFromSourceFile(QGLShader::Fragment, "./shaders/perpixelphong.frag"); // compile and bind the shader program.bind(); // update all uniform values program.setUniformValue("heightMap",0); program.setUniformValue("baseMap1", 1); program.setUniformValue("baseMap2", 2); program.setUniformValue("skybox", 3); program.setUniformValue("mode", int(0)); program.setUniformValue("envMap", 3); program.setUniformValue("numWaves", int(4)); // set the parameter for the sum of sins equation waveAmp = {1.5,1.5,1,2, 10,10,10,10}; wavelength= {50,30,50,30, 10,10,10,10}; waveSpeed = {10,20,10,10, 10,10,10,10}; direction[0] = QVector2D(-.2,.5); direction[1] = QVector2D(.5, -.3); direction[2] = QVector2D(0,1); direction[3] = QVector2D(-.1, -.8); program.setUniformValueArray("direction", direction, 4); program.setUniformValueArray("amplitude", waveAmp, 8,1); program.setUniformValueArray("wavelength", wavelength, 8,1); program.setUniformValueArray("speed", waveSpeed, 8,1); }