// prepare tables (clear, ...) void ClientWindow::prepare_tables(InfoType cmd) { switch (cmd) { case WHO: // delete player table { QListViewItemIterator lv(ListView_players); for (QListViewItem *lvi; (lvi = lv.current());) { lv++; delete lvi; } // set number of players to 0 myAccount->num_players = 0; myAccount->num_watchedplayers = 0; // use this for fast filling playerListEmpty = true; statusUsers->setText(" P: 0 / 0 "); break; } case GAMES: // delete games table { QListViewItemIterator lv(ListView_games); for (QListViewItem *lvi; (lvi = lv.current());) { lv++; delete lvi; } // set number of games to 0 myAccount->num_games = 0; statusGames->setText(" G: 0 / 0 "); break; } case CHANNELS: { // delete channel info channellist.clear(); statusChannel->setText(""); /* QListViewItemIterator lv(ListView_ch); for (QListViewItem *lvi; (lvi = lv.current());) { lv++; delete lvi; }*/ // delete tooltips too QToolTip::remove(statusChannel); QToolTip::add(statusChannel, tr("Current channels and users")); break; } default: // unknown command??? qWarning("unknown Command in 'prepare_tables()'"); break; } }
TEST_F(test_dvector, with_lvector) { lvector lv(1, 4); lv(1) = LONG_MIN; lv(2) = INT_MIN; lv(3) = INT_MAX; lv(4) = LONG_MAX; dvector actual(lv); EXPECT_DOUBLE_EQ(double(LONG_MIN), actual(1)); EXPECT_DOUBLE_EQ(double(INT_MIN), actual(2)); EXPECT_DOUBLE_EQ(double(INT_MAX), actual(3)); EXPECT_DOUBLE_EQ(double(LONG_MAX), actual(4)); }
void DL_vtv::init(DL_dyna* _d, DL_point* _pd, DL_geo* _g, DL_point* _pg) { if (_d==_g) { DL_dsystem->get_companion()->Msg("Error: vtv::init: a vtv-constraint needs points from _different_ objects\n vtv-constraint not initialised\n"); return; } DL_constraint::init(); d=_d; pd.assign(_pd); g=_g; pg.assign(_pg); if (g) g_is_dyna=g->is_dyna(); else g_is_dyna=FALSE; if (!g_is_dyna) { if (g) { g->new_toworld(&pg,&pgw); g->get_newvelocity(&pg,&dpgw); } else { pgw.assign(&pg); dpgw.init(0,0,0); } } F->makezero(); oldF->makezero(); // check if the constraint is initially valid DL_largevector lv(3); get_error(&lv); if (lv.norm()>DL_constraints->max_error) { DL_dsystem->get_companion()->Msg("Warning: initially invalid vtv-constraint.\n error: (%f,%f,%f)\n", lv.get(0), lv.get(1), lv.get(2) ); } }
void Handler_PINIT(int* myID, Character *myChar, std::string* str) { SYNCHED_CHARACTER_MAP* chars = SYNCHED_CHARACTER_MAP::getInstance(); SYNCHED_MONSTER_MAP* mons = SYNCHED_MONSTER_MAP::getInstance(); INIT::CONTENTS contents; contents.ParseFromString(*str); Scoped_Wlock SW(&chars->srw); auto user = contents.data(0); int id = user.id(), x = user.x(), y = user.y(); std::string name = user.name(); int lv = user.lv(), maxHp = user.maxhp(), power = user.power(), maxExp = user.maxexp(); int prtExp = user.prtexp(); *myID = id; Character* myCharacter = myChar; myCharacter->setID(id); myCharacter->setName(name); myCharacter->setX(x); myCharacter->setY(y); myCharacter->setLv(lv, maxHp, power, maxExp); myCharacter->setPrtExp(prtExp); chars->insert(id, myChar); printf("- %s님께서 위치 (%d,%d) 에 생성되었습니다!\n", myChar->getName().c_str(), myChar->getX(), myChar->getY()); contents.clear_data(); }
void Handler_PSET_MON(int *myID, std::string* str) { SYNCHED_CHARACTER_MAP* chars = SYNCHED_CHARACTER_MAP::getInstance(); SYNCHED_MONSTER_MAP* mons = SYNCHED_MONSTER_MAP::getInstance(); SET_MONSTER::CONTENTS setmonsterContents; setmonsterContents.ParseFromString(*str); Scoped_Wlock SW(&mons->srw); for (int i = 0; i < setmonsterContents.data_size(); ++i) { auto tmpMon = setmonsterContents.data(i); std::string monName = tmpMon.name(); Monster* mon; if (monName == "기사") { mon = new Knight(tmpMon.id()); } // 일단 else문 달음. 이것 안하면 c4703에러뜸 else { mon = new Knight(); } mon->setX(tmpMon.x()); mon->setY(tmpMon.y()); mon->setLv(tmpMon.lv(), tmpMon.maxhp(), tmpMon.power()); mons->insert(tmpMon.id(), mon); printf("※ 앗!야생의 %s [ID:%d]가 나타났습니다!\n", mon->getName().c_str(), mon->getID()); } setmonsterContents.clear_data(); }
QList<int>* Controller::search(QString txt,const int& c) const{ QList<int>* indexlist=0; if( !model.empty() && !txt.isEmpty() )//se il db non è vuoto e c'è un valore su cui eseguire la ricerca { switch(c){ case 0://Name indexlist=model.find(name(txt.toStdString()));//funtori break; case 1://Type indexlist=model.find(type(txt.toStdString())); break; case 2://HP indexlist=model.find(hp(txt.toShort())); break; case 3://MP indexlist=model.find(mp(txt.toShort())); break; case 4://LV indexlist=model.find(lv(txt.toShort())); break; case 5://Strength indexlist=model.find(strength(txt.toShort())); break; case 6://Constitution indexlist=model.find(constitution(txt.toShort())); break; case 7://Wisdom indexlist=model.find(wisdom(txt.toShort())); break; } } return indexlist; }
ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* rw_options) const { std::string ext( osgDB::getLowerCaseFileExtension(fileName) ); if( !acceptsExtension(ext) ) return ReadResult::FILE_NOT_HANDLED; osgToy::GlslLint::Options lint_options( osgToy::GlslLint::NONE ); if( rw_options ) { std::istringstream iss( rw_options->getOptionString() ); std::string opt; while( getline( iss, opt, ',' ) ) { if( opt == "verbose") lint_options = osgToy::GlslLint::VERBOSE; else { osg::notify(osg::WARN) << "\n" EXTENSION_NAME " plugin: unrecognized option \"" << opt << "\"\n" << "comma-delimited options:\n" << "\tverbose = enable verbose output\n" << "example: osgviewer -O verbose foo.osg.glsllint" "\n" << std::endl; } } } osg::notify(osg::INFO) << "ReaderWriterGLSLLINT( \"" << fileName << "\" )" << std::endl; // strip the pseudo-loader extension std::string subFileName( osgDB::getNameLessExtension(fileName) ); if( subFileName == fileName ) { osg::notify(osg::WARN) << "Missing subfilename for " EXTENSION_NAME " pseudo-loader" << std::endl; return ReadResult::FILE_NOT_HANDLED; } // recursively load the subfile. osg::Node *node( osgDB::readNodeFile(subFileName) ); if( !node ) { // propagate the read failure upwards osg::notify(osg::WARN) << "Subfile \"" << subFileName << "\" could not be loaded" << std::endl; return ReadResult::FILE_NOT_HANDLED; } // This is where the pseudoloader does its thing... std::cout << "\n\n\n==========================================" << std::endl; std::cout << "[ BEGIN GLSLLINT...\n" << std::endl; osgToy::GlslLintVisitor lv( lint_options ); node->accept( lv ); std::cout << "\n] ...END GLSLLINT" << std::endl; std::cout << "==========================================\n\n\n" << std::endl; return node; }
int LvertStrip::cur_level() const { if ( _verts.empty() ) return 0; return lv(0)->lmesh()->rel_cur_level(); }
TEST_F(test_dvector, cast_lvector) { dvector dv(1, 4); dv(1) = LONG_MIN; dv(2) = LONG_MIN/2; dv(3) = LONG_MAX/2; dv(4) = LONG_MAX; lvector lv(1, 2); lv(1) = 3; lv(2) = 1; dvector ret = dv(lv); EXPECT_EQ(lv.indexmin(), ret.indexmin()); EXPECT_EQ(lv.indexmax(), ret.indexmax()); EXPECT_DOUBLE_EQ(dv((int)lv(1)), ret(1)); EXPECT_DOUBLE_EQ(dv((int)lv(2)), ret(2)); }
void Model::Load(Serializer::Reader &rd) { LoadVisitor lv(&rd); m_root->Accept(lv); for (AnimationContainer::const_iterator i = m_animations.begin(); i != m_animations.end(); ++i) (*i)->SetProgress(rd.Double()); UpdateAnimations(); }
lsh_vector lsh_probe_generator::base_all() const { const size_t base_size = base_[0].size(); lsh_vector lv(base_size * base_.size()); for (size_t i = 0; i < base_.size(); ++i) { for (size_t j = 0; j < base_size; ++j) { lv.set(i * base_size + j, base_[i].get(j)); } } return lv; }
// evalImpl(): return value requires a deref(xsink) if not 0 QoreValue CallReferenceCallNode::evalValueImpl(bool& needs_deref, ExceptionSink* xsink) const { ReferenceHolder<AbstractQoreNode> lv(exp->eval(xsink), xsink); if (*xsink) return QoreValue(); ResolvedCallReferenceNode* r = dynamic_cast<ResolvedCallReferenceNode*>(*lv); if (!r) { xsink->raiseException("REFERENCE-CALL-ERROR", "expression does not evaluate to a call reference (evaluated to type '%s')", lv ? lv->getTypeName() : "NOTHING"); return QoreValue(); } return r->execValue(args, xsink); }
QoreValue VarRefNewObjectNode::evalValueImpl(bool& needs_deref, ExceptionSink* xsink) const { assert(typeInfo->getUniqueReturnClass()); ReferenceHolder<QoreObject> obj(qore_class_private::execConstructor(*typeInfo->getUniqueReturnClass(), variant, args, xsink), xsink); if (*xsink) return QoreValue(); QoreObject* rv = *obj; LValueHelper lv(this, xsink); if (!lv) return QoreValue(); lv.assign(obj.release()); if (*xsink) return QoreValue(); return QoreValue(rv->refSelf()); }
/* * Diagram "B1", SQED, broken SUSY, * Gauge sector. */ main() { page pg; FeynDiagram fd(pg); #define RAD 2.5 fd.line_thickness.set(0.15); fd.vertex_thickness.set(0.15); /* define the left and the right external points */ xy el(-6, 0), er(6, 0); /* the SB vertex */ xy sb_coord(0, -RAD); vertex_box sb(fd, sb_coord); sb.fill.setfalse(); vertex_cross sb_cross(fd, sb_coord); sb.radius.scale(SB_RADIUS_SCALE); sb_cross.radius.scale(SB_RADIUS_SCALE); /* the LV vertex */ xy lv_coord(RAD, 0); lv_coord.rotate(-45); vertex_circlecross lv(fd, lv_coord); xy arcpt1(0, RAD); xy arcpt2(RAD, 0); arcpt2.rotate(-20); xy arcpt3(RAD, 0); arcpt3.rotate(-60); xy arcpt4(RAD, 0); arcpt4.rotate(-135); /* the ordinary SQED vertex */ vertex v1(fd, -RAD, 0); vertex v2(fd, RAD, 0); /* photon line propagators */ line_wiggle ph1(fd, el, v1), ph2(fd, v2, er); line_plain f1(fd, v1, v2); line_plain f2(fd, v2, lv); f2.arrowon.setfalse(); line_plain f3(fd, lv, sb); f3.arrowon.setfalse(); line_plain f4(fd, sb, v1); /* stretch it to be an arc */ f1.arcthru(arcpt1); f2.arcthru(arcpt2); f3.arcthru(arcpt3); f4.arcthru(arcpt4); pg.output(); return 0; }
void GeometryRendererDemo::onProcessorValidated(AbstractProcessor* processor) { if (processor == &_geometryReader) { // update camera ScopedTypedData<IHasWorldBounds> lv(*_dataContainer, _geometryReader.p_targetImageID.getValue()); ScopedTypedData<IHasWorldBounds> teapot(*_dataContainer, "teapot"); ScopedTypedData<IHasWorldBounds> cube(*_dataContainer, "cube"); if (lv != 0 && teapot != 0) { cgt::Bounds unionBounds; unionBounds.addVolume(lv->getWorldBounds()); unionBounds.addVolume(teapot->getWorldBounds()); unionBounds.addVolume(cube->getWorldBounds()); _tcp.reinitializeCamera(unionBounds); } } }
osg::Matrix CameraModel::get_rot() const { osg::Vec3d lv( _center - _eye ); osg::Vec3d f( lv ); f.normalize(); osg::Vec3d s( f^_up ); s.normalize(); osg::Vec3d u( s^f ); u.normalize(); osg::Matrixd rotation_matrix( s[0], u[0], -f[0], 0.0f, s[1], u[1], -f[1], 0.0f, s[2], u[2], -f[2], 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ); return rotation_matrix; }
// returns a RunTimeObjectMethodReference or NULL if there's an exception QoreValue ParseObjectMethodReferenceNode::evalValueImpl(bool& needs_deref, ExceptionSink* xsink) const { // evaluate lvalue expression ReferenceHolder<AbstractQoreNode> lv(exp->eval(xsink), xsink); if (*xsink) return QoreValue(); QoreObject* o = (*lv) && (*lv)->getType() == NT_OBJECT ? reinterpret_cast<QoreObject*>(*lv) : 0; if (!o) { xsink->raiseException("OBJECT-METHOD-REFERENCE-ERROR", "expression does not evaluate to an object"); return QoreValue(); } //printd(5, "ParseObjectMethodReferenceNode::evalImpl() this: %p o: %p %s::%s() m: %p\n", this, o, o->getClassName(), method.c_str(), m); const QoreClass* oc = o->getClass(); // find the method at runtime if necessary if (!m) { // serialize method resolution at runtime AutoLocker al(lck); // check m again inside the lock (this way we avoid the lock in the common case where the method has already been resolved) if (!m) { bool m_priv = false; m = oc->findMethod(method.c_str(), m_priv); if (!m) { m = oc->findStaticMethod(method.c_str(), m_priv); if (!m) { xsink->raiseException("OBJECT-METHOD-REFERENCE-ERROR", "cannot resolve reference to %s::%s(): unknown method", o->getClassName(), method.c_str()); return QoreValue(); } } if (m_priv && !qore_class_private::runtimeCheckPrivateClassAccess(*oc)) { if (m->isPrivate()) xsink->raiseException("ILLEGAL-CALL-REFERENCE", "cannot create a call reference to private %s::%s() from outside the class", o->getClassName(), method.c_str()); else xsink->raiseException("ILLEGAL-CALL-REFERENCE", "cannot create a call reference to %s::%s() because the parent class that implements the method (%s::%s()) is privately inherited", o->getClassName(), method.c_str(), m->getClass()->getName(), method.c_str()); return QoreValue(); } } } if (oc == m->getClass() || oc == qc) return new RunTimeResolvedMethodReferenceNode(o, m); return new RunTimeObjectMethodReferenceNode(o, method.c_str()); }
void CSulManipulatorCamera::computePosition( const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up ) { osg::Vec3 lv(center-eye); osg::Vec3 f(lv); f.normalize(); osg::Vec3 s(f^up); s.normalize(); osg::Vec3 u(s^f); u.normalize(); osg::Matrix rotation_matrix(s[0], u[0], -f[0], 0.0f, s[1], u[1], -f[1], 0.0f, s[2], u[2], -f[2], 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); m_c = center; m_d = lv.length(); m_q = rotation_matrix.getRotate().inverse(); }
void LangevinThermostatOptimizerState::rescale_velocities() const { static const double gas_constant = 8.31441e-7; MolecularDynamics *md = dynamic_cast<MolecularDynamics *>(get_optimizer()); double c1 = exp(-gamma_ * md->get_last_time_step()); double c2 = sqrt((1.0 - c1) * gas_constant * temperature_); IMP_INTERNAL_CHECK(md, "Can only use velocity scaling with " "the molecular dynamics optimizer."); boost::normal_distribution<Float> mrng(0., 1.); boost::variate_generator<RandomNumberGenerator &, boost::normal_distribution<Float> > sampler(random_number_generator, mrng); for (unsigned int i = 0; i < pis_.size(); ++i) { Particle *p = pis_[i]; double mass = Mass(p).get_mass(); LinearVelocity lv(p); lv.set_velocity(c1 * lv.get_velocity() + c2 * sqrt((c1 + 1.0) / mass) * algebra::Vector3D(sampler(), sampler(), sampler())); } }
void FPSManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up) { osg::Vec3 lv(center-eye); osg::Vec3 f(lv); f.normalize(); osg::Vec3 s(f^up); s.normalize(); osg::Vec3 u(s^f); u.normalize(); osg::Matrix rotation_matrix(s[0], u[0], -f[0], 0.0f, s[1], u[1], -f[1], 0.0f, s[2], u[2], -f[2], 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); _center = eye; //_distance = lv.length(); _rotation = rotation_matrix.getRotate().inverse(); }
/* * Diagram "E", SQED, unbroken SUSY, * Gauge sector. */ main() { page pg; FeynDiagram fd(pg); #define RAD 2.5 fd.line_thickness.set(0.15); fd.vertex_thickness.set(0.15); /* define the left and the right external points */ xy el(-6, 0), er(6, 0); xy arcpt1(RAD, 0); arcpt1.rotate(180); arcpt1 += xy(0,RAD); xy arcpt2(RAD, 0); arcpt2 += xy(0,RAD); arcpt1 += xy(0, GAUGE_LIFT); arcpt2 += xy(0, GAUGE_LIFT); /* the LV vertex */ xy lv_coord(0, 2 * RAD + GAUGE_LIFT); vertex_circlecross lv(fd, lv_coord); vertex_dot v1(fd, 0, GAUGE_LIFT); /* the ordinary SQED vertex */ v1.radius.scale(1.7); /* photon line propagators */ line_wiggle ph1(fd, el, er); ph1.width.scale(0.7); line_plain f1(fd, v1, lv); line_plain f2(fd, lv, v1); /* stretch it to be an arc */ f1.arcthru(arcpt1); f2.arcthru(arcpt2); pg.output(); return 0; }
void ToonModel::draw() { LPDIRECT3DDEVICE9 device = ShaderDevise::device(); LPD3DXBUFFER materials = this->materials(); LPD3DXMATERIAL mat = (LPD3DXMATERIAL)this->materials()->GetBufferPointer(); std::vector<LPDIRECT3DTEXTURE9> tex = this->textures(); device->SetTexture(1, toon); D3DXMATRIX world = getWorld(); device->SetTransform(D3DTS_WORLD, &world); D3DMATERIAL9 tmp_mat; device->GetMaterial(&tmp_mat); device->SetFVF(D3DFVF_CUSTOMMODEL); D3DXMATRIX v(Camera::view()), p(Camera::projection()), wvp = (world * v * p); HRESULT hr; if(shader_pack) { hr = device->SetVertexShader(shader_pack->vs); hr = shader_pack->constant_table->SetMatrix(device, "g_world_view_projection", &wvp); D3DXVECTOR3 lv(ShaderDevise::getLight(0).Direction); hr = shader_pack->constant_table->SetVector(device, "g_light_direction", &D3DXVECTOR4(lv.x, lv.y, lv.z, 1)); hr = shader_pack->constant_table->SetMatrix(device, "g_world", &world); } for(int i = 0, len = numMaterials(); i < len; i++) { hr = device->SetMaterial(&mat[i].MatD3D); D3DXVECTOR4 diff(mat[i].MatD3D.Diffuse.r, mat[i].MatD3D.Diffuse.g, mat[i].MatD3D.Diffuse.b, mat[i].MatD3D.Diffuse.a); if(shader_pack) { hr = shader_pack->constant_table->SetVector(device, "g_material_diffuse", &diff); } hr = device->SetTexture(0, toon); this->mesh()->DrawSubset(i); } if(shader_pack) { device->SetVertexShader(NULL); } device->SetMaterial(&tmp_mat); }
void Handler_PUSER_SET_LV(int *myID, std::string* str) { SYNCHED_CHARACTER_MAP* chars = SYNCHED_CHARACTER_MAP::getInstance(); SYNCHED_MONSTER_MAP* mons = SYNCHED_MONSTER_MAP::getInstance(); SET_USER_LV::CONTENTS setuserlvContents; setuserlvContents.ParseFromString(*str); Scoped_Rlock SW(&chars->srw); for (int i = 0; i < setuserlvContents.data_size(); ++i) { auto setuserlv = setuserlvContents.data(i); int id = setuserlv.id(); int lv = setuserlv.lv(); int maxHp = setuserlv.maxhp(); int power = setuserlv.power(); int expUp = setuserlv.expup(); int maxexp = setuserlv.maxexp(); Character* lvUpChar = chars->find(id); if (lvUpChar->getID() == *myID) printf("- 레벨 업을 하였습니다!!\n"); if (lvUpChar == NULL) { printf("나 나오면 안돼는데 나옴?"); exit(0); } else { lvUpChar->setExpUp(expUp); lvUpChar->setLv(lv, maxHp, power, maxexp); printf("★ 유저 %s 님께서 레벨이 %d로 올랐습니다!!\n", lvUpChar->getName().c_str(), id, lv); } } }
void moto_setVarVal(MotoEnv *env, MotoVar *var, MotoVal *val) { moto_castVal(env,var->vs,val); /* If the MotoVar is a member var then we need to set the var in the MCI which this var is a member of */ if(var->isMemberVar) { switch (var->type->kind) { case INT32_TYPE: *(int32_t*)var->address = iv(var->vs); break; case INT64_TYPE: *(int64_t*)var->address = lv(var->vs); break; case FLOAT_TYPE: *(float*)var->address = fv(var->vs); break; case DOUBLE_TYPE: *(double*)var->address = dv(var->vs); break; case BOOLEAN_TYPE: *(unsigned char*)var->address = bv(var->vs); break; case BYTE_TYPE: *(signed char*)var->address = yv(var->vs); break; case CHAR_TYPE: *(char*)var->address = cv(var->vs); break; case REF_TYPE: *(void**)var->address = var->vs->refval.value; break; default: break; } } }
uint32 loopTetris(uint32 u,tetris* t) { int32 ch; uint32 i; while(1) { Sleep(lv(t->_l)); ch=button(); for(i=0;i!=u;++i) { if(ch)tetrisAction(&t[i],ch); tetrisAction(&t[i],0); if(!t[i]._flag) { tetrisDisplay(&t[i],8,"游戏结束",0); return i; } } } return 0; }
// take a new player from parser void ClientWindow::slot_player(Player *p, bool cmdplayers) { // insert into ListView QListViewItemIterator lv(ListView_players); QPoint pp(0,0); QListViewItem *topViewItem = ListView_players->itemAt(pp); bool deleted_topViewItem = false; if (p->online) { // check if it's an empty list, i.e. all items deleted before if (cmdplayers && !playerListEmpty) { for (PlayerTableItem *lvi; (lvi = static_cast<PlayerTableItem*>(lv.current()));) { lv++; // compare names if (lvi->text(1) == p->name) { // check if new player info is less than old if (p->info != "??") { // new entry has more info lvi->setText(0, p->info); //p->name, lvi->setText(2, p->rank); lvi->setText(3, p->play_str); lvi->setText(4, p->obs_str); lvi->setText(5, p->idle); //mark, lvi->setText(12, rkToKey(p->rank) + p->name.lower()); if (extUserInfo && myAccount->get_gsname() == IGS) { lvi->setText(7, p->extInfo); lvi->setText(8, p->won); lvi->setText(9, p->lost); lvi->setText(10, p->country); lvi->setText(11, p->nmatch_settings); } lvi->set_nmatchSettings(p); //lvi->nmatch = p->nmatch; lvi->ownRepaint(); } if (p->name == myAccount->acc_name) { qDebug("updating my account info... (1)"); // checkbox open bool b = (p->info.contains('X') == 0); slot_checkbox(0, b); // checkbox looking - don't set if closed if (p->info.contains('!') != 0) // "!" found slot_checkbox(1, true); else if (b) // "!" not found && open slot_checkbox(1, false); // checkbox quiet // NOT CORRECT REPORTED BY SERVER! //b = (p->info.contains('Q') != 0); //slot_checkbox(2, b); // -> WORKAROUND if (p->info.contains('Q') != 0) slot_checkbox(2, true); // get rank to calc handicap when matching myAccount->set_rank(p->rank); } return; } } } else if (!cmdplayers && !myAccount->num_players) { qDebug("player skipped because no init table"); // skip players until initial table has loaded return; } QString mark; // check for watched players if (watch && watch.contains(";" + p->name + ";")) { mark = "W"; // sound for entering - no sound while "who" cmd is executing if (!cmdplayers) qgoif->get_qgo()->playEnterSound(); else if (p->name == myAccount->acc_name) // it's me // - only possible if 'who'/'user' cmd is executing // - I am on the watchlist, however // don't count! myAccount->num_watchedplayers--; myAccount->num_watchedplayers++; } // check for excluded players else if (exclude && exclude.contains(";" + p->name + ";")) { mark = "X"; } // check for open/looking state if (cmdplayers) { if (p->name == myAccount->acc_name) { qDebug("updating my account info...(2)"); // checkbox open bool b = (p->info.contains('X') == 0); slot_checkbox(0, b); // checkbox looking b = (p->info.contains('!') != 0); slot_checkbox(1, b); // checkbox quiet // NOT CORRECT REPORTED BY SERVER! //b = (p->info.contains('Q') != 0); //slot_checkbox(2, b); // -> WORKAROUND if (p->info.contains('Q') != 0) slot_checkbox(2, true); // get rank to calc handicap when matching myAccount->set_rank(p->rank); mark = "M"; } } // from WHO command or {... has connected} if (extUserInfo && myAccount->get_gsname() == IGS) { PlayerTableItem *lv1 = new PlayerTableItem(ListView_players, p->info, p->name, p->rank, p->play_str, p->obs_str, p->idle, mark, p->extInfo, p->won, p->lost, p->country, p->nmatch_settings); lv1->setText(12, rkToKey(p->rank) + p->name.lower()); lv1->set_nmatchSettings(p); } else { PlayerTableItem *lv1 = new PlayerTableItem(ListView_players, p->info, p->name, p->rank, p->play_str, p->obs_str, p->idle, mark); lv1->setText(12, rkToKey(p->rank) + p->name.lower()); lv1->set_nmatchSettings(p); } // increase number of players myAccount->num_players++; statusUsers->setText(" P: " + QString::number(myAccount->num_players) + " / " + QString::number(myAccount->num_watchedplayers) + " "); //if (!cmdplayers) // ListView_players->sort() ; } else { // {... has disconnected} bool found = false; for (QListViewItem *lvi; (lvi = lv.current()) && !found;) { lv++; // compare names if (lvi->text(1) == p->name) { // check if it was a watched player if (lvi->text(6) == "W") { qgoif->get_qgo()->playLeaveSound(); myAccount->num_watchedplayers--; } lv++; if (lvi == topViewItem) // are we trying to delete the 'anchor' of the list viewport ? deleted_topViewItem = true ; delete lvi; found = true;; // decrease number of players myAccount->num_players--; statusUsers->setText(" P: " + QString::number(myAccount->num_players) + " / " + QString::number(myAccount->num_watchedplayers) + " "); } } if (!found) qWarning("disconnected player not found: " + p->name); } if (! deleted_topViewItem) //don't try to refer to a deleted element ... { int ip = topViewItem->itemPos(); ListView_players->setContentsPos(0,ip); } }
void DL_pts::init(DL_geo* _g, DL_point* _p, DL_surface* _surf) { DL_point ptmp; DL_vector vtmp; if (_g==_surf->get_geo()) { DL_dsystem->get_companion()->Msg("Error: pts::init: the surface and the point should lie in different objects!\n pts constraint not initialised\n"); return; } if (_g) g_is_dyna=_g->is_dyna(); else g_is_dyna=FALSE; if (_surf->get_geo()) sg_is_dyna=_surf->get_geo()->is_dyna(); else sg_is_dyna=FALSE; if (!(g_is_dyna || sg_is_dyna)) { DL_dsystem->get_companion()->Msg("Error: pts::init: either the point or the surface should belong to a dyna\n pts-constraint not initialised\n"); return; } // get the initial surface-parameters if (_g) _g->to_world(_p,&ptmp); else ptmp.assign(_p); if (!_surf->closeto(&ptmp,s,t)) { DL_dsystem->get_companion()->Msg("Error: pts::init: initial surface position (%f,%f) is out of bounds\n pts-constraint not initialised\n",s,t); return; } olds=s; oldt=t; // set up the local coordinate system: st_inbounds=_surf->pos(s,t,&sstl); if (sg_is_dyna) { sf=s; tf=t; sstf.assign(&sstl); } if (_surf->get_geo()) { _surf->deriv0(s,t,&vtmp); (_surf->get_geo())->to_world(&vtmp,&x); } else _surf->deriv0(s,t,&x); xxinv=1.0/x.inprod(&x); if (_surf->get_geo()) { _surf->deriv1(s,t,&vtmp); (_surf->get_geo())->to_world(&vtmp,&y); } else _surf->deriv1(s,t,&y); yyinv=1.0/y.inprod(&y); // make sure y is perpendicular to x: { DL_vector vtmp; x.times(-x.inprod(&y)*xxinv,&vtmp); y.plusis(&vtmp); } x.crossprod(&y,&n); n.normalize(); dcdp.setrow(0,&n); dfdR.setcolumn(0,&n); surf=_surf; g=_g; p.assign(_p); if (!g_is_dyna) { if (g) { g->new_toworld(&p,&pgw); g->get_newvelocity(&p,&dpgw); } else { pgw.assign(&p); dpgw.init(0,0,0); } } // check if the constraint is initially valid DL_largevector lv(1); get_error(&lv); if (!st_inbounds) { DL_dsystem->get_companion()->Msg("Error: pts::init: initial surface parameters (%f,%f) out of bounds\n pts-constraint not initialised\n",s,t); return; } if (lv.get(0)>DL_constraints->max_error) { DL_dsystem->get_companion()->Msg("Warning: initially invalid pts-constraint\n Error: %f\n Initial surface parameters: (%f,%f)\n", lv.get(0), s, t); } // ok: we're in business: DL_constraint::init(); F->makezero(); oldF->makezero(); }
void DemoKeeper::GravityActionDemo( void ) { mWorld->markForWrite(); // Define world gravity as zero. hkVector4 gravity( 0.0f, 0.0f, 0.0f ); mWorld->setGravity(gravity); // // Create the "planet" shape to orbit around. // hkpRigidBody* planet = HK_NULL; const hkVector4 gravityCenter(0.0f, 15.0f, 0.0f); { hkReal radius = 5.0f; hkpSphereShape* sphereShape = new hkpSphereShape(radius); hkpRigidBodyCinfo sphereInfo; sphereInfo.m_shape = sphereShape; sphereInfo.m_position.set(gravityCenter(0), gravityCenter(1), gravityCenter(2)); sphereInfo.m_angularDamping = 0.0f; sphereInfo.m_linearDamping = 0.0f; sphereInfo.m_friction = 0.0f; // Planet is fixed. sphereInfo.m_motionType = hkpMotion::MOTION_FIXED; // Create a rigid body (using the template above). planet = new hkpRigidBody(sphereInfo); // Remove reference since the hkpRigidBody now "owns" the Shape. sphereShape->removeReference(); // Add rigid body so we can see it, and remove reference since the hkpWorld now "owns" it. mWorld->addEntity(planet); //render it with Ogre Ogre::SceneNode* sphereNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); //scale sphereNode->scale(5.f, 5.f, 5.f); //display and sync Ogre::Entity *ent = mSceneMgr->createEntity(Ogre::StringConverter::toString(mLabMgr->getEntityCount()),"defSphere.mesh"); mLabMgr->setColor(ent, Ogre::Vector3(0.5538,0.3187,0.1275)); HkOgre::Renderable* rend = new HkOgre::Renderable(sphereNode, planet, mWorld); sphereNode->attachObject(ent); //register to lab manager mLabMgr->registerEnity( sphereNode, planet); } // Limit number of polygons as Havok renderer is not perfect! const int numBodies = 100; // // Create the satellites. // { hkPseudoRandomGenerator generator(234); for(int i = 0; i < numBodies; i++) { hkVector4 halfExtents(0.25f, 0.25f, 0.25f); hkpBoxShape* satelliteShape = new hkpBoxShape(halfExtents, 0 ); hkpRigidBodyCinfo satelliteInfo; satelliteInfo.m_shape = satelliteShape; satelliteInfo.m_position.set( generator.getRandRange( 7.0f, 25.0f ), generator.getRandRange( 7.0f+15, 25.0f+15 ), generator.getRandRange( 7.0f, 25.0f ) ); satelliteInfo.m_angularDamping = 0.0f; satelliteInfo.m_linearDamping = 0.0f; satelliteInfo.m_friction = 0.0f; satelliteInfo.m_motionType = hkpMotion::MOTION_BOX_INERTIA; hkReal mass = 10.0f; hkMassProperties massProperties; hkpInertiaTensorComputer::computeBoxVolumeMassProperties(halfExtents, mass, massProperties); satelliteInfo.m_inertiaTensor = massProperties.m_inertiaTensor; satelliteInfo.m_centerOfMass = massProperties.m_centerOfMass; satelliteInfo.m_mass = massProperties.m_mass; // Create a rigid body (using the template above). hkpRigidBody* satellite = new hkpRigidBody(satelliteInfo); // Give each hkpRigidBody an initial velocity so they orbit in the same direction. hkVector4 lv(0.0f, -5.0f, 0.0f); satellite->setLinearVelocity( lv ); // Remove reference since the body now "owns" the Shape satelliteShape->removeReference(); // Finally add body so we can see it, and remove reference since the world now "owns" it. mWorld->addEntity(satellite); const hkReal gravityConstant = 1000.0f; GravityAction* gravityAction = new GravityAction( satellite, gravityCenter, gravityConstant ); mWorld->addAction( gravityAction ); // After addAction() mWorld references antiGravityAction so the local reference can safely be removed. gravityAction->removeReference(); satellite->removeReference(); //render it with Ogre Ogre::SceneNode* boxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); //scale boxNode->scale(0.5, 0.5, 0.5); //display and sync Ogre::Entity *ent = mSceneMgr->createEntity(Ogre::StringConverter::toString(mLabMgr->getEntityCount()),"defCube.mesh"); mLabMgr->setColor(ent, Ogre::Vector3(rand()/(double)RAND_MAX,rand()/(double)RAND_MAX,rand()/(double)RAND_MAX)); HkOgre::Renderable* rend = new HkOgre::Renderable(boxNode, satellite,mWorld); boxNode->attachObject(ent); //register to lab manager mLabMgr->registerEnity( boxNode, satellite); } } planet->removeReference(); mWorld->unmarkForWrite(); }
static int isector(void) {int k, y1, y2, vv, ss, pp=0, tt=0, sh=0; int count=0; /* Nested function: lh */ /* Nested function: lv */ k = resl.mver; for (isect = 1; isect <= k; isect++) { {intsect *with1 = &resl.ints[isect-1]; y1 = with1->y; vv = with1->aliasvert; ss = with1->aliasslot; } jsect = 1; while (resr.ints[jsect-1].selfvert != vv || resr.ints[jsect-1].selfslot != ss) ++(jsect); {intsect *with1 = &resr.ints[jsect-1]; if (y1 == with1->y) ++(sh); else if (y1 == with1->y + ystep) ++(pp); else if (y1 == with1->y - ystep) ++(tt); } } sh = tt > sh ? - ystep : pp > sh ? ystep : 0; goto b; a: count++; if(sh==0) sh=-1; else {if(sh<0) sh=-sh; else sh=-sh-1;} // if (sh < 0) // ++(sh); // else // --(sh); b: pp = sh < 0 ? resl.mxy - sh : resr.mxy + sh; if (resr.mxy > pp) pp = resr.mxy; if (resl.mxy > pp) pp = resl.mxy; ++(pp); for (isect = 1; isect <= k; isect++) for (jsect = 1; jsect <= pp; jsect++) is[isect-1][jsect-1] = chsp; for (isect = 1; isect <= k; isect++) { {intsect *with1 = &resl.ints[isect-1]; y1 = with1->y; ssect = with1->sp % 2 == 0 ? 1 : 0; vv = with1->aliasvert; ss = with1->aliasslot; } jsect = 1; while (resr.ints[jsect-1].selfvert != vv || resr.ints[jsect-1].selfslot != ss) ++(jsect); y2 = resr.ints[jsect-1].y; if (sh < 0) y1 -= sh; else y2 += sh; if (y1 == y2) for (jsect = 1; jsect <= k; jsect++) tt = lh(y1); else if (y1 < y2) { for (jsect = 1; jsect <= isect - 1; jsect++) if (lh(y1) == 1) {if(count<5)goto a;} if (is[isect-1][y1-1] != chsp) {if(count<5)goto a;} is[isect-1][y1-1] = ssect ? chrBF : chrBB; for (jsect = y1 + 1; jsect <= y2 - 1; jsect++) lv(); if (is[isect-1][y2-1] != chsp) {if(count<5)goto a;} is[isect-1][y2-1] = ssect ? chrC0 : chrC8; for (jsect = isect + 1; jsect <= k; jsect++) if (lh(y2) == 1) {if(count<5)goto a;} } else { for (jsect = 1; jsect <= isect - 1; jsect++) if (lh(y1) == 1) {if(count<5)goto a;} if (is[isect-1][y1-1] != chsp) {if(count<5)goto a;} is[isect-1][y1-1] = ssect ? chrD9 : chrBC; for (jsect = y2 + 1; jsect <= y1 - 1; jsect++) lv(); if (is[isect-1][y2-1] != chsp) {if(count<5)goto a;} is[isect-1][y2-1] = ssect ? chrDA : chrC9; for (jsect = isect + 1; jsect <= k; jsect++) if (lh(y2) == 1) {if(count<5)goto a;} } } return sh; } /* The end of Isector's body */
// Implementation of: // // loadVariables(url:String, target:Object, [method:String]) : Void // loadMovie(url:String, target:Object, [method:String]) : Void // loadMovie(url:String, target:String, [method:String]) : Void // unloadMovie(target:MovieClip) : Void // unloadMovie(target:String) : Void // // url=="" means that the load_file() works as unloadMovie(target) // TODO: implement [method] character *as_environment::load_file ( const char *url, const as_value &target_value, int method ) { character *target = cast_to<character> ( find_target ( target_value ) ); if ( target == NULL ) { IF_VERBOSE_ACTION ( log_msg ( "load_file: target %s is't found\n", target_value.to_string() ) ); return NULL; } // is unloadMovie() ? if ( strlen ( url ) == 0 ) { character *parent = target->get_parent(); if ( parent ) { parent->remove_display_object ( target ); } else // target is _root, unloadMovie(_root) { target->clear_display_objects(); } return NULL; } // is path relative ? tu_string file_name = get_full_url ( get_player()->get_workdir(), url ); switch ( get_file_type ( file_name.c_str() ) ) { default: break; case TXT: { // Reads data from an external file, such as a text file and sets the values for // variables in a target movie clip. This action can also be used // to update variables in the active SWF file with new values. tu_file fi ( file_name.c_str(), "r" ); if ( fi.get_error() == TU_FILE_NO_ERROR ) { fi.go_to_end(); int len = fi.get_position(); fi.set_position ( 0 ); char *buf = ( char * ) malloc ( len ); if ( fi.read_string ( buf, len ) > 0 ) { // decode data in the standard MIME format and copy theirs into target #if TU_ENABLE_NETWORK == 1 as_loadvars lv ( get_player() ); lv.decode ( buf ); lv.copy_to ( target ); #else log_error ( "Compile gameswf with TU_ENABLE_NETWORK=1 to use loadVariable() function" ); #endif } free ( buf ); } break; } case URL: case SWF: { movie_definition *md = get_player()->create_movie ( file_name.c_str() ); if ( md && md->get_frame_count() > 0 ) { return target->replace_me ( md ); } break; } case X3DS: { #if TU_CONFIG_LINK_TO_LIB3DS == 0 log_error ( "gameswf is not linked to lib3ds -- can't load 3DS file\n" ); #else x3ds_definition *x3ds = create_3ds_definition ( get_player(), file_name.c_str() ); if ( x3ds ) { if ( x3ds->is_loaded() ) { rect bound; target->get_bound ( &bound ); x3ds->set_bound ( bound ); return target->replace_me ( x3ds ); } } #endif break; } case JPG: { #if TU_CONFIG_LINK_TO_JPEGLIB == 0 log_error ( "gameswf is not linked to jpeglib -- can't load jpeg image data!\n" ); #else image::rgb *im = image::read_jpeg ( file_name.c_str() ); if ( im ) { bitmap_info *bi = render::create_bitmap_info_rgb ( im ); delete im; movie_definition *rdef = get_root()->get_movie_definition(); assert ( rdef ); bitmap_character *jpeg = new bitmap_character ( rdef, bi ); return target->replace_me ( jpeg ); } #endif break; } } return NULL; }