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 / QuatMath.dll and set object keyframe x,y

spt games
Years of Service
User Offline
Joined: 14th Apr 2009
Location: United Kingdom
Posted: 31st Mar 2013 16:19 Edited at: 31st Mar 2013 16:30
Back here again after a long hiatus (due to studying and lack of time to code for fun), but now back to make a 3D rail shooter .

I have read through the DBC Tutorials.doc that Latch put together and understand the issue DBC has with 3D animations where the angle passes through 120 degrees (Unfortunately the math is beyond my understanding).

Anyway, I was wondering if it is possible to use QuatMath.dll to correct the angles generated by set object keyframe . I understand I could just use zrotate object to achieve the same effect as what I am doing in my code, but I was thinking of using angle correction in general with "set object keyframe".


Login to view attachments
Years of Service
User Offline
Joined: 23rd Jul 2006
Posted: 2nd Apr 2013 00:49
Hello, spt games,

I'm not at my computer at the moment so I can't look at or test any code. It's been a while since I looked at QuatMath.dll. I believe RobertTheRobot created that dll in delphi so I can't comment on it either at the moment.

However, I can tell you the concept. The problem exists within set object keyframe as well, and I don't know if there is an immediate angle correction solution using that command on a single limb. A quick fix might be to use 2 or more joints per limb.

For example, you have an arm attached to a shoulder. Create a shoulder joint and make sure that where the arm attaches to the should it has a pivot point at exactly the same place as the shoulder joint's pivot. If you want to rotate the arm up 180 degrees, you rotate the shoulder 90 and then the arm 90. This avoids the single rotation above 119 degrees that sends the limb rotating in the opposite direction.

You'd apply this "extra limb" technique to anywhere where you know you'll need to rotate past 119 degrees.

There are a couple of other approaches:

One is to rotate the limbs directly by cycling through values say, in an array. The problem here is that the rotate limb command is dreadfully slow when not applied sparingly. So trying to animate an entire humanoid character running or something can take up a lot of processing time using that method. If it's a few rotations here and there for a couple of limbs, then no big deal.

Another, is to convert the euler rotations to quaternions, attach the quaternions as a direct x animation key set to an X file, and then run the animations using PLAY OBJECTS or LOOP OBJECT. The animations will play correctly if the keyframes are coded correctly in the direct X file.

Another method which can be a little faster than the first method but maybe slower than the second method is to create a series of meshes of the different frames (not necessarily the key frames)of the animated object. Then using CHANGE MESH (maybe it's change object) cycle through the different mesh frames. This technique can also be used to create the illusion of skeletal animation.

The double/triple limb thing would probably do the trick most of the time without too much effort and you could still use the SET OBJECT KEYFRAME command for that. You don't need to use a lot of polygons for creating the joints. You could just use tiny trianlges or planes to keep the polygon count low and keep the joints out of sight. I can't remember if limbs rotate properly if hidden so I'm assuming the joints would have to be visible (but you could test that).

Enjoy your day.
spt games
Years of Service
User Offline
Joined: 14th Apr 2009
Location: United Kingdom
Posted: 6th Apr 2013 19:39
Wow! Thank you for the detailed explanation . I appreciate the time you have taken to explain this subject. This will be useful to know for any 3D projects that I do in DBC.

Thanks again

Login to post a reply

Server time is: 2020-08-05 09:19:08
Your offset time is: 2020-08-05 09:19:08