示例#1
0
// 初期化.
IZ_BOOL AppGalleryApp::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    IZ_BOOL result = IZ_TRUE;

    //izanagi::math::CMathRand::Init((IZ_UINT)app->GetTimer(0).GetCurTime());
    srand((IZ_UINT)GetTimer(0).GetCurTime());

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 0.0f, -45.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 0.0f, 0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f, 0.0f, 1.0f),
        1.0f,
        500.0f,
        izanagi::math::CMath::Deg2Rad(60.0f),
        (IZ_FLOAT)device->GetBackBufferWidth() / device->GetBackBufferHeight());
    camera.Update();

    TextureLoader::Instance().Init(allocator);

    GestureDetector::Instance().Init(
        allocator,
        this,
        device->GetViewport());

    StateManager::Instance().Create(camera);
    StateManager::Instance().Init();

    C2D::Instance().Init(allocator, device);

    ItemManager::Instance().Init(
        allocator,
        device);

    IZ_UINT imageNum = (Configure::ItemNum > COUNTOF(files) ? COUNTOF(files) : Configure::ItemNum);
    for (IZ_UINT i = 0; i < imageNum; i++) {
        ItemManager::Instance().EnqueueLoadingRequest(
            device,
            files[i]);
    }

    Scene::Instance().Init(
        allocator,
        device);

    m_Timer.Begin();

    if (!result) {
        ReleaseInternal();
    }

    return IZ_TRUE;
}
示例#2
0
// 開始
IZ_BOOL UpscaleGeometryRenderingApp::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    IZ_BOOL result = IZ_TRUE;

    m_scene.init(allocator, device, camera);

    auto width = device->GetBackBufferWidth();
    auto height = device->GetBackBufferHeight();

    m_shdGeometryPass.init(
        device,
        "shader/vs_geometry.glsl",
        "shader/ps_geometry.glsl");
    m_shdColorPass.init(
        device,
        "shader/vs_default.glsl",
        "shader/ps_default.glsl");
    m_shdFinalPass.init(
        device,
        "shader/vs_fillscreen.glsl",
        "shader/ps_final.glsl");
    
    m_gbuffer.init(allocator, device);

    m_screenFillPlane = izanagi::CDebugMeshScreenFillPlane::create(
        allocator,
        device,
        IZ_COLOR_RGBA(0xff, 0xff, 0xff, 0xff));
    IZ_ASSERT(m_screenFillPlane != IZ_NULL);

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 0.0f, 30.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 0.0f, 0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f, 0.0f, 1.0f),
        1.0f,
        500.0f,
        izanagi::math::CMath::Deg2Rad(60.0f),
        (IZ_FLOAT)device->GetBackBufferWidth() / device->GetBackBufferHeight());
    camera.Update();

