游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1422|回复: 2

求助 !! 一些D3D中的问题

[复制链接]

15

主题

248

帖子

248

积分

中级会员

Rank: 3Rank: 3

积分
248
发表于 2005-4-16 11:31:00 | 显示全部楼层 |阅读模式
我刚开始学习D3D, 遇到了一些令人头痛的问题, 希望各位好心的哥哥姐姐能帮帮忙, 拜谢!!!!!

1. D3D中有没有比较快的方法确定 近裁截面 的 4个 顶点坐标 ?
2. 如何确定 ?
3. D3DXMatrixPerspectiveFovLH() 函数中 第4个参数 near view-plane 的值 是否表示 视点
    与 近裁截面 的距离 ?
4. ShadowVolume中Z-Pass算法失效的原因是否是 视点在阴影体内 或 近裁截面与阴影体相
    交 ?
5. 判断线段与三角面的相交问题, 用 ( 线段的一个端点 与 三角面的三个顶点 所组成的 三个
    平面 与 线段的另外一个端点 的 位置关系 ) 判断 是否是比较简单的方法 ?
6. 有没有时间复杂度更低的算法 ?

再次感谢各位好心的哥哥姐姐能给予我帮助, 再拜一下!!!!!

[em24] [em24] [em7] [em7] [em8] [em8]

16

主题

83

帖子

103

积分

注册会员

Rank: 2

积分
103
QQ
发表于 2005-4-16 12:02:00 | 显示全部楼层

Re:求助 !! 一些D3D中的问题

1.这是一个视截体类,其中m_Planes存放的就是计算后的六个裁平面.近裁截面 的 4个 顶点坐标也就很简单的算出来了.
BOOL CFrustum::Construct(LPDIRECT3DDEVICE9 pd3dDevice, float ZDistance)
{
  D3DXMATRIX Matrix, matView, matProj;
  float      ZMin, Q;

  // Error checking
  if(pd3dDevice == NULL)
    return FALSE;

  // Calculate FOV data
  pd3dDevice->GetTransform(D3DTS_PROJECTION, &matProj);
  if(ZDistance != 0.0f) {
    // Calculate new projection matrix based on distance provided
    ZMin = -matProj._43 / matProj._33;
    Q = ZDistance / (ZDistance - ZMin);
    matProj._33 = Q;
    matProj._43 = -Q * ZMin;
  }
  pd3dDevice->GetTransform(D3DTS_VIEW, &matView);
  D3DXMatrixMultiply(&Matrix, &matView, &matProj);

  // Calculate the planes
  m_Planes[0].a = Matrix._14 + Matrix._13; // Near
  m_Planes[0].b = Matrix._24 + Matrix._23;
  m_Planes[0].c = Matrix._34 + Matrix._33;
  m_Planes[0].d = Matrix._44 + Matrix._43;
  D3DXPlaneNormalize(&m_Planes[0], &m_Planes[0]);

  m_Planes[1].a = Matrix._14 - Matrix._13; // Far
  m_Planes[1].b = Matrix._24 - Matrix._23;
  m_Planes[1].c = Matrix._34 - Matrix._33;
  m_Planes[1].d = Matrix._44 - Matrix._43;
  D3DXPlaneNormalize(&m_Planes[1], &m_Planes[1]);

  m_Planes[2].a = Matrix._14 + Matrix._11; // Left
  m_Planes[2].b = Matrix._24 + Matrix._21;
  m_Planes[2].c = Matrix._34 + Matrix._31;
  m_Planes[2].d = Matrix._44 + Matrix._41;
  D3DXPlaneNormalize(&m_Planes[2], &m_Planes[2]);

  m_Planes[3].a = Matrix._14 - Matrix._11; // Right
  m_Planes[3].b = Matrix._24 - Matrix._21;
  m_Planes[3].c = Matrix._34 - Matrix._31;
  m_Planes[3].d = Matrix._44 - Matrix._41;
  D3DXPlaneNormalize(&m_Planes[3], &m_Planes[3]);

  m_Planes[4].a = Matrix._14 - Matrix._12; // Top
  m_Planes[4].b = Matrix._24 - Matrix._22;
  m_Planes[4].c = Matrix._34 - Matrix._32;
  m_Planes[4].d = Matrix._44 - Matrix._42;
  D3DXPlaneNormalize(&m_Planes[4], &m_Planes[4]);

  m_Planes[5].a = Matrix._14 + Matrix._12; // Bottom
  m_Planes[5].b = Matrix._24 + Matrix._22;
  m_Planes[5].c = Matrix._34 + Matrix._32;
  m_Planes[5].d = Matrix._44 + Matrix._42;
  D3DXPlaneNormalize(&m_Planes[5], &m_Planes[5]);

  return TRUE;
}

15

主题

248

帖子

248

积分

中级会员

Rank: 3Rank: 3

积分
248
 楼主| 发表于 2005-4-16 17:52:00 | 显示全部楼层

Re:求助 !! 一些D3D中的问题

哦, 我明白了, 多谢多谢!!  再拜一下
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-25 08:37

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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