void GLWidget3D::keyPressEvent(QKeyEvent *e) { ctrlPressed = false; switch (e->key()) { case Qt::Key_Control: ctrlPressed = true; break; case Qt::Key_Delete: clearGeometry(); break; default: break; } }
void AerialMapDisplay::clear() { setStatus(StatusProperty::Warn, "Message", "No map received"); clearGeometry(); // the user has cleared here received_msg_ = false; // stop any loading... if (loader_) { ROS_INFO("Clearing loaded imagery."); // cancel current imagery, if any loader_->abort(); delete loader_; loader_ = 0; } }
SurfacePatchRenderable::~SurfacePatchRenderable() { clearGeometry(); delete mRenderOp.vertexData; delete mRenderOp.indexData; }
///////////////////////////////////////////////////////////////////// // Set Functions ////////////////////////////////////////////////////////////////////// // Clear the content of the geometry and makes it empty void GLC_Geometry::clear() { clearGeometry(); }
void Terrain::buildGeometry(Ogre::SceneNode* parent, bool editable) { clearGeometry(); assert(parent); // NB: We must adjust world geometry bounding box, especially for OctreeSceneManager Ogre::AxisAlignedBox aabb = mData->getBoundBox(); Ogre::Vector3 centre = aabb.getCenter(); const Ogre::Vector3 adjust(2000, 10000, 2000); const Ogre::Real scale = 1.5f; aabb.setExtents( (aabb.getMinimum() - centre) * scale + centre - adjust, (aabb.getMaximum() - centre) * scale + centre + adjust); parent->getCreator()->setOption("Size", &aabb); mEditable = editable; if (!mData->mXSize || !mData->mZSize) { // Do nothing if it's empty terrain. return; } // Prepare atlas texture for (size_t pixmapId = 0, numPixmap = mData->mPixmaps.size(); pixmapId < numPixmap; ++pixmapId) { _getPixmapAtlasId(pixmapId); } prepareLightmapTexture(); int depth = mData->mZSize; int width = mData->mXSize; int tileSize = mData->mTileSize; int numTilePerX = mData->mNumTilePerX; int numTilePerZ = mData->mNumTilePerZ; if (mEditable) { mGridTypeInfos.resize(2); mGridTypeInfos[0].material.setNull(); mGridTypeInfos[1].material = Ogre::MaterialManager::getSingleton().getByName( "FairyEditor/GridType"); } else { _initIndexBuffer(tileSize * tileSize); } mTiles.reserve(numTilePerX * numTilePerZ); for (int z = 0; z < numTilePerZ; ++z) { for (int x = 0; x < numTilePerX; ++x) { // Create the tile int tileX = x * tileSize; int tileZ = z * tileSize; int tileWidth = std::min(width - tileX, tileSize); int tileDepth = std::min(depth - tileZ, tileSize); TerrainTile* tile; if (mEditable) tile = new TerrainTileEditable(parent, this, tileX, tileZ, tileWidth, tileDepth); else tile = new TerrainTileOptimized(parent, this, tileX, tileZ, tileWidth, tileDepth); // Use the render queue that the world geometry associated with. tile->setRenderQueueGroup(parent->getCreator()->getWorldGeometryRenderQueue()); // Attach it to the aux data mTiles.push_back(tile); } } }
void Terrain::reset() { clearGeometry(); mData->reset(); }
void AerialMapDisplay::assembleScene() { if (!dirty_) { return; // nothing to update } dirty_ = false; if (!loader_) { return; // no tiles loaded, don't do anything } // get rid of old geometry, we will re-build this clearGeometry(); // iterate over all tiles and create an object for each of them const double resolution = loader_->resolution(); const std::vector<TileLoader::MapTile> &tiles = loader_->tiles(); for (const TileLoader::MapTile &tile : tiles) { const int w = tile.image().width(); const int h = tile.image().height(); // we here assume that the tiles are uniformly sized... const double tileW = w * resolution; const double tileH = h * resolution; const double origin_x = -loader_->originX() * tileW; const double origin_y = -(1 - loader_->originY()) * tileH; // determine location of this tile const double x = (tile.x() - loader_->tileX()) * tileW + origin_x; const double y = -(tile.y() - loader_->tileY()) * tileH + origin_y; // don't re-use any ids const std::string name_suffix = std::to_string(tile.x()) + "_" + std::to_string(tile.y()) + "_" + std::to_string(map_id_) + "_" + std::to_string(scene_id_); Ogre::TexturePtr tex; if (tile.hasImage()) { // one material per texture std::string matName = "material_" + name_suffix; Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create( matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); material->setReceiveShadows(false); material->getTechnique(0)->setLightingEnabled(false); material->setDepthBias(-16.0f, 0.0f); /// @todo: what the f**k does this do? material->setCullingMode(Ogre::CULL_NONE); material->setDepthWriteEnabled(false); // create textureing unit Ogre::Pass *pass = material->getTechnique(0)->getPass(0); Ogre::TextureUnitState *tex_unit = NULL; if (pass->getNumTextureUnitStates() > 0) { tex_unit = pass->getTextureUnitState(0); } else { tex_unit = pass->createTextureUnitState(); } // only add if we have a texture for it tex = textureFromImage(tile.image(), "texture_" + name_suffix); ROS_INFO("Rendering with texture: %s", tex->getName().c_str()); tex_unit->setTextureName(tex->getName()); tex_unit->setTextureFiltering(Ogre::TFO_BILINEAR); // create an object const std::string obj_name = "object_" + name_suffix; Ogre::ManualObject *obj = scene_manager_->createManualObject(obj_name); scene_node_->attachObject(obj); // configure depth & alpha properties if (alpha_ >= 0.9998) { material->setDepthWriteEnabled(!draw_under_); material->setSceneBlending(Ogre::SBT_REPLACE); } else { material->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); material->setDepthWriteEnabled(false); } if (draw_under_) { obj->setRenderQueueGroup(Ogre::RENDER_QUEUE_4); } else { obj->setRenderQueueGroup(Ogre::RENDER_QUEUE_MAIN); } tex_unit->setAlphaOperation(Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha_); // create a quad for this tile obj->begin(material->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST); // bottom left obj->position(x, y, 0.0f); obj->textureCoord(0.0f, 0.0f); obj->normal(0.0f, 0.0f, 1.0f); // top right obj->position(x + tileW, y + tileH, 0.0f); obj->textureCoord(1.0f, 1.0f); obj->normal(0.0f, 0.0f, 1.0f); // top left obj->position(x, y + tileH, 0.0f); obj->textureCoord(0.0f, 1.0f); obj->normal(0.0f, 0.0f, 1.0f); // bottom left obj->position(x, y, 0.0f); obj->textureCoord(0.0f, 0.0f); obj->normal(0.0f, 0.0f, 1.0f); // bottom right obj->position(x + tileW, y, 0.0f); obj->textureCoord(1.0f, 0.0f); obj->normal(0.0f, 0.0f, 1.0f); // top right obj->position(x + tileW, y + tileH, 0.0f); obj->textureCoord(1.0f, 1.0f); obj->normal(0.0f, 0.0f, 1.0f); obj->end(); if (draw_under_property_->getValue().toBool()) { // render under everything else obj->setRenderQueueGroup(Ogre::RENDER_QUEUE_4); } MapObject object; object.object = obj; object.texture = tex; object.material = material; objects_.push_back(object); } } scene_id_++; }
void UrbanGeometry::clear() { clearGeometry(); }