[SOLVED] Bone manual control and updates

Problems building or running the engine, queries about how to use features etc.
Post Reply
LePawel
Halfling
Posts: 53
Joined: Tue Jan 22, 2013 10:39 am
x 1

[SOLVED] Bone manual control and updates

Post by LePawel »

Hi,
I am currently working on some automated AI/Tank behavior, and I'm currently experiencing a Ogre::Bone related problem.
My scenario is:
I have a rigged tank with a turret bone (TB) and a muzzle bone(MB), which is linked to TB. I am using both to calculate per-frame rotation towards a target scene node.
My problem is that during the second loop after the target has been set, the derived position and orientation of the MB is set to 1.#IND000, and stays that way.
I have read about skeletons and the updates, but I can't figure out when, where or what to call after I rotate the turret.
Both of these have manual control set to true, and all I do at the moment is call TB->roll(angle);
Any help appreciated, If you need any more info ask.

LePawel
Last edited by LePawel on Thu Jun 12, 2014 1:50 pm, edited 1 time in total.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Bone manual control and updates

Post by c6burns »

#IND is indefinite. So you are possible doing math with a NaN in it somewhere? Step through the math in debugger and make sure. This is decent reference material:
http://www.johndcook.com/IEEE_exceptions_in_cpp.html
LePawel
Halfling
Posts: 53
Joined: Tue Jan 22, 2013 10:39 am
x 1

Re: Bone manual control and updates

Post by LePawel »

c6burns wrote:#IND is indefinite. So you are possible doing math with a NaN in it somewhere? Step through the math in debugger and make sure. This is decent reference material:
http://www.johndcook.com/IEEE_exceptions_in_cpp.html
Thanks, never experienced that IND stuff before, lecture was good enough, my 1 of my angle calculation functions was returning 1.#IND because of an uninitialized float, damn those copy constructors. All works now. Now my C&C Gen clone can keep evolving <evil laugh> Overall progress: 0.01%, almost ready by EA standards.
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: Bone manual control and updates

Post by insider »

LePawel wrote:Hi,
I am currently working on some automated AI/Tank behavior, and I'm currently experiencing a Ogre::Bone related problem.
My scenario is:
I have a rigged tank with a turret bone (TB) and a muzzle bone(MB), which is linked to TB. I am using both to calculate per-frame rotation towards a target scene node.
My problem is that during the second loop after the target has been set, the derived position and orientation of the MB is set to 1.#IND000, and stays that way.
I have read about skeletons and the updates, but I can't figure out when, where or what to call after I rotate the turret.
Both of these have manual control set to true, and all I do at the moment is call TB->roll(angle);
Any help appreciated, If you need any more info ask.

LePawel
Any clues as to how you are calculating the angle to hit the target, I am also working on a AI vehicle and mine misses the target by a few meters when the target is far way.
Any help would be great :)
LePawel
Halfling
Posts: 53
Joined: Tue Jan 22, 2013 10:39 am
x 1

Re: Bone manual control and updates

Post by LePawel »

Here's a link to a topic where I figured it out before anyonemanaged to answer :P
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=81004
Once I get the angle, I compare it against a value that I would normally rotate based on FPS and turret turn speed (which is usually 0.xx degrees at few hundred FPS, formula is: turn rate per second * (frame time/1000)), angle from turret to target is smaller than the FPS-based value, I use the remaining angle, and it snaps right at it, and changes state to locked on.
But what you can do if your angle is just slightly off at extreme distances is use the same function (you'd even use the same parameters) as in the link to slightly rotate particles/shells at spawn so they move in the correct direction.
Here's a quick piece to get -180 to 180 values in degrees so you know exactly where to rotate

Code: Select all

Ogre::Real angleDeg = angle.valueDegrees(); //<--- calculated angle from function mentioned
		if(angleDeg > 180)
			angleDeg = (360 - angleDeg) * (-1);
		else if(angleDeg < -180)
			angleDeg = 360 + angleDeg;
P.S, I am currently trying to figure out a solution w/o muzzle bone. I basically need to create a point that's locally offset from the turret bone position/orientation, but I am doing way too much at the same time to remember.
User avatar
insider
Orc
Posts: 462
Joined: Thu Sep 15, 2011 12:50 pm
x 31

Re: Bone manual control and updates

Post by insider »

LePawel wrote:Here's a link to a topic where I figured it out before anyonemanaged to answer :P
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=81004
Once I get the angle, I compare it against a value that I would normally rotate based on FPS and turret turn speed (which is usually 0.xx degrees at few hundred FPS, formula is: turn rate per second * (frame time/1000)), angle from turret to target is smaller than the FPS-based value, I use the remaining angle, and it snaps right at it, and changes state to locked on.
But what you can do if your angle is just slightly off at extreme distances is use the same function (you'd even use the same parameters) as in the link to slightly rotate particles/shells at spawn so they move in the correct direction.
Here's a quick piece to get -180 to 180 values in degrees so you know exactly where to rotate

P.S, I am currently trying to figure out a solution w/o muzzle bone. I basically need to create a point that's locally offset from the turret bone position/orientation, but I am doing way too much at the same time to remember.
Thanks a lot LePawel, I solved it thanks to your help. :D
Kudos to you :D
Post Reply