Hi Sledge,
Sorry fot the delay. Your previous bit of code was a great example of EntityInView.
I did a little mod on it below to iterate text to the screen to tell when a ship(Sphere) was in view. It only picks up 1 of the 2 entitys. Sorry for my ignorance but is it possible to report to the screen every time a ship(sphere) passes in front.
Regds,
Const NUMBER_OF_SHIPS = 2
Graphics3D 800,600,0,2
SetBuffer BackBuffer()
cam = CreateCamera()
PositionEntity cam,0,5,-20
light = CreateLight()
PositionEntity light,100,100,-100
Global shipseen
Type ship
Field geom
Field seen
End Type
CurrentShip.Ship = Null
Function CreateShip.Ship()
NewShip.Ship = New ship
NewShip\geom = CreateSphere(8)
EntityPickMode NewShip\geom,1
Return NewShip.Ship
End Function
Function CheckShipsAgainst(player_arg.player)
For CurrentShip.ship = Each ship
If EntityInView(CurrentShip\geom,player_arg\cam)
CurrentShip\seen = True
Else
CurrentShip\seen = False
EndIf
Next
End Function
Function ColourShips()
For CurrentShip.ship = Each ship
If CurrentShip\seen
EntityColor CurrentShip\geom,100,255,255
shipseen=1
Else
shipseen=0
EntityColor CurrentShip\geom,100,100,100
EndIf
Next
End Function
Type player
Field cam
Field geom
End Type
Function CreatePlayer.Player(viewX_arg, viewY_arg)
Local NewPlayer.Player = New player
NewPlayer\cam = CreateCamera()
CameraViewport NewPlayer\cam,viewX_arg,viewY_arg,256,256
CameraClsColor NewPlayer\cam,10,10,10
NewPlayer\geom = CreateCone()
RotateEntity NewPlayer\geom,90,0,0
EntityParent NewPlayer\geom,NewPlayer\cam
Return NewPlayer
End Function
CurrentPlayer.Player = CreatePlayer(0,0)
worldPiv = CreatePivot()
PointEntity cam,worldPiv
For i = 1 To NUMBER_OF_SHIPS
CurrentShip = CreateShip()
PositionEntity CurrentShip\geom,0,0,15
EntityParent CurrentShip\geom, worldPiv
TurnEntity worldPiv, 0, 360/NUMBER_OF_SHIPS, 0
Next
While Not MouseHit(1)
TurnEntity worldPiv,0,1,0
TurnEntity CurrentPlayer\cam,0,-.5,0
CheckShipsAgainst(CurrentPlayer)
ColourShips()
RenderWorld
If shipseen=0 Then
Text 0,0, "Ship out of view"
Else If shipseen=1 Then
Text 0,0, "Ships in view"
End If
Flip True
Cls
Delay 1
Wend
Sorry fot the delay. Your previous bit of code was a great example of EntityInView.
I did a little mod on it below to iterate text to the screen to tell when a ship(Sphere) was in view. It only picks up 1 of the 2 entitys. Sorry for my ignorance but is it possible to report to the screen every time a ship(sphere) passes in front.
Regds,
Const NUMBER_OF_SHIPS = 2
Graphics3D 800,600,0,2
SetBuffer BackBuffer()
cam = CreateCamera()
PositionEntity cam,0,5,-20
light = CreateLight()
PositionEntity light,100,100,-100
Global shipseen
Type ship
Field geom
Field seen
End Type
CurrentShip.Ship = Null
Function CreateShip.Ship()
NewShip.Ship = New ship
NewShip\geom = CreateSphere(8)
EntityPickMode NewShip\geom,1
Return NewShip.Ship
End Function
Function CheckShipsAgainst(player_arg.player)
For CurrentShip.ship = Each ship
If EntityInView(CurrentShip\geom,player_arg\cam)
CurrentShip\seen = True
Else
CurrentShip\seen = False
EndIf
Next
End Function
Function ColourShips()
For CurrentShip.ship = Each ship
If CurrentShip\seen
EntityColor CurrentShip\geom,100,255,255
shipseen=1
Else
shipseen=0
EntityColor CurrentShip\geom,100,100,100
EndIf
Next
End Function
Type player
Field cam
Field geom
End Type
Function CreatePlayer.Player(viewX_arg, viewY_arg)
Local NewPlayer.Player = New player
NewPlayer\cam = CreateCamera()
CameraViewport NewPlayer\cam,viewX_arg,viewY_arg,256,256
CameraClsColor NewPlayer\cam,10,10,10
NewPlayer\geom = CreateCone()
RotateEntity NewPlayer\geom,90,0,0
EntityParent NewPlayer\geom,NewPlayer\cam
Return NewPlayer
End Function
CurrentPlayer.Player = CreatePlayer(0,0)
worldPiv = CreatePivot()
PointEntity cam,worldPiv
For i = 1 To NUMBER_OF_SHIPS
CurrentShip = CreateShip()
PositionEntity CurrentShip\geom,0,0,15
EntityParent CurrentShip\geom, worldPiv
TurnEntity worldPiv, 0, 360/NUMBER_OF_SHIPS, 0
Next
While Not MouseHit(1)
TurnEntity worldPiv,0,1,0
TurnEntity CurrentPlayer\cam,0,-.5,0
CheckShipsAgainst(CurrentPlayer)
ColourShips()
RenderWorld
If shipseen=0 Then
Text 0,0, "Ship out of view"
Else If shipseen=1 Then
Text 0,0, "Ships in view"
End If
Flip True
Cls
Delay 1
Wend