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


C++ Matrix4x4f::data方法代码示例

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


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

示例1: load_camera

static void load_camera()
{
    FILE* fp = fopen("camera.txt", "rt");
    assert(fp);
    for (int i = 0; i < 16; i++)
        fscanf(fp, "%f", &cam_to_view.data()[i]);
    for (int i = 0; i < 16; i++)
        fscanf(fp, "%f", &cam_to_clip.data()[i]);
    fclose(fp);

    fprintf(stderr, "camera loaded from camera.txt\n");
}
开发者ID:hsaransa,项目名称:gpurt,代码行数:12,代码来源:main.cpp

示例2: main

int main()
{
    init();

    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
        return 1;
    }
    atexit(SDL_Quit);

    if (SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_OPENGL) == 0)
    {
        fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
        return 1;
    }

    cam_to_clip = perspective<float>(45.f / 180.f * 3.14159265f, 1.f, 0.1f, 100.f);

    Vector3f eye = Vector3f(4.f, 1.f, 4.f);
    Vector3f center = Vector3f(0.f, 0.f, 0.f);
    Vector3f up = Vector3f(0.f, 1.f, 0.f);
    cam_to_view = look_at<float>(eye, center, up);

    load_camera();

    int prev_ticks = SDL_GetTicks();

    int last_ticks = prev_ticks;
    int frames = 0;

    while (1)
    {
        int dt = SDL_GetTicks() - prev_ticks;
        prev_ticks += dt;

        // Handle events.

        SDL_Event ev;

        while (SDL_PollEvent(&ev))
        {
            switch (ev.type)
            {
            case SDL_KEYDOWN:
                switch (ev.key.keysym.sym)
                {
                case SDLK_ESCAPE:
                    return 0;

                case SDLK_1:
                    fprintf(stderr, "rendering using OpenGL\n");
                    mode = RENDER_GL;
                    last_ticks = SDL_GetTicks();
                    frames = 0;
                    break;

                case SDLK_2:
                    fprintf(stderr, "rendering using cpu ray tracing\n");
                    mode = RENDER_RT_CPU;
                    last_ticks = SDL_GetTicks();
                    frames = 0;
                    break;

                case SDLK_3:
                    fprintf(stderr, "rendering using cuda ray tracing\n");
                    mode = RENDER_RT_CUDA;
                    last_ticks = SDL_GetTicks();
                    frames = 0;
                    break;

                case SDLK_u:
                    {
                        FILE* fp = fopen("camera.txt", "wt");
                        for (int i = 0; i < 16; i++)
                            fprintf(fp, "%f ", cam_to_view.data()[i]);
                        for (int i = 0; i < 16; i++)
                            fprintf(fp, "%f ", cam_to_clip.data()[i]);
                        fclose(fp);

                        fprintf(stderr, "saved camera to camera.txt\n");
                    }
                    break;

                case SDLK_p:
                    load_camera();
                    break;

                default:
                    break;
                }
                break;

            case SDL_MOUSEMOTION:
                if (ev.motion.state & 1)
                {
                    float fdx = ev.motion.xrel / 400.;
                    float fdy = ev.motion.yrel / 400.;

                    cam_to_view =
//.........这里部分代码省略.........
开发者ID:hsaransa,项目名称:gpurt,代码行数:101,代码来源:main.cpp

示例3: load

        void load(const char* fn)
        {
            FILE* fp = fopen(fn, "r");

            for (;;)
            {
                Matrix4x4f m;
                int n = fscanf(fp, "%f %f %f %f  %f %f %f %f  %f %f %f %f  %f %f %f %f",
                    &m.data()[0], &m.data()[1], &m.data()[2], &m.data()[3],
                    &m.data()[4], &m.data()[5], &m.data()[6], &m.data()[7],
                    &m.data()[8], &m.data()[9], &m.data()[10], &m.data()[11],
                    &m.data()[12], &m.data()[13], &m.data()[14], &m.data()[15]);

                if (n != 16)
                    break;

                frames.push_back(m);
            }

            fclose(fp);
        }
开发者ID:hsaransa,项目名称:kakkidemo,代码行数:21,代码来源:camerapath.hpp


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