游戏开发论坛

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: tonykee

棘手的问题,关于投影变换

[复制链接]

180

主题

3511

帖子

3520

积分

论坛元老

Rank: 8Rank: 8

积分
3520
发表于 2007-1-15 22:05:00 | 显示全部楼层

Re:棘手的问题,关于投影变换

对了,还少了一些。如果
分辨率是 800*600 ,
屏幕宽高比是 16:10 = 1.6,
视野是 60度,那么

s=
(
400+ 400*x/ [z*tan(30度)*1.6]
,
300- 300*y/ [z*tan(30度)]
)

5

主题

19

帖子

25

积分

注册会员

Rank: 2

积分
25
发表于 2007-1-15 22:39:00 | 显示全部楼层

Re:棘手的问题,关于投影变换

Projects a 3D vector from object space into screen space.

D3DXVECTOR3 * D3DXVec3Project(
  D3DXVECTOR3 * pOut,
  CONST D3DXVECTOR3 * pV,
  CONST D3DVIEWPORT9 * pViewport,
  CONST D3DXMATRIX * pProjection,
  CONST D3DXMATRIX * pView,
  CONST D3DXMATRIX * pWorld
);
Parameters
pOut
[in, out] Pointer to the D3DXVECTOR3 structure that is the result of the operation.
pV
[in] Pointer to the source D3DXVECTOR3 structure.
pViewport
[in] Pointer to a D3DVIEWPORT9 structure, representing the viewport.
pProjection
[in] Pointer to a D3DXMATRIX structure, representing the projection matrix.
pView
[in] Pointer to a D3DXMATRIX structure, representing the view matrix.
pWorld
[in] Pointer to a D3DXMATRIX structure, representing the world matrix.
Return Values
Pointer to a D3DXVECTOR3 structure that is the vector projected from object space to screen space.

Remarks
The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXVec3Project function can be used as a parameter for another function.

Requirements
Header: Declared in D3dx9math.h.

See Also
D3DXVec3Unproject

以上摘自DirectX文档

140

主题

1228

帖子

1233

积分

金牌会员

Rank: 6Rank: 6

积分
1233
QQ
发表于 2007-1-16 00:03:00 | 显示全部楼层

Re:棘手的问题,关于投影变换

I 服了you ,dx里有一个直接的方法取。
这不光是投影矩阵要参与,视矩阵和世界矩阵都乘上。
D3DXVECTOR3 * D3DXVec3Project(
  D3DXVECTOR3 * pOut,
  CONST D3DXVECTOR3 * pV,
  CONST D3DVIEWPORT9 * pViewport,
  CONST D3DXMATRIX * pProjection,
  CONST D3DXMATRIX * pView,
  CONST D3DXMATRIX * pWorld
);
(不好意思,没注意楼上的兄弟已经发了)

4

主题

88

帖子

88

积分

注册会员

Rank: 2

积分
88
发表于 2007-1-16 10:57:00 | 显示全部楼层

Re:棘手的问题,关于投影变换

13楼正解,可以看下MSDN,关于D3DXProject的函数,同理还有D3DXUnproject,但是具体用法似乎不像楼上说的那么简单,算出的点还需要自己考量一下。

19

主题

73

帖子

73

积分

注册会员

Rank: 2

积分
73
发表于 2007-1-16 11:21:00 | 显示全部楼层

Re:棘手的问题,关于投影变换

D3DXVec3Project
得到的应该是你在 backbuffer 里的位置,如果你的 backbuffer 大小跟窗口不一致,那你还需要做相应的变换,

6

主题

307

帖子

309

积分

中级会员

Rank: 3Rank: 3

积分
309
发表于 2007-1-16 12:18:00 | 显示全部楼层

Re:棘手的问题,关于投影变换

简单得很,乘上视矩阵和投影矩阵不就完了

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
 楼主| 发表于 2007-1-16 16:07:00 | 显示全部楼层

Re:棘手的问题,关于投影变换

我用纯几何方法已经算出来了。呵呵。。。。还不知道,DX里面有这个函数?呵呵。。
谢谢各位

8

主题

716

帖子

716

积分

高级会员

Rank: 4

积分
716
发表于 2007-1-17 10:14:00 | 显示全部楼层

Re:棘手的问题,关于投影变换

有种顶点格式叫做XYZRHW

0

主题

29

帖子

29

积分

注册会员

Rank: 2

积分
29
发表于 2007-1-18 13:14:00 | 显示全部楼层

Re:棘手的问题,关于投影变换

呵呵
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-26 06:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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