Skip to content

CameraProject

Narta Xaymar Dirks edited this page Oct 28, 2026 · 6 revisions
Blitz3D

CameraProject

CameraProject:Void camera:Int32, x:Float32, y:Float32, z:Float32
Parameter Mode Type Default Description
camera In Int32 required Camera handle.
x In Float32 required X coordinate in the world.
y In Float32 required Y coordinate in the world.
z In Float32 required Z coordinate in the world.

Description

Works out where a point of the world lands on the screen. The result is not returned: read it afterwards with ProjectedX, ProjectedY and ProjectedZ. X and Y are pixels of the graphics buffer and Z is the distance of the point in front of the camera. A point behind the camera or a camera that is off gets Y and X far outside the screen, so check ProjectedZ before drawing. Use it to put 2D labels, health bars or a lens flare on a 3D position.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
light = CreateLight()
RotateEntity light, 45, 45, 0
cube = CreateCube()
PositionEntity cube, 1, 0.5, 6
TurnEntity cube, 25, 30, 0
RenderWorld
CameraProject camera, EntityX(cube), EntityY(cube) + 2, EntityZ(cube)
If ProjectedZ() > 0 Then
	Color 255, 255, 0
	Text ProjectedX(), ProjectedY(), "cube", 1, 1
EndIf
Flip
WaitKey

Media

CameraProject

Related Commands

CameraClsColor, CameraClsMode, CameraCulling, CameraCullingSource, CameraFogColor, CameraFogMode, CameraFogRange, CameraProjMode

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally