当前位置: 首页>>代码示例>>C++>>正文


C++ CLight::setAmbientColor方法代码示例

本文整理汇总了C++中CLight::setAmbientColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CLight::setAmbientColor方法的具体用法?C++ CLight::setAmbientColor怎么用?C++ CLight::setAmbientColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLight的用法示例。


在下文中一共展示了CLight::setAmbientColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qDebug

//-----------------------------------------------------------------------------------------
TestTransformation::TestTransformation()
    : m_bPressed(false)
    , m_bTouch(false)
    , m_StartPan(-1, -1)
    , m_LastPan(-1, -1)
{
    // On cr�e une camera
    CCamera* pCamera = m_pSceneManager->createCamera();

    m_vNewEyePosition = QVector3D(8., 8., 4.);
    pCamera->setEyePosition(m_vNewEyePosition);
    pCamera->setCenter(QVector3D(0., 0., 0.));

    qDebug() << "Create View";
    m_pView = createWidget3D(pCamera);
    m_pView->setAttribute(Qt::WA_AcceptTouchEvents);
    qDebug() << "End create View";

    // On cr�e un noeud afin d'y placer une lumi�re
    CSceneNode* pRootNode = getSceneManager()->getRootNode();

    // On cr�e une lumi�re diffuse bleue
    CLight* pLight = getSceneManager()->createLight();
    pLight->setDiffuseColor(1.0, 1.0, 1.0);
    pLight->setAmbientColor(1.0, 1.0, 1.0);
    pLight->setDirection(QVector3D(-1, 0, 0));
    pLight->setSpecularColor(1.0f, 1.0f, 1.0f);

    // On l'associe au noeud
    pRootNode->addItem(pLight);

    // SkyBox
    CSkyBox* pSkyBoxMesh = CMeshManager::getInstance().createCustomMesh<CSkyBox>("CSkyBox", "SkyBoxMesh");

    CMeshInstance* pSkyBox = getSceneManager()->createMeshInstance(pSkyBoxMesh, "SkyBox");
    pSkyBox->setSelectable(false);
    CSceneNode* pSkyBoxNode = pRootNode->createChild("SkyBoxNode");
    pSkyBoxNode->scale(400.);
    pSkyBoxNode->addItem(pSkyBox);


    CMaterial* pSkyBoxMat = CMaterialManager::getInstance().createMaterial("SkyBoxMaterial");
    pSkyBox->setMaterialName(pSkyBoxMat->getName());

    QStringList fileNames;
    fileNames << "://Resources/xpos.png" << "://Resources/xneg.png" << "://Resources/ypos.png"
              << "://Resources/yneg.png" << "://Resources/zpos.png" << "://Resources/zneg.png";

    ATexture* pSkyBoxTexture = CTextureManager::getInstance().createTextureCube("SkyBoxTexCube", fileNames);
    pSkyBoxMat->addTexture(pSkyBoxTexture, eDiffuse);

#ifdef EMBEDDED_TARGET
    CShader* pShader = CShaderManager::getInstance().createShader(
                "SkyBoxShader",
                "://Resources/skyboxES.vertex.glsl",
                "",
                "://Resources/skyboxES.fragment.glsl");
#else
    CShader* pShader = CShaderManager::getInstance().createShader(
                "SkyBoxShader",
                "://Resources/skybox.vertex.glsl",
                "",
                "://Resources/skybox.fragment.glsl");
#endif

    pSkyBoxMat->getRenderPass(0)->setShaderName(pShader->getName());
    pSkyBoxMat->getRenderPass(0)->renderStates().setFaceCulling(CFaceCulling(false));

    // Particules
    CBillboard* pBillboard = getSceneManager()->createBillboard();
    QVector<QVector3D> pos;
    for (int i = 0; i < 1000; ++i)
        pos << QVector3D(
                   Math::randDouble(-200., +200.),
                   Math::randDouble(-200., +200.),
                   Math::randDouble(-200., +200.));
    pBillboard->addPositions(pos);

    CMaterial* pBillboardMat = CMaterialManager::getInstance().createMaterial("BillboardMaterial");
    pBillboardMat->getRenderPass(0)->renderStates().setFaceCulling(CFaceCulling(false));
    CBlending blending;
    blending.setEnabled(true);
    blending.setBlendEquation(eAdd, eAdd);

    blending.setBlendSeparateFunction(Source::eSourceAlpha, Destination::eOneMinusSourceAlpha, Source::eOne, Destination::eZero);
    pBillboardMat->getRenderPass(0)->renderStates().setBlending(blending);

    ATexture* pBillboardTexture = CTextureManager::getInstance().createTexture2D("BillBoardTex", "://Resources/particle.png");
    pBillboardMat->addTexture(pBillboardTexture, eDiffuse);

    CShader* pBillboardShader = CShaderManager::getInstance().createShader("BillboardShader",
        "://Resources/billboard.vertex.glsl",
        "://Resources/billboard.geometry.glsl",
        "://Resources/billboard.fragment.glsl");

    pBillboardMat->getRenderPass(0)->setShaderName(pBillboardShader->getName());
    pBillboard->setMaterialName(pBillboardMat->getName());
    pBillboardShader->setUniformValue("halfSize", 1.);

//.........这里部分代码省略.........
开发者ID:Jbx2-0b,项目名称:Humble3D,代码行数:101,代码来源:TestTransformation.cpp

示例2: getSceneManager

//-----------------------------------------------------------------------------------------
TestAnimation::TestAnimation()
{
    // On crée une camera
    m_pCamera = getSceneManager()->createCamera();
    m_pCamera->setEyePosition(QVector3D(2., 1., 2.));
    m_pCamera->setCenter(QVector3D(0., 0., 0.));


#ifdef SOFTWARE_RENDERING
    m_pView = createSoftwareView3D(m_pCamera);
#else
    m_pView = createWidget3D(m_pCamera);
#endif

    m_pCamera->setAspectRatio((real)m_pView->width() / (real)m_pView->height());

    // On charge le modéle
    CSceneNode* pRootNode = m_pSceneManager->getRootNode();

    CSceneNode* pModelNode = pRootNode->createChild("dwarf");

    // anim_test.x
    // rotatingcube.3ds
    // dwarf.x

    if (!CAssimpImporter::mergeScene("://dwarf.x", m_pSceneManager, true, pModelNode).isEmpty())
    {
        // On récupére la bounding box
        CBox3D bbox = pRootNode->getGlobalAxisAlignedBoundingBox();

        real sizeX = bbox.getMaximum().x() - bbox.getMinimum().x();
        real sizeY = bbox.getMaximum().y() - bbox.getMinimum().y();
        real sizeZ = bbox.getMaximum().z() - bbox.getMinimum().z();

        real maxSize = sizeX;
        if (sizeY > maxSize) maxSize = sizeY;
        if (sizeZ > maxSize) maxSize = sizeZ;

        // On redimensionne la scene de façon à ce qu'elle tienne dans une boite de 1x1x1
        pModelNode->scale(1. / maxSize);

        CBox3D scaledBbox = pModelNode->getGlobalAxisAlignedBoundingBox();

        // On la centre
        pModelNode->translate(-scaledBbox.getCenter());

        CSceneNode* pLightNode = pRootNode->createChild("LightNode", QVector3D(8.0, 12.0, 0));

        // On crée une lumiére diffuse blanche
        CLight* pLight = m_pSceneManager->createLight("Light");
        pLight->setDiffuseColor(0.8f, 0.8f, 0.8f);
        pLight->setAmbientColor(0.6f, 0.6f, 0.6f);
        pLight->setSpecularColor(0.4f, 0.4f, 0.4f);
        pLight->setDirection(QVector3D(-1, -1, 0));

        // On l'associe au noeud
        pLightNode->addItem(pLight);

        pRootNode->dumpNodeTree();
        //m_pSceneManager->setSceneGraphVisible(true);

        QList<CAnimation*> anims = m_pSceneManager->getAnimations();

        m_pView->setGeometry(QRect(100, 100, 400, 300));
        m_pView->getRenderer()->run();
        getAnimationManager()->run();

        if (anims.size() > 0)
        {
            QList<CSceneNodeAnimation*> nodeAnimations = anims[0]->getNodeAnimations();

            foreach (CSceneNodeAnimation* pNodeAnim, nodeAnimations)
            {
                pNodeAnim->setAnimationBehavior(eAnimationBehaviourRepeat);
            }
开发者ID:Jbx2-0b,项目名称:Humble3D,代码行数:76,代码来源:TestAnimation.cpp


注:本文中的CLight::setAmbientColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。