__EXIT__:
    if (!result) {
        ReleaseInternal();
    }

    return result;
}
示例#3
0
IZ_BOOL CBillboard::Render(
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    izanagi::math::SMatrix44 mtx;
    izanagi::math::SMatrix44::SetUnit(mtx);

    // 軸と並行になる向きにする
    izanagi::math::SMatrix44::GetRotByX(mtx, IZ_DEG2RAD(-90.0f));

    // カメラに正対するようにする
    izanagi::math::SMatrix44 inv;
    {
        izanagi::math::SMatrix44::Copy(inv, camera.GetParam().mtxW2V);

        // 移動成分は消す
        inv.m[3][0] = inv.m[3][1] = inv.m[3][2] = 0.0f;

        // 逆行列にすることで、カメラのW2Vマトリクスと打ち消しあうようにする
        izanagi::math::SMatrix44::Inverse(inv, inv);
    }

    izanagi::math::SMatrix44::Mul(mtx, mtx, inv);

    m_Shader->Begin(device, 0, IZ_FALSE);
    {
        if (m_Shader->BeginPass(0)) {
            _SetShaderParam(
                m_Shader,
                "g_mL2W",
                (void*)&mtx,
                sizeof(mtx));

            _SetShaderParam(
                m_Shader,
                "g_mW2C",
                (void*)&camera.GetParam().mtxW2C,
                sizeof(camera.GetParam().mtxW2C));

            // シェーダ設定
            m_Shader->CommitChanges(device);

            m_Rect->Draw(device);
        }
    }
    m_Shader->End(device);

    return IZ_TRUE;
}
示例#4
0
// 初期化.
IZ_BOOL UnityChanApp::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    auto result = initModel(allocator, device);

    // Animation.
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open(anmFileName[posAnm]));

        m_Anm = izanagi::CAnimation::CreateAnimation(
            allocator,
            &in);

        result = (m_Anm != IZ_NULL);
        IZ_ASSERT(result);
    }

    // Timeline
    {
        m_Timeline.Init(
            m_Anm->GetAnimationTime(),
            0.0f);
        m_Timeline.EnableLoop(IZ_TRUE);
        m_Timeline.AutoReverse(IZ_FALSE);
        m_Timeline.Start();
        m_Timeline.Reset();
    }

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 5.0f, 100.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 5.0f, 0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f, 0.0f, 1.0f),
        1.0f,
        500.0f,
        izanagi::math::CMath::Deg2Rad(60.0f),
        (IZ_FLOAT)device->GetBackBufferWidth() / device->GetBackBufferHeight());
    camera.Update();

    // L2W
    izanagi::math::SMatrix44::SetUnit(m_L2W);

    return IZ_TRUE;
}
示例#5
0
IZ_BOOL CBillboardYAxis::Render(
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    izanagi::math::SMatrix44 mtx;
    izanagi::math::SMatrix44::SetUnit(mtx);
    izanagi::math::SMatrix44::RotByX(mtx, mtx, IZ_DEG2RAD(-90.0f));

    izanagi::math::SVector4 dir = camera.GetDir();

    if (dir.x == 0.0f) {
    }
    else {
        IZ_FLOAT deg = IZ_RAD2DEG(::atan2(dir.z, dir.x));
        izanagi::math::SMatrix44::RotByY(mtx, mtx, -1.0f * IZ_DEG2RAD(deg) + IZ_MATH_PI1_2);
    }

    m_Shader->Begin(device, 0, IZ_FALSE);
    {
        if (m_Shader->BeginPass(0)) {
            _SetShaderParam(
                m_Shader,
                "g_mL2W",
                (void*)&mtx,
                sizeof(mtx));

            _SetShaderParam(
                m_Shader,
                "g_mW2C",
                (void*)&camera.GetParam().mtxW2C,
                sizeof(camera.GetParam().mtxW2C));

            // シェーダ設定
            m_Shader->CommitChanges(device);

            m_Rect->Draw(device);
        }
    }
    m_Shader->End(device);

    return IZ_TRUE;
}
示例#6
0
// 初期化.
IZ_BOOL CBillboardApp::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    m_Billboard.Init(allocator, device);
    m_YBillboard.Init(allocator, device);
    m_ZBillboard.Init(allocator, device);

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 30.0f, -200.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 0.0f, 0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f, 0.0f, 1.0f),
        1.0f,
        5000.0f,
        izanagi::math::CMath::Deg2Rad(60.0f),
        (IZ_FLOAT)SCREEN_WIDTH / SCREEN_HEIGHT);
    camera.Update();

    return IZ_TRUE;
}
示例#7
0
// 初期化.
IZ_BOOL CMotionBindApp::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    IZ_BOOL result = IZ_TRUE;

    // Texture
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open("data/MikuImage.img"));

        m_Img = izanagi::CImage::CreateImage(
                    allocator,
                    device,
                    &in);

        VGOTO(result = (m_Img != IZ_NULL), __EXIT__);
    }

    // Animation
    for (IZ_UINT i = 0; i < COUNTOF(ANM_FILE_NAME); i++)
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open(ANM_FILE_NAME[i]));

        m_Anm[i] = izanagi::CAnimation::CreateAnimation(
                    allocator,
                    &in);

        VGOTO(result = (m_Anm[i] != IZ_NULL), __EXIT__);
    }

    // Mesh
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open(MSH_FILE_NAME));

        m_Msh = izanagi::CMesh::CreateMesh(
                    allocator,
                    device,
                    &in);
        
        VGOTO(result = (m_Msh != IZ_NULL), __EXIT__);
    }

    // Skelton
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open(SKL_FILE_NAME));

        m_Skl = izanagi::CSkeleton::CreateSkeleton(
                    allocator,
                    &in);

        VGOTO(result = (m_Skl != IZ_NULL), __EXIT__);
    }

    // 独自の補間計算を設定
    izanagi::CAnimation::SetUserFuncInterpScalar(CCustomInterp::InterpScalar);
    izanagi::CAnimation::SetUserFuncInterpVector(CCustomInterp::InterpVector);

    // アニメーションバインド
    {
        m_AnmBinder = izanagi::CAnimationBinder::CreateAnimationBinder(
            allocator,
            m_Skl);
        IZ_ASSERT(m_AnmBinder != IZ_NULL);

        for (IZ_UINT i = 0; i < COUNTOF(UpperBodyIdx); i++)
        {
            m_AnmBinder->BindByIdx(UpperBodyIdx[i], m_Anm[1]);
        }
        for (IZ_UINT i = 0; i < COUNTOF(LowerBodyIdx); i++)
        {
            m_AnmBinder->BindByIdx(LowerBodyIdx[i], m_Anm[0]);
        }
    }

    // Timeline
    {
        m_Timeline.Init(
            m_AnmBinder->GetAnimationTime(),
            0.0f);
        m_Timeline.EnableLoop(IZ_TRUE);
        m_Timeline.AutoReverse(IZ_FALSE);
        m_Timeline.Start();
        m_Timeline.Reset();
    }

    // Shader
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open("data/SkinShader.shd"));

        m_Shd = izanagi::shader::CShaderBasic::CreateShader<izanagi::shader::CShaderBasic>(
                    allocator,
                    device,
                    &in);

        VGOTO(result = (m_Shd != IZ_NULL), __EXIT__);

        // ジョイントマトリクスを描画時に設定するためのハンドラ
        s_MdlRenderHandler = izanagi::IMshRenderHandler::CreateMshRenderHandler<izanagi::sample::CSampleMdlRenderHandler>(allocator);
        s_MdlRenderHandler->SetShader(m_Shd);
        VGOTO(result = (s_MdlRenderHandler != IZ_NULL), __EXIT__);
    }

    // Model
    {
        m_Mdl = izanagi::CModel::CreateModel(
                    allocator,
                    m_Msh,
                    m_Skl,
                    s_MdlRenderHandler);

        VGOTO(result = (m_Mdl != IZ_NULL), __EXIT__);
    }

    // Material
    {
        izanagi::CFileInputStream in;
        IZ_CHAR tmp[32];

        for (IZ_UINT i = 0; i < COUNTOF(m_Mtrl); i++)
        {
            IZ_SPRINTF(tmp, sizeof(tmp), "data/miku_%d.mtrl\0", i);

            VRETURN(in.Open(tmp));

            m_Mtrl[i] = izanagi::CMaterial::CreateMaterial(allocator, &in);
            VGOTO((result = m_Mtrl[i] != IZ_NULL), __EXIT__);

            in.Finalize();
        }

        // シェーダ名を強制的に設定
        m_Shd->SetName("DefaultShader");

        for (IZ_UINT i = 0; i < COUNTOF(m_Mtrl); i++)
        {
            IZ_UINT num = m_Mtrl[i]->GetTexNum();

            IZ_PCSTR name = m_Mtrl[i]->GetTexInfoByIdx(num > 1 ? 1 : 0)->name.GetString();

            IZ_BOOL isToon = (::strncmp(name, "toon", 4) == 0);

            m_Mtrl[i]->SetTexture(name, m_Img->GetTexture(isToon ? 0 : 1));
            m_Mtrl[i]->SetShader(m_Shd);

            m_Mdl->SetMaterial(0, m_Mtrl[i]);
        }
    }

    // レンダーグラフ
    m_RenderGraph = izanagi::CRenderGraph::CreateRenderGraph(allocator, 5);
    VGOTO(result = (m_RenderGraph != IZ_NULL), __EXIT__);

    // レンダラ
    m_Renderer = izanagi::CSceneRenderer::CreateSceneRenderer(allocator);
    VGOTO(result = (m_Renderer != IZ_NULL), __EXIT__);

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 5.0f, CAMERA_Z, 1.0f),
        izanagi::math::CVector4(0.0f, 5.0f, 0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f, 0.0f, 1.0f),
        1.0f,
        500.0f,
        izanagi::math::CMath::Deg2Rad(60.0f),
        (IZ_FLOAT)device->GetBackBufferWidth() / device->GetBackBufferHeight());
    camera.Update();

