デルファイでGLSceneを使用して、オブジェクト(線または平面で十分)と可視スペースの交点を見つけて、このオブジェクトの現在表示されている部分を特定する必要があります。
ビュー錐台を取得しようとしましたが、方法が見つかりませんでした。カメラの位置、方向、視野を使用することを考えていましたが、MoveAroundTargetなどのメソッドを使用したり、ターゲットオブジェクトを設定したりすると、それらが更新されないのではないかと思います。
ありがとう、
マルコ
1612 次
2 に答える
2
錐台を取得するには、TGLSceneの現在のバッファーからModelViewMatrixと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;
于 2010-01-08T10:51:21.930 に答える
1
カメラ オブジェクト (TGLSceneViewer.Camera プロパティ) から錐台を取得できます。プロパティNearPlane
、DepthOfView
、Position
、Direction
および「TGLSceneViewer.FieldOfView」が必要です。
TGLCamera には、RayCastIntersect
便利なメソッドが呼び出されることもあります。
于 2009-12-30T22:38:43.247 に答える