void DataStoreFactory::createObjects(ObjectContainer * const container, std::vector<std::string> &names) { auto it = names.begin(); while( it != names.end() ) { std::string ext = File::getExtension(*it); if(m_gpkgSupported && compare(ext, DataStore::extension())) { std::string path = File::formFileName(container->path(), *it); addChild(container, ObjectPtr(new DataStore(container, *it, path))); it = names.erase(it); } else if(m_memSupported && compare(ext, MemoryStore::extension())) { std::string path = File::formFileName(container->path(), *it); addChild(container, ObjectPtr(new MemoryStore(container, *it, path))); it = names.erase(it); } else if(compare(ext, Dataset::attachmentsFolderExtension())) { it = names.erase(it); } else if(compare(ext, "xml") && (*it).find(DataStore::extension()) != std::string::npos) { it = names.erase(it); } else if(compare(ext, "xml") && (*it).find(MemoryStore::extension()) != std::string::npos) { it = names.erase(it); } else { ++it; } } }
void ConnectionFactory::createObjects(ObjectContainer * const container, std::vector<std::string> &names) { auto it = names.begin(); while( it != names.end() ) { std::string ext = File::getExtension(*it); if((m_wmsSupported || m_wfsSupported || m_ngwSupported) && compare(ext, Filter::extension(CAT_CONTAINER_NGW))) { std::string path = File::formFileName(container->path(), *it); enum ngsCatalogObjectType type = typeFromConnectionFile(path); if(Filter::isConnection(type)) { // Create object from connection addChild(container, ObjectPtr(new NGWConnection(container, *it, path))); it = names.erase(it); continue; } } else if(m_pgSupported && compare(ext, Filter::extension(CAT_CONTAINER_POSTGRES))) { std::string path = File::formFileName(container->path(), *it); enum ngsCatalogObjectType type = typeFromConnectionFile(path); if(Filter::isConnection(type)) { // TODO: Create object from connection // addChild(container, ObjectPtr(new DataStore(container, *it, path))); it = names.erase(it); continue; } } ++it; } }
//----------------------------------------------------------------------- ObjectPtr ObjectFactoryManager::createInstance(const Ogre::String& type) const { Factory<Object>* factory = findFactory(type); Object* object = factory->createInstance(); assert(object->getType() == type); return ObjectPtr(object, Factory<Object>::Deleter(factory)); }
void ColorChange::setup() { INFO("Creating a ColorChange ..."); if(colorMask & BLUE) color = "FlatBlue"; else if(colorMask & GREEN) color = "FlatGreen"; else if(colorMask & RED) color = "FlatRed"; else if(colorMask & GREY) color = "FlatGrey"; colorChange = ObjectPtr(new Object( LoadManager::getMesh("cube.obj"), MaterialManager::getMaterial(color))); RenderEngine::getRenderElement("regular")->addObject(colorChange); colorChange->scale(glm::vec3(.5, .5, .5)); colorChange->translate(position); setCollisionID(16); setCollideWithID(2); setCanCollide(true); setBoundingBox(BoundingBox(glm::vec3(.5f,.5f,.5f), glm::vec3(-.5f,-.5f,-.5f))); getBoundingBox()->setPosition(position); }
ObjectPtr jamoma_new(SymbolPtr s, AtomCount argc, AtomPtr argv) { int attrstart = attr_args_offset(argc, argv); int i = 0; int channelCount = 2; SymbolPtr className = gensym("gain"); MaxAudioGraphWrappedClassPtr classWrapper = NULL; char maxClassName[256]; if (!attrstart) { error("must specify a jamoma class as the first argument"); return NULL; } while (attrstart--) { if (atom_gettype(argv+i) == A_LONG) channelCount = atom_getlong(argv+i); else if (atom_gettype(argv+i) == A_SYM) className = atom_getsym(argv+i); i++; } snprintf(maxClassName, 256, "j.%s=", className->s_name); if (!s_jamoma_class_hash) s_jamoma_class_hash = hashtab_new(0); hashtab_lookup(s_jamoma_class_hash, className, (t_object**)&classWrapper); if (!classWrapper) { wrapAsMaxAudioGraph(className->s_name, maxClassName, &classWrapper); hashtab_store(s_jamoma_class_hash, className, ObjectPtr(classWrapper)); } return MaxAudioGraphWrappedClass_new(gensym(maxClassName), argc-1, argv+1); }
ObjectPtr Allocator::allocate() { unsigned int index = 0; for (CountedArray& carray : vec) { if (carray.used < BUCKET_SIZE) { // There is an opening, so use it (first fit) size_t curr = carray.next; for (;; curr = (curr + 1) % BUCKET_SIZE) { ObjectEntry& entry = carray.array[curr]; if (!entry.in_use) { carray.used++; carray.next = (curr + 1) % BUCKET_SIZE; entry.in_use = true; entry.index = index; entry.ref_count = 0; entry.object = Object(); return ObjectPtr(&entry.object); } } } ++index; } // No openings available anywhere, so rehash and move on vec.push_back(CountedArray()); return allocate(); //return new Object(); }
TTErr PackSetup(PackPtr self) { Atom a[2]; atom_setobj(a+0, ObjectPtr(self->audioGraphObject)); atom_setlong(a+1, 0); outlet_anything(self->audioGraphObjectOutlet, gensym("audio.connect"), 2, a); return kTTErrNone; }
TTErr PlugOutSetup(PlugOutPtr self) { Atom a[2]; atom_setobj(a+0, ObjectPtr(self->audioGraphObject)); atom_setlong(a+1, 0); outlet_anything(self->audioGraphOutlet, GENSYM("audio.connect"), 2, a); return kTTErrNone; }
ObjectPtr Object::fromValue(const mrb_value& self) { if (DATA_PTR(self)) { return *static_cast<ObjectPtr*>(DATA_PTR(self)); } else { return ObjectPtr(); } }
ObjectPtr Object::pointer() const { for(const auto& child : m_parent->getChildren()) { if(child.get() == this) { return child; } } return ObjectPtr(); }
ObjectPtr wrappedClass_new(SymbolPtr name, AtomCount argc, AtomPtr argv) { WrappedClass* wrappedMaxClass = NULL; WrappedInstancePtr self = NULL; TTValue v; TTErr err = kTTErrNone; TTUInt8 numInputs = 1; TTUInt8 numOutputs = 1; long attrstart = attr_args_offset(argc, argv); // support normal arguments // Find the WrappedClass hashtab_lookup(wrappedMaxClasses, name, (ObjectPtr*)&wrappedMaxClass); // If the WrappedClass has a validity check defined, then call the validity check function. // If it returns an error, then we won't instantiate the object. if (wrappedMaxClass) { if (wrappedMaxClass->validityCheck) err = wrappedMaxClass->validityCheck(wrappedMaxClass->validityCheckArgument); else err = kTTErrNone; } else err = kTTErrGeneric; if (!err) self = (WrappedInstancePtr)object_alloc(wrappedMaxClass->maxClass); if (self){ if (wrappedMaxClass->options && !wrappedMaxClass->options->lookup(TT("argumentDefinesNumInlets"), v)) { long argumentOffsetToDefineTheNumberOfInlets = v; if ((attrstart-argumentOffsetToDefineTheNumberOfInlets > 0) && argv+argumentOffsetToDefineTheNumberOfInlets) numInputs = atom_getlong(argv+argumentOffsetToDefineTheNumberOfInlets); } for (TTUInt16 i=numInputs-1; i>0; i--) self->inlets[i-1] = proxy_new(self, i, NULL); object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL)); // dumpout if (wrappedMaxClass->options && !wrappedMaxClass->options->lookup(TT("argumentDefinesNumOutlets"), v)) { long argumentOffsetToDefineTheNumberOfOutlets = v; if ((attrstart-argumentOffsetToDefineTheNumberOfOutlets > 0) && argv+argumentOffsetToDefineTheNumberOfOutlets) numOutputs = atom_getlong(argv+argumentOffsetToDefineTheNumberOfOutlets); } for (TTInt16 i=numOutputs-1; i>=0; i--) self->audioGraphOutlets[i] = outlet_new(self, "audio.connect"); self->wrappedClassDefinition = wrappedMaxClass; v.setSize(3); v.set(0, wrappedMaxClass->ttClassName); v.set(1, numInputs); v.set(2, numOutputs); err = TTObjectInstantiate(TT("audio.object"), (TTObjectPtr*)&self->audioGraphObject, v); attr_args_process(self, argc, argv); } return ObjectPtr(self); }
ObjectPtr Cell::GetObject(int index) { if (index >= 0 && index < _objects.size()) { auto o = _objects.begin(); for (int i = 0; i < index; ++i, ++o); return *(o); } return ObjectPtr(nullptr); }
TTErr MaxAudioGraphSetup(WrappedInstancePtr self) { Atom a[2]; TTUInt16 i=0; atom_setobj(a+0, ObjectPtr(self->audioGraphObject)); while (self->audioGraphOutlets[i]) { atom_setlong(a+1, i); outlet_anything(self->audioGraphOutlets[i], gensym("audio.connect"), 2, a); i++; } return kTTErrNone; }
void VectorSelector::editVector() { if (!selectedVector()) { return; // Don't crash when the user clicks the Edit vector button and there is no selected vector } else if (selectedVector()->provider()) { DialogLauncher::self()->showObjectDialog(selectedVector()->provider()); } else { QString vectorname; DialogLauncher::self()->showVectorDialog(vectorname, ObjectPtr(selectedVector()), true); } fillVectors(); // we might have just changed the name, so refill the combo. emit contentChanged(); }
void GroundPlane::setup(){ INFO("Creating the ground plane..."); plane = ObjectPtr(new Object( LoadManager::getMesh("plane.obj"), MaterialManager::getMaterial("FlatGrey"))); plane->translate(glm::vec3(0, 0, 0)); plane->rotate(90.0f, glm::vec3(-1, 0, 0)); plane->scale(glm::vec3(1, 1, 3)); RenderEngine::getRenderElement("regular")->addObject(plane); }
ObjectPtr load( const Path &path ) { // todo: use instream from filesystem //fs::File *f = fs::open( path, "r" ); std::ifstream f( path.c_str(), std::ios_base::in | std::ios_base::binary ); base::json::JSONReader reader; base::json::Parser parser; bool success = parser.parse( &f, &reader ); //fs::close(f); if(success) return reader.getRoot().asObject(); std::cout << "base::json(util)::load error parsing json\n"; return ObjectPtr(); }
tlx::CountingPtr<Subclass> GetOrCreate(Id object_id, Types&& ... construction) { auto it = map_.find(object_id); if (it != map_.end()) { die_unless(dynamic_cast<Subclass*>(it->second.get())); return tlx::CountingPtr<Subclass>( dynamic_cast<Subclass*>(it->second.get())); } // construct new object tlx::CountingPtr<Subclass> value = tlx::make_counting<Subclass>( std::forward<Types>(construction) ...); map_.insert(std::make_pair(object_id, ObjectPtr(value))); return value; }
ObjectPtr EventMonitorDialog::createNewDataObject() const { Q_ASSERT(_document && _document->objectStore()); EventMonitorEntryPtr eventMonitor = _document->objectStore()->createObject<EventMonitorEntry>(ObjectTag::fromString(tagString())); eventMonitor->setScriptCode(_eventMonitorTab->script()); eventMonitor->setEvent(_eventMonitorTab->event()); eventMonitor->setDescription(_eventMonitorTab->description()); eventMonitor->setLevel(_eventMonitorTab->logLevel()); eventMonitor->setLogKstDebug(_eventMonitorTab->logKstDebug()); eventMonitor->setLogEMail(_eventMonitorTab->logEMail()); eventMonitor->setLogELOG(_eventMonitorTab->logELOG()); eventMonitor->setEMailRecipients(_eventMonitorTab->emailRecipients()); eventMonitor->reparse(); eventMonitor->writeLock(); eventMonitor->update(0); eventMonitor->unlock(); return ObjectPtr(eventMonitor.data()); }
void *return_new(t_symbol *s, long argc, t_atom *argv) { long attrstart = attr_args_offset(argc, argv); t_return* x = (t_return *)object_alloc(return_class); t_symbol* name = _sym_nothing; ObjectPtr patcher = NULL; if (attrstart && argv) atom_arg_getsym(&name, 0, attrstart, argv); else name = symbol_unique(); // for instances buried inside of another object: // we pass a second argument which is a pointer to the patcher if (attrstart>1 && argv) patcher = ObjectPtr(atom_getobj(argv+1)); if (x) { x->outlets[k_outlet_dumpout] = outlet_new(x, 0L); object_obex_store((void *)x, _sym_dumpout, (t_object *)x->outlets[k_outlet_dumpout]); x->outlets[k_outlet_thru] = outlet_new(x, 0L); jcom_core_subscriber_new_extended(&x->common, name, jps_subscribe_return); atom_setsym(&x->output[0], name); x->output_len = 1; x->attrEnable = true; x->attrDataspace = jps_none; x->attrUnitNative = jps_none; if (patcher) x->common.container = patcher; attr_args_process(x, argc, argv); jcom_core_subscriber_subscribe((t_jcom_core_subscriber_common*)x); return_makesend(x); } return (x); }
bool TorusDeserializer::DeserializeToFrame(FramePtr frame, const TypeInfo& info, std::ostream& log) { if (info.TypeName != this->TokenName) { log << "[ERROR] " << TypeName << " deserializer passed an object not of type \"" << TokenName << "\". Object type was: \"" << info.TypeName.c_str() << "." << std::endl; return false; } Torus* torus = new Torus; ObjectPtr object = ObjectPtr(torus); bool is_static = true; bool errorbit = false; if (!GetReferenceFrame(torus->RefFrame, info, log)) errorbit = true; else is_static = torus->RefFrame.Velocity == ReferenceFrame::Default.Velocity; if (!GetPosition(torus->InitialPosition, is_static, info, log)) errorbit = true; if (!GetColour(torus->Colour, info, log)) errorbit = true; DESERIALIZE(RingRadius, "ring_radius", torus, info, log, errorbit); DESERIALIZE(Radius, "radius", torus, info, log, errorbit); if (!errorbit) { if (frame->Scene) frame->Scene->AddObject(object); } return !errorbit; }
ObjectPtr Create( sf::Uint16 id, sf::Packet& packet ) { return ObjectPtr( std::make_shared<T>( id, packet ) ); }
TTErr wrapAsMaxAudioGraph(TTSymbolPtr ttClassName, char* maxClassName, WrappedClassPtr* c, WrappedClassOptionsPtr options) { TTObject* o = NULL; TTValue v; TTUInt16 numChannels = 1; WrappedClass* wrappedMaxClass = NULL; common_symbols_init(); TTAudioGraphInit(); if(!wrappedMaxClasses) wrappedMaxClasses = hashtab_new(0); wrappedMaxClass = new WrappedClass; wrappedMaxClass->maxClassName = gensym(maxClassName); wrappedMaxClass->maxClass = class_new( maxClassName, (method)wrappedClass_new, (method)wrappedClass_free, sizeof(WrappedInstance), (method)0L, A_GIMME, 0); wrappedMaxClass->ttClassName = ttClassName; wrappedMaxClass->validityCheck = NULL; wrappedMaxClass->validityCheckArgument = NULL; wrappedMaxClass->options = options; wrappedMaxClass->maxAttrNamesToTTAttrNames = hashtab_new(0); // Create a temporary instance of the class so that we can query it. TTObjectInstantiate(ttClassName, &o, numChannels); o->getMessageNames(v); for(TTUInt16 i=0; i<v.getSize(); i++){ TTSymbolPtr name = NULL; v.get(i, &name); if(name == TT("updateMaxNumChannels") || name == TT("updateSr")) continue; // don't expose these attributes to Max users class_addmethod(wrappedMaxClass->maxClass, (method)wrappedClass_anything, (char*)name->getCString(), A_GIMME, 0); } o->getAttributeNames(v); for (TTUInt16 i=0; i<v.getSize(); i++) { TTSymbolPtr name = NULL; TTAttributePtr attr = NULL; SymbolPtr maxType = _sym_long; TTCString nameCString = NULL; SymbolPtr nameMaxSymbol = NULL; TTUInt32 nameSize = 0; v.get(i, &name); if(name == TT("maxNumChannels") || name == TT("processInPlace")) continue; // don't expose these attributes to Max users o->findAttribute(name, &attr); if (attr->type == kTypeFloat32) maxType = _sym_float32; else if (attr->type == kTypeFloat64) maxType = _sym_float64; else if (attr->type == kTypeSymbol || attr->type == kTypeString) maxType = _sym_symbol; // convert first letter to lower-case if it isn't already nameSize = name->getString().length(); nameCString = new char[nameSize+1]; strncpy_zero(nameCString, name->getCString(), nameSize+1); if (nameCString[0]>64 && nameCString[0]<91) nameCString[0] += 32; nameMaxSymbol = gensym(nameCString); hashtab_store(wrappedMaxClass->maxAttrNamesToTTAttrNames, nameMaxSymbol, ObjectPtr(name)); class_addattr(wrappedMaxClass->maxClass, attr_offset_new(nameCString, maxType, 0, (method)wrappedClass_attrGet, (method)wrappedClass_attrSet, NULL)); // Add display styles for the Max 5 inspector if (attr->type == kTypeBoolean) CLASS_ATTR_STYLE(wrappedMaxClass->maxClass, (char*)name->getCString(), 0, "onoff"); if (name == TT("fontFace")) CLASS_ATTR_STYLE(wrappedMaxClass->maxClass, "fontFace", 0, "font"); } TTObjectRelease(&o); class_addmethod(wrappedMaxClass->maxClass, (method)MaxAudioGraphReset, "audio.reset", A_CANT, 0); class_addmethod(wrappedMaxClass->maxClass, (method)MaxAudioGraphSetup, "audio.setup", A_CANT, 0); class_addmethod(wrappedMaxClass->maxClass, (method)MaxAudioGraphConnect, "audio.connect", A_OBJ, A_LONG, 0); class_addmethod(wrappedMaxClass->maxClass, (method)object_obex_dumpout, "dumpout", A_CANT, 0); class_addmethod(wrappedMaxClass->maxClass, (method)wrappedClass_assist, "assist", A_CANT, 0L); class_addmethod(wrappedMaxClass->maxClass, (method)stdinletinfo, "inletinfo", A_CANT, 0); class_register(_sym_box, wrappedMaxClass->maxClass); if (c) *c = wrappedMaxClass; hashtab_store(wrappedMaxClasses, wrappedMaxClass->maxClassName, ObjectPtr(wrappedMaxClass)); return kTTErrNone; }
void TutorialLevel::setup(){ INFO("Generating Tutorial Level..."); readFile(); initalizeGrid(); createRenders(); createLevel(); waterSurfaceManager = WaterSurfaceManagerPtr(new WaterSurfaceManager()); addGameObject(waterSurfaceManager); INFO("Removal String so less of make"); INFO("Setting up the cameras for the Test Level..."); CameraPtr cam3(new Camera(glm::vec3(25, 30, 0), glm::vec3(10, 20, 6), glm::vec3(0, 1, 0))); cam3->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); addCamera("CinematicCamera", cam3); setMainCamera("CinematicCamera"); setCullingCamera("CinematicCamera"); CameraPtr cam1(new Camera(glm::vec3(4, 10, -5), glm::vec3(4, 4, -10), glm::vec3(0, 1, 0))); cam1->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); addCamera("Camera1", cam1); CameraPtr cam2(new Camera(glm::vec3(0, 1, 0), glm::vec3(-6, -3, 6), glm::vec3(0, 1, 0))); cam2->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); l1 = LightPtr(new Light(glm::vec3(1), 30.0f, glm::vec3(0, 30, 0))); l1->setPosition(l1->getDirection()); Uniform3DGridPtr<int> typeGrid = getTypeGrid(); gridCenter = glm::vec3((typeGrid->getMaxX() - typeGrid->getMinX())/2.0f, (typeGrid->getMaxY() - typeGrid->getMinY())/2.0f, (typeGrid->getMinZ() - typeGrid->getMaxZ())/2.0f); l1->setViewMatrix(glm::lookAt( l1->getPosition(), gridCenter, glm::vec3(0, 1, 0))); l1->setProjectionMatrix(glm::ortho<float>(-30,30,-30,30,-70,70)); addLight("Sun", l1); INFO("Setting up the player for the Test Level..."); cinematicPlayer = CinematicPlayerPtr(new CinematicPlayer(cam3)); cinematicPlayer->setup(); addGameObject("cinematicPlayer", cinematicPlayer); player = PlayerPtr(new Player(cam1, 2)); player->setup(); addGameObject("player" , player); CollisionManager::addCollisionObjectToList(player); debugPlayer = DebugPlayerPtr(new DebugPlayer(cam2)); debugPlayer->setup(); addGameObject("debugPlayer" , debugPlayer); //Text addCamera("DebugCamera", cam2); sky = ObjectPtr(new Object( LoadManager::getMesh("sphere.obj"), MaterialManager::getMaterial("None"))); sky->applyTexture(LoadManager::getTexture("Sky")); sky->enableTexture(); sky->scale(glm::vec3(-90.0f,-90.0f,-90.0f)); sky->translate(Director::getScene()->getCamera()->getEye()); RenderEngine::getRenderElement("textured")->addObject(sky); ExclamationPtr exclamation = ExclamationPtr(new Exclamation(glm::vec3(30, 26, -48))); exclamation->setup(); addGameObject("exclamation", exclamation); }
ObjectPtr Sphere::clone() const { return ObjectPtr(new Sphere(*this)); }
inline NodePtr createChild(const std::string& name) { NodePtr newNode(new Node(ObjectPtr(), *(sceneNode_->createChildSceneNode()))); attachChild(name, newNode); return newNode; }
AVM::AVM() { _registers.resize(256); for (size_t i = 0; i < _registers.size(); ++i) _registers[i].push(Variable()); _stopFlag = false; _variables["_global"] = ObjectPtr(new Object()); _variables["_root"] = ObjectPtr(new Object()); _variables["Object"] = ObjectPtr(new DummyFunction()); _variables["Object"].asObject()->setMember("registerClass", new NativeFunction(boost::bind(&AVM::registerClass, this, _1), false, false, false, false)); _variables["Object"].asObject()->setMember("prototype", ObjectPtr(new Object())); _variables["Array"] = ObjectPtr(new DummyFunction()); _variables["Array"].asObject()->setMember("prototype", ObjectPtr(new Array())); _variables["String"] = ObjectPtr(new DummyFunction()); _variables["String"].asObject()->setMember("prototype", ObjectPtr(new String())); _variables["MovieClip"] = ObjectPtr(new DummyFunction()); _variables["MovieClip"].asObject()->setMember("prototype", ObjectPtr(new MovieClip())); _variables["TextField"] = ObjectPtr(new DummyFunction()); _variables["TextField"].asObject()->setMember("prototype", ObjectPtr(new TextField())); _variables["_root"].asObject()->setMember("gotoAndPlay", new NativeFunction(boost::bind(&AVM::gotoAndPlay, this, _1), false, false, false, false)); _variables["flash"] = ObjectPtr(new Object()); _variables["flash"].asObject()->setMember("external", ObjectPtr(new Object())); _variables["flash"].asObject()->getMember("external").asObject()->setMember("ExternalInterface", ObjectPtr(new Object())); _variables["flash"].asObject() ->getMember("external").asObject()->getMember("ExternalInterface").asObject() ->setMember("call", new NativeFunction(boost::bind(&AVM::call, this, _1), false, false, false, false)); }
void TunnelLevel::setup(){ INFO("Generating Test Level..."); readFile(); initalizeGrid(); createRenders(); createLevel(); INFO("Removal String so less of make"); waterSurfaceManager = WaterSurfaceManagerPtr(new WaterSurfaceManager()); addGameObject(waterSurfaceManager); CameraPtr cam3(new Camera(glm::vec3(30, 45, 0), glm::vec3(30, 15, 6), glm::vec3(0, 1, 0))); cam3->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); addCamera("CinematicCamera", cam3); setMainCamera("CinematicCamera"); setCullingCamera("CinematicCamera"); INFO("Setting up the cameras for the Test Level..."); CameraPtr cam1(new Camera(glm::vec3(32.0f, 12.0f, -24.0f), glm::vec3(4, 4, -10), glm::vec3(0, 1, 0))); cam1->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); addCamera("Camera1", cam1); setMainCamera("Camera1"); setCullingCamera("Camera1"); CameraPtr cam2(new Camera(glm::vec3(0, 1, 0), glm::vec3(-6, -3, 6), glm::vec3(0, 1, 0))); cam2->setProjectionMatrix( glm::perspective(glm::radians(90.0f), (float) Global::ScreenWidth/Global::ScreenHeight, 0.1f, 100.f)); l1 = LightPtr(new Light(glm::vec3(1), 30.0f, glm::vec3(32, 30, -20))); l1->setPosition(l1->getDirection()); Uniform3DGridPtr<int> typeGrid = getTypeGrid(); gridCenter = glm::vec3((typeGrid->getMaxX() - typeGrid->getMinX())/2.0f, (typeGrid->getMaxY() - typeGrid->getMinY())/2.0f, (typeGrid->getMinZ() - typeGrid->getMaxZ())/2.0f); l1->setViewMatrix(glm::lookAt( l1->getPosition(), gridCenter, glm::vec3(0, 1, 0))); l1->setProjectionMatrix(glm::ortho<float>(-30,30,-30,30,-70,70)); addLight("Sun", l1); cinematicPlayer = CinematicPlayerPtr(new CinematicPlayer(cam3)); cinematicPlayer->setup(); addGameObject("cinematicPlayer", cinematicPlayer); INFO("Setting up the player for the Test Level..."); player = PlayerPtr(new Player(cam1, 2)); player->setup(); addGameObject("player" , player); CollisionManager::addCollisionObjectToList(player); debugPlayer = DebugPlayerPtr(new DebugPlayer(cam2)); debugPlayer->setup(); addGameObject("debugPlayer" , debugPlayer); addCamera("DebugCamera", cam2); INFO("Creating Switch for the Test Level..."); SwitchPtr s1(new Switch(glm::vec3(0.9f, 0.1f, 0.1f), glm::vec3(33.7f, 11.0f, -27.0f), glm::vec3(0,0,1), -20.0f, 1)); s1->setup(); addGameObject("s1", s1); CollisionManager::addCollisionObjectToGrid(s1); std::list<SolidCubePtr> solidCubes; // INFO("Creating Active Terrain for the Test Level..."); for(int i = 11; i < 36; i+=2) { for(int j = -27; j < -20; j+=2) { SolidCubePtr at1(new SolidCube(glm::vec3(29, i, j))); at1->setup(); RenderEngine::getRenderGrid()->removeObject(at1->getObject()); solidCubes.push_back(at1); } } ActiveTerrainPtr a1(new ActiveTerrain(s1, glm::vec3(), glm::vec3(), 50.0f)); a1->setup(); a1->setCubes(solidCubes); addGameObject("a1", a1); sky = ObjectPtr(new Object( LoadManager::getMesh("sphere.obj"), MaterialManager::getMaterial("None"))); sky->applyTexture(LoadManager::getTexture("Sky")); sky->enableTexture(); sky->scale(glm::vec3(-50.0f,-50.0f,-50.0f)); sky->translate(Director::getScene()->getCamera()->getEye()); RenderEngine::getRenderElement("textured")->addObject(sky); ExclamationPtr exclamation = ExclamationPtr(new Exclamation(glm::vec3(60, 5, -23))); exclamation->setup(); addGameObject("exclamation", exclamation); PTR_CAST(SolidCube, (*grid)(7, 20, 11))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(7, 20, 12))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(7, 20, 11))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); PTR_CAST(SolidCube, (*grid)(7, 20, 12))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); shearRegion(8, 10, 21, 21, 11, 12, 1, 0, 0.0f); shearRegion(11, 13, 20, 20, 11, 12, 1, 0, 0.5f); PTR_CAST(SolidCube, (*grid)(16, 12, 0))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(17, 12, 0))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(16, 12, 0))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); PTR_CAST(SolidCube, (*grid)(17, 12, 0))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); shearRegion(16, 17, 13, 13, 1, 4, 0, 1, 0.0f); shearRegion(16, 17, 12, 12, 5, 8, 0, 1, 0.5f); PTR_CAST(SolidCube, (*grid)(16, 12, 23))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(17, 12, 23))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(16, 12, 23))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); PTR_CAST(SolidCube, (*grid)(17, 12, 23))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); shearRegion(16, 17, 13, 13, 19, 22, 0, -1, 0.0f); shearRegion(16, 17, 12, 12, 15, 18, 0, -1, 0.5f); PTR_CAST(SolidCube, (*grid)(26, 12, 15))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(26, 12, 8))->getObject()->applyTextureIndex(LoadManager::getTexture("DrainTexture"), 0); PTR_CAST(SolidCube, (*grid)(26, 12, 15))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); PTR_CAST(SolidCube, (*grid)(26, 12, 8))->getObject()->applyNormalMapIndex(LoadManager::getTexture("RegularNormalMap"), 0); }
void WaterSurface::setup() { if(colorMask & BLUE) color = "FlatBlue"; else if(colorMask & GREEN) color = "FlatGreen"; else if(colorMask & RED) color = "FlatRed"; else if(colorMask & GREY) color = "FlatGrey"; LevelTemplatePtr level = PTR_CAST(LevelTemplate, Director::getScene()); typeGrid = level->getTypeGrid(); // these are intentionally backwards - similar to setting "currentMax" to MIN_INT minX = typeGrid->getMaxX(); maxX = typeGrid->getMinX(); minY = typeGrid->getMaxY(); maxY = typeGrid->getMinY(); minZ = typeGrid->getMaxZ(); maxZ = typeGrid->getMinZ(); visitedGrid = Uniform3DGridPtr<int>(new Uniform3DGrid<int>( typeGrid->getSizeX(), typeGrid->getSizeY(), typeGrid->getSizeZ(), typeGrid->getMinX(), typeGrid->getMaxX(), typeGrid->getMinY(), typeGrid->getMaxY(), typeGrid->getMinZ(), typeGrid->getMaxZ())); targetGrid = Uniform3DGridPtr<int>(new Uniform3DGrid<int>( typeGrid->getSizeX(), typeGrid->getSizeY(), typeGrid->getSizeZ(), typeGrid->getMinX(), typeGrid->getMaxX(), typeGrid->getMinY(), typeGrid->getMaxY(), typeGrid->getMinZ(), typeGrid->getMaxZ())); lowestGrid = Uniform3DGridPtr<float>(new Uniform3DGrid<float>( typeGrid->getSizeX(), typeGrid->getSizeY(), typeGrid->getSizeZ(), typeGrid->getMinX(), typeGrid->getMaxX(), typeGrid->getMinY(), typeGrid->getMaxY(), typeGrid->getMinZ(), typeGrid->getMaxZ())); visitedGrid->initialize(0); targetGrid->initialize(1); lowestGrid->initialize(typeGrid->getMaxY()); floodFillVisit(position); floodFillTarget(position, typeGrid->getMaxY()); //special case - if it's only one cell tall, make it another cell tall if possible if(minY + 1.5f * typeGrid->getEdgeSizeY() > maxY && maxY + typeGrid->getEdgeSizeY() < typeGrid->getMaxY()) { maxY += typeGrid->getEdgeSizeY(); for(float x = minX; x < maxX + visitedGrid->getEdgeSizeX() * 0.5f; x += visitedGrid->getEdgeSizeX()) { for(float z = minZ; z < maxZ + visitedGrid->getEdgeSizeZ() * 0.5f; z += visitedGrid->getEdgeSizeX()) { visitedGrid->setValue(x, maxY, z, 1); } } } if((maxX - minX) * (maxZ - minZ) > 100.0f * visitedGrid->getEdgeSizeX() * visitedGrid->getEdgeSizeZ()) { //setSpeed(0.5f + sqrt(7.07f) / sqrt((maxX - minX) * (maxZ - minZ))); maxSpeed = speed * 3.0f; } timer = 0.0f; startPosition = position; waterSurface = ObjectPtr(new Object( LoadManager::getMesh("grid.obj"), MaterialManager::getMaterial(color))); waterDataTexture = LoadManager::getRenderTexture("waterData"); waterColorTexture = LoadManager::getRenderTexture("waterColor"); waterBlockTexture = LoadManager::getRenderTexture("waterBlock"); waterDataTexture->clear(); waterColorTexture->clear(); waterBlockTexture->clear(); waterBlockTexture->renderBlock(visitedGrid, minX, maxX, minY, maxY, minZ, maxZ, true, glm::vec3(1.0f, 0.0f, 0.0f)); waterBlockTexture->swapTextures(); waterBlockTexture->renderBlock(targetGrid, minX, maxX, minY, maxY, minZ, maxZ, false, glm::vec3(0.0f, 1.0f, 0.0f)); waterSurface->applyWaterBlock(waterBlockTexture->getTexture()); size = glm::vec3((maxX - minX + 2.0f) / 2.0f, (maxY - minY + 2.0f) / 2.0f, (maxZ - minZ + 2.0f) / 2.0f); waterColorTexture->render(LoadManager::getShader("render-texture-vertex-color-initial.glsl", "render-texture-fragment-color-initial.glsl"), waterBlockTexture->getTexture(), glm::vec2(0, 0), startPosition - position, size); waterSurface->applyWaterColor(waterColorTexture->getTexture()); waterColorTexture->swapTextures(); waterDataTexture->render(LoadManager::getShader("render-texture-vertex-data-initial.glsl", "render-texture-fragment-data-initial.glsl"), waterBlockTexture->getTexture(), glm::vec2(0, 0), startPosition - position, size); waterSurface->applyWaterData(waterDataTexture->getTexture()); waterDataTexture->swapTextures(); waterSurface->scale(size); waterSurface->enableWater(); waterSurface->setDTime(glm::vec2(0)); position = glm::vec3((maxX + minX) / 2.0f, (maxY + minY) / 2.0f, (maxZ + minZ) / 2.0f); waterSurface->translate(position); waterSurface->setGridScale(glm::vec2(size.x, size.z)); waterSurface->applyTexture(LoadManager::getTexture("PureWhiteTexture")); waterSurface->enableTexture(); waterSurface->applyNormalMap(LoadManager::getTexture("RegularNormalMap")); RenderEngine::getRenderElement("water")->addObject(waterSurface); }
void StringSelector::editString() { QString stringName; DialogLauncher::self()->showStringDialog(stringName, ObjectPtr(selectedString()), true); fillStrings(); }
void modifyTypedPrimitive( T * object, const CompoundObject * operands ) override { ScopedGILLock gilLock; this->methodOverride( "modifyTypedPrimitive" )( ObjectPtr( object ), CompoundObjectPtr( const_cast<CompoundObject *>( operands ) ) ); }