__EXIT__:
    if (!result) {
        ReleaseInternal();
    }

    return IZ_TRUE;
}
示例#8
0
// 初期化.
IZ_BOOL FoveatedRenderingApp::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    IZ_BOOL result = IZ_TRUE;

    IZ_UINT flag = izanagi::E_DEBUG_MESH_VTX_FORM_POS;

    // Cube
    {
        m_Cube = izanagi::sample::CSampleEnvBox::CreateSampleEnvBox(
            allocator,
            device);
        VGOTO(result = (m_Cube != IZ_NULL), __EXIT__);
    }

    // テクスチャ
    {
        izanagi::CFileInputStream in;
        VGOTO(result = in.Open("data/EnvMap.img"), __EXIT__);

        m_Img = izanagi::CImage::CreateImage(
                    allocator,
                    device,
                    &in);
        VGOTO(result = (m_Img != IZ_NULL), __EXIT__);
    }

    // FBO.
    {
        m_rt = device->CreateRenderTarget(
            SCREEN_WIDTH, SCREEN_HEIGHT,
            izanagi::graph::E_GRAPH_PIXEL_FMT_RGBA8);

        m_depth = device->CreateRenderTarget(
            SCREEN_WIDTH, SCREEN_HEIGHT,
            izanagi::graph::E_GRAPH_PIXEL_FMT_D24S8);

        m_mask = device->CreateRenderTarget(
            SCREEN_WIDTH, SCREEN_HEIGHT,
            izanagi::graph::E_GRAPH_PIXEL_FMT_RGBA8);
    }

    m_shdDrawCube.Init(
        device,
        "shader/vs_equirect.glsl",
        "shader/fs_equirect.glsl");
    m_shdMakeMask.Init(
        device,
        "shader/vs_2dscreen.glsl",
        "shader/fs_radicaldensitymask.glsl");
    m_shdFilter.Init(
        device,
        "shader/vs_2dscreen.glsl",
        "shader/fs_filter.glsl");

    IZ_FLOAT aspect = (IZ_FLOAT)SCREEN_WIDTH / SCREEN_HEIGHT;
    IZ_FLOAT verticalFOV = izanagi::math::CMath::Deg2Rad(60.0f);

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 0.0f,  0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 0.0f,  1.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f,  0.0f, 1.0f),
        1.0f,
        500.0f,
        verticalFOV,
        aspect);
    camera.Update();

