Hi everyone,
I have this:
(The evil Euler angles strike back )
A cylinder, use as a cannon barrel, on the top of it (initial position), there is a sphere, just put at cylinder.Position.Y + Sphere.radius (= A) and a weldjoint between them.
Rotating the barrel up/down before firing the first sphere is ok (entity move with it and go away when joint is inactivated + impulse applied).
My issue is how do I get the right location of a second sphere to put it on the same spot (B) with rotated barrel (let say angle alpha like on pic) ?
I'm a bit lost between XNA stuff to do the job (according to what I've seen so far, using quaternion and/or using Vector3.Transform method would do the job) and BEPU, which doesn't have the same methods (I guess another way has been chosen in BEPUutilities class). I don't know how to use Barrel.OrientationMatrix in this case.
The initial impulse use in fact thruster code from the demo and it's work just fine: linear impulse is on the expected direction. But I don't know how to do it for spawning a new sphere in the right location, knowing there are in fact two angles (on Z and on Y, as cannon has two degree of freedom), I guess doing the job with one is almost the same on the other.
Any help would be greatly appreciated, and please note I'm not asking for a ready-to-use answer, I would like even more to get just good clues and some exercises to do myself and try to reach the solution.
Thanks.
HELP: get position after rotate an entity
Re: HELP: get position after rotate an entity
Something like barrel.Position + barrel.OrientationMatrix.Up * (barrelHeight * 0.5) would work.
That is equivalent to barrel.Position + Matrix3x3.Transform(Vector3.Up, barrel.OrientationMatrix) * (barrelHeight * 0.5). Rotation matrices have the nice property that you can directly pull the three main axes out of their components, bypassing all the operations it would take to transform a vector.
That is equivalent to barrel.Position + Matrix3x3.Transform(Vector3.Up, barrel.OrientationMatrix) * (barrelHeight * 0.5). Rotation matrices have the nice property that you can directly pull the three main axes out of their components, bypassing all the operations it would take to transform a vector.
Re: HELP: get position after rotate an entity
Thanks a lot, it almost did it .Norbo wrote:Something like barrel.Position + barrel.OrientationMatrix.Up * (barrelHeight * 0.5) would work.
That is equivalent to barrel.Position + Matrix3x3.Transform(Vector3.Up, barrel.OrientationMatrix) * (barrelHeight * 0.5). Rotation matrices have the nice property that you can directly pull the three main axes out of their components, bypassing all the operations it would take to transform a vector.
What's work in my case is:
Code: Select all
Barrel.Position + Barrel.OrientationMatrix.Up * (4.5f)
Is there any way to get entity size related data for base shapes ? Or do we have to manage the data ourselves (for example: stored in entity tag, not very the best way but still better than global variables I guess) ?
Re: HELP: get position after rotate an entity
If you have a reference to a CollisionShape and you know it's a e.g. BoxShape, you could cast it to a BoxShape and then read its dimensions. Same goes for the other types. If you want a slightly more general and approximate representation of a shape's size, you could use EntityShape.GetBoundingBox.
If you're wondering how to get the Shape associated with an entity, it's stored in the Entity.CollisionInformation.Shape property.
If you're wondering how to get the Shape associated with an entity, it's stored in the Entity.CollisionInformation.Shape property.