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


C++ MeshBuilder::BuildPatch方法代码示例

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


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

示例1: Update

//-----------------------------------------------------------------------------------
void TheGame::Update(float deltaTime)
{
    DebugRenderer::instance->Update(deltaTime);
    if (InputSystem::instance->WasKeyJustPressed(InputSystem::ExtraKeys::TILDE))
    {
        Console::instance->ActivateConsole();
    }

    if (Console::instance->IsActive())
    {
        return; //Don't do anything involving input updates.
    }

    UpdateCamera(deltaTime);
    for (int i = 0; i < 16; i++)
    {
        m_lightPositions[i] = Vector3(sinf(static_cast<float>(GetCurrentTimeSeconds() + i)) * 5.0f, cosf(static_cast<float>(GetCurrentTimeSeconds() + i) / 2.0f) * 3.0f, 0.5f);
        m_lights[i].SetPosition(m_lightPositions[i]);
        m_currentMaterial->m_shaderProgram->SetVec3Uniform(Stringf("gLightPosition[%i]", i).c_str(), m_lightPositions[i], 16);
    }
    
    if (InputSystem::instance->WasKeyJustPressed('O'))
    {
        m_renderAxisLines = !m_renderAxisLines;
    }
    if (InputSystem::instance->WasKeyJustPressed('1'))
    {
        MeshBuilder builder;
        MeshBuilder::PlaneData* data = new MeshBuilder::PlaneData(Vector3::ZERO, Vector3::RIGHT, Vector3::UP);
        builder.BuildPatch(-5.0f, 5.0f, 50, -5.0f, 5.0f, 50,
            [](const void* userData, float x, float y)
        {
            MeshBuilder::PlaneData const *plane = (MeshBuilder::PlaneData const*)userData;
            Vector3 position = plane->initialPosition
                + (plane->right * x)
                + (plane->up * y);
            return position;
        }
        , data);
        builder.CopyToMesh(loadedMesh->m_mesh, &Vertex_SkinnedPCTN::Copy, sizeof(Vertex_SkinnedPCTN), &Vertex_SkinnedPCTN::BindMeshToVAO);
        spinFactor = 0.0f;
    }
    if (InputSystem::instance->WasKeyJustPressed('2'))
    {
        MeshBuilder builder;
        MeshBuilder::PlaneData* data = new MeshBuilder::PlaneData(Vector3::ZERO, Vector3::RIGHT, Vector3::UP);
        builder.BuildPatch(-5.0f, 5.0f, 50, -5.0f, 5.0f, 50,
            [](const void* userData, float x, float y)
            {
                MeshBuilder::PlaneData const *plane = (MeshBuilder::PlaneData const*)userData;
                Vector3 position = plane->initialPosition
                    + (plane->right * x)
                    + (plane->up * y);
                position.z = sin(x + y);
                return position;
            }
        , data);
        builder.CopyToMesh(loadedMesh->m_mesh, &Vertex_SkinnedPCTN::Copy, sizeof(Vertex_SkinnedPCTN), &Vertex_SkinnedPCTN::BindMeshToVAO);
        spinFactor = 0.0f;
    }
    if (InputSystem::instance->WasKeyJustPressed('3'))
    {
        MeshBuilder builder;
        MeshBuilder::PlaneData* data = new MeshBuilder::PlaneData(Vector3::ZERO, Vector3::RIGHT, Vector3::UP);
        builder.BuildPatch(-5.0f, 5.0f, 50, -5.0f, 5.0f, 50,
            [](const void* userData, float x, float y)
        {
            MeshBuilder::PlaneData const *plane = (MeshBuilder::PlaneData const*)userData;
            Vector3 position = plane->initialPosition
                + (plane->right * x)
                + (plane->up * y);
            position.z = .05f * -cos(((float)GetCurrentTimeSeconds() * 4.0f) + (Vector2(x, y).CalculateMagnitude() * 100.0f));
            return position;
        }
        , data);
        builder.CopyToMesh(loadedMesh->m_mesh, &Vertex_SkinnedPCTN::Copy, sizeof(Vertex_SkinnedPCTN), &Vertex_SkinnedPCTN::BindMeshToVAO);
        spinFactor = 0.0f;
    }
    if (InputSystem::instance->WasKeyJustPressed('4'))
    {
        FbxListScene("Data/FBX/SampleBox.fbx");
    }
    if (InputSystem::instance->WasKeyJustPressed('5'))
    {
        Console::instance->RunCommand("fbxLoad Data/FBX/unitychan.fbx");
    }
    if (InputSystem::instance->WasKeyJustPressed('6'))
    {
        Console::instance->RunCommand("fbxLoad Data/FBX/samplebox.fbx");
    }
    if (InputSystem::instance->WasKeyJustPressed('7'))
    {
        Console::instance->RunCommand("saveMesh saveFile.picomesh");
    }
    if (InputSystem::instance->WasKeyJustPressed('8'))
    {
        Console::instance->RunCommand("loadMesh saveFile.picomesh");
    }
    if (g_loadedMesh != nullptr)
//.........这里部分代码省略.........
开发者ID:picoriley,项目名称:BoneMasks,代码行数:101,代码来源:TheGame.cpp


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