コード例 #1
0
ファイル: CC3MeshNode.cpp プロジェクト: ClAndHHL/cocos3d-x
void CC3MeshNode::applyMaterialWithVisitor( CC3NodeDrawingVisitor* visitor )
{
	updateLightPosition();
	getMaterial()->drawWithVisitor(visitor);

	// currentColor can be set by material, mesh node, or node picking visitor prior to this method.
	visitor->getGL()->setColor( visitor->getCurrentColor() );
}
コード例 #2
0
ファイル: modelrenderer.cpp プロジェクト: osamu-k/QtStudy
ModelRenderer::ModelRenderer(QQuickItem *parent)
    : QQuickItem(parent)
    , m_window( nullptr )
    , m_useProgram2( false )
    , m_shaderProgram( nullptr )
    , m_shaderProgram2( nullptr )
    , m_rotateX(0.0)
    , m_rotateY(0.0)
    , m_rotateZ(0.0)
    , m_eyeDistance(4.0)
    , m_eyeAngleX(0.0)
    , m_eyeAngleY(0.0)
    , m_lightDistance(8.0)
    , m_lightAngleX(0.0)
    , m_lightAngleY(0.0)
    , m_ambientBrightness(0.5)
    , m_diffuseBrightness(0.75)
    , m_specularBrightness(1.0)
    , m_ambientReflection(0.5)
    , m_diffuseReflection(0.5)
    , m_specularReflection(0.5)
    , m_shininess(100.0)
    , m_spotExponent(1.0)
    , m_cutoffAngle(180.0)
{
    LOG_ENTER();

    QVector4D lineColor( 0.0, 0.0, 0.0, 1.0 );
//    QVector4D lineColor( 1.0, 1.0, 1.0, 1.0 );
    for( int i = 0; i < NUM_VERTICE * NUM_FACES; i++ ){
        m_lineColorArray[i] = lineColor;
    }

    for( int i = 0; i < NUM_FACES; i ++ ){
        QVector3D normal = createPolygonNormal(
                                m_positionArray[NUM_VERTICE * i].toVector3D(),
                                m_positionArray[NUM_VERTICE * i + 1].toVector3D(),
                                m_positionArray[NUM_VERTICE * i + 2].toVector3D() );
        for( int j = 0; j < NUM_VERTICE; j++ ){
            m_normalArray[NUM_VERTICE * i + j] = normal;
        }
    }

    updateEyePosition();
    updateLightPosition();

    connect( this, SIGNAL(windowChanged(QQuickWindow*)),
             this, SLOT(windowChanged(QQuickWindow *)),
             Qt::DirectConnection );

    LOG_LEAVE();
}
コード例 #3
0
ファイル: Main.cpp プロジェクト: mrotondo/ccrma
void renderFrame() {
    //////////////////////////////////////////////////////////////////////////
    // TODO: ADD YOUR RENDERING CODE HERE.  You may use as many .cpp files
    // in this assignment as you wish.
    //////////////////////////////////////////////////////////////////////////

    // Move the player based on keyboard input (wasd)
    move();

    // Move the light based on keyboard input (arrows)
    updateLightPosition();

    // Generate a shadow map, and send the light matrix over to the shader in texture matrix 7
    depthRenderTarget->bind();
    glUseProgram(simpleShader->programID());
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    setLightMatrix();
    renderNode(simpleShader, cathedralScene, cathedralScene->mRootNode, true);
    renderNode(simpleShader, armadilloScene, armadilloScene->mRootNode, true);
    depthRenderTarget->unbind();

    // Render our scene, sending the model matrices over to the shader in texture matrix 6
    glUseProgram(phongShader->programID());
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    setMatrices();
    renderNode(phongShader, cathedralScene, cathedralScene->mRootNode, true);

    // Render the armadillo using the environment map shader.
    glUseProgram(envMapShader->programID());
    setMatrices();
    renderNode(envMapShader, armadilloScene, armadilloScene->mRootNode, true);

    // Display a test quad on screen (press t key to toggle)
    if (test)
    {
        // Render test quad
        glDisable(GL_LIGHTING);
        glUseProgramObjectARB(0);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(-RENDER_WIDTH/2,RENDER_WIDTH/2,-RENDER_HEIGHT/2,RENDER_HEIGHT/2,1,20);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glColor4f(1,1,1,1);
        glActiveTextureARB(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, depthRenderTarget->textureID());
        glEnable(GL_TEXTURE_2D);
        glTranslated(0,-RENDER_HEIGHT/2,-1);
        glBegin(GL_QUADS);
        glTexCoord2d(0,0);
        glVertex3f(0,0,0);
        glTexCoord2d(1,0);
        glVertex3f(RENDER_WIDTH/2,0,0);
        glTexCoord2d(1,1);
        glVertex3f(RENDER_WIDTH/2,RENDER_HEIGHT/2,0);
        glTexCoord2d(0,1);
        glVertex3f(0,RENDER_HEIGHT/2,0);
        glEnd();
        glEnable(GL_LIGHTING);
        glDisable(GL_TEXTURE_2D);
        depthRenderTarget->unbind();
    }
}