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 Professional Discussion / Is there a workaround for this?

Author
Message
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 22nd Apr 2003 00:39
I installed the DBPro demo since I am thinking of upgrading from the old DB. Unfortunately something strange happens with the dbpro3 demo. I have some code that changes the orientation of an object by using the commands:
pitch object up objectnum, amount#
turn object left objectnum, amount#
pitch object down objectnum, amount#
turn object right objectnum, amount#

Then later on I use:
oax# = object angle x(objectnum)
oay# = object angle y(objectnum)
oaz# = object angle z(objectnum)

With DBPro, the object's angle never changes with the pitch/turn commands. It changes its angle on the screen, but you cannot seem to retrieve the correct angle after these commands are used. If I call something like YROTATE OBJECT, then oay# will change. This works fine in regular DarkBasic.

Any ideas? I'm stumped.
Thanks,
JS
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 22nd Apr 2003 01:24
Under the original release of DBPro (which is what the demo is based upon) these command sets where independant of each other, although there is a cunning trick around that involving a dummy object and set object orientation.

However under the latest patch I gather this has been resolved, however i've been working on 2D a lot of late and haven't played with the commands to confirm this.

Pneumatic Dryll
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 22nd Apr 2003 02:59
Hmm, well that's too bad. I tried making a dummy object, then calling:

SET OBJECT TO OBJECT ORIENTATION apparatusdummy, apparatus

But even after doing this,
oax#=object angle x(apparatusdummy)
oax# will be 0.

Does anyone know how to do this workaround that Mr. Dryll speaks of?
Thanks,
-JS
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 22nd Apr 2003 03:10 Edited at: 22nd Apr 2003 03:11
it works like this:

oldY=object angle y(objectNo)

set object to object orientation dummyOb,objectNo
turn object right dummyOb,90
set object to object orientation objectNo,dummyOb

newY=object angle y(objectNo)
print oldY;",";newY

So you do all the rotating to the dummy object, and all the reading of co-ordinates on the actual object

Pneumatic Dryll
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 22nd Apr 2003 04:12
Hey thanks for helping, but unfortunately that doesn't work for me either. I made a simple (but cool) program that you can load into db and dbpro and see that it works fine with db and still not with dbpro.
Can you take a look and tell me if I still did it wrong please? No additional media required for my sample, just load and run.

-JS
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 22nd Apr 2003 09:04
Aww come on. This is such an annoying bug. I just want to move on past it. ANYONE HAVE AN IDEA?! Is there another thread I should look at?
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 22nd Apr 2003 09:26
How bout this? Does someone know how I can make my own pitch, turn, and roll object routines using xrotate object, etc.?

Thanks,
JS
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 22nd Apr 2003 10:42
I was using that code for a long time and it can work. I can only assume there's an implementation issue.

Of course half the problem here is the demo is based on such an old version of DBPro that there's really no telling how many bugs are affecting what your doing, luckily Rich & Lee did say they where going to do a new version of the demo, unfortunately they said it wasn't going to be with this version of the patch...

Pneumatic Dryll
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 22nd Apr 2003 10:49
Hi again Pneumatic,
I posted some code above (it showed up as a 'source' button instead of a 'code snippet') and in it I tried to do what you said, but still had no luck. Can you try it out and see if you can spot something that I did wrong? I've tried many combinations, still no luck.

Thanks, *almost* ready to give up.
-JS
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 23rd Apr 2003 00:17
pitch , turn and roll keep oax#,oay# and oaz# unchanged
yrotate object works on object y angle
xrotate object works on object x angle
zrotate object works on world z angle

so...my plane can only fly south ..lol. ( because using zrotate towards north it rolls the object in the opposite direction, and using it pointing east it just affects the pitch)

there s along thread called zrotate object , you may go and have a look..)
workarounds? maybe with 1,000 lines of code..or a DLL
The Wendigo
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 23rd Apr 2003 00:48
The latest patch (Patch 4) DOES fixt the turn object pitch object code 100%!

1.00 GHZ processor, 256 MB RAM, GeForce 3 64MB, SB Live!, 8 cans of soda per day
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 23rd Apr 2003 01:01
Well thanks for the responses everyone. I guess I'll just have to wait until I buy program (or he updates the demo).