__EXIT__:
    if (!result) {
        ReleaseInternal();
    }

    return IZ_TRUE;
}
示例#9
0
// 初期化.
IZ_BOOL StereoCameraApp::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    IZ_BOOL result = IZ_TRUE;

    IZ_UINT flag = izanagi::E_DEBUG_MESH_VTX_FORM_POS;

    // Cube
    {
        m_Cube = izanagi::sample::CSampleEnvBox::CreateSampleEnvBox(
            allocator,
            device);
        VGOTO(result = (m_Cube != IZ_NULL), __EXIT__);
    }

    // テクスチャ
    {
        izanagi::CFileInputStream in;
        VGOTO(result = in.Open("data/EnvMap.img"), __EXIT__);

        m_Img = izanagi::CImage::CreateImage(
                    allocator,
                    device,
                    &in);
        VGOTO(result = (m_Img != IZ_NULL), __EXIT__);
    }

    // シェーダ
    {
        izanagi::CFileInputStream in;
        VGOTO(result = in.Open("shader/vs_equirect.glsl"), __EXIT__);

        std::vector<uint8_t> buf(in.GetSize() + 1);
        in.Read(&buf[0], 0, in.GetSize());

        m_vs = device->CreateVertexShader(&buf[0]);

        VGOTO(result = (m_vs != IZ_NULL), __EXIT__);
    }
    {
        izanagi::CFileInputStream in;
        VGOTO(result = in.Open("shader/fs_equirect.glsl"), __EXIT__);

        std::vector<uint8_t> buf(in.GetSize() + 1);
        in.Read(&buf[0], 0, in.GetSize());

        m_fs = device->CreatePixelShader(&buf[0]);

        VGOTO(result = (m_fs != IZ_NULL), __EXIT__);
    }
    {
        m_shd = device->CreateShaderProgram();
        m_shd->AttachVertexShader(m_vs);
        m_shd->AttachPixelShader(m_fs);
    }

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 0.0f,  0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 0.0f,  1.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f,  0.0f, 1.0f),
        0.01f,
        5.0f,
        izanagi::math::CMath::Deg2Rad(90.0f),
        (IZ_FLOAT)device->GetBackBufferWidth() / device->GetBackBufferHeight());
    camera.Update();

