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


C++ DiCullNode::Translate方法代码示例

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


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

示例1: CreateChild

    DiNode* DiCullNode::CreateChild(const DiVec3& inTranslate, const DiQuat& inRotate)
    {
        DiCullNode* newNode = mCreator->CreateNode();
        newNode->Translate(inTranslate);
        newNode->Rotate(inRotate);
        this->AddChild(newNode);

        return newNode;
    }
开发者ID:redkaras,项目名称:Demi3D,代码行数:9,代码来源:CullNode.cpp

示例2: InitScene

void InitScene()
{
    DiSceneManager* sm = DiBase::Driver->GetSceneManager();
    sm->SetAmbientColor(DiColor(0.6f, 0.6f, 0.6f));
    
    float scale = 0.5f;
    DiDirLightPtr dirlight;
    dirlight = make_shared<DiDirLight>();
    DiCullNode* dirNode = sm->GetRootNode()->CreateChild();
    dirNode->AttachObject(dirlight);
    dirlight->SetColor(DiColor(0.8f,0.8f,0.8f));
    dirlight->SetDirection(DiVec3(0.3f,-0.7f,0.4).normalisedCopy());
    //dirlight->InitForShadowCasting(sm, ShadowTextureConfig(1024,1024,PF_A32B32G32R32F));
    
    auto pos = DiVec3(150,275,130)*2;
    dirNode->SetPosition(pos);
    
    DiCullNode* spotNode = sm->GetRootNode()->CreateChild();
    DiSpotLightPtr sptLt = make_shared<DiSpotLight>();
    spotNode->AttachObject(sptLt);
    //spotNode->SetPosition(50, 100, 40);
    spotNode->SetPosition(pos);
    sptLt->SetDirection((-pos).normalisedCopy());
    sptLt->SetRange( DiDegree(80), DiDegree(90) );
    sptLt->InitForShadowCasting(sm, ShadowTextureConfig(1024,1024,PF_A32B32G32R32F));
    
    sptLt->mShadowCameraNear = 50;
    sptLt->mShadowCameraFar = 200;
    sptLt->mShadowCameraFov = 50;
    sptLt->_UpdateShadowCamera();
    
    DiDebugHelperPtr dbghelper;
    auto mat = DiMaterial::QuickCreate("lambert_v", "lambert_p", SHADER_FLAG_SHADOW_RECEIVER);
    mat->SetAmbient(DiColor(0.8f, 0.8f, 0.8f));
    mat->SetDiffuse(DiColor(0.8f, 0.8f, 0.8f));

    dbghelper = make_shared<DiDebugHelper>();
    sm->GetRootNode()->AttachObject(dbghelper);
    DiMaterialPtr helpermat = DiMaterial::QuickCreate("basic_v", "basic_p", SHADER_FLAG_USE_COLOR);
    helpermat->SetDepthCheck(false);
    dbghelper->SetMaterial(helpermat);
    //dbghelper->AddFrustum(dirlight->GetShadowCamera(0), DiColor::Red);

    hp = dbghelper.get();
    lt = sptLt.get();

#if 0
    DiSimpleShapePtr plane = make_shared<DiSimpleShape>();
    plane->SetShadowCastEnable(false);
    plane->CreatePlane(600, 600);
    plane->SetMaterial(mat);
    plane->GetMaterial()->SetDiffuse(DiColor::White);
    DiCullNode* planeNode = sm->GetRootNode()->CreateChild();
    planeNode->AttachObject(plane);
    planeNode->Translate(0, 0, 0);

    const int size = 1;
    for (int i = -size; i <= size; i++)
    {
        for (int j = -size; j <= size; j++)
        {
            DiMaterialPtr mat = DiMaterial::QuickCreate("lambert_v", "lambert_p", SHADER_FLAG_SKINNED | SHADER_FLAG_SHADOW_RECEIVER);
            mat->SetDiffuse(DiColor(1, 1, 1));
            mat->SetAmbient(DiColor(0.7f, 0.7f, 0.7f));
            
            DiString name;
            name.Format("md_%d_%d", i, j);
            DiAnimModelPtr model = make_shared<DiAnimModel>(name, "robot.model", "robot.motion");
            //DiModelPtr model = make_shared<DiModel>(name, "robot.model");
            model->SetMaterial(mat);
            model->SetShadowCastEnable(true);
            
            model->SetAutoUpdateAnims(true);
            model->GetClipSet()->GetClipController("Walk")->SetEnabled(true);
            
            DiCullNode* cullnode = sm->GetRootNode()->CreateChild();
            cullnode->AttachObject(model);
            cullnode->SetPosition(i * 140.0f, 0, j * 140.0f);
        }
    }
    
#else
    
    DiSimpleShapePtr plane = make_shared<DiSimpleShape>();
    plane->SetShadowCastEnable(false);
    plane->CreatePlane(300, 300);
    plane->SetMaterial(mat);
    plane->GetMaterial()->SetDiffuse(DiColor::White);
    DiCullNode* planeNode = sm->GetRootNode()->CreateChild();
    planeNode->AttachObject(plane);

    DiMaterialPtr m = DiMaterial::QuickCreate("basic_v", "basic_p", SHADER_FLAG_SHADOW_RECEIVER);
    m->SetDiffuse(DiColor(0.9f, 0.9f, 0.9f));
    
    DiSimpleShapePtr box = make_shared<DiSimpleShape>();
    box->SetShadowCastEnable(true);
    box->CreateBox(10);
    box->SetMaterial(m);
    DiCullNode* cullnode = sm->GetRootNode()->CreateChild();
    cullnode->SetPosition(0,5,0);
//.........这里部分代码省略.........
开发者ID:wangyanxing,项目名称:Demi3D,代码行数:101,代码来源:Shadow.cpp

示例3: InitScene

void InitScene()
{
	DiSceneManager* sm = DiBase::Driver->GetSceneManager();

    mat = DiMaterial::QuickCreate("lambert_v", "lambert_p");
    mat->SetDiffuse(DiColor::White);

    sm->SetAmbientColor(DiColor(0.1f, 0.1f, 0.1f, 0.1f));

    DiDirLightPtr dirlight = make_shared<DiDirLight>();
    sm->AttachObject(dirlight);
    dirlight->SetColor(DiColor());
    dirlight->SetDirection(DiVec3(-1, -1, -2).normalisedCopy());

    int amount = 2;

    DiCullNode* parent = sm->GetRootNode();

    for (int i = 0; i < amount; i++) 
    {
        DiSimpleShapePtr model = make_shared<DiSimpleShape>();
        model->CreateBox(10);
        model->SetMaterial(mat);

        DiCullNode* node = parent->CreateChild();
        node->AttachObject(model);
        node->Translate(10, 0, 0);
        nodes.push_back(node);
        parent = node;
    }

    parent = sm->GetRootNode();
    for (int i = 0; i < amount; i++) 
    {
        DiSimpleShapePtr model = make_shared<DiSimpleShape>();
        model->CreateBox(10);
        model->SetMaterial(mat);

        DiCullNode* node = parent->CreateChild();
        node->AttachObject(model);
        node->Translate(-10, 0, 0);
        nodes.push_back(node);
        parent = node;
    }

    parent = sm->GetRootNode();
    for (int i = 0; i < amount; i++) 
    {
        DiSimpleShapePtr model = make_shared<DiSimpleShape>();
        model->CreateBox(10);
        model->SetMaterial(mat);

        DiCullNode* node = parent->CreateChild();
        node->AttachObject(model);
        node->Translate(0, 10, 0);
        nodes.push_back(node);
        parent = node;
    }

    parent = sm->GetRootNode();
    for (int i = 0; i < amount; i++) 
    {
        DiSimpleShapePtr model = make_shared<DiSimpleShape>();
        model->CreateBox(10);
        model->SetMaterial(mat);

        DiCullNode* node = parent->CreateChild();
        node->AttachObject(model);
        node->Translate(0, -10, 0);
        nodes.push_back(node);
        parent = node;
    }

    parent = sm->GetRootNode();
    for (int i = 0; i < amount; i++) 
    {
        DiSimpleShapePtr model = make_shared<DiSimpleShape>();
        model->CreateBox(10);
        model->SetMaterial(mat);

        DiCullNode* node = parent->CreateChild();
        node->AttachObject(model);
        node->Translate(0, 0, 10);
        nodes.push_back(node);
        parent = node;
    }

    parent = sm->GetRootNode();
    for (int i = 0; i < amount; i++)
    {
        DiSimpleShapePtr model = make_shared<DiSimpleShape>();
        model->CreateBox(10);
        model->SetMaterial(mat);

        DiCullNode* node = parent->CreateChild();
        node->AttachObject(model);
        node->Translate(0, 0, -10);
        nodes.push_back(node);
        parent = node;
    }
//.........这里部分代码省略.........
开发者ID:wangyanxing,项目名称:Demi3D,代码行数:101,代码来源:Hierarchy.cpp


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