游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1068|回复: 1

D3D sdk Tutorial 5: Textures 教程中关于纹理操作的疑惑

[复制链接]

36

主题

109

帖子

111

积分

注册会员

Rank: 2

积分
111
发表于 2007-9-7 16:56:00 | 显示全部楼层 |阅读模式
#ifdef SHOW_HOW_TO_USE_TCI
        // Note: to use D3D texture coordinate generation, use the stage state
        // D3DTSS_TEXCOORDINDEX, as shown below. In this example, we are using
        // the position of the vertex in camera space to generate texture
        // coordinates. The tex coord index (TCI) parameters are passed into a
        // texture transform, which is a 4x4 matrix which transforms the x,y,z
        // TCI coordinates into tu, tv texture coordinates.

        // In this example, the texture matrix is setup to
        // transform the texture from (-1,+1) position coordinates to (0,1)
        // texture coordinate space:
        //    tu =  0.5*x + 0.5
        //    tv = -0.5*y + 0.5
        D3DXMATRIXA16 mat;
        mat._11 = 0.25f; mat._12 = 0.00f; mat._13 = 0.00f; mat._14 = 0.00f;
        mat._21 = 0.00f; mat._22 =-0.25f; mat._23 = 0.00f; mat._24 = 0.00f;
        mat._31 = 0.00f; mat._32 = 0.00f; mat._33 = 1.00f; mat._34 = 0.00f;
        mat._41 = 0.50f; mat._42 = 0.50f; mat._43 = 0.00f; mat._44 = 1.00f;

        g_pd3dDevice->SetTransform( D3DTS_TEXTURE0, &mat );
        g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
        g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION );
以上是render()函数中的原码,上面的部分是在渲染物体前设置的,我不知道上面的执行对纹理都执行了哪些操作,都有什么用哪,上面的注释我没有看懂 [em7]

2

主题

141

帖子

141

积分

注册会员

Rank: 2

积分
141
发表于 2007-9-7 17:56:00 | 显示全部楼层

Re:D3D sdk Tutorial 5: Textures 教程中关于纹理操作的疑惑

这种设置就是vertex buffer不需要UV坐标
从projection matrix直接产生纹理坐标
自己看代码,看书还不够认真阿
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-21 21:30

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表