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


C++ Entity::GetOrientation方法代码示例

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


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

示例1: OnMouseDown

    void OnMouseDown(UINT button, int x, int y)
    {
        XOrientation camOrient;
        cameraEntity->GetOrientation(&camOrient);

        if (button == 0)
            cameraControl = true;

        //shoot a cube
        else if (button == 1)
        {
            Entity* pCube = g_pScene->CreateEntity();
            g_pSelectedEntity = pCube;
            pCube->SetPosition(cameraEntity->GetPosition() + camOrient.z);
            pCube->SetVelocity(0.1f * camOrient.z);
            //pCube->SetMaxLifeTime(5.0f);

            MeshComponent* pMesh = new MeshComponent(pCube);
            pMesh->SetMeshResource("cube.nfm");

            BodyComponent* pBody = new BodyComponent(pCube);
            pBody->SetMass(10.0f);
            pBody->EnablePhysics((CollisionShape*)EngineGetResource(ResourceType::COLLISION_SHAPE,
                                 "shape_box"));


            OmniLightDesc lightDesc;
            lightDesc.radius = 4.0f;
            lightDesc.shadowFadeStart = 20.0;
            lightDesc.shadowFadeEnd = 30.0;

            Entity* pLightEntity = g_pScene->CreateEntity();
            pCube->Attach(pLightEntity);
            //pLightEntity->SetLocalPosition(Vector(0.0f, 1.0f, 0.0f));

            LightComponent* pLight = new LightComponent(pLightEntity);
            pLight->SetOmniLight(&lightDesc);
            pLight->SetColor(Float3(1.0f, 1.0f, 10.0f));
            pLight->SetShadowMap(0);

        }
        else
        {
            Entity* pBarrel = g_pScene->CreateEntity();
            g_pSelectedEntity = pBarrel;
            pBarrel->SetPosition(cameraEntity->GetPosition() + camOrient.z);
            pBarrel->SetVelocity(30.0f * camOrient.z);

            MeshComponent* pMesh = new MeshComponent(pBarrel);
            pMesh->SetMeshResource("barrel.nfm");

            BodyComponent* pBody = new BodyComponent(pBarrel);
            pBody->SetMass(20.0f);
            pBody->EnablePhysics((CollisionShape*)EngineGetResource(ResourceType::COLLISION_SHAPE,
                                 "shape_barrel"));

        }
    }
开发者ID:nfprojects,项目名称:nfengine,代码行数:58,代码来源:test.cpp

示例2: OnKeyPress

    void OnKeyPress(int key)
    {
        if (key == VK_F1)
        {
            BOOL fullscreen = getFullscreenMode();
            setFullscreenMode(!fullscreen);
        }

        XOrientation orient;

        //place spot light
        if (key == 'T')
        {
            Entity* pLightEntity = g_pScene->CreateEntity();
            cameraEntity->GetOrientation(&orient);
            pLightEntity->SetOrientation(&orient);
            pLightEntity->SetPosition(cameraEntity->GetPosition());

            LightComponent* pLight = new LightComponent(pLightEntity);
            SpotLightDesc lightDesc;
            lightDesc.nearDist = 0.1f;
            lightDesc.farDist = 500.0f;
            lightDesc.cutoff = NFE_MATH_PI / 4.0f;
            lightDesc.maxShadowDistance = 60.0;
            pLight->SetSpotLight(&lightDesc);
            pLight->SetColor(Float3(600, 200, 50));
            pLight->SetLightMap("flashlight.jpg");
            pLight->SetShadowMap(1024);

            g_pSelectedEntity = pLightEntity;
        }

        //place omni light
        if (key == 'O')
        {
            OmniLightDesc lightDesc;
            lightDesc.radius = 10.0f;
            lightDesc.shadowFadeStart = 20.0;
            lightDesc.shadowFadeEnd = 30.0;

            Entity* pLightEntity = g_pScene->CreateEntity();
            pLightEntity->SetPosition(cameraEntity->GetPosition());

            LightComponent* pLight = new LightComponent(pLightEntity);
            pLight->SetOmniLight(&lightDesc);
            pLight->SetColor(Float3(600, 600, 600));
            pLight->SetShadowMap(512);

            g_pSelectedEntity = pLightEntity;
        }
    }
开发者ID:nfprojects,项目名称:nfengine,代码行数:51,代码来源:test.cpp


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