| parent (optional) - parent entity of mirror |
|
Creates a mirror entity and returns its handle. A mirror entity is basically a flat, infinite 'ground'. This ground is invisible, except that it vertically flips anything above it to below it, and vice versa. It is useful for games where you want the effect of a shiny floor showing a reflection. For a convincing shiny floor, combine a mirror entity with a textured plane entity that has an EntityAlpha of about 0.5 - the reflection shows through the semi-transparent floor. Mirrors cost rendering time: the whole scene is rendered again for each mirror, so use them sparingly. The optional parent parameter allows you to specify a parent entity for the mirror, so that when the parent moves the mirror moves with it. The relationship is one way: applying movement commands to the child will not affect the parent. Specifying a parent will still result in the mirror being created at position 0,0,0 rather than at the parent entity's position. See also: CreatePlane, EntityAlpha. |
; CreateMirror Example
; --------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,2,-6
light=CreateLight()
RotateEntity light,45,45,0
; A spinning cone floating above the floor
cone=CreateCone(16)
EntityColor cone,255,100,0
; A semi-transparent textured plane makes the reflection look like a shiny floor
ground=CreatePlane()
ground_tex=LoadTexture("media/MossyGround.BMP")
EntityTexture ground,ground_tex
EntityAlpha ground,0.5
; Create the mirror - an infinite, invisible plane that reflects the scene
mirror=CreateMirror()
height#=2.0
While Not KeyDown(1)
; [ / ] lower and raise the cone above the mirror
If KeyDown(26) And height>0.5 Then height=height-0.05
If KeyDown(27) And height<5 Then height=height+0.05
PositionEntity cone,0,height,0
TurnEntity cone,0,2,0
; Arrow keys move the camera
If KeyDown(200) Then MoveEntity camera,0,0,0.1
If KeyDown(208) Then MoveEntity camera,0,0,-0.1
If KeyDown(203) Then TurnEntity camera,0,1,0
If KeyDown(205) Then TurnEntity camera,0,-1,0
RenderWorld
Text 0,0,"[ / ] : lower/raise cone Arrow keys: move camera Esc: exit"
Text 0,20,"CreateMirror() reflects the cone in the semi-transparent floor"
Flip
Wend
End