3D Animation Rotating and Translating simultaneously in WPF -


i have modelvisual3d of cube. want translate , rotate @ same time. wish center of rotation in middle of cube(the cube rotates around own axis). when try applying both transformations effect not expect. since object translating center of rotation different making move , rotate in strange way. how desired effect?

transform3dgroup transgroup = new transform3dgroup();  doubleanimation cardanimation = new doubleanimation(); cardanimation.from = 0; cardanimation.to = 3; cardanimation.duration = new duration(timespan.fromseconds(2));  transform3d transform = new translatetransform3d(0,0,0); transgroup.children.add(transform);   rotatetransform3d rotatetransform = new rotatetransform3d(); axisanglerotation3d rotateaxis =    new axisanglerotation3d(new vector3d(0, 1, 0), 180); rotation3danimation rotateanimation =    new rotation3danimation(rotateaxis, timespan.fromseconds(2)); rotateanimation.decelerationratio = 0.8;  transgroup.children.add(rotatetransform);   model.transform = transgroup;  transform.beginanimation(translatetransform3d.offsetxproperty,    cardanimation); rotatetransform.beginanimation(rotatetransform3d.rotationproperty,    rotateanimation); 

apply rotation first , translation. ensure cube rotates correct point - it's centre, , gets translated.

what meant reverse order you're applying transformations. matrix multiplication not commutative you'll different results depending on order apply transform.

it might easier update matrices , reapply complete transformation rather applying delta each time.


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -