Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. color on q3dsurface only shows when zooming in
Forum Updated to NodeBB v4.3 + New Features

color on q3dsurface only shows when zooming in

Scheduled Pinned Locked Moved Solved Game Development
2 Posts 1 Posters 647 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stevereine
    wrote on last edited by
    #1

    I've drawn a simple Q3DSurface. All seems to work OK, except the color only appears when I right click, mouse wheel zoom in, as close as I can to the surface. This is true for a solid color or a linear gradient. I've been through the Q3DSurface example line by line (the example works fine, I see the color immediately when I run the app) and I can't see anything significant that I think would cause this behavior. Can someone point out what I may be dong wrong? Note that the variable 'graph' is a Q3DSurface object.

    m_dataProxy = new QSurfaceDataProxy();
    m_dataSeries = new QSurface3DSeries(m_dataProxy);

    m_dataSeries->setDrawMode(QSurface3DSeries::DrawSurfaceAndWireframe);
    m_dataSeries->setFlatShadingEnabled(false);
    graph->addSeries(m_dataSeries);    
    
    QLinearGradient gr;
    gr.setColorAt(0.0, Qt::darkGreen);
    gr.setColorAt(0.5, Qt::yellow);
    gr.setColorAt(0.8, Qt::red);
    gr.setColorAt(1.0, Qt::darkRed);
    
    graph->activeTheme()->setType(Q3DTheme::ThemeQt);
    //graph->seriesList().at(0)->setBaseGradient(gr);
    //graph->seriesList().at(0)->setColorStyle(Q3DTheme::ColorStyleRangeGradient);
    
    QSurfaceDataArray *dataArray = new QSurfaceDataArray;
    dataArray->reserve(100);
    
    QSurfaceDataRow *tempRow1 = new QSurfaceDataRow(100);
    QSurfaceDataRow *tempRow2 = new QSurfaceDataRow(100);
    QSurfaceDataRow *tempRow3 = new QSurfaceDataRow(100);
    
    for (int i = 0 ; i < 100 ; i++)
    {
    (*tempRow1)[99-i].setPosition(QVector3D(i,1.0f,-50.0f));
    (*tempRow2)[99-i].setPosition(QVector3D(i,3.0f,0.0f));
    (*tempRow3)[99-i].setPosition(QVector3D(i,5.0f,50.0f));
    }
    
    *dataArray << tempRow1;
    *dataArray << tempRow2;
    *dataArray << tempRow3;
    
    m_dataProxy->resetArray(dataArray);
    
    graph->show();
    
    S 1 Reply Last reply
    0
    • S stevereine

      I've drawn a simple Q3DSurface. All seems to work OK, except the color only appears when I right click, mouse wheel zoom in, as close as I can to the surface. This is true for a solid color or a linear gradient. I've been through the Q3DSurface example line by line (the example works fine, I see the color immediately when I run the app) and I can't see anything significant that I think would cause this behavior. Can someone point out what I may be dong wrong? Note that the variable 'graph' is a Q3DSurface object.

      m_dataProxy = new QSurfaceDataProxy();
      m_dataSeries = new QSurface3DSeries(m_dataProxy);

      m_dataSeries->setDrawMode(QSurface3DSeries::DrawSurfaceAndWireframe);
      m_dataSeries->setFlatShadingEnabled(false);
      graph->addSeries(m_dataSeries);    
      
      QLinearGradient gr;
      gr.setColorAt(0.0, Qt::darkGreen);
      gr.setColorAt(0.5, Qt::yellow);
      gr.setColorAt(0.8, Qt::red);
      gr.setColorAt(1.0, Qt::darkRed);
      
      graph->activeTheme()->setType(Q3DTheme::ThemeQt);
      //graph->seriesList().at(0)->setBaseGradient(gr);
      //graph->seriesList().at(0)->setColorStyle(Q3DTheme::ColorStyleRangeGradient);
      
      QSurfaceDataArray *dataArray = new QSurfaceDataArray;
      dataArray->reserve(100);
      
      QSurfaceDataRow *tempRow1 = new QSurfaceDataRow(100);
      QSurfaceDataRow *tempRow2 = new QSurfaceDataRow(100);
      QSurfaceDataRow *tempRow3 = new QSurfaceDataRow(100);
      
      for (int i = 0 ; i < 100 ; i++)
      {
      (*tempRow1)[99-i].setPosition(QVector3D(i,1.0f,-50.0f));
      (*tempRow2)[99-i].setPosition(QVector3D(i,3.0f,0.0f));
      (*tempRow3)[99-i].setPosition(QVector3D(i,5.0f,50.0f));
      }
      
      *dataArray << tempRow1;
      *dataArray << tempRow2;
      *dataArray << tempRow3;
      
      m_dataProxy->resetArray(dataArray);
      
      graph->show();
      
      S Offline
      S Offline
      stevereine
      wrote on last edited by
      #2

      @stevereine

      I solved my own problem, was drawing the graph in a Window, but not using a container to do it. It kind of works, but not very good. Always best to thoroughly understand the instructions before writing code. All is now working very well!

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved