예제 #1
0
    void SpineDrawable::setSkin(const std::string& skinName)
    {
        spSkin* skin = spSkeletonData_findSkin(skeletonData, skinName.c_str());
        spSkeleton_setSkin(skeleton, skin);

        updateMaterials();
        updateBoundingBox();
    }
예제 #2
0
void ImpostorTexture::regenerate()
{
	assert(!texture.isNull());
	String texName(texture->getName());
	texture.setNull();
	if (TextureManager::getSingletonPtr())
		TextureManager::getSingleton().remove(texName);

	renderTextures(true);
	updateMaterials();
}
void FormMaterialIndicesManager::pasteImageFromClipboard(QImage& _image){


    int mIndex = FBOImageProporties::currentMaterialIndeks;
    if(updateMaterials(_image)){
          image    = _image;
          imageProp.init(image);
          emit materialChanged();
          FBOImageProporties::currentMaterialIndeks = mIndex;
          emit imageLoaded(image.width(),image.height());
          // repaint all materials
          if(FBOImageProporties::currentMaterialIndeks != MATERIALS_DISABLED){
              toggleMaterials(true);
          }
    }
}
void FormMaterialIndicesManager::setImage(QImage _image){

    if (imageProp.glWidget_ptr->isValid()){
        // remember the last id
        int mIndex = FBOImageProporties::currentMaterialIndeks;
        if(updateMaterials(_image)){
              image    = _image;
              imageProp.init(image);
              emit materialChanged();
        }

        FBOImageProporties::currentMaterialIndeks = mIndex ;

    }
    else
        qDebug() << Q_FUNC_INFO << "Invalid context.";
}
bool FormMaterialIndicesManager::loadFile(const QString &fileName)
{
    QFileInfo fileInfo(fileName);
    QImage _image;

    // Targa support added
    if(fileInfo.completeSuffix().compare("tga") == 0){
        TargaImage tgaImage;
        _image = tgaImage.read(fileName);
    }else{
        QImageReader loadedImage(fileName);
        _image = loadedImage.read();
    }

    if (_image.isNull()) {
        QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
                                 tr("Cannot load material image %1.").arg(QDir::toNativeSeparators(fileName)));
        return false;
    }

    qDebug() << "<FormImageProp> Open material image:" << fileName;


    (*FormImageProp::recentDir).setPath(fileName);

    int mIndex = FBOImageProporties::currentMaterialIndeks;
    if(updateMaterials(_image)){
          image    = _image;
          imageProp.init(image);
          emit materialChanged();
          FBOImageProporties::currentMaterialIndeks = mIndex;
          emit imageLoaded(image.width(),image.height());
          // repaint all materials
          if(FBOImageProporties::currentMaterialIndeks != MATERIALS_DISABLED){
              toggleMaterials(true);
          }
    }
    return true;
}
예제 #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowTitle( tr("TerraGear GUI") );

    // create MapControl
    mc = new MapControl(QSize(458, 254));
    mc->setMinimumSize(QSize(458,254));
    mc->showScale(true);
    mapadapter = new OSMMapAdapter();
    mainlayer = new MapLayer("OpenStreetMap-Layer", mapadapter);
    mc->addLayer(mainlayer);
    connect(mc, SIGNAL(boxDragged(QRectF)),
            this, SLOT(draggedRect(QRectF)));
    addZoomButtons();
    mc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    ui->mapLayout-> addWidget(mc);

    // restore variables from previous session
    loadSettings();

    // TAB: Airports
    updateAirportRadios(); // hide the non-selected options

    // TAB: Construct
    ui->shapefilesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->shapefilesTable->setHorizontalHeaderLabels(QStringList() << tr("Shapefile") << tr("Material"));
#if QT_VERSION >= 0x050000
    ui->shapefilesTable->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch);
