Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / 3D rolling / pitching problem

Author
Message
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 19th Mar 2007 11:28
Hi All, I'm having major problems with pitching / rolling combinations and was wondering if anyone can help. Picture the problem like this. The camera is fixed and I can make a ship speed up, slow down , turn left and right and roll (of coursing moving closer, away or even off screen depending on speed and angle etc), but its all with the Y-plane set constantly to zero (this was my stage 1). THe ship moves fine and looks ok. Then I tried allowing for pitch and hence a true 3D environment but its all gone pearsheaped. Picture the ship moving away from the camera (zero turn and zero roll), then rolls 45 degree to the right. Ok so far so good but when I pitch up it should pitch up at 45 degrees diagonally to the right not straight up which is whats happening. I'm sure the problem is probably solved with Cos and Sin functions but its been too long since I did trigonomatry? Can anyone help with this?

Thanks.
Ankillito
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 20th Mar 2007 04:10
Code is worth a thousand attempted explainations.

"There will always be evil, for, without evil, the good shall lose their virtue."
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 20th Mar 2007 05:11
It is indeed but where is it
Quisco DaLuse
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: USA
Posted: 20th Mar 2007 14:13
I think Ankillito is expecting you to post your code so that everyone can see exactly what your program is doing. Assuming you have media for the program, it will be needed too. Also, are you using DBC or DBP?

You idiots! You've captured their stunt doubles!
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 20th Mar 2007 23:08 Edited at: 21st Mar 2007 04:22
Ah sorry. Here is the code (DBC)...

DO

IF LEFTKEY()=1 THEN Turn#=Turn#-4.0
IF RIGHTKEY()=1 THEN Turn#=Turn#+4.0
IF UPKEY()=1 THEN Pitch#=Pitch#-4.0
IF DOWNKEY()=1 THEN Pitch#=Pitch#+4.0
Turn#=wrapvalue(Turn#)
Pitch#=wrapvalue(Pitch#)
if inkey$()="," then roll = roll +4
if inkey$()="." then roll = roll -4
if inkey$()="s" then SPD# = spd# + 0.01
if inkey$()="x" then SPD# = spd# - 0.01
if roll <0 then roll = 356
if roll >360 then roll = 4

x#=NEWXVALUE(x#,Turn#,SPD#)
y#=NEWZVALUE(y#,pitch#,SPD#)
z#=NEWZVALUE(z#,Turn#,SPD#)

POSITION OBJECT 1,x#,y#,z#
YROTATE OBJECT 1,Turn#
ZROTATE OBJECT 1,roll
XROTATE OBJECT 1,pitch#

SYNC

LOOP
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 5th Apr 2007 06:00
Sorry for sounding impatient but can any one help? (I've tried the roll object right and left commands but it doesnt work correctly)?
Cloggy
21
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 5th Apr 2007 15:15 Edited at: 5th Apr 2007 15:23
You should use the commands:-

Roll object
Pitch object
turn object

Rather than X,Y, & Z rotate object.



Cheers,

Cloggy
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 5th Apr 2007 15:49
Thanks but I've already tried the roll command.
Lucy
19
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 19th Apr 2007 20:38
Are you having problems where it appears to get stick once you try to rotate past straight up or down? If so, then it's a gimble locking problem. I'd suggest googling it. Gimble locking is a major pain in the neck.

Login to post a reply

Server time is: 2026-07-05 18:37:50
Your offset time is: 2026-07-05 18:37:50