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


C++ CoordinateFrame::toObjectSpace方法代码示例

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


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

示例1: onGraphics

void Demo::onGraphics(RenderDevice* rd) {

    LightingParameters lighting(G3D::toSeconds(2, 00, 00, AM), false);
    rd->setProjectionAndCameraMatrix(app->debugCamera);

    // Cyan background
    rd->setColorClearValue(Color3(0.1f, 0.5f, 1.0f));

    rd->clear(app->sky.isNull(), true, true);
    if (app->sky.notNull()) {
        app->sky->render(rd, lighting);
    }

    // Create a light 
    Vector4 wsLight(1.0f, 2.5f, 2.0f, 1.0f);
//    Vector4 wsLight(0,1,0,0);

    // Setup lighting
    rd->enableLighting();
		rd->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
		rd->setAmbientLightColor(lighting.ambient);

        CoordinateFrame cframe;
        // Rotate the quad
        cframe.rotation = Matrix3::fromAxisAngle(Vector3::unitY(), System::time() * 0.1);

        rd->pushState();
            GPUProgram::ArgList vertexArgs;

            rd->setObjectToWorldMatrix(cframe);

            // Take the light to object space
            Vector4 osLight = cframe.toObjectSpace(wsLight);

            // Take the viewer to object space
            Vector3 osEye = cframe.pointToObjectSpace(app->debugCamera.getCoordinateFrame().translation);

            vertexArgs.set("MVP", rd->getModelViewProjectionMatrix());
            vertexArgs.set("osLight", osLight);
            vertexArgs.set("osEye", osEye);
            rd->setVertexProgram(parallaxVP, vertexArgs);

            GPUProgram::ArgList pixelArgs;
            pixelArgs.set("texture", texture);
            pixelArgs.set("normalMap", normalMap);
            rd->setPixelProgram(parallaxPP, pixelArgs);

            model.render(rd);
        rd->popState();


    rd->disableLighting();

    Draw::sphere(Sphere(wsLight.xyz(), .1f), rd, Color3::white(), Color4::clear());

    if (app->sky.notNull()) {
        app->sky->renderLensFlare(rd, lighting);
    }

    rd->push2D();
        app->debugFont->draw2D(rd, "The surface is a single quad textured with parallax bump mapping and per-pixel shading.", Vector2(10, 10), 10, Color3::white(), Color3::black());
        app->debugFont->draw2D(rd, "Press TAB to toggle to first person camera controls.", Vector2(10, 30), 10, Color3::white(), Color3::black());
    rd->pop2D();
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:64,代码来源:main.cpp


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