#else
	ui->shapefilesTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif
    ui->shapefilesTable->horizontalHeader()->setStyleSheet("font: bold;");
    ui->shapefilesTable->verticalHeader()->hide();

    // create sub-directory variables
    dataDirectory = projectDirectory+"/data";
    outpDirectory = projectDirectory+"/output";
    workDirectory = projectDirectory+"/work";

    // run functions on startup
    if (flightgearDirectory != 0) {
        updateMaterials();
        if (airportFile.size() == 0) {
            // try to find apt.dat.gz file
            QString apfile = flightgearDirectory+"/Airports/apt.dat.gz";
            QFile apf(apfile);
            if (apf.exists()) {
                airportFile = apfile;
                settings.setValue("paths/airportFile", airportFile); // keep the airport file found
            }
        }
        if (airportFile.size())
            ui->aptFileField->setText(airportFile);
    }

    // re-apply the check boxes (for construct)
    bool ign_lm = settings.value("check/ignore_landmass").toBool();
    ui->ignoreLandmassCB->setCheckState(ign_lm ? Qt::Checked : Qt::Unchecked);

    // Network manager
    _manager = new QNetworkAccessManager(this);
    connect(_manager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*)));

    m_break = false;

    if (ui->tabWidget->currentIndex() == 1) {
        ui->textBrowser->hide();
        mc->resize(QSize(458,254));
    }

    // add context menu to table
    connect(ui->shapefilesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayMenu(QPoint)));
}
예제 #7
0
	virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay)
	{
		if (overlay->button("Randomize")) {
			updateMaterials();
		}
	}
예제 #8
0
    SpineDrawable::SpineDrawable(const std::string& atlasFile, const std::string& skeletonFile):
        Component(TYPE)
    {
        atlas = spAtlas_createFromFile(atlasFile.c_str(), 0);
        if (!atlas)
        {
            ouzel::Log(ouzel::Log::Level::ERR) << "Failed to load atlas";
            return;
        }

        if (skeletonFile.find(".json") != std::string::npos)
        {
            // is json format
            spSkeletonJson* json = spSkeletonJson_create(atlas);
            skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonFile.c_str());
            
            if (!skeletonData)
            {
                ouzel::Log(ouzel::Log::Level::ERR) << "Failed to load skeleton: " << json->error;
                return;
            }
            spSkeletonJson_dispose(json);
        }
        else
        {
            // binary format
            spSkeletonBinary* binary = spSkeletonBinary_create(atlas);
            skeletonData = spSkeletonBinary_readSkeletonDataFile(binary, skeletonFile.c_str());
            
            if (!skeletonData)
            {
                ouzel::Log(ouzel::Log::Level::ERR) << "Failed to load skeleton: " << binary->error;
                return;
            }
            spSkeletonBinary_dispose(binary);
        }

        bounds = spSkeletonBounds_create();

        skeleton = spSkeleton_create(skeletonData);

        animationStateData = spAnimationStateData_create(skeletonData);
        
        animationState = spAnimationState_create(animationStateData);
        animationState->listener = listener;
        animationState->rendererObject = this;

        spSkeleton_setToSetupPose(skeleton);
        spSkeleton_updateWorldTransform(skeleton);

        updateMaterials();
        updateBoundingBox();

        indexBuffer = std::make_shared<ouzel::graphics::Buffer>(*ouzel::engine->getRenderer());
        indexBuffer->init(ouzel::graphics::Buffer::Usage::INDEX, ouzel::graphics::Buffer::DYNAMIC);

        vertexBuffer = std::make_shared<ouzel::graphics::Buffer>(*ouzel::engine->getRenderer());
        vertexBuffer->init(ouzel::graphics::Buffer::Usage::VERTEX, ouzel::graphics::Buffer::DYNAMIC);

        whitePixelTexture = ouzel::engine->getCache().getTexture(ouzel::TEXTURE_WHITE_PIXEL);

        updateHandler.updateHandler = std::bind(&SpineDrawable::handleUpdate, this, std::placeholders::_1);
        ouzel::engine->getEventDispatcher().addEventHandler(&updateHandler);
    }