void Tiled2DGraphics::updateLevels() { if (_levels.size() == 0) return; Level* new_level = NULL; Levels::iterator i = _levels.lower_bound(_currentZoomLevel); if (i != _levels.begin()) --i; Levels::iterator next_i = i; if (next_i != _levels.end()) { next_i++; if (next_i == _levels.end()) --next_i; } float lower_d = (_currentZoomLevel - i->first); float upper_d = (i->first - _currentZoomLevel); new_level = (lower_d < upper_d) ? i->second : next_i->second; if(_currentVisibleLevel != new_level) { for(Level::TilesList::iterator i = _visibleTiles.begin(); i != _visibleTiles.end(); ++i) { _tilesToHide.push_back(*i); } _visibleTiles.clear(); hideOrphanedTiles(); } // std::cout << new_level << " lower: " << lower_d << " upper: " << upper_d << std::endl; for(Levels::iterator itr = _levels.begin(); itr != _levels.end(); ++itr) { // std::cout << itr->second->getLevelId() << ": " << ((itr->second == new_level) * 0xFFFF) << std::endl; itr->second->setNodeMask( (itr->second == new_level) * 0xFFFF); } _currentVisibleLevel = new_level; if (_tilesComputed) updateVisibility(); }
void WaveEditorWidget::updateFromInfo() { if (m_vwi != NULL) { m_lblName->setText(m_vwi->wave()->sName); m_lblSens->setText(tr("%0 mV").arg(m_vwi->voltsPerDivision())); m_lblShift->setText(tr("%0 s").arg(m_vwi->shift() / EAD_SAMPLES_PER_SECOND)); m_chkVisible->setChecked(m_vwi->isVisible()); } else { m_lblName->setText(""); m_lblSens->setText(tr("-")); m_lblShift->setText(tr("-")); m_chkVisible->setChecked(false); } updateVisibility(); }
void Level::replaceSquare(Vec2 pos, PSquare square) { if (contains(tickingSquares, getSquare(pos))) removeElement(tickingSquares, getSquare(pos)); Creature* c = squares[pos]->getCreature(); for (Item* it : squares[pos]->getItems()) square->dropItem(squares[pos]->removeItem(it)); squares[pos]->onConstructNewSquare(square.get()); addLightSource(pos, squares[pos]->getLightEmission(), -1); square->setCovered(squares[pos]->isCovered()); square->addLight(squares[pos]->getTotalLight()); square->setBackground(squares[pos].get()); squares[pos] = std::move(square); squares[pos]->setPosition(pos); squares[pos]->setLevel(this); if (c) { squares[pos]->putCreatureSilently(c); } addLightSource(pos, squares[pos]->getLightEmission(), 1); updateVisibility(pos); }
void TargetSetupPage::setupWidgets() { // Known profiles: QList<Kit *> kitList; if (m_requiredMatcher.isValid()) kitList = KitManager::matchingKits(m_requiredMatcher); else kitList = KitManager::kits(); foreach (Kit *k, kitList) addWidget(k); // Setup import widget: Utils::FileName path = Utils::FileName::fromString(m_projectPath); path = path.parentDir(); // base dir path = path.parentDir(); // parent dir m_importWidget->setCurrentDirectory(path); updateVisibility(); }
void CrumbleBar::pushFile(const QString &fileName) { if (m_isInternalCalled == false) { crumblePath()->clear(); } else { CrumbleBarInfo lastElementCrumbleBarInfo = crumblePath()->dataForLastIndex().value<CrumbleBarInfo>(); if (!lastElementCrumbleBarInfo.displayName.isEmpty() && lastElementCrumbleBarInfo.fileName == fileName) crumblePath()->popElement(); } CrumbleBarInfo crumbleBarInfo; crumbleBarInfo.fileName = fileName; crumblePath()->pushElement(fileName.split("/").last(), QVariant::fromValue(crumbleBarInfo)); m_isInternalCalled = false; updateVisibility(); }
void KSaneOptButton::createWidget(QWidget *parent) { if (m_widget) { return; } readOption(); if (!m_optDesc) { qDebug() << "This is a bug"; m_widget = new KSaneOptionWidget(parent, QStringLiteral("")); return; } m_widget = m_button = new KSaneButton(parent, i18n(m_optDesc->title)); m_widget->setToolTip(i18n(m_optDesc->desc)); connect(m_button, &KSaneButton::clicked, this, &KSaneOptButton::buttonClicked); updateVisibility(); readValue(); }
SpellCheckerWidget::SpellCheckerWidget(QWidget *parent) : QWidget(parent) { m_label = new QLabel(this); m_active = new QCheckBox(this); m_active->setChecked(ChatCore::settings()->value(LS("SpellChecker/Active")).toBool()); m_advanced = new QCheckBox(this); m_advanced->setChecked(ChatCore::settings()->value(LS("SpellChecker/Advanced")).toBool()); m_list = new QListWidget(this); m_list->setFrameShape(QFrame::NoFrame); m_list->setAlternatingRowColors(true); m_list->setSpacing(1); m_list->setDragDropMode(QAbstractItemView::InternalMove); m_list->installEventFilter(this); QGridLayout *listLay = new QGridLayout(); listLay->addWidget(m_list); listLay->setContentsMargins(16, 0, 0, 0); QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(m_active); layout->addWidget(m_advanced); layout->addLayout(listLay); layout->setContentsMargins(10, 0, 3, 0); QVBoxLayout *mainLay = new QVBoxLayout(this); mainLay->addWidget(m_label); mainLay->addLayout(layout); mainLay->setContentsMargins(0, 12, 0, 0); build(); updateVisibility(); retranslateUi(); connect(m_active, SIGNAL(clicked(bool)),SLOT(activeClicked(bool))); connect(m_advanced, SIGNAL(clicked(bool)),SLOT(advancedClicked(bool))); connect(m_list, SIGNAL(itemChanged(QListWidgetItem*)),SLOT(reloadDictionaries())); }
void Client::windowPropertyChanged(unsigned long atom) { if(atom == X11Support::atom("_NET_WM_WINDOW_TYPE") || atom == X11Support::atom("_NET_WM_STATE")) { updateVisibility(); } if(atom == X11Support::atom("_NET_WM_VISIBLE_NAME") || atom == X11Support::atom("_NET_WM_NAME") || atom == X11Support::atom("WM_NAME")) { updateName(); } if(atom == X11Support::atom("_NET_WM_ICON")) { updateIcon(); } if(atom == X11Support::atom("WM_HINTS")) { updateUrgency(); } }
QgsHtmlAnnotationItem::QgsHtmlAnnotationItem( QgsMapCanvas* canvas, QgsVectorLayer* vlayer, bool hasFeature, int feature ) : QgsAnnotationItem( canvas ) , mWidgetContainer( 0 ) , mWebView( 0 ) , mVectorLayer( vlayer ) , mHasAssociatedFeature( hasFeature ) , mFeatureId( feature ) { mWebView = new QgsWebView(); mWebView->page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() ); mWidgetContainer = new QGraphicsProxyWidget( this ); mWidgetContainer->setWidget( mWebView ); QObject::connect( mWebView->page()->mainFrame(), SIGNAL( javaScriptWindowObjectCleared() ), this, SLOT( javascript() ) ); if ( mVectorLayer && mMapCanvas ) { QObject::connect( mVectorLayer, SIGNAL( layerModified() ), this, SLOT( setFeatureForMapPosition() ) ); QObject::connect( mMapCanvas, SIGNAL( renderComplete( QPainter* ) ), this, SLOT( setFeatureForMapPosition() ) ); QObject::connect( mMapCanvas, SIGNAL( layersChanged() ), this, SLOT( updateVisibility() ) ); }
void EditableLabel::showLabel() { m_label_shown = true; updateVisibility(); }
CovarianceProperty::CovarianceProperty( const QString& name, bool default_value, const QString& description, Property* parent, const char *changed_slot, QObject* receiver ) // NOTE: changed_slot and receiver aren't passed to BoolProperty here, but initialized at the end of this constructor : BoolProperty( name, default_value, description, parent ) { position_property_ = new BoolProperty( "Position", true, "Whether or not to show the position part of covariances", this, SLOT( updateVisibility() )); position_property_->setDisableChildrenIfFalse( true ); position_color_property_ = new ColorProperty( "Color", QColor( 204, 51, 204 ), "Color to draw the position covariance ellipse.", position_property_, SLOT( updateColorAndAlphaAndScaleAndOffset() ), this ); position_alpha_property_ = new FloatProperty( "Alpha", 0.3f, "0 is fully transparent, 1.0 is fully opaque.", position_property_, SLOT( updateColorAndAlphaAndScaleAndOffset() ), this ); position_alpha_property_->setMin( 0 ); position_alpha_property_->setMax( 1 ); position_scale_property_ = new FloatProperty( "Scale", 1.0f, "Scale factor to be applied to covariance ellipse. Corresponds to the number of standard deviations to display", position_property_, SLOT( updateColorAndAlphaAndScaleAndOffset() ), this ); position_scale_property_->setMin( 0 ); orientation_property_ = new BoolProperty( "Orientation", true, "Whether or not to show the orientation part of covariances", this, SLOT( updateVisibility() )); orientation_property_->setDisableChildrenIfFalse( true ); orientation_frame_property_ = new EnumProperty( "Frame", "Local", "The frame used to display the orientation covariance.", orientation_property_, SLOT( updateOrientationFrame() ), this ); orientation_frame_property_->addOption( "Local", Local ); orientation_frame_property_->addOption( "Fixed", Fixed ); orientation_colorstyle_property_ = new EnumProperty( "Color Style", "Unique", "Style to color the orientation covariance: XYZ with same unique color or following RGB order", orientation_property_, SLOT( updateColorStyleChoice() ), this ); orientation_colorstyle_property_->addOption( "Unique", Unique ); orientation_colorstyle_property_->addOption( "RGB", RGB ); orientation_color_property_ = new ColorProperty( "Color", QColor( 255, 255, 127 ), "Color to draw the covariance ellipse.", orientation_property_, SLOT( updateColorAndAlphaAndScaleAndOffset() ), this ); orientation_alpha_property_ = new FloatProperty( "Alpha", 0.5f, "0 is fully transparent, 1.0 is fully opaque.", orientation_property_, SLOT( updateColorAndAlphaAndScaleAndOffset() ), this ); orientation_alpha_property_->setMin( 0 ); orientation_alpha_property_->setMax( 1 ); orientation_offset_property_ = new FloatProperty( "Offset", 1.0f, "For 3D poses is the distance where to position the ellipses representing orientation covariance. For 2D poses is the height of the triangle representing the variance on yaw", orientation_property_, SLOT( updateColorAndAlphaAndScaleAndOffset() ), this ); orientation_offset_property_->setMin( 0 ); orientation_scale_property_ = new FloatProperty( "Scale", 1.0f, "Scale factor to be applied to orientation covariance shapes. Corresponds to the number of standard deviations to display", orientation_property_, SLOT( updateColorAndAlphaAndScaleAndOffset() ), this ); orientation_scale_property_->setMin( 0 ); connect(this, SIGNAL( changed() ), this, SLOT( updateVisibility() )); // Connect changed() signal here instead of doing it through the initialization of BoolProperty(). // We do this here to make changed_slot be called _after_ updateVisibility() if(changed_slot && (parent || receiver)) { if(receiver) connect(this, SIGNAL( changed() ), receiver, changed_slot); else connect(this, SIGNAL( changed() ), parent, changed_slot); } setDisableChildrenIfFalse( true ); }
void LODNode::OnRegisterSceneNode() { bool shown = false; updateVisibility(&shown); const u32 now = irr_driver->getDevice()->getTimer()->getTime(); // support an optional, mostly hard-coded fade-in/out effect for objects with a single level if (m_nodes.size() == 1 && (m_nodes[0]->getType() == scene::ESNT_MESH || m_nodes[0]->getType() == scene::ESNT_ANIMATED_MESH) && now > m_last_tick) { if (m_previous_visibility == WAS_HIDDEN && shown) { scene::IMesh* mesh; if (m_nodes[0]->getType() == scene::ESNT_MESH) { scene::IMeshSceneNode* node = (scene::IMeshSceneNode*)(m_nodes[0]); mesh = node->getMesh(); } else { assert(m_nodes[0]->getType() == scene::ESNT_ANIMATED_MESH); scene::IAnimatedMeshSceneNode* node = (scene::IAnimatedMeshSceneNode*)(m_nodes[0]); assert(node != NULL); mesh = node->getMesh(); } for (unsigned int n=0; n<mesh->getMeshBufferCount(); n++) { scene::IMeshBuffer* mb = mesh->getMeshBuffer(n); video::ITexture* t = mb->getMaterial().getTexture(0); if (t == NULL) continue; Material* m = material_manager->getMaterialFor(t, mb); if (m != NULL) { m->onMadeVisible(mb); } } } else if (m_previous_visibility == WAS_SHOWN && !shown) { scene::IMesh* mesh; if (m_nodes[0]->getType() == scene::ESNT_MESH) { scene::IMeshSceneNode* node = (scene::IMeshSceneNode*)(m_nodes[0]); mesh = node->getMesh(); } else { assert(m_nodes[0]->getType() == scene::ESNT_ANIMATED_MESH); scene::IAnimatedMeshSceneNode* node = (scene::IAnimatedMeshSceneNode*)(m_nodes[0]); assert(node != NULL); mesh = node->getMesh(); } for (unsigned int n=0; n<mesh->getMeshBufferCount(); n++) { scene::IMeshBuffer* mb = mesh->getMeshBuffer(n); video::ITexture* t = mb->getMaterial().getTexture(0); if (t == NULL) continue; Material* m = material_manager->getMaterialFor(t, mb); if (m != NULL) { m->onHidden(mb); } } } else if (m_previous_visibility == FIRST_PASS && !shown) { scene::IMesh* mesh; if (m_nodes[0]->getType() == scene::ESNT_MESH) { scene::IMeshSceneNode* node = (scene::IMeshSceneNode*)(m_nodes[0]); mesh = node->getMesh(); } else { assert(m_nodes[0]->getType() == scene::ESNT_ANIMATED_MESH); scene::IAnimatedMeshSceneNode* node = (scene::IAnimatedMeshSceneNode*)(m_nodes[0]); assert(node != NULL); mesh = node->getMesh(); } for (unsigned int n=0; n<mesh->getMeshBufferCount(); n++) { scene::IMeshBuffer* mb = mesh->getMeshBuffer(n); video::ITexture* t = mb->getMaterial().getTexture(0); if(!t) continue; Material* m = material_manager->getMaterialFor(t, mb); if (m != NULL) { m->isInitiallyHidden(mb); } } } } m_previous_visibility = (shown ? WAS_SHOWN : WAS_HIDDEN); m_last_tick = now; if (!CVS->isGLSL()) { for (core::list<ISceneNode*>::Iterator it = Children.begin(); it != Children.end(); it++) { (*it)->updateAbsolutePosition(); } } scene::ISceneNode::OnRegisterSceneNode(); }
View::View(game::TileMap &tile_map, game::EntityMap &entity_map, const int2 &view_size) :m_tile_map(tile_map), m_entity_map(entity_map), m_occluder_config(tile_map.occluderMap()), m_height(1), m_cell_size(1), m_is_visible(false), m_view_size(view_size), m_view_pos(-200, 300) { updateVisibility(); }
void GfxLight::setDiffuseColour (const Vector3 &v) { if (dead) THROW_DEAD(className); diffuse = v; updateVisibility(); }
void GfxLight::setEnabled (bool v) { if (dead) THROW_DEAD(className); enabled = v; updateVisibility(); }
TabView::TabView(TraceItemView* parentView, QWidget* parent, const char* name) : QWidget(parent, name), TraceItemView(parentView) { setFocusPolicy(QWidget::StrongFocus); _isCollapsed = true; QVBoxLayout* vbox = new QVBoxLayout( this, 6, 6); _nameLabel = new KSqueezedTextLabel( this, "nameLabel" ); _nameLabel->setText(i18n("(No profile data file loaded)")); vbox->addWidget( _nameLabel ); _mainSplitter = new QSplitter(Qt::Horizontal, this); _leftSplitter = new Splitter(Qt::Vertical, _mainSplitter, "Left"); vbox->addWidget( _mainSplitter ); _rightTW = new TabWidget(this, _mainSplitter, "Right"); connect(_rightTW, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged(QWidget*))); connect(_rightTW, SIGNAL(visibleRectChanged(TabWidget*)), this, SLOT(visibleRectChangedSlot(TabWidget*))); _topTW = new TabWidget(this, _leftSplitter, "Top"); connect(_topTW, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged(QWidget*))); connect(_topTW, SIGNAL(visibleRectChanged(TabWidget*)), this, SLOT(visibleRectChangedSlot(TabWidget*))); _bottomSplitter = new Splitter(Qt::Horizontal, _leftSplitter, "Bottom"); _leftTW = new TabWidget(this, _bottomSplitter, "Left"); _leftTW->setTabPosition(QTabWidget::Bottom); connect(_leftTW, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged(QWidget*))); connect(_leftTW, SIGNAL(visibleRectChanged(TabWidget*)), this, SLOT(visibleRectChangedSlot(TabWidget*))); _bottomTW = new TabWidget(this, _bottomSplitter, "Bottom"); _bottomTW->setTabPosition(QTabWidget::Bottom); connect(_bottomTW, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged(QWidget*))); connect(_bottomTW, SIGNAL(visibleRectChanged(TabWidget*)), this, SLOT(visibleRectChangedSlot(TabWidget*))); // default positions... addTop( addTab( i18n("Types"), new CostTypeView(this, _topTW, "CostTypeView"))); addTop( addTab( i18n("Callers"), new CallView(true, this, _topTW, "CallerView"))); addTop( addTab( i18n("All Callers"), new CoverageView(true, this, _topTW, "AllCallerView"))); addTop( addTab( i18n("Caller Map"), new CallMapView(true, this, _bottomTW, "CallerMapView"))); addTop( addTab( i18n("Source"), new SourceView(this, _topTW, "SourceView"))); addBottom( addTab( i18n("Parts"), new PartView(this, _bottomTW, "PartView"))); addBottom( addTab( i18n("Call Graph"), new CallGraphView(this, _bottomTW, "CallGraphView"))); addBottom( addTab( i18n("Callees"), new CallView(false, this, _bottomTW, "CalleeView"))); addBottom( addTab( i18n("All Callees"), new CoverageView(false, this, _bottomTW, "AllCalleeView"))); addBottom( addTab( i18n("Callee Map"), new CallMapView(false, this, _topTW, "CalleeMapView"))); addBottom( addTab( i18n("Assembler"), new InstrView(this, _bottomTW, "InstrView"))); // after all child widgets are created... _lastFocus = 0; _active = false; installFocusFilters(); updateVisibility(); QWhatsThis::add( this, whatsThis() ); }
void TabBar::setShowTabBarWhenOneTab(bool enabled) { m_showTabBarWhenOneTab = enabled; updateVisibility(); }
GuiPanel::GuiPanel(QWidget *parent, IniData &id) : QWidget(parent), inidata(id), ui(new Ui::GuiPanel) { reference = NULL; curMaterialFocus = DIFFUSEA; //mapMT = mm; _selectedIndex = -1; ui->setupUi(this); // ui->attributeData->tabBar()->setContentsMargins(-4,0,-4,0); QTabWidget *tw = ui->attributeData; int mar = 0; tw->setStyleSheet(QString("QTabBar::tab { width: %1px;padding-top: 1px; padding-bottom: 1px;margin-right: %2px;margin-left: %2px;} ") .arg((tw->size().width()+(2*mar*tw->count())-1)/tw->count()).arg(-mar) ); ui->wiBodyAxisA->setVisible(false); ui->wiBodyAxisB->setVisible(false); ui->wiBodyRadius->setVisible(false); ui->wiBodyNFaces->setVisible(false); ui->wiBodyNVerts->setVisible(false); ui->wiBodySigns->setVisible(false); ui->wiBodyFlags->setVisible(false); ui->bodyData->setVisible(false); ui->meshData->setVisible(false); ui->textureData->setVisible(false); ui->animationData->setVisible(false); ui->materialData->setVisible(false); ui->skeletonData->setVisible(false); ui->shaderData->setVisible(false); ui->hitboxEdit->setVisible(false); ui->viewRuler->setVisible(false); ui->viewFloatingProbe->setVisible(false); ui->generalView->setVisible(false); ui->vertexData->setVisible(false); ui->lvTextAcc->setModel( new TextureAccessModel(this) ); ui->lvBodyPart->setModel( new BodyPartModel(this) ); ui->lvBones->setModel( new BodyPartModel(this) ); //ui->frameNumber->setBackgroundRole(QPalette::Foreground); //ui->frameNumberAni->setBackgroundRole(QPalette::Foreground); alignY(ui->textureData ,ui->meshData); alignY(ui->materialData ,ui->meshData); alignY(ui->animationData,ui->meshData); alignY(ui->skeletonData,ui->meshData); alignY(ui->shaderData, ui->meshData); alignY(ui->bodyData, ui->meshData); alignYAfter(ui->hitboxEdit, ui->skeletonData); alignY(ui->vertexData, ui->meshData); //alignYAfter(ui->vertexData , ui->meshData ); QString flagMask(">Hhhhhhhh"); ui->boxFlags->setInputMask(flagMask); ui->boxTextureFlags->setInputMask(flagMask); ui->leMatFlags->setInputMask(flagMask); ui->leShaderFlags->setInputMask(flagMask); ui->leShaderTaFlags->setInputMask(flagMask); ui->leBodyFlags->setInputMask(flagMask); ui->leShaderRequires->setInputMask(flagMask); skel = NULL; //ui->leMatR->setInputMask("0.0000"); //ui->leMatG->setInputMask("0.0000"); //ui->leMatB->setInputMask("0.0000"); //ui->leMatCoeff->setInputMask("0000"); //ui->timeOfFrame->setInputMask("0000"); textureAccessDup = new QAction("Duplicate",this); textureAccessDel = new QAction("Remove",this); textureAccessAdd = new QAction("Add",this); bodyPartDup = new QAction("Duplicate",this); bodyPartDel = new QAction("Remove",this); bodyPartAdd = new QAction("Add",this); connect(ui->cbSkin, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateVisibility())); connect(ui->cbRefani, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateVisibility())); connect(ui->cbRuler, SIGNAL(stateChanged(int)), this, SLOT(updateVisibility())); connect(ui->cbRefani, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateRefAnimation())); connect(ui->rulerSlid, SIGNAL(sliderMoved (int)), this, SLOT(setRulerLenght(int))); connect(ui->rulerSpin, SIGNAL(valueChanged(int)), this, SLOT(setRulerLenght(int))); connect(ui->lvTextAcc->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateShaderTextaccData())); connect(ui->lvBodyPart->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateBodyPartData())); connect(ui->lvBones->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateSelectedBone())); // skeleton direct editing connect(ui->editHbRange, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int))); connect(ui->editHbLenTop, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int))); connect(ui->editHbLenBot, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int))); connect(ui->editHbPosX, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int))); connect(ui->editHbPosY, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int))); connect(ui->editHbPosZ, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int))); connect(ui->editHbRotAlpha, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int))); connect(ui->editHbRotBeta, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int))); QString st = tr(" (keep [shift] pressed to nudge)"); ui->editHbRange->setStatusTip(ui->editHbRange->statusTip()+st); ui->editHbLenTop->setStatusTip(ui->editHbLenTop->statusTip()+st); ui->editHbLenBot->setStatusTip(ui->editHbLenBot->statusTip()+st); ui->editHbPosX->setStatusTip(ui->editHbPosX->statusTip()+st); ui->editHbPosY->setStatusTip(ui->editHbPosY->statusTip()+st); ui->editHbPosZ->setStatusTip(ui->editHbPosZ->statusTip()+st); ui->editHbRotAlpha->setStatusTip(ui->editHbRotAlpha->statusTip()+st); ui->editHbRotBeta->setStatusTip(ui->editHbRotBeta->statusTip()+st); connect(ui->editHbActive, SIGNAL(stateChanged(int)),this,SLOT(setHbEditVisible(int))); connect(ui->floatingProbeX,SIGNAL(valueChanged(double)),this,SLOT(onEditFloatingProbePos())); connect(ui->floatingProbeY,SIGNAL(valueChanged(double)),this,SLOT(onEditFloatingProbePos())); connect(ui->floatingProbeZ,SIGNAL(valueChanged(double)),this,SLOT(onEditFloatingProbePos())); // add a shortcut to hide/show skin quickToggleHideSkinAct = new QAction(this); quickToggleHideSkinAct->setShortcut(QKeySequence("space")); //quickToggleHideSkinAct->setShortcutContext(Qt::ApplicationShortcut); connect(quickToggleHideSkinAct, SIGNAL(triggered()),this,SLOT(quickToggleHideSkin())); ui->cbSkin->addAction(quickToggleHideSkinAct); connect(ui->cbFloatingProbe,SIGNAL(toggled(bool)),parent,SLOT(activateFloatingProbe(bool))); connect(ui->cbRuler,SIGNAL(toggled(bool)),parent,SLOT(activateRuler(bool))); }
void GuiPanel::setSelection(const QModelIndexList &newsel, int k){ int sel=-1; int nsel = (int)newsel.size(); if (newsel.size()!=0) sel = newsel[0].row(); //bool vertexani=false; //bool skinned=false; //bool vertexcolor=false; /*bool manyMaterials=false; int flags=-1; char materialSt[255]=""; bool differentAni = false; int nv=0, nf=0, nfr=0, np=0; int last = -1; for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){ sel = i->row(); if (k==MESH && sel<(int)data->mesh.size() ) { BrfMesh *m = &(data->mesh[sel]); skinned |= m->IsSkinned(); vertexani |= m->frame.size()>1; vertexcolor |= m->hasVertexColor; np += m->frame[0].pos.size(); nv += m->vert.size(); int k = m->frame.size(); if (nfr>k || !nfr) nfr=k; if (!differentAni) { if (last!=-1) { if (data->mesh[sel].frame.size()!=data->mesh[last].frame.size()) differentAni=true; else for (unsigned int fi=0; fi < data->mesh[sel].frame.size(); fi++) if (data->mesh[sel].frame[fi].time!=data->mesh[last].frame[fi].time) differentAni=true; } else { for (unsigned int fi=0; fi < data->mesh[sel].frame.size(); fi++) _frameTime[fi]=data->mesh[sel].frame[fi].time; } last = sel; } nf += m->face.size(); if (!materialSt[0]) sprintf(materialSt,"%s",m->material); else if (strcmp(materialSt,m->material)) { sprintf(materialSt,"%s","<various>"); manyMaterials=true; } if (flags==-1) flags=m->flags; else { if (flags!=(int)m->flags) flags=-2; } } } if (k==-1) k=NONE; BrfMesh *m = NULL; BrfTexture *tex = NULL; BrfAnimation *ani = NULL; */ _selectedIndex = sel; //_nsel = switch (TokenEnum(k)){ case MATERIAL:{ myClear(ui->leMatBump); myClear(ui->leMatDifA); myClear(ui->leMatDifB); myClear(ui->leMatEnv); myClear(ui->leMatShader); myClear(ui->leMatSpec); myClear(ui->leMatFlags); //myClear(ui->leMatRendOrd); myClear(ui->leMatCoeff); myClear(ui->leMatR); myClear(ui->leMatG); myClear(ui->leMatB); for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){ int sel = i->row(); if (sel<0 || sel>=(int)data->material.size()) break; BrfMaterial &m(data->material[sel]); mySetText(ui->leMatBump, m.bump ); mySetText(ui->leMatDifA, m.diffuseA ); mySetText(ui->leMatDifB, m.diffuseB ); mySetText(ui->leMatEnv, m.enviro); mySetText(ui->leMatShader,m.shader ); mySetText(ui->leMatSpec, m.spec ); mySetText(ui->leMatFlags, StringH(m.flags) ); //mySetText(ui->leMatRendOrd, m.RenderOrder() ); mySetText(ui->leMatCoeff, StringF(m.specular,3) ); mySetText(ui->leMatR, StringF( m.r ,3)); mySetText(ui->leMatG, StringF( m.g ,3)); mySetText(ui->leMatB, StringF( m.b ,3)); } break; } case MESH: { myClear(ui->boxFlags); myClear(ui->boxMaterial); myClear(ui->boxTexture); myClear(ui->boxNVerts); myClear(ui->boxNFaces); myClear(ui->boxNPos); myClear(ui->boxNVerts); myClear(ui->boxNFrames); ui->meshDataAni->setVisible(false); ui->rbRiggingcolor->setEnabled(false); ui->rbVertexcolor->setEnabled(false); ui->viewRefAni->setVisible( false ); int hasAni=-1,hasCol=-1,hasTan=-1,hasRig=-1; bool hasBump=false, hasSpec=false, hasTran = false; for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){ int sel = i->row(); if (sel<0 || sel>=(int)data->mesh.size()) continue; BrfMesh *m=&(data->mesh[sel]); mySetText(ui->boxFlags, StringH(m->flags & ~(3<<16) )); mySetText( ui->boxMaterial , m->material ); mySetValueAdd( ui->boxNVerts , (int)m->vert.size()); mySetValueAdd( ui->boxNFaces , (int)m->face.size()); mySetValueAdd( ui->boxNPos , (int)m->frame[0].pos.size()); mySetValueMax( ui->boxNFrames, (int)m->frame.size()); mySetCompositeVal(hasAni, m->HasVertexAni()); mySetCompositeVal(hasCol, m->hasVertexColor); mySetCompositeVal(hasTan, m->StoresTangentField()); mySetCompositeVal(hasRig, m->IsSkinned()); bool ta,tb,tc; QString s = inidata.mat2tex(m->material,&ta,&tb,&tc); if (s.isEmpty()) s = tr("<not found>"); hasBump |= ta; hasSpec |= tb; hasTran |= tc; mySetText( ui->boxTexture, s ); for (unsigned int fi=0; fi < m->frame.size(); fi++) frameTime[fi]=m->frame[fi].time; } if (hasRig>0) { ui->rbRiggingcolor->setEnabled( true ); ui->viewRefAni->setVisible( true ); } if (hasCol>0) ui->rbVertexcolor->setEnabled(true); if (hasAni>0) ui->meshDataAni->setVisible(true); ui->cbMeshHasAni->setCheckState(myCheckState(hasAni)); ui->cbMeshHasCol->setCheckState(myCheckState(hasCol)); ui->cbMeshHasTan->setCheckState(myCheckState(hasTan)); ui->cbMeshHasRig->setCheckState(myCheckState(hasRig)); ui->cbTransp->setEnabled( hasTran ); ui->cbNormalmap->setEnabled( hasBump ); ui->cbSpecularmap->setEnabled( hasSpec ); ui->timeOfFrame->setEnabled( newsel.size()==1 ); int nfr = (int)ui->boxNFrames->value(); if (nfr>0) ui->frameNumber->setMaximum(nfr -1 ); ui->frameNumber->setMinimum( 0 ); ui->frameNumber->setWrapping(true); break; } case TEXTURE: myClear(ui->boxTextureFlags); for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){ int j=i->row(); if (j>=0 && j<(int)data->texture.size()) mySetText(ui->boxTextureFlags,StringH(data->texture[j].flags)); int nf = data->texture[j].NFrames(); if (nf==0) ui->labNFrames->setHidden(true); else { ui->labNFrames->setHidden(false); ui->labNFrames->setText(QString("x %1").arg(nf)); } } break; case SKELETON: { { int hasHb=-1; myClear(ui->boxSkelNBones); for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){ int sel = i->row(); if (sel<0 || sel>=(int)data->skeleton.size()) continue; BrfSkeleton *s=&(data->skeleton[sel]); int bi=-1; if (hitBoxes) bi = hitBoxes->Find(s->name,BODY); mySetCompositeVal(hasHb,bi>=0); mySetValue(ui->boxSkelNBones,(int)s->bone.size()); } ui->cbSkelHasHitbox->setCheckState(myCheckState(hasHb)); } ui->cbTransp->setEnabled( true ); ui->cbNormalmap->setEnabled( true ); ui->cbSpecularmap->setEnabled( true ); BodyPartModel* bmp = ((BodyPartModel*)(ui->lvBones->model())); if (sel>=0 && nsel==1 && sel<(int)data->skeleton.size()) { BrfSkeleton &s(data->skeleton[sel]); bmp->setSkel(s); } else bmp->clear(); emit selectedSubPiece(-1); // unselect all ui->lvBones->selectionModel()->clearSelection(); ui->hitboxEdit->setVisible(false); // until a piece is not selected break; } case ANIMATION: { myClear(ui->boxAniNBones); myClear(ui->boxAniNFrames); myClear(ui->boxAniMinFrame); myClear(ui->boxAniMaxFrame); for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){ int sel = i->row(); if (sel<0 || sel>=(int)data->animation.size()) continue; BrfAnimation *a=&(data->animation[sel]); mySetValue(ui->boxAniNBones,a->nbones); mySetValue(ui->boxAniNFrames,a->frame.size()); mySetValue(ui->boxAniMinFrame,a->FirstIndex()); mySetValue(ui->boxAniMaxFrame,a->LastIndex() ); } BrfAnimation *ani =NULL; if (sel>=0 && nsel==1 && sel<(int)data->animation.size()) ani=&(data->animation[sel]); if (ani) { for (unsigned int fi=0; fi < ani->frame.size(); fi++) frameTime[fi]=ani->frame[fi].index; ui->frameNumberAni->setMaximum(ani->frame.size()); ui->frameNumberAni->setMinimum(1); updateFrameNumber( ui->frameNumberAni->value() ); } ui->cbTransp->setEnabled( true ); ui->cbNormalmap->setEnabled( true ); ui->cbSpecularmap->setEnabled( true ); ui->rbRiggingcolor->setEnabled( true ); // quick: use "true": just let user edit them ui->rbVertexcolor->setEnabled( true ); ui->viewRefSkel->setVisible( true ); if (ani) setAnimation(ani); } break; case SHADER: { if (!newsel.size()) break; int sel = newsel[0].row(); if (sel<0 || sel>=(int)data->shader.size()) break; BrfShader &s(data->shader[sel]); ui->leShaderTechnique->setText( s.technique ); ui->leShaderFallback->setText( s.fallback ); ui->leShaderFlags->setText( StringH(s.flags) ); ui->leShaderRequires->setText( StringH(s.requires) ); updateShaderTextaccSize(); } break; case BODY: bool collisionBodyHasMesh; if (nsel==1) { char* bodyname = data->body[sel].name; int si = data->Find(bodyname,SKELETON); collisionBodyHasSkel= (si>=0); if (si>=0) skel = &(data->skeleton[si]); else skel = NULL; collisionBodyHasMesh = false; for (int i=0; i<(int)data->mesh.size(); i++) { if (data->mesh[i].IsNamedAsBody(bodyname)) collisionBodyHasMesh = true; } } else { collisionBodyHasMesh = true; collisionBodyHasSkel = false; } ui->cbComparisonMesh->setEnabled( collisionBodyHasMesh || collisionBodyHasSkel ); updateBodyPartData(); break; default: break; } ui->animationData->setVisible(k == ANIMATION); ui->textureData->setVisible(k == TEXTURE); ui->meshData->setVisible(k == MESH); ui->materialData->setVisible( k==MATERIAL ); ui->skeletonData->setVisible( k==SKELETON ); ui->shaderData->setVisible( k==SHADER ); ui->bodyData->setVisible( k==BODY ); ui->generalView->setVisible( k!=SHADER && k!=NONE ); QRect rect = ui->generalView->geometry(); if (k==MATERIAL) rect.setTop( ui->materialData->geometry().bottom() + 40 ); else rect.setTop( ui->meshData->geometry().bottom() + 40 ); ui->generalView->setGeometry(rect); displaying=k; updateVisibility(); updateFrameNumber( ui->frameNumber->value() ); }
//-------------------------------------------------------------- void testApp::setup(){ ofDisableArbTex(); ofSetTextureWrap(); //configure FBO initFrameBuffer(); //camera config #ifdef KINECT context.setupUsingXMLFile(); image.setup(&context); depth.setup(&context); xn::DepthGenerator& depthGen = depth.getXnDepthGenerator(); xn::ImageGenerator& imageGen = image.getXnImageGenerator(); XnStatus ret = xnSetViewPoint(depthGen, imageGen); cout << "Using kinect" << endl; #else //ofSetLogLevel(OF_LOG_VERBOSE); //grabber.listDevices(); //grabber.setDeviceID(7); if(grabber.initGrabber(640, 480)){ cout << "Using grabber" << endl; } else { cout << "MASSIVE FAIL" <<endl; } #endif convert.allocate(640, 480); //conversion of camera image to grayscale gray.allocate(640, 480); //grayscale tracking image kinectImage.allocate(640, 480); //image from kinect kinectDepthImage.allocate(640, 480); //Depth image from kinect finalMaskImage.allocate(640, 480);; //final composition mask sceneDepthImage.allocate(640, 480);; //scenes depthmap image finalImage.allocate(640, 480); sceneImage.allocate(640,480); pixelBuf = new unsigned char[640*480]; //temp buffer for kinect depth strea colorPixelBuf = new unsigned char[640*480*3]; //temp buffer for kinect image sceneDepthBuf = new unsigned short[640 * 480]; //depth buffer from our rendered scene kinectDepthBuf = new unsigned short[640 * 480]; //camera image buffer finalBuf = new unsigned char[640 * 480]; //final mask buffer finalImageBuf = new unsigned char[640 * 480 * 3]; //final Image buffer sceneBuffer = new unsigned char[640 * 480 * 3]; //copy of the scene in the FBO bDraw = false; //tracker = new ARToolKitPlus::TrackerSingleMarkerImpl<6,6,6, 1, 8>(width,height); tracker = new ARToolKitPlus::TrackerMultiMarkerImpl<6,6,6, 1, 64>(width,height); tracker->setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_LUM); //markerboard_480-499.cfg if( !tracker->init( (const char *)ofToDataPath("bluedot.cfg").c_str(), (const char *)ofToDataPath("conf.cfg").c_str(), 1.0f, 1000.0f) ) // load std. ARToolKit camera file { printf("ERROR: init() failed\n"); delete tracker; return; } // the marker in the BCH test image has a thin border... tracker->setBorderWidth(0.125f); // set a threshold. alternatively we could also activate automatic thresholding //tracker->setThreshold(150); tracker->activateAutoThreshold(true); // let's use lookup-table undistortion for high-speed // note: LUT only works with images up to 1024x1024 tracker->setUndistortionMode(ARToolKitPlus::UNDIST_LUT); // RPP is more robust than ARToolKit's standard pose estimator tracker->setPoseEstimator(ARToolKitPlus::POSE_ESTIMATOR_RPP); tracker->setImageProcessingMode(ARToolKitPlus::IMAGE_FULL_RES); // switch to simple ID based markers // use the tool in tools/IdPatGen to generate markers tracker->setMarkerMode(ARToolKitPlus::MARKER_ID_SIMPLE); netThread = new NetworkThread(this); netThread->start(); //load textures ofDisableArbTex(); ofSetTextureWrap(); textures[0].loadImage("grass.png"); textures[1].loadImage("cobble.png"); textures[2].loadImage("dirt.png"); textures[3].loadImage("lava.png"); textures[4].loadImage("rock.png"); textures[5].loadImage("sand.png"); textures[6].loadImage("snow.png"); textures[7].loadImage("tree.png"); textures[8].loadImage("leaves.png"); mapWidth = 20; mapHeight = 20; mapDepth = 20; mapLocked = false; //fill our 3d vector with 20x20x20 mapLocked = true; array3D.resize(mapWidth); for (int i = 0; i < mapWidth; ++i) { array3D[i].resize(mapHeight); for (int j = 0; j < mapHeight; ++j) array3D[i][j].resize(mapDepth); } //create block face data and clear map Block b; vList[0] = ofxVec3f(0.0f, 0.0f, -1.0f); vList[1] = ofxVec3f(-1.0f, 0.0f, -1.0f); vList[2] = ofxVec3f(-1.0f, 0.0f, 0.0f); vList[3] = ofxVec3f(0.0f, 0.0f, 0.0f); vList[4] = ofxVec3f(-1.0f, -1.0f, 0.0f); vList[5] = ofxVec3f(0.0f, -1.0f, 0.0f); vList[6] = ofxVec3f(0.0f, -1.0f, -1.0f); vList[7] = ofxVec3f(-1.0f, -1.0f, -1.0f); //vertex indices for faces const static int faceVals[6][4] = { {2, 1, 0, 3}, //top {5, 4, 2, 3}, //front {0, 6, 5, 3},//right {4, 7, 1, 2},//left {5, 6, 7, 5},//bottom {0, 1, 7, 6} //back }; for(int x=0; x < mapWidth; x++){ for(int y=0; y < mapHeight; y++){ for(int z=0; z < mapDepth; z++){ b.type = NONE; b.textured = false; b.visMask = VIS_TOP; for(int a = 0; a < 6; a++){ for (int c = 0; c < 4; c++){ b.faceList[a][c] = faceVals[a][c]; } } array3D[x][y][z] = b; } } } //add some test blocks to play with when offline b.type = GRASS; b.textured = true; b.textureRef = 0; b.visMask = 63; array3D[1][1][5] = b; array3D[2][1][5] = b; array3D[3][1][5] = b; array3D[4][1][5] = b; array3D[5][1][5] = b; array3D[6][1][5] = b; //testBlock = b; //run the face visibility and normal calculations updateVisibility(); //dont draw the gui guiDraw = false; //scale and offset for map mapScale = 1.0f; offset.x = -100.0f; offset.y = 100.0f; scVal = 1.0f; //used as light colour (when lights eventually work) sceneWhiteLevel = ofColor(255,255,255); #ifdef SYPHON //start up syphon and set framerate mainOutputSyphonServer.setName("Minecraft"); #endif ofSetFrameRate(60); //try and set up some lights light light = { {0,50,0,1}, //position (the final 1 means the light is positional) {1,1,1,1}, //diffuse {0,0,0,1}, //specular {0,0,0,1} //ambient }; light0 = light; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); //glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0); //sets lighting to one-sided glLightfv(GL_LIGHT0, GL_POSITION, light0.pos); doLights(); //turn on backface culling glEnable(GL_CULL_FACE); }
void MFixedRenderer::drawScene(MScene * scene, MOCamera * camera) { M_PROFILE_SCOPE(MFixedRenderer::drawScene); struct MEntityLight { MBox3d lightBox; MOLight * light; }; struct MSubMeshPass { unsigned int subMeshId; unsigned int lightsNumber; MObject3d * object; MOLight * lights[4]; }; // sub objects #define MAX_TRANSP_SUBOBJ 4096 static int transpList[MAX_TRANSP_SUBOBJ]; static float transpZList[MAX_TRANSP_SUBOBJ]; static MSubMeshPass transpSubObjs[MAX_TRANSP_SUBOBJ]; // lights list #define MAX_ENTITY_LIGHTS 256 static int entityLightsList[MAX_ENTITY_LIGHTS]; static float entityLightsZList[MAX_ENTITY_LIGHTS]; static MEntityLight entityLights[MAX_ENTITY_LIGHTS]; // get render MRenderingContext * render = MEngine::getInstance()->getRenderingContext(); render->enableLighting(); render->enableBlending(); // make frustum MFrustum * frustum = camera->getFrustum(); frustum->makeVolume(camera); // update visibility updateVisibility(scene, camera); // fog enableFog(camera); // camera MVector3 cameraPos = camera->getTransformedPosition(); // transp sub obj number unsigned int transpSubObsNumber = 0; // lights unsigned int l; unsigned int lSize = scene->getLightsNumber(); // entities unsigned int i; unsigned int eSize = scene->getEntitiesNumber(); for(i=0; i<eSize; i++) { // get entity MOEntity * entity = scene->getEntityByIndex(i); MMesh * mesh = entity->getMesh(); if(! entity->isActive()) continue; if(! entity->isVisible()) { if(mesh) { MArmature * armature = mesh->getArmature(); MArmatureAnim * armatureAnim = mesh->getArmatureAnim(); if(armature) { // animate armature if(armatureAnim) animateArmature( mesh->getArmature(), mesh->getArmatureAnim(), entity->getCurrentFrame() ); // TODO : optimize and add a tag to desactivate it updateSkinning(mesh, armature); (*entity->getBoundingBox()) = (*mesh->getBoundingBox()); } } continue; } // draw mesh if(mesh) { MVector3 scale = entity->getTransformedScale(); MBox3d * entityBox = entity->getBoundingBox(); float minScale = scale.x; minScale = MIN(minScale, scale.y); minScale = MIN(minScale, scale.z); minScale = 1.0f / minScale; unsigned int entityLightsNumber = 0; for(l=0; l<lSize; l++) { // get entity MOLight * light = scene->getLightByIndex(l); if(! light->isActive()) continue; if(! light->isVisible()) continue; // light box MVector3 lightPos = light->getTransformedPosition(); MVector3 localPos = entity->getInversePosition(lightPos); float localRadius = light->getRadius() * minScale; MBox3d lightBox( MVector3(localPos - localRadius), MVector3(localPos + localRadius) ); if(! entityBox->isInCollisionWith(&lightBox)) continue; MEntityLight * entityLight = &entityLights[entityLightsNumber]; entityLight->lightBox = lightBox; entityLight->light = light; entityLightsNumber++; if(entityLightsNumber == MAX_ENTITY_LIGHTS) break; } // animate armature if(mesh->getArmature() && mesh->getArmatureAnim()) animateArmature( mesh->getArmature(), mesh->getArmatureAnim(), entity->getCurrentFrame() ); // animate textures if(mesh->getTexturesAnim()) animateTextures(mesh, mesh->getTexturesAnim(), entity->getCurrentFrame()); // animate materials if(mesh->getMaterialsAnim()) animateMaterials(mesh, mesh->getMaterialsAnim(), entity->getCurrentFrame()); unsigned int s; unsigned int sSize = mesh->getSubMeshsNumber(); for(s=0; s<sSize; s++) { MSubMesh * subMesh = &mesh->getSubMeshs()[s]; MBox3d * box = subMesh->getBoundingBox(); // check if submesh visible if(sSize > 1) { MVector3 * min = box->getMin(); MVector3 * max = box->getMax(); MVector3 points[8] = { entity->getTransformedVector(MVector3(min->x, min->y, min->z)), entity->getTransformedVector(MVector3(min->x, max->y, min->z)), entity->getTransformedVector(MVector3(max->x, max->y, min->z)), entity->getTransformedVector(MVector3(max->x, min->y, min->z)), entity->getTransformedVector(MVector3(min->x, min->y, max->z)), entity->getTransformedVector(MVector3(min->x, max->y, max->z)), entity->getTransformedVector(MVector3(max->x, max->y, max->z)), entity->getTransformedVector(MVector3(max->x, min->y, max->z)) }; if(! frustum->isVolumePointsVisible(points, 8)) continue; } // subMesh center MVector3 center = (*box->getMin()) + ((*box->getMax()) - (*box->getMin()))*0.5f; center = entity->getTransformedVector(center); // sort entity lights unsigned int lightsNumber = 0; for(l=0; l<entityLightsNumber; l++) { MEntityLight * entityLight = &entityLights[l]; if(! box->isInCollisionWith(&entityLight->lightBox)) continue; MOLight * light = entityLight->light; float z = (center - light->getTransformedPosition()).getLength(); entityLightsList[lightsNumber] = l; entityLightsZList[l] = (1.0f/z)*light->getRadius(); lightsNumber++; } if(lightsNumber > 1) sortFloatList(entityLightsList, entityLightsZList, 0, (int)lightsNumber-1); // local lights if(lightsNumber > 4) lightsNumber = 4; for(l=0; l<lightsNumber; l++) { MEntityLight * entityLight = &entityLights[entityLightsList[l]]; MOLight * light = entityLight->light; // attenuation float quadraticAttenuation = (8.0f / light->getRadius()); quadraticAttenuation = (quadraticAttenuation*quadraticAttenuation)*light->getIntensity(); // color MVector3 color = light->getFinalColor(); // set light render->enableLight(l); render->setLightPosition(l, light->getTransformedPosition()); render->setLightDiffuse(l, MVector4(color)); render->setLightSpecular(l, MVector4(color)); render->setLightAmbient(l, MVector3(0, 0, 0)); render->setLightAttenuation(l, 1, 0, quadraticAttenuation); // spot render->setLightSpotAngle(l, light->getSpotAngle()); if(light->getSpotAngle() < 90){ render->setLightSpotDirection(l, light->getRotatedVector(MVector3(0, 0, -1)).getNormalized()); render->setLightSpotExponent(l, light->getSpotExponent()); } else { render->setLightSpotExponent(l, 0.0f); } } for(l=lightsNumber; l<4; l++){ render->disableLight(l); } render->pushMatrix(); render->multMatrix(entity->getMatrix()); // draw opaques drawOpaques(subMesh, mesh->getArmature()); if(subMesh->hasTransparency()) { if(transpSubObsNumber < MAX_TRANSP_SUBOBJ) { // transparent subMesh pass MSubMeshPass * subMeshPass = &transpSubObjs[transpSubObsNumber]; // lights subMeshPass->lightsNumber = lightsNumber; for(l=0; l<lightsNumber; l++) subMeshPass->lights[l] = entityLights[entityLightsList[l]].light; // z distance to camera float z = getDistanceToCam(camera, center); // set values transpList[transpSubObsNumber] = transpSubObsNumber; transpZList[transpSubObsNumber] = z; subMeshPass->subMeshId = s; subMeshPass->object = entity; transpSubObsNumber++; } } render->popMatrix(); } mesh->updateBoundingBox(); (*entity->getBoundingBox()) = (*mesh->getBoundingBox()); } } // texts unsigned int tSize = scene->getTextsNumber(); for(i=0; i<tSize; i++) { MOText * text = scene->getTextByIndex(i); if(text->isActive() && text->isVisible()) { // transparent pass MSubMeshPass * subMeshPass = &transpSubObjs[transpSubObsNumber]; // center MBox3d * box = text->getBoundingBox(); MVector3 center = (*box->getMin()) + ((*box->getMax()) - (*box->getMin()))*0.5f; center = text->getTransformedVector(center); // z distance to camera float z = getDistanceToCam(camera, center); // set values transpList[transpSubObsNumber] = transpSubObsNumber; transpZList[transpSubObsNumber] = z; subMeshPass->object = text; transpSubObsNumber++; } } // sort transparent list if(transpSubObsNumber > 1) sortFloatList(transpList, transpZList, 0, (int)transpSubObsNumber-1); // draw transparents for(i=0; i<transpSubObsNumber; i++) { MSubMeshPass * subMeshPass = &transpSubObjs[transpList[i]]; MObject3d * object = subMeshPass->object; // objects switch(object->getType()) { case M_OBJECT3D_ENTITY: { MOEntity * entity = (MOEntity *)object; unsigned int subMeshId = subMeshPass->subMeshId; MMesh * mesh = entity->getMesh(); MSubMesh * subMesh = &mesh->getSubMeshs()[subMeshId]; // animate armature if(mesh->getArmature() && mesh->getArmatureAnim()) animateArmature( mesh->getArmature(), mesh->getArmatureAnim(), entity->getCurrentFrame() ); // animate textures if(mesh->getTexturesAnim()) animateTextures(mesh, mesh->getTexturesAnim(), entity->getCurrentFrame()); // animate materials if(mesh->getMaterialsAnim()) animateMaterials(mesh, mesh->getMaterialsAnim(), entity->getCurrentFrame()); // lights for(l=0; l<subMeshPass->lightsNumber; l++) { MOLight * light = subMeshPass->lights[l]; // attenuation float quadraticAttenuation = (8.0f / light->getRadius()); quadraticAttenuation = (quadraticAttenuation*quadraticAttenuation)*light->getIntensity(); // color MVector3 color = light->getFinalColor(); // set light render->enableLight(l); render->setLightPosition(l, light->getTransformedPosition()); render->setLightDiffuse(l, MVector4(color)); render->setLightSpecular(l, MVector4(color)); render->setLightAmbient(l, MVector3(0, 0, 0)); render->setLightAttenuation(l, 1, 0, quadraticAttenuation); // spot render->setLightSpotAngle(l, light->getSpotAngle()); if(light->getSpotAngle() < 90){ render->setLightSpotDirection(l, light->getRotatedVector(MVector3(0, 0, -1)).getNormalized()); render->setLightSpotExponent(l, light->getSpotExponent()); } else { render->setLightSpotExponent(l, 0.0f); } } for(l=subMeshPass->lightsNumber; l<4; l++){ render->disableLight(l); } render->pushMatrix(); render->multMatrix(entity->getMatrix()); drawTransparents(subMesh, mesh->getArmature()); render->popMatrix(); mesh->updateBoundingBox(); (*entity->getBoundingBox()) = (*mesh->getBoundingBox()); } break; case M_OBJECT3D_TEXT: { MOText * text = (MOText *)object; render->pushMatrix(); render->multMatrix(text->getMatrix()); drawText(text); render->popMatrix(); } break; } } render->disableLighting(); render->disableFog(); }
void testApp::processShit(const string& s){ char * results; char * cstr; //cout << "mess: " << s << endl; cstr = new char [s.size()+1]; strcpy (cstr, s.c_str()); results = strtok(cstr, ","); if(results[0] == 's'){ //cout << "mess: " << results[0] <<endl; int currentY, currentZ; currentY = 0; currentZ = 0; int curCount = 0; int ct = 0; while (results != NULL){ if(ct == 1){ currentY = atoi(results); ct++; } else if (ct == 2){ currentZ = atoi(results); //clear that row for(int x = 0; x < 20; x++){ array3D[x][currentY][currentZ].type = NONE; } // cout << "HOT DOGGETY" << endl; curCount = 0; ct++; } else { int type = atoi(results); setBlock(curCount,currentY,currentZ, type); curCount++; ct++; } results = strtok(NULL, ","); } /* } else if(s.substr(0, 4) == "del:"){ //<([-]?[0-9]*):([-]?[0-9]*):([-]?[0-9]*)> } else if(s.substr(0, 4) == "add:"){ //<([0-9]*)><([-]?[0-9]*):([-]?[0-9]*):([-]?[0-9]*)> } else if(s.substr(0, 7) == "player:"){ //<([0-9]*)><([-]?[0-9\\.]*):([-]?[0-9\\.]*):([-]?[0-9\\.]*)> //get the player pos, this should happen every 50ms } else if(s.substr(0, 9) == "starting:"){ //<([-]?[0-9]*)><([-]?[0-9]*)><([-]?[0-9]*)><([-]?[0-9]*)><([-]?[0-9]*)><([-]?[0-9]*)> */ updateVisibility(); } else if(results[0] == 'a'){ int ct = 0; int currentX = -1; int currentY = -1; int currentZ = -1; int type = 0; while (results != NULL){ if(ct == 1){ type = atoi(results); cout << "add block id: " << type << endl; ct++; } else if (ct == 2){ currentX = atoi(results); ct++; } else if (ct == 3){ currentY = atoi(results); ct++; }else if (ct == 4){ currentZ = atoi(results); ct++; } else { ct++; } results = strtok(NULL, ","); } if(currentX >= 0 && currentX < mapWidth && currentY >= 0 && currentY < mapHeight && currentZ >= 0 && currentZ < mapDepth){ setBlock(currentX, currentY, currentZ, type); cout << "added" << endl; } updateVisibility(); } else if(results[0] == 'd'){ int ct = 0; int currentX = -1; int currentY = -1; int currentZ = -1; int type = 0; while (results != NULL){ if (ct == 1){ currentX = atoi(results); ct++; } else if (ct == 2){ currentY = atoi(results); ct++; }else if (ct == 3){ currentZ = atoi(results); ct++; } else { ct++; } results = strtok(NULL, ","); } if(currentX >= 0 && currentX < mapWidth && currentY >= 0 && currentY < mapHeight && currentZ >= 0 && currentZ < mapDepth){ setBlock(currentX, currentY, currentZ, 0); cout << "delete" << endl; } updateVisibility(); } else if(results[0] == 'p'){ int ct = 0; float currentX = -1; float currentY = -1; float currentZ = -1; int playerId = 0; while (results != NULL){ if (ct == 1){ //player id playerId = atoi(results); //cout << "player id: " << playerId << endl; ct++; } else if (ct == 2){ //x p.xPos = strtod(results,NULL); //cout << currentX << endl; ct++; }else if (ct == 3){ //y p.yPos = strtod(results,NULL); ct++; } else if (ct == 4){ //z p.zPos = strtod(results,NULL); ct++; } else { ct++; } results = strtok(NULL, ","); } //cout << "pos" << endl; p.lastUpdateTime = ofGetElapsedTimeMillis(); } // delete cstr; // delete results; }
void EditableLabel::showInput() { m_label_shown = false; updateVisibility(); m_input->setFocus(); }
void TabBar::tabInserted(int position) { Q_UNUSED(position); updateVisibility(); }
JointInfo::JointInfo(const std::string name, rviz::Property* parent_category) { name_ = name; effort_ = 0; max_effort_ = 0; last_update_ = ros::Time::now(); //info->category_ = new Property( QString::fromStdString( info->name_ ) , QVariant(), "", joints_category_); category_ = new rviz::Property( QString::fromStdString( name_ ) , true, "", parent_category, SLOT( updateVisibility() ), this); effort_property_ = new rviz::FloatProperty( "Effort", 0, "Effort value of this joint.", category_); effort_property_->setReadOnly( true ); max_effort_property_ = new rviz::FloatProperty( "Max Effort", 0, "Max Effort value of this joint.", category_); max_effort_property_->setReadOnly( true ); }
void TabBar::tabRemoved(int position) { Q_UNUSED(position); updateVisibility(); }
void GfxLight::setSpecularColour (const Vector3 &v) { if (dead) THROW_DEAD(className); specular = v; updateVisibility(); }
SUMOTime MSDevice_BTreceiver::BTreceiverUpdate::execute(SUMOTime /*currentTime*/) { // build rtree with senders NamedRTree rt; for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::const_iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end(); ++i) { MSDevice_BTsender::VehicleInformation* vi = (*i).second; Boundary b = vi->getBoxBoundary(); b.grow(POSITION_EPS); const float cmin[2] = {(float) b.xmin(), (float) b.ymin()}; const float cmax[2] = {(float) b.xmax(), (float) b.ymax()}; rt.Insert(cmin, cmax, vi); } // check visibility for all receivers OptionsCont& oc = OptionsCont::getOptions(); bool allRecognitions = oc.getBool("device.btreceiver.all-recognitions"); bool haveOutput = oc.isSet("bt-output"); for (std::map<std::string, MSDevice_BTreceiver::VehicleInformation*>::iterator i = MSDevice_BTreceiver::sVehicles.begin(); i != MSDevice_BTreceiver::sVehicles.end();) { // collect surrounding vehicles MSDevice_BTreceiver::VehicleInformation* vi = (*i).second; Boundary b = vi->getBoxBoundary(); b.grow(vi->range); const float cmin[2] = {(float) b.xmin(), (float) b.ymin()}; const float cmax[2] = {(float) b.xmax(), (float) b.ymax()}; std::set<std::string> surroundingVehicles; Named::StoringVisitor sv(surroundingVehicles); rt.Search(cmin, cmax, sv); // loop over surrounding vehicles, check visibility status for (std::set<std::string>::const_iterator j = surroundingVehicles.begin(); j != surroundingVehicles.end(); ++j) { if ((*i).first == *j) { // seeing oneself? skip continue; } updateVisibility(*vi, *MSDevice_BTsender::sVehicles.find(*j)->second); } if (vi->haveArrived) { // vehicle has left the simulation; remove if (haveOutput) { writeOutput((*i).first, vi->seen, allRecognitions); } delete vi; MSDevice_BTreceiver::sVehicles.erase(i++); } else { // vehicle is still in the simulation; reset state vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1); ++i; } } // remove arrived senders / reset state for (std::map<std::string, MSDevice_BTsender::VehicleInformation*>::iterator i = MSDevice_BTsender::sVehicles.begin(); i != MSDevice_BTsender::sVehicles.end();) { MSDevice_BTsender::VehicleInformation* vi = (*i).second; if (vi->haveArrived) { delete vi; MSDevice_BTsender::sVehicles.erase(i++); } else { vi->updates.erase(vi->updates.begin(), vi->updates.end() - 1); ++i; } } return DELTA_T; }
void GfxLight::setFade (float f) { if (dead) THROW_DEAD(className); fade = f; updateVisibility(); }
TabView::TabView(TraceItemView* parentView, QWidget* parent, const char* name) : QWidget(parent), TraceItemView(parentView) { setFocusPolicy(Qt::StrongFocus); setObjectName(name); _isCollapsed = true; QVBoxLayout* vbox = new QVBoxLayout( this ); vbox->setSpacing( 6 ); vbox->setMargin( 6 ); _nameLabel = new QLabel(this); //KSqueezedTextLabel( this); _nameLabel->setSizePolicy(QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed )); _nameLabel->setObjectName( "nameLabel" ); _nameLabel->setText(tr("(No profile data file loaded)")); vbox->addWidget( _nameLabel ); updateNameLabel(tr("(No profile data file loaded)")); _mainSplitter = new QSplitter(Qt::Horizontal, this); _leftSplitter = new Splitter(Qt::Vertical, _mainSplitter, "Left"); vbox->addWidget( _mainSplitter ); _rightTW = new TabWidget(this, _mainSplitter, "Right"); connect(_rightTW, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged(QWidget*))); connect(_rightTW, SIGNAL(visibleRectChanged(TabWidget*)), this, SLOT(visibleRectChangedSlot(TabWidget*))); _topTW = new TabWidget(this, _leftSplitter, "Top"); connect(_topTW, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged(QWidget*))); connect(_topTW, SIGNAL(visibleRectChanged(TabWidget*)), this, SLOT(visibleRectChangedSlot(TabWidget*))); _bottomSplitter = new Splitter(Qt::Horizontal, _leftSplitter, "Bottom"); _leftTW = new TabWidget(this, _bottomSplitter, "Left"); _leftTW->setTabPosition(QTabWidget::Bottom); connect(_leftTW, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged(QWidget*))); connect(_leftTW, SIGNAL(visibleRectChanged(TabWidget*)), this, SLOT(visibleRectChangedSlot(TabWidget*))); _bottomTW = new TabWidget(this, _bottomSplitter, "Bottom"); _bottomTW->setTabPosition(QTabWidget::Bottom); connect(_bottomTW, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged(QWidget*))); connect(_bottomTW, SIGNAL(visibleRectChanged(TabWidget*)), this, SLOT(visibleRectChangedSlot(TabWidget*))); CallView* callerView = new CallView(true, this); CallView* calleeView = new CallView(false, this); CoverageView * allCallerView = new CoverageView(true, this); CoverageView * allCalleeView = new CoverageView(false, this); // Options of visualization views are stored by their view name callerView->setObjectName("CallerView"); calleeView->setObjectName("CalleeView"); allCallerView->setObjectName("AllCallerView"); allCalleeView->setObjectName("AllCalleeView"); // default positions... // Keep following order in sync with DEFAULT_xxxTABS defines! addTop( addTab( tr("Types"), new EventTypeView(this, 0, "EventTypeView"))); addTop( addTab( tr("Callers"), callerView) ); addTop( addTab( tr("All Callers"), allCallerView) ); addTop( addTab( tr("Callee Map"), new CallMapView(false, this, 0, "CalleeMapView"))); addTop( addTab( tr("Source Code"), new SourceView(this, 0, "SourceView"))); addBottom( addTab( tr("Parts"), new PartView(this, 0, "PartView"))); addBottom( addTab( tr("Callees"), calleeView) ); addBottom( addTab( tr("Call Graph"), new CallGraphView(this, 0, "CallGraphView"))); addBottom( addTab( tr("All Callees"), allCalleeView) ); addBottom( addTab( tr("Caller Map"), new CallMapView(true, this, 0, "CallerMapView"))); addBottom( addTab( tr("Machine Code"), new InstrView(this, 0, "InstrView"))); // after all child widgets are created... _lastFocus = 0; _active = false; installFocusFilters(); updateVisibility(); this->setWhatsThis( whatsThis() ); }