GLBasic forum

Main forum => GLBasic - en => Topic started by: kamakazieturtle on 2009-Apr-13

Title: Camera Help
Post by: kamakazieturtle on 2009-Apr-13
Ok, so I have been trying to learn how to make a 3rd person camera for like the last 2 weeks :S, and so far no success from the search. So if someone has code for one they wouldn't mind sharing. Or if someone feels like taking the time to explain how rotating a point around another works, I could really use the help.
Title: Re: Camera Help
Post by: Moru on 2009-Apr-13
Try this one: http://www.glbasic.com/forum/index.php?topic=1998.0 (http://www.glbasic.com/forum/index.php?topic=1998.0)
Title: Re: Camera Help
Post by: kamakazieturtle on 2009-Apr-13
I've read over it before, but I'm not really all that great at 3d. I've been programming for years, but have only been doing 2d and would be intermediate if at that. I can draw objects and have object rotation down, but now i want to rotate the camera around the character, so i can use the code later for 3rd person once I finish my person. I'll go over this again and try so suck it all in but if u have and helpful key points to cameras it'll help :), Thanks.
Title: Re: Camera Help
Post by: Moru on 2009-Apr-13
Ok, then try this one: http://www.glbasic.com/forum/index.php?topic=2021.0 (http://www.glbasic.com/forum/index.php?topic=2021.0)

Makes it a lot easier to use 3D on GLBasic.
Title: Re: Camera Help
Post by: kamakazieturtle on 2009-Apr-14
This still didn't really help, but I kept googling math and stuff and came up with something. I help this might help anyone with my same problem. Its just basic camera code. Thanks for all your help Moru.

Code (glbasic) Select

X_LOADOBJ "object.ddd", 2 //Insert the name for your object you want to view.

cx = 0
cy = 0
cz = 50
czoom = 50
mx = 0
my = 0

WHILE TRUE
X_MAKE3D 1,2000,45
X_CULLMODE 0
IF MOUSEAXIS(2) = 1
czoom = czoom - 3
ELSEIF MOUSEAXIS(2) = -1
czoom = czoom + 3
ENDIF
mx = mx - MOUSEAXIS(0)
my = my - MOUSEAXIS(1)
IF mx < 0 THEN mx = 360
IF mx > 360 THEN mx = 0
IF my < 0 THEN my = 360
IF my > 360 THEN my = 0
IF my > 270 THEN my = 270
IF my < 90 THEN my = 90
cx = czoom * SIN(mx)
cy = czoom * SIN(my)
cz = czoom * COS(mx)
X_CAMERA cx,cy,cz,0,0,0
X_DRAWOBJ 2, 0
SHOWSCREEN
WEND
Title: Re: Camera Help
Post by: kamakazieturtle on 2009-Apr-15
I didn't feel like making a new topic for this, but does anyone know how to rotate my object along with the camera?
Title: Re: Camera Help
Post by: Schranz0r on 2009-Apr-15
you need X_POPMATRIX and X_PUSHMATRIX
Title: Re: Camera Help
Post by: Kitty Hello on 2009-Apr-16
If you want to rotate your object with the camera, you must X_MOVEMENT, X_ROTATION it accordingly. Usually you do it the other way round: Move your player, and have the camera movve with the object. That's a lot easier.