Thursday, 15 January 2015

c# - Rotation over time in 3D -



c# - Rotation over time in 3D -

im working xna 4, doing game have game object (spaceship) moves in 3d world on y axis = 0 plane.. aka 2.5d..

until used complex angle calculation create rotation between 2 vectors, yet algorithm lacks ability take business relationship object rotated. results funkey.. hence hoping someone, show me smart , implementable way utilize matrices , vector math, such rotation on time thingy.

what noticed in previous searches, people have next variables in object classes: - position vector3 - right vector3 - vector3 - rotation matrix - transformmatrix matrix - velocity vector3 - etc..

often inquire myself why needed have many variables simple current position.. or maybe im not understanding.. anyways..

i have position, rotation , transformsmatrix currently, , know else need , how calculate it, , how implement rotation on time.

the method called right-click motion command trig sends vector3 position on y = 0 plane of click happened.

public void movecommand(vector3 pos){ }

ive tested this, , "pos" given accurate. help apreciated ..

you should check matrix.createrotationx y or z acording rotation want. x,y or z axis of rotation, if take y see "2d" rotation (yaw) because axis using depth. if take x or z axis see "3d" rotations (pitch , roll)

the code should this:

worldmatrix = rotations * translation

where rotations = matrix.createrotationx(angleradians) , translation = matrix.createtranslation(position);

the world matrix matrix affecting model, view , projection depends on camera

now if want know angle between vectors should check dot product or atan2 function because in 2d

c# xna rotation

No comments:

Post a Comment