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 / How to conform object orientation to matrix.

Author
Message
Felon Marmer
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 3rd Nov 2002 14:31
I need to set object rotation of a vehicle to match that of the matrix so it tilts correctly. I get the matrix y value at 4 points around the vehicle location and calculate the tilt angles. How can I set the object angles to match these angles? When I do it the vehicle's orientation varies dependant on the y angle and ends up half submerged.

Here's the code



Any help greatly apreciated.
Felon Marmer
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 3rd Nov 2002 14:33
Oops, forgot to say objects 11 to 14 are cubes at the points just to make sure that part was working.

The Masked Coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location:
Posted: 3rd Nov 2002 22:32
I have open source car physics, which has matrix tilting.

If you havn't seen it yet, it's available for download from my site at

http://www.vapournet.com/maskedcoder/index.html

Felon Marmer
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 4th Nov 2002 11:05
Ta Masked Coder.

I downloaded the file, and the executable version (V6) which works fine, however the open source version won't work when compiled. What version (Patch Number) of DBPro was it written for? I think the rotation commands have changed between patches.

The problem I'm having is with rotation - I need to rotate around axes independantly to match front to back and side to side inclination and heading. However all the rotation commands seem to rotate the previous rotations (if you see what I mean) rather than do them independantly. I think there is a way to do it with quaternions but the maths for that is a little beyond me.

The Masked Coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location:
Posted: 4th Nov 2002 11:20
Hello felon.

Whoops, my mistake.

My open source is actually for DB V.1 and not pro.

As pro is not backwards compatible with DB 1 i'm not surprised it doesnt work.

Sorry.

The move object commands in pro, don't work properlly, so of course using the free flight commands for object rotatiions is a big NO NO.


For matrix tilting, all you need is to use pitch and roll, for alignment, the yaw axis, turn angle is irrelevent.



Felon Marmer
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 4th Nov 2002 15:12
Does that mean you can't do it in DBPro until the rotation commands get fixed?

The Masked Coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location:
Posted: 5th Nov 2002 08:23
Hi felon.

Umm, have to think about that.

Not sure, as i've always used the free flight commands for matrix aligning.

I don't think the x-y-zrotate commands will work either, because they use a static world frame to rotate objects about.

I remember seeing another post on the rgt forums, where someone posted a code snippet for matrix aligning. It was said to be a different technique to most. I would suggest doing a search there. Think it was under code snippets.

http://www.realgametools.net/forums/index.php#1

My current technique, is to work out the surface normal, of the ground under my object, a direction vector, then rotate it by my object yaw axis, then pitch and roll my object by 2 componants of the normal vector, with use of the asin and acos commands.

But i still can't get perfect alignment on steep slopes, seems as though an error crops up, i think it's inaccuracies in the get ground height command i'm using, Would like to see a decent object to matrix align command in pro too, but i digress.

I would suggest visiting other db sites and searching for code snippets on matrix aligning, there should be quite a few out there. A good place to start might be the db web ring.

http://www.lagmaster.net/webring.html

Masked

Felon Marmer
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 5th Nov 2002 11:28
Last night I tried doing it by glueing the vehicle object to the limb of a dummy object. Applying Y-rotation to the dummy and X and Z to the vehicle. This worked but showed up another bug. The glued object vanished when viewed from certain angles, the angle at which you could see the object also decreased the more the object moved away from its starting point. I think I may have stumbled into another bug while avoiding the first one!

The Masked Coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location:
Posted: 5th Nov 2002 20:22
Well, best of luck felon.

Maybe someone else could help here ?

Felon Marmer
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 11th Nov 2002 22:48
After much trial and error I have found a solution.

I made a tank in bits, hull, turret, tracks, gun and saved each as a separate X file. Then each bit was loaded in as a separate mesh and added as limbs to a plain object and then linked Root->Hull->Tracks->Turret->Gun.

Y rotation was done on the dummy, X and Z on the first limb.

The Lemac
21
Years of Service
User Offline
Joined: 12th Nov 2002
Location:
Posted: 12th Nov 2002 21:46
Lee wrote a great example of correctly tilting an object on a matrix in the tank demo.

Thanks to a for loop issue, tank won't load, so I have no idea if DBPRO will do this - I haven't bothered to patch the code to make it work yet... too busy coding my FPS.

If it works, throw up a post!

The Lemac

Login to post a reply

Server time is: 2024-03-28 20:29:08
Your offset time is: 2024-03-28 20:29:08