• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            天行健 君子當自強而不息

            高級紋理映射技術(shù)(7)

            紋理坐標變換

            Direct3D提供了對生成的紋理坐標進行坐標變換的功能,與頂點坐標變換相類似,可以指定一個4x4的紋理坐標變換矩陣,把它與生成的紋理坐標相乘,然后將變換之后的紋理坐標輸出至Direct3D渲染流水線。使用紋理坐標變換可以對紋理坐標進行諸如平移、旋轉(zhuǎn)和縮放等三維變換。紋理坐標變換對于生成一些特殊效果是非常有用的,它不用直接修改頂點的紋理坐標。例如可以通過一個簡單的平移矩陣對紋理坐標進行變換,從而使物體表面上的紋理不斷變換位置,產(chǎn)生動畫效果。紋理坐標自動生成在三維圖形程序中最廣泛的應(yīng)用是環(huán)境映射。

            可通過函數(shù)IDirect3DDevice9::SetTransform()來設(shè)置4x4的紋理坐標變換矩陣,它以D3DTS_TEXTURE0~ D3DTS_TEXTURE7作為第一個參數(shù),表示設(shè)置紋理層0~7的紋理矩陣。下列代碼對紋理層0設(shè)置了一個將紋理坐標u、v縮小到原來一半的紋理矩陣:

            D3DXMATRIX mat;
            D3DXMatrixIdentity(&mat);
            mat._11 = 0.5f;
            mat._22 = 0.5f;
            pd3dDevice->SetTransform(D3DTS_TEXTURE0, &mat);

            下面的代碼將原來的紋理坐標平移(1.0, 1.0, 0)個單位。

            D3DXMATRIX mat;
            D3DXMatrixIdentity(&mat);
            mat._41 = 1.0f;
            mat._42 = 1.0f;
            mat._43 = 0.0f;
            pd3dDevice->SetTransform(D3DTS_TEXTURE0, &mat);

            示例程序通過下列代碼對自動生成的紋理坐標進行變換:

            // texture coordinate transform

            D3DXMATRIX mat_texture, mat_scale, mat_trans;

            D3DXMatrixIdentity(&mat_texture);
            D3DXMatrixScaling(&mat_scale, 0.5f, -0.5f, 1.0f);
            D3DXMatrixTranslation(&mat_trans, 0.5f, 0.5f, 1.0f);

            mat_texture = mat_texture * mat_scale * mat_trans;
            pd3dDevice->SetTransform(D3DTS_TEXTURE0, &mat_texture);


            運行效果圖:

             

            主程序:

            #include "dxstdafx.h"
            #include 
            "resource.h"

            #pragma warning(disable : 
            4127 4995 4996)

            #define release_com(p)    do { if(p) { (p)->Release(); (p) = NULL; } } while(0)

            #define IDC_TOGGLE_FULLSCREEN        1
            #define IDC_TOGGLE_REF                2
            #define IDC_CHANGE_DEVICE            3

            struct sCustomVertex
            {
                
            float x, y, z;
                D3DCOLOR color;
            };

            #define D3DFVF_CUSTOM_VERTEX    (D3DFVF_XYZ | D3DFVF_DIFFUSE)

            const D3DXCOLOR FONT_COLOR(1.0f0.5f0.25f1.0f);

            CDXUTDialogResourceManager    g_dlg_resource_manager;
            CD3DSettingsDlg                g_settings_dlg;
            CDXUTDialog                    g_button_dlg;

            IDirect3DVertexBuffer9
            *        g_vertex_buffer;
            IDirect3DTexture9
            *            g_texture;

            ID3DXFont
            *        g_font;
            ID3DXSprite
            *    g_text_sprite;
            bool            g_show_help;

            //--------------------------------------------------------------------------------------
            // Rejects any devices that aren't acceptable by returning false
            //--------------------------------------------------------------------------------------
            bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, 
                                              D3DFORMAT BackBufferFormat, 
            bool bWindowed, void* pUserContext )
            {
                
            // Typically want to skip backbuffer formats that don't support alpha blending

                IDirect3D9
            * pD3D = DXUTGetD3DObject(); 

                
            if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, 
                                D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat ) ) )
                    
            return false;

                
            return true;
            }


            //--------------------------------------------------------------------------------------
            // Before a device is created, modify the device settings as needed.
            //--------------------------------------------------------------------------------------
            bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext )
            {
                
            // If video card does not support hardware vertex processing, then uses sofaware vertex processing.
                if((pCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0)
                    pDeviceSettings
            ->BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

                
            static bool is_first_time = true;

                
            if(is_first_time)
                {
                    is_first_time 
            = false;

                    
            // if using reference device, then pop a warning message box.
                    if(pDeviceSettings->DeviceType == D3DDEVTYPE_REF)
                        DXUTDisplaySwitchingToREFWarning();
                }

                
            return true;
            }


            //--------------------------------------------------------------------------------------
            // Create any D3DPOOL_MANAGED resources here 
            //--------------------------------------------------------------------------------------
            HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, 
                                             
            const D3DSURFACE_DESC* pBackBufferSurfaceDesc, 
                                             
            void* pUserContext )
            {
                HRESULT    hr;

                V_RETURN(g_dlg_resource_manager.OnCreateDevice(pd3dDevice));
                V_RETURN(g_settings_dlg.OnCreateDevice(pd3dDevice));

                D3DXCreateFont(pd3dDevice, 
            180, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
                               DEFAULT_PITCH 
            | FF_DONTCARE, L"Arial"&g_font);

                V_RETURN(D3DXCreateTextureFromFile(pd3dDevice, L
            "texture.jpg"&g_texture));
                
                
            // create vertex buffer and fill data

                sCustomVertex vertices[] 
            =     
                {
                    { 
            -1.0f-1.0f,  0.0f,  0xFFFFFFFF},
                    { 
            -1.0f,  1.0f,  0.0f,  0xFFFFFFFF},
                    {  
            1.0f-1.0f,  0.0f,  0xFFFFFFFF},
                    {  
            1.0f,  1.0f,  0.0f,  0xFFFFFFFF}
                };

                pd3dDevice
            ->CreateVertexBuffer(sizeof(vertices), 0, D3DFVF_CUSTOM_VERTEX, D3DPOOL_MANAGED, &g_vertex_buffer, NULL);

                
            void* ptr;
                g_vertex_buffer
            ->Lock(0sizeof(vertices), (void**)&ptr, 0);
                memcpy(ptr, vertices, 
            sizeof(vertices));
                g_vertex_buffer
            ->Unlock();

                
            return S_OK;
            }


            //--------------------------------------------------------------------------------------
            // Create any D3DPOOL_DEFAULT resources here 
            //--------------------------------------------------------------------------------------
            HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, 
                                            
            const D3DSURFACE_DESC* pBackBufferSurfaceDesc, 
                                            
            void* pUserContext )
            {
                HRESULT hr;

                V_RETURN(g_dlg_resource_manager.OnResetDevice());
                V_RETURN(g_settings_dlg.OnResetDevice());
                V_RETURN(g_font
            ->OnResetDevice());
                V_RETURN(D3DXCreateSprite(pd3dDevice, 
            &g_text_sprite));

                
            // set dialog position and size

                g_button_dlg.SetLocation(pBackBufferSurfaceDesc
            ->Width - 1700);
                g_button_dlg.SetSize(
            170170);

                
            // setup world matrix
                D3DXMATRIX mat_world;
                D3DXMatrixIdentity(
            &mat_world);
                pd3dDevice
            ->SetTransform(D3DTS_WORLD, &mat_world);

                
            // setup view matrix

                D3DXMATRIX mat_view;
                D3DXVECTOR3 eye(
            0.0f0.0f-3.0f);
                D3DXVECTOR3  at(
            0.0f0.0f,  0.0f);
                D3DXVECTOR3  up(
            0.0f1.0f,  0.0f);

                D3DXMatrixLookAtLH(
            &mat_view, &eye, &at, &up);
                pd3dDevice
            ->SetTransform(D3DTS_VIEW, &mat_view);

                
            // set projection matrix
                D3DXMATRIX mat_proj;
                
            float aspect = (float)pBackBufferSurfaceDesc->Width / pBackBufferSurfaceDesc->Height;
                D3DXMatrixPerspectiveFovLH(
            &mat_proj, D3DX_PI/4, aspect, 1.0f100.0f);
                pd3dDevice
            ->SetTransform(D3DTS_PROJECTION, &mat_proj);

                pd3dDevice
            ->SetRenderState(D3DRS_LIGHTING, FALSE);

                
            // set texture color blend method, disalbe alpha blend.

                pd3dDevice
            ->SetTexture(0, g_texture);    
                pd3dDevice
            ->SetTextureStageState(0, D3DTSS_COLORARG1,        D3DTA_TEXTURE);    
                pd3dDevice
            ->SetTextureStageState(0, D3DTSS_COLORARG2,        D3DTA_DIFFUSE);    
                pd3dDevice
            ->SetTextureStageState(0, D3DTSS_COLOROP,            D3DTOP_MODULATE);    
                pd3dDevice
            ->SetTextureStageState(0, D3DTSS_ALPHAOP,            D3DTOP_DISABLE);

                
            // create texture coordinate using vertex position in camera space 
                pd3dDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX,            D3DTSS_TCI_CAMERASPACEPOSITION);    
                pd3dDevice
            ->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS,    D3DTTFF_COUNT2);

                
            // texture coordinate transform

                D3DXMATRIX mat_texture, mat_scale, mat_trans;

                D3DXMatrixIdentity(
            &mat_texture);
                D3DXMatrixScaling(
            &mat_scale, 0.5f-0.5f1.0f);
                D3DXMatrixTranslation(
            &mat_trans, 0.5f0.5f1.0f);

                mat_texture 
            = mat_texture * mat_scale * mat_trans;
                pd3dDevice
            ->SetTransform(D3DTS_TEXTURE0, &mat_texture);

                
            return S_OK;
            }

            //--------------------------------------------------------------------------------------
            // Release resources created in the OnResetDevice callback here 
            //--------------------------------------------------------------------------------------
            void CALLBACK OnLostDevice( void* pUserContext )
            {
                g_dlg_resource_manager.OnLostDevice();
                g_settings_dlg.OnLostDevice();
                g_font
            ->OnLostDevice();

                release_com(g_text_sprite);
            }


            //--------------------------------------------------------------------------------------
            // Release resources created in the OnCreateDevice callback here
            //--------------------------------------------------------------------------------------
            void CALLBACK OnDestroyDevice( void* pUserContext )
            {
                g_dlg_resource_manager.OnDestroyDevice();
                g_settings_dlg.OnDestroyDevice();    

                release_com(g_font);
                release_com(g_vertex_buffer);
                release_com(g_texture);
            }

            //--------------------------------------------------------------------------------------
            // Handle updates to the scene
            //--------------------------------------------------------------------------------------
            void CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
            {
            }

            //--------------------------------------------------------------------------------------
            // Render the helper information
            //--------------------------------------------------------------------------------------
            void RenderText()
            {
                CDXUTTextHelper text_helper(g_font, g_text_sprite, 
            20);
                
                text_helper.Begin();

                
            // show frame and device states
                text_helper.SetInsertionPos(55);
                text_helper.SetForegroundColor(FONT_COLOR);
                text_helper.DrawTextLine( DXUTGetFrameStats(
            true) );
                text_helper.DrawTextLine( DXUTGetDeviceStats() );

                
            // show other simple information
                
            //text_helper.SetForegroundColor( D3DXCOLOR(0.2f, 0.5f, 0.8f, 1.0f) );
                
            //text_helper.DrawTextLine(L"Texture Coordinate Transform");

                
            // show helper information
                
                
            const D3DSURFACE_DESC* surface_desc = DXUTGetBackBufferSurfaceDesc();

                
            if(g_show_help)
                {
                    text_helper.SetInsertionPos(
            10, surface_desc->Height - 18 * 5);
                    text_helper.SetForegroundColor(FONT_COLOR);
                    text_helper.DrawTextLine(L
            "Controls (F1 to hide):");
                    
                    text_helper.SetInsertionPos(
            40, surface_desc->Height - 18 * 4);
                    text_helper.DrawTextLine(L
            "Quit: ESC");
                }
                
            else
                {
                    text_helper.SetInsertionPos(
            10, surface_desc->Height - 15 * 4);
                    text_helper.SetForegroundColor( D3DXCOLOR(
            1.0f1.0f1.0f1.0f) );
                    text_helper.DrawTextLine(L
            "Press F1 for help");
                }

                text_helper.End();
            }

            //--------------------------------------------------------------------------------------
            // Render the scene 
            //--------------------------------------------------------------------------------------
            void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
            {
                HRESULT hr;

                
            if(g_settings_dlg.IsActive())
                {
                    g_settings_dlg.OnRender(fElapsedTime);
                    
            return;
                }

                
            // Clear the render target and the zbuffer 
                V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0000), 1.0f0) );

                
            // Render the scene
                if( SUCCEEDED( pd3dDevice->BeginScene() ) )
                {
                    pd3dDevice
            ->SetStreamSource(0, g_vertex_buffer, 0sizeof(sCustomVertex));
                    pd3dDevice
            ->SetFVF(D3DFVF_CUSTOM_VERTEX);
                    pd3dDevice
            ->DrawPrimitive(D3DPT_TRIANGLESTRIP, 02);

                    RenderText();

                    V(g_button_dlg.OnRender(fElapsedTime));

                    V( pd3dDevice
            ->EndScene() );
                }
            }


            //--------------------------------------------------------------------------------------
            // Handle messages to the application 
            //--------------------------------------------------------------------------------------
            LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, 
                                      
            bool* pbNoFurtherProcessing, void* pUserContext )
            {
                
            *pbNoFurtherProcessing = g_dlg_resource_manager.MsgProc(hWnd, uMsg, wParam, lParam);
                
            if(*pbNoFurtherProcessing)
                    
            return 0;

                
            if(g_settings_dlg.IsActive())
                {
                    g_settings_dlg.MsgProc(hWnd, uMsg, wParam, lParam);
                    
            return 0;
                }

                
            *pbNoFurtherProcessing = g_button_dlg.MsgProc(hWnd, uMsg, wParam, lParam);
                
            if(*pbNoFurtherProcessing)
                    
            return 0;

                
            return 0;
            }


            //--------------------------------------------------------------------------------------
            // Handle keybaord event
            //--------------------------------------------------------------------------------------
            void CALLBACK OnKeyboardProc(UINT charater, bool is_key_down, bool is_alt_down, void* user_context)
            {
                
            if(is_key_down)
                {
                    
            switch(charater)
                    {
                    
            case VK_F1:
                        g_show_help 
            = !g_show_help;
                        
            break;
                    }
                }
            }

            //--------------------------------------------------------------------------------------
            // Handle events for controls
            //--------------------------------------------------------------------------------------
            void CALLBACK OnGUIEvent(UINT eventint control_id, CDXUTControl* control, void* user_context)
            {
                
            switch(control_id)
                {
                
            case IDC_TOGGLE_FULLSCREEN:
                    DXUTToggleFullScreen();
                    
            break;

                
            case IDC_TOGGLE_REF:
                    DXUTToggleREF();
                    
            break;

                
            case IDC_CHANGE_DEVICE:
                    g_settings_dlg.SetActive(
            true);
                    
            break;
                }
            }

            //--------------------------------------------------------------------------------------
            // Initialize dialogs
            //--------------------------------------------------------------------------------------
            void InitDialogs()
            {
                g_settings_dlg.Init(
            &g_dlg_resource_manager);
                g_button_dlg.Init(
            &g_dlg_resource_manager);

                g_button_dlg.SetCallback(OnGUIEvent);

                
            int x = 35, y = 10, width = 125, height = 22;

                g_button_dlg.AddButton(IDC_TOGGLE_FULLSCREEN, L
            "Toggle full screen", x, y,         width, height);
                g_button_dlg.AddButton(IDC_TOGGLE_REF,          L
            "Toggle REF (F3)",     x, y += 24, width, height);
                g_button_dlg.AddButton(IDC_CHANGE_DEVICE,      L
            "Change device (F2)", x, y += 24, width, height, VK_F2);    
            }

            //--------------------------------------------------------------------------------------
            // Initialize everything and go into a render loop
            //--------------------------------------------------------------------------------------
            INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
            {
                
            // Enable run-time memory check for debug builds.
            #if defined(DEBUG) | defined(_DEBUG)
                _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF 
            | _CRTDBG_LEAK_CHECK_DF );
            #endif

                
            // Set the callback functions
                DXUTSetCallbackDeviceCreated( OnCreateDevice );
                DXUTSetCallbackDeviceReset( OnResetDevice );
                DXUTSetCallbackDeviceLost( OnLostDevice );
                DXUTSetCallbackDeviceDestroyed( OnDestroyDevice );
                DXUTSetCallbackMsgProc( MsgProc );
                DXUTSetCallbackFrameRender( OnFrameRender );
                DXUTSetCallbackFrameMove( OnFrameMove );
                DXUTSetCallbackKeyboard(OnKeyboardProc);
               
                
            // TODO: Perform any application-level initialization here
                InitDialogs();

                
            // Initialize DXUT and create the desired Win32 window and Direct3D device for the application
                DXUTInit( truetruetrue ); // Parse the command line, handle the default hotkeys, and show msgboxes
                DXUTSetCursorSettings( truetrue ); // Show the cursor and clip it when in full screen
                DXUTCreateWindow( L"Texture Coordinate Transform" );
                DXUTCreateDevice( D3DADAPTER_DEFAULT, 
            true640480, IsDeviceAcceptable, ModifyDeviceSettings );

                
            // Start the render loop
                DXUTMainLoop();

                
            // TODO: Perform any application-level cleanup here

                
            return DXUTGetExitCode();
            }

             

            下載示例工程


            posted on 2008-05-20 20:59 lovedday 閱讀(2834) 評論(6)  編輯 收藏 引用

            評論

            # re: 高級紋理映射技術(shù)(7) 2008-05-21 08:47 pazxlb

            樓主,是在太感謝了,剛好學(xué)到這里,您的文章來得太即時了,長期在您這居住了.  回復(fù)  更多評論   

            # re: 高級紋理映射技術(shù)(7) 2008-05-22 01:24 vw

            博主你好.看了你這篇有點想法.想請教您.
            開始我也是按照你所講述的自己寫了代碼.后來發(fā)現(xiàn)好像沒什么效果.下載了你的代碼.發(fā)現(xiàn)您把紋理置轉(zhuǎn)并放大了...
            我想請問您一個問題比如. OGRE 里的動態(tài)的云.是不是用這種技術(shù)來做的?  回復(fù)  更多評論   

            # re: 高級紋理映射技術(shù)(7) 2008-05-22 04:05 pazxlb

            博主您好,關(guān)于"紋理坐標變換只對自動生成的紋理坐標起作用,對頂點數(shù)據(jù)中的紋理坐標不起作用。"(我是初學(xué)者,有點疑惑于是又另外找了資料)

            感覺有點含糊,不知道您所說的“不起作用”是否是指不修改幾何體紋理坐標?

            附:

            系統(tǒng)可以從兩個數(shù)據(jù)源(FVF和D3D自動生成)得到紋理坐標。對于某一層紋理,應(yīng)用程序可以使用包含在頂點格式(D3DFVF_TEX1到D3DFVF_TEX8)中的紋理坐標,也可以使用Microsoft® Direct3D®自動生成的紋理坐標。如果當前紋理層的D3DTSS_TEXTURETRANSFORMFLAGS紋理層狀態(tài)為D3DTTFF_DISABLE(默認值),那么系統(tǒng)不會對輸入的紋理坐標進行變換。如果D3DTSS_TEXTURETRANSFORMFLAGS為任何其它值,那么系統(tǒng)會用該紋理層的變換矩陣對該輸入(包括FVF)紋理坐標進行變換。

            Direct3D不改變經(jīng)過變換和光照處理的頂點,因此,使用經(jīng)過變換和光照處理的頂點的應(yīng)用程序無法讓Direct3D變換頂點的紋理坐標。

            紋理坐標變換非常有用,它在生成特效的同時避免了對幾何體紋理坐標的直接修改。

            摘自:http://www.gesoftfactory.com/developer/Textures.htm  回復(fù)  更多評論   

            # re: 高級紋理映射技術(shù)(7) 2008-05-22 10:19 lovedday

            @pazxlb
            非常感謝你的糾正,確實D3DTSS_TEXTURETRANSFORMFLAGS對預(yù)先指定的紋理坐標也會起作用。

            這里給出測試代碼:

            if(FAILED(D3DXCreateTextureFromFile(g_device, "texture.jpg", &g_texture)))
            {
            MessageBox(NULL, "Create texture failed!", "ERROR", MB_OK);
            return false;
            }

            sCustomVertex vertices[] =
            {
            { -3, -3, 0.0f, 0.0f, 1.0f},
            { -3, 3, 0.0f, 0.0f, 0.0f},
            { 3, -3, 0.0f, 1.0f, 1.0f},
            { 3, 3, 0.0f, 1.0f, 0.0f }

            };

            g_device->CreateVertexBuffer(sizeof(vertices), 0, D3DFVF_CUSTOM_VERTEX, D3DPOOL_MANAGED, &g_vertex_buffer, NULL);

            void* ptr;

            g_vertex_buffer->Lock(0, 0, (void**)&ptr, 0);
            memcpy(ptr, vertices, sizeof(vertices));
            g_vertex_buffer->Unlock();

            g_device->SetTexture(0, g_texture);

            g_device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
            g_device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);

            D3DXMATRIX mat_texture, mat_scale;
            D3DXMatrixRotationX(&mat_texture, D3DX_PI);
            D3DXMatrixScaling(&mat_scale, 0.5f, 0.5f, 0.5f);
            mat_texture = mat_texture * mat_scale;
            g_device->SetTransform(D3DTS_TEXTURE0, &mat_texture);

            return true;

            以上代碼對原紋理坐標進行180度翻轉(zhuǎn),并且將原紋理坐標縮小為原來的一半。  回復(fù)  更多評論   

            # re: 高級紋理映射技術(shù)(7) 2008-05-22 10:22 lovedday

            @vw
            OGRE我還沒接觸過 :)  回復(fù)  更多評論   

            # re: 高級紋理映射技術(shù)(7) 2009-12-16 17:51 AsEngineDev

            D3DXMatrixTranslation(&mat_trans, 0.5f, 0.5f, 1.0f); 這句對嗎?
            不可以直接調(diào)用3維里面的矩陣去操作,2維坐標系

            如果,你要操作2D的紋理坐標系,應(yīng)該轉(zhuǎn)到3D用建立不是這樣的.

            比如說平移矩陣應(yīng)該是
            1 0 0
            0 1 0
            x y 1
            x,y應(yīng)該為平移矩陣

            如果,你平移,對應(yīng)3維空間里面的矩陣應(yīng)該為
            1 0 0 0
            0 1 0 0
            x y 1 0
            0 0 0 1
            也就是你要操作,請直接用
            mat_trans._31 = 0.5f;
            mat_trans._32 =0.5f;
            同樣的道理去推導(dǎo),紋理矩陣的旋轉(zhuǎn),之類的.

            一個紋理空間的點能做哪些操作?
            1,紋理空間的平移,因為這個紋理是2維的,所以也就是,在X,Y平面內(nèi)移動.這樣看,你的Z值也就是無效的.
            2,旋轉(zhuǎn),這個也是只能在一個平面內(nèi)旋轉(zhuǎn).所以,沒有圍繞X,Y坐標軸旋轉(zhuǎn)之類的.只能是有Z坐標軸旋轉(zhuǎn)是有效的.也就是道理.

              回復(fù)  更多評論   


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            公告

            導(dǎo)航

            統(tǒng)計

            常用鏈接

            隨筆分類(178)

            3D游戲編程相關(guān)鏈接

            搜索

            最新評論

            欧美粉嫩小泬久久久久久久| 国产99久久精品一区二区| 久久精品毛片免费观看| 中文精品99久久国产| 久久国产三级无码一区二区| 伊人色综合久久天天| 亚洲欧美日韩精品久久| 精品999久久久久久中文字幕| 久久精品亚洲一区二区三区浴池 | 久久久久亚洲AV无码专区首JN| 狠狠久久综合伊人不卡| 久久精品成人免费看| 久久久亚洲欧洲日产国码二区| 亚洲AV无码久久精品狠狠爱浪潮| 久久精品国产AV一区二区三区| 久久国产色av免费看| 久久精品国产亚洲AV无码娇色| 一本色道久久99一综合| 99久久99久久精品免费看蜜桃| 久久久久久久99精品免费观看| 亚洲一区中文字幕久久| 久久无码人妻精品一区二区三区| 欧美伊人久久大香线蕉综合69| 久久久久久久波多野结衣高潮| 日本人妻丰满熟妇久久久久久| 久久久久国产精品熟女影院 | 午夜精品久久久久9999高清| 久久精品国产亚洲精品| 国内精品久久久久影院老司| 亚洲中文字幕无码久久2020 | 性做久久久久久久久浪潮| 亚洲av伊人久久综合密臀性色| 久久综合久久综合九色| 色天使久久综合网天天| 久久精品天天中文字幕人妻| 久久91这里精品国产2020| 老男人久久青草av高清| 久久se精品一区精品二区| 亚洲人成无码久久电影网站| 精品久久久久久综合日本| 亚洲伊人久久综合影院|