| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>EntityInView ( entity,camera )</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- entity - entity handle
<br />
- camera - camera handle
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- Returns true if the specified entity is visible to the specified camera.
<br />
-
<br />
- If the entity is a mesh, its bounding box will be checked for visibility.
<br />
-
<br />
- For all other types of entities, only their centre position will be checked.
- </td>
- </tr>
- </table>
- <h1><a href=../3d_examples/EntityInView.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; EntityInView Example
<br />
- ; --------------------
<br />
-
<br />
- Graphics3D 640,480
<br />
- SetBuffer BackBuffer()
<br />
-
<br />
- camera=CreateCamera()
<br />
- PositionEntity camera,0,2,-10
<br />
-
<br />
- light=CreateLight()
<br />
- RotateEntity light,90,0,0
<br />
-
<br />
- plane=CreatePlane()
<br />
- ground_tex=LoadTexture("media/Chorme-2.bmp")
<br />
- EntityTexture plane,ground_tex
<br />
-
<br />
- cube=CreateCube()
<br />
- cube_tex=LoadTexture("media/b3dlogo.jpg")
<br />
- EntityTexture cube,cube_tex
<br />
- PositionEntity cube,0,1,0
<br />
-
<br />
- While Not KeyDown( 1 )
<br />
-
<br />
- If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0
<br />
- If KeyDown( 203 )=True Then TurnEntity camera,0,1,0
<br />
- If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.05
<br />
- If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.05
<br />
-
<br />
- ; Use camera project to get 2D coordinates from 3D coordinates of cube
<br />
- CameraProject(camera,EntityX(cube),EntityY(cube),EntityZ(cube))
<br />
-
<br />
- RenderWorld
<br />
-
<br />
- ; If cube is in view then draw text, if not then draw nothing otherwise text will be drawn at 0,0
<br />
- If EntityInView(cube,camera)=True
<br />
-
<br />
- ; Use ProjectedX() and ProjectedY() to get 2D coordinates from when CameraProject was used.
<br />
- ; Use these coordinates to draw text at a 2D position, on top of a 3D scene.
<br />
- Text ProjectedX#(),ProjectedY#(),"Cube"
<br />
-
<br />
- EndIf
<br />
-
<br />
- Text 0,0,"Use cursor keys to move about"
<br />
- Text 0,20,"ProjectedX: "+ProjectedX#()
<br />
- Text 0,40,"ProjectedY: "+ProjectedY#()
<br />
- Text 0,60,"ProjectedZ: "+ProjectedZ#()
<br />
- Text 0,80,"EntityInView: "+EntityInView(cube,camera)
<br />
-
<br />
- Flip
<br />
-
<br />
- Wend
<br />
-
<br />
- End
- </td>
- </tr>
- </table>
- <br>
- <a target=_top href=../index.htm>Index</a><br>
- <br>
- Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=EntityInView&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
- </html>
|