Blitz NG - Camera Problem

Started by Lucky_Strikez, October 03, 2020, 11:58:14

Previous topic - Next topic

Lucky_Strikez

Hi all, I'm trying to use this old camera code from 2003 and it works, but it doesn't point at the entity center. I'm just posting this as a bug report I guess, not sure where else to put it. It works correctly in regular old Blitz3d but not quite right in Blitz3d NG, the camera points to the left of the entity. You can paste it directly and run it to test it out, what you think about this Rontek?:

Code (blitz3D NG) Select

; SuperCam!
;
; by PsychicParrot 2003
;
;
; Usage : SuperCam(cam,ent,cspeed#,dist#,hite#,xrot#,tilt#)
;
;

Graphics3D 640,480,16,3
SetBuffer=BackBuffer()

Global campivot=CreateCube() ; create pivot for camera
Global camera=CreateCamera()  ; create camera (!!!)

; ---------------------- THIS IS ALL JUST TO POPULATE THE WORLD WITH SOME RUBBISH ---------------

Global light=CreateLight()
Global player=CreateCube()    ; create simple player
Global plane=CreatePlane()   ; create simple floor
MoveEntity player,0,1,0
; Create texture of size 256x256
tex=CreateTexture(256,256)

; Set buffer - texture buffer
SetBuffer TextureBuffer(tex)

; Clear texture buffer with background white color
For i=1 To 10
Color Rnd(0,255),Rnd(0,255),Rnd(0,255)
Rect Rnd(0,256),Rnd(0,256),Rnd(0,256),Rnd(0,256)
Next

; Texture cube with texture
EntityTexture plane,tex
EntityTexture player,tex

; Set buffer - backbuffer
SetBuffer BackBuffer()

; ----------------------------------------------------------------------------------------------

While Not KeyHit(1)

If KeyDown(200) Then
        MoveEntity player,0,0,.2
End If

If KeyDown(203) TurnEntity player,0,1,0
If KeyDown(205) TurnEntity player,0,-1,0

SuperCam(camera,player,.02,6,2,12,0)

RenderWorld
Flip

Wend

End

Function SuperCam(cam,ent,cspeed#,dist#,height#,xrot#,tilt#)

TFormPoint 0,height#,-dist#,ent,0

cx#=(TFormedX()-EntityX(cam))*cspeed#
cy#=(TFormedY()-EntityY(cam))*cspeed#
cz#=(TFormedZ()-EntityZ(cam))*cspeed#

TranslateEntity cam,cx,cy,cz
PointEntity cam,ent
RotateEntity cam,xrot#,EntityYaw(cam),tilt#

End Function