__EXIT__:
    if (!result) {
        ReleaseInternal();
    }

    return IZ_TRUE;
}
示例#10
0
// 初期化.
IZ_BOOL CMouseHit::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    IZ_BOOL result = IZ_TRUE;

    static const izanagi::math::SVector4 triPoint[3] =
    {
        { -10.0f, 0.0f,  0.0f, 1.0f },
        { -10.0f, 0.0f, 20.0f, 1.0f },
        {  10.0f, 0.0f, 20.0f, 1.0f },
    };

    static const izanagi::graph::SVertexElement vtxElem[] =
    {
        {0,  0, izanagi::graph::E_GRAPH_VTX_DECL_TYPE_FLOAT4, izanagi::graph::E_GRAPH_VTX_DECL_USAGE_POSITION, 0},    // 座標
        {0, 16, izanagi::graph::E_GRAPH_VTX_DECL_TYPE_COLOR, izanagi::graph::E_GRAPH_VTX_DECL_USAGE_COLOR, 0},        // 色
    };

    {
        izanagi::math::SMatrix44::SetUnit(m_Triangles.mtx);
        m_Triangles.tri.Set(triPoint);

        m_Triangles.vb = device->CreateVertexBuffer(
            sizeof(SVertex),
            3,
            izanagi::graph::E_GRAPH_RSC_TYPE_STATIC);

        SVertex* data = IZ_NULL;
        m_Triangles.vb->Lock(0, 0, (void**)&data, IZ_FALSE);
        {
            for (IZ_UINT i = 0; i < 3; i++)
            {
                izanagi::math::SVector4::Copy(data[i].pos, triPoint[i]);
                data[i].color = 0xffffffff;
            }
        }
        m_Triangles.vb->Unlock();

        m_VD = device->CreateVertexDeclaration(vtxElem, COUNTOF(vtxElem));
    }

    // シェーダ
    {
        izanagi::CFileInputStream in;
        VGOTO(result = in.Open("data/BasicShader.shd"), __EXIT__);

        m_Shader = izanagi::CShaderBasic::CreateShader<izanagi::CShaderBasic>(
                    allocator,
                    device,
                    &in);
        VGOTO(result = (m_Shader != IZ_NULL), __EXIT__);
    }

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 5.0f, -30.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 5.0f, 0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f, 0.0f, 1.0f),
        1.0f,
        500.0f,
        izanagi::math::CMath::Deg2Rad(60.0f),
        (IZ_FLOAT)SCREEN_WIDTH / SCREEN_HEIGHT);
    camera.Update();

__EXIT__:
    if (!result) {
        ReleaseInternal();
    }

    return IZ_TRUE;
}
示例#11
0
// 初期化.
IZ_BOOL DynamicStreamApp::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    IZ_BOOL result = IZ_TRUE;

    // Vertex Buffer.
    createVBForDynamicStream(allocator, device);
    createVBForMapUnmap(allocator, device);

    {
        izanagi::graph::SVertexElement elems[] = {
            { 0, 0, izanagi::graph::E_GRAPH_VTX_DECL_TYPE_FLOAT4, izanagi::graph::E_GRAPH_VTX_DECL_USAGE_POSITION, 0 },
            { 0, 16, izanagi::graph::E_GRAPH_VTX_DECL_TYPE_COLOR, izanagi::graph::E_GRAPH_VTX_DECL_USAGE_COLOR, 0 },
        };

        m_vd = device->CreateVertexDeclaration(elems, COUNTOF(elems));
    }

    {
        {
            izanagi::CFileInputStream in;
            in.Open("shader/vs.glsl");

            std::vector<IZ_BYTE> buf(in.GetSize() + 1);
            in.Read(&buf[0], 0, buf.size());

            buf[buf.size() - 1] = 0;

            m_vs = device->CreateVertexShader(&buf[0]);
        }

        {
            izanagi::CFileInputStream in;
            in.Open("shader/ps.glsl");

            std::vector<IZ_BYTE> buf(in.GetSize() + 1);
            in.Read(&buf[0], 0, buf.size());

            buf[buf.size() - 1] = 0;

            m_ps = device->CreatePixelShader(&buf[0]);
        }

        m_shd = device->CreateShaderProgram();
        m_shd->AttachVertexShader(m_vs);
        m_shd->AttachPixelShader(m_ps);
    }

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 0.0f, 30.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 0.0f, 0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f, 0.0f, 1.0f),
        1.0f,
        500.0f,
        izanagi::math::CMath::Deg2Rad(60.0f),
        (IZ_FLOAT)device->GetBackBufferWidth() / device->GetBackBufferHeight());
    camera.Update();

    createVertices();