Does anyone know offhand how I could calculate pitch turn and roll using sin/cos maths? I mean just make my own fixed pitch, yaw, roll functions using the current OBJECT ANGLE X() and X ROTATE OBJECT etc.

Glad to hear Patch4 fixes it. Did my code above work (camera should hover behind the object at any angle)? The whole dummyapparatus part should be removed if the problem's fixed.

Thanks again for the help.
Joe S.
Check out my friend's cool 3D stuff: http://www.vrman3d.com
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 23rd Apr 2003 01:17
Here s my code for my "only fly south" plane (not refined yet , since zrotate doesn't work as it should i quit it..)

Do
.......
gosub control
move object 9999,speed#
.............
Loop


control:
rem **UP/DOWN**
if downkey()=1
oax#=wrapvalue(oax#-0.2)
xrotate object 9999,oax#
endif
if upkey()=1
oax#=wrapvalue(oax#+0.2)
xrotate object 9999,oax#
endif
rem **TURN LEFT / RIGHT **
if leftkey()=1
xrotate object 9999,0.0
zrotate object 9999,0.0
oay#=wrapvalue(oay#-0.2)
oaz#=wrapvalue(oaz#+0.2)
yrotate object 9999,oay#
zrotate object 9999,oaz#
xrotate object 9999,oax#
endif
if rightkey()=1
xrotate object 9999,0.0
zrotate object 9999,0.0
oay#=wrapvalue(oay#+0.2)
oaz#=wrapvalue(oaz#-0.2)
yrotate object 9999,oay#
zrotate object 9999,oaz#
xrotate object 9999,oax#
endif
return
Muddleglum
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: New Zealand
Posted: 23rd Apr 2003 02:30
Joe Schmoe :- for a full pitch, roll, turn substitute using ordinary xrotate etc, look for kevil's flight sim code.
Sorry can't rememeber what board it was on., heading was 'flight sim code' i think. ... it linked to a board on the american DB site and you could download the whole thing.
That said, it is a large lump of code and involves substantial maths . It looks like a dark basic 'rendition' of what seems to be becoming the 'proper' way to do flight sim code such as i have seen on a few web sites.
If you are good at maths you may be able to extract he heart of the code for your use. (leaving out all the physics parameters.)
Personally i found it almost imcomprehensible (and not perfect in operation when speeded up) and will be staying with the built in roll, pitch turn of DB.( classic)
Hopefully soon i will get to try these commands in db pro .. at least when ALL the comments suggest they have at last been fixed. There seems to be some difference of opinion on this!

cheers.
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 23rd Apr 2003 12:33
Can you provide a link Muddlegum? I can't find anything about it....

Thanks,
-Mr. Joseph J. Schmoe
x-d
Muddleglum
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: New Zealand
Posted: 24th Apr 2003 03:36
Augh .. when i looked more closely - at the end of all the maths, Kevil's flight code still used pitch, roll, turn.
Sorry joseph.

However ... by changing the order of rotation of the 'apparatus' object in your code one can rotate left right and up and down without 'axis interference '
Is this what you were trying to do?

If you really want to try using euler rotations to handle INDEPENDENT roll, pitch and turn ( as in free flight commands) copy and paste the link below into your browser to download the . pdf file ......

http://www.web-discovery.net/aerodynamics/NAPSET2.PDF

About half way through it discusses the matter in some detail.
enough to put me off for ever !
(Note the 'official' flight sim. custom of using 'right handed' cordinates and rotation axes. Z is height ! a PAIN. )


Anyway, here's your code with rotation order changed and just using ordinary rotations. err.. ?? um ??.

sync on
sync rate 60
apparatus = 1
make object box apparatus, 10,10,40
set object rotation zyx apparatus

` make some extra stuff to give perspective to camera
make object cube 3, 40
position object 3, 30,20,200
color object 3, rgb(255,255,0)
make object cube 4, 40
position object 4, 100,20,0
color object 4, rgb(0,0,255)

camspeed# = 20
keyspeed# = 2.0
done = 0
repeat
if KEYSTATE(203)
yrotate object apparatus, wrapvalue( object angle Y(apparatus)- keyspeed# )
holdcamera = 1
else
if KEYSTATE(205)
yrotate object apparatus, wrapvalue(object angle Y(apparatus)+ keyspeed#)
holdcamera = 1
endif
endif

if KEYSTATE(208)
xrotate object apparatus, wrapvalue(object angle x(apparatus)- keyspeed#)
holdcamera = 1
else
if KEYSTATE(200)
xrotate object apparatus, wrapvalue(object angle x(apparatus)+ keyspeed#)
holdcamera = 1
endif
endif

if KEYSTATE(57)
done = 1
endif

text 1,1,"object x angle: "+str$(object angle x(apparatus))
text 1,30,"object y angle: "+str$(object angle y(apparatus))
text 1,60,"object z angle: "+str$(object angle z(apparatus))
if (holdcamera = 0)
cx# = camera position x()
cy# = camera position y()
cz# = camera position z()
cax# = camera angle x()
cay# = camera angle y()
caz# = camera angle z()
aax# = object angle x(apparatus)
aay# = object angle y(apparatus)
aaz# = object angle z(apparatus)
position camera object position x(apparatus), object position y(apparatus), object position z(apparatus)
rotate camera aax#, aay#, aaz#
move camera -200
cx2# = camera position x()
cy2# = camera position y()
cz2# = camera position z()
cx# = CURVEVALUE(cx2#, cx#, camspeed#)
cy# = CURVEVALUE(cy2#, cy#, camspeed#)
cz# = CURVEVALUE(cz2#, cz#, camspeed#)

cax2# = camera angle x()
cay2# = camera angle y()
caz2# = camera angle z()
cax# = CURVEANGLE(cax2#, cax#, camspeed#)
cay# = CURVEANGLE(cay2#, cay#, camspeed#)
caz# = CURVEANGLE(caz2#, caz#, camspeed#)
rotate camera cax#, cay#, caz#
position camera cx#, cy#, cz#
pos$ = "ox: "+str$(aax#)+", oy: "+str$(aay#)+", oz: "+str$(aaz#)
text 1,240,pos$
else
holdcamera = 0
endif
sync
until done
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 25th Apr 2003 02:11
Hi again,

Thanks muddleglum, that is decent, but still won't cut it for the game I'm writing. I'll take a look at the PDF file to see what they have to say. I guess it just amazes me that this is broken in their demo, and amazes me that they never fixed it with a patch or an updated demo. Especially considering that the turn left/pitch up commands work just fine in the original darkbasic.

I could also do it easily with vectors (like I do in C++) but I couldn't find the D3DVectorRotate equivilent in the 3DMaths section of the dbpro help file. Basically you'd just take the current vector of the object, rotate it around it's up vector to turn left right, etc.

Thanks for everyone's input. This is a great forum.

Peace,
-JS, personal friend of VRMan of http://www.vrman3d.com =)
Muddleglum
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: New Zealand
Posted: 25th Apr 2003 05:34
Now you have me curious .. what IS the effect you want?

Do you want the 'apparatus object' to z rotate as well?
I tried and, that can be done with the tank demo ' dummy object, and limb technique ... unfortunately the camera can't follow also z rotated. It has to stay z= 0. or things go badly awry.

?? or even ??????

I am so glad to be still with classic until they get these free flight things sorted out.
BTW , if its just the angles you want for free flight there is another way to get them - as long as the free flight does otherwise work ??? But the method returns the angles relative to the world.

OH well. good luck.
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 25th Apr 2003 11:42
>Now you have me curious .. what IS the effect you want?

Well take the code I posted above and run it with regular dark basic (not pro) to see. And if you want, take out all the apparatusdummy (the attempted workaround) junk and just turn and pitch the apparatus object (silly name in the demo I know, was just copied from some code where it made sense =)

The way it worked, and should work in dbpro, was that you could use the arrow keys to rotate the 3D pointer in a fairly intuitive manner - the camera position helps to make it intuitive since the left arrow key always moves left, and the down arrow key always moves down, etc. Your code above doesn't truely 'turn left' around the up vector of the object which results in very tight little cicles when the object is pitched up to near 90.

>...unfortunately the camera can't follow also z rotated. It has to stay z= 0. or things go badly awry.

With the camera code in my above example you should be able to roll with the camera no problem... Just didn't make a key for it since it wasn't needed.

Rich from db, do you read this forum? Is there a known way to work around this in the demo? I want to finish the game I'm working on! =)

Here, I decided to add the code again with a few edits (including roll) and without the workaround that didn't work...




Thanks,
-JS
fral
23
Years of Service
User Offline
Joined: 5th Mar 2003
Location:
Posted: 25th Apr 2003 20:54
Joe, I had your same problem for my "Triplane Fighters" game (check Retro Game Compo, No. 16).
I tried to use Roll/Pitch/Yaw (Free Flight) rotations in DBpro (demo version) but they didn't work.

They behave as if they were XRotate/YRotate/ZRotate commands, but actually they should be different, because Free Flight rotations are relative to the object's coordinate system, while XYZ are relative to world's coordinate system. In the end you cannot find a workaround for the Free Flight bug just using in some way XYZ rotations.

I also tried using DBPro math functions, but since you can orient your object only using angles (and not vectors and matrices), you can't use results of your math computations (which give you a rotation matrix in the end) to orient your object (at least, I couldn't figure out how to do that).

The only solution I found was to use DB classic (demo) instead.

You have to choose if you prefer to use Free Flight, but not have the more functionality of DBPro (improved graphics effects, etc.), or change your gameplay (not using Free Flight) with DBPro.

Of course there is another solution: buy DBPro and apply patch 4. But what if you discover that patch 4 doesn't fix this bug?

cheers,
fm

Muddleglum
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: New Zealand
Posted: 25th Apr 2003 23:11 Edited at: 26th Apr 2003 03:35
yeeesss.. okay tried in db 113 ... It seems to be that the angles are needed for the camera follow business.
So here is a new idea without angles. The camera rate variable will have to be set with a different approach.
The camera rotation doesn't have the slight 'bounciness' of the original but it's okay.

Till the next attempt !! I edited out the second and this is now the third .... sigh ... muddleglum .




sync on
sync rate 60

apparatus = 1
apparatusdummy = 2
make object box apparatus, 10,10,40

` make some extra stuff to give perspective to camera
make object cube 3, 40
position object 3, 30,20,200
color object 3, rgb(255,255,0)
make object cube 4, 40
position object 4, 100,20,0
color object 4, rgb(0,0,255)

camspeed# = 20
keyspeed# = 2.0
done = 0
color backdrop 0

` start loop startloop startloop startloop startloop startloop startloop
repeat

if inkey$()="r" then rotate object apparatus,0,0,0


if KEYSTATE(203)

turn object left apparatus, keyspeed#
holdcamera = 1
turn#=turn#+keyspeed#
else
if KEYSTATE(205)
turn object right apparatus, keyspeed#
holdcamera = 1
turn#=turn#-keyspeed#
endif
endif

if KEYSTATE(208)

pitch object down apparatus, keyspeed#
holdcamera = 1
pitch#=pitch#+keyspeed#
else
if KEYSTATE(200)

pitch object up apparatus, keyspeed#
holdcamera = 1
pitch#=pitch#-keyspeed#
endif
endif
` roll
if KEYSTATE(54)

roll object left apparatus, keyspeed#
holdcamera = 1
roll#=roll#+keyspeed#
else
if KEYSTATE(157)

roll object right apparatus, keyspeed#
holdcamera = 1
roll#=roll#-keyspeed#
endif
endif


if holdcamera = 0 : `now catch up rotations

roll#=roll#*.93
turn#=turn# *.93
pitch#=pitch#*.93
position camera object position x(apparatus), object position y(apparatus), object position z(apparatus)
set camera to object orientation apparatus
turn camera right turn#
pitch camera up pitch#
roll camera right roll#
move camera -200

else
holdcamera = 0
endif


sync
until done
Muddleglum
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: New Zealand
Posted: 25th Apr 2003 23:19
err .. um assuming DB pro does orient properly to free flight objects ??
My demo version expired ( impossible to use) months ago !!

cheers.
Joe Schmoe
23
Years of Service
User Offline
Joined: 21st Apr 2003
Location:
Posted: 26th Apr 2003 04:31
Thanks for trying. Hey well your code above works the same in regular db but in dbpro does completely bizarre things... Try just turning off the hold camera (instead of if holdcamera =0 just change to something like if 0=0) and it ends up winging the object around at crazy angles.

Anyway guess I'm just gonna have to upgrade. Got an email from Rich and he said he'd look into it and try my code, but that I should expect nothing to work from db to dbpro... And he said they'd update the demo after patch 5... =(((

Login to post a reply

Server time is: 2026-07-11 09:30:17
Your offset time is: 2026-07-11 09:30:17