Sign in to follow this  

More Turret Rotation Woes

This topic is 1511 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All.

I rotate my turrets based of how the animation manager does is if it was exported with the animation. This works fine when there is no

turrets on top of another turret Like this image here. Its shooting at a target the main big turret is pointing at it but the small one on top is out. Ther small turret looks like its out by the amout the main turret is rotated to face target.

 

Any Ideas how to update my matrix now.

the turrets are pointing to the front of the vehicle when exported

and the small turrets base bone is linked to the main turrets base bone so it should be offset correct.

 

Image....

 

this is how Im doing it in code;

//make a rotation matrix
D3DXMatrixRotationX(&mSpin, D3DXToRadian(TurretCurrentAngle[ctr]));

//animation manager does this
//Anim->m_Bone->TransformationMatrix *= mInvBindPose;// matRotation;

D3DXMatrixIdentity(&temp);

temp *= mSpin;
temp *= FrameTurretBase[ctr]->TransformationMatrix;

FrameTurretBase[ctr]->TransformationMatrix = temp;
		
//end turret base

//now do the elevation rotation axis is  X elevation and Z Spin
		
//make the elevation rotation
		
D3DXMatrixRotationY(&mSpinElevation, D3DXToRadian(TurretCurrentElevationAngle[ctr]));

	       
D3DXMatrixIdentity(&temp);

temp *= mSpinElevation;
temp *= FrameTurretElevation[ctr]->TransformationMatrix;
		FrameTurretElevation[ctr]->TransformationMatrix = temp;//
	
	
//end elevation
///////////////////////////////////////////////////////////////////////////////////////////////

Share this post


Link to post
Share on other sites

My guess is that if the small turret is linked to the larger turrets bone or rotation then u would have to subtract the rotation of the main gun when u want to rotate it independently.

 

Or you can link the smaller turret to the root of the tank this way you can rotate it independently.

Edited by JacobM

Share this post


Link to post
Share on other sites

I know whats happening now the small turret inheritance the main turrets rotation as well as its own rotation.

How would the the app know when the turrets are linked(to root bone or a turret base bone) like so because some turrets would be linked to otheres and some not.

 

The only way I can think of is in the asset manager for each vehicles turret set a flag to true if it inheritance from another turret

 

but that would only work for the two turrets if shooting at the same target.

 

Is the a mathematical way to do this.

Share this post


Link to post
Share on other sites

Ok. I think its working 100% now, said that a couple of times now lol.

 

I went with the flag idea now when you create a vehicle type in the assetmanager you set a flag when you load the mesh.

if that turret has a turret on top. This allows the vehicle to have turrets any where on the vehicle and turrets on top of them anywhere aswell.

that was a lot of work for such a small affect. It was fun but THANKS ALL.

 

then in the first post's code, I use this flag like so

 

//if this turret inheritance is true then we dont add the spin

//only if where shooting meaning we have a target

if(targetobj)

{

 

//if we have no Inheritance then add the spin. turret is randomly spinning(Idel turret)

 

      if(TurretInheritance[ctr] == false)

      temp *= mSpin;

}

else//if we are not attacking then where Idel so add the spin

     temp *= mSpin;

 

temp *= FrameTurretBase[ctr]->TransformationMatrix;

FrameTurretBase[ctr]->TransformationMatrix = temp;

 

 

 

Share this post


Link to post
Share on other sites

This topic is 1511 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this