示例#1
0
void MainWindow::setup()
{
	camera.setPosition(vec3(0,5,13.0f));
	camera.setViewDirection(vec3(0,-0.6f,-1));
	
	renderer = new RendererHelper();

	renderer->lightPosition = vec3(0,4,6);
	renderer->diffusionIntensity = 0.5f;
	renderer->specularColor = vec4(1.0f, 1.0f, 1.0f, 1.0f);
	renderer->specularExponent = 10;
	renderer->overridingObjectColor = vec3(0.5f,0.5f,0.5f);
	renderer->ambientLight = vec3(0.7f, 0.7f, 0.7f);
	renderer->eyePosition;

	setupGeometry();
	setupTransforms();
	renderer->addShader("../Resources/Shaders/LightingTextureAlphaNormalVertexShader.glsl", "../Resources/Shaders/LightingTextureAlphaNormalFragmentShader.glsl",RendererHelper::ShaderType::SHADER_LIGHTING_TEXTURE, "textureLightingShader");
	renderer->addShader("../Resources/Shaders/LightingNoiseVertexShader.glsl", "../Resources/Shaders/LightingNoiseFragmentShader.glsl",RendererHelper::ShaderType::SHADER_LIGHTING_TEXTURE, "lightingNoiseShader");
	renderer->addShader("../Resources/Shaders/PassThroughVertexShader.glsl", "../Resources/Shaders/PassThroughFragmentShader.glsl",RendererHelper::ShaderType::SHADER_PASSTHROUGH, "passThroughShader");
	setupTextures();
	setupRenderables();


	dMenu->addVec3Slider("tab", &(renderer->lightPosition),-20,20,-20,20,-20,20,"light");
	/*dMenu->addFloatSlider("tab", &heightMin, -1, 0, "Height Min");
	dMenu->addFloatSlider("tab", &heightMax, 0,1, "Height Max");
	dMenu->addFloatSlider("tab", &heightIncrement, 0.01f, 1, "Increment");
	dMenu->addFloatSlider("tab", &burnThreshold, 0.0f, 1, "burnThreshold");*/
}
示例#2
0
void GrGpu::drawIndexed(GrPrimitiveType type,
                        int startVertex,
                        int startIndex,
                        int vertexCount,
                        int indexCount) {
    GrAssert(kReserved_GeometrySrcType != fGeometrySrc.fVertexSrc ||
             fReservedGeometry.fLocked);
    GrAssert(kReserved_GeometrySrcType != fGeometrySrc.fIndexSrc ||
             fReservedGeometry.fLocked);

    this->handleDirtyContext();

    if (!this->setupClipAndFlushState(type)) {
        return;
    }

#if GR_COLLECT_STATS
    fStats.fVertexCnt += vertexCount;
    fStats.fIndexCnt  += indexCount;
    fStats.fDrawCnt   += 1;
#endif

    int sVertex = startVertex;
    int sIndex = startIndex;
    setupGeometry(&sVertex, &sIndex, vertexCount, indexCount);

    drawIndexedHelper(type, sVertex, sIndex,
                      vertexCount, indexCount);
}
示例#3
0
void TwLayoutManager::layout()
{
    if (m_dirty || m_cacheHostSize != m_hostWidget->size())
    {
        setupGeometry();
        layoutWidgets();
        m_cacheHostSize = m_hostWidget->size();
    }
}
void
ColladaGeometry::readTriangles(domMesh *mesh, domTriangles *triangles)
{
    OSG_COLLADA_LOG(("ColladaGeometry::readTriangles\n"));

    const domInputLocal_Array       &vertInputs =
        mesh->getVertices()->getInput_array();
    const domInputLocalOffset_Array &inputs     =
        triangles          ->getInput_array();

    IndexStore idxStore;
    UInt32     geoIdx   = setupGeometry(vertInputs, inputs,
                                        triangles->getMaterial(), idxStore);

    const domListOfUInts &pList   = triangles->getP()->getValue();
    UInt32                currIdx = 0;
    UInt32                length  = 0;

    for(UInt32 i = 0; i < pList.getCount(); ++i)
    {
        idxStore[currIdx]->push_back(pList[i]);

        ++currIdx;

        if(currIdx == idxStore.size())
        {
            currIdx = 0;
            ++length;
        }
    }

    _geoStore[geoIdx]._types  ->push_back(GL_TRIANGLES);
    _geoStore[geoIdx]._lengths->push_back(length      );

    OSG_COLLADA_LOG(("ColladaGeometry::readTriangles: material symbol [%s] "
                     "vertices [%d] triangles [%d]\n",
                     (triangles->getMaterial() != NULL ?
                      triangles->getMaterial() : ""),
                     length, length/3));

    if(length == 0)
    {
        SWARNING << "ColladaGeometry::readTriangles: Empty <triangles> "
                 << "with material ["
                 << (triangles->getMaterial() != NULL ?
                     triangles->getMaterial() : "")
                 << "]." << std::endl;

        _geoStore.erase(_geoStore.begin() + geoIdx);
    }
}
示例#5
0
文件: GrGpu.cpp 项目: killvxk/KUI
void GrGpu::onDrawNonIndexed(GrPrimitiveType type,
                             int startVertex,
                             int vertexCount) {
    this->handleDirtyContext();

    if (!this->setupClipAndFlushState(PrimTypeToDrawType(type))) {
        return;
    }

    int sVertex = startVertex;
    setupGeometry(&sVertex, NULL, vertexCount, 0);

    this->onGpuDrawNonIndexed(type, sVertex, vertexCount);
}
示例#6
0
// Change the gameboard
void PlayGround::change(uint selectedGameboard)
{
  QDomDocument layoutsDocument;
  bool ok = topLevel->loadLayout(layoutsDocument);
  if (ok) ok = loadPlayGround(layoutsDocument, selectedGameboard);
  if (!ok) loadFailure();

  toDraw.clear();
  history.clear();
  currentAction = 0;

  setupGeometry();

  update();
}
//----------------------------------------------------------------------------------------
// Iterate
void CCudaReconstructionAlgorithm2D::run(int _iNrIterations)
{
	// check initialized
	ASTRA_ASSERT(m_bIsInitialized);

	bool ok = true;
	const CVolumeGeometry2D& volgeom = *m_pReconstruction->getGeometry();

	if (!m_bAlgoInit) {

		ok = setupGeometry();
		ASTRA_ASSERT(ok);

		ok = m_pAlgo->allocateBuffers();
		ASTRA_ASSERT(ok);

		m_bAlgoInit = true;
	}

	float fPixelSize = volgeom.getPixelLengthX();
	float fSinogramScale = 1.0f/(fPixelSize*fPixelSize);

	ok = m_pAlgo->copyDataToGPU(m_pSinogram->getDataConst(), m_pSinogram->getGeometry()->getDetectorCount(), fSinogramScale,
	                            m_pReconstruction->getDataConst(), volgeom.getGridColCount(),
	                            m_bUseReconstructionMask ? m_pReconstructionMask->getDataConst() : 0, volgeom.getGridColCount(),
	                            m_bUseSinogramMask ? m_pSinogramMask->getDataConst() : 0, m_pSinogram->getGeometry()->getDetectorCount());

	ASTRA_ASSERT(ok);

	if (m_bUseMinConstraint)
		ok &= m_pAlgo->setMinConstraint(m_fMinValue);
	if (m_bUseMaxConstraint)
		ok &= m_pAlgo->setMaxConstraint(m_fMaxValue);

	ok &= m_pAlgo->iterate(_iNrIterations);
	ASTRA_ASSERT(ok);

	ok &= m_pAlgo->getReconstruction(m_pReconstruction->getData(),
	                                 volgeom.getGridColCount());

	ASTRA_ASSERT(ok);
}
GLuint GenericHolder::setupDrawing(){
	glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);//this is bound to the geometry setup in the next call
	vbo = setupGeometry();

	shaderProgram = glCreateProgram();
	vertexShader = setupVertexShader();
	glAttachShader(shaderProgram, vertexShader);
	fragmentShader = setupFragmentShader();
	glAttachShader(shaderProgram, fragmentShader);
	glLinkProgram(shaderProgram);
	glUseProgram(shaderProgram);

	posAttrib = glGetAttribLocation(shaderProgram, "position");
	glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0);
	glEnableVertexAttribArray(posAttrib);


	uniTrans = glGetUniformLocation(shaderProgram, "view");
	glUniformMatrix4fv(uniTrans, 1, GL_FALSE, glm::value_ptr(view));
	return shaderProgram;
}
示例#9
0
// Constructor
PlayGround::PlayGround(TopLevel *parent, const char *name, uint selectedGameboard)
    : QWidget(parent, name)
{
  topLevel = parent;

  textsLayout = objectsLayout = 0;
  textsList = soundsList = 0;
  draggedCursor = 0;

  toDraw.setAutoDelete(true);
  history.setAutoDelete(true);

  setBackgroundColor(white);

  QDomDocument layoutsDocument;
  bool ok = topLevel->loadLayout(layoutsDocument);
  if (ok) ok = registerPlayGrounds(layoutsDocument);
  if (ok) ok = loadPlayGround(layoutsDocument, selectedGameboard);
  if (!ok) loadFailure();

  currentAction = 0;
  setupGeometry();
}
示例#10
0
void MainWindow::resizeEvent(QResizeEvent *e)
{
    setupGeometry(e->size());
    if(m_noteView)m_noteView->setFixedSize(width(), height());
    QWidget::resizeEvent(e);
}
void
ColladaGeometry::readTriStrips(domMesh *mesh, domTristrips *triStrips)
{
    OSG_COLLADA_LOG(("ColladaGeometry::readTriStrips\n"));

    const domInputLocal_Array       &vertInputs =
        mesh->getVertices()->getInput_array();
    const domInputLocalOffset_Array &inputs     =
        triStrips          ->getInput_array();

    IndexStore idxStore;
    UInt32     geoIdx   = setupGeometry(vertInputs, inputs,
                                        triStrips->getMaterial(), idxStore);

    const domP_Array &pArray  = triStrips->getP_array();
    UInt32            currIdx = 0;
    UInt32            length  = 0;
    UInt32            verts   = 0;

    for(UInt32 i = 0; i < pArray.getCount(); ++i)
    {
        const domListOfUInts &pList = pArray[i]->getValue();

        for(UInt32 j = 0; j < pList.getCount(); ++j)
        {
            idxStore[currIdx]->push_back(pList[j]);

            ++currIdx;

            if(currIdx == idxStore.size())
            {
                currIdx = 0;
                ++length;
            }
        }

        // only add non-empty tri strip
        if(length > 0)
        {
            _geoStore[geoIdx]._types  ->push_back(GL_TRIANGLE_STRIP);
            _geoStore[geoIdx]._lengths->push_back(length           );
        }

        verts  += length;
        length =  0;
    }

    OSG_COLLADA_LOG(("ColladaGeometry::readTriStrips: material symbol [%s] "
                     "vertices [%d] strips [%d]\n",
                     (triStrips->getMaterial() != NULL ?
                      triStrips->getMaterial() : ""), verts,
                     _geoStore[geoIdx]._lengths->size()));

    // remove empty geometry
    if(verts == 0)
    {
        SWARNING << "ColladaGeometry::readTriStrips: Empty <tristrips> "
                 << "with material ["
                 << (triStrips->getMaterial() != NULL ?
                     triStrips->getMaterial() : "")
                 << "]." << std::endl;

        _geoStore.erase(_geoStore.begin() + geoIdx);
    }
}
void
ColladaGeometry::readPolyList(domMesh *mesh, domPolylist *polyList)
{
    OSG_COLLADA_LOG(("ColladaGeometry::readPolyList\n"));

    const domInputLocal_Array       &vertInputs =
        mesh->getVertices()->getInput_array();
    const domInputLocalOffset_Array &inputs     =
        polyList           ->getInput_array();

    IndexStore idxStore;
    UInt32     geoIdx   = setupGeometry(vertInputs, inputs,
                                        polyList->getMaterial(), idxStore);

    const domListOfUInts &pList    = polyList->getP     ()->getValue();
    const domListOfUInts &vList    = polyList->getVcount()->getValue();
    UInt32                currIdx  = 0;
    UInt32                verts    = 0;
    UInt32                prims    = 0;
    bool                  useQuads = true;

    // check if all polys are quads
    for(UInt32 i = 0; i < vList.getCount(); ++i)
    {
        if(vList[i] != 4)
        {
            useQuads = false;
            break;
        }
    }

    OSG_COLLADA_LOG(("ColladaGeometry::readPolyList: useQuads [%d]\n",
                     useQuads));

    if(useQuads == true)
    {
        for(UInt32 i = 0; i < 4 * vList.getCount(); ++i)
        {
            for(UInt32 k = 0; k < idxStore.size(); ++k)
            {
                idxStore[k]->push_back(pList[currIdx]);

                ++currIdx;
            }
        }

        // only add non-empty quads
        if(vList.getCount() > 0)
        {
            _geoStore[geoIdx]._types  ->push_back(GL_QUADS            );
            _geoStore[geoIdx]._lengths->push_back(4 * vList.getCount());
        }

        verts += 4 * vList.getCount();
        prims +=     vList.getCount();
    }
    else
    {
        for(UInt32 i = 0; i < vList.getCount(); ++i)
        {
            for(UInt32 j = 0; j < vList[i]; ++j)
            {
                for(UInt32 k = 0; k < idxStore.size(); ++k)
                {
                    idxStore[k]->push_back(pList[currIdx]);

                    ++currIdx;
                }
            }

            // only add non-empty polygons
            if(vList[i] > 0)
            {
                _geoStore[geoIdx]._types  ->push_back(GL_POLYGON);
                _geoStore[geoIdx]._lengths->push_back(vList[i]  );
            }

            verts += vList[i];
            prims += 1;
        }
    }

    OSG_COLLADA_LOG(("ColladaGeometry::readPolyList: material symbol [%s] "
                     "vertices [%d] %s [%d]\n",
                     (polyList->getMaterial() != NULL ?
                      polyList->getMaterial() : ""),
                     verts,
                     (useQuads == true ? "quads" : "polygons"), prims));

    // remove empty geometry
    if(verts == 0)
    {
        SWARNING << "ColladaGeometry::readPolyList: Empty <polylist> "
                 << "with material ["
                 << (polyList->getMaterial() != NULL ?
                     polyList->getMaterial() : "")
                 << "]." << std::endl;

        _geoStore.erase(_geoStore.begin() + geoIdx);
    }
}
void
ColladaGeometry::readPolygons(domMesh *mesh, domPolygons *polygons)
{
    OSG_COLLADA_LOG(("ColladaGeometry::readPolygons\n"));

    const domInputLocal_Array       &vertInputs =
        mesh->getVertices()->getInput_array();
    const domInputLocalOffset_Array &inputs     =
        polygons           ->getInput_array();

    IndexStore idxStore;
    UInt32     geoIdx   = setupGeometry(vertInputs, inputs,
                                        polygons->getMaterial(), idxStore);

    const domP_Array &pArray  = polygons->getP_array();
    UInt32            currIdx = 0;
    UInt32            length  = 0;
    UInt32            verts   = 0;

    for(UInt32 i = 0; i < pArray.getCount(); ++i)
    {
        const domListOfUInts &pList = pArray[i]->getValue();

        for(UInt32 j = 0; j < pList.getCount(); ++j)
        {
            idxStore[currIdx]->push_back(pList[j]);

            ++currIdx;

            if(currIdx == idxStore.size())
            {
                currIdx = 0;
                ++length;
            }
        }

        // only add non-empty polygon
        if(length > 0)
        {
            _geoStore[geoIdx]._types  ->push_back(GL_POLYGON);
            _geoStore[geoIdx]._lengths->push_back(length    );
        }

        verts  += length;
        length =  0;
    }

    const domPolygons::domPh_Array &phArray = polygons->getPh_array();
    currIdx = 0;
    length  = 0;

    for(UInt32 i = 0; i < phArray.getCount(); ++i)
    {
        // we only get the <p> elements (polygons) and skip the <h> elements
        // (holes)

        const domListOfUInts &pList = phArray[i]->getP()->getValue();

        for(UInt32 j = 0; j < pList.getCount(); ++j)
        {
            idxStore[currIdx]->push_back(pList[j]);

            ++currIdx;

            if(currIdx == idxStore.size())
            {
                currIdx = 0;
                ++length;
            }
        }

        // only add non-empty polygon
        if(length > 0)
        {
            _geoStore[geoIdx]._types  ->push_back(GL_POLYGON);
            _geoStore[geoIdx]._lengths->push_back(length    );
        }

        verts  += length;
        length =  0;

        if(phArray[i]->getH_array().getCount() > 0)
        {
            SWARNING << "ColladaGeometry::readPolygon: Ignoring ["
                     << phArray[i]->getH_array().getCount()
                     << "] holes in polygon." << std::endl;
        }
    }

    OSG_COLLADA_LOG(("ColladaGeometry::readPolygons: material symbol [%s] "
                     "vertices [%d] polygons [%d]\n",
                     (polygons->getMaterial() != NULL ?
                      polygons->getMaterial() : ""), verts,
                     _geoStore[geoIdx]._lengths->size()));

    // remove empty geometry
    if(verts == 0)
    {
        SWARNING << "ColladaGeometry::readPolygons: Empty <polygons> "
                 << "with material ["
                 << (polygons->getMaterial() != NULL ?
                     polygons->getMaterial() : "")
                 << "]." << std::endl;

        _geoStore.erase(_geoStore.begin() + geoIdx);
    }
}
示例#14
0
TwSize<int> TwLayoutManager::preferredSize() 
{
    setupGeometry();
    return m_cachePerredSize;
}