在Delphi使用的GLScene我需要找到(线面是足够或)的对象之间的交点和可见的空间,以确定哪些此对象的一部分当前显示。结果, 我试图让视锥,但我怎么也找不到。我是用摄像机的位置,方向和视野的思维,但我怀疑使用像MoveAroundTarget方法或设置目标对象时,他们没有更新。点击 谢谢你,结果 马可

有帮助吗?

解决方案

为了让你可以使用multipying的ModelViewMatrix和TGLScene当前缓冲区的ProjectionMatrix获得的ModelViewProjection矩阵的视锥。为了从基质飞机使用ExtractFrustumFromModelViewProjection功能。这里是一个代码段:

var
  matMVP: TMatrix;
  frustum : TFrustum;
  intersectPoint : TVector;
begin
  // get the ModelViewProjection matrix
  matMVP:=MatrixMultiply(GLScene1.CurrentBuffer.ModelViewMatrix, GLScene1.CurrentBuffer.ProjectionMatrix);
  // extract frustum
  frustum:=ExtractFrustumFromModelViewProjection(matMVP);
  // calculate intersection between left plane and line passing through GLArrowLineX object
  if (IntersectLinePlane(GLArrowLineX.Position.AsVector,GLArrowLineX.Direction.AsVector, frustum.pLeft, @intersectPoint)=1)
  then begin
    // do something with intersectPoint
  end else begin
    // no intersection point (parallel or inside plane)
  end;
end;

其他提示

可以得到锥台从相机对象(TGLSceneViewer.Camera属性)的 - 将所需的性质NearPlaneDepthOfViewPositionDirection,以及“TGLSceneViewer.FieldOfView”。

在TGLCamera也有一个称为RayCastIntersect方法可以证明是有用的。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top