void VRSnappingEngine::addTree(VRObject* obj, float weight) { vector<VRObject*> objs = obj->getObjectListByType("Geometry"); for (auto o : objs) addObject((VRTransform*)o, weight); }
Object* ObjectsPool::addObjectbyName(const string& obj, Sint16 x, Sint16 y, const ParameterMap& objparam, bool outside) { ParameterMap parameters; if (hasParam(objparam,"file")) { parameters=getFileParameters(objparam.find("file")->second); ParameterMap::const_iterator it=objparam.begin(); while (it!=objparam.end()) { if (it->first!="file") parameters[it->first]=it->second; ++it; } } else { parameters=objparam; } //Set names... if (!hasParam(parameters,"name")) parameters["name"]=getNextObjectName(obj); if (obj=="Wall") return (addObject(new Wall(x,y,parameters), outside)); else if (obj=="Exit") return (addObject(new Exit(x,y,parameters), outside)); else if (obj=="Water") return (addObject(new Water(x,y,parameters), outside)); else if (obj=="Teleporter") return (addObject(new Teleporter(x,y,parameters), outside)); else if (obj=="Wind") return (addObject(new Wind(x,y,parameters), outside)); else if (obj=="Geyser") return (addObject(new Geyser(x,y,parameters), outside)); else if (obj=="Trigger") return (addObject(new Trigger(x,y,parameters), outside)); else if (obj=="Door") return (addObject(new Door(x,y,parameters), outside)); else if (obj=="Spike") return (addObject(new Spike(x,y,parameters), outside)); else if (obj=="Heart") return (addObject(new Heart(x,y,parameters), outside)); else if (obj=="Key") return (addObject(new Key(x,y,parameters), outside)); else if (obj=="Bomb") return (addObject(new Bomb(x,y,parameters), outside)); else if (obj=="TriggeredBomb") return (addObject(new TriggeredBomb(x,y,parameters), outside)); else if (obj=="DeadPlayer") return (addObject(new DeadPlayer(x,y,parameters), outside)); else if (obj=="Erik") return (addObject(new Erik(x,y,parameters), outside)); else if (obj=="Olaf") return (addObject(new Olaf(x,y,parameters), outside)); else if (obj=="Baleog") return (addObject(new Baleog(x,y,parameters), outside)); else if (obj=="Fang") return (addObject(new Fang(x,y,parameters), outside)); else if (obj=="Scorch") return (addObject(new Scorch(x,y,parameters), outside)); else if (obj=="Plant") return (addObject(new Plant(x,y,parameters), outside)); else if (obj=="Zombie") return (addObject(new Zombie(x,y,parameters), outside)); else { cout << "Object " << obj << " unknown, skipping...\n"; return NULL; } }
void Scn_Test::Init() { m_screenArea = new Sprite; m_screenArea->CreateTexture(L"Resource/ScreenArea.png"); m_screenArea->SetPosition(D3DXVECTOR2(100, 100)); m_screenArea->SetanchorPoint(D3DXVECTOR2(0.f, 0.f)); addObject(m_screenArea); m_Sound = new SoundPlayer; m_noteNum = new GraphicFont(16); m_noteNum->CreateTexture(L"Resource/Num.png"); m_noteNum->SetValue(0); m_noteNum->SetPosition(D3DXVECTOR2(620,15)); addObject(m_noteNum); m_whatNoteNum = new AVString; m_whatNoteNum->SetText(L"Note Total Number : "); m_whatNoteNum->SetRect(AVRECT(370,00,300,50)); addObject(m_whatNoteNum); m_noteMax = 0; SharedTexture2D::GetsharedTexture2D()->addFile(L"Resource/Judgment_1_1.png", IMG_JUD_1_1); SharedTexture2D::GetsharedTexture2D()->addFile(L"Resource/Judgment_1_2.png", IMG_JUD_1_2); SharedTexture2D::GetsharedTexture2D()->addFile(L"Resource/Note.png", IMG_NOTE); SharedTexture2D::GetsharedTexture2D()->addFile(L"Resource/Num.png", IMG_GRAPHIC_NUM); for(int i=0; i<SCREEN_NOTE_MAX; i++) { m_Jud[i].Init(); addObject(&m_Jud[i]); } for(int i=0; i<SCREEN_NOTE_MAX*2; i++) { m_Note[i].Create(SharedTexture2D::GetsharedTexture2D()->GetTexture2D(IMG_NOTE), SharedTexture2D::GetsharedTexture2D()->GetTexture2D(IMG_GRAPHIC_NUM)); m_Note[i].SetisMod(true); addObject( &m_Note[i] ); } m_Interface = new NoteInterface; m_countString = new AVString; m_countString->SetText(L"Play Count :"); m_countString->SetRect(AVRECT(-20,0,200,50)); addObject(m_countString); m_PlayCount = new GraphicFont(16); m_PlayCount->CreateTexture(L"Resource/Num.png"); m_PlayCount->SetPosition(D3DXVECTOR2(145,15)); m_PlayCount->SetValue(5); addObject(m_PlayCount); m_vStartPosition = D3DXVECTOR2(0,0); sprite.CreateTexture(L"Resource/Sun.png"); sprite.SetanchorPoint(D3DXVECTOR2(0.5f, 0.5f)); sprite.SetPosition(D3DXVECTOR2(0.f, 0.f)); // sprite.Action(&RotateAction(30.f, AV_DI(360),AV_TO)); sprite.Actions(OPTION(ACT_SEQUENCE,1),&RotateAction(30.f, AV_DI(360),AV_TO),NULL); addObject(&sprite); }
void DrasculaEngine::doTalkSequenceCommand(TalkSequenceCommand cmd) { switch (cmd.commandType) { case kPause: pause(cmd.action); break; case kSetFlag: flags[cmd.action] = 1; break; case kClearFlag: flags[cmd.action] = 0; break; case kPickObject: pickObject(cmd.action); break; case kAddObject: addObject(cmd.action); break; case kBreakOut: breakOut = 1; break; case kConverse: converse(cmd.action); break; case kPlaceVB: placeVonBraun(cmd.action); break; case kUpdateRoom: updateRoom(); break; case kUpdateScreen: updateScreen(); break; case kTrackProtagonist: trackProtagonist = cmd.action; break; case kPlaySound: playSound(cmd.action); break; case kFinishSound: finishSound(); break; case kTalkerGeneral: talk(cmd.action); break; case kTalkerDrunk: talk_drunk(cmd.action); break; case kTalkerPianist: talk_pianist(cmd.action); break; case kTalkerBJ: talk_bj(cmd.action); break; case kTalkerVBNormal: talk_vonBraun(cmd.action, kVonBraunNormal); break; case kTalkerVBDoor: talk_vonBraun(cmd.action, kVonBraunDoor); break; case kTalkerIgorSeated: talk_igor(cmd.action, kIgorSeated); break; case kTalkerWerewolf: talk_werewolf(cmd.action); break; case kTalkerMus: talk_mus(cmd.action); break; case kTalkerDrascula: talk_drascula(cmd.action, 1); break; case kTalkerBartender0: talk_bartender(cmd.action, 0); break; case kTalkerBartender1: talk_bartender(cmd.action, 1); break; default: error("doTalkSequenceCommand: Unknown command: %d", cmd.commandType); } }
void JsonDbReduceDefinition::updateObject(JsonDbObject before, JsonDbObject after, JsonDbUpdateList *changeList) { initScriptEngine(); QJsonValue beforeKeyValue = sourceKeyValue(before); QJsonValue afterKeyValue = sourceKeyValue(after); if (jsondbSettings->debug()) qDebug() << "JsonDbReduceDefinition::updateObject" << "beforeKeyValue" << beforeKeyValue << "afterKeyValue" << afterKeyValue; if (!after.isEmpty() && !after.isDeleted() && !before.isEmpty() && (beforeKeyValue != afterKeyValue)) { // do a subtract only on the before key if (!beforeKeyValue.isUndefined()) updateObject(before, QJsonObject(), changeList); // and then continue here with the add with the after key before = QJsonObject(); } const QJsonValue keyValue((after.isEmpty() || after.isDeleted()) ? beforeKeyValue : afterKeyValue); if (keyValue.isUndefined()) return; GetObjectsResult getObjectResponse = mTargetTable->getObjects(mTargetKeyName, keyValue, mTargetType); if (!getObjectResponse.error.isNull()) setError(getObjectResponse.error.toString()); JsonDbObject previousObject; QJsonValue previousValue(QJsonValue::Undefined); JsonDbObjectList previousResults = getObjectResponse.data; for (int k = 0; k < previousResults.size(); ++k) { JsonDbObject previous = previousResults.at(k); if (previous.value(QStringLiteral("_reduceUuid")).toString() == mUuid) { previousObject = previous; previousValue = previousObject; break; } } QJsonValue value = previousValue; if (!before.isEmpty()) value = addObject(JsonDbReduceDefinition::Subtract, keyValue, value, before); if (!after.isEmpty() && !after.isDeleted()) value = addObject(JsonDbReduceDefinition::Add, keyValue, value, after); JsonDbObjectList objectsToUpdate; // if we had a previous object to reduce if (previousObject.contains(JsonDbString::kUuidStr)) { // and now the value is undefined if (value.isUndefined()) { // then remove it previousObject.markDeleted(); objectsToUpdate.append(previousObject); } else { //otherwise update it JsonDbObject reduced(value.toObject()); reduced.insert(JsonDbString::kTypeStr, mTargetType); reduced.insert(JsonDbString::kUuidStr, previousObject.value(JsonDbString::kUuidStr)); reduced.insert(JsonDbString::kVersionStr, previousObject.value(JsonDbString::kVersionStr)); reduced.insert(mTargetKeyName, keyValue); reduced.insert(QStringLiteral("_reduceUuid"), mUuid); objectsToUpdate.append(reduced); } } else if (!value.isUndefined()) { // otherwise create the new object JsonDbObject reduced(value.toObject()); reduced.insert(JsonDbString::kTypeStr, mTargetType); reduced.insert(mTargetKeyName, keyValue); reduced.insert(QStringLiteral("_reduceUuid"), mUuid); objectsToUpdate.append(reduced); } JsonDbWriteResult res = mPartition->updateObjects(mOwner, objectsToUpdate, JsonDbPartition::ViewObject, changeList); if (res.code != JsonDbError::NoError) setError(QString::fromLatin1("Error executing add function: %1").arg(res.message)); }
void Library::addLibrary(void *buf, size_t buflen) { addObject(NULL, buf, buflen); }
/// Add a reference to render an object (wrapper). /// /// \param object Object to queue for rendering. /// \param state Animation state to use. /// \param transform Object transformation. /// \param pass Render pass id. void addObject(const Object &object, const mat4 &transform, const AnimationState &state, unsigned pass = 0) { addObject(object, transform, pass, true, &state); }
bool Scene::readXml(TiXmlElement* e) { string objName; TiXmlElement* child = e->FirstChildElement(); while(child != NULL) { if(child->ValueStr() == "pixel") { if((objName = Xml::getAttrString(child, "name")) != "") { LOG_DEBUG << "Scene \"" << _name << "\": Loading pixel \"" << objName << "\"" << std::endl; Pixel* p = new Pixel(objName); p->loadXml(child); addObject(p); } else { LOG_WARN << "Scene \"" << _name << "\": cannot load pixel without name, line " << child->Row() << endl; } } else if(child->ValueStr() == "line") { if((objName = Xml::getAttrString(child, "name")) != "") { LOG_DEBUG << "Scene \"" << _name << "\": Loading line \"" << objName << "\"" << std::endl; Line* l = new Line(objName); l->loadXml(child); addObject(l); } else { LOG_WARN << "Scene \"" << _name << "\": cannot load line without name, line " << child->Row() << endl; } } else if(child->ValueStr() == "rect") { if((objName = Xml::getAttrString(child, "name")) != "") { LOG_DEBUG << "Scene \"" << _name << "\": Loading rect \"" << objName << "\"" << std::endl; Rect* r = new Rect(objName); r->loadXml(child); addObject(r); } else { LOG_WARN << "Scene \"" << _name << "\": cannot load rect without name, line " << child->Row() << endl; } } else if(child->ValueStr() == "bitmap") { if((objName = Xml::getAttrString(child, "name")) != "") { LOG_DEBUG << "Scene \"" << _name << "\": Loading bitmap \"" << objName << "\"" << std::endl; Bitmap* b = new Bitmap(objName); b->loadXml(child); addObject(b); } else { LOG_WARN << "Scene \"" << _name << "\": cannot load bitmap without name, line " << child->Row() << endl; } } else if(child->ValueStr() == "sprite") { if((objName = Xml::getAttrString(child, "name")) != "") { LOG_DEBUG << "Scene \"" << _name << "\": Loading sprite \"" << objName << "\"" << std::endl; Sprite* s = new Sprite(objName); s->loadXml(child); addObject(s); } else { LOG_WARN << "Scene \"" << _name << "\": cannot load sprite without name, line " << child->Row() << endl; } } else if(child->ValueStr() == "image") { if((objName = Xml::getAttrString(child, "name")) != "") { LOG_DEBUG << "Scene \"" << _name << "\": Loading image \"" << objName << "\"" << std::endl; Image* i = new Image(objName); i->loadXml(child); addObject(i); } else { LOG_WARN << "Scene \"" << _name << "\": cannot load image without name, line " << child->Row() << endl; } } else if(child->ValueStr() != "background") { LOG_WARN << "Scene \"" << _name << "\": ignoring unknown element \"" << child->ValueStr() << "\"" << endl; } child = child->NextSiblingElement(); } return true; }
/* QGUISkin */ QGUISkin::QGUISkin(plCreatable* pCre, QWidget* parent) : QCreatable(pCre, kGUISkin, parent), fCurElement(-1) { pfGUISkin* skin = pfGUISkin::Convert(fCreatable); fItemMargin = new QIntEdit(this); fItemMargin->setRange(0, 0xFFFF); fItemMargin->setValue(skin->getItemMargin()); fBorderMargin = new QIntEdit(this); fBorderMargin->setRange(0, 0xFFFF); fBorderMargin->setValue(skin->getBorderMargin()); fTexture = new QCreatableLink(this); fTexture->setKey(skin->getTexture()); fTexture->setText(skin->getTexture().Exists() ? ~skin->getTexture()->getName() : "(None)"); fElements = new QComboBox(this); fElements->addItems(QStringList() << tr("Upper-Left Corner") << tr("Top Span") << tr("Upper-Right Corner") << tr("Right Span") << tr("Lower-Right Corner") << tr("Bottom Span") << tr("Lower-Left Corner") << tr("Left Span") << tr("Middle Fill") << tr("Selection Fill") << tr("Submenu Arrow") << tr("Selected Submenu Arrow") << tr("Tree Button Closed") << tr("Tree Button Open")); QGroupBox* grpElement = new QGroupBox(tr("Element Texture Source"), this); fX = new QIntEdit(grpElement); fX->setRange(0, 0xFFFF); fY = new QIntEdit(grpElement); fY->setRange(0, 0xFFFF); fWidth = new QIntEdit(grpElement); fWidth->setRange(0, 0xFFFF); fHeight = new QIntEdit(grpElement); fHeight->setRange(0, 0xFFFF); setElement(0); QGridLayout* layElement = new QGridLayout(grpElement); layElement->setContentsMargins(8, 8, 8, 8); layElement->setHorizontalSpacing(4); layElement->setVerticalSpacing(4); layElement->addWidget(new QLabel("X", grpElement), 0, 1, 1, 1, Qt::AlignCenter); layElement->addWidget(new QLabel("Y", grpElement), 0, 2, 1, 1, Qt::AlignCenter); layElement->addWidget(new QLabel("Position:", grpElement), 1, 0); layElement->addWidget(new QLabel("Size:", grpElement), 2, 0); layElement->addWidget(fX, 1, 1); layElement->addWidget(fY, 1, 2); layElement->addWidget(fWidth, 2, 1); layElement->addWidget(fHeight, 2, 2); QGridLayout* layout = new QGridLayout(this); layout->setContentsMargins(8, 8, 8, 8); layout->addWidget(new QLabel(tr("Item Margin:"), this), 0, 0); layout->addWidget(fItemMargin, 0, 1); layout->addWidget(new QLabel(tr("Border:"), this), 1, 0); layout->addWidget(fBorderMargin, 1, 1); layout->addWidget(new QLabel(tr("Texture:"), this), 2, 0); layout->addWidget(fTexture, 2, 1); layout->addItem(new QSpacerItem(0, 16, QSizePolicy::Minimum, QSizePolicy::Minimum), 3, 0, 1, 2); layout->addWidget(new QLabel(tr("Element:"), this), 4, 0); layout->addWidget(fElements, 4, 1); layout->addWidget(grpElement, 5, 0, 1, 2); connect(fTexture, SIGNAL(addObject()), this, SLOT(setTexture())); connect(fTexture, SIGNAL(delObject()), this, SLOT(unsetTexture())); connect(fElements, SIGNAL(currentIndexChanged(int)), this, SLOT(setElement(int))); }
void process_keys() { if (game.cooldown <= 0) { scanKeys(); u32 keys = keysHeld(); u32 down = keysDown(); touchPosition touch = touchReadXY(); if (down & KEY_START) { new_game(); return; } if (down & KEY_SELECT) { test_map(); torch.buf.scroll.x = game.player.x - 16; torch.buf.scroll.y = game.player.y - 12; torch.buf.bounded(torch.buf.scroll.x, torch.buf.scroll.y); torch.dirty_screen(); torch.reset_luminance(); return; } if (down & KEY_X) { inventory(); return; } if (down & KEY_L) { overview(); return; } if (down & KEY_TOUCH && touch.px != 0 && touch.py != 0) { if (!(keys & KEY_R) && game.player.projectile) { game.player.chuck(torch.buf.scroll.x + touch.px/8, torch.buf.scroll.y + touch.py/8); } return; } if (down & KEY_R) { printf("Saving... "); fflush(stdout); game.save("blah.adrift"); printf("done\n"); printf("Loading... "); fflush(stdout); game.load("blah.adrift"); printf("done\n"); } if (keys & KEY_Y) { if (get_items()) return; } DIRECTION dir = 0; if (keys & KEY_RIGHT) dir |= D_EAST; else if (keys & KEY_LEFT) dir |= D_WEST; if (keys & KEY_DOWN) dir |= D_SOUTH; else if (keys & KEY_UP) dir |= D_NORTH; if (dir) { game.player.moveDir(dir, keys & KEY_B); return; } if (down & KEY_A) { seek_and_destroy(); if (!game.player.target) { // no monsters in range for (int x = game.player.x-1; x <= game.player.x+1; x++) { for (int y = game.player.y-1; y <= game.player.y+1; y++) { Object *o = game.map.at(x,y)->objects.head(); if (!o) continue; if (o->type == VENDING_MACHINE) { if (game.player.x == x+D_DX[o->orientation] && game.player.y == y+D_DY[o->orientation]) { iprintf("You kick the vending machine. "); if (o->quantity > 0 && rand4() < 5) { if (rand4() & 1) { iprintf("Clunk! A can rolls out.\n"); addObject(game.player.x, game.player.y, CAN_OF_STEWED_BEEF); } else { iprintf("Clunk! A bottle rolls out.\n"); addObject(game.player.x, game.player.y, BOTTLE_OF_WATER); } o->quantity--; } else { iprintf("Nothing happens.\n"); } game.cooldown += 5; } } } } } else return; } if (keys & KEY_A) { seek_and_destroy(); return; } } else if (game.cooldown > 0) game.cooldown--; }
void addDirStepOsc(MidiMap midi, int stepPin, int directionPin, int enableShiftPin, int stepDirCC) { DirStepOsc *o = new DirStepOsc(); initDirStepOsc(o, stepPin, directionPin, enableShiftPin, stepDirCC); addObject(midi, o, (tickFn)tickDirStepOsc, (noteOnFn)playDirStepOsc, (noteOffFn)stopDirStepOsc, (ccFn)ccDirStepOsc); }
Options::Options() { btn_back.setFunction([]() {game.switchToScene(scene_num::mainmenu);}); addObject(&btn_back); }
/// Add objects from an object database, constructing at limits. /// /// \param db Database. /// \param pos Position to render from. /// \param fw Collect objects that have bounding box lying in area this much forward. /// \param bk Collect objects that have bounding box lying in area this much backward. /// \param interp Fade-in interpolation range (<=0 to disable). /// \param pass Render pass id. void addObjectDatabaseConstructing(const ObjectDatabase &db, const vec3 &pos, float fw, float bk, float fade = 0.0f, unsigned pass = 0) { unsigned mid = db.find(pos[2]); #if defined(USE_LD) if((fade >= fw) || (fade >= bk)) { std::ostringstream sstr; sstr << "fade-in range " << fade << " must be smaller than advance ranges " << vec2(bk, fw); BOOST_THROW_EXCEPTION(std::runtime_error(sstr.str())); } #endif // Forward. { float limit = pos[2] + fw; for(unsigned ii = mid; (ii < db.getObjectCount()); ++ii) { const Object &obj = db.getObject(ii); float cmp = obj.getBoundingVolume().getMinZ(); if(cmp <= limit) { float diff = limit - cmp; if(diff <= fade) { mat4 aa = obj.unpackTransform(m_frame); mat4 bb = randomOffsetTransform(aa, obj.getCenter(), ii, diff / fade); addObject(obj, bb, pass, false); } else { addObject(obj, pass); } } else if(cmp - fade > limit) { break; } } } if(mid > 0) { float limit = pos[2] - bk; unsigned ii = mid - 1; for(;;) { const Object &obj = db.getObject(ii); float cmp = obj.getBoundingVolume().getMaxZ(); if(cmp >= limit) { float diff = cmp - limit; if(diff <= fade) { //std::cout << "cmp " << cmp << " versus limit " << limit << ", diff: " << diff << std::endl << // obj.getBoundingVolume() << std::endl; mat4 aa = obj.unpackTransform(m_frame); mat4 bb = randomOffsetTransform(aa, obj.getCenter(), ii, diff / fade); addObject(obj, bb, pass, false); } else { addObject(obj, pass); } } else if(cmp + fade < limit) { break; } if(0 >= ii) { break; } --ii; } } }
/// Add a reference to render an object (wrapper). /// /// \param object Object to queue for rendering. /// \param state Animation state to use. /// \param pass Render pass id. void addObject(const Object &object, const AnimationState &state, unsigned pass = 0) { addObject(object, object.unpackTransform(m_frame), state, pass); }
Scripting::Scripting() : _ctx{[](){ PythonQtInit(); return PythonQt::self()->getMainModule(); }()} { state->scripting = this; PythonQt::self()->registerClass(&EmitOnCtorDtor::staticMetaObject); evalScript("import sys"); evalScript("sys.argv = ['']"); // <- this is needed to import the ipython module from the site-package #ifdef Q_OS_OSX // as ipython does not export it's sys paths after the installation we refer to that site-package evalScript("sys.path.append('/Library/Python/2.7/site-packages')"); #endif PythonQt::self()->createModuleFromScript(SCRIPTING_KNOSSOS_MODULE); evalScript(QString("import %1").arg(SCRIPTING_KNOSSOS_MODULE)); evalScript(QString("%1.%2 = {}").arg(SCRIPTING_KNOSSOS_MODULE).arg(SCRIPTING_PLUGIN_CONTAINER)); addObject("signalRelay", state->signalRelay); addObject("knossos", &pythonProxy); addObject("scripting", this); addObject("segmentation", &segmentationProxy); addObject("skeleton", &skeletonProxy); addObject("knossos_global_viewer", state->viewer); addObject("knossos_global_mainwindow", state->viewer->window); addObject("knossos_global_skeletonizer", &Skeletonizer::singleton()); addObject("knossos_global_segmentation", &Segmentation::singleton()); addObject("knossos_global_loader", &Loader::Controller::singleton()); addVariable("GL_POINTS", GL_POINTS); addVariable("GL_LINES", GL_LINES); addVariable("GL_LINE_STRIP", GL_LINE_STRIP); addVariable("GL_LINE_LOOP", GL_LINE_LOOP); addVariable("GL_TRIANGLES", GL_TRIANGLES); addVariable("GL_TRIANGLES_STRIP", GL_TRIANGLE_STRIP); addVariable("GL_TRIANGLE_FAN", GL_TRIANGLE_FAN); addVariable("GL_QUADS", GL_QUADS); addVariable("GL_QUAD_STRIP", GL_QUAD_STRIP); addVariable("GL_POLYGON", GL_POLYGON); addWidgets(); auto makeDecorator = [](QObject * decorator, const char * typeName){ // PythonQt tries to reparent the decorators, we do their missing work of pushing it into their thread first // due to the QObject handling they also get deleted by PythonQt then decorator->moveToThread(PythonQt::self()->thread()); PythonQt::self()->addDecorators(decorator); PythonQt::self()->registerCPPClass(typeName, "", "internal"); }; makeDecorator(new CoordinateDecorator, "Coordinate"); makeDecorator(new FloatCoordinateDecorator, "floatCoordinate"); makeDecorator(new NodeListDecorator, "Node"); makeDecorator(new SegmentListDecorator, "Segment"); makeDecorator(new TreeListDecorator, "Tree"); createDefaultPluginDir(); addPythonPath(getPluginDir()); addPresetCustomPythonPaths(); #ifdef Q_OS_LINUX //in linux there’s an explicit symlink to a python 2 binary _ctx.evalFile(QString("sys.path.append('%1')").arg("./python2")); #else _ctx.evalFile(QString("sys.path.append('%1')").arg("./python")); #endif changeWorkingDirectory(); executeResourceStartup(); executeFromUserDirectory(); QObject::connect(&state->scripting->pythonProxy, &PythonProxy::viewport_snapshot, &state->viewer->window->widgetContainer.snapshotWidget, &SnapshotWidget::snapshotRequest); state->viewer->window->widgetContainer.pythonInterpreterWidget.startConsole(); }
bool GendatChecker::compute() { #if 0 vistle::Vec<vistle::Scalar> *a = vistle::Vec<vistle::Scalar>::create(); for (unsigned int index = 0; index < 1024 * 1024 * 4; index ++) a->x->push_back(index); /* vistle::Vec3<int> *b = vistle::Vec3<int>::create(16); for (unsigned int index = 0; index < b->getSize(); index ++) { b->x[index] = index; b->y[index] = index; b->z[index] = index; } */ #endif vistle::Object::const_ptr grid = takeFirstObject("grid_in"); vistle::Object::const_ptr data = takeFirstObject("data_in"); vistle::Triangles::const_ptr t = expect<vistle::Triangles>("grid_in"); vassert(t.get() && "expected Triangles"); //vassert(t->cl().size() == 6); vassert(t->cl()[0] == 0); vassert(t->cl()[1] == 1); vassert(t->cl()[2] == 2); vassert(t->cl()[3] == 0); vassert(t->cl()[4] == 2); vassert(t->cl()[5] == 3); //vassert(t->x().size() == 4); //vassert(t->y().size() == 4); //vassert(t->z().size() == 4); for(size_t i=0; i<4; ++i) { vassert(t->x()[i] == 1. + rank()); vassert(t->y()[i] == 0.); vassert(t->z()[i] == 0.); } vistle::Vec<vistle::Scalar>::const_ptr v = expect<vistle::Vec<vistle::Scalar>>("data_in"); vassert(v.get() && "expected Vec<Scalar>"); //vassert(v->x().size() == 4); for (size_t i=0; i<4; ++i) { vassert(v->x()[i] == vistle::Scalar(i)); } #if 0 vistle::Triangles *t = new vistle::Triangles(6, 4); t->cl()[0] = 0; t->cl()[1] = 1; t->cl()[2] = 2; t->cl()[3] = 0; t->cl()[4] = 2; t->cl()[5] = 3; t->x()[0] = 0.0 + rank; t->y()[0] = 0.0; t->z()[0] = 0.0; t->x()[1] = 1.0 + rank; t->y()[1] = 0.0; t->z()[1] = 0.0; t->x()[2] = 1.0 + rank; t->y()[2] = 1.0; t->z()[2] = 0.0; t->x()[3] = 0.0 + rank; t->y()[3] = 1.0; t->z()[3] = 0.0; addObject("grid_out", t); vistle::Vec<vistle::Scalar> *v = new vistle::Vec<vistle::Scalar>(4); v->x()[0] = 1.; v->x()[1] = 2.; v->x()[2] = 3.; v->x()[3] = 4.; addObject("data_out", v); #endif return true; }
void Scene::addFocusedObject(Drawable * obj) { addObject(obj); focusedObjects.push_back(obj); }
bool DrasculaEngine::runCurrentChapter() { int n; rightMouseButton = 0; previousMusic = -1; if (currentChapter != 2) { int soc = 0; for (n = 0; n < 6; n++) { soc = soc + CHARACTER_WIDTH; _frameX[n] = soc; } } for (n = 1; n < ARRAYSIZE(inventoryObjects); n++) inventoryObjects[n] = 0; for (n = 0; n < NUM_FLAGS; n++) flags[n] = 0; if (currentChapter == 2) { flags[16] = 1; flags[17] = 1; flags[27] = 1; } for (n = 1; n < 7; n++) inventoryObjects[n] = n; if (currentChapter == 1) { pickObject(28); if (loadedDifferentChapter == 0) animation_1_1(); selectVerb(kVerbNone); loadPic("2aux62.alg", drawSurface2); trackProtagonist = 1; objExit = 104; if (loadedDifferentChapter != 0) { if (!loadGame(saveName)) { return true; } } else { enterRoom(62); curX = -20; curY = 56; gotoObject(65, 145); } } else if (currentChapter == 2) { addObject(kItemPhone); trackProtagonist = 3; objExit = 162; if (loadedDifferentChapter == 0) enterRoom(14); else { if (!loadGame(saveName)) { return true; } } } else if (currentChapter == 3) { addObject(kItemPhone); addObject(kItemEarplugs); addObject(kItemSickle); addObject(kItemHandbag); addObject(kItemCross); addObject(kItemReefer); addObject(kItemOneCoin); flags[1] = 1; trackProtagonist = 1; objExit = 99; if (loadedDifferentChapter == 0) enterRoom(20); else { if (!loadGame(saveName)) { return true; } } // From here onwards the items have different IDs } else if (currentChapter == 4) { addObject(kItemPhone2); addObject(kItemCross2); addObject(kItemReefer2); addObject(kItemOneCoin2); objExit = 100; if (loadedDifferentChapter == 0) { enterRoom(21); trackProtagonist = 0; curX = 235; curY = 164; } else { if (!loadGame(saveName)) { return true; } } } else if (currentChapter == 5) { addObject(28); addObject(7); addObject(9); addObject(11); addObject(13); addObject(14); addObject(15); addObject(17); addObject(20); trackProtagonist = 1; objExit = 100; if (loadedDifferentChapter == 0) { enterRoom(45); } else { if (!loadGame(saveName)) { return true; } } } else if (currentChapter == 6) { addObject(28); addObject(9); trackProtagonist = 1; objExit = 104; if (loadedDifferentChapter == 0) { enterRoom(58); animation_1_6(); } else { if (!loadGame(saveName)) { return true; } loadPic("auxdr.alg", drawSurface2); } } showCursor(); while (!shouldQuit()) { if (characterMoved == 0) { stepX = STEP_X; stepY = STEP_Y; } if (characterMoved == 0 && walkToObject == 1) { trackProtagonist = trackFinal; walkToObject = 0; } if (currentChapter == 2) { // NOTE: the checks for room number 14 below are a hack used in the original // game, and move the character to a place where his feet are not drawn above // the pianist's head. Originally, walkToObject was not updated properly, which // lead to an incorrect setting of the protagonist's tracking flag (above). This // made the character start walking off screen, as his actual position was // different than the displayed one if (roomNumber == 3 && (curX == 279) && (curY + curHeight == 101)) { gotoObject(178, 121); gotoObject(169, 135); } else if (roomNumber == 14 && (curX == 214) && (curY + curHeight == 121)) { walkToObject = 1; gotoObject(190, 130); } else if (roomNumber == 14 && (curX == 246) && (curY + curHeight == 112)) { walkToObject = 1; gotoObject(190, 130); } } moveCursor(); updateScreen(); if (currentChapter == 2) { if (musicStatus() == 0 && roomMusic != 0) playMusic(roomMusic); } else { if (musicStatus() == 0) playMusic(roomMusic); } delay(25); #ifndef _WIN32_WCE // FIXME // This and the following #ifndefs disable the excess updateEvents() calls *within* the game loop. // Events such as keypresses or mouse clicks are dropped on the ground with no processing // by these calls. They are properly handled by the implicit call through getScan() below. // It is not a good practice to not process events and indeed this created problems with synthesized // events in the wince port. updateEvents(); #endif if (!_menuScreen && takeObject == 1) checkObjects(); #ifdef _WIN32_WCE if (rightMouseButton) { if (_menuScreen) { #else if (rightMouseButton == 1 && _menuScreen) { #endif rightMouseButton = 0; delay(100); if (currentChapter == 2) { loadPic(menuBackground, cursorSurface); loadPic(menuBackground, backSurface); } else { loadPic(99, cursorSurface); loadPic(99, backSurface); } setPalette((byte *)&gamePalette); _menuScreen = false; #ifndef _WIN32_WCE // FIXME: This call here is in hope that it will catch the rightmouseup event so the // next if block won't be executed. This too is not a good coding practice. I've recoded it // with a mutual exclusive if block for the menu. I would commit this properly but I cannot test // for other (see Desktop) ports right now. updateEvents(); #endif #ifdef _WIN32_WCE } else { #else } // Do not show the inventory screen in chapter 5, if the right mouse button is clicked // while the plug (object 16) is held // Fixes bug #2059621 - "DRASCULA: Plug bug" if (rightMouseButton == 1 && !_menuScreen && !(currentChapter == 5 && pickedObject == 16)) { #endif rightMouseButton = 0; delay(100); characterMoved = 0; if (trackProtagonist == 2) trackProtagonist = 1; if (currentChapter == 4) { loadPic("icons2.alg", backSurface); loadPic("icons2.alg", cursorSurface); } else if (currentChapter == 5) { loadPic("icons3.alg", backSurface); loadPic("icons3.alg", cursorSurface); } else if (currentChapter == 6) { loadPic("iconsp.alg", backSurface); loadPic("iconsp.alg", cursorSurface); } else { loadPic("icons.alg", backSurface); loadPic("icons.alg", cursorSurface); } _menuScreen = true; #ifndef _WIN32_WCE updateEvents(); #endif selectVerb(kVerbNone); } #ifdef _WIN32_WCE } #endif if (leftMouseButton == 1 && _menuBar) { delay(100); selectVerbFromBar(); } else if (leftMouseButton == 1 && takeObject == 0) { delay(100); if (verify1()) return true; } else if (leftMouseButton == 1 && takeObject == 1) { if (verify2()) return true; } _menuBar = (mouseY < 24 && !_menuScreen) ? true : false; Common::KeyCode key = getScan(); if (key == Common::KEYCODE_F1 && !_menuScreen) { selectVerb(kVerbLook); } else if (key == Common::KEYCODE_F2 && !_menuScreen) { selectVerb(kVerbPick); } else if (key == Common::KEYCODE_F3 && !_menuScreen) { selectVerb(kVerbOpen); } else if (key == Common::KEYCODE_F4 && !_menuScreen) { selectVerb(kVerbClose); } else if (key == Common::KEYCODE_F5 && !_menuScreen) { selectVerb(kVerbTalk); } else if (key == Common::KEYCODE_F6 && !_menuScreen) { selectVerb(kVerbMove); } else if (key == Common::KEYCODE_F9) { volumeControls(); } else if (key == Common::KEYCODE_F10) { if (!saveLoadScreen()) return true; } else if (key == Common::KEYCODE_F8) { selectVerb(kVerbNone); } else if (key == Common::KEYCODE_v) { _subtitlesDisabled = true; ConfMan.setBool("subtitles", !_subtitlesDisabled); print_abc(_textsys[2], 96, 86); updateScreen(); delay(1410); } else if (key == Common::KEYCODE_t) { _subtitlesDisabled = false; ConfMan.setBool("subtitles", !_subtitlesDisabled); print_abc(_textsys[3], 94, 86); updateScreen(); delay(1460); } else if (key == Common::KEYCODE_ESCAPE) { if (!confirmExit()) return false; } else if (key == Common::KEYCODE_TILDE || key == Common::KEYCODE_BACKQUOTE) { _console->attach(); _console->onFrame(); } else if (currentChapter == 6 && key == Common::KEYCODE_0 && roomNumber == 61) { loadPic("alcbar.alg", bgSurface, 255); } if (leftMouseButton != 0 || rightMouseButton != 0 || key != 0) if (currentChapter != 3) framesWithoutAction = 0; if (framesWithoutAction == 15000) { screenSaver(); if (currentChapter != 3) framesWithoutAction = 0; } if (currentChapter != 3) framesWithoutAction++; } return false; } bool DrasculaEngine::verify1() { int l; if (_menuScreen) removeObject(); else { for (l = 0; l < numRoomObjs; l++) { if (mouseX >= x1[l] && mouseY >= y1[l] && mouseX <= x2[l] && mouseY <= y2[l] && doBreak == 0) { if (exitRoom(l)) return true; if (doBreak == 1) break; } } if (mouseX > curX && mouseY > curY && mouseX < curX + curWidth && mouseY < curY + curHeight) doBreak = 1; for (l = 0; l < numRoomObjs; l++) { if (mouseX > x1[l] && mouseY > y1[l] && mouseX < x2[l] && mouseY < y2[l] && doBreak == 0) { roomX = roomObjX[l]; roomY = roomObjY[l]; trackFinal = trackObj[l]; doBreak = 1; walkToObject = 1; startWalking(); } } if (doBreak == 0) { roomX = CLIP(mouseX, floorX1, floorX2); roomY = CLIP(mouseY, floorY1 + feetHeight, floorY2); startWalking(); } doBreak = 0; } return false; }
void ConnectionPool::preparePool(const InetSocketAddress& key) { addObject(key); }
/// Add a reference to render an object (wrapper). /// /// \param object Object to queue for rendering. /// \param program Program to use for rendering. /// \param pass Render pass id. void addObject(const Object &object, unsigned pass = 0) { addObject(object, object.unpackTransform(m_frame), pass); }