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


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

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


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

示例1: SetUpShader

//-----------------------------------------------------------------------------------
void TheGame::SetUpShader()
{
    m_testMaterial = new Material(
        new ShaderProgram("Data/Shaders/SkinDebug.vert", "Data/Shaders/SkinDebug.frag"), //fixedVertexFormat timeBased basicLight multiLight
        RenderState(RenderState::DepthTestingMode::ON, RenderState::FaceCullingMode::CULL_BACK_FACES, RenderState::BlendMode::ALPHA_BLEND)
    );

    m_uvDebugMaterial = new Material(
        new ShaderProgram("Data/Shaders/basicLight.vert", "Data/Shaders/uvDebug.frag"),
        RenderState(RenderState::DepthTestingMode::ON, RenderState::FaceCullingMode::CULL_BACK_FACES, RenderState::BlendMode::ALPHA_BLEND)
    );

    m_normalDebugMaterial = new Material(
        new ShaderProgram("Data/Shaders/basicLight.vert", "Data/Shaders/normalDebug.frag"),
        RenderState(RenderState::DepthTestingMode::ON, RenderState::FaceCullingMode::CULL_BACK_FACES, RenderState::BlendMode::ALPHA_BLEND)
    );
    m_testMaterial->SetDiffuseTexture("Data/Images/stone_diffuse.png");
    m_testMaterial->SetNormalTexture("Data/Images/stone_normal.png");
    m_testMaterial->SetEmissiveTexture("Data/Images/pattern_81/maymay.tga");
    m_testMaterial->SetNoiseTexture("Data/Images/perlinNoise.png");
    m_testMaterial->SetVec4Uniform("gDissolveColor", Vector4(0.0f, 1.0f, 0.3f, 1.0f));
    m_testMaterial->SetVec4Uniform("gColor", Vector4(1.0f, 1.0f, 1.0f, 1.0f));
    m_testMaterial->SetVec4Uniform("gAmbientLight", Vector4(1.0f, 1.0f, 1.0f, 0.0f));
    m_testMaterial->SetFloatUniform("gSpecularPower", 16.0f);
    m_testMaterial->SetFloatUniform("gSpecularIntensity", 0.5f); //0 to 1
    m_testMaterial->SetVec4Uniform("gFogColor", Vector4(0.7f, 0.7f, 0.7f, 1.0f));
    m_testMaterial->SetFloatUniform("gMinFogDistance", 10.0f);
    m_testMaterial->SetFloatUniform("gMaxFogDistance", 20.0f);
    m_testMaterial->SetIntUniform("gLightCount", NUM_LIGHTS);

    lightMaterial = new Material(
        new ShaderProgram("Data/Shaders/fixedVertexFormat.vert", "Data/Shaders/fixedVertexFormat.frag"), //fixedVertexFormat timeBased basicLight
        RenderState(RenderState::DepthTestingMode::ON, RenderState::FaceCullingMode::CULL_BACK_FACES, RenderState::BlendMode::ALPHA_BLEND)
        );
    lightMaterial->SetDiffuseTexture(Renderer::instance->m_defaultTexture);

    //Set all attributes of the arrays to default values
    for (int i = 0; i < 16; i++)
    {
        m_lightPositions[i] = Vector3::ZERO;
        m_lightDirections[i] = Vector3::FORWARD;
        m_lightDirectionFactor[i] = 0.0f;
        m_nearPower[i] = 1.0f;
        m_farPower[i] = 1.0f;
        m_nearDistance[i] = 2.0f;
        m_farDistance[i] = 6.0f;
        m_innerPower[i] = 1.0f;
        m_outerPower[i] = 1.0f;
        m_innerAngle[i] = 1.0f;
        m_outerAngle[i] = -1.0f;
        m_lightColors[i] = RGBA::BLACK.ToVec4(); //i % 2 == 0 ? RGBA::RED.ToVec4() : RGBA::BLUE.ToVec4();// 
    }


    //Initialize the lights for the demo
// 	m_lights[0] = Light(Vector3::ZERO, RGBA(RGBA::RED), lightMaterial);
// 	m_lights[0].ConvertToLocalPointLight(2.0f, 6.0f, 1.0f, 0.0f);
// 	m_lights[1] = Light(Vector3::ZERO, RGBA(RGBA::GREEN), lightMaterial);
// 	m_lights[1].ConvertToGlobalDirectLight(Vector3::FORWARD, 2.0f, 6.0f);

    //Initialize the arrays with our values
    for (int i = 0; i < NUM_LIGHTS; i++)
    {
        m_lightColors[i] = m_lights[i].GetColor();
        m_lightDirections[i] = m_lights[i].GetDirection();
        m_lightDirectionFactor[i] = m_lights[i].IsDirectional() ? 1.0f : 0.0f;
        m_nearPower[i] = m_lights[i].GetNearPower();
        m_farPower[i] = m_lights[i].GetFarPower();
        m_nearDistance[i] = m_lights[i].GetNearDistance();
        m_farDistance[i] = m_lights[i].GetFarDistance();
        m_innerPower[i] = m_lights[i].GetInnerPower();
        m_outerPower[i] = m_lights[i].GetOuterPower();
        m_innerAngle[i] = m_lights[i].GetInnerAngle();
        m_outerAngle[i] = m_lights[i].GetOuterAngle();
    }

    for (int i = 0; i < NUM_LIGHTS; i++)
    {
        m_testMaterial->SetVec4Uniform(Stringf("gLightColor[%i]", i).c_str(), m_lightColors[i], 16);
        m_testMaterial->SetVec3Uniform(Stringf("gLightDirection[%i]", i).c_str(), m_lightDirections[i], 16);
        m_testMaterial->SetFloatUniform(Stringf("gLightDirectionFactor[%i]", i).c_str(), m_lightDirectionFactor[i], 16);
        m_testMaterial->SetFloatUniform(Stringf("gNearPower[%i]", i).c_str(), m_nearPower[i], 16);
        m_testMaterial->SetFloatUniform(Stringf("gFarPower[%i]", i).c_str(), m_farPower[i], 16);
        m_testMaterial->SetFloatUniform(Stringf("gNearDistance[%i]", i).c_str(), m_nearDistance[i], 16);
        m_testMaterial->SetFloatUniform(Stringf("gFarDistance[%i]", i).c_str(), m_farDistance[i], 16);
        m_testMaterial->SetFloatUniform(Stringf("gInnerPower[%i]", i).c_str(), m_innerPower[i], 16);
        m_testMaterial->SetFloatUniform(Stringf("gOuterPower[%i]", i).c_str(), m_outerPower[i], 16);
        m_testMaterial->SetFloatUniform(Stringf("gInnerAngle[%i]", i).c_str(), m_innerAngle[i], 16);
        m_testMaterial->SetFloatUniform(Stringf("gOuterAngle[%i]", i).c_str(), m_outerAngle[i], 16);
    }
    m_currentMaterial = m_testMaterial;

    MeshBuilder builder;
    builder.AddCube(2.0f);
    //Lol more blatant memory leaks fml
    loadedMesh = new MeshRenderer(new Mesh(), m_currentMaterial);
    builder.CopyToMesh(loadedMesh->m_mesh, &Vertex_SkinnedPCTN::Copy, sizeof(Vertex_SkinnedPCTN), &Vertex_SkinnedPCTN::BindMeshToVAO);
    

//.........这里部分代码省略.........
开发者ID:picoriley,项目名称:BoneMasks,代码行数:101,代码来源:TheGame.cpp


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