コード例 #1
0
ファイル: CullNode.cpp プロジェクト: wangyanxing/Demi3D
    void DiCullNode::SetVisible( bool vis, bool cascade /*= true*/ )
    {
        for (auto oi = mObjects.begin(); oi != mObjects.end(); ++oi)
        {
            (*oi)->SetVisible(vis);
        }

        if (cascade)
        {
            for (size_t i = 0; i < mChildren.size(); ++i)
            {
                DiCullNode* sceneChild = static_cast<DiCullNode*>(mChildren[i]);
                sceneChild->SetVisible(vis, cascade);
            }
        }
    }
コード例 #2
0
ファイル: CullNode.cpp プロジェクト: redkaras/Demi3D
    void DiCullNode::SetVisible( bool vis, bool cascade /*= true*/ )
    {
        ObjectMap::iterator oi, oiend;
        oiend = mObjectsByName.end();
        for (oi = mObjectsByName.begin(); oi != oiend; ++oi)
        {
            oi->second->SetVisible(vis);
        }

        if (cascade)
        {
            for (size_t i = 0; i < mChildren.size(); ++i)
            {
                DiCullNode* sceneChild = static_cast<DiCullNode*>(mChildren[i]);
                sceneChild->SetVisible(vis, cascade);
            }
        }
    }
コード例 #3
0
ファイル: Pool.cpp プロジェクト: wangyanxing/Demi3D
void SetupWater(DiSceneManager* sm)
{
    // Render targets
    auto reflectMap = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiTexture>("reflect_rt");
    reflectMap->SetDimensions(512, 512);
    reflectMap->SetFormat(PF_A8R8G8B8);
    reflectMap->SetUsage(TU_RENDER_TARGET);
    reflectMap->SetAutoMipmap(false);
    reflectMap->SetAddressing(AM_CLAMP);
    reflectMap->CreateTexture();
    auto reflectRT = reflectMap->GetRenderTarget();

    auto refractMap = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiTexture>("refract_rt");
    refractMap->SetDimensions(512, 512);
    refractMap->SetFormat(PF_A8R8G8B8);
    refractMap->SetUsage(TU_RENDER_TARGET);
    refractMap->SetAutoMipmap(false);
    refractMap->SetAddressing(AM_CLAMP);
    refractMap->CreateTexture();
    auto refractRT = refractMap->GetRenderTarget();
    
    // Water plane 
    DiCullNode* nodePlane = sm->GetRootNode()->CreateChild();
    DiSimpleShapePtr model = make_shared<DiSimpleShape>();
    model->CreatePlane(100);

    auto waterMat = DiMaterial::QuickCreate("pool_fresnel_v", "pool_fresnel_p");
    auto shaderParam = waterMat->GetShaderParameter();

    shaderParam->WriteFloat("scale", 1.0f);
    shaderParam->WriteFloat("scroll", 0.05f);
    shaderParam->WriteFloat("fresnelBias", -0.1f);
    shaderParam->WriteFloat("fresnelScale", 1.8f);
    shaderParam->WriteFloat("fresnelPower", 8.0f);
    shaderParam->WriteFloat("noiseScale", 0.05f);
    shaderParam->WriteFloat4("tintColour", DiVec4(0, 0.05f, 0.05f, 1));
    shaderParam->WriteTexture2D("noiseMap", "waves2.dds");
    shaderParam->WriteTexture2D("reflectMap", "reflect_rt");
    shaderParam->WriteTexture2D("refractMap", "refract_rt");

    model->SetMaterial(waterMat);
    nodePlane->AttachObject(model);
    nodePlane->SetScale(7, 1, 13);

    // Add to scene manager with the callbacks
    DiCamera* cam = sm->GetCamera();
    cam->MoveRelative(DiVec3(0, 0, 700));
    
    sm->AddExtraRenderTarget(refractRT, cam,
        [nodePlane](DiRenderTarget*) {
            nodePlane->SetVisible(false);
        },
        [nodePlane](DiRenderTarget*) {
            nodePlane->SetVisible(true);
        }
    );

    sm->AddExtraRenderTarget(reflectRT, cam,
        [nodePlane, cam](DiRenderTarget*) {
            nodePlane->SetVisible(false);
            cam->EnableReflection(DiPlane(DiVec3::UNIT_Y, 0));
        },
        [nodePlane, cam](DiRenderTarget*) {
            nodePlane->SetVisible(true);
            cam->DisableReflection();
        }
    );
    
    DiPostEffectManager* peMgr = DiBase::Driver->GetMainRenderWindow()->GetPostEffectManager();
	DiPostEffect* bloom = peMgr->GetEffect("Bloom");
    if (bloom)
		bloom->SetEnable(false);
}