- Код: Выделить всё
Sub PurchaseFollowing(MeshObject As Mesh, RelativeEndPosition As D3DVECTOR, LookAtInMesh As D3DVECTOR, CameraSpeed As Single, Optional ExponentialSpeed As Boolean = True, Optional MaxCameraSpeed As Single = 100, Optional AvoidObject As Boolean = False)
Dim RelPos As D3DVECTOR, Direct As D3DVECTOR, Direction As D3DVECTOR, EndV As D3DVECTOR, a As D3DVECTOR
RelPos = MTransform(Mesh(MeshObject.GetMeshIndex).Features.Matrix, RelativeEndPosition)
Direct = VSubtract(RelPos, StartPos)
CameraSpeed = CameraSpeed * VModulus(Direct)
If CameraSpeed > MaxCameraSpeed Then CameraSpeed = MaxCameraSpeed
If CameraSpeed <= 0 Then Exit Sub
'If Direct.y < SystemFrame / 1000 Then Direct.y = 0
Direction = VNormalize(Direct)
a = StartPos
EndV = VAdd(StartPos, VScale(Direction, SystemFrame * CameraSpeed / 1000))
' If LocalScene.Collide(a, EndV) = False Or AvoidObject = False Then
' StartPos = EndV
' Else
' StartPos = a
' End If
RelPos = MTransform(Mesh(MeshObject.GetMeshIndex).Features.Matrix, LookAtInMesh)
EndPos = RelPos
DirectX.ViewMatrix ViewMatrix, StartPos, EndPos, Vector(0, 1, 0), 0
End Sub
StartPos - позиция камеры, EndPos - точку на которую смотрит камера.
Остальное я так думаю понятно...
Помогите очень прошу!