Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 确定场景中与平截头体的交点_Delphi_Opengl_Frustum_Glscene - Fatal编程技术网

Delphi 确定场景中与平截头体的交点

Delphi 确定场景中与平截头体的交点,delphi,opengl,frustum,glscene,Delphi,Opengl,Frustum,Glscene,使用delphi中的GLScene,我需要找到一个对象(一条线或一个平面足够)和可见空间之间的交点,以确定该对象当前显示的部分。 我试着得到视图截头体,但我找不到方法。我曾考虑使用相机的位置、方向和视野,但我怀疑在使用移动目标或设置目标对象等方法时,它们不会更新。 谢谢, Marco您可以从相机对象中取出截锥体(TGLSceneViewer.camera属性)——需要属性近平面,深度视图,位置,方向,以及“TGLSceneViewer.FieldOfView” TGLCamera还有一种称为“R

使用delphi中的GLScene,我需要找到一个对象(一条线或一个平面足够)和可见空间之间的交点,以确定该对象当前显示的部分。
我试着得到视图截头体,但我找不到方法。我曾考虑使用相机的位置、方向和视野,但我怀疑在使用移动目标或设置目标对象等方法时,它们不会更新。
谢谢,

Marco

您可以从相机对象中取出截锥体(TGLSceneViewer.camera属性)——需要属性
近平面
深度视图
位置
方向
,以及“TGLSceneViewer.FieldOfView”


TGLCamera还有一种称为“RayCastIntersect”的方法,可能会被证明很有用。

要获取平截头体,可以使用从TGLSene当前缓冲区中的ModelViewMatrix和ProjectionMatrix叠加得到的ModelViewProjection矩阵。要从矩阵中获取平面,请使用ExtractFrustomFromModelViewProjection函数。以下是一段代码片段:

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;

方向不会改变,例如,当我使用TGLCamera.MoveAroundTarget时,我现在正在试验投影矩阵和模型视图矩阵mat:=MatrixMultiply(GLScene1.CurrentBuffer.ProjectionMatrix,GLScene1.CurrentBuffer.ModelViewMatrix);正确的矩阵是MatrixMultiply(GLScene1.CurrentBuffer.ModelViewMatrix,GLScene1.CurrentBuffer.ProjectionMatrix);当我清理我的测试时,我会发布一些delphi代码