本文整理汇总了C++中AABB::RayIntersact方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::RayIntersact方法的具体用法?C++ AABB::RayIntersact怎么用?C++ AABB::RayIntersact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB::RayIntersact方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunTest
void Object_Picking_Test::RunTest(float mX, float mY)
{
CameraPtr ptr = scene->GetActiveCamera();
Camera * cam = ptr.Get();
cam->CalcPickingRay(mX, mY);
using namespace DirectX;
for (unsigned int i = 0; i < pickable.size(); i++)
{
SceneObj obj = pickable[i];
StaticEntity * ent = obj.obj.Get();
XMFLOAT4X4 mat = ent->GetWorldMatrix();
XMMATRIX world = XMLoadFloat4x4((XMFLOAT4X4*)&mat);
world = XMMatrixTranspose(world);
XMVECTOR det = XMMatrixDeterminant(world);
XMMATRIX invWorld = XMMatrixInverse(&det, world);
Vector3 org = cam->GetPosition();
Vector3 dir = cam->GetPickingRayDirection();
XMVECTOR orgInv = XMVector3TransformCoord(XMLoadFloat3((XMFLOAT3*)&org), invWorld);
XMVECTOR dirInv = XMVector3TransformNormal(XMLoadFloat3((XMFLOAT3*)&dir), invWorld);
dirInv = XMVector3Normalize(dirInv);
XMStoreFloat3((XMFLOAT3*)&org, orgInv);
XMStoreFloat3((XMFLOAT3*)&dir, dirInv);
AABB bbox = ent->GetAABB();
/*XMVECTOR max = XMLoadFloat3((XMFLOAT3*)&bbox.max);
XMVECTOR min = XMLoadFloat3((XMFLOAT3*)&bbox.min);
max = XMVector3TransformCoord(max, world);
min = XMVector3TransformCoord(min, world);
XMStoreFloat3((XMFLOAT3*)&bbox.max, max);
XMStoreFloat3((XMFLOAT3*)&bbox.min, min);*/
if (bbox.RayIntersact(org, dir))
{
obj.bbox.Get()->SetVisible(!obj.bbox.Get()->IsVisible());
}
}
}