__EXIT__:
    if (!result) {
        ReleaseInternal();
    }

    return IZ_TRUE;
}
示例#12
0
// 初期化.
IZ_BOOL CResourceManagerApp::InitInternal(
    izanagi::IMemoryAllocator* allocator,
    izanagi::graph::CGraphicsDevice* device,
    izanagi::sample::CSampleCamera& camera)
{
    IZ_BOOL result = IZ_TRUE;

    m_RscMgr = izanagi::resource::CResourceManager::CreateResourceManager(allocator);
    IZ_ASSERT(m_RscMgr != IZ_NULL);

    izanagi::CMesh* msh = IZ_NULL;
    izanagi::CSkeleton* skl = IZ_NULL;

    // Texture
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open("data/ModelImage.img"));

        izanagi::CImage* img = izanagi::CImage::CreateImage(
            allocator,
            device,
            &in);


        VGOTO(result = (img != IZ_NULL), __EXIT__);

        m_RscMgr->Add(
            img,
            IZ_CC3('i', 'm', 'g'),
            izanagi::CKey("ModelImage.img"));

        // ResourceManagerに登録したのでもういらない
        SAFE_RELEASE(img);
    }

    // Mesh
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open("data/Seymour.msh"));

        msh = izanagi::CMesh::CreateMesh(
            allocator,
            device,
            &in);
        
        VGOTO(result = (msh != IZ_NULL), __EXIT__);
    }

    // Skelton
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open("data/Seymour.skl"));

        skl = izanagi::CSkeleton::CreateSkeleton(
            allocator,
            &in);

        VGOTO(result = (skl != IZ_NULL), __EXIT__);
    }

    // Shader
    {
        izanagi::CFileInputStream in;
        VRETURN(in.Open("data/SkinShader.shd"));

        izanagi::shader::CShaderBasic* shd = izanagi::shader::CShaderBasic::CreateShader<izanagi::shader::CShaderBasic>(
                    allocator,
                    device,
                    &in);

        VGOTO(result = (shd != IZ_NULL), __EXIT__);

        // ジョイントマトリクスを描画時に設定するためのハンドラ
        s_MdlRenderHandler = izanagi::IMshRenderHandler::CreateMshRenderHandler<izanagi::sample::CSampleMdlRenderHandler>(allocator);
        s_MdlRenderHandler->SetShader(shd);
        VGOTO(result = (s_MdlRenderHandler != IZ_NULL), __EXIT__);

        m_RscMgr->Add(
            shd,
            IZ_CC3('s', 'h', 'd'),
            izanagi::CKey("SkinShader.shd"));

        // ResourceManagerに登録したのでもういらない
        SAFE_RELEASE(shd);
    }

    // Model
    {
        izanagi::CModel* mdl = izanagi::CModel::CreateModel(
            allocator,
            msh,
            skl,
            s_MdlRenderHandler);

        VGOTO(result = (mdl != IZ_NULL), __EXIT__);

        // Modelに登録したのでもういらない
        SAFE_RELEASE(msh);
        SAFE_RELEASE(skl);

        m_RscMgr->Add(
            mdl,
            IZ_CC3('m', 'd', 'l'),
            izanagi::CKey("Seymour.mdl"));

        // ResourceManagerに登録したのでもういらない
        SAFE_RELEASE(mdl);
    }

    // カメラ
    camera.Init(
        izanagi::math::CVector4(0.0f, 5.0f, 30.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 5.0f, 0.0f, 1.0f),
        izanagi::math::CVector4(0.0f, 1.0f, 0.0f, 1.0f),
        1.0f,
        500.0f,
        izanagi::math::CMath::Deg2Rad(60.0f),
        (IZ_FLOAT)device->GetBackBufferWidth() / device->GetBackBufferHeight());
    camera.Update();

__EXIT__:
    if (!result) {
        ReleaseInternal();
    }

    return IZ_TRUE;
}