Tokomak's GetPos and GetRotationQ returning QNAN

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
ChrML
Posts: 30
Joined: Sun Oct 03, 2004 2:45 pm
Location: Norway

Tokomak's GetPos and GetRotationQ returning QNAN

Post by ChrML »

I've integrated Tokamak with my game. I've coded a system for physical elements (consisting of geometries) and a system that loads physical terrains into tokamak.

It works quite well, but sometimes Tokamak's GetPos and GetRotationQ manages to return me a position and a quaternion full of ##QNAN00's. Either all the values returned from both functions fail and have that value, or none of them have and it works perfectly. It works up to a random point where it happens, causing the scenenode that I update the Tokamak position to to disappear or flicker. It happens mainly after the physical cube for example has collided with an another cube or the terrain, but not always.

I've been stuck with this problem for a while and I haven't really been able to figure it out. What might cause this?

I figured one possible reason was feeding SetRotation (quat) at the beginning of the simulation with a wrong number (I'm not good at quaternions). I'm unsure on the code that sets the rotation once at the beginning when it is created, but it came up with a quaternion looking like this: 0,0,0,1. Is that a correct quaternion that won't cause problems with the physics later?

I've checked about every thing I can think of. Any ideas?

Oh, and I would've asked on the Tokamak forum if it wasn't for that bots have spammed it all down with porn. Not quite sure if I have any useful code to paste... It all works until it doesn't (NaN), and I have quite a lot of code.

Thanks in advance!
drac_gd
Posts: 132
Joined: Sun Apr 09, 2006 8:43 pm

Post by drac_gd »

I am not sure but I think it might be a result of divide by zero error. Sorry I know nothing about Tokamak so I cant be much help but I would look for zero float values where they shouldnt be zero
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

Post by zenaku »

You may need to call CreateDeviceEx() and set HighPrecisionFPU to true in the SCreationParameters if using DirectX. DirectX is known to clobber the FPU. You also might want to mess with FPU precision settings in the project's C++ -> code generation settings. And like drac_gd says, it's most likely a div by zero error. It might be easiest to find the bug by turning on the enable FPU exceptions flag.
-------------------------------------
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
Post Reply