Hello folks!
Today, when i took a piss, i was thinking how to make a reflected water surface with a matrix or plain object.
The fastest option is a plain object as far as i know.
Theoretical the surface can be generated like this.
You are a at position 0,0,-20
The water is at position 0,0,0
and above the water is a floating box at position 0,10,0
When you aim the camera at the water (plain) object, the camera moves to the plain with the x-angle of the old position but then + 180+90 degrees more. so you get a sort of bounce-off effect.
create an image from that point and paste it on the water surface.
then restore the old camera position and angle.
The main problem is.. How in gods name should i create something like this?
This is my code so far, only it doesnt create an image with the camera thats been placed on the water surface, NO its making images of the normal camera. and that sux.
create bitmap and stuff doesnt work. the water surface is getting black and oh well.. the screen is flickering like it was insane.
Here's my code:
oh and btw.. dont mind the ENGINE.DBA file, in this its only used for the CAMERA CONTROL.WSAD function.
you can replace that with a normal mouselook/arrow control if you like.
#INCLUDE "BIN32\ENGINE.DBA"
SET DISPLAY MODE 1024,768,32
SYNC ON
SYNC RATE 0
AUTOCAM OFF
MAKE MATRIX 1,100,100,10,10
POSITION MATRIX 1,-50,-10,-50
MAKE OBJECT BOX 1,50,1,50
`GHOST OBJECT ON 1
MAKE OBJECT BOX 2,10,1,10
POSITION OBJECT 2,0,10,0
DO
CONTROL CAMERA.WSAD(2.0,1.0,1,15.0,4.0)
REFLECT(1)
SCREEN DRAW.FPS
SYNC
LOOP
FUNCTION REFLECT(WID)
OLDCX#=CAMERA POSITION X()
OLDCY#=CAMERA POSITION Y()
OLDCZ#=CAMERA POSITION Z()
OLDAX#=CAMERA ANGLE X()
OLDAY#=CAMERA ANGLE Y()
OLDAZ#=CAMERA ANGLE Z()
WCX#=OBJECT POSITION X(WID)
WCY#=OBJECT POSITION Y(WID)
WCZ#=OBJECT POSITION Z(WID)
WAX#=OBJECT ANGLE X(WID)
WAY#=OBJECT ANGLE Y(WID)
WAZ#=OBJECT ANGLE Z(WID)
IF BITMAP EXIST(1)=1 THEN DELETE BITMAP 1
HIDE OBJECT WID
POSITION CAMERA WCX#,WCY#-10,WCZ#
ROTATE CAMERA WRAPVALUE(-90),WAY#,WAZ#
GET IMAGE 1,0,0,128,128
SHOW OBJECT WID
TEXTURE OBJECT 1,1
POSITION CAMERA OLDCX#,OLDCY#,OLDCZ#
ROTATE CAMERA OLDAX#,OLDAY#,OLDAZ#
ENDFUNCTION